예제 #1
0
    def __init__(self,
                 package,
                 version: str,
                 repo="https://repo.maven.apache.org/maven2"):
        """
        Constructs a new ``MavenRequirement``, using the ``PackageRequirement``
        constructor.

        >>> mr = MavenRequirement('com.puppycrawl.tools:checkstyle', '6.15')
        >>> mr.type
        'mvn'
        >>> mr.package
        'com.puppycrawl.tools:checkstyle'
        >>> mr.version
        '6.15'
        >>> str(mr)
        'com.puppycrawl.tools:checkstyle 6.15'
        >>> mr.repo
        'https://repo.maven.apache.org/maven2'

        :param package: A string with the {groupId:artifactId} of
                        the package to be installed.
        :param version: A version string.
        :param repo:    The repository from which the package is to be
                        installed.
        """
        package_regex = '([^: /]*:[^: /]*)'
        package_match = (re.compile(package_regex)).match(package)

        if not package_match:
            raise ValueError(
                'The package must be of the form [groupId:artifactId]')

        PackageRequirement.__init__(self, 'mvn', package, version, repo)
예제 #2
0
    def __init__(self,
                 package,
                 version="",
                 flag="",
                 repo="http://cran.rstudio.com"):
        """
        Constructs a new ``RscriptRequirement``, using the
        ``PackageRequirement`` constructor.

        >>> pr = RscriptRequirement(
        ...         'formatR', version='1.4', flag='-e',
        ...         repo="http://cran.rstudio.com")
        >>> pr.type
        'R'
        >>> pr.package
        'formatR'
        >>> pr.version
        '1.4'
        >>> str(pr)
        'formatR 1.4'
        >>> pr.flag
        '-e'
        >>> pr.repo
        'http://cran.rstudio.com'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        :param flag:    A string that specifies any additional flags, that
                        are passed to the type.
        :param repo:    The repository from which the package is to be
                        installed.
        """
        PackageRequirement.__init__(self, 'R', package, version, repo)
        self.flag = flag
예제 #3
0
    def __init__(self, executable):
        """
        Constructs a new ``ExecutableRequirement``, using the
        ``PackageRequirement`` constructor.

        >>> er = ExecutableRequirement('python')
        >>> er.executable
        'python'
        """

        self.executable = executable
        PackageRequirement.__init__(self, 'exec', executable, '')
예제 #4
0
    def __init__(self, package, version=""):
        """
        Constructs a new ``PipRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = PipRequirement('setuptools', '19.2')
        >>> pr.type
        'pip'
        >>> pr.package
        'setuptools'
        >>> pr.version
        '19.2'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'pip', package, version)
예제 #5
0
    def __init__(self, package, version=""):
        """
        Constructs a new ``NpmRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = NpmRequirement('ramllint', '6.2')
        >>> pr.type
        'npm'
        >>> pr.package
        'ramllint'
        >>> pr.version
        '6.2'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'npm', package, version)
예제 #6
0
    def __init__(self, package, version=''):
        """
        Constructs a new ``CabalRequirement``, using the ``PackageRequirement``
        constructor.

        >>> cr = CabalRequirement('zoom', '0.1')
        >>> cr.type
        'cabal'
        >>> cr.package
        'zoom'
        >>> cr.version
        '0.1'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'cabal', package, version)
예제 #7
0
    def __init__(self, package, version=""):
        """
        Constructs a new ``JuliaRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = JuliaRequirement('Lint', '19.2')
        >>> pr.type
        'julia'
        >>> pr.package
        'Lint'
        >>> pr.version
        '19.2'
        >>> str(pr)
        'Lint 19.2'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'julia', package, version)
예제 #8
0
    def __init__(self, package, version=''):
        """
        Constructs a new ``CargoRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = CargoRequirement('pulldown-cmark', '0.0.14')
        >>> pr.type
        'cargo'
        >>> pr.package
        'pulldown-cmark'
        >>> pr.version
        '0.0.14'
        >>> str(pr)
        'pulldown-cmark 0.0.14'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'cargo', package, version)
예제 #9
0
    def __init__(self, package, version=''):
        """
        Constructs a new ``Luarocks``, using the ``PackageRequirement``
        constructor.

        >>> pr = LuarocksRequirement('luasocket', '3.0rc1')
        >>> pr.type
        'luarocks'
        >>> pr.package
        'luasocket'
        >>> pr.version
        '3.0rc1'
        >>> str(pr)
        'luasocket 3.0rc1'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'luarocks', package, version)
예제 #10
0
    def __init__(self, package, version='', repo=''):
        """
        Constructs a new ``CondaRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = CondaRequirement('scipy', '0.15.0')
        >>> pr.type
        'conda'
        >>> pr.package
        'scipy'
        >>> pr.version
        '0.15.0'
        >>> str(pr)
        'scipy 0.15.0'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        :param repo: The repository from which the package is to be installed.
        """
        PackageRequirement.__init__(self, 'conda', package, version, repo)
