Skip to content

Commit

Permalink
Replace safe conversions with older canonicalize function. Safe funct…
Browse files Browse the repository at this point in the history
…ions are preventing proper name conversion.
  • Loading branch information
GabrielC101 committed Dec 5, 2017
1 parent c91db63 commit 129f5cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
6 changes: 3 additions & 3 deletions packaging/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from .markers import MARKER_EXPR, Marker
from .specifiers import LegacySpecifier, Specifier, SpecifierSet
from .utils import safe_extra, safe_name
from .utils import canonicalize_name


class InvalidRequirement(ValueError):
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(self, requirement_string):
"Invalid requirement, parse error at \"{0!r}\"".format(
requirement_string[e.loc:e.loc + 8]))

self.name = safe_name(req.name)
self.name = canonicalize_name(req.name)
if req.url:
parsed_url = urlparse.urlparse(req.url)
if not (parsed_url.scheme and parsed_url.netloc) or (
Expand All @@ -105,7 +105,7 @@ def __init__(self, requirement_string):
self.url = req.url
else:
self.url = None
self.extras = set([safe_extra(extra) for extra in req.extras.asList()] if req.extras else [])
self.extras = set([canonicalize_name(extra) for extra in req.extras.asList()] if req.extras else [])
self.specifier = SpecifierSet(req.specifier)
self.marker = req.marker if req.marker else None

Expand Down
17 changes: 0 additions & 17 deletions packaging/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,3 @@
def canonicalize_name(name):
# This is taken from PEP 503.
return _canonicalize_regex.sub("-", name).lower()


def safe_extra(extra):
"""Convert an arbitrary string to a standard 'extra' name
Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
"""
return re.sub('[^A-Za-z0-9.-]+', '_', extra).lower()


def safe_name(name):
"""Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
"""
return re.sub('[^A-Za-z0-9.]+', '-', name)

0 comments on commit 129f5cd

Please sign in to comment.