Initial commit

This commit is contained in:
Scoder12
2020-07-27 12:01:38 -07:00
parent efb4ccd2bb
commit 83ec541343
7 changed files with 27 additions and 4 deletions
+8
View File
@@ -0,0 +1,8 @@
[flake8]
select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W
ignore = E203,W503,ANN101,ANN102
per-file-ignores = tests/*:S101
max-line-length = 88
application-import-names = vidgen,tests
import-order-style = google
docstring-convention = google
+4
View File
@@ -0,0 +1,4 @@
{
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
Generated
+1 -1
View File
@@ -371,7 +371,7 @@ secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0
socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
[metadata]
content-hash = "026e038e920e232b777a5cdce90826fd4d514746ef70d4bcdb9b51029059020c"
content-hash = "79080e433cd4f13b656467565b30525d1cd82155f5ad6a3fcf5895c7dd3a44a8"
python-versions = "^3.8"
[metadata.files]
+2
View File
@@ -0,0 +1,2 @@
"""The replit python module."""
from .database import db
Binary file not shown.
@@ -1,4 +1,5 @@
"""Interface with the Replit Database."""
import os
import json
from sys import stderr
from typing import Any, Callable, Dict, Tuple, Union
@@ -12,7 +13,8 @@ JSON_TYPE = Union[str, int, float, bool, type(None), dict, list]
class JSONKey:
"""Represents a key in the database that holds a JSON value.
db.jsonkey() will initialize an instance for you, you don't have to do it manually."""
db.jsonkey() will initialize an instance for you,
you don't have to do it manually."""
def __init__(
self,
@@ -36,7 +38,10 @@ class JSONKey:
return self.dtype is Any or isinstance(data, self.dtype)
def _type_mismatch_msg(self, data: Any) -> str:
return f"Type mismatch: Got type {type(data).__name__}, expected {self.dtype.__name__}"
return (
f"Type mismatch: Got type {type(data).__name__},"
"expected {self.dtype.__name__}"
)
def get(self):
"""Get the value of the key.
@@ -87,7 +92,8 @@ class JSONKey:
"""Prompt user for action when key is invalid."""
while True:
choice = input(
"d to use default, v to view the invalid data, c to insert custom value, ^C to exit: "
"d to use default, v to view the invalid data, c to insert custom value,"
"^C to exit: "
)
if choice.startswith("d"):
print("Writing default...")
@@ -232,3 +238,6 @@ class ReplitDb(dict):
def __repr__(self) -> str:
"""A representation of the database."""
return f"<ReplitDb(db_url={self.db_url!r})>"
db = ReplitDb(os.environ["REPLIT_DB_URL"])