def validate(): COUNT = 0 ERRORCOUNT = 0 SchemaExamples.loadExamplesFiles("default") print("Loaded %d examples " % (SchemaExamples.count())) print("Processing") for ex in SchemaExamples.allExamples(sort=True): if len(EXLIST) == 0 or ex.getKey() in EXLIST: COUNT += 1 if not validateExample(ex): ERRORCOUNT += 1 print ("Processed %s examples %s invalid" % (COUNT,ERRORCOUNT))
import logging logging.basicConfig(level=logging.INFO) # dev_appserver.py --log_level debug . log = logging.getLogger(__name__) from schemaexamples import SchemaExamples, Example SchemaExamples.loadExamplesFiles("default") print("Loaded %d examples " % (SchemaExamples.count())) log.info("Processing") #Example.nextIdReset() changedFiles = [] changedCount = 0 for ex in SchemaExamples.allExamples(sort=True): if not ex.hasValidId(): ex.setKey(Example.nextId()) changedCount += 1 if not ex.getMeta('file') in changedFiles: changedFiles.append(ex.getMeta('file')) filename = "" f = None examples = SchemaExamples.allExamples(sort=True) if changedCount == 0: log.info("No new identifiers assigned") sys.exit(0) log.info("Writing %s updated examples into %s files" %
# -*- coding: UTF-8 -*- import sys import os for path in [os.getcwd(), "SchemaExamples"]: sys.path.insert(1, path) #Pickup libs from shipped lib directory import logging logging.basicConfig(level=logging.INFO) # dev_appserver.py --log_level debug . log = logging.getLogger(__name__) from schemaexamples import Example, SchemaExamples """ Load examples from file write back to another file """ SchemaExamples.loadExamplesFile("data/ext/pending/issue-894-examples.txt") #print(SchemaExamples.examplesForTerm("Event")) #filename = "out" + term.id +".html" filename = "SchemaExamples/example-code/out" exes = sorted(SchemaExamples.allExamples(), key=lambda x: (x.exmeta['file'], x.exmeta['filepos'])) f = open(filename, "w") for ex in exes: f.write(ex.serialize()) f.write("\n") f.close()