Module QFlow.utils.source
Classes
class Source (path: str | pathlib._local.Path, root: pathlib._local.Path)-
Expand source code
class Source: def __init__( self, path: str | Path, root: Path ): self.inputPath = Path(path) if self.inputPath.is_absolute(): self.resolvedPath = self.inputPath else: self.resolvedPath = (root / self.inputPath).resolve() @classmethod def library(cls, path: str | Path) -> "Source": """ Resolve a path relative to the QFlow package. """ if FROZENLIB: root = Path(sys._MEIPASS) else: root = Path(res.files(QFlow)).resolve().parent return cls(path, root) @classmethod def project(cls, path: str | Path) -> "Source": """ Resolve a path relative to the user's project. """ if FROZENLIB: root = Path(sys._MEIPASS) else: root = os.getcwd() return cls(path, root) def get(self) -> str: """ Get the resolved path. """ return str(self.resolvedPath) def exists(self) -> bool: """ Check if the path exists. """ return self.resolvedPath.exists() def path(self) -> Path: """ Get the resolved Path object. """ return self.resolvedPath def __str__(self) -> str: return str(self.resolvedPath) def __fspath__(self): return str(self.resolvedPath)Static methods
def library(path: str | pathlib._local.Path) ‑> Source-
Resolve a path relative to the QFlow package.
def project(path: str | pathlib._local.Path) ‑> Source-
Resolve a path relative to the user's project.
Methods
def exists(self) ‑> bool-
Expand source code
def exists(self) -> bool: """ Check if the path exists. """ return self.resolvedPath.exists()Check if the path exists.
def get(self) ‑> str-
Expand source code
def get(self) -> str: """ Get the resolved path. """ return str(self.resolvedPath)Get the resolved path.
def path(self) ‑> pathlib._local.Path-
Expand source code
def path(self) -> Path: """ Get the resolved Path object. """ return self.resolvedPathGet the resolved Path object.