From 1c5530dca46535db7912e8466571411bcdf535ac Mon Sep 17 00:00:00 2001 From: Semjon Kerner Date: Sun, 9 May 2021 11:09:26 +0200 Subject: [PATCH] fix whitespaces according to flake8 --- fishy/__main__.py | 4 ++-- fishy/engine/fullautofisher/calibrator.py | 1 - fishy/engine/fullautofisher/recorder.py | 1 - fishy/engine/semifisher/engine.py | 1 - fishy/engine/semifisher/fishing_event.py | 8 ++++---- fishy/engine/semifisher/fishing_mode.py | 1 + fishy/gui/config_top.py | 2 +- fishy/gui/main_gui.py | 2 +- fishy/gui/splash.py | 6 +++--- fishy/gui/terms_gui.py | 8 ++++---- fishy/gui/update_dialog.py | 14 ++++++------- fishy/helper/auto_update.py | 1 + fishy/helper/helper.py | 10 ++++----- fishy/helper/luaparser.py | 25 +++++++++++------------ fishy/web/web.py | 20 +++++++++--------- setup.py | 2 +- 16 files changed, 52 insertions(+), 54 deletions(-) diff --git a/fishy/__main__.py b/fishy/__main__.py index 1159945..738bf9a 100644 --- a/fishy/__main__.py +++ b/fishy/__main__.py @@ -43,8 +43,8 @@ def initialize(window_to_hide): try: if helper.upgrade_avail() and not config.get("dont_ask_update", False): - cv,hv = helper.versions() - update_now, dont_ask_update = update_dialog.start(cv,hv) + cv, hv = helper.versions() + update_now, dont_ask_update = update_dialog.start(cv, hv) if dont_ask_update: config.set("dont_ask_update", dont_ask_update) else: diff --git a/fishy/engine/fullautofisher/calibrator.py b/fishy/engine/fullautofisher/calibrator.py index c09025a..87a0a5a 100644 --- a/fishy/engine/fullautofisher/calibrator.py +++ b/fishy/engine/fullautofisher/calibrator.py @@ -114,4 +114,3 @@ class Calibrator: def calibrate(self): self._walk_calibrate() self._rotate_calibrate() - diff --git a/fishy/engine/fullautofisher/recorder.py b/fishy/engine/fullautofisher/recorder.py index 6bf8471..b4b614b 100644 --- a/fishy/engine/fullautofisher/recorder.py +++ b/fishy/engine/fullautofisher/recorder.py @@ -68,4 +68,3 @@ class Recorder: pickle.dump(data, file) file.close() FullAuto.state = State.NONE - diff --git a/fishy/engine/semifisher/engine.py b/fishy/engine/semifisher/engine.py index 4c0a2f6..29ee8f7 100644 --- a/fishy/engine/semifisher/engine.py +++ b/fishy/engine/semifisher/engine.py @@ -92,4 +92,3 @@ if __name__ == '__main__': # noinspection PyTypeChecker fisher = SemiFisherEngine(None) fisher.toggle_start() - diff --git a/fishy/engine/semifisher/fishing_event.py b/fishy/engine/semifisher/fishing_event.py index aaa064c..e028275 100644 --- a/fishy/engine/semifisher/fishing_event.py +++ b/fishy/engine/semifisher/fishing_event.py @@ -30,15 +30,15 @@ class FishEvent: # initialize these action_key = 'e' - collect_key = 'r' + collect_key = 'r' sound = False -def _fishing_sleep(waittime, lower_limit_ms = 16, upper_limit_ms = 2500): +def _fishing_sleep(waittime, lower_limit_ms=16, upper_limit_ms=2500): reaction = 0.0 if FishEvent.jitter and upper_limit_ms > lower_limit_ms: - reaction = float( random.randrange(lower_limit_ms, upper_limit_ms) )/1000.0 - max_wait_t = waittime+reaction if waittime+reaction <= 2.5 else 2.5 + reaction = float(random.randrange(lower_limit_ms, upper_limit_ms)) / 1000.0 + max_wait_t = waittime + reaction if waittime + reaction <= 2.5 else 2.5 time.sleep(max_wait_t) diff --git a/fishy/engine/semifisher/fishing_mode.py b/fishy/engine/semifisher/fishing_mode.py index 9a6c397..bf8a05c 100644 --- a/fishy/engine/semifisher/fishing_mode.py +++ b/fishy/engine/semifisher/fishing_mode.py @@ -16,6 +16,7 @@ class State(Enum): FIGHT = 14 DEAD = 15 + Colors = { State.IDLE : [255, 255, 255], State.LOOKAWAY : [ 76, 0, 76], diff --git a/fishy/gui/config_top.py b/fishy/gui/config_top.py index aba92a0..886ec41 100644 --- a/fishy/gui/config_top.py +++ b/fishy/gui/config_top.py @@ -62,7 +62,7 @@ def start_semifisher_config(gui: 'GUI'): gui._notify.set(1) def del_entry_key(event): - event.widget.delete(0,"end") + event.widget.delete(0, "end") event.widget.insert(0, str(event.char)) top = PopUp(save, gui._root, background=gui._root["background"]) diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index 3cdc1d8..7c74c84 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -114,7 +114,7 @@ def _create(gui: 'GUI'): gui._config_button.pack(side=tk.RIGHT) gui._start_button = ttk.Button(start_frame, text=gui._get_start_stop_text(), width=25, - command=gui.funcs.start_engine) + command=gui.funcs.start_engine) gui._start_button.pack(side=tk.RIGHT) start_frame.pack(padx=(10, 10), pady=(5, 15), fill=tk.X) diff --git a/fishy/gui/splash.py b/fishy/gui/splash.py index 20efe75..f273674 100644 --- a/fishy/gui/splash.py +++ b/fishy/gui/splash.py @@ -9,7 +9,7 @@ from fishy.helper.config import config def show(win_loc): - dim=(300,200) + dim = (300, 200) top = tk.Tk() top.overrideredirect(True) @@ -27,9 +27,9 @@ def show(win_loc): # Position splash at the center of the main window - default_loc = (str(top.winfo_reqwidth())+"+"+str(top.winfo_reqheight())+"+"+"0"+"0") + default_loc = (str(top.winfo_reqwidth()) + "+" + str(top.winfo_reqheight()) + "+" + "0" + "0") loc = (win_loc or default_loc).split("+")[1:] - top.geometry("{}x{}+{}+{}".format(dim[0], dim[1], int(loc[0])+int(dim[0]/2), int(loc[1])+int(dim[1]/2))) + top.geometry("{}x{}+{}+{}".format(dim[0], dim[1], int(loc[0]) + int(dim[0] / 2), int(loc[1]) + int(dim[1] / 2))) top.update() time.sleep(3) diff --git a/fishy/gui/terms_gui.py b/fishy/gui/terms_gui.py index e84bd26..4276f4a 100644 --- a/fishy/gui/terms_gui.py +++ b/fishy/gui/terms_gui.py @@ -8,7 +8,7 @@ from PIL import Image, ImageTk from fishy import helper, web from fishy.helper.config import config -hyperlinkPattern = re.compile(r'\[(?P.*?)\]\((?P<address>.*?)\)') +hyperlinkPattern = re.compile(r'\[(?P<title>.*?)\]\((?P<address>.*?)\)') def check_eula(): @@ -45,7 +45,7 @@ def _run_terms_window(): g1 = ttk.Frame(f) ttk.Checkbutton(g1, command=disable_enable_button, variable=check_value).pack(side=tk.LEFT) text = tk.Text(g1, width=len(hyperlinkPattern.sub(r'\g<title>', message)), - height=1, borderwidth=0, highlightthickness=0) + height=1, borderwidth=0, highlightthickness=0) text["background"] = root["background"] _format_hyper_link(text, message) @@ -57,10 +57,10 @@ def _run_terms_window(): g2 = ttk.Frame(f) accept_button = ttk.Button(g2, text="Accept", - command=accept) + command=accept) accept_button.grid(row=0, column=0) ttk.Button(g2, text="Deny", - command=lambda: root.destroy()).grid(row=0, column=1) + command=lambda: root.destroy()).grid(row=0, column=1) g2.pack(pady=(5, 0)) disable_enable_button() diff --git a/fishy/gui/update_dialog.py b/fishy/gui/update_dialog.py index 105e7f8..9e16ac9 100644 --- a/fishy/gui/update_dialog.py +++ b/fishy/gui/update_dialog.py @@ -9,27 +9,27 @@ def show(currentversion, newversion, returns): top.title("A wild fishy update appeared!") top.iconbitmap(helper.manifest_file('icon.ico')) - dialogLabel = tk.Label(top, text="There is a new fishy update available ("+currentversion+"->"+newversion+"). Do you want to update now?") + dialogLabel = tk.Label(top, text="There is a new fishy update available (" + currentversion + "->" + newversion + "). Do you want to update now?") dialogLabel.grid(row=0, columnspan=2, padx=5, pady=5) cbVar = tk.IntVar() dialogCheckbutton = tk.Checkbutton(top, text="don't ask again", variable=cbVar) dialogCheckbutton.grid(row=1, columnspan=2, padx=5, pady=0) top.update() - buttonWidth = int(dialogLabel.winfo_width()/2)-20 + buttonWidth = int(dialogLabel.winfo_width() / 2) - 20 def _clickYes(): - returns[0],returns[1]=True, False + returns[0], returns[1] = True, False top.destroy() def _clickNo(): - returns[0],returns[1]=False, bool(cbVar.get()) + returns[0], returns[1] = False, bool(cbVar.get()) top.destroy() - pixelVirtual = tk.PhotoImage(width=1, height=1) # trick to use buttonWidth as pixels, not #symbols - dialogBtnNo = tk.Button(top, text="No " + str(chr(10005)), fg='red4', command=_clickNo, image=pixelVirtual, width=buttonWidth, compound="c") + pixelVirtual = tk.PhotoImage(width=1, height=1) # trick to use buttonWidth as pixels, not #symbols + dialogBtnNo = tk.Button(top, text="No " + str(chr(10005)), fg='red4', command=_clickNo, image=pixelVirtual, width=buttonWidth, compound="c") dialogBtnNo.grid(row=2, column=0, padx=5, pady=5) - dialogBtnYes = tk.Button(top, text="Yes " + str(chr(10003)), fg='green', command=_clickYes, image=pixelVirtual, width=buttonWidth, compound="c") + dialogBtnYes = tk.Button(top, text="Yes " + str(chr(10003)), fg='green', command=_clickYes, image=pixelVirtual, width=buttonWidth, compound="c") dialogBtnYes.grid(row=2, column=1, padx=5, pady=5) dialogBtnYes.focus_set() diff --git a/fishy/helper/auto_update.py b/fishy/helper/auto_update.py index 155f984..cc1644e 100644 --- a/fishy/helper/auto_update.py +++ b/fishy/helper/auto_update.py @@ -76,6 +76,7 @@ def _get_current_version(): index = "https://pypi.python.org/simple" pkg = "fishy" + def versions(): return _hr_version(_get_current_version()), _hr_version(_get_highest_version(index, pkg)) diff --git a/fishy/helper/helper.py b/fishy/helper/helper.py index e07bdda..95ba88b 100644 --- a/fishy/helper/helper.py +++ b/fishy/helper/helper.py @@ -28,7 +28,7 @@ def playsound_multiple(path, count=2): return def _ps_m(): - for i in range(count-1): + for i in range(count - 1): playsound(path, True) playsound(path, False) @@ -194,21 +194,21 @@ def install_addon(name, url, v=None): r = requests.get(url, stream=True) z = ZipFile(BytesIO(r.content)) z.extractall(path=get_addondir()) - logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO") + logging.info("Add-On " + name + " installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO") return 0 except Exception as ex: - logging.error("Could not install Add-On "+name+", try doing it manually") + logging.error("Could not install Add-On " + name + ", try doing it manually") return 1 def remove_addon(name, url=None, v=None): try: shutil.rmtree(os.path.join(get_addondir(), name)) - logging.info("Add-On "+name+" removed!") + logging.info("Add-On " + name + " removed!") except FileNotFoundError: pass except PermissionError as ex: - logging.error("Fishy has no permission to remove "+name+" Add-On") + logging.error("Fishy has no permission to remove " + name + " Add-On") return 1 return 0 diff --git a/fishy/helper/luaparser.py b/fishy/helper/luaparser.py index bdc4616..ebebead 100644 --- a/fishy/helper/luaparser.py +++ b/fishy/helper/luaparser.py @@ -18,7 +18,7 @@ def _sv_parser(path): - remove empty expressions EXPRESSIONS: A) List-Start "name=", B) Variable assignment "name=val", C) List End "}" """ - for old, new in ((",","\n"), ("{","{\n"), ("}","}\n"), ("{",""), (",", ""), ("[", ""), ("]", ""), ('"', ""), (" ", "")): + for old, new in ((",", "\n"), ("{", "{\n"), ("}", "}\n"), ("{", ""), (",", ""), ("[", ""), ("]", ""), ('"', ""), (" ", "")): lua = lua.replace(old, new) lua = lua.lower().split("\n") lua = [expression for expression in lua if expression] @@ -29,22 +29,22 @@ def _sv_parser(path): the last symbol of each line decides the type of the node (branch vertex or leaf) """ stack = [] - root = (dict(),"root") + root = (dict(), "root") stack.append(root) for line in lua: if line == "": break - if line[-1] == '=': #subtree start + if line[-1] == '=': #subtree start t = dict() tname = line.split("=")[0] - stack.append((t,tname)) - elif line[-1] == '}': #subtree end + stack.append((t, tname)) + elif line[-1] == '}': #subtree end t = stack.pop() tp = stack.pop() tp[0][t[1]] = t[0] stack.append(tp) - else: #new element in tree - name,val = line.split("=") + else: #new element in tree + name, val = line.split("=") t = stack.pop() t[0][name] = val stack.append(t) @@ -68,13 +68,12 @@ def sv_color_extract(Colors): ingame representation of colors range from 0 to 1 in float these values are scaled by 255 """ - rgb=[ - floor(float(root["colors"][i]["r"])*255), - floor(float(root["colors"][i]["g"])*255), - floor(float(root["colors"][i]["b"])*255) + rgb = [ + floor(float(root["colors"][i]["r"]) * 255), + floor(float(root["colors"][i]["g"]) * 255), + floor(float(root["colors"][i]["b"]) * 255) ] colors.append(rgb) - for i,c in enumerate(Colors): + for i, c in enumerate(Colors): Colors[c] = colors[i] return Colors - diff --git a/fishy/web/web.py b/fishy/web/web.py index 616352e..12ae97a 100644 --- a/fishy/web/web.py +++ b/fishy/web/web.py @@ -17,7 +17,7 @@ def is_logged_in(): if config.get("uid") is None: return -1 - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.get(urls.discord, params=body) logged_in = response.json()["discord_login"] return 1 if logged_in else 0 @@ -25,7 +25,7 @@ def is_logged_in(): @fallback(False) def login(uid, login_code): - body = {"uid": uid, "login_code": login_code, "apiversion":apiversion} + body = {"uid": uid, "login_code": login_code, "apiversion": apiversion} reponse = requests.post(urls.discord, json=body) result = reponse.json() @@ -37,7 +37,7 @@ def login(uid, login_code): @fallback(False) def logout(): - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} reponse = requests.delete(urls.discord, json=body) result = reponse.json() return result["success"] @@ -57,7 +57,7 @@ def send_notification(message): if not is_subbed()[0]: return False - body = {"uid": config.get("uid"), "message": message, "apiversion":apiversion} + body = {"uid": config.get("uid"), "message": message, "apiversion": apiversion} requests.post(urls.notify, json=body) @@ -71,13 +71,13 @@ def send_fish_caught(fish_caught, hole_time, fish_times): "session": get_session() } - body = {"uid": config.get("uid"), "hole_data": hole_data, "apiversion":apiversion} + body = {"uid": config.get("uid"), "hole_data": hole_data, "apiversion": apiversion} requests.post(urls.hole_depleted, json=body) @fallback(False) def sub(): - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.post(urls.subscription, json=body) result = response.json() return result["success"] @@ -94,7 +94,7 @@ def is_subbed(): if config.get("uid") is None: return False, False - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.get(urls.subscription, params=body) if response.status_code != 200: @@ -106,7 +106,7 @@ def is_subbed(): @fallback(None) def unsub(): - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.delete(urls.subscription, json=body) result = response.json() return result["success"] @@ -119,7 +119,7 @@ def get_session(lazy=True): if lazy and _session_id is not None: return _session_id - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.post(urls.session, params=body) if response.status_code == 405: @@ -133,7 +133,7 @@ def get_session(lazy=True): @fallback(False) def has_beta(): - body = {"uid": config.get("uid"), "apiversion":apiversion} + body = {"uid": config.get("uid"), "apiversion": apiversion} response = requests.get(urls.beta, params=body) result = response.json() diff --git a/setup.py b/setup.py index 634467a..13e81b3 100644 --- a/setup.py +++ b/setup.py @@ -213,4 +213,4 @@ setup( }, include_package_data=True -) \ No newline at end of file +)