mrv.mdepparse

Epydoc: mrv.mdepparse

Contains parser allowing to retrieve dependency information from maya ascii files and convert it into an easy-to-use networkx graph with convenience methods.

Functions

mrv.mdepparse.iterNetworkxGraph(graph, startItem, direction=0, prune=<function <lambda> at 0x2eca7d0>, stop=<function <lambda> at 0x2eca848>, depth=-1, branch_first=True, visit_once=True, ignore_startitem=1)
Returns:

iterator yielding pairs of depth, item

Parameters:
  • direction – specifies search direction, either : 0 = items being successors of startItem 1 = items being predecessors of startItem
  • prune – return True if item d,i in graph g should be pruned from result. d is the depth of item i
  • stop – return True if item d,i in graph g, d is the depth of item i stop the search in that direction. It will not be returned.
  • depth – define at which level the iteration should not go deeper if -1, there is no limit if 0, you would only get startitem. i.e. if 1, you would only get the startitem and the first level of predessessors/successors
  • branch_first – if True, items will be returned branch first, otherwise depth first
  • visit_once – if True, items will only be returned once, although they might be encountered several times
  • ignore_startitem – if True, the startItem will be ignored and automatically pruned from the result
Note:

this is an adjusted version of dge.iterShells

mrv.mdepparse.make_path(path)
Returns:A path instance of the correct type
Note:use this constructor if you use the Path.set_separator method at runtime to assure you will always create instances of the actual type, and not only of the type you imported last

Classes

Epydoc: mrv.mdepparse

class mrv.mdepparse.DiGraph(data=None, name='', **attr)

Bases: networkx.classes.graph.Graph

add_cycle(nlist, **attr)
add_edge(u, v, attr_dict=None, **attr)
add_edges_from(ebunch, attr_dict=None, **attr)
add_node(n, attr_dict=None, **attr)
add_nodes_from(nodes, **attr)
add_path(nlist, **attr)
add_star(nlist, **attr)
add_weighted_edges_from(ebunch, **attr)
adjacency_iter()
adjacency_list()
clear()
copy()
degree(nbunch=None, with_labels=False, weighted=False)
degree_iter(nbunch=None, weighted=False)
edges(nbunch=None, data=False)
edges_iter(nbunch=None, data=False)
get_edge_data(u, v, default=None)
has_edge(u, v)
has_node(n)
has_predecessor(u, v)
has_successor(u, v)
in_degree(nbunch=None, with_labels=False, weighted=False)
in_degree_iter(nbunch=None, weighted=False)
in_edges(nbunch=None, data=False)
in_edges_iter(nbunch=None, data=False)
is_directed()
is_multigraph()
nbunch_iter(nbunch=None)
neighbors(n)
neighbors_iter(n)
nodes(data=False)
nodes_iter(data=False)
nodes_with_selfloops()
number_of_edges(u=None, v=None)
number_of_nodes()
number_of_selfloops()
order()
out_degree(nbunch=None, with_labels=False, weighted=False)
out_degree_iter(nbunch=None, weighted=False)
out_edges(nbunch=None, data=False)
out_edges_iter(nbunch=None, data=False)
predecessors(n)
predecessors_iter(n)
remove_edge(u, v)
remove_edges_from(ebunch)
remove_node(n)
remove_nodes_from(nbunch)
reverse(copy=True)
selfloop_edges(data=False)
size(weighted=False)
subgraph(nbunch, copy=True)
successors(n)
successors_iter(n)
to_directed()
to_undirected()

Epydoc: mrv.mdepparse.MayaFileGraph

class mrv.mdepparse.MayaFileGraph(data=None, name='', **attr)

Bases: networkx.classes.digraph.DiGraph

Contains dependnecies between maya files including utility functions allowing to more easily find what you are looking for

addFromFiles(mafiles, parse_all_paths=False, to_os_path=<function <lambda> at 0x6261aa0>, os_path_to_db_key=<function <lambda> at 0x6261b18>)

Parse the dependencies from the given maya ascii files and add them to this graph

Note:

the more files are given, the more efficient the method can be

