merge back into one module
This commit is contained in:
parent
a8f1b83256
commit
782f83fbd4
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -116,14 +116,3 @@ dmypy.json
|
|||
|
||||
test*.py
|
||||
reload.cfg
|
||||
|
||||
# symlinks
|
||||
/izzylib
|
||||
/base/izzylib/dbus
|
||||
/base/izzylib/hasher
|
||||
/base/izzylib/http_urllib_client
|
||||
/base/izzylib/http_server
|
||||
/base/izzylib/mbus
|
||||
/base/izzylib/sql
|
||||
/base/izzylib/template
|
||||
/base/izzylib/tinydb
|
||||
|
|
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
@ -0,0 +1 @@
|
|||
recursive-include izzylib *
|
34
README.md
34
README.md
|
@ -4,29 +4,19 @@ These are just a number of functions I keep reusing over and over again in most
|
|||
|
||||
## Installation
|
||||
|
||||
You only need to install the base and whatever sub-modules you want to use
|
||||
|
||||
### From Git
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-base&subdirectory=base"
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-dbus&subdirectory=dbus"
|
||||
optional dependencies
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-hasher&subdirectory=hasher"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-http-server&subdirectory=http_server"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-http-urllib-client&subdirectory=http_urllib_client"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-sql&subdirectory=sql"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-templates&subdirectory=template"
|
||||
|
||||
$(venv)/bin/python -m pip install -e "git+https://git.barkshark.xyz/izaliamae/izzylib.git@rework#egg=izzylib-tinydb&subdirectory=tinydb"
|
||||
|
||||
### From Source
|
||||
|
||||
$(venv)/bin/python setup.py install ['all' or a combination of these: dbus hasher http_server http_urllib_client sql template tinydb]
|
||||
- dbus
|
||||
- hasher
|
||||
- http_server
|
||||
- http_urllib_client
|
||||
- sql
|
||||
- template
|
||||
- tinydb
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -36,13 +26,13 @@ Most useful classes and functions are imported in the module root, so you don't
|
|||
|
||||
This is fine:
|
||||
|
||||
from izzylib import SqlDatabase
|
||||
from izzylib import Database
|
||||
|
||||
and points to:
|
||||
|
||||
from izzylib.sql.generic import SqlDatabase
|
||||
from izzylib.sql.database import Database
|
||||
|
||||
Or even simply do `import izzylib` and use `izzylib.SqlDatabase()`.
|
||||
Or even simply do `import izzylib` and use `izzylib.Database()`.
|
||||
|
||||
### Usage
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib Base",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib']),
|
||||
python_requires='>=3.7.0',
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='a collection of often-used functions and classes',
|
||||
keywords='web http client',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'dasbus==1.6'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib DBus",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.dbus']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='Client and server for DBus',
|
||||
keywords='client server dbus',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1,44 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'argon2-cffi==20.1.0'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib Password Hasher",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.hasher']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='a collection of often-used functions and classes',
|
||||
keywords='web http server templates argon2 jinja haml',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||
'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
recursive-include izzylib/http_server/frontend *
|
|
@ -1,44 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'sanic>=20.12.3',
|
||||
'sanic-cors>=1.0.0',
|
||||
'envbash>=1.0.0'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib HTTP Server",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.http_server']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=True,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='An HTTP server based on Sanic',
|
||||
keywords='web http server',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'pillow==8.2.0',
|
||||
'pycryptodome==3.10.1',
|
||||
'urllib3==1.26.5',
|
||||
'tldextract==3.1.0'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib HTTP Urllib Client",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.http_urllib_client']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='A Urllib3 client with support for http header signing and verifying',
|
||||
keywords='web http client',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
85
izzylib/dbus/types.py
Normal file
85
izzylib/dbus/types.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
import typing
|
||||
|
||||
|
||||
class DBusType(typing.NewType):
|
||||
def __init__(self, name, type, string):
|
||||
super().__init__(name, type)
|
||||
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.string = string
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.string
|
||||
|
||||
|
||||
class Dict(DBusType):
|
||||
def __init__(key=Str, value=Str):
|
||||
super().__init__('Dict', dict, None)
|
||||
|
||||
self.key = key
|
||||
self.value = value
|
||||
|
||||
|
||||
# I'm pretty sure there's an easier way to do f-strings without parsing curly brackets, but I'm not sure how atm
|
||||
def __str__(self):
|
||||
return '{' + f'{self.key}{self.value}' + '}'
|
||||
|
||||
|
||||
class List(DBusType):
|
||||
def __init__(*types):
|
||||
super().__init__('List', list, None)
|
||||
|
||||
self.types = types
|
||||
|
||||
|
||||
def __str__(self):
|
||||
types = ''.join(self.types)
|
||||
return f'a{types}'
|
||||
|
||||
|
||||
def Set(List):
|
||||
def __init__(*types):
|
||||
super().__init__('Set', set, None)
|
||||
|
||||
self.types = types
|
||||
|
||||
|
||||
def Tuple(List):
|
||||
def __init__(*types):
|
||||
super().__init__('Tuple', Tuple, None)
|
||||
|
||||
self.types = types
|
||||
|
||||
|
||||
Str = DBusType('String', str, 's')
|
||||
Byte = DBusType('Byte', bytes, 'y')
|
||||
Bool = DBusType('Boolean', bool, 'b')
|
||||
Float = DBusType('Float', float, 'd')
|
||||
Int = DbusType('Int64', int, 'x')
|
||||
Int16 = DBusType('Int16', int, 'n')
|
||||
Int32 = DbusType('Int32', int, 'i')
|
||||
Int64 = DbusType('Int64', int, 'x')
|
||||
Uint16 = DBusType('Uint16', int, 'q')
|
||||
Uint32 = DBusType('Uint32', int, 'u')
|
||||
Uint64 = DBusType('Uint64', int, 't')
|
||||
|
||||
|
||||
__all__ = [
|
||||
'Any',
|
||||
'Bytes',
|
||||
'Dict',
|
||||
'Float',
|
||||
'Int',
|
||||
'Int16',
|
||||
'Int32',
|
||||
'Int64',
|
||||
'List',
|
||||
'Set',
|
||||
'Str',
|
||||
'Tuple',
|
||||
'Uint16',
|
||||
'Uint32',
|
||||
'Uint64'
|
||||
]
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
|
@ -1,16 +0,0 @@
|
|||
dasbus==1.6
|
||||
argon2-cffi==20.1.0
|
||||
pillow==8.2.0
|
||||
pycryptodome==3.10.1
|
||||
requests==2.25.1
|
||||
tldextract==3.1.0
|
||||
SQLAlchemy==1.4.7
|
||||
SQLAlchemy-Paginator==0.2
|
||||
colour==0.1.5
|
||||
Hamlish-Jinja==0.3.3
|
||||
Jinja2==3.0.1
|
||||
Markdown==3.3.3
|
||||
tinydb==4.4.0
|
||||
tinydb-serialization==2.1.0
|
||||
tinydb-smartcache==2.0.0
|
||||
tinyrecord==0.2.0
|
63
setup.cfg
Normal file
63
setup.cfg
Normal file
|
@ -0,0 +1,63 @@
|
|||
[metadata]
|
||||
name = IzzyLib
|
||||
version = 0.7.0
|
||||
author = Zoey Mae
|
||||
author_email = zoey@barkshark.xyz
|
||||
url = https://git.barkshark.xyz/izaliamae/izzylib
|
||||
description = Functions and classes that I use often
|
||||
license = CNPL
|
||||
license_file = LICENSE
|
||||
platform = any
|
||||
keywords = python http activitypub sql database html css
|
||||
classifiers =
|
||||
Development Status :: 3 - Alpha
|
||||
Intended Audience :: Developers
|
||||
Operating System :: OS Independent
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python 3.6
|
||||
Programming Language :: Python 3.7
|
||||
Programming Language :: Python 3.8
|
||||
Programming Language :: Python 3.9
|
||||
Topic :: Software Development :: Libraries :: Python Modules
|
||||
project_urls =
|
||||
Bug Tracker = https://git.barkshark.xyz/izaliamae/izzylib/issues
|
||||
Documentation = https://git.barkshark.xyz/izaliamae/izzylib/wiki
|
||||
Source Code = https://git.barkshark.xyz/izaliamae/izzylib
|
||||
|
||||
[options]
|
||||
include_package_data = true
|
||||
packages = izzylib
|
||||
python_requires = >= 3.6
|
||||
setup_requires =
|
||||
setuptools >= 38.3.0
|
||||
|
||||
[options.package_data]
|
||||
izzylib = izzylib/*
|
||||
|
||||
[options.extras_require]
|
||||
dbus =
|
||||
dasbus==1.6
|
||||
hasher =
|
||||
argon2-cffi == 21.1.0
|
||||
http_server =
|
||||
sanic == 21.6.2
|
||||
envbash == 1.2.0
|
||||
http_urllib_client =
|
||||
pillow == 8.3.2
|
||||
pycryptodome == 3.10.1
|
||||
urllib3 == 1.26.6
|
||||
tldextract == 3.1.2
|
||||
sql =
|
||||
SQLAlchemy == 1.4.23
|
||||
SQLAlchemy-Paginator == 0.2
|
||||
template =
|
||||
colour == 0.1.5
|
||||
Hamlish-Jinja == 0.3.3
|
||||
Jinja2 == 3.0.1
|
||||
Markdown == 3.3.4
|
||||
|
||||
[bdist_wheel]
|
||||
universal = true
|
||||
|
||||
[sdist]
|
||||
formats = zip, gztar
|
94
setup.py
94
setup.py
|
@ -1,94 +0,0 @@
|
|||
import subprocess, sys
|
||||
|
||||
|
||||
submodules = [
|
||||
'http_server',
|
||||
'requests_client',
|
||||
'sql',
|
||||
'template',
|
||||
'tinydb'
|
||||
]
|
||||
|
||||
submodule_names = [
|
||||
'IzzyLib-Base',
|
||||
'IzzyLib-Database',
|
||||
'IzzyLib-HTTP-Server',
|
||||
'IzzyLib-Requests-Client',
|
||||
'IzzyLib-SQL',
|
||||
'IzzyLib-Templates',
|
||||
'IzzyLib-TinyDB',
|
||||
]
|
||||
|
||||
|
||||
def main(*args):
|
||||
if not len(args):
|
||||
print('Missing command')
|
||||
return cmd_help()
|
||||
|
||||
command = args[0]
|
||||
|
||||
if command not in ['install', 'uninstall', 'dev']:
|
||||
print('Invalid command:', command)
|
||||
return cmd_help()
|
||||
|
||||
if command == 'uninstall':
|
||||
subprocess.run([sys.executable, '-m', 'pip', 'uninstall', '-y', *submodule_names])
|
||||
return
|
||||
|
||||
submodule_args = []
|
||||
|
||||
if len(args) > 1:
|
||||
if args[1] == 'all':
|
||||
submodule_args = [f'./{module}' for module in modinstall]
|
||||
|
||||
else:
|
||||
submodule_args = [f'./{module}' for module in args[1:]]
|
||||
|
||||
for mod in submodules:
|
||||
if mod not in submodules:
|
||||
print('Invalid submodule:', mod)
|
||||
return cmd_help()
|
||||
|
||||
options = ['-m', 'pip', 'install', './base', *submodule_args]
|
||||
|
||||
if command == 'dev':
|
||||
options.insert(3, '--use-feature=in-tree-build')
|
||||
|
||||
print(options)
|
||||
|
||||
subprocess.run([sys.executable, *options])
|
||||
|
||||
|
||||
def cmd_help(*args):
|
||||
text = f'''IzzyLib manager
|
||||
|
||||
Commands:
|
||||
install [submodules: space-separated list]:
|
||||
Install IzzyLib as well as any sub-modules if any are required
|
||||
|
||||
uninstall [submodules]
|
||||
Uninstall IzzyLib and any installed submodules
|
||||
|
||||
Valid Submodules:
|
||||
{', '.join(submodules)}
|
||||
'''
|
||||
|
||||
print(text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
args = sys.argv[1:]
|
||||
|
||||
except IndexError:
|
||||
args = []
|
||||
|
||||
try:
|
||||
if not args:
|
||||
cmd_help()
|
||||
|
||||
else:
|
||||
main(*args)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print('Bye! UvU')
|
43
sql/setup.py
43
sql/setup.py
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'SQLAlchemy==1.4.7',
|
||||
'SQLAlchemy-Paginator==0.2'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib SQL",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.sql']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='a collection of often-used functions and classes',
|
||||
keywords='database postgresql sqlite tinydb',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Database',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1,46 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'colour==0.1.5',
|
||||
'Hamlish-Jinja==0.3.3',
|
||||
'Jinja2==3.0.1',
|
||||
'Markdown==3.3.3',
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib Templates",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.template']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='A template engine based on Jinja2 and HAMLish-Jinja',
|
||||
keywords='web http templates jinja haml',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
from .tiny import TinyDatabase, TinyRow, TinyRows
|
|
@ -1,174 +0,0 @@
|
|||
# incomplete
|
||||
import base64
|
||||
import json
|
||||
import operator
|
||||
import queue
|
||||
import threading
|
||||
import time
|
||||
|
||||
import tinydb
|
||||
import tinydb_serialization
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from izzylib import Path, random_gen
|
||||
|
||||
|
||||
class AwaitingResult(object):
|
||||
pass
|
||||
|
||||
|
||||
class TinyDatabase(tinydb.TinyDB):
|
||||
def __init__(self, dbfile: Path, queue_limit: int=64, serializers: list=[]):
|
||||
options = {
|
||||
'indent': 2
|
||||
}
|
||||
|
||||
serialization = tinydb_serialization.SerializationMiddleware(ThreadSupport)
|
||||
serialization.register_serializer(tinydb_serialization.serializers.DateTimeSerializer(), 'TinyDate')
|
||||
serialization.register_serializer(ByteSerializer(), 'TinyBytes')
|
||||
serialization.register_serializer(PathSerialize(), 'IzzyLibPath')
|
||||
serialization.register_serializer(DotDictSerialize(), 'IzzyLibDotDict')
|
||||
|
||||
for serializer in serializers:
|
||||
serialization.register_serializer(serializer(), serializer.__class__.__name__)
|
||||
|
||||
options['storage'] = serialization
|
||||
|
||||
super().__init__(dbfile, **options)
|
||||
|
||||
self.dbfile = dbfile
|
||||
self.queue = queue.Queue(maxsize=queue_limit)
|
||||
self.sessions = {}
|
||||
|
||||
|
||||
@property
|
||||
def session(self):
|
||||
return TinySession(self)
|
||||
|
||||
|
||||
def fetch(self, table, single=True, orderby=None, reverse=False, **kwargs):
|
||||
query = tinydb.Query()
|
||||
|
||||
if not kwargs:
|
||||
rows = TinyRows(self, self.table(table).all())
|
||||
single = False
|
||||
|
||||
else:
|
||||
rows = TinyRows(self, self.table(table).search(query.fragment(kwargs)))
|
||||
|
||||
if single:
|
||||
return rows[0] if rows else None
|
||||
|
||||
return rows if not orderby else sorted(rows, key=operator.itemgetter(orderby), reverse=reverse)
|
||||
|
||||
|
||||
def insert(self, table, row=None, rowid=None, **kwargs):
|
||||
if row:
|
||||
rowid = row.doc_id
|
||||
|
||||
elif not rowid:
|
||||
row = self.fetch(table, **kwargs)
|
||||
rowid = row.doc_id if row else None
|
||||
|
||||
if rowid:
|
||||
return self.table(table).update(kwargs, doc_ids=[rowid])
|
||||
|
||||
return self.table(table).insert(kwargs)
|
||||
|
||||
|
||||
def remove(self, table, row=None, rowid=None, **kwargs):
|
||||
query = tinydb.Query()
|
||||
|
||||
if row or rowid:
|
||||
rowid = rowid or row.doc_id
|
||||
return self.table(table).remove(doc_ids=[row.doc_id])
|
||||
|
||||
return self.table(table).remove(query.fragment(kwargs))
|
||||
|
||||
|
||||
def TinyRows(db, rows):
|
||||
return [TinyRow(db, row) for row in rows]
|
||||
|
||||
|
||||
class TinyRow(DotDict):
|
||||
def __init__(self, db, row):
|
||||
super().__init({'id': row.doc_id})
|
||||
super().update({k: v for k,v in row.items()})
|
||||
|
||||
|
||||
def update(self, data={}):
|
||||
db.update(rowid=self.id, **data)
|
||||
super().update(data)
|
||||
|
||||
|
||||
def remove(self):
|
||||
db.remove(rowid=self.id)
|
||||
|
||||
|
||||
class ThreadSupport(tinydb.storages.JSONStorage):
|
||||
def __init__(self, filename, *args, **kwargs):
|
||||
super().__init__(filename, *args, **kwargs)
|
||||
|
||||
self.pool = ThreadPoolExecutor(max_workers=8)
|
||||
|
||||
## send all storage commands to the queue
|
||||
def read(self):
|
||||
data = self.queue_put('read')
|
||||
return data
|
||||
|
||||
|
||||
def write(self, data):
|
||||
for future in as_completed(self.pool.submit(super().write, data)):
|
||||
self.queue_put('write', data)
|
||||
|
||||
|
||||
def close(self):
|
||||
self.pool.shutdown(wait=False)
|
||||
|
||||
|
||||
class ByteSerializer(tinydb_serialization.Serializer):
|
||||
OBJ_CLASS = bytes
|
||||
|
||||
def encode(self, obj):
|
||||
#print('encode', self.__class__.__name__, obj)
|
||||
return base64.b64encode(obj).decode('ascii')
|
||||
|
||||
def decode(self, obj):
|
||||
#print('decode', self.__class__.__name__, obj)
|
||||
return base64.b64decode(obj)
|
||||
|
||||
|
||||
class DictSerializer(tinydb_serialization.Serializer):
|
||||
OBJ_CLASS = dict
|
||||
|
||||
def encode(self, obj):
|
||||
#print('encode', self.__class__.__name__, obj)
|
||||
return json.dumps(obj)
|
||||
|
||||
def decode(self, obj):
|
||||
#print('decode', self.__class__.__name__, obj)
|
||||
return json.loads(obj)
|
||||
|
||||
|
||||
class DotDictSerialize(tinydb_serialization.Serializer):
|
||||
OBJ_CLASS = DotDict
|
||||
|
||||
def encode(self, obj):
|
||||
#print('encode', self.__class__.__name__, obj)
|
||||
return obj.toJson()
|
||||
|
||||
def decode(self, obj):
|
||||
#print('decode', self.__class__.__name__, obj)
|
||||
return DotDict(obj)
|
||||
|
||||
|
||||
class PathSerialize(tinydb_serialization.Serializer):
|
||||
OBJ_CLASS = Path
|
||||
|
||||
def encode(self, obj):
|
||||
#print('encode', self.__class__.__name__, obj)
|
||||
return obj.str()
|
||||
|
||||
def decode(self, obj):
|
||||
#print('decode', self.__class__.__name__, obj)
|
||||
return Path(obj)
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
from setuptools import setup, find_namespace_packages
|
||||
|
||||
|
||||
requires = [
|
||||
'tinydb==4.4.0',
|
||||
'tinydb-serialization==2.1.0',
|
||||
'tinydb-smartcache==2.0.0',
|
||||
'tinyrecord==0.2.0'
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="IzzyLib TinyDB",
|
||||
version='0.6.0',
|
||||
packages=find_namespace_packages(include=['izzylib.tinydb']),
|
||||
python_requires='>=3.7.0',
|
||||
install_requires=requires,
|
||||
include_package_data=False,
|
||||
author='Zoey Mae',
|
||||
author_email='admin@barkshark.xyz',
|
||||
description='a collection of often-used functions and classes',
|
||||
keywords='database postgresql sqlite tinydb',
|
||||
url='https://git.barkshark.xyz/izaliamae/izzylib',
|
||||
project_urls={
|
||||
'Bug Tracker': 'https://git.barkshark.xyz/izaliamae/izzylib/issues',
|
||||
'Documentation': 'https://git.barkshark.xyz/izaliamae/izzylib/wiki',
|
||||
'Source Code': 'https://git.barkshark.xyz/izaliamae/izzylib'
|
||||
},
|
||||
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Information Technology',
|
||||
'License :: Co-operative Non-violent Public License (CNPL 6+)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Topic :: Database',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
Loading…
Reference in a new issue