From 959e6ecd13e1809793f34b437778a302fa8c2509 Mon Sep 17 00:00:00 2001 From: ChrisRBe Date: Sat, 21 Nov 2020 00:52:45 +0100 Subject: [PATCH] Further clean up of code --- parse-account-statements.py | 2 ++ src/Statement.py | 4 ++-- src/p2p_account_statement_parser.py | 9 ++++----- src/portfolio_performance_writer.py | 2 -- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/parse-account-statements.py b/parse-account-statements.py index ebf861c..81a748e 100755 --- a/parse-account-statements.py +++ b/parse-account-statements.py @@ -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)) @@ -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): diff --git a/src/Statement.py b/src/Statement.py index 4221505..e1dd1d6 100644 --- a/src/Statement.py +++ b/src/Statement.py @@ -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 = "" @@ -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()] diff --git a/src/p2p_account_statement_parser.py b/src/p2p_account_statement_parser.py index 48e7111..7a1928a 100644 --- a/src/p2p_account_statement_parser.py +++ b/src/p2p_account_statement_parser.py @@ -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() @@ -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() diff --git a/src/portfolio_performance_writer.py b/src/portfolio_performance_writer.py index 95e036d..487f410 100644 --- a/src/portfolio_performance_writer.py +++ b/src/portfolio_performance_writer.py @@ -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(