Parameters:
  • parse_all_paths – if True, default False, all paths found in the file will be used. This will slow down the parsing as the whole file will be searched for references instead of just the header of the file
  • to_os_path – functor returning an MA file from given posssibly parsed file that should be existing on the system parsing the files. The passed in file could also be an mb file ( which cannot be parsed ), thus it would be advantageous to return a corresponding ma file This is required as references can have environment variables inside of them
  • os_path_to_db_key – converts the given path as used in the filesystem into a path to be used as key in the database. It should be general. Ideally, os_path_to_db_key is the inverse as to_os_path.
Note:

if the parsed path contain environment variables you must start the tool such that these can be resolved by the system. Otherwise files might not be found

Todo:

parse_all_paths still to be implemented

add_cycle(nlist, **attr)
add_edge(u, v, attr_dict=None, **attr)
add_edges_from(ebunch, attr_dict=None, **attr)
add_node(n, attr_dict=None, **attr)
add_nodes_from(nodes, **attr)
add_path(nlist, **attr)
add_star(nlist, **attr)
add_weighted_edges_from(ebunch, **attr)
adjacency_iter()
adjacency_list()
clear()
copy()
classmethod createFromFiles(fileList, **kwargs)
Returns:

MayaFileGraph providing dependency information about the files in fileList and their subReference.

Parameters:
  • fileList – iterable providing the filepaths to be parsed and added to this graph
  • kwargs – alll arguemnts of addFromFiles are supported
degree(nbunch=None, with_labels=False, weighted=False)
degree_iter(nbunch=None, weighted=False)
depends(filePath, direction=0, to_os_path=<function <lambda> at 0x6261c08>, os_path_to_db_key=<function <lambda> at 0x6261c80>, return_unresolved=False, invalid_only=False, **kwargs)
Returns:

list of paths ( converted to os paths ) that are related to the given filePath

Parameters:
  • direction – specifies search direction, either : kAffects = Files that filePath affects kAffectedBy = Files that affect filePath
  • return_unresolved – if True, the output paths will not be translated to an os paths and you get the paths as stored in the graph. Please not that the to_os_path function is still needed to generate a valid key, depending on the format of filepaths stored in this graph
  • invalid_only – if True, only invalid dependencies will be returned, all including the invalid ones otherwise
  • to_os_path – see addFromFiles
  • os_path_to_db_key – see addFromFiles
  • kwargs – passed to iterNetworkxGraph
edges(nbunch=None, data=False)
edges_iter(nbunch=None, data=False)
get_edge_data(u, v, default=None)
has_edge(u, v)
has_node(n)
has_predecessor(u, v)
has_successor(u, v)
in_degree(nbunch=None, with_labels=False, weighted=False)
in_degree_iter(nbunch=None, weighted=False)
in_edges(nbunch=None, data=False)
in_edges_iter(nbunch=None, data=False)
invalidFiles()
Returns:list of filePaths that could not be parsed, most probably because they could not be found by the system
is_directed()
is_multigraph()
nbunch_iter(nbunch=None)
neighbors(n)
neighbors_iter(n)
nodes(data=False)
nodes_iter(data=False)
nodes_with_selfloops()
number_of_edges(u=None, v=None)
number_of_nodes()
number_of_selfloops()
order()
out_degree(nbunch=None, with_labels=False, weighted=False)
out_degree_iter(nbunch=None, weighted=False)
out_edges(nbunch=None, data=False)
out_edges_iter(nbunch=None, data=False)
predecessors(n)
predecessors_iter(n)
remove_edge(u, v)
remove_edges_from(ebunch)
remove_node(n)
remove_nodes_from(nbunch)
reverse(copy=True)
selfloop_edges(data=False)
size(weighted=False)
subgraph(nbunch, copy=True)
successors(n)
successors_iter(n)
to_directed()
to_undirected()

Exceptions

Epydoc: mrv.mdepparse

class mrv.mdepparse.NetworkXError

Bases: networkx.exception.NetworkXException

Exception for a serious error in NetworkX

args
message

Table Of Contents

Previous topic

mrv.util

Next topic

mrv.interface

This Page