Use the cache dir for a cached run if no files were listed explicitly.

master
Remigiusz Marcinkiewicz 2017-01-16 18:57:42 +01:00
parent 8a6c9ad031
commit 7c8c2fdabc
1 changed files with 15 additions and 2 deletions

View File

@ -38,6 +38,7 @@ import bs4
import csv
import enum
import hashlib
import os
import random
import re
import requests
@ -390,6 +391,7 @@ if __name__ == "__main__":
account_number = IBParser.parse_account_number(an)
if account_number is None:
print "[e] Account number \"{}\" unparseable".format(an)
sys.exit(2)
history = open(f,'r').read()
load_files[account_number] = history
@ -401,11 +403,22 @@ if __name__ == "__main__":
if cached:
print "[i] Cached run - will not connect to the bank"
if len(load_files) > 0:
print "[i] Using manually supplied files"
history_logs = load_files
else:
for account_number in config["IB_ACCOUNTS"]:
print "[e] Automated cache loading not implemented"
print "[i] Loading cached files from {}".format(CACHE_DIR)
for f in os.listdir(CACHE_DIR):
account_number = IBParser.parse_account_number(f)
if account_number is None:
print "[e] File name number \"{}\" unparseable".format(f)
continue
history = open(CACHE_DIR + "/" + f,'r').read()
load_files[account_number] = history
print "[i] Loading \"{}\" as \"{}\"".format(f, account_number)
if len(load_files) == 0:
print "[e] No cached files to process"
sys.exit(2)
history_logs = load_files
else:
print "[i] Normal run - will connect to the bank"