def buildTerms(terms): all = ["ALL", "All", "all"] for a in all: if a in terms: terms = SdoTermSource.getAllTerms(supressSourceLinks=True) break import time, datetime start = datetime.datetime.now() lastCount = 0 if len(terms): print("\nBuilding term pages...\n") for t in terms: tic = datetime.datetime.now() #diagnostics term = SdoTermSource.getTerm(t, expanded=True) if not term: print("No such term: %s\n" % t) continue if term.termType == SdoTerm.REFERENCE: #Don't create pages for reference types continue examples = SchemaExamples.examplesForTerm(term.id) pageout = termtemplateRender(term, examples) f = open(termFileName(term.id), "w") f.write(pageout) f.close() #diagnostics ########################################## termsofar = len(SdoTermSource.termCache()) #diagnostics termscreated = termsofar - lastCount #diagnostics lastCount = termsofar #diagnostics print("Term: %s (%d) - %s" % (t, termscreated, str(datetime.datetime.now() - tic))) #diagnostics # Note: (%d) = number of individual newly created (not cached) term definitions to # build this expanded definition. ie. All Properties associated with a Type, etc. if len(terms): print() print("All terms took %s seconds" % str(datetime.datetime.now() - start)) #diagnostics
#!/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()))