Re: DTD Parsing

2010-11-10 Thread r0g
On 10/11/10 23:18, Christian Heimes wrote: Am 10.11.2010 04:36, schrieb Asun Friere: Yes but configuration files are not necessarily meant to be edited by humans either! Yeah, you are right. I'm sorry but every time I read XML and configuration in one sentence, I see the horror of TomCat or Sh

Re: DTD Parsing

2010-11-10 Thread r0g
On 10/11/10 20:38, Ian wrote: On Nov 10, 1:05 am, r0g wrote: That's five whole lines of code. Why go to all that trouble when you can just do this: import config Heh, mainly because I figure the config module will have a lot more options than I have use for right now and therefore the docs

Re: DTD Parsing

2010-11-10 Thread Steve Holden
On 11/10/2010 10:07 PM, Lawrence D'Oliveiro wrote: > In message , Ian Kelly > wrote: > >> > On 11/9/2010 11:14 PM, r0g wrote: >>> >> >>> >> config = {} >>> >> for line in (open("config.txt", 'r')): >>> >> if len(line) > 0 and line[0] <> "#": >>> >> param, value = line.rstrip().split("

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
In message , Ian Kelly wrote: > On 11/9/2010 11:14 PM, r0g wrote: >> >> config = {} >> for line in (open("config.txt", 'r')): >> if len(line) > 0 and line[0] <> "#": >> param, value = line.rstrip().split("=",1) >> config[param] = value > > That's five whole lines of code. Wh

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
In message , Christian Heimes wrote: > I'm sorry but every time I read XML and configuration in one sentence, I > see the horror of TomCat or Shibboleth XML configs popping up. Tomcat I know is written in Java; let me guess—Shibboleth is too? -- http://mail.python.org/mailman/listinfo/python-li

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
In message , Christian Heimes wrote: > Don't repeat the mistakes of others and use XML as a configuration > language. XML isn't meant to be edited by humans. My principle is: anything automatically generated by machine is not fit for viewing or editing by humans. There’s nothing special about X

Re: DTD Parsing

2010-11-10 Thread Christian Heimes
Am 10.11.2010 04:36, schrieb Asun Friere: > Yes but configuration files are not necessarily meant to be edited by > humans either! Yeah, you are right. I'm sorry but every time I read XML and configuration in one sentence, I see the horror of TomCat or Shibboleth XML configs popping up. -- http:

Re: DTD Parsing

2010-11-10 Thread Stefan Behnel
Felipe Bastos Nunes, 10.11.2010 13:34: Does any, libxml2 or lxml, collect children like jdom does in java? List children = myRoot.getChildren(); Bah, that's *so* Java. ;) ElementTree and lxml.etree do it like this: children = list(myRoot) lxml also supports XPath and lots of other

Re: DTD Parsing

2010-11-10 Thread Ian
On Nov 10, 1:05 am, r0g wrote: > > That's five whole lines of code. Why go to all that trouble when you can > > just do this: > > > import config > > Heh, mainly because I figure the config module will have a lot more > options than I have use for right now and therefore the docs will take > me lo

Re: DTD Parsing

2010-11-10 Thread Felipe Bastos Nunes
I'll look at the options. But anyway, only to give an example of the configs I told, the ShoX project (at sourceforge.net) has xml as config files. I'm not talking about common users to edit the xmls, it's about the developer edit them :-) I'm working in a python wireless sensor network simulator,

Re: DTD Parsing

2010-11-10 Thread Asun Friere
On Nov 10, 5:00 pm, Stefan Behnel wrote: > Give lxml.objectify a try. It doesn't use DTDs, but does what you want. Yes I should take the time to familiarise myself with the lxml API in general. I mostly use libxml2 and libxslt nowadays. For simple stuff (like this) I use a StateParser which is

Re: DTD Parsing

