def paths_from_env(prefix=None, names=None):
def expand_path(path):<EOL><INDENT>"""<STR_LIT>"""<EOL>return os.path.abspath(os.path.expanduser(os.path.expandvars(path)))<EOL><DEDENT>if prefix is None:<EOL><INDENT>prefix = "<STR_LIT>"<EOL><DEDENT>if names is None:<EOL><INDENT>names = [<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>"<EOL>]<EOL><DEDENT>conf = {v: os.environ.get("<STR_LIT:_>".join([prefix, v])) for v in names}<EOL>for env in (e for e in conf.keys() if e[:len(prefix)] in names and conf[e]):<EOL><INDENT>conf[env] = expand_path(conf[env])<EOL>if not os.path.exists(conf[env]):<EOL><INDENT>err("<STR_LIT>" % (prefix, env, conf[env]))<EOL><DEDENT><DEDENT>return conf<EOL>
Construct dict of paths from environment variables