Changeset 6350 for misc/tools/plotcsv/plotcsv.py
- Timestamp:
- Feb 16, 2009, 4:46:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/tools/plotcsv/plotcsv.py
r6348 r6350 157 157 158 158 class Config(object): 159 """ 160 An object that behaves like a dictionary but is persistent: 159 """An object that behaves like a dictionary but is persistent: 161 160 162 161 cfg = Config('filename') … … 170 169 171 170 def __init__(self, configfile=None): 172 """ 173 __init__(self, String filename=None) -> Config 174 """ 171 """__init__(self, String filename=None) -> Config""" 175 172 176 173 self.delconf = False … … 194 191 195 192 def __setitem__(self, key, value): 196 """ 197 Override to allow: cfg[<key>] = <value> 198 """ 193 """Override to allow: cfg[<key>] = <value>""" 194 199 195 self.cfgdict[key] = value 200 196 self.changed = True 201 197 202 198 def __getitem__(self, key): 203 """ 204 Override to allow: <var> = cfg[<key>] 205 """ 199 """Override to allow: <var> = cfg[<key>]""" 200 206 201 return self.cfgdict.get(key, None) 207 202 208 203 def __str__(self): 209 """ 210 __str__(self) -> String 211 """ 204 """__str__(self) -> String""" 205 212 206 return "<config object at %s>" % hex(id(self)) 213 207 214 208 def getfilename(self): 215 """ 216 getfilename(self) -> String filename 217 """ 209 """getfilename(self) -> String filename""" 210 218 211 return self.configfile 219 212 220 213 def setdeleted(self): 221 """ 222 setdeleted(self) 223 """ 214 """setdeleted(self)""" 215 224 216 self.delconf = True 225 217 226 218 def save(self): 227 """ 228 save(self) 229 """ 219 """save(self)""" 220 230 221 try: 231 222 f = open(self.configfile, "w") … … 239 230 240 231 def close(self): 241 """ 242 close(self) 243 """ 232 """close(self)""" 233 244 234 if self.changed: 245 235 self.save() … … 249 239 250 240 def __del__(self): 251 """ 252 __del__(self) 253 """ 241 """__del__(self)""" 242 254 243 self.close() 244 255 245 256 246 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.