zBuilder package

Submodules

zBuilder.IO module

class zBuilder.IO.BaseNodeEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
zBuilder.IO.check_data(data)[source]

Utility to check data format after loaded from josn. Used to check if data is wrapped in dictionary. If it isn’t it wraps it. Used to deal with older zBuilder files.

Parameters:data – Data to check.
Returns:Result of operation.
zBuilder.IO.dump_json(file_path, json_data)[source]

Saves a json file to disk given a file path and data.

Parameters:
  • file_path – The location to save the json file.
  • json_data – The data to save in the json.
Returns:

file path if successful.

Raises:

IOError – If not able to write file.

zBuilder.IO.find_class(module_, type_)[source]

Given a module and a type returns class object.

Parameters:
  • module (str) – The module to look for.
  • type (str) – The type to look for.
Returns:

class object.

Return type:

obj

zBuilder.IO.load_base_node(json_object)[source]

Loads json objects into proper classes. Serves as object hook for loading json.

Parameters:json_object (obj) – json obj to perform action on
Returns:Result of operation
Return type:obj
zBuilder.IO.load_json(file_path)[source]

loads a json file from disk given a file path.

Parameters:file_path – The location to save the json file.
Returns:json data
Raises:IOError – If not able to read file.
zBuilder.IO.update_json(json_object)[source]

This takes the json_object and updates it to work with zBuilder 1.0.0

Returns:modified json_object
zBuilder.IO.wrap_data(data, type_)[source]

Utility wrapper to identify data.

Parameters:
  • data
  • type (str) – The type of data it is.

zBuilder.builder module

zBuilder.bundle module

class zBuilder.bundle.Bundle[source]

Bases: object

Mixin class to deal with storing node data and component data. meant to be inherited by main.

append_scene_item(scene_item)[source]

appends a parameter to the parameter list. Checks if parameter is already in list, if it is it overrides the previous one.

Parameters:scene_item (obj) – the parameter to append to collection list.
compare(type_filter=[], name_filter=[])[source]

Compares info in memory with that which is in scene.

Parameters:
  • type_filter (list or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list
extend_scene_items(scene_items)[source]
Parameters:scene_items

Returns:

get_scene_items(type_filter=[], name_filter=[], name_regex=None, association_filter=[], association_regex=None, invert_match=False)[source]

Gets the scene items from builder for further inspection or modification.

Parameters:
  • type_filter (str or list, optional) – filter by parameter type. Defaults to list.
  • name_filter (str or list, optional) – filter by parameter name. Defaults to list.
  • name_regex (str) – filter by parameter name by regular expression. Defaults to None.
  • association_filter (str or list, optional) – filter by parameter association. Defaults to list.
  • association_regex (str) – filter by parameter association by regular expression. Defaults to None.
  • invert_match (bool) – Invert the sense of matching, to select non-matching items. Defaults to False
Returns:

List of scene items.

Return type:

list

print_(type_filter=[], name_filter=[])[source]

Prints out basic information for each scene item in the Builder. Information is all information that is stored in the __dict__. Useful for trouble shooting.

Parameters:
  • type_filter (list or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list
remove_scene_item(scene_item)[source]

Removes a scene_item from the bundle list while keeping order. :param scene_item: The scene_item object to remove. :type scene_item: obj

stats(type_filter='')[source]

Prints out basic information in Maya script editor. Information is scene item types and counts.

Parameters:type_filter (str) – filter by parameter type. Defaults to str
string_replace(search, replace)[source]

Searches and replaces with regular expressions the scene items in the builder.

Parameters:
  • search (str) – what to search for
  • replace (str) – what to replace it with

Example

replace r_ at front of item with l_:

>>> z.string_replace('^r_','l_')

replace _r at end of line with _l:

>>> z.string_replace('_r$','_l')

zBuilder.util module

zBuilder.zMaya module

Module contents