Skip to content

Commit

Permalink
Further clean up of code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRBe committed Nov 20, 2020
1 parent 1dba09a commit 959e6ec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions parse-account-statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def platform_factory(operator_name="mintos"):
Return an object for the required Peer-to-Peer lending platform
:param operator_name: name of the P2P lending site, defaults to Mintos
:return: object for the actual lending platform parser, None if not supported
"""
config = os.path.join(os.path.dirname(__file__), "config", "{op}.yml".format(op=operator_name))
Expand All @@ -50,6 +51,7 @@ def main(infile, p2p_operator_name="mintos"):
:param infile: input file containing the account statements from a supported platform
:param p2p_operator_name: name of the Peer-to-Peer lending platform, defaults to Mintos
:return: True, False if an error occurred.
"""
if not os.path.exists(infile):
Expand Down
4 changes: 2 additions & 2 deletions src/Statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_category(self):
"""
Check the category of the given statement.
:return: category of the statement; if unkown return the empty string
:return: category of the statement; if unknown return the empty string
"""
booking_type = self._statement[self._config.get_booking_type()]
category = ""
Expand Down Expand Up @@ -66,7 +66,7 @@ def get_currency(self):
"""
Check the currency of the given statement.
:return: currency of the statement; if unkown return 'EUR'
:return: currency of the statement; if unknown return 'EUR'
"""
if self._config.get_booking_currency():
return self._statement[self._config.get_booking_currency()]
Expand Down
9 changes: 4 additions & 5 deletions src/p2p_account_statement_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __format_statement(self, statement):
:param statement: contains a line from the given CSV file
:returns: dictionary containing the formatted account entry
:return: dictionary containing the formatted account entry
"""
statement = Statement(self.config, statement)
category = statement.get_category()
Expand All @@ -76,19 +76,18 @@ def __format_statement(self, statement):
def __parse_service_config(self):
"""
Parse the YAML configuration file containing specific settings for the individual p2p loan platform
:return:
"""
with open(self.config_file, "r", encoding="utf-8") as ymlconfig:
yaml = YAML(typ="safe")
config = yaml.load(ymlconfig)
self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="monthly"):
"""
read a platform account statement csv file and filter the content according to the defined strings
:return:
:param aggregate: specifies the aggregation period. defaults to monthly.
:return: list of account statement entries ready for use in Portfolio Performance
"""
if os.path.exists(self._account_statement_file):
self.__parse_service_config()
Expand Down
2 changes: 0 additions & 2 deletions src/portfolio_performance_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def __init__(self, dialect="excel"):
def init_output(self):
"""
Initialize output csv file
:return:
"""
if not self.out_csv_writer:
self.out_csv_writer = csv.DictWriter(
Expand Down

0 comments on commit 959e6ec

Please sign in to comment.