run black on everything.

This commit is contained in:
fiatjaf
2020-08-30 23:19:43 -03:00
parent 2cecaa229b
commit 660d56d400
31 changed files with 397 additions and 241 deletions
+4 -5
View File
@@ -1,6 +1,5 @@
from datetime import datetime
from typing import List, Optional, Union
import shortuuid # type: ignore
from lnbits.db import open_ext_db
from lnbits.helpers import urlsafe_short_hash
@@ -63,7 +62,7 @@ def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]:
row = db.fetchone("SELECT * FROM withdraw_link WHERE id = ?", (link_id,))
link = []
for item in row:
link.append(item)
link.append(item)
link.append(num)
return WithdrawLink._make(link)
@@ -73,10 +72,9 @@ def get_withdraw_link_by_hash(unique_hash: str, num=0) -> Optional[WithdrawLink]
row = db.fetchone("SELECT * FROM withdraw_link WHERE unique_hash = ?", (unique_hash,))
link = []
for item in row:
link.append(item)
link.append(item)
link.append(num)
return WithdrawLink._make(link)
def get_withdraw_links(wallet_ids: Union[str, List[str]]) -> List[WithdrawLink]:
@@ -103,6 +101,7 @@ def delete_withdraw_link(link_id: str) -> None:
with open_ext_db("withdraw") as db:
db.execute("DELETE FROM withdraw_link WHERE id = ?", (link_id,))
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
yield lst[i : i + n]
+14 -19
View File
@@ -1,7 +1,4 @@
from datetime import datetime
from lnbits.db import open_ext_db
from lnbits.helpers import urlsafe_short_hash
def m001_initial(db):
@@ -25,8 +22,10 @@ def m001_initial(db):
used INTEGER DEFAULT 0,
usescsv TEXT
);
""")
"""
)
def m002_change_withdraw_table(db):
"""
Creates an improved withdraw table and migrates the existing data.
@@ -61,7 +60,7 @@ def m002_change_withdraw_table(db):
usescsv += "," + str(i + 1)
else:
usescsv += "," + str(1)
usescsv = usescsv[1:]
usescsv = usescsv[1:]
db.execute(
"""
INSERT INTO withdraw_link (
@@ -82,29 +81,25 @@ def m002_change_withdraw_table(db):
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
row[0],
row[1],
row[2],
row[3],
row[0],
row[1],
row[2],
row[3],
row[4],
row[5],
row[6],
row[7],
row[5],
row[6],
row[7],
row[8],
row[9],
row[10],
row[11],
row[11],
usescsv,
),
)
db.execute("DROP TABLE withdraw_links")
def migrate():
with open_ext_db("withdraw") as db:
m001_initial(db)
m002_change_withdraw_table(db)
+8 -2
View File
@@ -2,7 +2,7 @@ from flask import url_for
from lnurl import Lnurl, LnurlWithdrawResponse, encode as lnurl_encode
from sqlite3 import Row
from typing import NamedTuple
import shortuuid # type: ignore
import shortuuid # type: ignore
from lnbits.settings import FORCE_HTTPS
@@ -40,7 +40,13 @@ class WithdrawLink(NamedTuple):
usescssv = self.usescsv.split(",")
tohash = self.id + self.unique_hash + usescssv[self.number]
multihash = shortuuid.uuid(name=tohash)
url = url_for("withdraw.api_lnurl_multi_response", unique_hash=self.unique_hash, id_unique_hash=multihash, _external=True, _scheme=scheme)
url = url_for(
"withdraw.api_lnurl_multi_response",
unique_hash=self.unique_hash,
id_unique_hash=multihash,
_external=True,
_scheme=scheme,
)
else:
url = url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash, _external=True, _scheme=scheme)