def __init__(self, filepath): if type(filepath) is not str: filepath = path2filepath(filepath) title = 'Not a file' detail = f'The filepath {filepath} is not a file' super().__init__(title, detail)
def __init__(self, filepath): if type(filepath) is not str: filepath = path2filepath(filepath) title = "Metadata cannot be correctly understood." detail = f"The filepath {filepath} has unsupported metadata." super().__init__(title, detail)
def __init__(self, filepath): if type(filepath) is not str: filepath = path2filepath(filepath) title = "No matching format found" detail = f"The filepath {filepath} is recognized by any of the available formats." super().__init__(title, detail)
def __init__(self, filepath, representation=None): if type(filepath) is not str: filepath = path2filepath(filepath) title = 'No appropriate representation found' detail = f'The filepath {filepath} does not have an appropriate representation' if representation: detail += f' (expected {representation})' super().__init__(title, detail, representation=representation)
def from_path(cls, path): info = { "file_type": FileType.from_path(path), "filepath": path2filepath(path), "stem": path.true_stem, "extension": path.extension, "created_at": path.creation_datetime, "size": path.size, "is_symbolic": path.is_symlink(), "role": FileRole.from_path(path) } if path.is_collection(): children = [] for p in path.get_extracted_children(): if p.is_symlink(): children.append(FileInfo.from_path(p.resolve())) return CollectionFileInfo(children=children, **info) else: return SingleFileInfo(**info)
def test_path2filepath(app, settings, rootpath): fake_settings = settings.copy() fake_settings.root = rootpath path = Path(rootpath) / "dir/file" assert path2filepath(path, fake_settings) == "dir/file"
def __init__(self, filepath): if type(filepath) is not str: filepath = path2filepath(filepath) title = 'Filepath not found' detail = f'The filepath {filepath} does not exist.' super().__init__(title, detail)