From a38d1f4409aa41f82b91af048eb2aa125f08673c Mon Sep 17 00:00:00 2001 From: Corder Guy Date: Tue, 17 Apr 2018 14:50:46 -0500 Subject: [PATCH] Add vim modeline --- mocha_server.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mocha_server.py b/mocha_server.py index 727ee61..7a5a47a 100755 --- a/mocha_server.py +++ b/mocha_server.py @@ -14,6 +14,7 @@ if not path.exists(DATABASE): # TODO: Add fetching of top N users by score # TODO: Add ability to store and retrieve avatars (as image files?) + def get_users(username_list): """ Gets a list of users searching by name. @@ -24,7 +25,7 @@ def get_users(username_list): cursor = conn.cursor() output = [] for usr in username_list: - cursor.execute("select * from users where username=(?)", (usr,)) + cursor.execute("select * from users where username=(?)", (usr, )) output += cursor.fetchall() output = json.dumps([dict(row) for row in output]) @@ -48,9 +49,11 @@ def get_top_N(search_parameter, desc, N): conn.row_factory = sqlite3.Row cursor = conn.cursor() if desc == True: - cursor.execute("select * from users order by ? desc limit ?", (search_parameter, N)) + cursor.execute("select * from users order by ? desc limit ?", + (search_parameter, N)) else: - cursor.execute("select * from users order by ? asc limit ?", (search_parameter, N)) + cursor.execute("select * from users order by ? asc limit ?", + (search_parameter, N)) output = cursor.fetchall() #print(output) @@ -72,9 +75,9 @@ def update_row(user_id, updated_username): def insert_row(user_id, username): """ - Inserts a row for a NEW user with given parameters - This may work better with AUTOINCREMENT to avoid arbitrary ids and duplicates - """ + Inserts a row for a NEW user with given parameters + This may work better with AUTOINCREMENT to avoid arbitrary ids and duplicates + """ conn = sqlite3.connect(DATABASE) conn.row_factory = sqlite3.Row @@ -92,8 +95,8 @@ def fetch_user(user_id): conn = sqlite3.connect(DATABASE) conn.row_factory = sqlite3.Row cursor = conn.cursor() - if user_id != '*': # must use (?), (item,) format - cursor.execute("SELECT * FROM users WHERE user_id=(?)", (user_id,)) + if user_id != '*': # must use (?), (item,) format + cursor.execute("SELECT * FROM users WHERE user_id=(?)", (user_id, )) else: cursor.execute("SELECT * FROM users") @@ -156,3 +159,5 @@ def application(environ, start_response): start_response(status, response_headers) return [output] + +# vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab