Skip to main content

Module stringtools

Module stringtools 

Source
Expand description

music21’s common.stringTools: names recased and split, text compared and cleaned, and brackets matched.

Structs§

ParenthesesMatch
A bracketed stretch of text that parentheses_match found: music21’s ParenthesesMatch. Positions count characters.

Functions§

camel_case_to_hyphen
music21’s common.camelCaseToHyphen: a camel-cased name as words joined by replacement, lower case. A capital that starts a run of lower-case letters is set apart first, then any capital following a lower-case letter or a digit, which is the pair of substitutions music21 makes.
camel_case_to_hyphen_checked
camel_case_to_hyphen with music21’s checks on the replacement: one character, and not a capital, which the result would lose.
format_str
A debugging or warning message as music21’s common.formatStr makes one: the parts joined by spaces, ending in a newline.
get_num_from_str
The characters of a string that are among numbers, and the rest, each in order: music21’s getNumFromStr, whose numbers are the ten digits.
hyphen_to_camel_case
A replacement-joined name, movement-name, as a camel-cased one, movementName: music21’s hyphenToCamelCase.
is_python_space
Whether Python’s str.isspace counts a character as white space, which is Unicode’s white space and the four ASCII separators below it.
md5_hex
The MD5 digest of some bytes, in lower-case hexadecimal: music21’s getMd5, which hashes a string’s UTF-8.
normalize_filename
A name made safe as a file name: accents stripped, anything else outside ASCII dropped, and what is not a letter, a digit, _ or - made _, all but a four-character extension: music21’s normalizeFilename.
parentheses_match
Every bracketed stretch of a string, each with those nested in it: music21’s parenthesesMatch. A bracket after a backslash is not one, and either bracket may be longer than a character.
remove_punctuation
Text with ASCII’s punctuation taken out: music21’s removePunctuation.
space_camel_case
A camel-cased name, or one of letters and numbers, spaced into words: music21’s spaceCamelCase. A space goes before each capital and where numbers start or stop; each of keep_together, spaced out, is joined up again, and with replace_underscore an underscore is a space too. music21 keeps PMFC together where it is given nothing to keep.
str_repr
A string as Python’s repr writes it, in single quotes unless it holds one and no double quote.
strip_accents
Text with its accents taken off: music21’s stripAccents. Each character is decomposed for compatibility and its combining marks are dropped; ß becomes ss and curly quotes straight ones. A character with nothing to take off, like 音, is left as it is.
whitespace_equal
Whether two strings are the same once all their white space is taken out: music21’s whitespaceEqual.