lodstorage package

Submodules

lodstorage.csv module

class lodstorage.csv.CSV(name)[source]

Bases: lodstorage.lod.LOD

helper for converting data in csv format to list of dicts (LoD) and vice versa

Constructor

static fixTypes(lod: list)[source]

fixes the types of the given LoD.

static fromCSV(csvString: str, fields: list = None, delimiter=', ', quoting=2, **kwargs)[source]

convert given csv string to list of dicts (LOD)

Parameters:
  • csvStr (str) – csv string that should be converted to LOD
  • headerNames (list) – Names of the headers that should be used. If None it is assumed that the header is given.
Returns:

list of dicts (LoD) containing the content of the given csv string

static readFile(filename: str) → str[source]

Reads the given filename and returns it as string :param filename: Name of the file that should be returned as string

Returns:Content of the file as string
static restoreFromCSVFile(filePath: str, headerNames: list = None, withPostfix: bool = False)[source]

restore LOD from given csv file

Parameters:
  • filePath (str) – file name
  • headerNames (list) – Names of the headers that should be used. If None it is assumed that the header is given.
  • withPostfix (bool) – If False the file type is appended to given filePath. Otherwise file type MUST be given with filePath.
Returns:

list of dicts (LoD) containing the content of the given csv file

static storeToCSVFile(lod: list, filePath: str, withPostfix: bool = False)[source]

converts the given lod to CSV file.

Parameters:
  • lod (list) – lod that should be converted to csv file
  • filePath (str) – file name the csv should be stored to
  • withPostfix (bool) – If False the file type is appended to given filePath. Otherwise file type MUST be given with filePath.
Returns:

csv string of the given lod

static toCSV(lod: list, includeFields: list = None, excludeFields: list = None, delimiter=', ', quoting=2, **kwargs)[source]

converts the given lod to CSV string. For details about the csv dialect parameters see https://docs.python.org/3/library/csv.html#csv-fmt-params

Parameters:
  • lod (list) – lod that should be converted to csv string
  • includeFields (list) – list of fields that should be included in the csv (positive list)
  • excludeFields (list) – list of fields that should be excluded from the csv (negative list)
  • kwargs – csv dialect parameters
Returns:

csv string of the given lod

static writeFile(content: str, filename: str) → str[source]

Write the given str to the given filename :param content: string that should be written into the file :type content: str :param filename: Name of the file the given str should be written to

Returns:Nothing

lodstorage.entity module

lodstorage.jsonable module

This module has a class JSONAble for serialization of tables/list of dicts to and from JSON encoding

Created on 2020-09-03

@author: wf

class lodstorage.jsonable.JSONAble[source]

Bases: object

mixin to allow classes to be JSON serializable see

Constructor

asJSON(asString=True, data=None)[source]

recursively return my dict elements

Parameters:asString (boolean) – if True return my result as a string
checkExtension(jsonFile: str, extension: str = '.json') → str[source]

make sure the jsonFile has the given extension e.g. “.json”

Parameters:jsonFile (str) – the jsonFile name - potentially without “.json” suffix
Returns:the jsonFile name with “.json” as an extension guaranteed
Return type:str
fromDict(data: dict)[source]

initialize me from the given data

Parameters:data (dict) – the dictionary to initialize me from
fromJson(jsonStr)[source]

initialize me from the given JSON string

Parameters:jsonStr (str) – the JSON string
getJSONValue(v)[source]

get the value of the given v as JSON

Parameters:v (object) – the value to get
Returns:the the value making sure objects are return as dicts
getJsonTypeSamples()[source]

does my class provide a “getSamples” method?

static getJsonTypeSamplesForClass(cls)[source]

return the type samples for the given class

Returns:a list of dict that specify the types by example
Return type:list
classmethod getPluralname()[source]
static readJsonFromFile(jsonFilePath)[source]

read json string from the given jsonFilePath

Parameters:jsonFilePath (string) – the path of the file where to read the result from
Returns:the JSON string read from the file
reprDict(srcDict)[source]

get the given srcDict as new dict with fields being converted with getJSONValue

