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))
#!/usr/bin/env python3 # -*- 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 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 = ""
def loadExamples(): global LOADEDEXAMPLES if not LOADEDEXAMPLES: SchemaExamples.loadExamplesFiles("default") print("Loaded %d examples " % (SchemaExamples.count()))
#!/usr/bin/env python3 # -*- 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 """ import glob globpatterns = ["data/*examples.txt", "data/ext/*/*examples.txt"] files = [] for g in globpatterns: files.extend(glob.glob(g)) print("Loading %d files" % len(files)) SchemaExamples.loadExamplesFiles(files) for term in ["CreativeWork", "Person", "Atlas", "DefinedTerm"]: for ex in SchemaExamples.examplesForTerm(term): print("%s has example key: %s" % (term, ex.getKey()))