Mercurial > gnulib
changeset 38932:633f03091b3d
filesystem: do not export private class members into inherited classes
author | Dmitry Selyutin <ghostmansd@gmail.com> |
---|---|
date | Sat, 09 Sep 2017 19:42:34 +0300 |
parents | 16eab8474a66 |
children | e896a3753833 |
files | pygnulib/filesystem.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/pygnulib/filesystem.py Sat Sep 09 19:35:00 2017 +0300 +++ b/pygnulib/filesystem.py Sat Sep 09 19:42:34 2017 +0300 @@ -33,8 +33,8 @@ raise FileNotFoundError(root) if not os.path.isdir(root): raise NotADirectoryError(root) - self._config_ = config - self._root_ = os.path.realpath(root) + self.__config = config + self.__root = os.path.realpath(root) def __getitem__(self, name): @@ -53,15 +53,21 @@ if not replaced: for old, new in Directory._SUBST_.items(): if part == old: - part = self._config_[new] + part = self.__config[new] replaced = True parts += [part] - path = os.path.sep.join([self._root_] + parts) + path = os.path.sep.join([self.__root] + parts) if not os.path.exists(path): raise FileNotFoundError(name) return path + @property + def root(self): + """root directory path""" + return self.__root + + class Git(Directory): """gnulib Git-based virtual file system""" @@ -80,10 +86,8 @@ def __init__(self, root, config): - if not os.path.isdir(root): - raise FileNotFoundError(root) super().__init__(root, config) - if not os.path.isdir(os.path.join(self._root_, ".git")): + if not os.path.isdir(os.path.join(self.root, ".git")): raise TypeError("%r is not a gnulib repository")