Ejemplo n.º 1
0
 def _setUpRecords(self):
     recbuf = Config.getRecordBuffer()
     if recbuf:
         # recbuf is not a empty list
         for buf in recbuf:
             rdate, rec = buf2record(buf)
             self.addRecord(rdate, rec)
     # set record buffer up to default value a empty list.
     Config.setRecordBuffer(list())
Ejemplo n.º 2
0
 def resetAll(self):
     """This method reset all the data of the Expense to default status.
     Be careful when call this method, it should be make a warning
     message to the user.
     """
     self.rec_m.clear()
     for key in self.projects:
         del self.projects[key]
     Config.setProjectBuffer(dict())
Ejemplo n.º 3
0
 def addRecord(self, rdate, baserec):
     if self.isSetup:
         self.rec_m.addItem(rdate, baserec)
         self._checkProjects(rdate, baserec, act="add")
         Config.setDefault(baserec)
     else:
         buf = record2buf(rdate, baserec)
         recbuf = Config.getRecordBuffer()
         recbuf.append(buf)
         Config.setRecordBuffer(recbuf)
Ejemplo n.º 4
0
 def _setUpProjects(self):
     projbuf = Config.getProjectBuffer()
     if projbuf:
         # projbuf is not a empty dict
         for name, dictbuf in projbuf.items():
             projtype = dictbuf["projtype"]
             proj = Projects.__dict__[projtype]()
             proj.import_from_dict(dictbuf)
             self.projects[name] = proj
Ejemplo n.º 5
0
"""
    pyExpenses.RecManip
    ~~~~~~~~~~~~~~~~~~~

    Implements the interface's object that manipulator of records for pyExpenses.

    :copyright: (c) 2012 by Jason Lai.
    :license: BSD, see LICENSE for more details.
"""

from datetime import date, timedelta

from ConfigManip import Config
import RecManipImpl

STORAGE_BACKEND = RecManipImpl.__dict__[Config.getInfo('StorageBackend')]

class RecManip(object):

    def setUp(self, *args, **kwargs):
        """It's the method really initialize the instance. This should be
        called after create a instance, the passing arguments can control
        defferent options.
        """
        self.impl = STORAGE_BACKEND(*args, **kwargs)

    def updatePassword(self, oldpwd, newpwd):
        self.impl.updatePassword(oldpwd, newpwd)

    def cancelPassword(self, oldpwd):
        from RecManipImpl import DEFAULT_PASSWORD
Ejemplo n.º 6
0
 def saveProjects(self):
     savebuf = {}
     for name, proj in self.projects.items():
         savebuf[name] = proj.export_to_dict()
         savebuf[name]["projtype"] = proj.__class__.__name__
     Config.setProjectBuffer(savebuf)