From: Dmitry Selyutin Date: Tue, 17 Oct 2017 19:26:03 +0000 (+0300) Subject: vfs: simplify code; pure virtual operations X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=66c7c364cb1323c55b4603a8b47d45d234a6fa04;p=gnulib.git vfs: simplify code; pure virtual operations --- diff --git a/pygnulib/vfs.py b/pygnulib/vfs.py index cb514fc8b3..576b081f4a 100644 --- a/pygnulib/vfs.py +++ b/pygnulib/vfs.py @@ -20,25 +20,19 @@ from .module import File as _FileModule_ class Base: """gnulib generic virtual file system""" - def __init__(self, name, **kwargs): - _type_assert_("name", name, str) - path = _os_.path.realpath(name) - if not _os_.path.exists(path): - raise FileNotFoundError(path) - if not _os_.path.isdir(path): - raise NotADirectoryError(path) + def __init__(self, path, **kwargs): + _type_assert_("path", path, str) self.__table = {} for (key, value) in kwargs.items(): _type_assert_(key, value, str) - self.__table[key] = value - self.__name = name + self.__table[key] = _os_.path.normpath(value) self.__path = path def __repr__(self): module = self.__class__.__module__ name = self.__class__.__name__ - return "{}.{}{}".format(module, name, repr(self.__name)) + return "{}.{}{{{}}}".format(module, name, repr(self.__path)) def __contains__(self, name): @@ -51,7 +45,6 @@ class Base: def __getitem__(self, name): - """retrieve the canonical path of the specified file name""" _type_assert_("name", name, str) parts = [] replaced = False @@ -69,15 +62,9 @@ class Base: return _os_.path.sep.join([self.__path] + parts) - @property - def name(self): - """directory name""" - return self.__name - - @property def path(self): - """root directory path""" + """directory path""" return self.__path