Return a tuple (roman numeral, accidentals, chord suffix). Examples: >>> parse_string('I') ('I', 0, '') >>> parse_string('bIM7') ('I', -1, 'M7')
(progression)
| 213 | |
| 214 | |
| 215 | def parse_string(progression): |
| 216 | """Return a tuple (roman numeral, accidentals, chord suffix). |
| 217 | |
| 218 | Examples: |
| 219 | >>> parse_string('I') |
| 220 | ('I', 0, '') |
| 221 | >>> parse_string('bIM7') |
| 222 | ('I', -1, 'M7') |
| 223 | """ |
| 224 | acc = 0 |
| 225 | roman_numeral = "" |
| 226 | suffix = "" |
| 227 | i = 0 |
| 228 | for c in progression: |
| 229 | if c == "#": |
| 230 | acc += 1 |
| 231 | elif c == "b": |
| 232 | acc -= 1 |
| 233 | elif c.upper() == "I" or c.upper() == "V": |
| 234 | roman_numeral += c.upper() |
| 235 | else: |
| 236 | break |
| 237 | i += 1 |
| 238 | suffix = progression[i:] |
| 239 | return (roman_numeral, acc, suffix) |
| 240 | |
| 241 | |
| 242 | def tuple_to_string(prog_tuple): |
no outgoing calls
no test coverage detected