goblin.gremlin package

Submodules

goblin.gremlin.base module

class goblin.gremlin.base.BaseGremlinMethod(path=None, method_name=None, classmethod=False, property=False, defaults=None, transaction=True, imports=None)[source]

Bases: object

Maps a function in a groovy file to a method on a python class

configure_method(klass, attr_name, gremlin_path)[source]

Sets up the methods internals

Parameters:
  • klass (object) – The class object this function is being added to
  • attr_name (str) – The attribute name this function will be added as
  • gremlin_path (str) – The path to the gremlin file containing method
transform_params_to_database(params)[source]

Takes a dictionary of parameters and recursively translates them into parameters appropriate for sending over Rexpro.

Parameters:params (dict) – The parameters to be sent to the function
Return type:dict
class goblin.gremlin.base.GremlinMethod(path=None, method_name=None, classmethod=False, property=False, defaults=None, transaction=True, imports=None)[source]

Bases: goblin.gremlin.base.BaseGremlinMethod

Gremlin method that returns a graph element

class goblin.gremlin.base.GremlinTable(path=None, method_name=None, classmethod=False, property=False, defaults=None, transaction=True, imports=None)[source]

Bases: goblin.gremlin.base.GremlinMethod

Gremlin method that returns a table as its result

class goblin.gremlin.base.GremlinValue(path=None, method_name=None, classmethod=False, property=False, defaults=None, transaction=True, imports=None)[source]

Bases: goblin.gremlin.base.GremlinMethod

Gremlin Method that returns one value

goblin.gremlin.base.groovy_import(extra_import)[source]

goblin.gremlin.groovy module

goblin.gremlin.groovy.GroovyFileDef

alias of GroovyFileDefinition

class goblin.gremlin.groovy.GroovyFunction(name, args, body, defn)

Bases: tuple

args

Alias for field number 1

body

Alias for field number 2

defn

Alias for field number 3

name

Alias for field number 0

class goblin.gremlin.groovy.GroovyFunctionParser[source]

Bases: object

Given a string containing a single function definition this class will parse the function definition and return information regarding it.

FuncDefn = {{{{{"def" Re:('[A-Za-z_]\\w*')} "("} Re:('[A-Za-z_]\\w*') [, Re:('[A-Za-z_]\\w*')]...} ")"} "{"}
FuncName = Re:('[A-Za-z_]\\w*')
KeywordDef = "def"
VarName = Re:('[A-Za-z_]\\w*')
classmethod parse(data)[source]

Parse the given function definition and return information regarding the contained definition.

Parameters:data (str | basestring) – The function definition in a string
Return type:dict
class goblin.gremlin.groovy.GroovyImport(comment_list, import_strings, import_list)

Bases: tuple

comment_list

Alias for field number 0

import_list

Alias for field number 2

import_strings

Alias for field number 1

class goblin.gremlin.groovy.GroovyImportParser[source]

Bases: object

Given a string containing a single import definition this class will parse the import definition and return information regarding it.

CommentVar = comment
ImportDef = Suppress:("import")
ImportDefn = {{{Suppress:("import") Re:('[A-Za-z_.\\*]*') [. Re:('[A-Za-z_.\\*]*')]...} Suppress:(";")} [{Suppress:("//") comment [Empty comment]...}]}
ImportVarName = Re:('[A-Za-z_.\\*]*')
OptionalSpace = [" "]
classmethod parse(data)[source]

Parse the given import and return information regarding the contained import statement.

Parameters:data (str | basestring) – The import statement in a string
Return type:dict
goblin.gremlin.groovy.parse(filename)[source]

Parse Groovy code in the given file and return a list of information about each function necessary for usage in queries to database.

Parameters:filename (str) – The file containing groovy code.
Return type:list

goblin.gremlin.table module

class goblin.gremlin.table.Table(gremlin_result)[source]

Bases: object

A table accepts the results of a GremlinTable in it’s constructor. It can be iterated over like a normal list, but within the rows the dictionaries are accessible via .notation

For example:

# returns a table of people & my friend edge to them # the edge contains my nickname for that person friends = goblin.gremlin.GremlinTable()

def get_friends_and_my_nickname(self):

result = self.friends() for i in result:

print “{}:{}”.format(i.friend_edge.nickname, i.person.name)
next()[source]
class goblin.gremlin.table.Row(data)[source]

Bases: object

A row represent a table row, from which it’s columns can be accessed like a tuple or dict. Rows are read-only and accept elements or dicts with as initializers as a result of a GremlinTable query. Also the . getattr notation can be used to access elements

Example: row = Row({‘person’: Friend.create(....), ‘myval’: 3}) print “{}:{} - {}”.format(row.friend_edge.nickname, row.person.name, row.myval)

items()[source]
iteritems()[source]
keys()[source]
next()[source]
values()[source]