### Install vfxnaming Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/index.md Install the library using pip. ```bash pip install vfxnaming ``` -------------------------------- ### Configure Tokens and Rules Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/validating.md Setup tokens and define an active rule for subsequent validation operations. ```python import vfxnaming as n # CREATE TOKENS n.reset_tokens() n.add_token("whatAffects", fallback="nothing") n.add_token_number("digits") n.add_token( "category", natural="natural", practical="practical", dramatic="dramatic", volumetric="volumetric", default="natural", ) n.add_token( "function", key="key", fill="fill", ambient="ambient", bounce="bounce", rim="rim", custom="custom", kick="kick", default="custom", ) n.add_token("type", lighting="LGT", animation="ANI", default="lighting") # CREATE RULES n.add_rule("lights", "{category}_{function}_{whatAffects}_{digits}_{type}") n.set_active_rule("lights") ``` -------------------------------- ### Parsing Result Example Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md The dictionary output generated after parsing a valid name. ```python result = { "category": "dramatic", "function": "bounce", "whatAffects": "chars", "digits": 1, "type":"lighting" } ``` -------------------------------- ### Define Tokens and Rules Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md Configures tokens and a naming rule for lights, then sets the rule as active. ```python import vfxnaming as n # CREATE TOKENS n.add_token('whatAffects') n.add_token_number('digits') n.add_token( 'category', natural='nat', practical='pra', dramatic='dra', volumetric='vol', default='nat' ) n.add_token( 'function', key='key', fill='fil', ambient='amb', bounce='bnc', rim='rim', kick='kik', custom='cst', default='cst' ) n.add_token( 'type', lighting='LGT', animation='ANI', default='LGT' ) # CREATE RULES n.add_rule( 'lights', '{category}_{function}_{whatAffects}_{digits}_{type}' ) n.set_active_rule("lights") ``` -------------------------------- ### Define Tokens and Rules Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/solving.md Initialize tokens with various configurations and define a naming rule to be used for solving. ```python import vfxnaming as n # CREATE TOKENS n.add_token('whatAffects') n.add_token('shadowType', fallback='soft') n.add_token_number('digits') n.add_token( 'category', natural='nat', practical='pra', dramatic='dra', volumetric='vol', default='nat' ) n.add_token( 'function', key='key', fill='fil', ambient='amb', bounce='bnc', rim='rim', kick='kik', custom='cst', default='custom' ) n.add_token( 'type', lighting='LGT', animation='ANI', default='LGT' ) # CREATE RULES n.add_rule( 'lights', '{category}_{function}_{whatAffects}_{shadowType}_{digits}_{type}' ) n.set_active_rule("lights") ``` -------------------------------- ### Create and save a naming repository Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/repositories.md Defines tokens and rules in memory and saves the session to a specified directory. ```python import vfxnaming as n n.add_token('whatAffects') n.add_token_number('digits') n.add_token( 'category', natural='nat', practical='pra', dramatic='dra', volumetric='vol', default='nat' ) n.add_token( 'function', key='key', fill='fil', ambient='amb', bounce='bnc', rim='rim', kick='kik', custom='cst', default='cst' ) n.add_token( 'type', lighting='LGT', animation='ANI', default='LGT' ) n.add_rule( 'lights', '{category}_{function}_{whatAffects}_{digits}_{type}' ) my_repo = 'C:/path/to/my/repo' n.save_session(my_repo) ``` -------------------------------- ### Initialize Logger Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/index.md Initialize the logger to output to stdout or a log file. ```python from vfxnaming import logger logger.init_logger() ``` ```python from vfxnaming import logger logger.init_file_logger() ``` -------------------------------- ### Define various token types Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/repositories.md Demonstrates creating required, fallback, numeric, and optional tokens. ```python n.add_token('whatAffects') n.add_token('shadowType', fallback='soft') n.add_token_number('digits') n.add_token( 'category', natural='nat', practical='pra', dramatic='dra', volumetric='vol', default='nat' ) ``` -------------------------------- ### Define tokens in vfxnaming Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/tokens.md Demonstrates how to add required, fallback, numeric, and optional tokens to a naming instance. ```python n.add_token('whatLights') n.add_token('shadowType', fallback='soft') n.add_token_number('digits') n.add_token('category', natural='nat', practical='pra', dramatic='dra', volumetric='vol', default='nat') ``` -------------------------------- ### Load a naming repository session Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/repositories.md Restores a previously saved session from a directory and retrieves rules and tokens. ```python import vfxnaming as n my_repo = 'C:/path/to/my/repo' n.load_session(my_repo) all_rules = n.get_rules() all_tokens = n.get_tokens() ``` -------------------------------- ### Solve Names with Explicit and Implicit Arguments Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/solving.md Demonstrates different ways to call the solve function, including using full keyword arguments, partial arguments, or positional arguments. ```python n.solve( category='natural', function='custom', whatAffects='chars', digits=1, type='lighting' ) n.solve(whatAffects='chars', digits=1) n.solve('chars', 1) ``` -------------------------------- ### Add naming rules with patterns and anchoring Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/rules.md Use add_rule to define naming conventions. Anchoring options like Rule.ANCHOR_END can be used to force evaluation direction for patterns containing hardcoded values. ```python import vfxnaming as n n.add_rule( 'lights', '{category}_{function}_{whatAffects}_{digits}_{type}' ) n.add_rule( 'filename', '{side}-{region}_{side}-{region}_{side}-{region}' ) n.add_rule( 'filename', 'crazy_hardcoded_value_{awesometoken}', n.Rule.ANCHOR_END ) ``` -------------------------------- ### Define naming rules with anchors Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/repositories.md Registers naming rules with specific patterns and optional anchoring constraints. ```python n.add_rule( 'lights', '{category}_{function}_{whatAffects}_{digits}_{type}' ) n.add_rule( 'filename', 'crazy_hardcoded_value_{awesometoken}', n.Rule.ANCHOR_END ) ``` -------------------------------- ### Create Rule with Repeated Tokens Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md Defines a rule that uses the same token multiple times. ```python import vfxnaming as n n.add_token( 'side', center='C', left='L', right='R', default='C' ) n.add_token( 'region', orbital="ORBI", parotidmasseter="PAROT", mental="MENT", frontal="FRONT", zygomatic="ZYGO", retromandibularfossa="RETMAND" ) n.add_rule( "filename", '{side}-{region}_{side}-{region}_{side}-{region}' ) n.save_session() ``` -------------------------------- ### Solve Repeated Tokens Globally Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/solving.md Pass a single argument without a digit to apply the same value to all repetitions of that token. ```python n.solve( side="left", region1="mental", region2="parotidmasseter", region3="retromandibularfossa" ) ``` -------------------------------- ### Solve Repeated Tokens Explicitly Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/solving.md Pass each token repetition explicitly by appending an incremental digit to the token name. ```python n.solve( side1="center", side2="left", side3="right", region1="mental", region2="parotidmasseter", region3="retromandibularfossa" ) ``` -------------------------------- ### Result of Parsing Repeated Tokens Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md The dictionary output showing incremental digits appended to repeated token keys. ```python result = { "side1": "center", "region1": "frontal", "side2": "left", "region2": "orbital", "side3": "right", "region3": "zygomatic" } ``` -------------------------------- ### Solve Repeated Tokens Partially Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/solving.md Pass specific token repetitions explicitly; omitted tokens will fall back to their default values. ```python n.solve( side1="center", side3="right", region2="parotidmasseter", region3="retromandibularfossa" ) ``` -------------------------------- ### Validate Naming Strings Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/validating.md Perform validation checks against the active rule to determine if a string conforms to defined naming conventions. ```python n.validate("dramatic_bounce_chars_001_LGT") # Result: True n.validate("dramatic_bounce_nothing_001_LGT") # Result: True n.validate("dramatic_bounce_chars_001") # Result: False. Last token is missing. n.validate("whatEver_bounce_chars_001_LGT") # Result: False. whatEver is not a valid option for the category token. n.validate("dramatic_bounce_chars_01_LGT") # Result: False. Padding on numbers by default is 3, got 2 in these case. n.validate("dramatic_bounce_chars_v001_LGT") # Result: False. No prefix are defined by default or by the code above. n.validate("dramatic_bounce_chars_1000_LGT") # Result: True. Even though 1000 has 4 digits, we're validating padding, not the number of digits. ``` -------------------------------- ### Parse a Name Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md Executes the parsing function on a string based on the active rule. ```python n.parse("dramatic_bounce_chars_001_LGT") ``` -------------------------------- ### Clean Repeated Token Keys Source: https://github.com/xiancg/vfxnaming/blob/master/docs/source/usage/parsing.md Uses regular expressions to strip incremental digits from the parsed dictionary keys. ```python import re pattern = re.compile(r'[a-zA-Z]+') for key in result.keys(): print(pattern.search(key)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.