changeset 39033:d12ca012cd9d

vfs: simplify code; pure virtual operations
author Dmitry Selyutin <ghostmansd@gmail.com>
date Tue, 17 Oct 2017 22:26:03 +0300
parents 2673a181e856
children 092ea8d7ef06
files pygnulib/vfs.py
diffstat 1 files changed, 5 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/pygnulib/vfs.py	Sun Oct 08 22:08:56 2017 +0300
+++ b/pygnulib/vfs.py	Tue Oct 17 22:26:03 2017 +0300
@@ -20,25 +20,19 @@
 
 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 @@
 
 
     def __getitem__(self, name):
-        """retrieve the canonical path of the specified file name"""
         _type_assert_("name", name, str)
         parts = []
         replaced = False
@@ -70,14 +63,8 @@
 
 
     @property
-    def name(self):
-        """directory name"""
-        return self.__name
-
-
-    @property
     def path(self):
-        """root directory path"""
+        """directory path"""
         return self.__path