Stricter types
This commit is contained in:
parent
ee6aa7e527
commit
42574f98a4
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user