<s> import logging <EOL> import click <EOL> from click . termui import echo , style <EOL> import chanjo <EOL> from chanjo . compat import iteritems <EOL> from chanjo . config import questionnaire <EOL> from chanjo . store import Store <EOL> from chanjo . store . models import BASE <EOL> from chanjo . store . txmodels import BASE as TXBASE <EOL> logger = logging . getLogger ( __name__ ) <EOL> @ click . command ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True , help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True , help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True , help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True , <EOL> help = '<STR_LIT>' ) <EOL> @ click . pass_context <EOL> def init ( context , setup , reset , automate , transcripts ) : <EOL> """<STR_LIT>""" <EOL> click . echo ( chanjo . __banner__ ) <EOL> cov_tresholds = ( context . obj . get ( '<STR_LIT>' , { } ) <EOL> . get ( '<STR_LIT>' , [ <NUM_LIT:10> , <NUM_LIT:20> ] ) ) <EOL> defaults = { '<STR_LIT>' : { '<STR_LIT:value>' : cov_tresholds , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { '<STR_LIT:value>' : str ( context . obj [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } } <EOL> if not automate : <EOL> questions = [ ( key , value [ '<STR_LIT>' ] , value [ '<STR_LIT:value>' ] ) <EOL> for key , value in iteritems ( defaults ) ] <EOL> init_pipeline ( '<STR_LIT>' , context . obj , questions ) <EOL> else : <EOL> logger . info ( '<STR_LIT>' ) <EOL> for key , value in iteritems ( defaults ) : <EOL> context . obj . set ( key , value [ '<STR_LIT:value>' ] , scope = context . obj . user_data ) <EOL> context . obj . save ( default_flow_style = False ) <EOL> if setup : <EOL> only_tx = transcripts or context . obj . get ( '<STR_LIT>' ) or False <EOL> base = TXBASE if only_tx else BASE <EOL> chanjo_db = Store ( uri = context . obj [ '<STR_LIT>' ] , base = base ) <EOL> if reset : <EOL> chanjo_db . tear_down ( ) <EOL> chanjo_db . set_up ( ) <EOL> def init_pipeline ( program , config , questions ) : <EOL> """<STR_LIT>""" <EOL> if config . user_data : <EOL> message = "<STR_LIT>" <EOL> segments = dict ( program = program , note = style ( '<STR_LIT>' , fg = '<STR_LIT>' ) , <EOL> file = style ( config . config_path . basename ( ) , fg = '<STR_LIT>' ) ) <EOL> echo ( message . format ( ** segments ) ) <EOL> user_defaults = questionnaire ( questions ) <EOL> for dot_key , value in user_defaults . items ( ) : <EOL> config . set ( dot_key , value , scope = config . user_data ) </s>
