# Path: f8a_worker/models.py
# class Ecosystem(Base):
#     """Table for Ecosystem."""
# 
#     __tablename__ = 'ecosystems'
# 
#     id = Column(Integer, primary_key=True)
#     name = Column(String(255), unique=True)
#     url = Column(String(255))
#     fetch_url = Column(String(255))
#     _backend = Column(
#         Enum(*[b.name for b in EcosystemBackend], name='ecosystem_backend_enum'))
# 
#     packages = relationship('Package', back_populates='ecosystem')
#     feedback = relationship('RecommendationFeedback',
#                             back_populates='ecosystem')
# 
#     @property
#     def backend(self):
#         """Get backend property."""
#         return EcosystemBackend[self._backend]
# 
#     @backend.setter
#     def backend(self, backend):
#         """Set backend property."""
#         self._backend = EcosystemBackend(backend).name
# 
#     def is_backed_by(self, backend):
#         """Is this ecosystem backed by specified backend?."""
#         return self.backend == backend
# 
#     @classmethod
#     def by_name(cls, session, name):
#         """Get a row with specified name."""
#         try:
#             return cls._by_attrs(session, name=name)
#         except NoResultFound:
#             # What to do here ?
#             raise
# 
# Path: f8a_worker/utils.py
# class MavenCoordinates(object):
#     """Represents Maven coordinates.
# 
#     https://maven.apache.org/pom.html#Maven_Coordinates
#     """
# 
#     _default_packaging = 'jar'
# 
#     def __init__(self, groupId, artifactId, version='',
#                  classifier='', packaging=None):
#         """Initialize attributes."""
#         self.groupId = groupId
#         self.artifactId = artifactId
#         self.classifier = classifier
#         self.packaging = packaging or MavenCoordinates._default_packaging
#         self.version = version
# 
#     def is_valid(self):
#         """Check if the current coordinates are valid."""
#         return self.groupId and self.artifactId and self.version and self.packaging
# 
#     def to_str(self, omit_version=False):
#         """Return string representation of the coordinates."""
#         mvnstr = "{g}:{a}".format(g=self.groupId, a=self.artifactId)
#         pack = self.packaging
#         if pack == MavenCoordinates._default_packaging:
#             pack = ''
#         if pack:
#             mvnstr += ":{p}".format(p=pack)
#         if self.classifier:
#             if not pack:
#                 mvnstr += ':'
#             mvnstr += ":{c}".format(c=self.classifier)
#         if not self.version or omit_version:
#             if self.classifier or pack:
#                 mvnstr += ':'
#         else:
#             mvnstr += ":{v}".format(v=self.version)
# 
#         return mvnstr
# 
#     def to_repo_url(self, ga_only=False):
#         """Return relative path to the artifact in Maven repository."""
#         if ga_only:
#             return "{g}/{a}".format(g=self.groupId.replace('.', '/'),
#                                     a=self.artifactId)
# 
#         dir_path = "{g}/{a}/{v}/".format(g=self.groupId.replace('.', '/'),
#                                          a=self.artifactId,
#                                          v=self.version)
#         classifier = "-{c}".format(c=self.classifier) if self.classifier else ''
#         filename = "{a}-{v}{c}.{e}".format(a=self.artifactId,
#                                            v=self.version,
#                                            c=classifier,
#                                            e=self.packaging)
#         return dir_path + filename
# 
#     @staticmethod
#     def _parse_string(coordinates_str):
#         """Parse string representation into a dictionary."""
#         a = {'groupId': '',
#              'artifactId': '',
#              'packaging': MavenCoordinates._default_packaging,
#              'classifier': '',
#              'version': ''}
# 
#         ncolons = coordinates_str.count(':')
#         if ncolons == 1:
#             a['groupId'], a['artifactId'] = coordinates_str.split(':')
#         elif ncolons == 2:
#             a['groupId'], a['artifactId'], a['version'] = coordinates_str.split(':')
#         elif ncolons == 3:
#             a['groupId'], a['artifactId'], a['packaging'], a['version'] = coordinates_str.split(':')
#         elif ncolons == 4:
#             a['groupId'], a['artifactId'], a['packaging'], a['classifier'], a['version'] = \
#                 coordinates_str.split(':')
#         else:
#             raise ValueError('Invalid Maven coordinates %s', coordinates_str)
# 
#         return a
# 
#     def __repr__(self):
#         """Represent as string."""
#         return self.to_str()
# 
#     def __eq__(self, other):
#         """Implement == operator."""
#         return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
# 
#     def __ne__(self, other):
#         """Implement != operator."""
#         return not self.__eq__(other)
# 
#     @classmethod
#     def normalize_str(cls, coordinates_str):
#         """Normalize string representation."""
#         return cls.from_str(coordinates_str).to_str()
# 
#     @classmethod
#     def from_str(cls, coordinates_str):
#         """Create instance from string."""
#         coordinates = MavenCoordinates._parse_string(coordinates_str)
#         return cls(**coordinates)


import logging
from urllib.parse import urlparse
from selinon import StoragePool
from f8a_worker.enums import EcosystemBackend
from f8a_worker.models import Ecosystem
from f8a_worker.utils import MavenCoordinates
"""Functions for dispatcher."""




logger = logging.getLogger(__name__)


