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(f
'"Python {version}" virtual environments "{name}" not found.')
80 log.info(f
'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)):
92 [tbl.DATA, i + 1, f
'\x1b[92m{version1}\x1b[0m', f
'\x1b[91m{name1}\x1b[0m', path1]
94 data.append([tbl.SEPARATOR])
105 log.notice(f
'Deleting {len(envs)} Python virtual environment{plural} from "pyenv":')
106 log.notice(f
' * Version: \x1b[0m"\x1b[92m{version}\x1b[0m"')
107 log.notice(f
' * Name: \x1b[0m"\x1b[91m{name}\x1b[0m"')
111 headline=f
'\x1b[91mSELECTED PYTHON VIRTUAL ENVIRONMENT{plural.upper()} TO DELETE:\x1b[0m'
116 s = input(f
'\x1b[94mDo you really want to delete {plural1} item{plural}?\x1b[0m [\x1b[91myes\x1b[0m/\x1b[92mNo\x1b[0m]: ').strip().lower()
117 if (s ==
'')
or (
not s.startswith(
'y')):
125 for junction
in junctions:
131 f
'Matching "{name}", {len(envs)} virtual environment{plural} and its junction{plural} {plural2} been deleted from "pyenv".'
161 parser = argparse.ArgumentParser(
163 prog=
'pyenv virtualenv-delete',
164 description=
'Delete existing virtual environment in "pyenv". Wildcards are allowed.'
169 help=
'Python version, which contains the virtual environment you want to delete.'
174 help=
'Short name of the Python virtual environment, which you want to delete.'
177 return parser.parse_args(), rc
223 except Exception
as exc:
228 '\x1b[91mERROR: Unexpected error "%s".\x1b[0m'
236if __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.