<s> import os <EOL> import sys <EOL> import traceback <EOL> from libqtile . log_utils import logger <EOL> class ConfigError ( Exception ) : <EOL> pass <EOL> class File ( object ) : <EOL> def __init__ ( self , fname = None , is_restart = False ) : <EOL> if not fname : <EOL> config_directory = os . path . expandvars ( '<STR_LIT>' ) <EOL> if config_directory == '<STR_LIT>' : <EOL> config_directory = os . path . expanduser ( "<STR_LIT>" ) <EOL> fname = os . path . join ( config_directory , "<STR_LIT>" , "<STR_LIT>" ) <EOL> from . resources import default_config <EOL> if fname == "<STR_LIT:default>" : <EOL> config = default_config <EOL> elif os . path . isfile ( fname ) : <EOL> try : <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . dirname ( fname ) ) <EOL> config = __import__ ( os . path . basename ( fname ) [ : - <NUM_LIT:3> ] ) <EOL> except Exception as v : <EOL> tb = traceback . format_exc ( ) <EOL> if is_restart : <EOL> logger . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , tb ) <EOL> config = None <EOL> else : <EOL> raise ConfigError ( tb ) <EOL> else : <EOL> config = None <EOL> config_options = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> for option in config_options : <EOL> if hasattr ( config , option ) : <EOL> v = getattr ( config , option ) <EOL> else : <EOL> v = getattr ( default_config , option ) <EOL> if not hasattr ( self , option ) : <EOL> setattr ( self , option , v ) </s>
