Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

[WIP] Allow requirement mapping by URI. #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions galaxy/tools/deps/resolvers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ def _expand_mappings(self, requirement):

class RequirementMapping(object):

def __init__(self, from_name, from_version, to_name, to_version):
def __init__(self, from_name, from_version, to_name, to_version, from_uri=None):
self.from_name = from_name
self.from_version = from_version
self.from_uri = from_uri
self.to_name = to_name
self.to_version = to_version

Expand All @@ -131,7 +132,13 @@ def matches_requirement(self, requirement):
"""

if requirement.name != self.from_name:
return False
found_spec = False
for spec in requirement.spec:
if spec.uri == self.from_uri:
found_spec = True

if not found_spec:
return False
elif self.from_version is None:
return True
elif self.from_version is FROM_UNVERSIONED:
Expand All @@ -155,14 +162,15 @@ def from_dict(raw_mapping):
unversioned = from_raw.get("unversioned", False)
if unversioned and raw_version:
raise Exception("Cannot define both version and set unversioned to True.")

if unversioned:
from_version = FROM_UNVERSIONED
else:
from_version = str(raw_version) if raw_version is not None else raw_version
from_uri = from_raw.get("uri")
else:
from_name = from_raw
from_version = None
from_uri = None

to_raw = raw_mapping.get("to")
if isinstance(to_raw, dict):
Expand All @@ -172,7 +180,7 @@ def from_dict(raw_mapping):
to_name = to_raw
to_version = None

return RequirementMapping(from_name, from_version, to_name, to_version)
return RequirementMapping(from_name, from_version, to_name, to_version, from_uri)


@six.add_metaclass(ABCMeta)
Expand Down