Implement __dir__ dunder method
This commit is contained in:
parent
cc76e91afc
commit
2aff6704bc
@ -66,6 +66,23 @@ class Hierarchy(PathLike):
|
|||||||
"""Return a string representation of this Hierarchy."""
|
"""Return a string representation of this Hierarchy."""
|
||||||
return str(self._path)
|
return str(self._path)
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
return (
|
||||||
|
"__dir__",
|
||||||
|
"__eq__",
|
||||||
|
"__fspath__",
|
||||||
|
"__hash__",
|
||||||
|
"__ne__",
|
||||||
|
"__repr__",
|
||||||
|
"__str__",
|
||||||
|
"path",
|
||||||
|
"name",
|
||||||
|
"metadata_path",
|
||||||
|
"cleanup",
|
||||||
|
"read_metadata",
|
||||||
|
"write_metadata",
|
||||||
|
)
|
||||||
|
|
||||||
def _gen_metadata(self):
|
def _gen_metadata(self):
|
||||||
"""Generate metadata for this repository.
|
"""Generate metadata for this repository.
|
||||||
|
|
||||||
|
@ -143,6 +143,25 @@ class Repository(Hierarchy):
|
|||||||
"""Return the next Snapshot in this Repository."""
|
"""Return the next Snapshot in this Repository."""
|
||||||
return next(self._snapshot_iterator)
|
return next(self._snapshot_iterator)
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
return (
|
||||||
|
super().__dir__(),
|
||||||
|
"__contains__",
|
||||||
|
"__delitem__",
|
||||||
|
"__getitem__",
|
||||||
|
"__iter__",
|
||||||
|
"__len__",
|
||||||
|
"__next__",
|
||||||
|
"is_valid_snapshot_name",
|
||||||
|
"snapshot_dir",
|
||||||
|
"snapshot_symlink",
|
||||||
|
"snapshots",
|
||||||
|
"empty",
|
||||||
|
"cleanup",
|
||||||
|
"create_snapshot",
|
||||||
|
"symlink_snapshot",
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_valid_snapshot_name(name):
|
def is_valid_snapshot_name(name):
|
||||||
"""Check if the given name is a valid name.
|
"""Check if the given name is a valid name.
|
||||||
|
@ -31,6 +31,9 @@ class Snapshot(Hierarchy):
|
|||||||
|
|
||||||
self._pkg_dir = self.path / "pkg"
|
self._pkg_dir = self.path / "pkg"
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
return super().__dir__(), "ctime", "pkg_dir"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Return a string representation of this Snapshot."""
|
"""Return a string representation of this Snapshot."""
|
||||||
return f"{self.__class__.__name__}('{self.name}')"
|
return f"{self.__class__.__name__}('{self.name}')"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user