|
|
@ -40,7 +40,7 @@ Checks
|
|
|
|
- Any sections made but not used in the skeleton will produce a warning.
|
|
|
|
- Any sections made but not used in the skeleton will produce a warning.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
|
|
|
from jinja2 import Environment, FileSystemLoader, StrictUndefined
|
|
|
|
import internal.units
|
|
|
|
import internal.units
|
|
|
|
import internal.sections
|
|
|
|
import internal.sections
|
|
|
|
import json
|
|
|
|
import json
|
|
|
@ -50,15 +50,14 @@ def load_units():
|
|
|
|
return internal.units.load()
|
|
|
|
return internal.units.load()
|
|
|
|
|
|
|
|
|
|
|
|
def load_sections(env, units):
|
|
|
|
def load_sections(env, units):
|
|
|
|
print "Loading sections..."
|
|
|
|
print "\nLoading sections..."
|
|
|
|
return internal.sections.load(env, units)
|
|
|
|
return internal.sections.load(env, units)
|
|
|
|
|
|
|
|
|
|
|
|
def create_from_skeleton(skeleton, sections):
|
|
|
|
def create_from_skeleton(skeleton, sections):
|
|
|
|
print "Creating spec from skeleton..."
|
|
|
|
print "\nCreating spec from skeleton..."
|
|
|
|
print "Section keys: %s" % (sections.keys())
|
|
|
|
print "Section keys: %s" % (sections.keys())
|
|
|
|
return skeleton.render(sections.data)
|
|
|
|
return skeleton.render(sections.data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_unaccessed(name, store):
|
|
|
|
def check_unaccessed(name, store):
|
|
|
|
unaccessed_keys = store.get_unaccessed_set()
|
|
|
|
unaccessed_keys = store.get_unaccessed_set()
|
|
|
|
if len(unaccessed_keys) > 0:
|
|
|
|
if len(unaccessed_keys) > 0:
|
|
|
@ -71,7 +70,10 @@ def main():
|
|
|
|
return json.dumps(input, indent=4)
|
|
|
|
return json.dumps(input, indent=4)
|
|
|
|
|
|
|
|
|
|
|
|
# make Jinja aware of the templates and filters
|
|
|
|
# make Jinja aware of the templates and filters
|
|
|
|
env = Environment(loader=FileSystemLoader("templates"))
|
|
|
|
env = Environment(
|
|
|
|
|
|
|
|
loader=FileSystemLoader("templates"),
|
|
|
|
|
|
|
|
undefined=StrictUndefined
|
|
|
|
|
|
|
|
)
|
|
|
|
env.filters["jsonify"] = jsonify
|
|
|
|
env.filters["jsonify"] = jsonify
|
|
|
|
|
|
|
|
|
|
|
|
# load up and parse the lowest single units possible: we don't know or care
|
|
|
|
# load up and parse the lowest single units possible: we don't know or care
|
|
|
@ -87,7 +89,6 @@ def main():
|
|
|
|
spec = create_from_skeleton(skeleton, sections)
|
|
|
|
spec = create_from_skeleton(skeleton, sections)
|
|
|
|
|
|
|
|
|
|
|
|
check_unaccessed("units", units)
|
|
|
|
check_unaccessed("units", units)
|
|
|
|
check_unaccessed("sections", sections)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open("spec.rst", "w") as f:
|
|
|
|
with open("spec.rst", "w") as f:
|
|
|
|
f.write(spec)
|
|
|
|
f.write(spec)
|
|
|
|