def getUUIDFromFile(filename, create=False): uuid = mUUID() uuid.readFromFile(filename) if uuid.valid(): return uuid lf = LockFile(filename + '.lock') try: lf.lock() uuid.readFromFile(filename) if uuid.valid(): return uuid uuid = mUUID() uuid.generate() if not uuid.writeToFile(filename): return None return uuid finally: lf.unlock()
def to_ofx(self): fields = [] if self.type is None: self.type = "DEBIT" fields.append(TRNTYPE(self.type)) fields.append(DTPOSTED(self.date)) fields.append(TRNAMT(self.amount)) if self.number is not None: fields.append(CHECKNUM(self.number)) if self.txid is None: self.txid = uuid.generate().upper() fields.append(FITID(self.txid)) fields.append(NAME(self.payee)) if self.memo is not None: fields.append(MEMO(self.memo)) return STMTTRN(*fields)