2
2
from pathlib import Path , PosixPath
3
3
import sys
4
4
5
- try :
6
- category = str (sys .argv [2 ])
7
- except :
8
- raise Exception ("You need to specify a display_as category!" )
9
-
5
+ categories = ["file_settings" , "basic" , "statistical" , "scientific" , "maps" , "3d_charts" , "multiple_axes" ]
10
6
try :
11
7
path = str (sys .argv [1 ])
12
8
except :
13
9
raise Exception ("You need to specify a path!" )
14
10
15
- # will contain all posts with display_as: file_settings
16
- postFamily = []
17
-
18
- #get all posts with frontmatter in md format
19
- for md_path in Path (path ).glob ("**/*.md" ):
20
- post = frontmatter .load (str (md_path ))
21
- if len (post .metadata .keys ()) > 0 :
22
- if "display_as" in post .metadata ['jupyter' ]['plotly' ]:
23
- if post .metadata ['jupyter' ]['plotly' ]['display_as' ] == category :
24
- postFamily .append ({'path' :str (md_path ), 'order' : post .metadata ['jupyter' ]['plotly' ]['order' ]})
25
-
26
- sortedPostFamily = sorted (postFamily , key = lambda i : i ['order' ])
11
+ for category in categories :
12
+ postFamily = []
13
+ #get all posts with frontmatter in md format
14
+ for md_path in Path (path ).glob ("**/*.md" ):
15
+ post = frontmatter .load (str (md_path ))
16
+ if len (post .metadata .keys ()) > 0 :
17
+ if "display_as" in post .metadata ['jupyter' ]['plotly' ]:
18
+ if post .metadata ['jupyter' ]['plotly' ]['display_as' ] == category :
19
+ postFamily .append ({'path' :str (md_path ), 'order' : post .metadata ['jupyter' ]['plotly' ]['order' ]})
20
+
21
+ sortedPostFamily = sorted (postFamily , key = lambda i : i ['order' ])
27
22
28
- order = []
23
+ order = []
29
24
30
- for post in sortedPostFamily :
31
- if post ['order' ] == 5 :
32
- raise Exception ("Order Check Failed! Post {} cannot have order 5!" .format (post ['path' ]))
33
- order .append (post ['order' ])
25
+ for post in sortedPostFamily :
26
+ if post ['order' ] == 5 :
27
+ raise Exception ("Order Check Failed! Post {} cannot have order 5!" .format (post ['path' ]))
28
+ order .append (post ['order' ])
34
29
35
- if order [0 ] != 1 :
36
- raise Exception ("Order Check Failed! First post does not have order 1!" )
30
+ print (order )
37
31
38
- def checkConsecutive ( l ):
39
- return sorted ( l ) == list ( range ( min ( l ), max ( l ) + 1 ))
32
+ if order [ 0 ] != 1 :
33
+ raise Exception ( "Order Check Failed! First post does not have order 1!" )
40
34
41
- print (order )
35
+ def checkConsecutive (l ):
36
+ return sorted (l ) == list (range (min (l ), max (l )+ 1 ))
42
37
43
- try :
44
- checkConsecutive (order )
45
- except :
46
- raise Exception ("Order Check Failed! Orders are not consecutive integers!!" )
38
+ try :
39
+ checkConsecutive (order )
40
+ except :
41
+ raise Exception ("Order Check Failed! Orders are not consecutive integers!!" )
47
42
48
- print ("Order Checks Passed!" )
43
+ print ("Order Checks Passed!" )
44
+ order = []
0 commit comments