sidif package

Submodules

sidif.sidif module

Created on 06.11.2020

@author: wf

class sidif.sidif.Comment(comment, location)[source]

Bases: object

a comment with it’s location

class sidif.sidif.DataInterchange[source]

Bases: object

a data interchange

addComment(comment)[source]

add the given comment

addSchemaFromDict(pDict, context, parent, parentName)[source]

add schema information from the given dict

addTopic(name, context)[source]
addTriple(triple)[source]

add the given triple

Parameters

triple (Triple) – the triple to add

asSiDIF()[source]

convert me to SiDIF notation

fixId(name)[source]
static ofDict(pDict, context='context')[source]
toDictOfDicts()[source]

convert me to a dict of dicts following the “it” semantics

e.g.

JohnDoe isA Person
"John" is firstName of it
"Doe"  is lastName of it
35 is age of it

will have a pseudo - triple representation of

JohnDoe isA Person
John firstName it
Doe lastName it
35 age it

leading to a dict

{
   'JohnDoe': {
      'isA': Person,
      'firstName': John,
       'lastName': 'Doe'
      'age': 35
    }
}
Returns

the dict of dicts representation of the triples found

Return type

dict

class sidif.sidif.SiDIFParser(showErrors=True, debug=False)[source]

Bases: object

Parser for SiDIF Simple Data Interchange Format see http://wiki.bitplan.com/index.php/SiDIF

addContent(di, token, tokenName)[source]
convertToBoolean(tokenStr, location, token)[source]

convert the token to a boolean

convertToTime(tokenStr, location, token)[source]

convert a timeLiteral to a time

convertToTriple(tokenStr, location, group)[source]

convert the given token to a triple

Parameters
  • tokenStr (str) – the token string

  • location (object) – location of the parse process

  • group (ParseResults) – the expected triple defining group

getGrammar()[source]
getIdentifier()[source]
getLiteral()[source]

get the literal sub Grammar

static getUriRegexp()[source]

get a regular expression for an URI

getValueGrammar()[source]

sub grammar for value definition

handleComment(location, tokens)[source]

handle the comment given comment tokens

handleDateTimeLiteral(tokenStr, location, group)[source]

handle a date time literal

handleGroup(_tokenStr, _location, tokens)[source]
handleIdentifier(_tokenStr, _location, tokens)[source]

handle identifiers

handleLines(_tokenStr, _location, tokens)[source]

handle the line derived

handleStringLiteral(_tokenStr, _location, tokens)[source]

handle string literals

Parameters

tokens (ParseResults) – the tokens for the literal

parseText(sidif, title=None)[source]

parse the given sidif text

Parameters

sidif (str) – the SiDIF text to be parsed

Returns

ParseResult from pyParsing and error - one of these should be None

Return type

tuple

parseUrl(url, title=None)[source]

parse the sidif text from the given url

Parameters

url (str) – the url to read the SiDIF text from

parseWithGrammar(grammar, text, title=None)[source]

parse the given text with the given grammar optionally labeling the parse with the given title

Parameters
  • grammar (object) – a pyparsing grammar

  • text (str) – the text to be parsed

  • title (str) – optional title

printResult(pr, indent='')[source]

print the given parseResult recursively

Parameters
  • pr (object) – the ParseResult to print

  • indent (str) – initial indentation

warn(msg)[source]

show a warning with the given message

Parameters

msg (str) – the warning message

class sidif.sidif.Triple(pSubject, pPredicate, pObject, location=0)[source]

Bases: object

a pseudo - triple (subject,predicate,object) with it’s location

due to the “it” syntax the subject may contain the object and the real subject is the latest non it-reference

asLiteral(value)[source]
asSiDIF()[source]
dump(value)[source]

sidif.uml module

Created on 2020-11-12

@author: wf

class sidif.uml.PlantUml(copyRight=None, title=None, debug=False, withSkin=True)[source]

Bases: object

classdocs

asUmlDict(dif)[source]

return the given DataInterchange as a UML Dict

fromDIF(dif)[source]

create uml from a Data Interchange

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"

Module contents