New Files

This commit is contained in:
Firepup Sixfifty 2023-05-24 13:58:35 +00:00
parent d948b35b57
commit 3e226a113e
14 changed files with 331 additions and 0 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
.cache/*
.cache/**
__pycache__/**
.upm
venv/**
**/__pycache__/**

94
.replit Normal file
View file

@ -0,0 +1,94 @@
run = "python main.py"
entrypoint = "package/src/fpsql/__init__.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-22_11"
[[hints]]
regex = "stderred: .+GLIBC.+not found"
message = "The command `stderred` is known to cause issues. It's recommended you remove it from your .replit configuration."
[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "$PYTHONHOME/lib/python3.8:${VIRTUAL_ENV}/lib/python3.8/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"
# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"
# Add a debugger!
[debugger]
support = true
# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]
# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"
# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"
[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true
# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"
[debugger.interactive.launchMessage.arguments]
logging = {}
# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]
[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = true
# These are the files that need to be preserved when this
# language template is used as the base language template
# for Python repos imported from GitHub
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "venv"]
[languages]
[languages.python3]
pattern = "**/*.py"
[languages.python3.languageServer]
start = "pylsp"
[deployment]
run = ["sh", "-c", "python3 main.py"]

2
.replit.backup Normal file
View file

@ -0,0 +1,2 @@
run = "python main.py"
entrypoint = "package/src/fpsql/__init__.py"

5
askpass.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
case "$1" in
Username*) exec echo "$NAME" ;;
Password*) exec echo "$PASS" ;;
esac

7
fix.sh Executable file
View file

@ -0,0 +1,7 @@
echo "Fixing poetry..."
pip install --upgrade poetry > /dev/null
echo "Updating/Installing dependencies..."
poetry update > /dev/null
echo "Logging completion..."
touch /tmp/updated.txt
echo "Done!"

4
git_log.txt Normal file
View file

@ -0,0 +1,4 @@
error: unable to read askpass response from 'replit-git-askpass'
error: unable to read askpass response from 'replit-git-askpass'
remote: Push to create is not enabled for users.
fatal: unable to access 'https://git--firecat650.repl.co/Firepup650/FPSQL.git/': The requested URL returned error: 403

4
lspfix.sh Executable file
View file

@ -0,0 +1,4 @@
unzip pylsp.sh -d venv/lib/python3.8/site-packages
sed -i 6d .config/pip/pip.conf
pip install ujson docstring_to_markdown jedi
mv pylsp venv/bin

Binary file not shown.

BIN
package/dist/fpsql-1.0.1.tar.gz vendored Normal file

Binary file not shown.

0
package/requirements.txt Normal file
View file

3
package/setup.py Normal file
View file

@ -0,0 +1,3 @@
from setuptools import setup
setup()

View file

@ -0,0 +1,177 @@
"""Firepup650's SQL Package"""
import sqlite3, ast, pydoc
def alias(Function):
def decorator(f):
f.__doc__ = (
"This method is an alias of the following method:\n\n"
+ pydoc.text.document(Function)
)
return f
return decorator
__VERSION__ = "1.0.26"
__NEW__ = "Adds `remove_prefix` and `remove_suffix`, name mangles internal variables in `sql`, fixes a bug in `console.warn`, adds `__VERSION__`, `__NEW__`, and `__LICENSE__`, adds many aliases for interactive help."
__LICENSE__ = "MIT"
class sql:
def addTable(self, tableName: str, mode: int = 0, address: str = "") -> None:
"""# Function: sql.addTable
Adds a table to the database
# Inputs:
tableName: str - The name of the table to create
mode: int - Not yet implemented
address: str - Not yet implemented
# Returns:
None
# Raises:
None"""
self.__con.execute(
f"""CREATE TABLE IF NOT EXISTS "{tableName}"
(id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
value TEXT NOT NULL)"""
)
self.__con.commit()
self.__table = tableName
def __init__(self, filename: str):
"""# Function: sql.__init__
Constructs an SQL instance
# Inputs:
filename: str - The name of the database file to connect to (or `:memory:`)
# Returns:
None
# Raises:
None"""
if filename.endswith(".db") or filename == ":memory:":
self.__db = filename
else:
self.__db = filename + ".db"
self.__con = sqlite3.connect(self.__db)
self.addTable("default")
def setTable(self, tableName: str) -> None:
"""# Function: sql.setTable
Sets the currently active table
# Inputs:
tableName: str - The name of the table to use
# Returns:
None
# Raises:
None"""
self.__table = tableName
def get(self, name: str) -> object or None:
"""# Function: sql.get
Gets the value of a key
# Inputs:
name: str - The name of the key to retrieve
# Returns:
object or None - If the key exists, return it's value, otherwise, return `None`
# Raises:
AttributeError - If the table is unset"""
if not self.__table:
raise AttributeError("Attempted to read from unset table")
cur = self.__con.execute(
f"""SELECT value FROM "{self.__table}" WHERE name = ?""", (name,)
)
data = cur.fetchone()
if data:
try:
return ast.literal_eval(data[0])
except:
return data[0]
return None
def set(self, name: str, value: object) -> int:
"""# Function: sql.set
Sets the value of a key
# Inputs:
name: str - The name of the key to set
value: object - The value of the key
# Returns:
int - `1` if the key was created, `2` if it was updated
# Raises:
AttributeError - If the table is unset"""
if not self.__table:
raise AttributeError("Attempted to write to unset table")
if self.get(name):
self.__con.execute(
f"""UPDATE "{self.__table}" SET value = ? WHERE name = ?""",
(str(value), name),
)
self.__con.commit()
return 2
else:
self.__con.execute(
f"""INSERT INTO "{self.__table}" (name, value) VALUES (?, ?)""",
(name, str(value)),
)
self.__con.commit()
return 1
def delete(self, name: str) -> None:
"""# Function: sql.delete
Deletes a key from the table
# Inputs:
name: str - The name of the key to delete
# Returns:
None
# Raises:
AttributeError - If the table is unset"""
if not self.__table:
raise AttributeError("Attempted to delete from unset table")
if self.get(name):
self.__con.execute(
f"""DELETE FROM "{self.__table}" WHERE name = ?""", (name,)
)
self.__con.commit()
def delete_all(self) -> None:
"""# Function: sql.delete_all
Deletes all keys from the table
# Inputs:
None
# Returns:
None
# Raises:
AttributeError - If the table is unset"""
if not self.__table:
raise AttributeError("Attempted to delete from unset table")
self.__con.execute(f"""DELETE FROM "{self.__table}" """)
self.__con.commit()
def close(self) -> None:
"""# Function: sql.close
Closes the database connection
# Inputs:
None
# Returns:
None
# Raises:
None"""
self.__con.close()
self.__con = None
self.__db = None
self.__table = None

7
package/upload.sh Executable file
View file

@ -0,0 +1,7 @@
echo "Formatting..."
black . > /dev/null
echo "Building..."
poetry build > /dev/null
echo "Uploading..."
python3 -m twine upload -r pypi dist/*
echo "Done!"

22
replit.nix Normal file
View file

@ -0,0 +1,22 @@
{ pkgs }: {
deps = [
pkgs.man-db
pkgs.less
pkgs.zip
pkgs.unzip
pkgs.python38Full
];
env = {
PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
# Needed for pandas / numpy
pkgs.stdenv.cc.cc.lib
pkgs.zlib
# Needed for pygame
pkgs.glib
# Needed for matplotlib
pkgs.xorg.libX11
];
PYTHONBIN = "${pkgs.python38Full}/bin/python3.8";
LANG = "en_US.UTF-8";
};
}