Exemple #1
0
def parse_balance(input_file):
    """
    :param input_file: str
        Parse balance data from this file
    :return: [] of {}
        List of balanced for each wallet found
    """

    if os.path.exists(input_file):
        content = JSONParser(input_file).get_content()
        content[DATE_TIME_KEY] = parse_datetime(content[DATE_TIME_KEY])
        return content
Exemple #2
0
    def time_last_update(self):
        """
        :return: datetime
            Time of last update
        """

        if self.last_update:
            return self.last_update

        try:
            return parse_datetime(self.get("last_update"))
        except:
            return datetime.fromtimestamp(0)  # no record
Exemple #3
0
    def __init__(self, input_file, max_error_search):
        """
        :param input_file: str
            File with database to model
        :param max_error_search: float
            When searching for date, returns nearest date found if within
            max error. Should be measured in seconds.
        """

        JSONParser.__init__(self, input_file)

        self.content = {
            parse_datetime(item[DATE_TIME_KEY]): item
            for item in self.get_content()
        }  # date -> raw dict
        self.dates = sorted(self.content.keys())  # sorted list of all dates
        self.max_error = float(max_error_search)  # seconds