From b2ced96ba4e0404e2da5ed2885c1ed9b047ac1b1 Mon Sep 17 00:00:00 2001 From: Lartza Date: Tue, 10 Mar 2020 22:22:20 +0200 Subject: [PATCH 1/3] PEP8 --- command.py | 81 +++++++++++++++++++++++--------------- constants.py | 2 + database.py | 17 ++++---- interface.py | 41 +++++++++++-------- librb/radiobrowser.py | 12 ++++-- librb/rbRadios.py | 1 - media/cache.py | 11 +++--- media/file.py | 16 +++++--- media/item.py | 12 ++++-- media/playlist.py | 10 ++--- media/radio.py | 12 ++++-- media/url.py | 17 ++++---- media/url_from_playlist.py | 14 ++++--- mumbleBot.py | 35 +++++++--------- util.py | 6 ++- 15 files changed, 166 insertions(+), 121 deletions(-) diff --git a/command.py b/command.py index e8e32b4..9799884 100644 --- a/command.py +++ b/command.py @@ -19,6 +19,7 @@ from media.radio import RadioItem log = logging.getLogger("bot") + def register_all_commands(bot): bot.register_command(constants.commands('joinme'), cmd_joinme, no_partial_match=False, access_outside_channel=True) bot.register_command(constants.commands('user_ban'), cmd_user_ban, no_partial_match=True) @@ -71,6 +72,7 @@ def register_all_commands(bot): bot.register_command('loop', cmd_loop_state, True) bot.register_command('item', cmd_item, True) + def send_multi_lines(bot, lines, text, linebreak="
"): global log @@ -79,19 +81,20 @@ def send_multi_lines(bot, lines, text, linebreak="
"): for newline in lines: msg += br br = linebreak - if (len(msg) + len(newline)) > (bot.mumble.get_max_message_length() - 4) != 0: # 4 == len("
") + if (len(msg) + len(newline)) > (bot.mumble.get_max_message_length() - 4) != 0: # 4 == len("
") bot.send_msg(msg, text) msg = "" msg += newline bot.send_msg(msg, text) + # ---------------- Variables ----------------- song_shortlist = [] -# ---------------- Commands ------------------ +# ---------------- Commands ------------------ def cmd_joinme(bot, user, text, command, parameter): global log @@ -146,6 +149,7 @@ def cmd_url_ban(bot, user, text, command, parameter): bot.mumble.users[text.actor].send_text_message(constants.strings('not_admin')) return + def cmd_url_ban_list(bot, user, text, command, parameter): if bot.is_admin(user): bot.mumble.users[text.actor].send_text_message(util.get_url_ban()) @@ -153,6 +157,7 @@ def cmd_url_ban_list(bot, user, text, command, parameter): bot.mumble.users[text.actor].send_text_message(constants.strings('not_admin')) return + def cmd_url_unban(bot, user, text, command, parameter): global log @@ -170,9 +175,11 @@ def cmd_play(bot, user, text, command, parameter): if len(var.playlist) > 0: if parameter: if parameter.isdigit() and 1 <= int(parameter) <= len(var.playlist): - var.playlist.point_to(int(parameter) - 1 - 1) # First "-1" transfer 12345 to 01234, second "-1" - # point to the previous item. the loop will next to - # the one you want + # First "-1" transfer 12345 to 01234, second "-1" + # point to the previous item. the loop will next to + # the one you want + var.playlist.point_to(int(parameter) - 1 - 1) + bot.interrupt() else: bot.send_msg(constants.strings('invalid_index', index=parameter), text) @@ -241,7 +248,7 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals else: # try to do a partial match files = var.cache.files - matches = [ file for file in files if parameter.lower() in file.lower()] + matches = [file for file in files if parameter.lower() in file.lower()] if len(matches) == 1: file = matches[0] music_wrapper = get_cached_wrapper_by_id(bot, var.cache.file_id_lookup[file], user) @@ -250,7 +257,7 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals bot.send_msg(constants.strings('file_added', item=music_wrapper.format_song_string())) return elif len(matches) > 1: - msgs = [ constants.strings('multiple_matches') ] + msgs = [constants.strings('multiple_matches')] song_shortlist = [] for index, match in enumerate(matches): id = var.cache.file_id_lookup[match] @@ -277,7 +284,7 @@ def cmd_play_file_match(bot, user, text, command, parameter, do_not_refresh_cach music_folder = var.music_folder if parameter: files = var.cache.files - msgs = [ constants.strings('multiple_file_added') + "