Linting
This commit is contained in:
@@ -34,9 +34,9 @@ class docketModel(QAbstractTableModel):
|
|||||||
if not query.exec():
|
if not query.exec():
|
||||||
query_error(query)
|
query_error(query)
|
||||||
while query.next():
|
while query.next():
|
||||||
date = query.value('date')
|
date = query.value("date")
|
||||||
assert isinstance(date, QDate)
|
assert isinstance(date, QDate)
|
||||||
row = [date.toString('MMMM d, yyyy'), query.value(3)]
|
row = [date.toString("MMMM d, yyyy"), query.value(3)]
|
||||||
self.entries.append(row)
|
self.entries.append(row)
|
||||||
q2.bindValue(":eid", query.value("entry_id"))
|
q2.bindValue(":eid", query.value("entry_id"))
|
||||||
if not q2.exec():
|
if not q2.exec():
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from pony.orm import (
|
from pony.orm import ( # type: ignore[import-untyped]
|
||||||
Database,
|
Database,
|
||||||
LongStr,
|
LongStr,
|
||||||
Optional,
|
Optional,
|
||||||
@@ -16,7 +16,7 @@ db = Database
|
|||||||
db = Database()
|
db = Database()
|
||||||
|
|
||||||
|
|
||||||
class Cases(db.Entity):
|
class Cases(db.Entity): # type: ignore[name-defined]
|
||||||
case_id = PrimaryKey(int, auto=True)
|
case_id = PrimaryKey(int, auto=True)
|
||||||
docket_id = Required(str)
|
docket_id = Required(str)
|
||||||
petitioners = Required(str)
|
petitioners = Required(str)
|
||||||
@@ -24,28 +24,32 @@ class Cases(db.Entity):
|
|||||||
date = Required(date)
|
date = Required(date)
|
||||||
active = Required(bool)
|
active = Required(bool)
|
||||||
entries = Set("Entries")
|
entries = Set("Entries")
|
||||||
lhs_id = Set('Cases', column='lhs')
|
lhs_id = Set("Cases", column="lhs")
|
||||||
rhs_id = Set('Cases', column='rhs')
|
rhs_id = Set("Cases", column="rhs")
|
||||||
|
|
||||||
class Entries(db.Entity):
|
|
||||||
|
class Entries(db.Entity): # type: ignore[name-defined]
|
||||||
entry_id = PrimaryKey(int, auto=True)
|
entry_id = PrimaryKey(int, auto=True)
|
||||||
case_id = Required(Cases)
|
case_id = Required(Cases)
|
||||||
date = Required(date)
|
date = Required(date)
|
||||||
text = Required(LongStr)
|
text = Required(LongStr)
|
||||||
documents = Set('Documents')
|
documents = Set("Documents")
|
||||||
|
|
||||||
class Documents(db.Entity):
|
|
||||||
|
class Documents(db.Entity): # type: ignore[name-defined]
|
||||||
document_id = PrimaryKey(int, auto=True)
|
document_id = PrimaryKey(int, auto=True)
|
||||||
entry_id = Required(Entries)
|
entry_id = Required(Entries)
|
||||||
name = Required(str)
|
name = Required(str)
|
||||||
url = Required(LongStr)
|
url = Required(LongStr)
|
||||||
|
|
||||||
class History(db.Entity):
|
|
||||||
|
class History(db.Entity): # type: ignore[name-defined]
|
||||||
history_id = PrimaryKey(int, auto=True)
|
history_id = PrimaryKey(int, auto=True)
|
||||||
year = Required(str, max_len=3)
|
year = Required(str, max_len=3)
|
||||||
edocket = Required(bool)
|
edocket = Required(bool)
|
||||||
number = Required(int)
|
number = Required(int)
|
||||||
|
|
||||||
|
|
||||||
set_sql_debug(True)
|
set_sql_debug(True)
|
||||||
db.bind(
|
db.bind(
|
||||||
provider="mysql",
|
provider="mysql",
|
||||||
|
|||||||
@@ -81,14 +81,16 @@ class documentDelegate(QStyledItemDelegate):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def eventFilter(self, object: QObject, event: QEvent) -> bool:
|
def eventFilter(self, object: QObject, event: QEvent) -> bool:
|
||||||
if event.type() in [ QEvent.Type.MouseButtonPress,
|
if event.type() in [
|
||||||
QEvent.Type.MouseButtonRelease]:
|
QEvent.Type.MouseButtonPress,
|
||||||
|
QEvent.Type.MouseButtonRelease,
|
||||||
|
]:
|
||||||
return False
|
return False
|
||||||
return super().eventFilter(object, event)
|
return super().eventFilter(object, event)
|
||||||
|
|
||||||
def event(self, ev:QEvent) -> bool:
|
def event(self, ev: QEvent) -> bool:
|
||||||
print(ev)
|
print(ev)
|
||||||
return super(documentDelegate,self).event(ev)
|
return super(documentDelegate, self).event(ev)
|
||||||
|
|
||||||
def paint(
|
def paint(
|
||||||
self,
|
self,
|
||||||
@@ -211,7 +213,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.updateThread.start()
|
self.updateThread.start()
|
||||||
return
|
return
|
||||||
|
|
||||||
@Slot(QModelIndex) # type: ignore
|
@Slot(QModelIndex) # type: ignore
|
||||||
def on_docketView_clicked(self, index: QModelIndex) -> None:
|
def on_docketView_clicked(self, index: QModelIndex) -> None:
|
||||||
print(f"view clicked, cell: {index.column()}, {index.row()}")
|
print(f"view clicked, cell: {index.column()}, {index.row()}")
|
||||||
return
|
return
|
||||||
@@ -226,6 +228,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
model.setQuery(query)
|
model.setQuery(query)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
#
|
#
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
@@ -236,6 +239,7 @@ def main() -> int:
|
|||||||
db.setPassword("lechOtvirf8Om/")
|
db.setPassword("lechOtvirf8Om/")
|
||||||
db.open()
|
db.open()
|
||||||
import lib.dbConfig
|
import lib.dbConfig
|
||||||
|
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
return app.exec()
|
return app.exec()
|
||||||
|
|
||||||
|
|||||||
35
workers.py
35
workers.py
@@ -156,7 +156,7 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
|
|||||||
assert isinstance(tmp, str)
|
assert isinstance(tmp, str)
|
||||||
matches = re.match(r"(No.)?\s*(\d+[-A]\d+).*$", tmp)
|
matches = re.match(r"(No.)?\s*(\d+[-A]\d+).*$", tmp)
|
||||||
assert matches is not None
|
assert matches is not None
|
||||||
print(matches,matches.groups())
|
print(matches, matches.groups())
|
||||||
docket_id = matches.group(2)
|
docket_id = matches.group(2)
|
||||||
print(f"Found {docket_id}")
|
print(f"Found {docket_id}")
|
||||||
|
|
||||||
@@ -188,13 +188,13 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
|
|||||||
assert isinstance(tr, Tag) and isinstance(tr.contents[1], Tag)
|
assert isinstance(tr, Tag) and isinstance(tr.contents[1], Tag)
|
||||||
td = tr.contents[1]
|
td = tr.contents[1]
|
||||||
assert isinstance(td, Tag)
|
assert isinstance(td, Tag)
|
||||||
if td.string is None:
|
docket_date = td.string
|
||||||
tmp = datetime.datetime(year=1776, month=7, day=4)
|
if docket_date is None:
|
||||||
else:
|
docket_date = "July 7, 1776"
|
||||||
docket_date = td.string.strip()
|
|
||||||
tmp = dateparser.parse(docket_date)
|
tmp = dateparser.parse(docket_date) # type: ignore[assignment]
|
||||||
assert isinstance(tmp, datetime.datetime)
|
assert tmp is not None
|
||||||
date = QDateTime.fromSecsSinceEpoch(int(tmp.timestamp()))
|
date = QDateTime.fromSecsSinceEpoch(int(tmp.timestamp())) # type: ignore[assignment, attr-defined]
|
||||||
|
|
||||||
#
|
#
|
||||||
# linked case is row 3, column 0
|
# linked case is row 3, column 0
|
||||||
@@ -224,7 +224,7 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
|
|||||||
# If there is a linked case, we need to get the ID for that case.
|
# If there is a linked case, we need to get the ID for that case.
|
||||||
if linked is not None:
|
if linked is not None:
|
||||||
linked = linked.replace("Linked with ", "")
|
linked = linked.replace("Linked with ", "")
|
||||||
for did in linked.split(','):
|
for did in linked.split(","):
|
||||||
did = did.strip()
|
did = did.strip()
|
||||||
query.prepare("SELECT * FROM cases WHERE docket_id = :did")
|
query.prepare("SELECT * FROM cases WHERE docket_id = :did")
|
||||||
query.bindValue(":did", linked)
|
query.bindValue(":did", linked)
|
||||||
@@ -235,19 +235,22 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
|
|||||||
if linked_id <= 0:
|
if linked_id <= 0:
|
||||||
raise Exception(f"Unable to create linked case: {did}")
|
raise Exception(f"Unable to create linked case: {did}")
|
||||||
else:
|
else:
|
||||||
linked_id = query.value('case_id')
|
linked_id = query.value("case_id")
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
query.prepare("SELECT * FROM cases_cases WHERE lhs = :lhs "
|
query.prepare(
|
||||||
"AND rhs = :rhs")
|
"SELECT * FROM cases_cases WHERE lhs = :lhs " "AND rhs = :rhs"
|
||||||
query.bindValue(':lhs', case_id)
|
)
|
||||||
query.bindValue(':rhs', linked_id)
|
query.bindValue(":lhs", case_id)
|
||||||
|
query.bindValue(":rhs", linked_id)
|
||||||
if not query.exec():
|
if not query.exec():
|
||||||
query_error(query)
|
query_error(query)
|
||||||
if not query.next():
|
if not query.next():
|
||||||
query.prepare("INSERT INTO cases_cases (lhs, rhs) "
|
query.prepare(
|
||||||
"VALUES ( :lhs, :rhs)")
|
"INSERT INTO cases_cases (lhs, rhs) "
|
||||||
|
"VALUES ( :lhs, :rhs)"
|
||||||
|
)
|
||||||
query.bindValue(":lhs", case_id)
|
query.bindValue(":lhs", case_id)
|
||||||
query.bindValue(":rhs", linked_id)
|
query.bindValue(":rhs", linked_id)
|
||||||
if not query.exec():
|
if not query.exec():
|
||||||
|
|||||||
Reference in New Issue
Block a user