stchris / untangle

Converts XML to Python objects
MIT License
612 stars 83 forks source link

Add parse_raw() to handle large XML strings #18

Closed turt2live closed 6 years ago

turt2live commented 8 years ago

In Windows environments the path length limitation causes a path too long exception to be raised from parse(). To combat this, I've written a parse_raw() function that accepts an XML string and will not attempt to estimate what type of data it was given. This seemed like a better choice over adding a type parameter to parse() because of the several options it could be given: filepath, url, xml string, stream, or some value to indicate that it needs to be figured out (like None).

This has been confirmed to work on Windows 7 with Python 3.4.3 using a document that exceeds 300+ characters.

stchris commented 8 years ago

This seems quite useful, thanks! Can you have a look at the failing Windows build? Once I merge it please allow some time before a release, I want to add similar parse_url and parse_file methods which requires some refactoring.

turt2live commented 8 years ago

It looks as though the test failed due to a problem in the coverage package running on Python 3.2. I'm still fairly new to Python in general, but it looks like the version installed is not applicable to the Python version to be testing on.

landscape-bot commented 8 years ago

Code Health Repository health decreased by 0.28% when pulling ef38ae2 on turt2live:long-document into fc2f7c8 on stchris:master.

landscape-bot commented 8 years ago

Code Health Repository health decreased by 0.28% when pulling 57d56fc on turt2live:long-document into fc2f7c8 on stchris:master.

landscape-bot commented 8 years ago

Code Health Repository health decreased by 0.28% when pulling 04911b2 on turt2live:long-document into fc2f7c8 on stchris:master.

turt2live commented 8 years ago

@stchris I apologize for the spam of commits (testing locally proved difficult). The tests were failing because coveralls recently updated to support coverage 4.x. On pypy coveralls does not list Python 3.2 as a supported version. Using a lesser version appears to resolve the issue.

landscape-bot commented 8 years ago

Code Health Repository health decreased by 0.28% when pulling e1a1a3b on turt2live:long-document into fc2f7c8 on stchris:master.

stchris commented 8 years ago

Awesome, thanks for the fix @turt2live . I will merge this as soon as I find time to cut a release. I'd like to make the API more uniform, now that there's not just the parse method. I hope you can wait a bit longer. Sorry about that :|

turt2live commented 8 years ago

No problem - having consistent and clean code is always a good thing :)

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-1.8%) to 34.906% when pulling ffd27383568c95ec615d04984444f241e8e85a52 on turt2live:long-document into 8e07869b7d52c34ae894ece2473fcdd1ed6e045e on stchris:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-1.7%) to 34.259% when pulling dd8cc3d0d64bbcab2b8d32920720f23f9e98a776 on turt2live:long-document into c0f102d14a887235f63cf5bb8f21dacc7e594ae8 on stchris:master.

turt2live commented 7 years ago

@stchris Have you had a chance to look at this? ;)

mattijn commented 7 years ago

@stchris would be nice having this, or that the parse function is formatted that it sees longs strings as strings and not as filenames

turt2live commented 6 years ago

I'm going to have to close this: It's been open for a pretty long time and the project I originally needed it for is no longer in development.

If someone else wants to take this on, by all means please do :)