fix whitespaces according to flake8

This commit is contained in:
Semjon Kerner 2021-05-09 11:09:26 +02:00
parent 3172b30d98
commit 1c5530dca4
16 changed files with 52 additions and 54 deletions

View File

@ -43,8 +43,8 @@ def initialize(window_to_hide):
try: try:
if helper.upgrade_avail() and not config.get("dont_ask_update", False): if helper.upgrade_avail() and not config.get("dont_ask_update", False):
cv,hv = helper.versions() cv, hv = helper.versions()
update_now, dont_ask_update = update_dialog.start(cv,hv) update_now, dont_ask_update = update_dialog.start(cv, hv)
if dont_ask_update: if dont_ask_update:
config.set("dont_ask_update", dont_ask_update) config.set("dont_ask_update", dont_ask_update)
else: else:

View File

@ -114,4 +114,3 @@ class Calibrator:
def calibrate(self): def calibrate(self):
self._walk_calibrate() self._walk_calibrate()
self._rotate_calibrate() self._rotate_calibrate()

View File

@ -68,4 +68,3 @@ class Recorder:
pickle.dump(data, file) pickle.dump(data, file)
file.close() file.close()
FullAuto.state = State.NONE FullAuto.state = State.NONE

View File

@ -92,4 +92,3 @@ if __name__ == '__main__':
# noinspection PyTypeChecker # noinspection PyTypeChecker
fisher = SemiFisherEngine(None) fisher = SemiFisherEngine(None)
fisher.toggle_start() fisher.toggle_start()

View File

@ -30,15 +30,15 @@ class FishEvent:
# initialize these # initialize these
action_key = 'e' action_key = 'e'
collect_key = 'r' collect_key = 'r'
sound = False 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 reaction = 0.0
if FishEvent.jitter and upper_limit_ms > lower_limit_ms: if FishEvent.jitter and upper_limit_ms > lower_limit_ms:
reaction = float( random.randrange(lower_limit_ms, upper_limit_ms) )/1000.0 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 max_wait_t = waittime + reaction if waittime + reaction <= 2.5 else 2.5
time.sleep(max_wait_t) time.sleep(max_wait_t)

View File

@ -16,6 +16,7 @@ class State(Enum):
FIGHT = 14 FIGHT = 14
DEAD = 15 DEAD = 15
Colors = { Colors = {
State.IDLE : [255, 255, 255], State.IDLE : [255, 255, 255],
State.LOOKAWAY : [ 76, 0, 76], State.LOOKAWAY : [ 76, 0, 76],

View File

@ -62,7 +62,7 @@ def start_semifisher_config(gui: 'GUI'):
gui._notify.set(1) gui._notify.set(1)
def del_entry_key(event): def del_entry_key(event):
event.widget.delete(0,"end") event.widget.delete(0, "end")
event.widget.insert(0, str(event.char)) event.widget.insert(0, str(event.char))
top = PopUp(save, gui._root, background=gui._root["background"]) top = PopUp(save, gui._root, background=gui._root["background"])

View File

@ -114,7 +114,7 @@ def _create(gui: 'GUI'):
gui._config_button.pack(side=tk.RIGHT) gui._config_button.pack(side=tk.RIGHT)
gui._start_button = ttk.Button(start_frame, text=gui._get_start_stop_text(), width=25, 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) gui._start_button.pack(side=tk.RIGHT)
start_frame.pack(padx=(10, 10), pady=(5, 15), fill=tk.X) start_frame.pack(padx=(10, 10), pady=(5, 15), fill=tk.X)

View File

@ -9,7 +9,7 @@ from fishy.helper.config import config
def show(win_loc): def show(win_loc):
dim=(300,200) dim = (300, 200)
top = tk.Tk() top = tk.Tk()
top.overrideredirect(True) top.overrideredirect(True)
@ -27,9 +27,9 @@ def show(win_loc):
# Position splash at the center of the main window # 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:] 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() top.update()
time.sleep(3) time.sleep(3)

View File

@ -8,7 +8,7 @@ from PIL import Image, ImageTk
from fishy import helper, web from fishy import helper, web
from fishy.helper.config import config from fishy.helper.config import config
hyperlinkPattern = re.compile(r'\[(?P<title>.*?)\]\((?P<address>.*?)\)') hyperlinkPattern = re.compile(r'\[(?P<title>.*?)\]\((?P<address>.*?)\)')
def check_eula(): def check_eula():
@ -45,7 +45,7 @@ def _run_terms_window():
g1 = ttk.Frame(f) g1 = ttk.Frame(f)
ttk.Checkbutton(g1, command=disable_enable_button, variable=check_value).pack(side=tk.LEFT) 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)), 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"] text["background"] = root["background"]
_format_hyper_link(text, message) _format_hyper_link(text, message)
@ -57,10 +57,10 @@ def _run_terms_window():
g2 = ttk.Frame(f) g2 = ttk.Frame(f)
accept_button = ttk.Button(g2, text="Accept", accept_button = ttk.Button(g2, text="Accept",
command=accept) command=accept)
accept_button.grid(row=0, column=0) accept_button.grid(row=0, column=0)
ttk.Button(g2, text="Deny", 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)) g2.pack(pady=(5, 0))
disable_enable_button() disable_enable_button()

