diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-09-07 11:37:37 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-09-07 11:37:37 +1000 |
| commit | daccbbd9c73a5292ea9d6746560d7009e5aa666d (patch) | |
| tree | 9156bf011ab6302eb3c0d219d40587d594f51841 /backend/tolData/genPopData.py | |
| parent | 1a7fe33edafa68a6f759d124bdeee673ff9cf9ff (diff) | |
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'
Diffstat (limited to 'backend/tolData/genPopData.py')
| -rwxr-xr-x | backend/tolData/genPopData.py | 9 |
1 files changed, 4 insertions, 5 deletions
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() |
