Merged in hotfix/HTTPASTE-33 (pull request #17)

refactor(setuptools): include sql schema
This commit is contained in:
Tiara Rodney 2022-04-03 01:51:25 +00:00
commit 88851970d2
4 changed files with 12 additions and 8 deletions

View file

@ -1,6 +1,6 @@
[metadata]
name = httpaste-victorykit
version = 1.0.4-alpha
version = 1.0.5-alpha
author = Tiara Rodney
author_email = t.rodney@victoryk.it
description = a versatile HTTP pastebin
@ -39,4 +39,5 @@ console_scripts =
where = src
[options.package_data]
schema = src/httpaste/schema/httpaste.openapi.json
openapi_schema = src/httpaste/schema/httpaste.openapi.json
sql_schema = *.sql

View file

@ -2,6 +2,7 @@
"""
import argparse
import os
from importlib.resources import open_text
def _this_dir(basename: str) -> str:
@ -20,7 +21,7 @@ def _path_output(path, echo: bool = False) -> str:
return path
else:
with open(path, 'r') as fh:
with open_text('httpaste', path) as fh:
return fh.read()
@ -51,21 +52,21 @@ def command_wsgi(**kwargs):
"""get WSGI script
"""
print(_path_output(_this_dir('wsgi.py'), kwargs.get('echo')))
print(_path_output('wsgi.py', kwargs.get('echo')))
def command_cgi(**kwargs):
"""get CGI script
"""
print(_path_output(_this_dir('cgi.py'), kwargs.get('echo')))
print(_path_output('cgi.py', kwargs.get('echo')))
def command_fcgi(**kwargs):
"""get FastCGI script
"""
print(_path_output(_this_dir('fcgi.py'), kwargs.get('echo')))
print(_path_output('fcgi.py', kwargs.get('echo')))
def command_default_config(**kwargs):

View file

@ -3,6 +3,7 @@
from os import path
from sqlite3 import Connection
from time import time
from importlib.resources import open_text
def load(proto: object, connection: Connection, model_class: type):
@ -63,7 +64,7 @@ def init(connection: Connection):
cur = connection.cursor()
with open(path.join(path.dirname(__file__), 'paste.sql'), 'r') as fh:
with open_text('httpaste.backend.sqlite', 'paste.sql') as fh:
cur.execute(fh.read())

View file

@ -3,6 +3,7 @@
from os import path
from sqlite3 import Connection
from httpaste.model import User
from importlib.resources import open_text
def load(proto: User, connection: Connection):
@ -48,7 +49,7 @@ def init(connection: Connection):
cur = connection.cursor()
with open(path.join(path.dirname(__file__), 'user.sql'), 'r') as fh:
with open_text('httpaste.backend.sqlite', 'user.sql') as fh:
cur.execute(fh.read())