def setUp(self): self.dm = docsmodel.DocsModel() self.schema = docsmodel.get_schema_from_file( 'test_schemas/simple_object.json') self.parsed_items = self.dm.parse(self.schema)
def setUp(self): """Tests set up.""" self.docs_model = docsmodel.DocsModel() self.schema = docsmodel.get_schema_from_file('test_schemas/enum.json')
def setUp(self): self.docs_model = docsmodel.DocsModel() self.schema = docsmodel.get_schema_from_file( 'test_schemas/array_list.json')
def setUp(self): self.docs_model = docsmodel.DocsModel() self.schema = docsmodel.get_schema_from_file( 'test_schemas/string_defaults.json') self.parsed_items = self.docs_model.parse(self.schema)
def setUp(self): self.dm = docsmodel.DocsModel() self.schema = docsmodel.get_schema_from_file( 'test_schemas/number_defaults.json') self.parsed_items = self.dm.parse(self.schema)
def process(stuff): if isinstance(stuff, dict): l = [(k, process(v)) for (k, v) in stuff.iteritems()] keys = set(stuff) for order in orders: if keys.issubset(order) or keys.issuperset(order): return OrderedDict(sorted(l, key=lambda x: order.get(x[0], 0))) return OrderedDict(sorted(l)) if isinstance(stuff, list): return [process(x) for x in stuff] return stuff return process SCHEMA_HTML_FILE = "schema.html" schema = json.dumps(CONFIG_SCHEMA, sort_keys=True) schema = json.loads(schema, object_pairs_hook=OrderedDict) req = sorted(schema["required"]) custom_sort = make_custom_sort([req]) schema = custom_sort(schema) parsed_items = docsmodel.DocsModel().parse(schema)[1:] output = html_output.HtmlOutput().generate_output(parsed_items) with open(SCHEMA_HTML_FILE, "wt") as f: f.write(output)