Completed
Pull Request — master (#2422)
by
unknown
02:15
created

JuliaRequirement.is_installed()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
from coalib.bears.requirements.PackageRequirement import PackageRequirement
2
3
4
class JuliaRequirement(PackageRequirement):
5
    """
6
    This class is a subclass of ``PackageRequirement``, and helps specifying
7
    requirements from ``julia``, without using the manager name.
8
    """
9
10
    def __init__(self, package, version="", flag=""):
11
        """
12
        Constructs a new ``JuliaRequirement``, using the ``PackageRequirement``
13
        constructor.
14
15
        >>> pr = JuliaRequirement('"Pkg.add(\"Lint\")"', '19.2', '-e')
16
        >>> pr.manager
17
        'julia'
18
        >>> pr.package
19
        '"Pkg.add(\"Lint\")"'
20
        >>> pr.version
21
        '19.2'
22
        >>> pr.flag
23
        '-e'
24
25
        :param package: A string with the name of the package to be installed.
26
        :param version: A version string. Leave empty to specify latest version.
27
        :param flag:    A string that specifies any additional flags, that
28
                        are passed to the manager.
29
        """
30
        PackageRequirement.__init__(self, 'julia', package, version)
31
        self.flag = flag
32
33
    def install_command(self):
34
        """
35
       Creates the installation command for the instance of the class.
36
37
       >>> JuliaRequirement("Lint", '', '-e').install_command()
38
       'julia -e "Pkg.add(\"Lint\")'
39
40
       :param return: A string with the installation command.
41
       """
42
        return 'julia {} "Pkg.add(\"{}\")'.format(self.flag, self.package)
43
44
    def is_installed(self):
45
        """
46
       Checks if the dependency is installed.
47
48
       :param return: True if dependency is installed, false otherwise.
49
       """
50
        return not call_without_output(('julia', 'show', self.package),)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'call_without_output'
Loading history...
51