Compare commits

..

3 Commits

Author SHA1 Message Date
Peter J. Holzer 0f3cd9be19 Add metadata 2022-02-26 11:09:35 +01:00
Peter J. Holzer a03a1e96d3 Move entry point to __init__.py
I couldn't find a way to include scripts but pip can automatically
create them from entry-points.
2022-02-26 10:49:24 +01:00
Peter J. Holzer 6ebb397a86 Create basic package structure 2022-02-25 16:54:21 +01:00
6 changed files with 85 additions and 14 deletions

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2020 Peter J. Holzer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,2 +1,14 @@
ProcruSQL ProcruSQL
========= =========
Make a database fit its description.
Why?
----
To be written ...
Syntax
------
To be written ...

6
pyproject.toml Normal file
View File

@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"

28
setup.cfg Normal file
View File

@ -0,0 +1,28 @@
[metadata]
name = ProcruSQL
version = 0.0.1
author = Peter J. Holzer
author_email = hjp@hjp.at
description = Make a database fit its description
long_description = file: README.md
long_description_content_type = text/markdown
url = https://git.hjp.at:3000/hjp/procrusql
project_urls =
Bug Tracker = https://git.hjp.at:3000/hjp/procrusql/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
package_dir =
= src
packages = find:
python_requires = >=3.8
[options.packages.find]
where = src
[options.entry_points]
console_scripts =
procrusql-fit = procrusql:main

View File

@ -1,4 +1,5 @@
import logging import logging
import sys
import psycopg2 import psycopg2
from psycopg2 import sql from psycopg2 import sql
@ -241,3 +242,19 @@ def dump_dot():
for i in range(1, len(in_order)): for i in range(1, len(in_order)):
print(f"\t{in_order[i-1]} -> {in_order[i]} [style=dashed]") print(f"\t{in_order[i-1]} -> {in_order[i]} [style=dashed]")
print("}") print("}")
def main():
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(lineno)d | %(message)s", level=logging.DEBUG)
with open(sys.argv[1]) as rf:
text = rf.read()
ps = procrusql.parser.ParseState(text)
ps2 = procrusql.parser.parse_ruleset(ps)
if not ps2:
ps.printerror()
sys.exit(1)
db = psycopg2.connect(sys.argv[2])
procrusql.fit(db, ps2.ast)

View File

@ -291,17 +291,3 @@ def rulename():
rulenum += 1 rulenum += 1
return f"__rule_{rulenum}" return f"__rule_{rulenum}"
if __name__ == "__main__":
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(lineno)d | %(message)s", level=logging.DEBUG)
with open(sys.argv[1]) as rf:
text = rf.read()
ps = ParseState(text)
ps2 = parse_ruleset(ps)
if not ps2:
ps.printerror()
sys.exit(1)
db = psycopg2.connect(sys.argv[2])
procrusql.fit(db, ps2.ast)