Mercurial > libervia-backend
comparison src/memory/memory.py @ 1015:fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 04 May 2014 18:43:54 +0200 |
parents | a7d33c7a8277 |
children | f6182f6418ea |
comparison
equal
deleted
inserted
replaced
1014:e40d9858cb83 | 1015:fee00f2e11c2 |
---|---|
205 value = dict(csv.reader([item], delimiter=':', quotechar='"').next() | 205 value = dict(csv.reader([item], delimiter=':', quotechar='"').next() |
206 for item in csv.reader([value], delimiter=',', quotechar='"').next()) | 206 for item in csv.reader([value], delimiter=',', quotechar='"').next()) |
207 return value | 207 return value |
208 | 208 |
209 def load_xml(self, filename): | 209 def load_xml(self, filename): |
210 """Load parameters template from xml file""" | 210 """Load parameters template from xml file |
211 if filename is None: | 211 |
212 @param filename (str): input file | |
213 @return bool: True in case of success | |
214 """ | |
215 if not filename: | |
212 return False | 216 return False |
213 filename = os.path.expanduser(filename) | 217 filename = os.path.expanduser(filename) |
214 if os.path.exists(filename): | 218 if os.path.exists(filename): |
215 try: | 219 try: |
216 self.params.load_xml(filename) | 220 self.params.load_xml(filename) |
244 try: | 248 try: |
245 del self._entities_cache[profile] | 249 del self._entities_cache[profile] |
246 except KeyError: | 250 except KeyError: |
247 log.error(_("Trying to purge roster status cache for a profile not in memory: [%s]") % profile) | 251 log.error(_("Trying to purge roster status cache for a profile not in memory: [%s]") % profile) |
248 | 252 |
249 def save_xml(self, filename=None): | 253 def save_xml(self, filename): |
250 """Save parameters template to xml file""" | 254 """Save parameters template to xml file |
251 if filename is None: | 255 |
256 @param filename (str): output file | |
257 @return bool: True in case of success | |
258 """ | |
259 if not filename: | |
252 return False | 260 return False |
253 #TODO: need to encrypt files (at least passwords !) and set permissions | 261 #TODO: need to encrypt files (at least passwords !) and set permissions |
254 filename = os.path.expanduser(filename) | 262 filename = os.path.expanduser(filename) |
255 try: | 263 try: |
256 self.params.save_xml(filename) | 264 self.params.save_xml(filename) |