-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjls
executable file
·51 lines (46 loc) · 1.08 KB
/
jls
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
#!/usr/bin/env python3
"""
"""
import glob
import sys
import os
import re
HOME = os.getenv("HOME")
NOTES = os.path.join(HOME, "notes")
padding = " "
# pattern = re.compile("^[\t\*]*")
def parse_line(line):
line = line.strip(" ")
x = line.lstrip("\t*")
n = len(line) - len(x)
x = x.strip()
line = padding * n + x
# # x = pattern.findall(line)
# # line = pattern.sub("", line)
# # s = padding * len(x)
return(line)
def print_stuff(files):
# content
for f in files:
print("%s:" % f)
fin = open(f, 'r')
for x in fin:
x = x.strip(" \n")
x = parse_line(x)
print(x)
print()
# index
print("Index:")
for f in files:
print(padding, f)
if __name__ == '__main__':
script_name = os.path.basename(sys.argv[0])
if script_name == 'jls':
files = glob.glob(os.path.join(NOTES, "journal_*"))
elif script_name == 'nls':
files = glob.glob(os.path.join(NOTES, "note_*"))
else:
print("something is wrong")
print(script_name)
files.sort(reverse=False)
print_stuff(files)