comparison planemo/lib/python3.7/site-packages/virtualenv/discovery/discover.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 from __future__ import absolute_import, unicode_literals
2
3 from abc import ABCMeta, abstractmethod
4
5 from six import add_metaclass
6
7
8 @add_metaclass(ABCMeta)
9 class Discover(object):
10 """Discover and provide the requested Python interpreter"""
11
12 @classmethod
13 def add_parser_arguments(cls, parser):
14 """Add CLI arguments for this discovery mechanisms.
15
16 :param parser: the CLI parser
17 """
18 raise NotImplementedError
19
20 # noinspection PyUnusedLocal
21 def __init__(self, options):
22 """Create a new discovery mechanism.
23
24 :param options: the parsed options as defined within :meth:`add_parser_arguments`
25 """
26 self._has_run = False
27 self._interpreter = None
28
29 @abstractmethod
30 def run(self):
31 """Discovers an interpreter.
32
33
34 :return: the interpreter ready to use for virtual environment creation
35 """
36 raise NotImplementedError
37
38 @property
39 def interpreter(self):
40 """
41 :return: the interpreter as returned by :meth:`run`, cached
42 """
43 if self._has_run is False:
44 self._interpreter = self.run()
45 self._has_run = True
46 return self._interpreter