From 75ab5910bf64b4c214cb4584bb899d4eebd5ad94 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 9 Sep 2017 19:42:34 +0300 Subject: [PATCH] filesystem: do not export private class members into inherited classes --- pygnulib/filesystem.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pygnulib/filesystem.py b/pygnulib/filesystem.py index 3d5721ff30..3c03f6e42c 100644 --- a/pygnulib/filesystem.py +++ b/pygnulib/filesystem.py @@ -33,8 +33,8 @@ class Directory: 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 @@ class Directory: 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 @@ class Git(Directory): 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") -- 2.39.5