mgvWrapper module¶
-
mgvWrapper.connect(name=None, user=None, pwd=None)¶ Called at mangrove startup and used to set up global variables to access to the database. In this case the variable db, which stores the mongo connection.
-
mgvWrapper.createLink(nodeA, nodeB)¶ Create a link between two node objects.
This function can be empty. Used for optional complex database quieries.
Parameters:
-
mgvWrapper.createNode(father, code, **kwargs)¶ Create a mangrove object in the database.
Parameters: - father (one of the mangrove classes) – the parent mangrove object.
- code (str) – the code of the classe, i.e. “Node” or “GraphTemplate”.
- kwargs (dict) – attributes of the object.
Returns: a new uuid.
Return type: str
-
mgvWrapper.delDictionary(father, typeDic, name)¶ Delete an node data or parameter.
Parameters: - father (MgvNode) – the node.
- typeDic (str) – type of the dictionary (“Parameter” or “Data”).
- name (str) – name of the entry.
-
mgvWrapper.deleteGraph(pattern, keys)¶ Delete a graph in the database and all its hierarchy.
-
mgvWrapper.deleteLink(nodeA, nodeB)¶ Delete a link between two node objects.
This function can be empty. Used for optional complex database quieries.
Parameters:
-
mgvWrapper.deleteNode(node)¶ Delete an object in the database and all its hierarchy.
-
mgvWrapper.deleteNodeRecurs(project, pid)¶ This function isn’t called by mangrove and is used in the mongo wrapper only.
-
mgvWrapper.fromHtml(s)¶ Convert string from html formatting.
-
mgvWrapper.getBatchScript(project_name, name=None, uuid=None)¶ Return a MgvBatchScript object from the database.
Uuid or name has to be provided.
Parameters: - project_name (str) – the name of the project.
- name (str) – the name of the batchScript (optional).
- uuid (str) – the uuid of the batchScript (optional).
Returns: the batchScript.
Return type:
-
mgvWrapper.getGraphInfo(pattern, keys)¶ Get a graph details from its path.
Parameters: - pattern (MgvPattern) – the pattern.
- keys (list of str) – path of the graph from the pattern name to its name.
- Returns
- dict: a dictionary with a uuid value and a template_name value.
-
mgvWrapper.getGraphVars(pattern, keys)¶
-
mgvWrapper.getHud(project_name, name=None, uuid=None)¶ Return a MgvHud object from the database.
Uuid or name has to be provided.
Parameters: - project_name (str) – the name of the project.
- name (str) – the name of the hud (optional).
- uuid (str) – the uuid of the hud (optional).
Returns: the hud.
Return type:
-
mgvWrapper.getLockType(type)¶ Returns the lock property of a type.
Parameters: type (MgvType) – the type. Returns: the lock value (user name) of the type. None: the type has not been found. Return type: str
-
mgvWrapper.getNodeAttr(node, attr)¶ Returns an object attribute.
Parameters: - node (Mgv object) – the mangrove object.
- attr (str) – the attribute name.
Returns: The object attribute. None: The object has not been found.
Return type: str
-
mgvWrapper.getObjects(graph)¶ Returns the elements of a graph.
The graph is found in the database by its uuid if not None. By its path in other case.
Parameters: graph (MgvGraph) – the graph. Returns: The graph has not been found. dict: A complete dictionary representing the graph and all its elements.Return type: None
-
mgvWrapper.getPatternGraphs(pattern, with_node_named=None, with_type_named=None)¶ Returns a list of graph paths.
Parameters: - pattern (MgvPattern) – the pattern of the graphs to return.
- with_node_named (str) – only returns graphs that contains a node with this name (optional).
- with_type_named (str) – only returns graphs that contains a node with this type name (optional).
Returns: list of element formed as : [patternName,key0,..,keyN,graph_name].
Return type: list
-
mgvWrapper.getProject(project_name)¶ Returns a MgvProject object from the database from its name.
-
mgvWrapper.getProjectNames()¶ Returns the list of the projects’s names.
-
mgvWrapper.getType(project_name, name=None, uuid=None)¶ Return a MgvType object from the database.
Uuid or name has to be provided.
Parameters: - project_name (str) – the name of the project.
- name (str) – the name of the type (optional).
- uuid (str) – the uuid of the type (optional).
Returns: the type.
Return type:
-
mgvWrapper.getTypes(project_name)¶ Returns a list of the project types.
Parameters: project_name (str) – the project name. Returns: a list of the types. Return type: list of MgvType
-
mgvWrapper.graphExists(pattern, keys)¶ Check if a graph exists in the database.
Parameters: - pattern (MgvPattern) – the pattern.
- keys (list of str) – the graph path from the pattern name to the last key.
Returns: True if the graph exists.
Return type: bool
-
mgvWrapper.isString(var)¶
-
mgvWrapper.lockProject(project, user)¶ Set project lock property with user name if it’s empty.
Parameters: - project (MgvProject) – the project.
- user (str) – the user name.
Returns: same user name if lock was empty, else lock value.
Return type: str
-
mgvWrapper.setDictionary(father, typeDic, name, value)¶ Set an node data or parameter.
Parameters: - father (MgvNode) – the node.
- typeDic (str) – type of the dictionary (“Parameter” or “Data”).
- name (str) – name of the entry.
- value (str) – value of the entry.
-
mgvWrapper.setGraphVar(pattern, keys, name, newname=None, value=None, active=None)¶
-
mgvWrapper.setLockType(type, user)¶ Set the lock property of a type with a user name.
Parameters: - type (MgvType) – the type.
- user (str) – the user name.
-
mgvWrapper.setNodeAttr(node, **kwargs)¶ Set an object attributes.
Parameters: - node (Mgv object) – the mangrove object.
- kwargs – dictionary to set the object values.
Returns: True if object has been set.
Return type: bool
-
mgvWrapper.syncProject(project)¶ Copy and replace all the project data, including patterns, contexts and templates, to the database.
-
mgvWrapper.toHtml(s)¶ Convert string to html formatting.
-
mgvWrapper.unlockProject(project)¶ Set project lock property to empty.