REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.32 KB
Close
//opt/alt/python37/lib/python3.7/site-packages/virtualenv/activation/via_template.py
Text
Base64
from __future__ import absolute_import, unicode_literals import os import sys from abc import ABCMeta, abstractmethod from six import add_metaclass from virtualenv.util.six import ensure_text from .activator import Activator if sys.version_info >= (3, 7): from importlib.resources import read_binary else: from importlib_resources import read_binary @add_metaclass(ABCMeta) class ViaTemplateActivator(Activator): @abstractmethod def templates(self): raise NotImplementedError def generate(self, creator): dest_folder = creator.bin_dir replacements = self.replacements(creator, dest_folder) generated = self._generate(replacements, self.templates(), dest_folder, creator) if self.flag_prompt is not None: creator.pyenv_cfg["prompt"] = self.flag_prompt return generated def replacements(self, creator, dest_folder): return { "__VIRTUAL_PROMPT__": "" if self.flag_prompt is None else self.flag_prompt, "__VIRTUAL_ENV__": ensure_text(str(creator.dest)), "__VIRTUAL_NAME__": creator.env_name, "__BIN_NAME__": ensure_text(str(creator.bin_dir.relative_to(creator.dest))), "__PATH_SEP__": ensure_text(os.pathsep), } def _generate(self, replacements, templates, to_folder, creator): generated = [] for template in templates: text = self.instantiate_template(replacements, template, creator) dest = to_folder / self.as_name(template) # use write_bytes to avoid platform specific line normalization (\n -> \r\n) dest.write_bytes(text.encode("utf-8")) generated.append(dest) return generated def as_name(self, template): return template.name def instantiate_template(self, replacements, template, creator): # read content as binary to avoid platform specific line normalization (\n -> \r\n) binary = read_binary(self.__module__, str(template)) text = binary.decode("utf-8", errors="strict") for key, value in replacements.items(): value = self._repr_unicode(creator, value) text = text.replace(key, value) return text @staticmethod def _repr_unicode(creator, value): # by default we just let it be unicode return value
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 8 × Files: 3
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
bash
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
batch
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
cshell
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
fish
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
nushell
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
powershell
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
python
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2024-03-03 22:53:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
activator.py
1.38 KB
lrw-r--r--
2022-01-02 15:54:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
via_template.py
2.32 KB
lrw-r--r--
2022-01-02 15:54:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
486 B
lrw-r--r--
2022-01-02 15:54:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).