From daccbbd9c73a5292ea9d6746560d7009e5aa666d Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Wed, 7 Sep 2022 11:37:37 +1000 Subject: Add python type annotations Also use consistent quote symbols Also use 'is None' instead of '== None' Also use 'if list1' instead of 'if len(list1) > 0' --- backend/tolData/genPopData.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'backend/tolData/genPopData.py') diff --git a/backend/tolData/genPopData.py b/backend/tolData/genPopData.py index 9c5382c..3bb1325 100755 --- a/backend/tolData/genPopData.py +++ b/backend/tolData/genPopData.py @@ -1,13 +1,12 @@ #!/usr/bin/python3 -import sys import sqlite3 import argparse -parser = argparse.ArgumentParser(description=''' +parser = argparse.ArgumentParser(description=""" Reads enwiki page view info from a database, and stores it as node popularity values in the database. -''', formatter_class=argparse.RawDescriptionHelpFormatter) +""", formatter_class=argparse.RawDescriptionHelpFormatter) args = parser.parse_args() pageviewsDb = 'enwiki/pageviewData.db' @@ -19,7 +18,7 @@ dbCur = dbCon.cursor() print('Getting view counts') pdbCon = sqlite3.connect(pageviewsDb) pdbCur = pdbCon.cursor() -nodeToViews = {} # Maps node names to counts +nodeToViews: dict[str, int] = {} # Maps node names to counts iterNum = 0 for wikiId, views in pdbCur.execute('SELECT id, views from views'): iterNum += 1 @@ -27,7 +26,7 @@ for wikiId, views in pdbCur.execute('SELECT id, views from views'): print(f'At iteration {iterNum}') # Reached 1.6e6 # row = dbCur.execute('SELECT name FROM wiki_ids WHERE id = ?', (wikiId,)).fetchone() - if row != None: + if row is not None: nodeToViews[row[0]] = views pdbCon.close() -- cgit v1.2.3