Commits

Gustavo Picon committed 6335267

Using new syntax for @property

  • Participants
  • Parent commits 82c0a75

Comments (0)

Files changed (2)

File magicbus/plugins/opsys.py

         self.gid = gid
         self.umask = umask
 
-    def _get_uid(self):
+    @property
+    def uid(self):
+        """The uid under which to run. Availability: Unix."""
         return self._uid
 
-    def _set_uid(self, val):
+    @uid.setter
+    def uid(self, val):
         if val is not None:
             if pwd is None:
                 self.bus.log("pwd module not available; ignoring uid.",
             elif isinstance(val, basestring):
                 val = pwd.getpwnam(val)[2]
         self._uid = val
-    uid = property(_get_uid, _set_uid,
-                   doc="The uid under which to run. Availability: Unix.")
 
-    def _get_gid(self):
+    @property
+    def gid(self):
+        """The gid under which to run. Availability: Unix."""
         return self._gid
 
-    def _set_gid(self, val):
+    @gid.setter
+    def gid(self, val):
         if val is not None:
             if grp is None:
                 self.bus.log("grp module not available; ignoring gid.",
             elif isinstance(val, basestring):
                 val = grp.getgrnam(val)[2]
         self._gid = val
-    gid = property(_get_gid, _set_gid,
-                   doc="The gid under which to run. Availability: Unix.")
 
-    def _get_umask(self):
+    @property
+    def umask(self):
+        """The default permission mode for newly created files and directories.
+
+        Usually expressed in octal format, for example, ``0644``.
+        Availability: Unix, Windows.
+        """
         return self._umask
 
-    def _set_umask(self, val):
+    @umask.setter
+    def umask(self, val):
         if val is not None:
             try:
                 os.umask
                              level=30)
                 val = None
         self._umask = val
-    umask = property(
-        _get_umask,
-        _set_umask,
-        doc="""The default permission mode for newly created files and
-        directories.
-
-        Usually expressed in octal format, for example, ``0644``.
-        Availability: Unix, Windows.
-        """)
 
     def start(self):
         # uid/gid

File magicbus/win32.py

             self.events[state] = event
             return event
 
-    def _get_state(self):
+    @property
+    def state(self):
         return self._state
 
-    def _set_state(self, value):
+    @state.setter
+    def state(self, value):
         self._state = value
         event = self._get_state_event(value)
         win32event.PulseEvent(event)
-    state = property(_get_state, _set_state)
 
     def wait(self, state, interval=0.1, channel=None):
         """Wait for the given state(s), KeyboardInterrupt or SystemExit.