Html pages no include tags and completion date.
This commit is contained in:
@@ -4,15 +4,26 @@ import subprocess
|
||||
from operator import itemgetter
|
||||
from collections import namedtuple
|
||||
from os.path import getmtime
|
||||
import json
|
||||
|
||||
|
||||
def extract_metadata(ipynb_file):
|
||||
Metadata = namedtuple('Metadata', ['tags', 'completion_date'])
|
||||
with open(ipynb_file, 'r') as f:
|
||||
j = json.load(f)
|
||||
tags = j['metadata']['tags']
|
||||
completion_date = j['metadata']['completion_date']
|
||||
return Metadata(tags, completion_date)
|
||||
|
||||
|
||||
def file_name_to_solution(name):
|
||||
Solution = namedtuple('Solution', ["number", "ipynb", "html", "name"])
|
||||
Solution = namedtuple('Solution', ["number", "ipynb", "html", "name", "metadata"])
|
||||
number = int(name.replace("EulerProblem", "").replace(".ipynb", ""))
|
||||
ipynb = name
|
||||
metadata = extract_metadata(ipynb)
|
||||
html = name.replace(".ipynb", ".html")
|
||||
name = name.replace("EulerProblem", "Problem ").replace(".ipynb", "")
|
||||
return Solution(number, ipynb, html, name)
|
||||
name = name.replace("EulerProblem", "Problem ").replace(".ipynb", "")
|
||||
return Solution(number, ipynb, html, name, metadata)
|
||||
|
||||
|
||||
def get_solution_list(directory="./"):
|
||||
@@ -27,7 +38,7 @@ def convert_solutions_to_html(solutions):
|
||||
if getmtime(s.html) < getmtime(s.ipynb):
|
||||
args = ["ipython", "nbconvert", s.ipynb]
|
||||
subprocess.call(args)
|
||||
|
||||
|
||||
|
||||
def render_solutions(solutions):
|
||||
loader = jinja2.FileSystemLoader(searchpath="./")
|
||||
@@ -56,4 +67,4 @@ if __name__ == "__main__":
|
||||
solutions = get_solution_list()
|
||||
convert_solutions_to_html(solutions)
|
||||
render_solutions(solutions)
|
||||
ship_to_failx()
|
||||
#ship_to_failx()
|
||||
|
||||
Reference in New Issue
Block a user