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