예제 #11
0
    def __init__(self, requirements: list):
        """
        Constructs a new ``AnyOneOfRequirements``.

        Requirements are ordered by priority.

        >>> from dependency_management.requirements.ExecutableRequirement \\
        ...     import ExecutableRequirement
        >>> aor = AnyOneOfRequirements([ExecutableRequirement("python"),
        ...                             ExecutableRequirement("python3")])
        >>> str(aor)
        'ExecutableRequirement(python) ExecutableRequirement(python3)'
        """
        self.requirements = requirements
        self._packages_str = " ".join(sorted(
                                      ["%s(%s)" %
                                       (requirement.__class__.__name__,
                                        str(requirement))
                                       for requirement in self.requirements]))
        PackageRequirement.__init__(self, "any-one-of", self._packages_str)
예제 #12
0
    def __init__(self, package, version=""):
        """
        Constructs a new ``ComposerRequirement``, using the
        ``PackageRequirement`` constructor.

        >>> pr = ComposerRequirement('phpstan/phpstan', '0.6.4')
        >>> pr.type
        'composer'
        >>> pr.package
        'phpstan/phpstan'
        >>> pr.version
        '0.6.4'
        >>> str(pr)
        'phpstan/phpstan 0.6.4'

        :param package:
            A string with the name of the package to be installed.
        :param version:
            A version string. Leave empty to specify latest version.
        """
        PackageRequirement.__init__(self, 'composer', package, version)
예제 #13
0
    def __init__(self, package, version="", require=""):
        """
        Constructs a new ``GemRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = GemRequirement('setuptools', '19.2', 'flag')
        >>> pr.type
        'gem'
        >>> pr.package
        'setuptools'
        >>> pr.version
        '19.2'
        >>> pr.require
        'flag'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        :param require: A string that specifies any additional flags, that
                        would be used with ``require``.
        """
        PackageRequirement.__init__(self, 'gem', package, version)
        self.require = require
예제 #14
0
    def __init__(self, package, version="", flag=""):
        """
        Constructs a new ``GoRequirement``, using the ``PackageRequirement``
        constructor.

        >>> pr = GoRequirement('github.com/golang/lint/golint', '19.2', '-u')
        >>> pr.type
        'go'
        >>> pr.package
        'github.com/golang/lint/golint'
        >>> pr.version
        '19.2'
        >>> pr.flag
        '-u'

        :param package: A string with the name of the package to be installed.
        :param version: A version string. Leave empty to specify latest version.
        :param flag:    A string that specifies any additional flags, that
                        are passed to the manager.
        """
        PackageRequirement.__init__(self, 'go', package, version)
        self.flag = flag
예제 #15
0
class VintBear:
    """
    Check vimscript code for possible style problems.

    See <https://github.com/Kuniwak/vint> for more information.
    """

    LANGUAGES = {'VimScript'}
    REQUIREMENTS = {PackageRequirement('broken', 'vim-vint', '0.3.10')}
    AUTHORS = {'The coala developers'}
    AUTHORS_EMAILS = {'*****@*****.**'}
    LICENSE = 'AGPL-3.0'
    CAN_DETECT = {'Formatting'}

    @staticmethod
    def create_arguments(filename, file, config_file):
        return filename,
예제 #16
0
    def __init__(self,
                 package: str = None,
                 version='',
                 repo='',
                 **package_overrides):
        """
        Constructs a new ``DistributionRequirement``, using the
        ``PackageRequirement`` constructor.

        When a ``package`` name is provided, it is used as the
        package attribute, even when override package names are
        provided for specific package managers.

        >>> dr = DistributionRequirement(package='clang',
        ...                              apt_get='libclang',
        ...                              dnf='libclangg')
        >>> dr.package
        'clang'
        >>> dr.packages['apt_get']
        'libclang'
        >>> dr.packages['dnf']
        'libclangg'

        When no ``package`` name is provided, the override package name
        for the local host's package manager is used if possible,
        otherwise the most common override is used.

        >>> dr = DistributionRequirement(unknown1='libclangg',
        ...                              unknown2='libclang',
        ...                              unknown3='libclang')
        >>> dr.package
        'libclang'
        >>> dr.packages['unknown1']
        'libclangg'
        >>> dr.packages['unknown2']
        'libclang'
        >>> dr.packages['unknown3']
        'libclang'

        >>> from pprint import pprint
        >>> len(dr.REQUIREMENTS)
        2
        >>> not_grep_req = [dep for dep in dr.REQUIREMENTS
        ...                 if str(dep) != 'grep'][0]
        >>> pprint(str(not_grep_req))
        ('ExecutableRequirement(apt-get) ExecutableRequirement(brew) '
         'ExecutableRequirement(dnf) ExecutableRequirement(emerge) '
         'ExecutableRequirement(pacman) ExecutableRequirement(xbps-install) '
         'ExecutableRequirement(yum) ExecutableRequirement(zypper)')

        :param package: A string with the name of the package to be installed.
        :param version: A version string.  Unused.
        :param repo:    The repository from which the package is to be
                        installed.  Unused.
        :param kwargs: Override package names for supported package managers.
        """
        self._managers = None
        self._manager = None
        self.packages = package_overrides

        if not package and not package_overrides:
            raise NoArgsNotImplementedError('No package managers specified')

        if package:
            defaults = {(pm, package)
                        for pm in self.SUPPORTED_PACKAGE_MANAGERS.keys()
                        if pm not in package_overrides}
            self.packages.update(defaults)

        else:
            package = self._get_best_package_name()

        PackageRequirement.__init__(self, 'distribution', package, version)