> From: Rinat Yangurazov

> Sent: Sunday, June 30, 2013 7:17 AM
> 


> Hello David,
> 
> Found gends_user_methods.py source file here:
> https://raw.github.com/botondus/generateds/master/gends_user_methods.py
> I will check it out today; will appreciate your comments for other
> items.

Rinat -

Great.  Glad you found it.

I've added a couple more comments below.


> 
> Thanks!
> 
> Rinat
> 
> -----Original Message-----
> From: Rinat Yangurazov
> Sent: Sunday, June 30, 2013 1:16 AM
> To: 'Dave Kuhlman'
> Subject: RE: using generateDS.py with XMLSchema.xsd ?
> 
> Hello David,
> 
> I have just started to look into other comments you provided other
> day.  Since there are few things I wanted to follow-up with on you I
> decided to itemize those comments.
> 
> So here they are:
> 
> 1. First of all, version 2.10a worked with suggested for all xsd
>    files I used. Here is sample syntax I used in the script:
> 
>        /opt/python2.7/bin/generateDS.py --silence -f -o
>        XMLSchemaSup.py -s XMLSchemaSub.py --super="XMLSchemaSup"
>        --member-specs=dict --export="write etree literal"
>        XMLSchema.xsd
> 
> 2. The crux of this section 12.9
>    (http://pythonhosted.org/generateDS/#user-methods is all around
>    gends_user_methods.py.  But unfortunately corresponding link is
>    not working
>    (http://pythonhosted.org/generateDS/gends_user_methods.py =>
>    404).  And the only gends* files I found on the system are these:
> 
>         gends_extract_simple_types.py
>         gends_run_gen_django.py
>         gends_generate_django.py
> 
> 3. In regards to these comments (which I think is part of item 2,
>    but let's have it separate since I'm might be missing something
>    here):
>    
>        Then add a method to the superclass (GeneratedsSuper) that
>        you can call to produce a list of the members (children) of each
>        element.  Note that the generated code will attempt to load that
>        superclass from another file if you want it to.  See the code at
>        the top of class GeneratedsSuper in the generated file (or look
>        at the doc) to learn how to do that.  Also note that there is a
>        list of the names of generated classes at the end of each
>        generated superclass file.  See variable __all__.
> 
>    If I follow section 12.9 correctly, "--member-specs=dict"
>    generated dictionary then can be used to expand GeneratedsSuper

Yes.  I do not know your specific needs, but, you definitely could
add code to GeneratedsSuper that used the information generated by
--member-specs=dict.  It sounds to me that you are on the right
track here.  Also note that the generated info (in
member_data_items_) has a description of each item in an element.
If you have not already found it, look at the definition of class
MemberSpec_ in your generated code for clues about what information
you can get from it.

> 
> 4. Sphinx notes are referring to version 2.10b:
> 
>        ... You can read
>        about it in the following files, which are in the generateDS.py
>        distribution file:
> 
>         generateDS-2.10b/librarytemplate_howto.txt
>         generateDS-2.10b/librarytemplate-1.0a.zip
> 
>    The latest version I was able to find is 2.10a (pip install
>    --upgrade & https://pypi.python.org/pypi/generateDS/2.10a) I have
>    not checked https://bitbucket.org/dkuhlman/generateds though.
>    How stable is it and how soon you are planning to release it?

I have delayed making a numbered release out of the latest code
(which is also at Bitbucket) in order to see if there are additional
changes that we might want to make.  Perhaps, after we've found out
whether things are working well enough for you, then I'll turn it
into a new release, probably 2.10b.

> 
> 5. I think that this related to item 2, but let's mention it as a
>    separate item: But, if generateDS.py and the code it generates
>    does *not* do what you need, then you might consider writing a
>    Python script that uses xpath to search for the and extract
>    information that you want to expose.  Note that Lxml
>    (http://lxml.de/) supports xpath.
> 
>    I took a look at it and I would like to focus on the single
>    solution and so far (except item 3 :) ) I have happy with it.
> 
> 6. One more idea came to my mind.  I have 2 versions of the same
>    xsd file and would like to see what has changed between version
>    1 and version 2.  I think that solution for item 2 should do
>    it.  But I'm thinking if there is some Python-ic way to run
>    class comparison between 2 sets of generated libraries.

Using something along the lines of an added method in
GeneratedsSuper which used the information in member_data_items_
sounds quite Pythonic to me.  Maybe the code could use hasattr and
getattr builtin functions, or if that is not powerful enough, the
"inspect" module.  And, don't forget the __all__ variable at the end
of the file that contains a list of the names of generated modules.

But, you might also be interested in xmldiff:

    http://www.logilab.org/project/xmldiff

On, my Ubuntu Debian GNU/Linux machine, it is installable with
apt-get, the package management tool.  It's Python code, so it
should be easy for you to install from source.  I have not tried it,
but perhaps I should.

I just tried xmldiff.  I haven't figured it out completely yet, but
it looks like it could be useful.  Your plan seems more powerful for
custom uses, but still, it good to have some possible options.

The version of xmldiff at the Python Package Index
(pypi.python.org), by the way, seems out of date.

> 
> Many thanks for all your help and support and for keeping
> development of the package going.

You are welcome.  And, your comments, questions, and suggestions
have been a real help.  So, thanks for your time and effort on that.

- Dave

> 
> Hope to hear from you soon.
> 
> Best regards,
> 
> Rinat
> 
> -----Original Message----- From: Dave Kuhlman
> [mailto:dkuhl...@rexx.com] Sent: Monday, June 24, 2013 3:39 PM To:
> Rinat Yangurazov; generateds-users@lists.sourceforge.net Subject:
> Re: using generateDS.py with XMLSchema.xsd ?
> 
> > From: Rinat Yangurazov
> 
> > Sent: Monday, June 24, 2013 11:36 AM
> >
> 
> > Hello Dave,
> >
> > I hope all goes well with you.
> >
> > It looks like I finally got some cycles to focus more on
> > generateDS.  Last year I got some mileage with generateDS while
> > using it for smaller projects and it helped a lot.  This time
> > around I would like to use generateDS generated libraries for a
> > bigger solution.  But unfortunately, version 2.9a hit the same
> > issue related to the ability to work with XMLSchema.xsd (please
> > see below).
> 
> Rinat -
> 
> Thanks for the report.
> 
> The latest version of generateDS.py seems to be able to
> successfully generate output, although I do not have a way to test
> whether the generated files are usable.  I was able to import the
> generated files, so at least they are syntactically correct.
> 
> I obtained XMLSchema.xsd from this location:
> http://www.w3.org/2001/XMLSchema.xsd
> 
> Is that the version that you are using?
> 
> I generated this output with the following bash script:
> 
>     #!/bin/bash ./generateDS.py \ -f \ -o $1sup.py -s $1sub.py \
>     --super $1sup \ --member-specs=list \ --export="write etree
>     literal" \ XMLSchema.xsd
> 
> I used this command:
> 
>     $ ./run_test tmp01
> 
> I've attached this copy of generateDS.py (and process_includes.py
> also, in case it has changed).  You can also get it from
> Bitbucket:
> 
>     https://bitbucket.org/dkuhlman/generateds
> 
> >
> > For this solution XMLSchame.xsd generated code is going to be
> > used to provide reference information for each xs: - data type
> > in terms of it is capabilities.  I would love to get it all done
> > using generateDS generated libraries, but since time is an
> > essence I can use some temporary solution until support for
> > XMLSchema.xsd becomes available.  I have just started to look
> > into alternative solutions for XMLSchema.xsd parsing for
> > information lookup and if you have a suggestion please share it
> > with me.  Also, if there is anything I can help you with in
> > regards to implementation of support for XMLSchame.xsd please
> > let me know.
> 
> I'm not too sure about what you are trying to do, but some of it
> seems to involve learning about the children/members of each
> generated Python class.  If so, one suggestion is to consider
> generating your code using generateDS.py with either:
> 
>     --member-specs=list
> 
> or:
> 
>    --member-specs=dict
> 
> Then add a method to the superclass (GeneratedsSuper) that you can
> call to produce a list of the members (children) of each element.
> Note that the generated code will attempt to load that superclass
> from another file if you want it to.  See the code at the top of
> class GeneratedsSuper in the generated file (or look at the doc)
> to learn how to do that.
> 
> Also note that there is a list of the names of generated classes
> at the end of each generated superclass file.  See variable
> __all__.
> 
> Are you familiar with Sphinx?  Sphinx generates documentation on
> Python classes, so you could use it to produce documentation on
> the classes generated by generateDS.py and on the members of those
> classes.  I even worked up an orderly way to do that with code
> generated by generateDS.py.  You can read about it in the
> following files, which are in the generateDS.py distribution file:
> 
>     generateDS-2.10b/librarytemplate_howto.txt
>     generateDS-2.10b/librarytemplate-1.0a.zip
> 
> But, if generateDS.py and the code it generates does *not* do what
> you need, then you might consider writing a Python script that
> uses xpath to search for the and extract information that you want
> to expose.  Note that Lxml (http://lxml.de/) supports xpath.
> 
> Hope this makes sense and is a little help.  Let me know how it
> goes and when you have questions etc.
> 
> - Dave
> 
> >
> > With thanks and best regards,
> >
> > Rinat
> >
> > ### version 2.9a (version that I'm currently using):
> >
> > $ /opt/python2.7/bin/generateDS.py --silence -o
> > XMLSchema_Code.py -s
> >XMLSchema_Subs.py XMLSchema.xsd  Traceback (most recent call
> >   last): File "/opt/python2.7/bin/generateDS.py", line 5, in
> >   <module> pkg_resources.run_script('generateDS==2.9a',
> >   'generateDS.py') File
> >   "/opt/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
> >   /pkg_resources.py", line 489, in run_script
> >   File
> >"/opt/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
> >/pkg_resources.py", line 1214, in run_script File
> >"/opt/python2.7/lib/python2.7/site-packages/generateDS-2.9a-py2.7.egg/E
> >GG-INFO/scripts/generateDS.py", line 5674, in <module>
> >
> >   File
> >"/opt/python2.7/lib/python2.7/site-packages/generateDS-2.9a-py2.7.egg/E
> >GG-INFO/scripts/generateDS.py", line 5668, in main
> >
> >   File
> >"/opt/python2.7/lib/python2.7/site-packages/generateDS-2.9a-py2.7.egg/E
> >GG-INFO/scripts/generateDS.py", line 5384, in parseAndGenerate
> >
> >   File "/opt/python2.7/lib/python2.7/xml/sax/expatreader.py",
> >   line
> >107, in parse xmlreader.IncrementalParser.parse(self, source)
> >     File "/opt/python2.7/lib/python2.7/xml/sax/xmlreader.py",
> >     line 123, in parse self.feed(buffer) File
> >     "/opt/python2.7/lib/python2.7/xml/sax/expatreader.py", line
> >     207, in feed
> >     self._parser.Parse(data, isFinal) File
> >     "/opt/python2.7/lib/python2.7/xml/sax/expatreader.py", line
> >304, in end_element self._cont_handler.endElement(name) File
> >     "/opt/python2.7/lib/python2.7/site-packages/generateDS-2.9a-py2.7.egg/E
> >     GG-INFO/scripts/generateDS.py", line 1594, in endElement
> >
> 
> [snip]
> 
> 
> 
> --
> 
> Dave Kuhlman http://www.rexx.com/~dkuhlman
> 
> 


 
--

Dave Kuhlman
http://www.rexx.com/~dkuhlman 


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to