Model

Model of the Model View Controller external link

Contains the classes for the

  • Hierarchy
  • Schemas
class model.schema.Hierarchy

Class: Hierarchy

Goal: Get the whole hierarchy of Schema.org

  • _schemas contains the actual schemas
  • _hierarchy contains a list of lists to maintain the same order as Schema.org
  • _property_types contains the input types
  • _version check to see whether a new version of Schema.org has been published
get_schema(thing)

Public function to obtain one schema

Parameters:thing – string, name of the schema to retrieve
Returns:schema
hierarchy

Public function to obtain the hierarchy

Returns:hierarchy- list
class model.schema.SchemaClass(thing, callback=None)

Class: SchemaClass

Goal: Get the properties and property types of a schema

  • _html (can) contain the html of the schema
  • parent contains a list of parents (complete with hierarchy)
  • properties contains the properties and property types
  • name
  • _callback optional callback function for thread-safety (used by the Schema bot)
  • is_alive indicator for the Schema bot
clean()

Class method used before dump to reduce the size of the pickle file

generator_callback(s_gen=None)

Method called by the SchemaClassGenerator after finishing

  • is_alive becomes False
  • the html gets analyzed
  • if there is a callback, it’s called (from Schema bot)
Parameters:s_gen – the SchemaClassGenerator or nothing
get_parent_class

Class method to get all parents of one schema used by Schema bot to create the hierarchy

Returns:list of lists
get_schema_body()

Method called by SchemaView.show_schema_properties

Returns:html
start(b_immediate=False)

Tries to get Schema from file

Otherwise, tries to get it from Internet

Parameters:b_immediate – Optional, if True will force join() on the Thread
class model.schema.SchemaClassGenerator(thing, generator_callback)

Class: SchemaClassGenerator

Goal: Get the markup of a schema thread-safe. This class can be started concurrently by the Schema bot

  • html from URL after decode("utf-8")
  • name of the schema
  • callback from SchemaClass
run()

Start the thread

Get the schema markup from the Internet

Call the SchemaClass back when done