Esempio n. 1
0
    def __init__(self, oldMasterFile, newMasterFile, accountsFile):
        lines = FileIO.readLines(oldMasterFile)
        self.newMasterFile = newMasterFile
        self.accountsFile = accountsFile
        self.list = []
        count = 0
        for line in lines:
            line = line.strip("\r\n ")
            params = line.split(' ')

            if (len(params) != 3):
                Utility.fatal("Line " + str(count) +
                              " is invalid - parameter count != 3")

            self.list.append(Account(int(params[0]), int(params[1]),
                                     params[2]))
            count += 1
Esempio n. 2
0
def readAccounts(path):
    lines   = FileIO.readLines(path)
    cleaned = []
    
    if len(lines) < 1:
        raise ValueError('Empty Accounts File')

    # Clean and strip newlines from the numbers, then
    # ensure that they're valid account numbers
    for line in lines:
        clean = Utility.cleanString(line)
        if (not clean.isdigit() or len(clean.strip()) != 7 or (
            clean != lines[-1].strip() and clean[0] == '0')):
            raise ValueError('Invalid accounts file, error: ' + clean)
        cleaned.append(clean)
    
    # Ensure that the last line is the all zero account number
    if (cleaned[-1] != "0000000"):
        raise ValueError('Invalid accounts file, missing zero account number at file end')

    return cleaned
Esempio n. 3
0
#--------------------------------------------------------------------
# Get the command line options
#--------------------------------------------------------------------
def getCommandArgs():
    parser = argparse.ArgumentParser()
    parser.add_argument("mergedtransactionfile")
    parser.add_argument("oldmasterfile")
    parser.add_argument("newmasterfile")
    parser.add_argument("newaccountsfile")
    return parser.parse_args()


#--------------------------------------------------------------------
# Parse a transaction file line into it's seperate parts
#--------------------------------------------------------------------
def parseLine(line):
    return Utility.cleanString(line).split(' ')


#--------------------------------------------------------------------
# Main
#--------------------------------------------------------------------

args = getCommandArgs()
commands = Commands(args.oldmasterfile, args.newmasterfile,
                    args.newaccountsfile)
lines = FileIO.readLines(args.mergedtransactionfile)

for line in lines:
    parsed = parseLine(line)
    commands.runCommand(parsed[0], parsed[1], parsed[3], parsed[2], parsed[4])