3
3
import sys
4
4
5
5
try :
6
- category = str (sys .argv [1 ])
6
+ category = str (sys .argv [2 ])
7
7
except :
8
8
raise Exception ("You need to specify a display_as category!" )
9
9
10
+ try :
11
+ path = str (sys .argv [1 ])
12
+ except :
13
+ raise Exception ("You need to specify a path!" )
14
+
10
15
# will contain all posts with display_as: file_settings
11
16
postFamily = []
12
17
13
18
#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" ):
15
20
post = frontmatter .load (str (md_path ))
16
21
if len (post .metadata .keys ()) > 0 :
17
22
if "display_as" in post .metadata ['jupyter' ]['plotly' ]:
21
26
sortedPostFamily = sorted (postFamily , key = lambda i : i ['order' ])
22
27
23
28
order = []
29
+
24
30
for post in sortedPostFamily :
25
31
order .append (post ['order' ])
26
32
27
33
if order [0 ] != 1 :
28
34
raise Exception ("Order Check Failed! First post does not have order 1!" )
29
35
36
+ def checkSequential (l ):
37
+ return all (i == j - 1 for i , j in zip (l , l [1 :]))
38
+
30
39
def checkConsecutive (l ):
31
40
return sorted (l ) == list (range (min (l ), max (l )+ 1 ))
32
41
33
42
print (order )
34
43
35
44
try :
36
- if not checkConsecutive (order ):
37
- raise Exception ("Order Check Failed! Posts are Not in Consecutive Order!" )
45
+ checkConsecutive (order )
38
46
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!!" )
40
51
41
52
print ("Order Checks Passed!" )
0 commit comments