changeset 35:de7c1237220c

prefix the instance variables of BaseStatus with a '_'
author Bernhard Herzog <bh@intevation.de>
date Thu, 15 Mar 2007 12:04:52 +0100
parents 1fefedfb77df
children 086c68ca51d2
files treepkg/status.py
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/status.py	Thu Mar 15 12:02:28 2007 +0100
+++ b/treepkg/status.py	Thu Mar 15 12:04:52 2007 +0100
@@ -55,51 +55,51 @@
 
     magic = "Status 0.0\n"
 
-    attrs = set(["filename", "values"])
+    attrs = set(["_filename", "_values"])
 
     def __init__(self, filename):
         assert os.path.isabs(filename)
-        self.filename = filename
+        self._filename = filename
         self.read()
 
     def _init_values(self):
-        self.values = {}
+        self._values = {}
 
     def read(self):
         self._init_values()
-        if not os.path.exists(self.filename):
+        if not os.path.exists(self._filename):
             return
-        f = open(self.filename)
+        f = open(self._filename)
         try:
             magic = f.next()
             if magic != self.magic:
-                raise ValueError("File %r has wrong magic" % self.filename)
+                raise ValueError("File %r has wrong magic" % self._filename)
             for line in f:
                 field, value = line.split(":", 1)
-                self.values[field] = self.fields[field].deserialize(value)
+                self._values[field] = self.fields[field].deserialize(value)
         finally:
             f.close()
 
     def write(self):
         lines = [self.magic]
         for field, desc in self.fields.items():
-            if field in self.values:
+            if field in self._values:
                 lines.append("%s: %s\n"
-                             % (field, desc.serialize(self.values[field])))
-        util.writefile(self.filename, "".join(lines))
+                             % (field, desc.serialize(self._values[field])))
+        util.writefile(self._filename, "".join(lines))
 
     def __getattr__(self, attr):
         desc = self.fields.get(attr)
         if desc is not None:
-            if attr in self.values:
-                return self.values[attr]
+            if attr in self._values:
+                return self._values[attr]
             elif desc.has_default():
                 return desc.default
         raise AttributeError(attr)
 
     def __setattr__(self, attr, value):
         if attr in self.fields:
-            self.values[attr] = value
+            self._values[attr] = value
             self.write()
         elif attr in self.attrs:
             self.__dict__[attr] = value
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)