Server IP : 66.29.132.122 / Your IP : 18.224.31.236 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/virtualenv/run/plugin/ |
Upload File : |
from argparse import ArgumentTypeError from collections import OrderedDict from .base import ComponentBuilder class ActivationSelector(ComponentBuilder): def __init__(self, interpreter, parser): self.default = None possible = OrderedDict( (k, v) for k, v in self.options("virtualenv.activate").items() if v.supports(interpreter) ) super().__init__(interpreter, parser, "activators", possible) self.parser.description = "options for activation scripts" self.active = None def add_selector_arg_parse(self, name, choices): self.default = ",".join(choices) self.parser.add_argument( f"--{name}", default=self.default, metavar="comma_sep_list", required=False, help="activators to generate - default is all supported", type=self._extract_activators, ) def _extract_activators(self, entered_str): elements = [e.strip() for e in entered_str.split(",") if e.strip()] missing = [e for e in elements if e not in self.possible] if missing: raise ArgumentTypeError(f"the following activators are not available {','.join(missing)}") return elements def handle_selected_arg_parse(self, options): selected_activators = ( self._extract_activators(self.default) if options.activators is self.default else options.activators ) self.active = {k: v for k, v in self.possible.items() if k in selected_activators} self.parser.add_argument( "--prompt", dest="prompt", metavar="prompt", help=( "provides an alternative prompt prefix for this environment " "(value of . means name of the current working directory)" ), default=None, ) for activator in self.active.values(): activator.add_parser_arguments(self.parser, self.interpreter) def create(self, options): return [activator_class(options) for activator_class in self.active.values()] __all__ = [ "ActivationSelector", ]