[lxml-dev] [objectify] __MATCH_PATH_SEGMENT regexmodificationsuggestion
Holger Joukl
Holger.Joukl at LBBW.de
Wed Feb 21 15:03:02 CET 2007
Hi,
just noticed this has probably gone down and wanted to bring it up
once more:
I suggest to loosen the __MATCH_PATH_SEGMENT regex a little
to care for more possible element names, which are sometimes
outside of my control.
Currently ObjectPath chokes on paths like 'root.a-x.a-y'.
While such names are often inconvenient at best I found that
python itself is quite non-restrictive wrt attibute names:
python2.4
Python 2.4.3 (#2, Nov 20 2006, 16:26:48)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
... pass
...
>>> setattr(Foo, 'a-b', "hmm")
>>>
Also, such names are actually allowed:
>>> etree.tostring(etree.fromstring("""<a-a><b>34</b></a-a>"""))
'<a-a><b>34</b></a-a>'
>>>
"Holger Joukl" <Holger.Joukl at LBBW.de> schrieb am 02.01.2007 14:56:05:
> "Holger Joukl" <Holger.Joukl at LBBW.de> schrieb am 29.12.2006 16:16:12:
>
> > I suggest to loosen the __MATCH_PATH_SEGMENT regex a little
> > [...]
>
> Sorry that was too loose as it destroys the correct matching of the
> index part; it should read
>
> __MATCH_PATH_SEGMENT = re.compile(
>
r"(\.?)\s*(?:\{([^}]*)\})?\s*([^.{}\[\]]+)\s*(?:\[\s*([-0-9]+)\s*\])?",
> re.U).match
>
> (Changed: (([^.{}\[\]]+) replaces (\w+))
Holger
Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.
The contents of this e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail. Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.
Landesbank Baden-Württemberg
Anstalt des öffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim
More information about the lxml-dev
mailing list