Parameters:scrcDict (dict) – the source dictionary
Returns
dict: the converted dictionary
restoreFromJsonFile(jsonFile: str)[source]

restore me from the given jsonFile

Parameters:jsonFile (string) – the jsonFile to restore me from
static singleQuoteToDoubleQuote(singleQuoted, useRegex=False)[source]

convert a single quoted string to a double quoted one

Parameters:
  • singleQuoted (str) –

    a single quoted string e.g.

    {‘cities’: [{‘name’: “Upper Hell’s Gate”}]}

  • useRegex (boolean) – True if a regular expression shall be used for matching
Returns:

the double quoted version of the string

Return type:

string

static singleQuoteToDoubleQuoteUsingBracketLoop(singleQuoted)[source]

convert a single quoted string to a double quoted one using a regular expression

Parameters:
  • singleQuoted (string) – a single quoted string e.g. {‘cities’: [{‘name’: “Upper Hell’s Gate”}]}
  • useRegex (boolean) – True if a regular expression shall be used for matching
Returns:

the double quoted version of the string e.g.

Return type:

string

static singleQuoteToDoubleQuoteUsingRegex(singleQuoted)[source]

convert a single quoted string to a double quoted one using a regular expression

Parameters:
  • singleQuoted (string) – a single quoted string e.g. {‘cities’: [{‘name’: “Upper Hell’s Gate”}]}
  • useRegex (boolean) – True if a regular expression shall be used for matching
Returns:

the double quoted version of the string e.g.

Return type:

string

static storeJsonToFile(jsonStr, jsonFilePath)[source]

store the given json string to the given jsonFilePath

Parameters:
  • jsonStr (string) – the string to store
  • jsonFilePath (string) – the path of the file where to store the result
storeToJsonFile(jsonFile: str, extension: str = '.json', limitToSampleFields: bool = False)[source]

store me to the given jsonFile

Parameters:
  • jsonFile (str) – the JSON file name (optionally without extension)
  • exension (str) – the extension to use if not part of the jsonFile name
  • limitToSampleFields (bool) – If True the returned JSON is limited to the attributes/fields that are present in the samples. Otherwise all attributes of the object will be included. Default is False.
toJSON(limitToSampleFields: bool = False)[source]
Parameters:limitToSampleFields (bool) – If True the returned JSON is limited to the attributes/fields that are present in the samples. Otherwise all attributes of the object will be included. Default is False.
Returns:a recursive JSON dump of the dicts of my objects
toJsonAbleValue(v)[source]

return the JSON able value of the given value v :param v: the value to convert :type v: object

class lodstorage.jsonable.JSONAbleList(listName: str = None, clazz=None, tableName: str = None, initList: bool = True, handleInvalidListTypes=False, filterInvalidListTypes=False)[source]

Bases: lodstorage.jsonable.JSONAble

Container class

Constructor

Parameters:
  • listName (str) – the name of the list attribute to be used for storing the List
  • clazz (class) – a class to be used for Object relational mapping (if any)
  • tableName (str) – the name of the “table” to be used
  • initList (bool) – True if the list should be initialized
  • handleInvalidListTypes (bool) – True if invalidListTypes should be converted or filtered
  • filterInvalidListTypes (bool) – True if invalidListTypes should be deleted
asJSON(asString=True)[source]

recursively return my dict elements

Parameters:asString (boolean) – if True return my result as a string
fromJson(jsonStr, types=None)[source]

initialize me from the given JSON string

Parameters:
  • jsonStr (str) – the JSON string
  • fixType (Types) – the types to be fixed
fromLoD(lod, append: bool = True, debug: bool = False)[source]

load my entityList from the given list of dicts

Parameters:
  • lod (list) – the list of dicts to load
  • append (bool) – if True append to my existing entries
Returns:

a list of errors (if any)

Return type:

list

getJsonData()[source]

get my Jsondata

getList()[source]

get my list

getLoDfromJson(jsonStr: str, types=None, listName: str = None)[source]

get a list of Dicts form the given JSON String

Parameters:
  • jsonStr (str) – the JSON string
  • fixType (Types) – the types to be fixed
