changeset 27879:52a4ad62b006

cleanup: use modern @property/@foo.setter property specification We can use this now that we're 2.6+, and this is more idiomatic modern Python.
author Augie Fackler <augie@google.com>
date Sat, 16 Jan 2016 10:50:28 -0500
parents e7bd55db011b
children b04df9ce1fb0
files mercurial/bundle2.py mercurial/scmutil.py
diffstat 2 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Fri Jan 15 16:16:25 2016 +0100
+++ b/mercurial/bundle2.py	Sat Jan 16 10:50:28 2016 -0500
@@ -851,13 +851,15 @@
                               self._advisoryparams, self._data, self.mandatory)
 
     # methods used to defines the part content
-    def __setdata(self, data):
+    @property
+    def data(self):
+        return self._data
+
+    @data.setter
+    def data(self, data):
         if self._generated is not None:
             raise error.ReadOnlyPartError('part is being generated')
         self._data = data
-    def __getdata(self):
-        return self._data
-    data = property(__getdata, __setdata)
 
     @property
     def mandatoryparams(self):
--- a/mercurial/scmutil.py	Fri Jan 15 16:16:25 2016 +0100
+++ b/mercurial/scmutil.py	Sat Jan 16 10:50:28 2016 -0500
@@ -448,22 +448,22 @@
         if realpath:
             base = os.path.realpath(base)
         self.base = base
-        self._setmustaudit(audit)
+        self.mustaudit = audit
         self.createmode = None
         self._trustnlink = None
 
-    def _getmustaudit(self):
+    @property
+    def mustaudit(self):
         return self._audit
 
-    def _setmustaudit(self, onoff):
+    @mustaudit.setter
+    def mustaudit(self, onoff):
         self._audit = onoff
         if onoff:
             self.audit = pathutil.pathauditor(self.base)
         else:
             self.audit = util.always
 
-    mustaudit = property(_getmustaudit, _setmustaudit)
-
     @util.propertycache
     def _cansymlink(self):
         return util.checklink(self.base)
@@ -561,14 +561,14 @@
     def __init__(self, vfs):
         self.vfs = vfs
 
-    def _getmustaudit(self):
+    @property
+    def mustaudit(self):
         return self.vfs.mustaudit
 
-    def _setmustaudit(self, onoff):
+    @mustaudit.setter
+    def mustaudit(self, onoff):
         self.vfs.mustaudit = onoff
 
-    mustaudit = property(_getmustaudit, _setmustaudit)
-
 class filtervfs(abstractvfs, auditvfs):
     '''Wrapper vfs for filtering filenames with a function.'''