<s> import re <EOL> import sys <EOL> import glob <EOL> import commands <EOL> import os <EOL> import stat <EOL> import subprocess <EOL> import zipfile <EOL> import rpy2 . robjects as robjects <EOL> import shutil <EOL> import psycopg2 as dbapi2 <EOL> import optparse <EOL> import string <EOL> import time <EOL> PUBLICMAPPINGPASS = "<STR_LIT>" <EOL> def clear_publicmapping_db ( ) : <EOL> db = dbapi2 . connect ( database = "<STR_LIT>" , user = "<STR_LIT>" , password = PUBLICMAPPINGPASS ) <EOL> cur = db . cursor ( ) <EOL> redtable = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for i in redtable : <EOL> cur . execute ( "<STR_LIT>" % i ) <EOL> db . commit ( ) <EOL> db . close ( ) <EOL> def drop_db ( ) : <EOL> olddir = os . getcwd ( ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ '<STR_LIT>' ] , shell = True ) <EOL> subprocess . check_call ( [ '<STR_LIT>' ] , shell = True ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:start>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:start>" ] ) <EOL> os . chdir ( olddir ) <EOL> def install_dependencies ( ) : <EOL> if ( os . path . exists ( "<STR_LIT>" ) == False ) : <EOL> cmdarg = '<STR_LIT>' <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> def get_census_data ( stateFips ) : <EOL> if ( stateFips < <NUM_LIT:10> ) : <EOL> stateFips = "<STR_LIT>" % stateFips <EOL> print '<STR_LIT>' <EOL> olddir = os . getcwd ( ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> cenBlockFilePrefix = '<STR_LIT>' % stateFips <EOL> cenTractFilePrefix = '<STR_LIT>' % stateFips <EOL> cenCountyFilePrefix = '<STR_LIT>' % stateFips <EOL> cmdarg = '<STR_LIT>' % cenBlockFilePrefix <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> cmdarg = '<STR_LIT>' % cenTractFilePrefix <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> cmdarg = '<STR_LIT>' % cenCountyFilePrefix <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> print '<STR_LIT>' <EOL> cmdarg = '<STR_LIT>' % stateFips <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> cmdarg = '<STR_LIT>' % stateFips <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" , cmdarg ] ) <EOL> print '<STR_LIT>' <EOL> for i in [ cenBlockFilePrefix , cenTractFilePrefix , cenCountyFilePrefix ] : <EOL> zfile = '<STR_LIT>' % i <EOL> print ( '<STR_LIT>' % zfile ) <EOL> myzip = zipfile . ZipFile ( zfile , '<STR_LIT:r>' ) <EOL> myzip . extractall ( ) <EOL> myzip = zipfile . ZipFile ( '<STR_LIT>' % stateFips , '<STR_LIT:r>' ) <EOL> myzip . extractall ( ) <EOL> print '<STR_LIT>' <EOL> if ( os . path . exists ( "<STR_LIT>" ) ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> if ( os . path . exists ( "<STR_LIT>" ) ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> if ( os . path . exists ( "<STR_LIT>" ) ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % cenBlockFilePrefix ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % cenTractFilePrefix ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % cenCountyFilePrefix ] ) <EOL> print '<STR_LIT>' <EOL> shutil . copy ( '<STR_LIT>' % stateFips , '<STR_LIT>' ) <EOL> if ( os . path . exists ( "<STR_LIT>" ) ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> if ( os . path . exists ( "<STR_LIT>" % stateFips ) ) : <EOL> shutil . copy ( "<STR_LIT>" % stateFips , '<STR_LIT>' ) <EOL> os . chdir ( olddir ) <EOL> class DictionaryTemplate : <EOL> def __init__ ( self , dict = { } , ** keywords ) : <EOL> self . dict = dict <EOL> self . dict . update ( keywords ) <EOL> def __str__ ( self ) : <EOL> return self . _template % self <EOL> def __getitem__ ( self , key ) : <EOL> return self . _process ( key . split ( "<STR_LIT:|>" ) ) <EOL> def _process ( self , l ) : <EOL> arg = l [ <NUM_LIT:0> ] <EOL> if len ( l ) == <NUM_LIT:1> : <EOL> if arg in self . dict : <EOL> return self . dict [ arg ] <EOL> elif hasattr ( self , arg ) and callable ( getattr ( self , arg ) ) : <EOL> return getattr ( self , arg ) ( ) <EOL> else : <EOL> raise KeyError ( arg ) <EOL> else : <EOL> func_name = l [ <NUM_LIT:1> ] <EOL> if func_name in self . dict : <EOL> func = self . dict [ func_name ] <EOL> else : <EOL> func = getattr ( self , func_name ) <EOL> return func ( self . _process ( [ arg ] ) ) <EOL> class ListTemplate : <EOL> def __init__ ( self , input_list = [ ] ) : <EOL> self . input_list = input_list <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:\n>" . join ( [ self . _template % x for x in self . input_list ] ) <EOL> class Empty_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT:U+0020>""" <EOL> class SldList_Template ( DictionaryTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> class Sld_Poly_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> class Sld_PolyB_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> class Sld_Line_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> class Sld_Range_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> class Sld_URange_Template ( ListTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> def gensld_none ( geoname ) : <EOL> target_file = '<STR_LIT>' % ( geoname ) <EOL> f = open ( target_file , '<STR_LIT:w>' ) <EOL> f . write ( str ( SldList_Template ( layername = "<STR_LIT>" % ( geoname ) , layertitle = "<STR_LIT>" % ( geoname ) , layerabs = "<STR_LIT>" , slst = [ ] , sli = Empty_Template , lst = [ { "<STR_LIT:title>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:1.0>" } ] , li = Sld_Poly_Template , elst = [ { "<STR_LIT:title>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:1.0>" } ] , eli = Sld_Line_Template ) ) ) <EOL> f . write ( "<STR_LIT:\n>" ) <EOL> f . close ( ) <EOL> os . chmod ( target_file , stat . S_IRUSR | stat . S_IRGRP | stat . S_IROTH ) <EOL> def gensld_boundaries ( geoname ) : <EOL> target_file = '<STR_LIT>' % ( geoname ) <EOL> f = open ( target_file , '<STR_LIT:w>' ) <EOL> f . write ( str ( SldList_Template ( layername = "<STR_LIT>" % ( geoname ) , layertitle = "<STR_LIT>" % ( geoname ) , layerabs = "<STR_LIT>" , slst = [ ] , sli = Empty_Template , lst = [ ] , li = Empty_Template , elst = [ { "<STR_LIT:title>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:2>" , "<STR_LIT>" : "<STR_LIT>" } ] , eli = Sld_PolyB_Template ) ) ) <EOL> f . write ( "<STR_LIT:\n>" ) <EOL> f . close ( ) <EOL> os . chmod ( target_file , stat . S_IRUSR | stat . S_IRGRP | stat . S_IROTH ) <EOL> def gensld_choro ( geoname , varname , vartitle , quantiles ) : <EOL> gensld_choro_internal ( geoname , varname , vartitle , quantiles , unit = "<STR_LIT>" ) <EOL> def gensld_choro_internal ( geoname , varname , vartitle , quantiles , unit = "<STR_LIT>" ) : <EOL> lvarname = string . lower ( varname ) <EOL> target_file = '<STR_LIT>' % ( geoname , lvarname ) <EOL> varabs = "<STR_LIT>" % ( varname ) <EOL> valuelist = [ <EOL> { "<STR_LIT>" : str ( quantiles [ <NUM_LIT:4> ] ) , <EOL> "<STR_LIT>" : str ( quantiles [ <NUM_LIT:3> ] ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1.0>" , <EOL> "<STR_LIT>" : unit } , <EOL> { "<STR_LIT>" : str ( quantiles [ <NUM_LIT:3> ] ) , <EOL> "<STR_LIT>" : str ( quantiles [ <NUM_LIT:2> ] ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1.0>" , <EOL> "<STR_LIT>" : unit } , <EOL> { "<STR_LIT>" : str ( quantiles [ <NUM_LIT:2> ] ) , <EOL> "<STR_LIT>" : str ( quantiles [ <NUM_LIT:1> ] ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1.0>" , <EOL> "<STR_LIT>" : unit } , <EOL> { "<STR_LIT>" : str ( quantiles [ <NUM_LIT:1> ] ) , <EOL> "<STR_LIT>" : str ( quantiles [ <NUM_LIT:0> ] ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1.0>" , <EOL> "<STR_LIT>" : unit } ] <EOL> svaluelist = [ { "<STR_LIT>" : str ( quantiles [ <NUM_LIT:5> ] ) , <EOL> "<STR_LIT>" : str ( quantiles [ <NUM_LIT:4> ] ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1.0>" , <EOL> "<STR_LIT>" : unit } ] <EOL> f = open ( target_file , '<STR_LIT:w>' ) <EOL> f . write ( str ( SldList_Template ( layername = lvarname , layertitle = vartitle , layerabs = varabs , slst = svaluelist , sli = Sld_URange_Template , lst = valuelist , li = Sld_Range_Template , elst = [ { "<STR_LIT:title>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:1.0>" } ] , eli = Sld_Line_Template ) ) ) <EOL> f . write ( "<STR_LIT:\n>" ) <EOL> f . close ( ) <EOL> os . chmod ( target_file , stat . S_IRUSR | stat . S_IRGRP | stat . S_IROTH ) <EOL> def gensld_choro_denquint ( geoname , varname , vartitle , dummy ) : <EOL> quantiles = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ] <EOL> gensld_choro_internal ( geoname , varname , vartitle , quantiles , unit = "<STR_LIT>" ) <EOL> class Config_Template ( DictionaryTemplate ) : <EOL> _template = """<STR_LIT>""" <EOL> def gen_config ( num_districts_congress , num_districts_senate , num_districts_house , sum_TOTPOP , has_election_data = <NUM_LIT:0> , has_vtds = <NUM_LIT:0> , conf_na = False , <EOL> target_na_congress = <NUM_LIT:0> , target_hisp_congress = <NUM_LIT:0> , target_bl_congress = <NUM_LIT:0> , <EOL> target_na_house = <NUM_LIT:0> , target_hisp_house = <NUM_LIT:0> , target_bl_house = <NUM_LIT:0> , <EOL> target_na_senate = <NUM_LIT:0> , target_hisp_senate = <NUM_LIT:0> , target_bl_senate = <NUM_LIT:0> , contiguityOverrideString = "<STR_LIT>" ) : <EOL> start_na = "<STR_LIT>" <EOL> start_elec = "<STR_LIT>" <EOL> end_elec = "<STR_LIT>" <EOL> end_na = "<STR_LIT>" <EOL> midlevel = "<STR_LIT>" <EOL> if ( conf_na == True ) : <EOL> start_na = "<STR_LIT>" <EOL> end_na = "<STR_LIT>" <EOL> midlevel_width = "<STR_LIT>" <EOL> midlevel_var = "<STR_LIT>" <EOL> if ( has_election_data == <NUM_LIT:1> ) : <EOL> start_elec = "<STR_LIT>" <EOL> end_elec = "<STR_LIT>" <EOL> if ( has_vtds == <NUM_LIT:1> ) : <EOL> midlevel = "<STR_LIT>" <EOL> midlevel_width = "<STR_LIT:4>" <EOL> midlevel_var = "<STR_LIT>" <EOL> pop_congress = int ( round ( ( sum_TOTPOP / float ( num_districts_congress ) ) ) ) <EOL> pop_congress_max = int ( round ( ( sum_TOTPOP / float ( num_districts_congress ) ) * <NUM_LIT> ) ) <EOL> pop_congress_min = int ( round ( ( sum_TOTPOP / float ( num_districts_congress ) ) * <NUM_LIT> ) ) <EOL> pop_house = int ( round ( ( sum_TOTPOP / float ( num_districts_house ) ) ) ) <EOL> pop_house_max = int ( round ( ( sum_TOTPOP / float ( num_districts_house ) ) * <NUM_LIT> ) ) <EOL> pop_house_min = int ( round ( ( sum_TOTPOP / float ( num_districts_house ) ) * <NUM_LIT> ) ) <EOL> pop_senate = int ( round ( ( sum_TOTPOP / float ( num_districts_senate ) ) ) ) <EOL> pop_senate_max = int ( round ( ( sum_TOTPOP / float ( num_districts_senate ) ) * <NUM_LIT> ) ) <EOL> pop_senate_min = int ( round ( ( sum_TOTPOP / float ( num_districts_senate ) ) * <NUM_LIT> ) ) <EOL> target_file = '<STR_LIT>' <EOL> f = open ( target_file , '<STR_LIT:w>' ) <EOL> f . write ( str ( Config_Template ( start_elec = start_elec , end_elec = end_elec , num_districts_congress = num_districts_congress , num_districts_house = num_districts_house , num_districts_senate = num_districts_senate , pop_congress_max = pop_congress_max , pop_congress_min = pop_congress_min , pop_senate_max = pop_senate_max , pop_senate_min = pop_senate_min , pop_house_max = pop_house_max , pop_house_min = pop_house_min , pop_congress = pop_congress , pop_senate = pop_senate , pop_house = pop_house , start_na = start_na , end_na = end_na , target_na_congress = target_na_congress , target_hisp_congress = target_hisp_congress , target_bl_congress = target_bl_congress , target_na_house = target_na_house , target_hisp_house = target_hisp_house , target_bl_house = target_bl_house , target_na_senate = target_na_senate , target_hisp_senate = target_hisp_senate , target_bl_senate = target_bl_senate , contiguityOverrideString = contiguityOverrideString ) ) ) <EOL> f . write ( "<STR_LIT:\n>" ) <EOL> f . close ( ) <EOL> os . chmod ( target_file , stat . S_IRUSR | stat . S_IRGRP | stat . S_IROTH ) <EOL> parser = optparse . OptionParser ( usage = "<STR_LIT>" , version = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , dest = "<STR_LIT>" , help = "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , help = "<STR_LIT>" , type = int , default = <NUM_LIT:0> ) <EOL> ( parseResults , numargs ) = parser . parse_args ( ) <EOL> if ( ( parseResults . target_na_congress + parseResults . target_na_senate + parseResults . target_na_house ) > <NUM_LIT:0> ) : <EOL> parseResults . conf_na = True <EOL> allops = ( not parseResults . do_install ) and ( not parseResults . do_getdata ) and ( not parseResults . do_gensld ) and ( not parseResults . do_genconf ) and ( not parseResults . do_dropdb ) and ( not parseResults . do_run ) <EOL> if ( allops ) : <EOL> parseResults . do_install = True <EOL> parseResults . do_getdata = True <EOL> parseResults . do_gensld = True <EOL> parseResults . do_genconf = True <EOL> parseResults . do_dropdb = True <EOL> parseResults . do_run = True <EOL> if len ( numargs ) != <NUM_LIT:0> : <EOL> parser . error ( "<STR_LIT>" ) <EOL> stateFips = parseResults . stateFips <EOL> houseDis = parseResults . houseDis <EOL> senDis = parseResults . senDis <EOL> congDis = parseResults . congDis <EOL> if ( stateFips == <NUM_LIT:0> or houseDis == <NUM_LIT:0> or senDis == <NUM_LIT:0> or congDis == <NUM_LIT:0> ) : <EOL> print "<STR_LIT>" <EOL> raise ValueError <EOL> if ( parseResults . do_install ) : <EOL> print "<STR_LIT>" <EOL> install_dependencies ( ) <EOL> if ( parseResults . do_dropdb ) : <EOL> print '<STR_LIT>' <EOL> drop_db ( ) <EOL> if ( parseResults . do_gensld ) : <EOL> print '<STR_LIT>' <EOL> gensld_none ( "<STR_LIT>" ) <EOL> gensld_none ( "<STR_LIT>" ) <EOL> gensld_none ( "<STR_LIT>" ) <EOL> gensld_boundaries ( "<STR_LIT>" ) <EOL> gensld_boundaries ( "<STR_LIT>" ) <EOL> gensld_boundaries ( "<STR_LIT>" ) <EOL> if ( parseResults . do_getdata ) : <EOL> print '<STR_LIT>' <EOL> get_census_data ( stateFips ) <EOL> print '<STR_LIT>' <EOL> robjects . r . source ( "<STR_LIT>" ) <EOL> if ( ( parseResults . do_genconf ) or ( parseResults . do_gensld ) ) : <EOL> print '<STR_LIT>' <EOL> robjects . r . source ( "<STR_LIT>" ) <EOL> sum_TOTPOP = robjects . r . sum_TOTPOP [ <NUM_LIT:0> ] <EOL> has_election_data = robjects . r . has_election_data [ <NUM_LIT:0> ] <EOL> if ( parseResults . do_genconf ) : <EOL> robjects . r . source ( "<STR_LIT>" ) <EOL> f = open ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> contiguityOverrideString = f . read ( ) <EOL> f . close ( ) <EOL> if ( parseResults . do_gensld ) : <EOL> print '<STR_LIT>' <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_TOTPOP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_TOTPOP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_TOTPOP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_TOTPOP_NA ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VAP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VAP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VAP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VAP_NA ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_TOTPOP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_TOTPOP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_TOTPOP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_TOTPOP_NA ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VAP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VAP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VAP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VAP_NA ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_TOTPOP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_TOTPOP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_TOTPOP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_TOTPOP_NA ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VAP ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VAP_H ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VAP_B ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VAP_NA ) <EOL> if ( has_election_data == <NUM_LIT:1> ) : <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_DEM ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_REP ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_TOT ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_DEM ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_REP ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_TOT ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_DEM ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_REP ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_TOT ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_DEM_N ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_REP_N ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_block_VOTE_TOT_N ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_DEM_N ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_REP_N ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_tract_VOTE_TOT_N ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_DEM_N ) <EOL> gensld_choro_denquint ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_REP_N ) <EOL> gensld_choro ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , robjects . r . q_county_VOTE_TOT_N ) <EOL> if ( parseResults . do_genconf ) : <EOL> print '<STR_LIT>' <EOL> gen_config ( num_districts_congress = congDis , num_districts_senate = senDis , num_districts_house = houseDis , sum_TOTPOP = sum_TOTPOP , has_election_data = has_election_data , has_vtds = <NUM_LIT:0> , conf_na = parseResults . conf_na , <EOL> target_na_congress = parseResults . target_na_congress , target_hisp_congress = parseResults . target_hisp_congress , target_bl_congress = parseResults . target_bl_congress , <EOL> target_na_house = parseResults . target_na_house , target_hisp_house = parseResults . target_hisp_house , target_bl_house = parseResults . target_bl_house , <EOL> target_na_senate = parseResults . target_na_senate , target_hisp_senate = parseResults . target_hisp_senate , target_bl_senate = parseResults . target_bl_senate , contiguityOverrideString = contiguityOverrideString ) <EOL> if ( parseResults . do_run ) : <EOL> print '<STR_LIT>' <EOL> olddir = os . getcwd ( ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> subprocess . check_call ( [ "<STR_LIT>" ] ) <EOL> subprocess . check_call ( [ "<STR_LIT>" ] , shell = True ) <EOL> os . chdir ( olddir ) <EOL> else : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:start>" ] ) </s>
