-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirhelp.py
More file actions
48 lines (38 loc) · 937 Bytes
/
dirhelp.py
File metadata and controls
48 lines (38 loc) · 937 Bytes
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
import os
import sys
import re
from helpstring import helpstring
dirlist = []
helplist = helpstring.split('\n')
for index, line in enumerate(helplist):
if line == "":
line = "\n"
if line[0] == "$" or line[0] == "/":
helplist[index] = os.path.expandvars(line)
def no_matches(path):
print("No help found for", path)
def get_dir_info(path):
for index, string in enumerate(helplist):
if string == path:
while True:
if helplist[index][0] not in ["\n", "/", "$"]:
return helplist[index]
else:
index += 1
return None
for arg in sys.argv[1:]:
if os.path.exists(arg):
arg = os.path.abspath(arg)
dirlist.append(arg)
else:
print(arg, "does not exist.")
exit()
if len(dirlist) == 0:
dirlist.append(os.getcwd())
for path in dirlist:
pathinfo = get_dir_info(path)
if pathinfo is None:
no_matches(path)
break
print(path)
print(pathinfo)