tp package

Submodules

tp.gremlin module

Created on 2020-03-30

@author: wf

class tp.gremlin.RemoteGremlin(server='localhost', port=8182)[source]

Bases: object

helper for remote gremlin connections

Variables:
  • server – the server to connect to
  • port – the port to connect to
  • sharepoint – the directory that is the shared with the janusgraph instance e.g. via a docker bind/mount or volume
  • sharepath – the path o the sharepoint as seens by the janusgraph server
clean()[source]

clean the graph database by removing all vertices

close()[source]

close the remote connection

debug = False
open()[source]

open the remote connection

Returns:the remote graph traversal source
Return type:GraphTraversalSource
setSharepoint(sharepoint, sharepath)[source]

set up a sharepoint :param sharepoint: the directory that is the shared with the janusgraph instance e.g. via a docker bind/mount or volume :type sharepoint: str :param sharepath: the path o the sharepoint as seens by the janusgraph server :type sharepath: str

share(file)[source]

share the given file and return the path as seen by the server

Parameters:file (str) – path to the file to share
class tp.gremlin.TinkerPopAble[source]

Bases: object

mixin for classes to store and retrieve from tinkerpop graph database

static cache(rg, gfile, clazz, objectList, initFunction)[source]

generic caching

Parameters:
  • gfile (str) – the graph storage file
  • clazz (class) – the class of the objects in the objectList
  • objectList (list) – a list of instances to fill or read
  • initFunction (function) – a function to call to fill the cache
debug = False
static fields(instance)[source]
Returns:either the vars of the instance or the fields specified by the tpfields attribute
Return type:dict
fromMap(pMap)[source]

fill my attributes from the given pMap dict

Parameters:pmap (dict) – the dict to fill my attributes from
storeFields(fieldList)[source]

define the fields to be stored as tinkerpop vertice properties

Parameters:fieldList (list) – list of fields to be stored
toVertex(g)[source]

create a vertex from me

Parameters:g (GraphTraversalSource) – where to add me as a vertex
static writeCSV(csvfileName, objectList, fieldnames=None)[source]

write the given objectList to a CSV file

Parameters:
  • csvfileName (str) – the path for the CSV File to write to
  • objectList (list) – a list of instances for which CSV lines should be created
  • fieldnames (list) – an optional list of fieldnames - if set to None the fields will be derived from the first instance in the objectList

Module contents