View File

@ -9,27 +9,27 @@ def show(currentversion, newversion, returns):
top.title("A wild fishy update appeared!") top.title("A wild fishy update appeared!")
top.iconbitmap(helper.manifest_file('icon.ico')) 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) dialogLabel.grid(row=0, columnspan=2, padx=5, pady=5)
cbVar = tk.IntVar() cbVar = tk.IntVar()
dialogCheckbutton = tk.Checkbutton(top, text="don't ask again", variable=cbVar) dialogCheckbutton = tk.Checkbutton(top, text="don't ask again", variable=cbVar)
dialogCheckbutton.grid(row=1, columnspan=2, padx=5, pady=0) dialogCheckbutton.grid(row=1, columnspan=2, padx=5, pady=0)
top.update() top.update()
buttonWidth = int(dialogLabel.winfo_width()/2)-20 buttonWidth = int(dialogLabel.winfo_width() / 2) - 20
def _clickYes(): def _clickYes():
returns[0],returns[1]=True, False returns[0], returns[1] = True, False
top.destroy() top.destroy()
def _clickNo(): def _clickNo():
returns[0],returns[1]=False, bool(cbVar.get()) returns[0], returns[1] = False, bool(cbVar.get())
top.destroy() top.destroy()
pixelVirtual = tk.PhotoImage(width=1, height=1) # trick to use buttonWidth as pixels, not #symbols 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 = 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) 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.grid(row=2, column=1, padx=5, pady=5)
dialogBtnYes.focus_set() dialogBtnYes.focus_set()

View File

@ -76,6 +76,7 @@ def _get_current_version():
index = "https://pypi.python.org/simple" index = "https://pypi.python.org/simple"
pkg = "fishy" pkg = "fishy"
def versions(): def versions():
return _hr_version(_get_current_version()), _hr_version(_get_highest_version(index, pkg)) return _hr_version(_get_current_version()), _hr_version(_get_highest_version(index, pkg))

View File

@ -28,7 +28,7 @@ def playsound_multiple(path, count=2):
return return
def _ps_m(): def _ps_m():
for i in range(count-1): for i in range(count - 1):
playsound(path, True) playsound(path, True)
playsound(path, False) playsound(path, False)
@ -194,21 +194,21 @@ def install_addon(name, url, v=None):
r = requests.get(url, stream=True) r = requests.get(url, stream=True)
z = ZipFile(BytesIO(r.content)) z = ZipFile(BytesIO(r.content))
z.extractall(path=get_addondir()) 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 return 0
except Exception as ex: 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 return 1
def remove_addon(name, url=None, v=None): def remove_addon(name, url=None, v=None):
try: try:
shutil.rmtree(os.path.join(get_addondir(), name)) shutil.rmtree(os.path.join(get_addondir(), name))
logging.info("Add-On "+name+" removed!") logging.info("Add-On " + name + " removed!")
except FileNotFoundError: except FileNotFoundError:
pass pass
except PermissionError as ex: 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 1
return 0 return 0

View File

