Yaml.unsafe_load error

2022-10-19 Thread Albert-Jan Roskam
Hi, I am trying to create a celery.schedules.crontab object from an external yaml file. I can successfully create an instance from a dummy class "Bar", but the crontab class seems call __setstate__ prior to __init__. I have no idea how to solve this. Any ideas? See code below. Tha

xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
Hi all, For the impatient: Below the longish text is a fully self-contained Python example that illustrates my problem. I'm struggling to understand xml.etree's handling of namespaces. I'm trying to parse an Inkscape document which uses several namespaces. From etree's documentation: If the

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
I mean, it's worth to look at BeautifulSoup source how do they do that. With BS I work with attributes exactly as you want, and I explicitly tell BS to use lxml parser. Axy. On 19/10/2022 14:25, Robert Latest via Python-list wrote: Hi all, For the impatient: Below the longish text is a fully s

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Jon Ribbens via Python-list
On 2022-10-19, Robert Latest wrote: > If the XML input has namespaces, tags and attributes with prefixes > in the form prefix:sometag get expanded to {uri}sometag where the > prefix is replaced by the full URI. > > Which means that given an Element e, I cannot directly access its attri

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
I have no idea why, I used to remove namespaces, following the advice from stackoverflow: https://stackoverflow.com/questions/4255277/lxml-etree-xmlparser-remove-unwanted-namespace _ns_removal_xslt_transform = etree.XSLT(etree.fromstring('''     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Re: Yaml.unsafe_load error

2022-10-19 Thread Albert-Jan Roskam
On Oct 19, 2022 13:02, Albert-Jan Roskam wrote:    Hi,    I am trying to create a celery.schedules.crontab object from an external    yaml file. I can successfully create an instance from a dummy class "Bar",    but the crontab class seems call __setstate__ prior

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
Jon Ribbens wrote: > That's because you *always* need to know the URI of the namespace, > because that's its only meaningful identifier. If you assume that a > particular namespace always uses the same prefix then your code will be > completely broken. The following two pieces of XML should be unde