<s> import yaml <EOL> import os <EOL> from dateutil . parser import parse as dateparse <EOL> from django . conf import settings <EOL> from django . core . management . base import BaseCommand , CommandError <EOL> from legislators . models import * <EOL> PROJECT_ROOT = getattr ( settings , '<STR_LIT>' ) <EOL> current_membership = os . path . join ( PROJECT_ROOT , '<STR_LIT:..>' , '<STR_LIT>' , '<STR_LIT:data>' , '<STR_LIT>' ) <EOL> def process_file ( filename ) : <EOL> print "<STR_LIT>" % ( filename ) <EOL> membership_records = yaml . load ( open ( filename , '<STR_LIT:r>' ) ) <EOL> for membership in membership_records : <EOL> if len ( membership ) == <NUM_LIT:4> : <EOL> print membership <EOL> committee = Committee . objects . get ( thomas_id = membership ) <EOL> print "<STR_LIT>" % ( committee ) <EOL> for member in membership_records [ membership ] : <EOL> bioguide = member [ '<STR_LIT>' ] <EOL> legislator = Legislator . objects . get ( bioguide = bioguide ) <EOL> print "<STR_LIT>" % ( legislator . last_name ) <EOL> try : <EOL> CurrentCommitteeMembership . objects . get ( committee = committee , member = legislator ) <EOL> except CurrentCommitteeMembership . DoesNotExist : <EOL> CurrentCommitteeMembership . objects . create ( <EOL> committee = committee , <EOL> member = legislator , <EOL> rank = member [ '<STR_LIT>' ] , <EOL> party = member [ '<STR_LIT>' ] , <EOL> title = member . get ( '<STR_LIT:title>' ) , <EOL> ) <EOL> class Command ( BaseCommand ) : <EOL> help = "<STR_LIT>" <EOL> requires_model_validation = False <EOL> def handle ( self , * args , ** options ) : <EOL> process_file ( current_membership ) </s>
