import sys
from function import process_file

weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

try:
    if len(sys.argv) < 1:
        pass
        
    filestring = sys.argv[1]
    regtrans = process_file(filestring)
except IndexError:
    print("Error: Not enough command line arguments!")
    sys.exit()
except ValueError:
    print("Error: File not found!")
    sys.exit()
    
#Starting Balance
try:
    start_bal = float(input("Starting balance: $"))
    cur_bal = start_bal
except ValueError:
    print("Error: Cannot convert to float!")
    sys.exit()
except EOFError:
    print("Error: File not found!")
    sys.exit()

if start_bal <= 0:
    print("Error: Must start with positive balance!")
示例#2
0
import sys
from function import process_file

weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

# Write your code here
#+---------------------------EXCEPTIONS-------------------------+
day = 0
if len(sys.argv) < 2:
    print("Error: Not enough command line arguments!")
    exit()
try:
    f = process_file(sys.argv[1])
    a = open(sys.argv[1], 'r')
except ValueError:
    print("Error: File not found!")
    quit()
try:
    start_balance = float(input("Starting balance: $"))
except ValueError:
    print("Error: Cannot convert to float!")
    exit()
current = start_balance + f[0][day] - f[1][day]
if start_balance <= 0:
    print("Error: Must start with positive balance!")
    exit()
#+------------------------------STARTS-----------------------------+
print()
while True:
    f = process_file(sys.argv[1])
    cmd = input("Enter command: ")
示例#3
0
import sys
from function import process_file
from function import help
from function import terminate
from function import regular

day = 0
weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

# deal with regular transaction
if len(sys.argv) == 1:
    print('Error: Not enough command line arguments!')
    exit()
else:
    try:
        regular_balance = process_file(sys.argv[1])
    except ValueError as Error:
        print('Error: File not found!')
        exit()

# deal with start balance
try:
    start_balance = float(input('Starting balance: $'))
except ValueError as Error:
    print('Error: Cannot convert to float!')
    exit()
if start_balance <= 0:
    print('Error: Must start with positive balance!')
    exit()

# initialize current balance (money after a day) and start balance (money at the begin of a day)
示例#4
0
from function import process_file

sampleRegularTransactions = 'Sample_Regular_Transactions.txt'
noRegularTransactions = 'No_Regular_Transactions.txt'

weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

# Imports command line arguments and tests function for exceptions
try:
    major_list = process_file(file)
except ValueError:
    print('Error: File not found!')
    exit()
except IndexError:
    print('Error: Not enough command line arguments!')
    exit()

# Create variables for regular income/expense
income = major_list[0]
expenses = major_list[1]

# This is the day counter which starts at 0
i = 0

# Boolean value which will control while loop
loop_value = True

# Asks the user for their starting balance
try:
    starting_balance = input('Starting balance: $')
    starting_balance = float(starting_balance)