Move some constants into the constants file

This commit is contained in:
Raoul Snyman 2021-07-30 11:17:52 -07:00
parent 7541b88101
commit ba2e2e5ee9
2 changed files with 9 additions and 8 deletions

View File

@ -1,14 +1,8 @@
import re
from hyphen import Hyphenator
from chordpro.constants import KNOWN_DIRECTIVES, KNOWN_VERSE_TYPES
from chordpro.constants import DIRECTIVE, CHORD_WORD, CHORUS_MARKER, KNOWN_DIRECTIVES, \
START_OF, END_OF
DIRECTIVE = re.compile(r'\{(.*?): *(.*?)\}')
START_OF = re.compile(r'\{start_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')(: *(.*?))?\}')
END_OF = re.compile(r'\{end_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')\}')
CHORUS_MARKER = re.compile(r'\{chorus(: *(.*?))?\}')
CHORD_WORD = re.compile(r'(.*?)\[(.*?)\]')
HYPHEN_CACHE = {}
SYLLABLE_EXCEPTIONS = {
'outer': ['out', 'er']

View File

@ -1,3 +1,5 @@
import re
KNOWN_DIRECTIVES = [
('title', 't'),
('subtitle', 'st'),
@ -27,3 +29,8 @@ GERMAN_NOTES = '[CDEFGAH]'
NEOLATIN_NOTES = '(Do|Re|Mi|Fa|Sol|La|Si)'
CHORD_SUFFIXES = '(b|bb)?(#)?(m|maj7|maj|min7|min|sus)?(1|2|3|4|5|6|7|8|9)?'
SLIM_CHARS = 'fiíIÍjlĺľrtť.,;/ ()|"\'!:\\'
DIRECTIVE = re.compile(r'\{(.*?): *(.*?)\}')
START_OF = re.compile(r'\{start_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')(: *(.*?))?\}')
END_OF = re.compile(r'\{end_of_(' + '|'.join(KNOWN_VERSE_TYPES) + r')\}')
CHORUS_MARKER = re.compile(r'\{chorus(: *(.*?))?\}')
CHORD_WORD = re.compile(r'(.*?)\[(.*?)\]')