nomenclate.core.tokens module

class nomenclate.core.tokens.TokenAttr(token='', label=None, case='', prefix='', suffix='')[source]

Bases: nomenclate.core.tools.Serializable

A TokenAttr represents a string token that we want to replace in a given nomenclate.core.formatter.FormatString It has 3 augmentation properties:

TokenAttr().case TokenAttr().prefix TokenAttr().suffix

These three settings enforce that after final rendering (finding matches in the config for the current token’s label and any custom rendering syntax the user added) we will upper case the result and add either the given prefix or suffix no matter what.

SERIALIZE_ATTRS = ['token', 'label', 'case', 'prefix', 'suffix']
property label

Get or set the current token’s “label” or value. Setting the label to a new value means it will be added as the internal “raw_string” which will be used to look up any given config value or be used if no config value is found.

set(value)[source]
to_json()[source]
property token

Get or set the current token. Setting the token to a new value means it will be validated and then added as the internal “raw_token” which will be used to look up any given config value or be used if no config value is found.

static validate_entries(*entries)[source]
class nomenclate.core.tokens.TokenAttrList(token_attrs)[source]

Bases: nomenclate.core.tools.Serializable

classmethod from_json(json_blob)[source]
has_token_attr(token)[source]
merge_json(json_blob)[source]
merge_token_attr(token_attr)[source]
purge_tokens(input_token_attrs=None)[source]

Removes all specified token_attrs that exist in instance.token_attrs

Parameters

token_attrs – list(str), list of string values of tokens to remove. If None, removes all

reset()[source]
to_json()[source]
property unset_token_attrs