Sub routine to run the application.
53def run() -> int:
54 rc: int = 0
55 cwd = os.getcwd()
56
57 try:
58 while True:
60 'Listing Python virtual environments in "pyenv".'
61 )
63
64
65 versions_dir = os.path.join(
66 os.environ['PYENV_ROOT'],
67 'versions'
68 )
69 if not os.path.isdir(versions_dir):
70 log.error(
'Cannot find any Python version in "pyenv".')
71 log.info(
'Install a Python version 3.3+ into "pyenv".')
72 rc = 1
73 break
75 '*',
76 venv_capable=False,
77 as_paths=True
78 )
79 if len(vers) == 0:
80 log.error(
'Cannot find a Python version in "pyenv".')
81 log.info(
'Install a Python version 3.3+ into "pyenv".')
82 rc = 1
83 break
84 per = os.environ['PYENV_ROOT']
85
86 pyts = [
87 [tbl.HEADER, 'G', 'Venv-Capable', 'Version', '"pyenv" Location'],
88 [tbl.SEPARATOR]
89 ]
90 for ver in vers:
91 pyts_item = [
92 tbl.DATA,
95 os.path.basename(ver),
96 '%PYENV_ROOT%' + os.sep + ver[len(per):]
97 ]
98 pyts.append(pyts_item)
99
100 pyts.append([tbl.SEPARATOR])
101
102 pves = [
103 [tbl.HEADER, 'A', 'Version', 'Name', '"pyenv" Location'],
104 [tbl.SEPARATOR]
105 ]
106 for ver in vers:
108 for venv in venvs:
109 act = ' '
110 if (
111 ('PROMPT' in os.environ)
112 and
113 (f'({os.path.basename(venv)})' in os.environ['PROMPT'])
114 ):
115 act = '*'
116 pves.append([
117 tbl.DATA,
118 act,
119 os.path.basename(ver),
120 os.path.basename(venv),
121 '%PYENV_ROOT%' + os.sep + venv[len(per):]
122 ])
123
124 pves.append([tbl.SEPARATOR])
125
127 pyts,
128 headline='INSTALLED PYTHON VERSIONS (G = global):'
129 )
130 table_pyts.run()
131
133 pves,
134 headline='AVAILABLE PYTHON VIRTUAL ENVIRONMENTS (A = active):'
135 )
136 table_pves.run()
137
140
141 break
142
143 except:
145 rc = 1
146 finally:
147 os.chdir(cwd)
148 return rc
149
150
151
152
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".
int listProjectProperties()
Display the table, which shows a list about project properties.
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.
info((str, tuple) msg)
Log info message colored to console only.
error((str, tuple) msg)
Log error message colored to console only.