Returns:

a list of dicts

Return type:

list

getLookup(attrName: str, withDuplicates: bool = False)[source]

create a lookup dictionary by the given attribute name

Parameters:
  • attrName (str) – the attribute to lookup
  • withDuplicates (bool) – whether to retain single values or lists
Returns:

a dictionary for lookup or a tuple dictionary,list of duplicates depending on withDuplicates

readLodFromJsonFile(jsonFile: str, extension: str = '.json')[source]

read the list of dicts from the given jsonFile

Parameters:jsonFile (string) – the jsonFile to read from
Returns:a list of dicts
Return type:list
readLodFromJsonStr(jsonStr) → list[source]

restore me from the given jsonStr

Parameters:storeFilePrefix (string) – the prefix for the JSON file name
restoreFromJsonFile(jsonFile: str) → list[source]

read my list of dicts and restore it

restoreFromJsonStr(jsonStr: str) → list[source]

restore me from the given jsonStr

Parameters:jsonStr (str) – the json string to restore me from
setListFromLoD(lod: list) → list[source]

set my list from the given list of dicts

Parameters:lod (list) –
Returns:
a list of dicts if no clazz is set
otherwise a list of objects
Return type:list
toJsonAbleValue(v)[source]

make sure we don’t store our meta information clazz, tableName and listName but just the list we are holding

class lodstorage.jsonable.JSONAbleSettings[source]

Bases: object

settings for JSONAble - put in a separate class so they would not be serialized

indent = 4

regular expression to be used for conversion from singleQuote to doubleQuote see https://stackoverflow.com/a/50257217/1497139

singleQuoteRegex = re.compile("(?<!\\\\)'")
class lodstorage.jsonable.Types(name: str, warnOnUnsupportedTypes=True, debug=False)[source]

Bases: lodstorage.jsonable.JSONAble

holds entity meta Info

Variables:name(string) – entity name = table name

Constructor

Parameters:
  • name (str) – the name of the type map
  • warnOnUnsupportedTypes (bool) – if TRUE warn if an item value has an unsupported type
  • debug (bool) – if True - debugging information should be shown
addType(listName, field, valueType)[source]

add the python type for the given field to the typeMap

Parameters:
  • listName (string) – the name of the list of the field
  • field (string) – the name of the field
  • valueType (type) – the python type of the field
fixListOfDicts(typeMap, listOfDicts)[source]

fix the type in the given list of Dicts

fixTypes(lod: list, listName: str)[source]

fix the types in the given data structure

Parameters:
  • lod (list) – a list of dicts
  • listName (str) – the types to lookup by list name
static forTable(instance, listName: str, warnOnUnsupportedTypes: bool = True, debug=False)[source]

get the types for the list of Dicts (table) in the given instance with the given listName :param instance: the instance to inspect :type instance: object :param listName: the list of dicts to inspect :type listName: string :param warnOnUnsupportedTypes: if TRUE warn if an item value has an unsupported type :type warnOnUnsupportedTypes: bool :param debug: True if debuggin information should be shown :type debug: bool

Returns:a types object
Return type:Types
getType(typeName)[source]

get the type for the given type name

getTypes(listName: str, sampleRecords: list, limit: int = 10)[source]

determine the types for the given sample records

Parameters:
  • listName (str) – the name of the list
  • sampleRecords (list) – a list of items
  • limit (int) – the maximum number of items to check
getTypesForItems(listName: str, items: list, warnOnNone: bool = False)[source]

get the types for the given items side effect is setting my types

Parameters:
  • listName (str) – the name of the list
  • items (list) – a list of items
  • warnOnNone (bool) – if TRUE warn if an item value is None
typeName2Type = {'bool': <class 'bool'>, 'date': <class 'datetime.date'>, 'datetime': <class 'datetime.datetime'>, 'float': <class 'float'>, 'int': <class 'int'>, 'str': <class 'str'>}

lodstorage.jsonpicklemixin module

lodstorage.lod module

Created on 2021-01-31

@author: wf

class lodstorage.lod.LOD(name)[source]

