From 6ebb397a866116a7a57f6bd7cb22cfbea3007929 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Fri, 25 Feb 2022 16:54:21 +0100 Subject: [PATCH] Create basic package structure --- LICENSE | 0 pyproject.toml | 0 setup.cfg | 0 src/procrusql-fit | 25 +++++++++++++++++++++ procrusql.py => src/procrusql/__init__.py | 0 parse_dsl_manual => src/procrusql/parser.py | 14 ------------ 6 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 LICENSE create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100755 src/procrusql-fit rename procrusql.py => src/procrusql/__init__.py (100%) rename parse_dsl_manual => src/procrusql/parser.py (95%) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e69de29 diff --git a/src/procrusql-fit b/src/procrusql-fit new file mode 100755 index 0000000..a086a29 --- /dev/null +++ b/src/procrusql-fit @@ -0,0 +1,25 @@ +#!/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 diff --git a/procrusql.py b/src/procrusql/__init__.py similarity index 100% rename from procrusql.py rename to src/procrusql/__init__.py diff --git a/parse_dsl_manual b/src/procrusql/parser.py similarity index 95% rename from parse_dsl_manual rename to src/procrusql/parser.py index ecdc431..5d33596 100755 --- a/parse_dsl_manual +++ b/src/procrusql/parser.py @@ -291,17 +291,3 @@ def rulename(): rulenum += 1 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)