Skip to content

Commit

Permalink
fixup! Extract extras from fragment's egg when vcs is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
ticosax committed Jul 7, 2017
1 parent 01b2f5c commit cab9ebd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions requirements/fragment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import re

# Copied from pip
# https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/pip/index.py#L947
HASH_ALGORITHMS = set(['sha1', 'sha224', 'sha384', 'sha256', 'sha512', 'md5'])

extras_require_search = re.compile(
r'(?P<name>.+)\[(?P<extras>[^\]]+)\]').search


def parse_fragment(fragment_string):
"""Takes a fragment string nd returns a dict of the components"""
Expand Down Expand Up @@ -30,7 +35,10 @@ def get_hash_info(d):


def parse_extras_require(egg):
if egg is not None and ('[' and ']') in egg:
name, _, extras = egg.partition('[')
return name, [extra.strip() for extra in extras[:-1].split(',')]
if egg is not None:
match = extras_require_search(egg)
if match is not None:
name = match.group('name')
extras = match.group('extras')
return name, [extra.strip() for extra in extras.split(',')]
return egg, []

0 comments on commit cab9ebd

Please sign in to comment.