Bases: object

list of Dict aka Table

Constructor

static addLookup(lookup, duplicates, record, value, withDuplicates: bool)[source]

add a single lookup result

Parameters:
  • lookup (dict) – the lookup map
  • duplicates (list) – the list of duplicates
  • record (dict) – the current record
  • value (object) – the current value to lookup
  • withDuplicates (bool) – if True duplicates should be allowed and lists returned if False a separate duplicates
  • is created (list) –
static filterFields(lod: list, fields: list, reverse: bool = False)[source]

filter the given LoD with the given list of fields by either limiting the LoD to the fields or removing the fields contained in the list depending on the state of the reverse parameter

Parameters:
  • lod (list) – list of dicts from which the fields should be excluded
  • fields (list) – list of fields that should be excluded from the lod
  • reverse (bool) – If True limit dict to the list of given fields. Otherwise exclude the fields from the dict.
Returns:

LoD

static getFields(listOfDicts, sampleCount: int = None)[source]
static getLookup(lod: list, attrName: str, withDuplicates: bool = False)[source]

create a lookup dictionary by the given attribute name for the given list of dicts

Parameters:
  • lod (list) – the list of dicts to get the lookup dictionary for
  • attrName (str) – the attribute to lookup
  • withDuplicates (bool) – whether to retain single values or lists
Returns:

a dictionary for lookup

classmethod handleListTypes(lod, doFilter=False, separator=', ')[source]

handle list types in the given list of dicts

Parameters:
  • cls – this class
  • lod (list) – a list of dicts
  • doFilter (bool) – True if records containing lists value items should be filtered
  • separator (str) – the separator to use when converting lists
static intersect(listOfDict1, listOfDict2, key=None)[source]

get the intersection of the two lists of Dicts by the given key

static setNone(record, fields)[source]

make sure the given fields in the given record are set to none :param record: the record to work on :type record: dict :param fields: the list of fields to set to None :type fields: list

static setNone4List(listOfDicts, fields)[source]

set the given fields to None for the records in the given listOfDicts if they are not set :param listOfDicts: the list of records to work on :type listOfDicts: list :param fields: the list of fields to set to None :type fields: list

static sortKey(d, key=None)[source]

get the sort key for the given dict d with the given key

lodstorage.mwTable module

Created on 2020-08-21

@author: wf

class lodstorage.mwTable.MediaWikiTable(wikiTable=True, colFormats=None, sortable=True, withNewLines=False)[source]

Bases: object

helper for https://www.mediawiki.org/wiki/Help:Tables

Constructor

addHeader(record)[source]

add the given record as a “sample” header

addRow4Dict(record)[source]
asWikiMarkup()[source]

convert me to MediaWiki markup

Returns:the MediWiki Markup for this table
Return type:string
fromListOfDicts(listOfDicts)[source]
noneReplace(value)[source]

lodstorage.plot module

lodstorage.query module

lodstorage.sample module

Created on 2020-08-24

@author: wf

class lodstorage.sample.Cities(load=False)[source]

Bases: lodstorage.jsonable.JSONAbleList

class lodstorage.sample.Royal[source]

Bases: lodstorage.jsonable.JSONAble

i am a single Royal

Constructor

classmethod getSamples()[source]
class lodstorage.sample.Royals(load=False)[source]

Bases: lodstorage.jsonable.JSONAbleList

a non ORM Royals list

class lodstorage.sample.RoyalsORMList(load=False)[source]

Bases: lodstorage.jsonable.JSONAbleList

class lodstorage.sample.Sample[source]

Bases: object

Sample dataset generator

Constructor

cityList = None
static dob(isoDateString)[source]

get the date of birth from the given iso date state

static getCities()[source]

get a list of cities

static getCountries()[source]
static getRoyals()[source]
static getRoyalsInstances()[source]
static getSample(size)[source]

lodstorage.schema module

Created on 2021-01-26

@author: wf

class lodstorage.schema.Schema(name: str, title: str)[source]

Bases: object

a relational Schema

Constructor

Parameters:
  • name (str) – the name of the schema
  • title (str) – the title of the schema
