madpah / requirements-parser

A Pip requirements file parser.
https://requirements-parser.readthedocs.io
Apache License 2.0
125 stars 41 forks source link

Big parser refactor #14

Closed davidfischer closed 11 years ago

davidfischer commented 11 years ago

This is backwards incompatible in the sense that parse returns a generator of objects rather than dicts. However, the objects behave like dict-like objects. The parser is much more complete in my opinion as it handles more use cases from the revised spec. It should fix #10, #8, and #12 more or less.

I need to create more docs but here's some usage:

>>> from requirements import parse
>>> list(parse('https://github.com/django/django/tarball/stable/1.6.x'))[0].uri
'https://github.com/django/django/tarball/stable/1.6.x'
>>> list(parse('django==1.5.2'))[0].specs
[('==', '1.5.2')]
>>> list(parse('django==1.5.2'))[0].specifier
True
>>> list(parse('-e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject'))[0].editable
True
>>> list(parse('-e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject'))[0].revision
'v1.0'

I wouldn't mind a weigh-in by @treyhunner on this change.

davidfischer commented 11 years ago

Ugh. Python3.2 and it's lack of compatibility. I'll probably just drop support for it. Nobody uses 3.2 anyways.

treyhunner commented 11 years ago

:+1: for splitting out the code into an object that can be used more flexibly.

As for Python 3.2, I agree that most people don't use 3.2, but I think 3.2 is a pretty good guideline for "you're doing it right". In this case since all strings should be unicode, instead of prepending u to them you should put a from __future__ import unicode_literals at the top of every file.

Unrelated: you might consider sticking a Coveralls badge in the README too just to demonstrate code coverage. Example: https://github.com/treyhunner/pep438#pep438