def _create_analysis_arguments(ecosystem, name, version):
    """Create arguments for analysis."""
    return {
        'ecosystem': ecosystem,

# Path: f8a_worker/models.py
# class Ecosystem(Base):
#     """Table for Ecosystem."""
# 
#     __tablename__ = 'ecosystems'
# 
#     id = Column(Integer, primary_key=True)
#     name = Column(String(255), unique=True)
#     url = Column(String(255))
#     fetch_url = Column(String(255))
#     _backend = Column(
#         Enum(*[b.name for b in EcosystemBackend], name='ecosystem_backend_enum'))
# 
#     packages = relationship('Package', back_populates='ecosystem')
#     feedback = relationship('RecommendationFeedback',
#                             back_populates='ecosystem')
# 
#     @property
#     def backend(self):
#         """Get backend property."""
#         return EcosystemBackend[self._backend]
# 
#     @backend.setter
#     def backend(self, backend):
#         """Set backend property."""
#         self._backend = EcosystemBackend(backend).name
# 
#     def is_backed_by(self, backend):
#         """Is this ecosystem backed by specified backend?."""
#         return self.backend == backend
# 
#     @classmethod
#     def by_name(cls, session, name):
#         """Get a row with specified name."""
#         try:
#             return cls._by_attrs(session, name=name)
#         except NoResultFound:
#             # What to do here ?
#             raise
# 
# Path: f8a_worker/utils.py
# class MavenCoordinates(object):
#     """Represents Maven coordinates.
# 
#     https://maven.apache.org/pom.html#Maven_Coordinates
#     """
# 
#     _default_packaging = 'jar'
# 
#     def __init__(self, groupId, artifactId, version='',
#                  classifier='', packaging=None):
#         """Initialize attributes."""
#         self.groupId = groupId
#         self.artifactId = artifactId
#         self.classifier = classifier
#         self.packaging = packaging or MavenCoordinates._default_packaging
#         self.version = version
# 
#     def is_valid(self):
#         """Check if the current coordinates are valid."""
#         return self.groupId and self.artifactId and self.version and self.packaging
# 
#     def to_str(self, omit_version=False):
#         """Return string representation of the coordinates."""
#         mvnstr = "{g}:{a}".format(g=self.groupId, a=self.artifactId)
#         pack = self.packaging
#         if pack == MavenCoordinates._default_packaging:
#             pack = ''
#         if pack:
#             mvnstr += ":{p}".format(p=pack)
#         if self.classifier:
#             if not pack:
#                 mvnstr += ':'
#             mvnstr += ":{c}".format(c=self.classifier)
#         if not self.version or omit_version:
#             if self.classifier or pack:
#                 mvnstr += ':'
#         else:
#             mvnstr += ":{v}".format(v=self.version)
# 
#         return mvnstr
# 
#     def to_repo_url(self, ga_only=False):
#         """Return relative path to the artifact in Maven repository."""
#         if ga_only:
#             return "{g}/{a}".format(g=self.groupId.replace('.', '/'),
#                                     a=self.artifactId)
# 
#         dir_path = "{g}/{a}/{v}/".format(g=self.groupId.replace('.', '/'),
#                                          a=self.artifactId,
#                                          v=self.version)
#         classifier = "-{c}".format(c=self.classifier) if self.classifier else ''
#         filename = "{a}-{v}{c}.{e}".format(a=self.artifactId,
#                                            v=self.version,
#                                            c=classifier,
#                                            e=self.packaging)
#         return dir_path + filename
# 
#     @staticmethod
#     def _parse_string(coordinates_str):
#         """Parse string representation into a dictionary."""
#         a = {'groupId': '',
#              'artifactId': '',
#              'packaging': MavenCoordinates._default_packaging,
#              'classifier': '',
#              'version': ''}
# 
#         ncolons = coordinates_str.count(':')
#         if ncolons == 1:
#             a['groupId'], a['artifactId'] = coordinates_str.split(':')
#         elif ncolons == 2:
#             a['groupId'], a['artifactId'], a['version'] = coordinates_str.split(':')
#         elif ncolons == 3:
#             a['groupId'], a['artifactId'], a['packaging'], a['version'] = coordinates_str.split(':')
#         elif ncolons == 4:
#             a['groupId'], a['artifactId'], a['packaging'], a['classifier'], a['version'] = \
#                 coordinates_str.split(':')
#         else:
#             raise ValueError('Invalid Maven coordinates %s', coordinates_str)
# 
#         return a
# 
#     def __repr__(self):
#         """Represent as string."""
#         return self.to_str()
# 
#     def __eq__(self, other):
#         """Implement == operator."""
#         return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
# 
#     def __ne__(self, other):
#         """Implement != operator."""
#         return not self.__eq__(other)
# 
#     @classmethod
#     def normalize_str(cls, coordinates_str):
#         """Normalize string representation."""
#         return cls.from_str(coordinates_str).to_str()
# 
#     @classmethod
#     def from_str(cls, coordinates_str):
#         """Create instance from string."""
#         coordinates = MavenCoordinates._parse_string(coordinates_str)
#         return cls(**coordinates)


# Path: f8a_worker/dispatcher/foreach.py
import logging
from urllib.parse import urlparse
from selinon import StoragePool
from f8a_worker.enums import EcosystemBackend
from f8a_worker.models import Ecosystem
from f8a_worker.utils import MavenCoordinates

"""Functions for dispatcher."""




logger = logging.getLogger(__name__)


def _create_analysis_arguments(ecosystem, name, version):
    """Create arguments for analysis."""
    return {
        'ecosystem': ecosystem,

        'name': MavenCoordinates.normalize_str(name) if Ecosystem.by_name(