mgear.core.string module
string management methods
- mgear.core.string.convertRLName(name)
Convert a string with underscore
i.e: “_L”, “_L0_”, “L_”, “_L” to “R”. And vice and versa.
- Parameters:
name (string) – string to convert
- Returns:
Tuple of Integer
- mgear.core.string.convertRLName_old(name)
Convert a string with underscore
i.e: “_L”, “_L0_”, “L_”, “_L” to “R”. And vice and versa.
- Parameters:
name (string) – string to convert
- Returns:
Tuple of Integer
- mgear.core.string.normalize(string)
Replace all invalid characters with “_”
- Parameters:
string (string) – A string to normalize.
- Return string:
Normalized string
- mgear.core.string.normalize2(string)
Replace all invalid characters with “_”. including “-” This ensure that the name is compatible with Maya naming rules
- Parameters:
string (string) – A string to normalize.
- Return string:
Normalized string
- mgear.core.string.normalize_path(string)
Ensure that string path use always forward slash
- Parameters:
string (TYPE) – Description
- Returns:
Description
- Return type:
TYPE
- mgear.core.string.normalize_with_padding(string)
Replace all invalid characters with “_”. including “-” This ensure that the name is compatible with Maya naming rules
Also list of # symbol with properly padded index.
ie. count_### > count_001
- Parameters:
string (string) – A string to normalize.
- Return string:
Normalized string
- mgear.core.string.removeInvalidCharacter(string)
Remove all invalid character.
- Parameters:
string (string) – A string to normalize.
- Return string:
Normalized string.
- mgear.core.string.removeInvalidCharacter2(string)
Remove all invalid character. Incluede “_” and “.”as valid character.
- Parameters:
string (string) – A string to normalize.
- Return string:
Normalized string.
- mgear.core.string.replaceSharpWithPadding(string, index)
Replace a list of # symbol with properly padded index.
ie. count_### > count_001
- Parameters:
string (string) – A string to set. Should include ‘#’
index (integer) – Index to replace.
- Return string:
Normalized string.
- mgear.core.string.replace_string_in_file(search_string, replace_string, new_filename, source_path)
Replace all occurrences of a string in an ASCII file and save a copy.
- Parameters:
search_string (str) – string to search in the file.
replace_string (str) – string to replace the search_string with.
new_filename (str) – Name for the modified file.
source_path (str) – Path to the original ASCII file.
- Returns:
- (str) Path to the modified file,
(int) Number of replacements made.
- Return type:
tuple