Reformat project
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
# import requests
|
||||
# from json import dumps
|
||||
|
||||
# Project imports
|
||||
from settings import settings
|
||||
import sinks.nordigen
|
||||
import sinks.truelayer
|
||||
import util
|
||||
from db import r
|
||||
# Project imports
|
||||
from settings import settings
|
||||
|
||||
|
||||
class Sinks(util.Base):
|
||||
@@ -54,7 +54,9 @@ class Sinks(util.Base):
|
||||
|
||||
difference = util.convert(difference)
|
||||
|
||||
new_transactions = [x for x in transactions if x["transaction_id"] in difference]
|
||||
new_transactions = [
|
||||
x for x in transactions if x["transaction_id"] in difference
|
||||
]
|
||||
|
||||
# Rename the new key to the old key so we can run the diff again
|
||||
r.rename(new_key_name, old_key_name)
|
||||
@@ -79,12 +81,18 @@ class Sinks(util.Base):
|
||||
fields = ["sort_code", "number", "iban"]
|
||||
for field in fields:
|
||||
if field in account:
|
||||
account_infos[bank][index]["account_number"][field] = account[field]
|
||||
account_infos[bank][index]["account_number"][
|
||||
field
|
||||
] = account[field]
|
||||
del account_infos[bank][index][field]
|
||||
if len(account["account_number"]) == 1:
|
||||
account_infos[bank].remove(account)
|
||||
self.log.warning(f"Potentially useless bank account: {account}")
|
||||
currencies = [account["currency"] for bank, accounts in account_infos.items() for account in accounts]
|
||||
currencies = [
|
||||
account["currency"]
|
||||
for bank, accounts in account_infos.items()
|
||||
for account in accounts
|
||||
]
|
||||
for bank, accounts in account_infos.items():
|
||||
self.account_info[bank] = []
|
||||
for account in accounts:
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
# Twisted/Klein imports
|
||||
from twisted.internet.task import LoopingCall
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
from hashlib import sha256
|
||||
from json import dumps, loads
|
||||
|
||||
# Other library imports
|
||||
import requests
|
||||
from simplejson.errors import JSONDecodeError
|
||||
from json import dumps, loads
|
||||
from lib.serde.nordigen import (
|
||||
TXRoot,
|
||||
AccessToken,
|
||||
Institutions,
|
||||
Agreement,
|
||||
Requisitions,
|
||||
AccountDetails,
|
||||
AccountBalancesRoot,
|
||||
RequisitionResponse,
|
||||
)
|
||||
from serde import ValidationError
|
||||
from hashlib import sha256
|
||||
import treq
|
||||
|
||||
import util
|
||||
from lib.serde.nordigen import (AccessToken, AccountBalancesRoot,
|
||||
AccountDetails, Agreement, Institutions,
|
||||
RequisitionResponse, Requisitions, TXRoot)
|
||||
from serde import ValidationError
|
||||
# Project imports
|
||||
from settings import settings
|
||||
import util
|
||||
from simplejson.errors import JSONDecodeError
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
|
||||
class Nordigen(util.Base):
|
||||
@@ -296,7 +288,9 @@ class Nordigen(util.Base):
|
||||
ownernames = self.get_ownernames()
|
||||
if account_id in ownernames:
|
||||
parsed["ownerName"] = ownernames[account_id]
|
||||
self.log.info(f"Found supplementary owner name for {account_id}: {ownernames[account_id]}")
|
||||
self.log.info(
|
||||
f"Found supplementary owner name for {account_id}: {ownernames[account_id]}"
|
||||
)
|
||||
else:
|
||||
self.log.error(f"No owner name in parsed, cannot use: {account_id}")
|
||||
return False
|
||||
@@ -387,7 +381,9 @@ class Nordigen(util.Base):
|
||||
else:
|
||||
# No transaction ID. This is a problem for our implementation
|
||||
|
||||
tx_hash = sha256(dumps(transaction, sort_keys=True).encode("utf8")).hexdigest()
|
||||
tx_hash = sha256(
|
||||
dumps(transaction, sort_keys=True).encode("utf8")
|
||||
).hexdigest()
|
||||
transaction["transaction_id"] = tx_hash
|
||||
|
||||
# Rename timestamp
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# Twisted/Klein imports
|
||||
from twisted.internet.task import LoopingCall
|
||||
import urllib
|
||||
from json import dumps, loads
|
||||
from time import time
|
||||
|
||||
# Other library imports
|
||||
import requests
|
||||
from simplejson.errors import JSONDecodeError
|
||||
from time import time
|
||||
from json import dumps, loads
|
||||
import util
|
||||
from lib.serde.truelayer import AccountBalancesRoot
|
||||
import urllib
|
||||
from serde import ValidationError
|
||||
|
||||
# Project imports
|
||||
from settings import settings
|
||||
import util
|
||||
from simplejson.errors import JSONDecodeError
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
|
||||
class TrueLayer(util.Base):
|
||||
@@ -130,7 +129,9 @@ class TrueLayer(util.Base):
|
||||
else:
|
||||
self.log.error("Received an authcode we didn't ask for")
|
||||
return
|
||||
self.log.info(f"Retrieved access/refresh tokens for {self.current_authcode_bank}")
|
||||
self.log.info(
|
||||
f"Retrieved access/refresh tokens for {self.current_authcode_bank}"
|
||||
)
|
||||
|
||||
def get_new_tokens_all(self):
|
||||
refresh_tokens = loads(settings.TrueLayer.RefreshKeys)
|
||||
@@ -174,7 +175,10 @@ class TrueLayer(util.Base):
|
||||
if "access_token" in parsed.keys():
|
||||
self.tokens[bank] = parsed["access_token"]
|
||||
# self.log.info(f"Refreshed access token for {bank}")
|
||||
if len(self.refresh_tokens.keys()) == len(self.tokens.keys()) and not self.authed:
|
||||
if (
|
||||
len(self.refresh_tokens.keys()) == len(self.tokens.keys())
|
||||
and not self.authed
|
||||
):
|
||||
# We are now fully authenticated and ready to start loops!
|
||||
self.__authed__()
|
||||
self.authed = True
|
||||
@@ -197,7 +201,9 @@ class TrueLayer(util.Base):
|
||||
try:
|
||||
parsed = r.json()
|
||||
except JSONDecodeError:
|
||||
self.log.error("Error parsing accounts response: {content}", content=r.content)
|
||||
self.log.error(
|
||||
"Error parsing accounts response: {content}", content=r.content
|
||||
)
|
||||
return False
|
||||
|
||||
return parsed
|
||||
|
||||
Reference in New Issue
Block a user