From fa8b4d0e872d182ee878020fb1b066ce0da621ae Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 14 Feb 2021 01:13:52 +0000 Subject: Syntactic sugar --- tools/extract.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/extract.py b/tools/extract.py index d60de84..f323d44 100644 --- a/tools/extract.py +++ b/tools/extract.py @@ -53,11 +53,15 @@ def keep(name): return k == "+" return True +class Row(sqlite3.Row): + def __getattr__(self, name): + return self[name] + db = sqlite3.connect("trac.db") -db.row_factory = sqlite3.Row +db.row_factory = Row for row in db.execute(wiki_query): - if keep(row["name"]): - print(urllib.parse.quote(row["name"], ""), row["version"]) + if keep(row.name): + print(urllib.parse.quote(row.name, ""), row.version) db.close() -- cgit v1.2.3