static generalizeColumn(tableList, colName: str)[source]

remove the column with the given name from all tables in the tablelist and return it

Parameters:
  • tableList (list) – a list of Tables
  • colName (string) – the name of the column to generalize
Returns:

the column having been generalized and removed

Return type:

string

static getGeneral(tableList, name: str, debug: bool = False)[source]

derive a general table from the given table list :param tableList: a list of tables :type tableList: list :param name: name of the general table :type name: str :param debug: True if column names should be shown :type debug: bool

Returns:at table dict for the generalized table
static getGeneralViewDDL(tableList, name: str, debug=False) → str[source]

get the DDL statement to create a general view

Parameters:
  • tableList – the list of tables
  • name (str) – the name of the view
  • debug (bool) – True if debug should be set
class lodstorage.schema.SchemaManager(schemaDefs=None, baseUrl: str = None)[source]

Bases: object

a manager for schemas

constructor
Args:
schemaDefs(dict): a dictionary of schema names baseUrl(str): the base url to use for links

lodstorage.sparql module

lodstorage.sql module

Created on 2020-08-24

@author: wf

class lodstorage.sql.EntityInfo(sampleRecords, name, primaryKey=None, debug=False)[source]

Bases: object

holds entity meta Info

Variables:
  • name(string) – entity name = table name
  • primaryKey(string) – the name of the primary key column
  • typeMap(dict) – maps column names to python types
  • debug(boolean) – True if debug information should be shown

construct me from the given name and primary key

Parameters:
  • name (string) – the name of the entity
  • primaryKey (string) – the name of the primary key column
  • debug (boolean) – True if debug information should be shown
addType(column, valueType, sqlType)[source]

add the python type for the given column to the typeMap

Parameters:
  • column (string) – the name of the column
  • valueType (type) – the python type of the column
fixDates(resultList)[source]

fix date entries in the given resultList by parsing the date content e.g. converting ‘1926-04-21’ back to datetime.date(1926, 4, 21)

Parameters:resultList (list) – the list of records to be fixed
getCreateTableCmd(sampleRecords)[source]

get the CREATE TABLE DDL command for the given sample records

Parameters:sampleRecords (list) – a list of Dicts of sample Records
Returns:CREATE TABLE DDL command for this entity info
Return type:string

Example:

CREATE TABLE Person(name TEXT PRIMARY KEY,born DATE,numberInLine INTEGER,wikidataurl TEXT,age FLOAT,ofAge BOOLEAN)
getInsertCmd(replace: bool = False) → str[source]

get the INSERT command for this entityInfo

Parameters:replace (bool) – if True allow replace for insert
Returns:the INSERT INTO SQL command for his entityInfo e.g.
Return type:str

Example:

INSERT INTO Person (name,born,numberInLine,wikidataurl,age,ofAge) values (?,?,?,?,?,?).
class lodstorage.sql.SQLDB(dbname: str = ':memory:', connection=None, check_same_thread=True, timeout=5, debug=False, errorDebug=False)[source]

Bases: object

Structured Query Language Database wrapper

Variables:
  • dbname(string) – name of the database
  • debug(boolean) – True if debug info should be provided
  • errorDebug(boolean) – True if debug info should be provided on errors (should not be used for production since it might reveal data)

Construct me for the given dbname and debug

Parameters:
  • dbname (string) – name of the database - default is a RAM based database
  • connection (Connection) – an optional connection to be reused
  • check_same_thread (boolean) – True if object handling needs to be on the same thread see https://stackoverflow.com/a/48234567/1497139
  • timeout (float) – number of seconds for connection timeout
  • debug (boolean) – if True switch on debug
  • errorDebug (boolean) – True if debug info should be provided on errors (should not be used for production since it might reveal data)
RAM = ':memory:'
backup(backupDB, action='Backup', profile=False, showProgress: int = 200, doClose=True)[source]

create backup of this SQLDB to the given backup db

see https://stackoverflow.com/a/59042442/1497139

