def __init__( self, contains_lidvids: bool, subcomponents: Set[S], fs: FS, filepaths: Set[str], ) -> None: """ Create a 'VersionContents' object. DO NOT USE this constructor. Instead use the static methods VersionContents.create_from_lids() and VersionContents.create_from_lidvids(). """ if not _data_consistent(contains_lidvids, subcomponents): raise TypeError( "Subcomponents are not consistent, should be all " + "livids or all lids." ) self.contains_lidvids = contains_lidvids self.subcomponents: Set[S] = subcomponents for filepath in filepaths: if not isabs(filepath): raise ValueError(f"{filepath} is not an absolute path.") if not fs.isfile(filepath): raise ValueError(f"{filepath} is not a file.") self.fs = fs self.filepaths = filepaths
def abs(self): if fp.isabs(self.path): return self.path else: from fs.osfs import OSFS with OSFS('.') as fs: return fs.getsyspath(self.path)
def abs(self) -> str: #return fp.abspath(self.route) if fp.isabs(self.route): return self.route else: from fs.osfs import OSFS with OSFS('.') as fs: return fs.getsyspath(self.route)
def is_abs(self): return fp.isabs(self._path)
def deref_link(link_path, real_path): if isabs(real_path): return real_path else: basename, fname = pathsplit(link_path) return pathjoin(basename, real_path)
def parts(self): result = fp.iteratepath(self.path) if fp.isabs(self.path) and not result[0] == '/': result = ['/'] + result return tuple(result)
def isrel(self): return not fp.isabs(self.path)
def isabs(self): return fp.isabs(self.path)
def test_isabs(self): self.assertTrue(isabs("/")) self.assertTrue(isabs("/foo")) self.assertFalse(isabs("foo"))
def isabs(self): return fp.isabs(self.route)
def is_absolute(self) -> bool: return fp.isabs(self.s)