comparison env/lib/python3.7/site-packages/virtualenv/discovery/discover.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
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