-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjpypaths.py
55 lines (44 loc) · 1.54 KB
/
jpypaths.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Simple commmandline utility that prints all Jupyter paths"""
from jupyter_core import paths
def printVars(names):
"""Pretty print path vars by name
Parameters
----------
names list(str) - variable names"""
# Calculate the left column size
leftCol = max([len(name) for name in names]) + 1
space = ' ' * leftCol
# Print each var
for name in names:
# If the var is actually a method, invoke it.
values = getattr(paths, name)
if callable(values):
values = values()
# If this is a list, print the var name only on the first row.
if isinstance(values, list):
values = [str(value) for value in values]
print(name + (' ' * (leftCol - len(name))) + values[0])
# Followed by left column padding and the rest of the list
if len(values) > 1:
for value in values[1:]:
print(space + value)
# If it's not a list, print the var name and var value.
else:
print(name + (' ' * (leftCol - len(name))) + str(values))
# Print the most important variables first
print('Paths\n-----')
printVars([
'jupyter_config_dir',
'jupyter_config_path',
'jupyter_data_dir',
'jupyter_path',
'jupyter_runtime_dir'
])
# Print the variables used to calculate other variables second.
print('\n\nInternals\n---------')
printVars([
'ENV_CONFIG_PATH',
'ENV_JUPYTER_PATH',
'SYSTEM_CONFIG_PATH',
'SYSTEM_JUPYTER_PATH'
])