Anonymous avatar Anonymous committed 38078fe

resources: using property as a decorator

Comments (0)

Files changed (1)

rope/base/resources.py

     def exists(self):
         return os.path.exists(self.real_path)
 
-    def _get_parent(self):
+    @property
+    def parent(self):
         parent = '/'.join(self.path.split('/')[0:-1])
         return self.project.get_resource(parent)
 
-    def _get_path(self):
+    @property
+    def path(self):
         """Return the path of this resource relative to the project root
 
         The path is the list of parent directories separated by '/' followed
         """
         return self._path
 
-    def _get_name(self):
+    @property
+    def name(self):
         """Return the name of this resource"""
         return self.path.split('/')[-1]
 
-    def _get_real_path(self):
+    @property
+    def real_path(self):
         """Return the file system path of this resource"""
         return self.project._get_resource_path(self.path)
 
                 return self.name
         return destination
 
-    parent = property(_get_parent)
-    name = property(_get_name)
-    path = property(_get_path)
-    real_path = property(_get_real_path)
-
     def __eq__(self, obj):
         return self.__class__ == obj.__class__ and self.path == obj.path
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.