@ -18,7 +18,7 @@ def _sv_parser(path):
- remove empty expressions - remove empty expressions
EXPRESSIONS: A) List-Start "name=", B) Variable assignment "name=val", C) List End "}" 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.replace(old, new)
lua = lua.lower().split("\n") lua = lua.lower().split("\n")
lua = [expression for expression in lua if expression] 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) the last symbol of each line decides the type of the node (branch vertex or leaf)
""" """
stack = [] stack = []
root = (dict(),"root") root = (dict(), "root")
stack.append(root) stack.append(root)
for line in lua: for line in lua:
if line == "": if line == "":
break break
if line[-1] == '=': #subtree start if line[-1] == '=': #subtree start
t = dict() t = dict()
tname = line.split("=")[0] tname = line.split("=")[0]
stack.append((t,tname)) stack.append((t, tname))
elif line[-1] == '}': #subtree end elif line[-1] == '}': #subtree end
t = stack.pop() t = stack.pop()
tp = stack.pop() tp = stack.pop()
tp[0][t[1]] = t[0] tp[0][t[1]] = t[0]
stack.append(tp) stack.append(tp)
else: #new element in tree else: #new element in tree
name,val = line.split("=") name, val = line.split("=")
t = stack.pop() t = stack.pop()
t[0][name] = val t[0][name] = val
stack.append(t) stack.append(t)
@ -68,13 +68,12 @@ def sv_color_extract(Colors):
ingame representation of colors range from 0 to 1 in float ingame representation of colors range from 0 to 1 in float
these values are scaled by 255 these values are scaled by 255
""" """
rgb=[ rgb = [
floor(float(root["colors"][i]["r"])*255), floor(float(root["colors"][i]["r"]) * 255),
floor(float(root["colors"][i]["g"])*255), floor(float(root["colors"][i]["g"]) * 255),
floor(float(root["colors"][i]["b"])*255) floor(float(root["colors"][i]["b"]) * 255)
] ]
colors.append(rgb) colors.append(rgb)
for i,c in enumerate(Colors): for i, c in enumerate(Colors):
Colors[c] = colors[i] Colors[c] = colors[i]
return Colors return Colors

View File

@ -17,7 +17,7 @@ def is_logged_in():
if config.get("uid") is None: if config.get("uid") is None:
return -1 return -1
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.get(urls.discord, params=body) response = requests.get(urls.discord, params=body)
logged_in = response.json()["discord_login"] logged_in = response.json()["discord_login"]
return 1 if logged_in else 0 return 1 if logged_in else 0
@ -25,7 +25,7 @@ def is_logged_in():
@fallback(False) @fallback(False)
def login(uid, login_code): 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) reponse = requests.post(urls.discord, json=body)
result = reponse.json() result = reponse.json()
@ -37,7 +37,7 @@ def login(uid, login_code):
@fallback(False) @fallback(False)
def logout(): def logout():
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
reponse = requests.delete(urls.discord, json=body) reponse = requests.delete(urls.discord, json=body)
result = reponse.json() result = reponse.json()
return result["success"] return result["success"]
@ -57,7 +57,7 @@ def send_notification(message):
if not is_subbed()[0]: if not is_subbed()[0]:
return False 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) requests.post(urls.notify, json=body)
@ -71,13 +71,13 @@ def send_fish_caught(fish_caught, hole_time, fish_times):
"session": get_session() "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) requests.post(urls.hole_depleted, json=body)
@fallback(False) @fallback(False)
def sub(): def sub():
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.post(urls.subscription, json=body) response = requests.post(urls.subscription, json=body)
result = response.json() result = response.json()
return result["success"] return result["success"]
@ -94,7 +94,7 @@ def is_subbed():
if config.get("uid") is None: if config.get("uid") is None:
return False, False return False, False
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.get(urls.subscription, params=body) response = requests.get(urls.subscription, params=body)
if response.status_code != 200: if response.status_code != 200:
@ -106,7 +106,7 @@ def is_subbed():
@fallback(None) @fallback(None)
def unsub(): def unsub():
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.delete(urls.subscription, json=body) response = requests.delete(urls.subscription, json=body)
result = response.json() result = response.json()
return result["success"] return result["success"]
@ -119,7 +119,7 @@ def get_session(lazy=True):
if lazy and _session_id is not None: if lazy and _session_id is not None:
return _session_id return _session_id
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.post(urls.session, params=body) response = requests.post(urls.session, params=body)
if response.status_code == 405: if response.status_code == 405:
@ -133,7 +133,7 @@ def get_session(lazy=True):
@fallback(False) @fallback(False)
def has_beta(): def has_beta():
body = {"uid": config.get("uid"), "apiversion":apiversion} body = {"uid": config.get("uid"), "apiversion": apiversion}
response = requests.get(urls.beta, params=body) response = requests.get(urls.beta, params=body)
result = response.json() result = response.json()

View File

@ -213,4 +213,4 @@ setup(
}, },
include_package_data=True include_package_data=True
) )