From 9680a416da797f6af4b208a38aa8ce4fa8c21d44 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Sun, 19 May 2024 17:56:26 -0500 Subject: [PATCH] move leglib into a python package --- analyser.py | 20 +++++++++++--------- leglib.py | 2 -- leglib/__main__.py | 0 billdb.py => leglib/billdb.py | 4 ++-- common.py => leglib/common.py | 0 lib.py => leglib/lib.py | 0 parsers.py => leglib/parsers.py | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 leglib.py create mode 100644 leglib/__main__.py rename billdb.py => leglib/billdb.py (97%) rename common.py => leglib/common.py (100%) rename lib.py => leglib/lib.py (100%) rename parsers.py => leglib/parsers.py (99%) diff --git a/analyser.py b/analyser.py index 51ea1cb..3477948 100644 --- a/analyser.py +++ b/analyser.py @@ -1,6 +1,8 @@ import leglib #billdb import BillDB, BillQuery, QueryField, QueryAll +from leglib.billdb import BillDB, BillQuery, QueryField, QueryAll +from leglib.parsers import HSYIGPdfParser -parser = leglib.parsers.HSYIGPdfParser.from_filename( +parser = HSYIGPdfParser.from_filename( filename="YIGVolunteerBook2024.pdf", confname="HSVolunteer" ) @@ -8,19 +10,19 @@ parser.parse() print(len(parser.bills)) -db = leglib.billdb.BillDB() +db = BillDB() db.add_conference(parser=parser) -allbills = len(db.search(query=leglib.billdb.QueryAll)) +allbills = len(db.search(query=QueryAll)) -bluelen = len(db.search(query=leglib.billdb.BillQuery(color=leglib.billdb.QueryField.Colors.Blue))) -whitelen = len(db.search(query=leglib.billdb.BillQuery(color=leglib.billdb.QueryField.Colors.White))) -redlen = len(db.search(query=leglib.billdb.BillQuery(color=leglib.billdb.QueryField.Colors.Red))) +bluelen = len(db.search(query=BillQuery(color=QueryField.Colors.Blue))) +whitelen = len(db.search(query=BillQuery(color=QueryField.Colors.White))) +redlen = len(db.search(query=BillQuery(color=QueryField.Colors.Red))) -senatelen = len(db.search(query=leglib.billdb.BillQuery(assembly=leglib.billdb.QueryField.Assemblies.Senate))) -houselen = len(db.search(query=leglib.billdb.BillQuery(assembly=leglib.billdb.QueryField.Assemblies.House))) +senatelen = len(db.search(query=BillQuery(assembly=QueryField.Assemblies.Senate))) +houselen = len(db.search(query=BillQuery(assembly=QueryField.Assemblies.House))) -franklincount = len(db.search(query=leglib.billdb.BillQuery(school="Franklin"))) +franklincount = len(db.search(query=BillQuery(school="Franklin"))) print(allbills) print(redlen, whitelen, bluelen, redlen + whitelen + bluelen) diff --git a/leglib.py b/leglib.py deleted file mode 100644 index 045c0d3..0000000 --- a/leglib.py +++ /dev/null @@ -1,2 +0,0 @@ -import parsers -import billdb diff --git a/leglib/__main__.py b/leglib/__main__.py new file mode 100644 index 0000000..e69de29 diff --git a/billdb.py b/leglib/billdb.py similarity index 97% rename from billdb.py rename to leglib/billdb.py index c558fae..13bdf90 100644 --- a/billdb.py +++ b/leglib/billdb.py @@ -1,5 +1,5 @@ -from common import Bill, CCEColors, CCEAssemblies -from parsers import BookParser +from .common import Bill, CCEColors, CCEAssemblies +from .parsers import BookParser from typing import Type, Self from dataclasses import dataclass diff --git a/common.py b/leglib/common.py similarity index 100% rename from common.py rename to leglib/common.py diff --git a/lib.py b/leglib/lib.py similarity index 100% rename from lib.py rename to leglib/lib.py diff --git a/parsers.py b/leglib/parsers.py similarity index 99% rename from parsers.py rename to leglib/parsers.py index 326e0d4..b2a33d0 100644 --- a/parsers.py +++ b/leglib/parsers.py @@ -3,8 +3,8 @@ from typing import Any, Self, ClassVar from itertools import groupby from dataclasses import dataclass -from lib import FitzBlockWrapper -from common import Bill +from .lib import FitzBlockWrapper +from .common import Bill @dataclass class BookParser: