2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2018-06-13 12:44:36 +03:00
|
|
|
import os
|
2020-08-11 22:29:44 +03:00
|
|
|
from pathlib import Path
|
2013-07-25 20:25:18 +04:00
|
|
|
|
2018-04-20 02:19:13 +03:00
|
|
|
|
2022-04-10 21:20:48 +03:00
|
|
|
def is_path(f):
|
2020-08-11 22:29:44 +03:00
|
|
|
return isinstance(f, (bytes, str, Path))
|
2013-06-30 22:50:38 +04:00
|
|
|
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2022-04-10 21:20:48 +03:00
|
|
|
def is_directory(f):
|
|
|
|
"""Checks if an object is a string, and that it points to a directory."""
|
|
|
|
return is_path(f) and os.path.isdir(f)
|
2014-04-03 07:09:04 +04:00
|
|
|
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2022-04-10 21:21:50 +03:00
|
|
|
class DeferredError:
|
2014-04-04 03:05:02 +04:00
|
|
|
def __init__(self, ex):
|
|
|
|
self.ex = ex
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2014-04-03 07:09:04 +04:00
|
|
|
def __getattr__(self, elt):
|
2014-04-04 03:05:02 +04:00
|
|
|
raise self.ex
|