-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery Starbot ⭐ refactored enthyp/chat #15
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,9 +85,8 @@ def password_correct(self, nick, password): | |
log.err('DB: password_correct CALL SUCCESSFUL') | ||
if correct_password: | ||
return correct_password[0][0] == password | ||
else: | ||
log.err('DB: password_correct CALL FAILURE: no such user in database') | ||
raise failure.Failure(sqlite3.IntegrityError()) | ||
log.err('DB: password_correct CALL FAILURE: no such user in database') | ||
raise failure.Failure(sqlite3.IntegrityError()) | ||
except failure.Failure as f: | ||
log.err(f'DB: password_correct FAILURE: {f.getErrorMessage()}') | ||
raise | ||
|
@@ -174,8 +173,7 @@ def add_notification(self, author, target, notification): | |
@log_operation | ||
@defer.inlineCallbacks | ||
def get_notifications(self, user): | ||
results = yield self._dbpool.runQuery(query.select_notifications, (user,)) | ||
return results | ||
return (yield self._dbpool.runQuery(query.select_notifications, (user,))) | ||
Comment on lines
-177
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
@log_operation | ||
def delete_notifications(self, user): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,10 +45,7 @@ def remove_peer(self, peer, nick=None): | |
for c in self.channels.values(): | ||
c.unregister_user(nick) | ||
elif isinstance(peer, ChatServer): | ||
nicks = [] | ||
for k, v in self.user2peer.items(): | ||
if v == peer: | ||
nicks.append(k) | ||
nicks = [k for k, v in self.user2peer.items() if v == peer] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self.server_peers.remove(peer) | ||
for n in nicks: | ||
self.user2peer.pop(n, None) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,7 +490,6 @@ def msg_JOIN(self, message): | |
else: | ||
if self.connected: | ||
self.endpoint.no_channel(channel_name) | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
except failure.Failure: | ||
self.endpoint.internal_error('DB error, please try again.') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,9 +94,8 @@ def __init__(self, app, parent=None): | |
def send_message(self): | ||
message = self.ui.plainTextEdit.toPlainText() | ||
self.ui.textBrowser.append(message) | ||
if message.strip(" ") != "": | ||
if self.client: | ||
self.client.handle_input(message.strip(" ")) | ||
if message.strip(" ") != "" and self.client: | ||
self.client.handle_input(message.strip(" ")) | ||
Comment on lines
-97
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self.ui.plainTextEdit.clear() | ||
|
||
def quit_channel(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ | |
|
||
def connect_db(): | ||
"""Connects to the specific database.""" | ||
conn = sqlite3.connect(app.config['DATABASE']) | ||
return conn | ||
return sqlite3.connect(app.config['DATABASE']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def init_db(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ def extract_ratings(rows): | |
|
||
# extracts all channels from records and returns list | ||
def extract_channels(rows): | ||
return list(set([row[1] for row in rows])) | ||
return list({row[1] for row in rows}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
@app.route('/', methods=['GET', 'POST']) | ||
|
@@ -69,8 +69,8 @@ def history(): | |
ratings_list = extract_ratings(rows) | ||
channels_list = extract_channels(rows) | ||
|
||
for i in range(0, len(ratings_list)): | ||
for j in range(0, 6): | ||
for i in range(len(ratings_list)): | ||
for j in range(6): | ||
Comment on lines
-72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
if ratings_list[i][j] < 0.5: | ||
ratings_list[i][j] = 0 | ||
|
@@ -95,8 +95,8 @@ def channel(name): | |
ratings_list = extract_ratings(rows) | ||
channels_list = [name] | ||
|
||
for i in range(0, len(ratings_list)): | ||
for j in range(0, 6): | ||
for i in range(len(ratings_list)): | ||
for j in range(6): | ||
Comment on lines
-98
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
if ratings_list[i][j] < 0.5: | ||
ratings_list[i][j] = 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
DBService.password_correct
refactored with the following changes:remove-unnecessary-else
)