Parameters:
  • backupDB (string) – the path to the backupdb or SQLDB.RAM for in memory
  • action (string) – the action to display
  • profile (boolean) – True if timing information shall be shown
  • showProgress (int) – show progress at each showProgress page (0=show no progress)
backupProgress(status, remaining, total)[source]
close()[source]

close my connection

copyTo(copyDB, profile=True)[source]

copy my content to another database

Parameters:
  • copyDB (Connection) – the target database
  • profile (boolean) – if True show profile information
createTable(listOfRecords, entityName: str, primaryKey: str = None, withCreate: bool = True, withDrop: bool = False, sampleRecordCount=1, failIfTooFew=True)[source]

derive Data Definition Language CREATE TABLE command from list of Records by examining first recorda as defining sample record and execute DDL command

auto detect column types see e.g. https://stackoverflow.com/a/57072280/1497139

Parameters:
  • listOfRecords (list) – a list of Dicts
  • entityName (string) – the entity / table name to use
  • primaryKey (string) – the key/column to use as a primary key
  • withDrop (boolean) – true if the existing Table should be dropped
  • withCreate (boolean) – true if the create Table command should be executed - false if only the entityInfo should be returned
  • sampleRecords (int) – number of sampleRecords expected and to be inspected
  • failIfTooFew (boolean) – raise an Exception if to few sampleRecords else warn only
Returns:

meta data information for the created table

Return type:

EntityInfo

execute(ddlCmd)[source]

execute the given Data Definition Command

Parameters:ddlCmd (string) – e.g. a CREATE TABLE or CREATE View command
executeDump(connection, dump, title, maxErrors=100, errorDisplayLimit=12, profile=True)[source]

execute the given dump for the given connection

Parameters:
  • connection (Connection) – the sqlite3 connection to use
  • dump (string) – the SQL commands for the dump
  • title (string) – the title of the dump
  • maxErrors (int) – maximum number of errors to be tolerated before stopping and doing a rollback
  • profile (boolean) – True if profiling information should be shown
Returns:

a list of errors

getDebugInfo(record, index, executeMany)[source]

get the debug info for the given record at the given index depending on the state of executeMany

Parameters:
  • record (dict) – the record to show
  • index (int) – the index of the record
  • executeMany (boolean) – if True the record may be valid else not
getTableDict(tableType='table')[source]

get the schema information from this database as a dict

Parameters:tableType (str) – table or view
Returns:Lookup map of tables with columns also being converted to dict
Return type:dict
getTableList(tableType='table')[source]

get the schema information from this database

Parameters:tableType (str) – table or view
Returns:a list as derived from PRAGMA table_info
Return type:list
logError(msg)[source]

log the given error message to stderr

Parameters:msg (str) – the error messsage to display
progress(action, status, remaining, total)[source]

show progress

query(sqlQuery, params=None)[source]

run the given sqlQuery and return a list of Dicts

Parameters:
  • sqlQuery (string) – the SQL query to be executed
  • params (tuple) – the query params, if any
Returns:

a list of Dicts

Return type:

list

queryAll(entityInfo, fixDates=True)[source]

query all records for the given entityName/tableName

Parameters:
  • entityName (string) – name of the entity/table to qury
  • fixDates (boolean) – True if date entries should be returned as such and not as strings
queryGen(sqlQuery, params=None)[source]

run the given sqlQuery a a generator for dicts

Parameters:
  • sqlQuery (string) – the SQL query to be executed
  • params (tuple) – the query params, if any
Returns:

a generator of dicts

static restore(backupDB, restoreDB, profile=False, showProgress=200, debug=False)[source]

restore the restoreDB from the given backup DB

Parameters:
  • backupDB (string) – path to the backupDB e.g. backup.db
  • restoreDB (string) – path to the restoreDB or in Memory SQLDB.RAM
  • profile (boolean) – True if timing information should be shown
  • showProgress (int) – show progress at each showProgress page (0=show no progress)
restoreProgress(status, remaining, total)[source]
showDump(dump, limit=10)[source]

show the given dump up to the given limit

Parameters:
  • dump (string) – the SQL dump to show
  • limit (int) – the maximum number of lines to display
