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.')
54def run(args: argparse.Namespace) -> int:
61 'Listing Python virtual environments in "pyenv".'
66 versions_dir = os.path.join(
67 os.environ[
'PYENV_ROOT'],
70 if not os.path.isdir(versions_dir):
71 log.error(
'Cannot find any Python version in "pyenv".')
72 log.info(
'Install a Python version 3.3+ into "pyenv".')
82 log.error(
'Cannot find a Python version in "pyenv".')
83 log.info(
'Install a Python version 3.3+ into "pyenv".')
87 per = os.environ[
'PYENV_ROOT']
90 [tbl.HEADER,
'A',
'Venv-Capable',
'Version',
'"pyenv" Location'],
98 os.path.basename(ver),
99 '%PYENV_ROOT%' + os.sep + ver[len(per):]
101 pyts.append(pyts_item)
103 pyts.append([tbl.SEPARATOR])
106 [tbl.HEADER,
'A',
'Version',
'Name',
'"pyenv" Location'],
114 (
'PROMPT' in os.environ)
116 (
'({})'.format(os.path.basename(venv))
in os.environ[
'PROMPT'])
122 os.path.basename(ver),
123 os.path.basename(venv),
124 '%PYENV_ROOT%' + os.sep + venv[len(per):]
127 pves.append([tbl.SEPARATOR])
131 headline=
'INSTALLED PYTHON VERSIONS (A = active):'
137 headline=
'AVAILABLE PYTHON VIRTUAL ENVIRONMENTS (A = active):'
169 parser = argparse.ArgumentParser(
171 prog=
'pyenv virtualenvs',
172 description=
'Output lists of Python versions, virtual environments and related project properties.'
178 action=argparse.BooleanOptionalAction,
179 help=
'Display project properties in local folder tree view.'
182 return parser.parse_args(), rc
228 except Exception
as exc:
233 '\x1b[91mERROR: Unexpected error "%s".\x1b[0m'
241if __name__ ==
"__main__":
int listProjectProperties(bool show_tree=False)
Display the table, which shows a list about project properties.
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.
str getGlobalStar(str ver)
Get the "*" marker for this version, if it is the globally selected version in "pyenv".
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] getPythonVersions(str version=' *', bool venv_capable=False, bool as_paths=False)
Get list of installed Python version directories in "pyenv".
str getColoredVenvCapability(str ver)
Get the colored virtual environment capability str for the specific version number or path.
verbose((str, tuple) msg)
Log verbose message colored to console only.
initLogging()
Initialize the logging.
info((str, tuple) msg)
Log info message colored to console only.
error((str, tuple) msg)
Log error message colored to console only.
int run(argparse.Namespace args)
Sub routine to run the application.
int main()
Main routine of the application.
tuple[(argparse.Namespace, None), int] parseCliArguments()
Parse CLI arguments for this application.