Move entry point to __init__.py

I couldn't find a way to include scripts but pip can automatically
create them from entry-points.
This commit is contained in:
Peter J. Holzer 2022-02-26 10:49:24 +01:00 committed by Peter J. Holzer
parent 6ebb397a86
commit a03a1e96d3
2 changed files with 17 additions and 25 deletions

View File

@ -1,25 +0,0 @@
#!/usr/bin/python3
import logging
import sys
import psycopg2
import procrusql
import procrusql.parser
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 = 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)
# vim: tw=0

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)