Skip to content

Commit

Permalink
use parse_requirements backport from dparse
Browse files Browse the repository at this point in the history
  • Loading branch information
jayfk committed Jul 19, 2017
1 parent 21fc4fc commit b4be388
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
35 changes: 1 addition & 34 deletions pyup/requirements.py
Expand Up @@ -10,40 +10,7 @@

from dparse import parse, parser, updater, filetypes
from dparse.dependencies import Dependency


# This is a setuptools backport
def parse_requirements(strs):
"""Yield ``Requirement`` objects for each specification in `strs`
`strs` must be a string, or a (possibly-nested) iterable thereof.
"""
from packaging.requirements import Requirement as PackagingRequirement
# create a steppable iterator, so we can handle \-continuations

def yield_lines(strs):
"""Yield non-empty/non-comment lines of a string or sequence"""
if isinstance(strs, six.string_types):
for s in strs.splitlines():
s = s.strip()
# skip blank lines/comments
if s and not s.startswith('#'):
yield s
else:
for ss in strs:
for s in yield_lines(ss):
yield s
lines = iter(yield_lines(strs))

for line in lines:
# Drop comments -- a hash without a space may be in a URL.
if ' #' in line:
line = line[:line.find(' #')]
# If there is a line continuation, drop it, and append the next line.
if line.endswith('\\'):
line = line[:-2].strip()
line += next(lines)
yield PackagingRequirement(line)

from dparse.parser import setuptools_parse_requirements_backport as parse_requirements

PYTHON_VERSIONS = [
"2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -24,7 +24,7 @@
"packaging",
"six",
"python-gitlab",
"dparse"
"dparse>=2.1"
]

test_requirements = [
Expand Down

0 comments on commit b4be388

Please sign in to comment.