Skip to content

Commit dbd1860

Browse files
author
Joseph Damiba
committed
fixup to scripts
1 parent d2f05ad commit dbd1860

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

check-order.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
import sys
44

55
try:
6-
category = str(sys.argv[1])
6+
category = str(sys.argv[2])
77
except:
88
raise Exception("You need to specify a display_as category!")
99

10+
try:
11+
path = str(sys.argv[1])
12+
except:
13+
raise Exception("You need to specify a path!")
14+
1015
# will contain all posts with display_as: file_settings
1116
postFamily = []
1217

1318
#get all posts with frontmatter in md format
14-
for md_path in Path("python").glob("**/*.md"):
19+
for md_path in Path(path).glob("**/*.md"):
1520
post = frontmatter.load(str(md_path))
1621
if len(post.metadata.keys()) > 0:
1722
if "display_as" in post.metadata['jupyter']['plotly']:
@@ -21,21 +26,27 @@
2126
sortedPostFamily = sorted(postFamily, key = lambda i: i['order'])
2227

2328
order = []
29+
2430
for post in sortedPostFamily:
2531
order.append(post['order'])
2632

2733
if order[0] != 1:
2834
raise Exception("Order Check Failed! First post does not have order 1!")
2935

36+
def checkSequential(l):
37+
return all(i == j-1 for i, j in zip(l, l[1:]))
38+
3039
def checkConsecutive(l):
3140
return sorted(l) == list(range(min(l), max(l)+1))
3241

3342
print(order)
3443

3544
try:
36-
if not checkConsecutive(order):
37-
raise Exception("Order Check Failed! Posts are Not in Consecutive Order!")
45+
checkConsecutive(order)
3846
except:
39-
raise Exception("Order Check Failed! Orders are not all integers!!")
47+
raise Exception("Order Check Failed! Orders are not consecutive integers!!")
48+
49+
if not checkSequential(order):
50+
raise Exception("Order Check Failed! Orders are not sequential integers!!")
4051

4152
print("Order Checks Passed!")

enforce-order.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
import sys
44

55
try:
6-
category = str(sys.argv[1])
6+
category = str(sys.argv[2])
77
except:
88
raise Exception("You need to specify a display_as category!")
99

10+
try:
11+
path = str(sys.argv[1])
12+
except:
13+
raise Exception("You need to specify a path!")
14+
1015
# will contain all posts with display_as: file_settings
1116
postFamily = []
1217

0 commit comments

Comments
 (0)