Dict Model

Parsing is always the hardest part.

This component takes a dictionary data-structure and parses it into a nicely usable table.

You can define your model simply using the table of the component. When adjusting the table definition, the output will be cleared, but stays consistent over saves.

  • name: The name of the attribute in the parsed dictionary.
  • path: The expected path in the unparsed dictionary, using . notation. When a list is expected, feed it an integer.
  • default: The value that will be used when the member is not set.
  • required: set to True to throw an exception when the member does not exist.
  • type: used for the Get_Data methods. write int, bool, float etc. to get the correct member returned.
  • parser: define a function that will be executed before the data is saved. Perfect for timestamps.

Outputs: 
  1. TableDAT : The parsed table.

Parameters:
  • Clear: Removes all entries from the table.
  • Strict Valueparsing : If true, will throw a WrongType error when input and definition do not match up.
  • Unique Values : If true, will overwrite entries with the same index.
  • Clear on Write: Clears the complete set if Write is called.
  • Folder: Where to save static data. Data should be omitted from GIT, so default is TDImportCache
  • External: If true, data will be stored externaly.

Attirbutes:
  • Exceptions: A module holding the exceptions to catch. WrongType and EntryRequired.

Methods:
  • Write( list_of_dicts, dict) : Appends a dict or list of dicts to the output.
  • Get( index ) : Returns a dictionary of a specific entry. Returns none if item is not found.
  • Delete( index ) : Removes an entry from the table.
  • Clear(): Removes all entries.

Downloads: 261

Created at: 6.7.2021

Uploaded: 5.6.2022
Added optional usage of dictionary argument for a parser.
Download