2010-11-10 Thread Asun Friere
On Nov 10, 6:36 pm, Ian Kelly wrote: > That's five whole lines of code.  Why go to all that trouble when you > can just do this: > > import config > > I kid, but only partially.   For myself, generally because I only become aware of the module, or the module is only written after I written some

Re: DTD Parsing

2010-11-10 Thread r0g
On 10/11/10 07:36, Ian Kelly wrote: On 11/9/2010 11:14 PM, r0g wrote: Me too when possible, TBH if I only needed strings and there was no pressing security issue I'd just do this... config = {} for line in (open("config.txt", 'r')): if len(line) > 0 and line[0] <> "#": param, value = line.rstri

Re: DTD Parsing

2010-11-09 Thread Ian Kelly
On 11/9/2010 11:14 PM, r0g wrote: Me too when possible, TBH if I only needed strings and there was no pressing security issue I'd just do this... config = {} for line in (open("config.txt", 'r')): if len(line) > 0 and line[0] <> "#": param, value = line.rstrip().split("=",1) config[param] = valu

Re: DTD Parsing

2010-11-09 Thread r0g
On 10/11/10 03:36, Asun Friere wrote: On Nov 10, 2:02 pm, Christian Heimes wrote: Am 10.11.2010 03:44, schrieb Felipe Bastos Nunes: I'd like to know too. I work with java and jdom, but I'm doing personal things in python, and plan to go full python in the next 2 years. Xml is my first option

Re: DTD Parsing

2010-11-09 Thread Stefan Behnel
Asun Friere, 10.11.2010 06:41: On Nov 10, 4:11 pm, Stefan Behnel wrote: What's your interest in parsing a DTD if you're not up to validating XML? Spitting out boilerplate code. [...] A few years back I used a similar technique to write some boiler plate python code where xml was isomorphicall

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 4:11 pm, Stefan Behnel wrote: > What's your interest in parsing a DTD if you're not up to validating XML? Spitting out boilerplate code. Just at the moment I'm creating a stub XSLT sheet, which creates a template per element (from a 3rd party DTD with 143 elements, yuk!) containing n

Re: DTD Parsing

2010-11-09 Thread Stefan Behnel
Asun Friere, 10.11.2010 04:42: On Nov 10, 2:02 pm, Christian Heimes wrote: Back to the initial question: I highly recommend LXML for any kind of XML processing, validation, XPath etc. Sorry Christian, didn't realise at first that that was a response to MY intial question. But does lxml actua

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 2:02 pm, Christian Heimes wrote: > Back to the initial question: I highly recommend LXML for any kind of > XML processing, validation, XPath etc. Sorry Christian, didn't realise at first that that was a response to MY intial question. But does lxml actually have something for parsing

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 2:02 pm, Christian Heimes wrote: > Am 10.11.2010 03:44, schrieb Felipe Bastos Nunes: > > > I'd like to know too. I work with java and jdom, but I'm doing > > personal things in python, and plan to go full python in the next 2 > > years. Xml is my first option for configuration files and

Re: DTD Parsing

2010-11-09 Thread Christian Heimes
Am 10.11.2010 03:44, schrieb Felipe Bastos Nunes: > I'd like to know too. I work with java and jdom, but I'm doing > personal things in python, and plan to go full python in the next 2 > years. Xml is my first option for configuration files and simple > storages. Don't repeat the mistakes of other

Re: DTD Parsing

2010-11-09 Thread Felipe Bastos Nunes
I'd like to know too. I work with java and jdom, but I'm doing personal things in python, and plan to go full python in the next 2 years. Xml is my first option for configuration files and simple storages. 2010/11/10, Asun Friere : > Now that PyXML (and thus xmlproc) is defunct, does anyone know a

DTD Parsing

2010-11-09 Thread Asun Friere
Now that PyXML (and thus xmlproc) is defunct, does anyone know any handy modules (apart from re :) for parsing DTDs? -- http://mail.python.org/mailman/listinfo/python-list