1
0

Stricter types
All checks were successful
Build container / Package-Python (push) Successful in 25s
Build container / Package-Container (push) Successful in 1m21s

This commit is contained in:
Jon Michael Aanes 2024-05-16 00:47:42 +02:00
parent ee6aa7e527
commit 42574f98a4
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
4 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import abc import abc
import dataclasses import dataclasses
from collections.abc import Iterator from collections.abc import Iterator, Mapping
from enum import Enum from enum import Enum
import requests import requests
@ -38,5 +38,5 @@ class Scraper(abc.ABC):
return False return False
@abc.abstractmethod @abc.abstractmethod
def scrape(self) -> Iterator[object]: def scrape(self) -> Iterator[Mapping[str, object]]:
pass pass

View File

@ -3,8 +3,11 @@ import datetime
import email.utils import email.utils
import json import json
import logging import logging
from collections.abc import Iterator, Mapping
from decimal import Decimal from decimal import Decimal
from frozendict import frozendict
from personal_data.data import DeduplicateMode, Scraper from personal_data.data import DeduplicateMode, Scraper
from .. import secrets from .. import secrets
@ -61,8 +64,7 @@ class MpcBalance(Scraper):
json_data, date = self.get_json(url, data=data) json_data, date = self.get_json(url, data=data)
return json_data['coins']['coins'] return json_data['coins']['coins']
def scrape(self): def scrape_latest_values_for(self, address: str) -> frozendict[str, object]:
address = secrets.PBC_ACCOUNT_ADDRESS
coins = self.determine_coins() coins = self.determine_coins()
url = URL_ACCOUNT_PLUGIN.format( url = URL_ACCOUNT_PLUGIN.format(
@ -93,4 +95,7 @@ class MpcBalance(Scraper):
data_point['balance.' + coin_data['symbol']] = native_balance data_point['balance.' + coin_data['symbol']] = native_balance
del coin_idx, coin_data del coin_idx, coin_data
yield data_point return frozendict(data_point)
def scrape(self) -> Iterator[Mapping[str, object]]:
yield self.scrape_latest_values_for(secrets.PBC_ACCOUNT_ADDRESS)

View File

@ -1,8 +1,8 @@
import csv import csv
import datetime import datetime
import decimal
import io import io
import logging import logging
import decimal
from decimal import Decimal from decimal import Decimal
import requests import requests

View File

@ -1,6 +1,6 @@
import datetime import datetime
from decimal import Decimal from decimal import Decimal
import pytest import pytest
from personal_data.main import to_value from personal_data.main import to_value