Orchestration cleanup
This commit is contained in:
parent
59deeffefe
commit
7e47eec4ae
@ -42,6 +42,7 @@ crt Cornet
|
|||||||
crtt Cornett (Zink)
|
crtt Cornett (Zink)
|
||||||
cv Child's voice
|
cv Child's voice
|
||||||
db Double Bass
|
db Double Bass
|
||||||
|
drum Drumset
|
||||||
dlcn Dulcian
|
dlcn Dulcian
|
||||||
dom Domra
|
dom Domra
|
||||||
dulc Dulcimer
|
dulc Dulcimer
|
||||||
@ -139,6 +140,18 @@ xyl Xylophone
|
|||||||
zith Zither
|
zith Zither
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ORCHESTRATIONS = {
|
||||||
|
'SATB': ('S', 'A', 'T', 'B'),
|
||||||
|
'String Quartet': ('Vln1', 'Vln2', 'Vla', 'Vc'),
|
||||||
|
'String Orchestra': ('Vln1', 'Vln2', 'Vla', 'Vc', 'Cb'),
|
||||||
|
'Chamber Orchestra': ('Vln1', 'Vln2', 'Vla', 'Vc', 'Cb',
|
||||||
|
'Fl1', 'Fl2', 'Cl1', 'Cl2', 'Hn1', 'Hn2',
|
||||||
|
'Tpt1', 'Tpt2', 'Tbn1', 'Tbn2', 'Tuba',
|
||||||
|
'Timp', 'Drum', 'Perc'),
|
||||||
|
'Custom': (),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
INSTRUMENTS = []
|
INSTRUMENTS = []
|
||||||
for line in ABBREVIATIONS.split('\n'):
|
for line in ABBREVIATIONS.split('\n'):
|
||||||
parts = line.strip().split(maxsplit=1)
|
parts = line.strip().split(maxsplit=1)
|
||||||
@ -146,8 +159,8 @@ for line in ABBREVIATIONS.split('\n'):
|
|||||||
name, _, _ = parts[1].partition('(')
|
name, _, _ = parts[1].partition('(')
|
||||||
INSTRUMENTS.append((parts[0], name))
|
INSTRUMENTS.append((parts[0], name))
|
||||||
|
|
||||||
INSTRUMENT_LOOKUP = dict(INSTRUMENTS)
|
INSTRUMENT_NAMES = dict(INSTRUMENTS)
|
||||||
TAG_LOOKUP = dict( ( (x[1].lower(), x[0]) for x in INSTRUMENTS ) )
|
INSTRUMENT_TAGS = dict( ( (x[1].lower(), x[0]) for x in INSTRUMENTS ) )
|
||||||
|
|
||||||
class Instrument(namedtuple('Instrument', ('name', 'variant'), defaults=[None])):
|
class Instrument(namedtuple('Instrument', ('name', 'variant'), defaults=[None])):
|
||||||
|
|
||||||
@ -162,7 +175,7 @@ class Instrument(namedtuple('Instrument', ('name', 'variant'), defaults=[None]))
|
|||||||
Instrument(name='Jaws Harp', variant=None)
|
Instrument(name='Jaws Harp', variant=None)
|
||||||
"""
|
"""
|
||||||
abbr, _, variant = tag.partition('-')
|
abbr, _, variant = tag.partition('-')
|
||||||
name = INSTRUMENT_LOOKUP.get(abbr.lower(), abbr)
|
name = INSTRUMENT_NAMES.get(abbr.lower(), abbr)
|
||||||
|
|
||||||
if variant:
|
if variant:
|
||||||
return cls(name, variant)
|
return cls(name, variant)
|
||||||
@ -176,7 +189,7 @@ class Instrument(namedtuple('Instrument', ('name', 'variant'), defaults=[None]))
|
|||||||
>>> Instrument('Double Bass').abbreviate()
|
>>> Instrument('Double Bass').abbreviate()
|
||||||
'db'
|
'db'
|
||||||
"""
|
"""
|
||||||
tag = TAG_LOOKUP.get(self.name.lower())
|
tag = INSTRUMENT_TAGS.get(self.name.lower())
|
||||||
if self.variant:
|
if self.variant:
|
||||||
tag = f"{tag}-{self.variant}"
|
tag = f"{tag}-{self.variant}"
|
||||||
return tag
|
return tag
|
||||||
|
|||||||
@ -25,18 +25,6 @@ logger = logging.getLogger(__name__)
|
|||||||
#logger.info("Library storage: %s", library_storage.__class__.__name__)
|
#logger.info("Library storage: %s", library_storage.__class__.__name__)
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
ORCHESTRATIONS = {
|
|
||||||
'SATB': ('S', 'A', 'T', 'B'),
|
|
||||||
'String Quartet': ('Vln1', 'Vln2', 'Vla', 'Vc'),
|
|
||||||
'String Orchestra': ('Vln1', 'Vln2', 'Vla', 'Vc', 'Cb'),
|
|
||||||
'Chamber Orchestra': ('Vln1', 'Vln2', 'Vla', 'Vc', 'Cb',
|
|
||||||
'Fl1', 'Fl2', 'Cl1', 'Cl2', 'Hn1', 'Hn2',
|
|
||||||
'Tpt1', 'Tpt2', 'Tbn1', 'Tbn2', 'Tuba',
|
|
||||||
'Timp', 'Drum', 'Perc'),
|
|
||||||
'Custom': (),
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
DOCTYPES = [
|
DOCTYPES = [
|
||||||
(1, 'PDF'),
|
(1, 'PDF'),
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import re
|
|||||||
from interface.views import EnsembleMixin, ProjectMixin
|
from interface.views import EnsembleMixin, ProjectMixin
|
||||||
from interface.models import Project
|
from interface.models import Project
|
||||||
from .models import Collection, Work, Document, Section
|
from .models import Collection, Work, Document, Section
|
||||||
from .imslp import INSTRUMENTS, TAG_LOOKUP
|
from .imslp import INSTRUMENT_TAGS, INSTRUMENTS
|
||||||
from . import forms, models
|
from . import forms, models
|
||||||
from .pdf_utils import extract_pages, extract_and_concat
|
from .pdf_utils import extract_pages, extract_and_concat
|
||||||
|
|
||||||
@ -277,13 +277,15 @@ class WorkAddDocumentView(EnsembleMixin, CreateView):
|
|||||||
# auto tag the document
|
# auto tag the document
|
||||||
|
|
||||||
name, _ = os.path.splitext(os.path.basename(doc.upload.name))
|
name, _ = os.path.splitext(os.path.basename(doc.upload.name))
|
||||||
parts = re.split(r'[^A-Za-z]+', name.lower())
|
parts = re.split(r'[^A-Za-z]+', name)
|
||||||
parts.reverse()
|
parts.reverse()
|
||||||
for word in parts:
|
for word in parts:
|
||||||
print(word)
|
try:
|
||||||
if word in TAG_LOOKUP:
|
tag = INSTRUMENT_TAGS[word.lower()]
|
||||||
doc.sections.create(tag=TAG_LOOKUP[word])
|
doc.sections.create(tag=tag)
|
||||||
break
|
break
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if self.request.headers['Accept'] == 'application/json':
|
if self.request.headers['Accept'] == 'application/json':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user