30 '\x1b[101mCRITICAL %s\x1b[0m'
32 'Cannot find package "%s".'
37 '\x1b[37mINFO %s\x1b[0m'
39 'Install it using "pip". Then try again.')
53def run(args: argparse.Namespace) -> int:
60 version: str = args.version.strip()
61 name: str = args.name.strip()
79 log.warning(
'"Python {}" virtual environments "{}" not found.'.format(version, name))
80 log.info(
'Call "pyenv virtualenvs". Then try "pyenv virtualenvs-delete" again, giving correct arguments.')
85 [tbl.HEADER,
'Item',
'Version',
'Name',
'Path'],
88 for i
in range(len(envs)):
95 '\x1b[92m{}\x1b[0m'.format(version1),
96 '\x1b[91m{}\x1b[0m'.format(name1),
100 data.append([tbl.SEPARATOR])
111 log.notice(
'Deleting {} Python virtual environment{} from "pyenv":'.format(len(envs), plural))
112 log.notice(
' * Version: \x1b[0m"\x1b[92m{}\x1b[0m"'.format(version))
113 log.notice(
' * Name: \x1b[0m"\x1b[91m{}\x1b[0m"'.format(name))
117 headline=
'\x1b[91mSELECTED PYTHON VIRTUAL ENVIRONMENT{} TO DELETE:\x1b[0m'.format(plural.upper())
122 s = input(
'\x1b[94mDo you really want to delete {} item{}?\x1b[0m [\x1b[91myes\x1b[0m/\x1b[92mNo\x1b[0m]: '.format(plural1, plural)).strip().lower()
123 if (s ==
'')
or (
not s.startswith(
'y')):
131 for junction
in junctions:
137 'Matching "{}", {} virtual environment{} and its junction{} {} been deleted from "pyenv".'.format(
173 parser = argparse.ArgumentParser(
175 prog=
'pyenv virtualenv-delete',
176 description=
'Delete existing virtual environment in "pyenv". Wildcards are allowed.'
181 help=
'Python version, which contains the virtual environment you want to delete.'
186 help=
'Short name of the Python virtual environment, which you want to delete.'
189 return parser.parse_args(), rc
235 except Exception
as exc:
240 '\x1b[91mERROR: Unexpected error "%s".\x1b[0m'
248if __name__ ==
"__main__":
int auditPyEnv(str min_ver)
Check if "pyenv" version is greater or equal the given minimal version.
int auditGlobalPythonVersion(str min_ver)
Check if Python version is greater or equal the given minimal version.
int auditPlatform(str name)
Check if the program in running on the required platform.
tuple[str, str, str] parseEnvDir(str env_dir)
Parse virtual environment directory path.
list[str] getEnvs(str ver, str name=' *', bool as_paths=False)
Get list of installed virtual environments for a specific Python version in "pyenv".
list[str] getEnvJunctions(str path)
Scan the Pythons versions in "pyenv" for junctions, which points to a specific virtual environment di...
list[str] getPythonVersions(str version=' *', bool venv_capable=False, bool as_paths=False)
Get list of installed Python version directories in "pyenv".
warning((str, tuple) msg)
Log warning message colored to console only.
notice((str, tuple) msg)
Log notice message colored to console only.
verbose((str, tuple) msg)
Log verbose message colored to console only.
initLogging()
Initialize the logging.
success((str, tuple) msg)
Log success message colored to console only.
info((str, tuple) msg)
Log info message colored to console only.
error((str, tuple) msg)
Log error message colored to console only.
int main()
Main routine of the application.
int run(argparse.Namespace args)
Sub routine to run the application.
tuple[(argparse.Namespace, None), int] parseCliArguments()
Parse CLI arguments for this application.