Skip to content

Order refactor #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactoring check order script to check all display_as categories at …
…once
  • Loading branch information
Joseph Damiba committed Nov 11, 2019
commit a21e8d5518d8551aa4c9755dd1e62987473b5efe
60 changes: 28 additions & 32 deletions check-order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,43 @@
from pathlib import Path, PosixPath
import sys

try:
category = str(sys.argv[2])
except:
raise Exception("You need to specify a display_as category!")

categories = ["file_settings", "basic", "statistical", "scientific", "maps", "3d_charts", "multiple_axes"]
try:
path = str(sys.argv[1])
except:
raise Exception("You need to specify a path!")

# will contain all posts with display_as: file_settings
postFamily = []

#get all posts with frontmatter in md format
for md_path in Path(path).glob("**/*.md"):
post = frontmatter.load(str(md_path))
if len(post.metadata.keys()) > 0:
if "display_as" in post.metadata['jupyter']['plotly']:
if post.metadata['jupyter']['plotly']['display_as'] == category:
postFamily.append({'path':str(md_path), 'order' : post.metadata['jupyter']['plotly']['order']})

sortedPostFamily = sorted(postFamily, key = lambda i: i['order'])
for category in categories:
postFamily = []
#get all posts with frontmatter in md format
for md_path in Path(path).glob("**/*.md"):
post = frontmatter.load(str(md_path))
if len(post.metadata.keys()) > 0:
if "display_as" in post.metadata['jupyter']['plotly']:
if post.metadata['jupyter']['plotly']['display_as'] == category:
postFamily.append({'path':str(md_path), 'order' : post.metadata['jupyter']['plotly']['order']})

sortedPostFamily = sorted(postFamily, key = lambda i: i['order'])

order = []
order = []

for post in sortedPostFamily:
if post['order'] == 5:
raise Exception("Order Check Failed! Post {} cannot have order 5!".format(post['path']))
order.append(post['order'])
for post in sortedPostFamily:
if post['order'] == 5:
raise Exception("Order Check Failed! Post {} cannot have order 5!".format(post['path']))
order.append(post['order'])

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

def checkConsecutive(l):
return sorted(l) == list(range(min(l), max(l)+1))
if order[0] != 1:
raise Exception("Order Check Failed! First post does not have order 1!")

print(order)
def checkConsecutive(l):
return sorted(l) == list(range(min(l), max(l)+1))

try:
checkConsecutive(order)
except:
raise Exception("Order Check Failed! Orders are not consecutive integers!!")
try:
checkConsecutive(order)
except:
raise Exception("Order Check Failed! Orders are not consecutive integers!!")

print("Order Checks Passed!")
print("Order Checks Passed!")
order = []