def from_abspath(cls, abspath): env = get_env() root_directory = env.root_directory if not os.path.isabs(abspath): abspath = os.path.abspath(abspath) if not abspath.startswith(root_directory): raise ValueError("{abspath} must start with {root_directory}.".format(**locals())) if abspath == root_directory: return "" # root c = abspath[len(root_directory):] if not c.startswith("/"): raise ValueError("{} must start with / .".format(c)) return Filepath(c, env)
def Session(**kw): env = get_env() return env.Session(**kw)
def __new__(cls, path, env=None): cls.env = env or get_env() obj = super().__new__(cls, path) return obj