store(listOfRecords, entityInfo, executeMany=False, fixNone=False, replace=False)[source]

store the given list of records based on the given entityInfo

Parameters:
  • listOfRecords (list) – the list of Dicts to be stored
  • entityInfo (EntityInfo) – the meta data to be used for storing
  • executeMany (bool) – if True the insert command is done with many/all records at once
  • fixNone (bool) – if True make sure empty columns in the listOfDict are filled with “None” values
  • replace (bool) – if True allow replace for insert

lodstorage.storageconfig module

Created on 2020-08-29

@author: wf

class lodstorage.storageconfig.StorageConfig(mode=<StoreMode.SQL: 3>, cacheRootDir: str = None, cacheDirName: str = 'lodstorage', cacheFile=None, withShowProgress=True, profile=True, debug=False, errorDebug=True)[source]

Bases: object

a storage configuration

Constructor

Parameters:
  • mode (StoreMode) – the storage mode e.g. sql
  • cacheRootDir (str) – the cache root directory to use - if None the home directory will be used
  • cacheFile (string) – the common cacheFile to use (if any)
  • withShowProgress (boolean) – True if progress should be shown
  • profile (boolean) – True if timing / profiling information should be shown
  • debug (boolean) – True if debugging information should be shown
  • errorDebug (boolean) – True if debug info should be provided on errors (should not be used for production since it might reveal data)
getCachePath(ensureExists=True) → str[source]

get the path to the default cache

Parameters:name (str) – the name of the cache to use
static getDefault(debug=False)[source]
static getJSON(debug=False)[source]
static getJsonPickle(debug=False)[source]
static getSPARQL(prefix, endpoint, host, debug=False)[source]
static getSQL(debug=False)[source]
static getYaml(debug=False)[source]
class lodstorage.storageconfig.StoreMode[source]

Bases: enum.Enum

possible supported storage modes

JSON = 2
JSONPICKLE = 1
SPARQL = 4
SQL = 3
YAML = 5

lodstorage.tabulateCounter module

lodstorage.uml module

Created on 2020-09-04

@author: wf

class lodstorage.uml.UML(debug=False)[source]

Bases: object

UML diagrams via plantuml

Constructor :param debug: True if debug information should be shown :type debug: boolean

mergeSchema(schemaManager, tableList, title=None, packageName=None, generalizeTo=None, withSkin=True)[source]

merge Schema and tableList to PlantUml notation

Parameters:
  • schemaManager (SchemaManager) – a schema manager to be used
  • tableList (list) – the tableList list of Dicts from getTableList() to convert
  • title (string) – optional title to be added
  • packageName (string) – optional packageName to be added
  • generalizeTo (string) – optional name of a general table to be derived
  • withSkin (boolean) – if True add default BITPlan skin parameters
Returns:

the Plantuml notation for the entities in columns of the given tablelist

Return type:

string

skinparams = "\n' BITPlan Corporate identity skin params\n' Copyright (c) 2015-2020 BITPlan GmbH\n' see http://wiki.bitplan.com/PlantUmlSkinParams#BITPlanCI\n' skinparams generated by com.bitplan.restmodelmanager\nskinparam note {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam component {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam package {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam usecase {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam activity {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam classAttribute {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam interface {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam class {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nskinparam object {\n BackGroundColor #FFFFFF\n FontSize 12\n ArrowColor #FF8000\n BorderColor #FF8000\n FontColor black\n FontName Technical\n}\nhide Circle\n' end of skinparams '\n"
tableListToPlantUml(tableList, title=None, packageName=None, generalizeTo=None, withSkin=True)[source]

convert tableList to PlantUml notation

Parameters:
  • tableList (list) – the tableList list of Dicts from getTableList() to convert
  • title (string) – optional title to be added
  • packageName (string) – optional packageName to be added
  • generalizeTo (string) – optional name of a general table to be derived
  • withSkin (boolean) – if True add default BITPlan skin parameters
Returns:

the Plantuml notation for the entities in columns of the given tablelist

Return type:

string

lodstorage.yamlablemixin module

Module contents