fix code for py3.9.2
This commit is contained in:
parent
319c7cac8c
commit
0020731207
4 changed files with 4 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Sand
|
# Sand
|
||||||
|
|
||||||
## Exécution avec Python 3.10.8
|
## Exécution avec Python 3.9.2
|
||||||
|
|
||||||
Préparation de l'environnement
|
Préparation de l'environnement
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ def init() -> None:
|
||||||
|
|
||||||
# Create upload folder if doesn't exists
|
# Create upload folder if doesn't exists
|
||||||
if not exist(Config.uploads_dir):
|
if not exist(Config.uploads_dir):
|
||||||
mkdir(path=Config.uploads_dir)
|
mkdir(Config.uploads_dir)
|
||||||
|
|
||||||
# TODO: Clear every t mins the uploads directory and database
|
# TODO: Clear every t mins the uploads directory and database
|
||||||
# TODO: On init, check if files in db are corresponding to the files stored
|
# TODO: On init, check if files in db are corresponding to the files stored
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from sys import set_int_max_str_digits
|
|
||||||
|
|
||||||
BYTEORDER = "big"
|
BYTEORDER = "big"
|
||||||
|
|
||||||
|
@ -23,6 +22,4 @@ def int_to_bytes(data: int) -> bytes:
|
||||||
|
|
||||||
def hash_data(string: str) -> str:
|
def hash_data(string: str) -> str:
|
||||||
"""Hash a string"""
|
"""Hash a string"""
|
||||||
# https://docs.python.org/3/library/sys.html#sys.set_int_max_str_digits
|
|
||||||
set_int_max_str_digits(len(string))
|
|
||||||
return str(int.from_bytes(sha256(int_to_bytes(int(string))).digest(), BYTEORDER))
|
return str(int.from_bytes(sha256(int_to_bytes(int(string))).digest(), BYTEORDER))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from os import mkdir
|
from os import mkdir
|
||||||
from sqlite3 import Cursor, connect
|
from sqlite3 import connect
|
||||||
|
|
||||||
from utils.misc import exist
|
from utils.misc import exist
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class Database:
|
||||||
|
|
||||||
self.fullpath = fullpath
|
self.fullpath = fullpath
|
||||||
|
|
||||||
def request(self, request: str, valeurs=None) -> tuple[Cursor, int | None]:
|
def request(self, request: str, valeurs=None) -> tuple:
|
||||||
"""Send a request to the database"""
|
"""Send a request to the database"""
|
||||||
connection = connect(self.fullpath)
|
connection = connect(self.fullpath)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
Reference in a new issue