Initial commit
This commit is contained in:
42
pyinfo.py
Normal file
42
pyinfo.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import sys
|
||||
import click
|
||||
|
||||
def print_list(name, l):
|
||||
print(f"{name}:")
|
||||
for v in l: print("\t", v)
|
||||
print()
|
||||
|
||||
def print_dict(name, d):
|
||||
print(f"{name}:")
|
||||
for k, v in d.items():
|
||||
print(f"\t{k:10}: {v}")
|
||||
print()
|
||||
|
||||
sys_vars = (
|
||||
"path",
|
||||
"meta_path",
|
||||
"orig_argv",
|
||||
"executable",
|
||||
"version",
|
||||
#"implementation",
|
||||
"prefix",
|
||||
"_is_gil_enabled",
|
||||
)
|
||||
|
||||
@click.command()
|
||||
def info():
|
||||
"""Show info about the current python environment."""
|
||||
for var in sys_vars:
|
||||
name = f"sys.{var}"
|
||||
value = getattr(sys, var)
|
||||
if callable(value):
|
||||
value = value()
|
||||
name += "()"
|
||||
|
||||
if isinstance(value, list): print_list(name, value)
|
||||
elif isinstance(value, dict): print_dict(name, value)
|
||||
else: print(f"{name:25}: {value}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
info()
|
||||
Reference in New Issue
Block a user