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

View File

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

View File

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