Band Contacts to Google Contacts v4
This commit is contained in:
@@ -4,8 +4,8 @@ import datetime
|
||||
import re
|
||||
import sys
|
||||
|
||||
def clean_instrument_name(instrument_raw):
|
||||
"""Cleans the instrument name based on Percussion, Winds, and Default rules."""
|
||||
def clean_instrument_name(instrument_raw, grade_level):
|
||||
"""Cleans the instrument name based on Percussion, Winds, and Drum Major rules."""
|
||||
# Strip numerical prefix
|
||||
if '-' in instrument_raw:
|
||||
instrument = instrument_raw.split('-', 1)[-1].strip()
|
||||
@@ -14,9 +14,12 @@ def clean_instrument_name(instrument_raw):
|
||||
|
||||
lower_inst = instrument.lower()
|
||||
|
||||
# Pre-catch Drum Major so they are always cleanly named
|
||||
# Pre-catch Drum Major to apply Junior/Senior title
|
||||
if 'drum major' in lower_inst:
|
||||
return 'Drum Major'
|
||||
if grade_level.lower() == 'senior':
|
||||
return 'Senior Drum Major'
|
||||
else:
|
||||
return 'Junior Drum Major'
|
||||
|
||||
# 1. The Percussion Rule
|
||||
if 'percussion' in lower_inst and '(' in instrument and ')' in instrument:
|
||||
@@ -24,12 +27,11 @@ def clean_instrument_name(instrument_raw):
|
||||
if match:
|
||||
extracted = match.group(1).strip().title()
|
||||
|
||||
# Ensure "Drum" is in the name
|
||||
if 'Drum' not in extracted:
|
||||
if extracted.lower() in ['tenor', 'tenors']:
|
||||
# Explicitly only append "Drum(s)" to Snare and Tenors
|
||||
if extracted.lower() == 'snare':
|
||||
return 'Snare Drum'
|
||||
elif extracted.lower() in ['tenor', 'tenors']:
|
||||
return 'Tenor Drums'
|
||||
else:
|
||||
return f"{extracted} Drum"
|
||||
|
||||
return extracted
|
||||
|
||||
@@ -52,7 +54,7 @@ def get_category(instrument):
|
||||
return 'Woodwinds'
|
||||
if any(x in inst_lower for x in ['trumpet', 'mellophone', 'horn', 'trombone', 'baritone', 'euphonium', 'tuba', 'sousaphone']):
|
||||
return 'Brass'
|
||||
if any(x in inst_lower for x in ['percussion', 'snare', 'tenor', 'drum', 'cymbal', 'marimba', 'vibraphone', 'timpani', 'bells', 'electronics']):
|
||||
if any(x in inst_lower for x in ['percussion', 'snare', 'tenor', 'drum', 'cymbal', 'marimba', 'vibraphone', 'timpani', 'bells', 'electronics', 'aux', 'keyboard']):
|
||||
return 'Percussion'
|
||||
if 'guard' in inst_lower or 'color' in inst_lower:
|
||||
return 'Colorguard'
|
||||
@@ -116,15 +118,11 @@ def main():
|
||||
last_name = name_parts[0].strip() if len(name_parts) > 0 else ""
|
||||
first_name = name_parts[1].strip() if len(name_parts) > 1 else ""
|
||||
|
||||
# Parse and Clean Instrument
|
||||
section_raw = row.get('SECTION', '').strip()
|
||||
instrument = clean_instrument_name(section_raw)
|
||||
if not instrument:
|
||||
instrument = "Unknown"
|
||||
|
||||
# Parse Grade and formulate Notes
|
||||
# Parse Grade and formulate Notes FIRST (so we have grade_level for instruments)
|
||||
grade_raw = row.get('GRADE', '').strip()
|
||||
grade_match = re.match(r"(\d{4})\s*\((.*?)\)", grade_raw)
|
||||
grade_level = ""
|
||||
|
||||
if grade_match:
|
||||
grad_year = grade_match.group(1)
|
||||
grade_level = grade_match.group(2).capitalize()
|
||||
@@ -132,9 +130,15 @@ def main():
|
||||
else:
|
||||
notes = grade_raw
|
||||
|
||||
# Parse and Clean Instrument
|
||||
section_raw = row.get('SECTION', '').strip()
|
||||
instrument = clean_instrument_name(section_raw, grade_level)
|
||||
if not instrument:
|
||||
instrument = "Unknown"
|
||||
|
||||
# Determine Label
|
||||
category = get_category(instrument)
|
||||
label = f"{target_year} {category} ::: Marching Band ::: * myContacts"
|
||||
label = f"{target_year} {category} ::: {target_year} Marching Band ::: * myContacts"
|
||||
|
||||
# Build the output row
|
||||
out_row = {key: "" for key in google_headers}
|
||||
|
||||
Reference in New Issue
Block a user