CleanFreak¶
A sanity checking framework for cg production, fully customizable through yaml configuration files. Use CleanFreak to check for and fix various issues in a scene prior publication.
Installation¶
CleanFreak is available through PyPi <http://pypi.python.org/pypi/cleanfreak>. Install using pip.
pip install cleanfreak
If you need pip get it here <http://pip.readthedocs.org/en/latest/installing.html>.
Contents¶
Getting Started¶
This section will guide you through the most basic usage of CleanFreak.
Showing the UI¶
from cleanfreak import CleanFreak
app = CleanFreak("maya.yml")
app.show()
Using CleanFreak without UI¶
from cleanfreak import CleanFreak
app = CleanFreak("maya.yml")
app.set_suite("Model")
app.run_checks()
print app.grade.format()
# Results:
#
# Grade Title
# 50%
# Grade Message
#
# Test Name Failed with an exception:
# *STACK TRACE*
#
# Test Name Failed:
# *FAIL MESSAGE*
app.run_fixes()
print app.grade.format()
# Results:
#
# Grade Title
# 100%
# Grade Message
Configuration¶
API Documentation¶
CleanFreak¶
- class cleanfreak.CleanFreak(context=None, cfg_root=None)¶
CleanFreak collects and runs Checker check() and fix() methods based on the config file in your configuration root directory. Configuration root is looked up in the following order.
- Parameter cfg_root passed to CleanFreak on instantiation
- Environment variable CLEANFREAK_CFG
- ~/cleanfreak
If the directory does not exist the default config in cleanfreak/conf is copied to the directory. Providing you with a default configuration to extend. The configuration root directory is then added to your pythonpath allowing you to load python modules from there. This is the best place to keep a module containing Checker objects.
Parameters: cfg_root – Optional configuration root directory. - grade¶
Returns a Grade with data based on the number of successful checks.
- list_suites()¶
Returns a list suite names.
- run_checks()¶
Executes check() for each Checker in the current suite. Emits three Message s.
- StartChecker is emitted prior to running checks.
- OnCheck is emitted after each check with the checker and a
- grade objects.
- FinishChecker is emitted after all checks are completed
with the final grade object.
- run_fixes()¶
Executes fix() for each Checker in the current suite. Emits three Message s.
- StartChecker is emitted prior to running checks.
- OnFix is emitted after each check with the checker and a
- grade objects.
- FinishChecker is emitted after all checks are completed
with the final grade object.
- set_suite(suite)¶
Sets the suite to the specified value. Collects all checkers listed in the suites configuration. Raises a KeyError if the squite is not in your configuration.
Parameters: suite – The key of your suite in config[‘SUITES’]
- show()¶
Shows a PySide UI to control the app. Parenting of the UI is handled by different subclasses of UI. You can set the context using the “CONTEXT” key of your configuration.
- successes¶
Returns the number of successful checks.
Checker¶
- class cleanfreak.Checker¶
Abstract Base Class for all Checkers. You must override the following attributes and methods:
Attr full_name: The full name of the Checker Attr description: A description of the issue the Checker checks Meth setup: Runs prior to any checking should include any necessary including imports, and attribute defaults :meth check: Checks for the described issue :meth fix: Recipe to fix the described issue if check does not pass
- check()¶
Do your scene check here including any relevant imports Return (True, message) if check passes Return (False, message) if check fails
nodes = cmds.ls(type='mesh') for node in nodes: if not has_uvs(node): self.no_uvs.append(node) if self.no_uvs: return False, self.fail_msg.format(self.no_uvs) return True, self.passed_msg
- fix()¶
Attempt to fix the issue check found.
if self.passed: return for node in self.no_uvs: automatic_map(node) return True, self.msg
- select()¶
Select the objects in Checker.selection that caused a failure.
- ::
- import pymel.core as pm pm.select(self.selection)
- setup()¶
OPTIONAL METHOD: Called prior to running Checker’s check method. Includes any relevant default values for attributes. Override if your checker requires some sort of setup.
import maya.cmds as cmds self.no_uvs = []