rfm2  22.0
A python-based rewrite of RenderMan for Maya
rfm2.utils.string_expr Namespace Reference

Classes

class  StringExpression
 

Functions

def time_this (f)
 
def fixup_file_name (inputNm)
 
def test (verbose=False)
 
def ntest (n)
 

Variables

 COUNTERS = None
 
 STD_TOKENS = OrderedDict()
 
 PARSING_EXPR
 

Detailed Description

Token substitution in strings.

We will use maya's <token> format and slightly extend it.
- our tokens are lower case but we accept capitalized tokens like Maya's.
- we allow for simple attribute lookups:
  - Explicit/named nodes: <rmanGlobals.hider_maxSamples>
  - Implicit nodes: <shape.hider_maxSamples>

Global tokens:
- <ws>: Current workspace root
- <pwd>: Current directory
- <file>: current scene name (with extension)
- <scene>: current scene name (no extension)
- <camera>: current camera
- <aov>: AOV display name
- <aovdir>: AOV directory name (without '_variance' if denoised)
- <ext>: image file extension
- <layer> <renderlayer>: render layer name
- <shape>: short shape name
- <shapepath>: long shape name
- <frame>: float frame number
- <f>: integer frame
- <f2> <f3> <f4>: zero-padded integer frame
- <jobid>: unique job id, i.e. '170524182112' (see <date> and <time>)
- <date>: current date, i.e. '17_05_24' for 24th of May 2017
- <time>: current time, i.e. '18-21-12' for 18h 21m 24s
- <version>: Current version
- <take>: Current take
- <assetlib>: Path to the standard RenderManAssetLibrary
- <imagedir>: images output path defined in rmanGlobals
- <integrator>: current integrator

Per-invocation tokens (optional):
- <shape>: the short shape name
- <shapepath>: the long shape name

Attribute lookups:
- <shape.frame> or <shapepath.frame>: the value of the 'frame' attribute on the
  current shape.
- It is also possible to define a default value in case the attribute doesn't
  exist:
    <rmanGlobal.woolala?2.5>

- We accepts a colon-separated python formatting string, when you need to format
  the output:
    if frame == 12.25,  <shape.frame:%04d>  ->  '0012'

Environment variable lookups:
- $MY_ENV_VAR: env vars must start with '$' and be all upper-case with a minimum
  length of 3 characters

NOTE: To run the tests, you will need to un-comment the @time_this decorators in
      StringExpression.

Function Documentation

◆ fixup_file_name()

def rfm2.utils.string_expr.fixup_file_name (   inputNm)

◆ ntest()

def rfm2.utils.string_expr.ntest (   n)

◆ test()

def rfm2.utils.string_expr.test (   verbose = False)
+ Here is the call graph for this function:

◆ time_this()

def rfm2.utils.string_expr.time_this (   f)
Function that can be used as a decorator to time any method.

Variable Documentation

◆ COUNTERS

rfm2.utils.string_expr.COUNTERS = None

◆ PARSING_EXPR

rfm2.utils.string_expr.PARSING_EXPR
Initial value:
1 = re.compile(r'<([\w\:]*[\w\.]+)(\?[\w\d\._-]+)*' # token
2  r'(:[^>]+)*>|' # formatter
3  r'\$\{?([A-Z0-9_]{3,})\}?')

◆ STD_TOKENS

rfm2.utils.string_expr.STD_TOKENS = OrderedDict()