From 77b8c0f6d1d83eac374abe9e9238ac765690a840 Mon Sep 17 00:00:00 2001 From: jubeaz Date: Sat, 25 May 2024 17:04:08 +0200 Subject: [PATCH] linting --- arsenal/modules/command.py | 10 +++------- arsenal/modules/gui.py | 18 +++--------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/arsenal/modules/command.py b/arsenal/modules/command.py index 11d875c..258f93d 100644 --- a/arsenal/modules/command.py +++ b/arsenal/modules/command.py @@ -44,10 +44,7 @@ def compute_args(self, cheat, gvars): Process cmdline from the cheatsheet to get args names """ self.args = {} - # Use a list of tuples here instead of dict in case - # the cmd has multiple args with the same name.. - position = 0 - for arg_name in re.findall(r'<([^ <>]+)>', cheat.command): + for position, arg_name in enumerate(re.findall(r"<([^ <>]+)>", cheat.command)): if "|" in arg_name: # Format name, var = arg_name.split("|")[:2] self._add_arg(name, var, position) @@ -60,7 +57,6 @@ def compute_args(self, cheat, gvars): self._add_arg(arg_name, cheat.variables[arg_name], position) else: self._add_arg(arg_name, "", position) - position += 1 def _add_arg(self, name=None, value="", position=0): if name in self.args: @@ -86,7 +82,7 @@ def set_arg_value(self, position, value): def get_command_parts(self): if self.nb_place_holder != 0: - regex = '|'.join('<' + arg + '>' for arg in self.args) + regex = "|".join("<" + arg + ">" for arg in self.args) cmdparts = re.split(regex, self.cmdline) else: cmdparts = [self.cmdline] @@ -103,7 +99,7 @@ def build(self): argsval = [a[1] for a in self.args] if "" not in argsval: # split cmdline at each arg position - regex = '|'.join('<' + arg + '>' for arg in self.args) + regex = "|".join("<" + arg + ">" for arg in self.args) cmdparts = re.split(regex, self.cmdline) # concat command parts and arguments values to build the command self.cmdline = "" diff --git a/arsenal/modules/gui.py b/arsenal/modules/gui.py index d06af37..4a9e265 100644 --- a/arsenal/modules/gui.py +++ b/arsenal/modules/gui.py @@ -425,8 +425,7 @@ def get_nb_preview_new_lines(self): firstline = False # extract len of args in the current line - i = 0 - for arg_name, arg_val in Gui.cmd.args.items(): + for i, (arg_name, arg_val) in enumerate(Gui.cmd.args.items()): if i == next_arg and nb_args_todo > 0: if arg_val["value"] != "": # use value len if not empty @@ -436,7 +435,6 @@ def get_nb_preview_new_lines(self): nbchar += (len(arg_name) + 2) next_arg += 1 nb_args_todo -= 1 - i += 1 # len of the cmd body for p in parts: @@ -556,12 +554,7 @@ def draw_cmd_preview(self, argprev, p_x, p_y=1): self.draw_preview_part(argprev, cmdparts[i // 2], curses.color_pair(Gui.BASIC_COLOR)) else: arg_name, arg_value = Gui.cmd.get_arg((i - 1) // 2) - if arg_value == "": - # if arg empty use its name - arg = '<' + arg_name + '>' - else: - # else its value - arg = arg_value + arg = "<" + arg_name + ">" if arg_value == "" else arg_value # draw argument if self.current_arg_name == arg_name: @@ -590,10 +583,6 @@ def draw(self, stdscr): # draw argslist menu popup self.prev_lastline_len = 0 nbpreviewnewlines = self.get_nb_preview_new_lines() - # if len(Gui.cmd.args) != 0: - # nbpreviewnewlines = self.get_nb_preview_new_lines() - # else: - # nbpreviewnewlines = 0 # -------------- border # cmd @@ -664,7 +653,7 @@ def autocomplete_arg(self): """ # current argument value # look for all files that match the argument in the working directory - matches = glob.glob('{}*'.format(self.current_arg_value)) + matches = glob.glob(f"{self.current_arg_value}*") if not matches: return False @@ -791,7 +780,6 @@ class Gui: INFO_DESC_COLOR = 0 INFO_CMD_COLOR = 0 ARG_NAME_COLOR = 5 - loaded_menu = False def __init__(self):