Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved with ast2dict and ast2json and compatible with python2 and python3. #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

edelvalle
Copy link

No description provided.

@Psycojoker
Copy link
Member

Hello,

Thanks for your PR :)

I've been trying to prettify the xml and while doing this, I've discovered that your code doesn't correctly escape strings which causes minidom to complain. You can test this by doing:

python ast2json.py ast2json.py

My code is here: https://github.com/Psycojoker/ast2json/tree/xml_and_stuff

I guess that we'll have to find a way to correctly escape the strings or to build the xml another way using a lib lke minidom https://docs.python.org/2/library/xml.dom.minidom.html

My current (dirty) attempt to do this is:

attrs.append('%(attr)s=%(value)s' % {"attr": attr, "value": json.dumps(value) if isinstance(value, basestring) else '"%s"' % value})

for this line https://github.com/Psycojoker/ast2json/blob/943039a363c3fa0080c740c787c2243d6d61048c/ast2json.py#L87 and it's not a success at all.

This new feature should also be added to the documentation.

Kind regards,

@edelvalle
Copy link
Author

Hi,

Ohh.. you are right... sorry. It will be nice to have a propper XML.

We also need to add the pyyaml dependency in the setup.py becuase I also added a YAML encoder.

I will check your code later.

See you around, Ed.

@Psycojoker
Copy link
Member

Psycojoker commented Sep 14, 2015 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants