<s> """<STR_LIT>""" <EOL> import yaml <EOL> import os . path <EOL> from mod import log , util , config <EOL> def load ( proj_dir ) : <EOL> """<STR_LIT>""" <EOL> settings = None <EOL> path = proj_dir + '<STR_LIT>' <EOL> if os . path . isfile ( path ) : <EOL> with open ( path , '<STR_LIT:r>' ) as f : <EOL> settings = yaml . load ( f ) <EOL> if not settings : <EOL> settings = { } <EOL> return settings <EOL> def save ( proj_dir , settings ) : <EOL> """<STR_LIT>""" <EOL> path = proj_dir + '<STR_LIT>' <EOL> with open ( path , '<STR_LIT:w>' ) as f : <EOL> yaml . dump ( settings , f ) <EOL> def get_default ( key ) : <EOL> """<STR_LIT>""" <EOL> if key == '<STR_LIT>' : <EOL> return config . get_default_config ( ) <EOL> elif key == '<STR_LIT:target>' : <EOL> return None <EOL> elif key == '<STR_LIT>' : <EOL> return <NUM_LIT:3> <EOL> elif key == '<STR_LIT>' : <EOL> return False <EOL> else : <EOL> return None <EOL> def get ( proj_dir , key ) : <EOL> """<STR_LIT>""" <EOL> util . ensure_valid_project_dir ( proj_dir ) <EOL> value = None <EOL> settings = load ( proj_dir ) <EOL> if key in settings : <EOL> value = settings [ key ] <EOL> if value is None : <EOL> value = get_default ( key ) <EOL> return value <EOL> def set ( proj_dir , key , value ) : <EOL> """<STR_LIT>""" <EOL> util . ensure_valid_project_dir ( proj_dir ) <EOL> settings = load ( proj_dir ) <EOL> settings [ key ] = value <EOL> save ( proj_dir , settings ) <EOL> proj_name = util . get_project_name_from_dir ( proj_dir ) <EOL> if type ( value ) is bool : <EOL> value_str = '<STR_LIT>' if value else '<STR_LIT>' ; <EOL> else : <EOL> value_str = str ( value ) <EOL> log . info ( "<STR_LIT>" . format ( key , value_str , proj_name ) ) <EOL> def unset ( proj_dir , key ) : <EOL> """<STR_LIT>""" <EOL> util . ensure_valid_project_dir ( proj_dir ) <EOL> settings = load ( proj_dir ) <EOL> if key in settings : <EOL> del settings [ key ] <EOL> save ( proj_dir , settings ) <EOL> proj_name = util . get_project_name_from_dir ( proj_dir ) <EOL> log . info ( "<STR_LIT>" . format ( key , proj_name ) ) </s>
