def read_settings(filename=None):
logger = logging.getLogger(__name__)<EOL>logger.info("<STR_LIT>")<EOL>settings = _DEFAULT_CONFIG.copy()<EOL>if filename:<EOL><INDENT>logger.debug("<STR_LIT>", filename)<EOL>settings_path = os.path.dirname(filename)<EOL>tempdict = {}<EOL>with open(filename) as f:<EOL><INDENT>code = compile(f.read(), filename, '<STR_LIT>')<EOL>exec(code, tempdict)<EOL><DEDENT>settings.update((k, v) for k, v in tempdict.items()<EOL>if k not in ['<STR_LIT>'])<EOL>paths = ['<STR_LIT:source>', '<STR_LIT>', '<STR_LIT>']<EOL>if os.path.isdir(join(settings_path, settings['<STR_LIT>'])) andos.path.isdir(join(settings_path, settings['<STR_LIT>'],<EOL>'<STR_LIT>')):<EOL><INDENT>paths.append('<STR_LIT>')<EOL><DEDENT>for p in paths:<EOL><INDENT>path = settings[p]<EOL>if path and not isabs(path):<EOL><INDENT>settings[p] = abspath(normpath(join(settings_path, path)))<EOL>logger.debug("<STR_LIT>", p, path, settings[p])<EOL><DEDENT><DEDENT><DEDENT>for key in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>w, h = settings[key]<EOL>if h > w:<EOL><INDENT>settings[key] = (h, w)<EOL>logger.warning("<STR_LIT>"<EOL>"<STR_LIT>", key)<EOL><DEDENT><DEDENT>if not settings['<STR_LIT>']:<EOL><INDENT>logger.info('<STR_LIT>')<EOL><DEDENT>logger.debug('<STR_LIT>', pformat(settings, width=<NUM_LIT>))<EOL>return settings<EOL>
Read settings from a config file in the source_dir root.