API

class c4dplugwiz.PluginWizard(config, plugin_type=None)[source]

CINEMA 4D plugin template wizard.

Main class which provides methods for replacements in the names and contents of files contained within a folder structure.

classmethod get_tokentable_listing(indent=3)[source]

Get a string with all data entries of the token table, including forms.

Parameters:indent (int) – how many spaces for indentation.
process_contents(exclude=None)[source]

Replace tokens in file contents based on rules.py

Parameters:exclude (string) – if filename (incl. ext) matches this regex, the file is excluded from being processed. Note that self.excluded_files are being skipped by default.
process_names(overwrite=False)[source]

Do magic token and rule based replacements in file and rootdir names.

A magic token has the form %!Value!% or %!ValueAsForm!% where Value is the value of an entry in the token table and Form a conjugate of that value.

E.g. Value might be PluginName which would result in the plugin’s name as entered by the user.

PluginNameAsID is PluginName taking the form of an ID, meaning it has invalid characters replaced, spaces stripped and converted to CamelCase form.

There are multiple such forms for each magic token. For an overview call print_tokentable().

Parameters:overwrite (bool) – if True, rename a file or rootdir even if it would replace an already existing file or rootdir.
class c4dplugwiz.TextFX[source]

Methods for processing and transforming text.

static abbreviate(word, maxchars=-1)[source]

Reduce some string to an abbreviation of a given length. Example:

>>> TextFX.abbreviate('AndisSSuper_PluginSTOP ')
'ASPS'
Parameters:
  • word (string) – the string to abbreviate
  • maxchars (int) – if > 0, determines length of abbreviation, e.g. with a length of 3, ‘ASPS’ above becomes ‘ASP’.
static decomp_unicode(word, canonical=True)[source]

Decompose Unicode character sequences using either canonical or nominal mapping.

E.g. LATIN SMALL LETTER E WITH ACUTE (U+00E9) becomes LATIN SMALL LETTER E (U+0065) + COMBINING ACUTE ACCENT (U+0301).

Parameters:
  • word (unicode) – the unicode word to decompose
  • canonical (bool) – if True non-combining diacritical marks will be mapped to their combining forms and maybe combined with the letter preceeding the position.
static precomp_unicode(word, canonical=True)[source]

Precompose Unicode character sequences, using either canonical or nominal mapping. E.g. LATIN SMALL LETTER E (U+0065) + COMBINING ACUTE ACCENT (U+0301) becomes LATIN SMALL LETTER E WITH ACUTE (U+00E9).

Parameters:
  • word (unicode) – the unicode word to preccompose
  • canonical (bool) – if True combining diacritical marks will be mapped to their non-combining forms when they cannot be combined with the letter preceeding the position.
static sanitize(word, safechar='_', replace_umlauts=False, replace_diacritics=False, replace_greek=False, allowed_chars='_\-()', errors='replace', encoding='utf-8')[source]

Sanitize word so that it might be used as a filename in an online transfer or in software that needs to work on a restricted set of names for files and other resource descriptors, e.g. only underscores are allowed, no accented characters, etc.

Tries to deal gracefully with higher order characters, such as diacritics so that the original meaning of a word may be preserved better than, for example, just replacing higher order chars with a char deemed safe, like an underbar ‘_’, e.g. given ‘Über’, ‘Ueber’ or ‘Uber’ are generally favorable to ‘_ber’.

Examples:

>>> TextFX.sanitize(u'Äsbëst-Shop')
u'_sb_st-Shop'
>>> TextFX.sanitize(u'Äsbëst-Shop', safechar='')
u'sbst-Shop'
>>> TextFX.sanitize(u'Äsbëst-Shop', safechar='', replace_umlauts=True)
u'Aesbst-Shop'
>>> TextFX.sanitize(u'Äsbëst-Shop', safechar='', replace_umlauts=True, replace_diacritics=True)
u'Aesbest-Shop'
>>> TextFX.sanitize(u'Äsbëst-Shop', safechar='', replace_umlauts=True, replace_diacritics=True, allowed_chars='')
u'AesbestShop'
Parameters:
  • word (string) – the word to sanitize
  • safechar (string) – the char to use for replacing non-allowed chars
  • replace_umlauts (bool) – if True, replace umlauts like ‘ä’ with a phonetic equivalent like ‘ae’.
  • replace_diacritics (bool) – if True, replace diacritics with a decomposed form where the mark is dropped (e.g. ‘ç’ becomes ‘c’)
  • replace_greek (bool) – if True, replace greek letters with their translitterated name, e.g. ‘π’ becomes ‘pi’.
  • allowed_chars (string) – string of chars to leave unchanged. Note that the string is used within a regex.
  • errors (string) – if ‘strict’ raise whatever exception occurred. If ‘replace’, replace each character that causes an error during processing with an underscore. Default is ‘replace’.
static split_camelcase(word)[source]

Split a CamelCaseString into ['Camel', 'Case', 'String'].

Parameters:word (string) – the string to split
static to_camelcase(word, capitalize=True)[source]

Convert ‘word’ to CamelCase.

Examples:

>>> TextFX.to_camelcase('hot flaming cats')
'HotFlamingCats'
>>> TextFX.to_camelcase('HotFlamingCats')
'HotFlamingCats'
>>> TextFX.to_camelcase('hotFlamingCats')
'HotFlamingCats'
>>> TextFX.to_camelcase('hot_flaming_cats')
'HotFlamingCats'
>>> TextFX.to_camelcase('Hot Flaming _ Cats')
'HotFlamingCats'
>>> print(TextFX.to_camelcase(u'höt_fläming_cäts', False))
hötFlämingCäts
Parameters:
  • word (unicode) – the string to convert
  • capitalized (bool) – if True, always capitalize the first character of the result.

Previous topic

Alternative Forms

This Page