Skip to content

Commit 32144cc

Browse files
authored
Merge pull request #38 from smarbal/main
Updated requirements.txt and f-strings
2 parents 97df993 + 2326b63 commit 32144cc

File tree

14 files changed

+59
-59
lines changed

14 files changed

+59
-59
lines changed

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
peewee
2-
prompt_toolkit>=3.0.32
1+
peewee>=3.17.6
2+
prompt_toolkit>=3.0.47
33
requests
4-
tinyscript>=1.28.6
4+
tinyscript>=1.30.15

src/sploitkit/base/commands/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def run(self, text):
5555
t = BorderlessTable(data, "Matching modules")
5656
print_formatted_text(t.table)
5757
n = len(data) - 2
58-
self.logger.info("{} match{} found".format(n, ["", "es"][n > 0]))
58+
self.logger.info(f"{n} match{['', 'es'][n > 0]} found")
5959

6060

6161
class Show(Command):

src/sploitkit/base/commands/project.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ class Archive(ProjectRootCommand):
4545
def run(self, project):
4646
projpath = Path(self.workspace).joinpath(project)
4747
folder = ProjectPath(projpath)
48-
self.logger.debug("Archiving project '{}'...".format(project))
48+
self.logger.debug(f"Archiving project '{project}'...")
4949
ask = self.console.config.option("ENCRYPT_PROJECT").value
5050
try:
5151
folder.archive(ask=ask)
52-
self.logger.success("'{}' archived".format(project))
52+
self.logger.success(f"'{project}' archived")
5353
except OSError as e:
54-
logger.error(str(e))
55-
self.logger.failure("'{}' not archived".format(project))
54+
self.logger.error(str(e))
55+
self.logger.failure(f"'{project}' not archived")
5656

5757

5858
class Delete(ProjectRootCommand):
5959
""" Delete a project """
6060
def run(self, project):
61-
self.logger.debug("Deleting project '{}'...".format(project))
61+
self.logger.debug(f"Deleting project '{project}'...")
6262
self.workspace.joinpath(project).remove()
63-
self.logger.success("'{}' deleted".format(project))
63+
self.logger.success(f"'{project}' deleted")
6464

6565

6666
class Load(ProjectRootCommand):
@@ -70,16 +70,16 @@ def complete_values(self):
7070
return [x.stem for x in self.workspace.iterfiles(".zip")]
7171

7272
def run(self, project):
73-
self.logger.debug("Loading archive '{}'...".format(project + ".zip"))
73+
self.logger.debug(f"Loading archive '{project}.zip'...")
7474
projpath = Path(self.workspace).joinpath(project)
7575
archive = ProjectPath(projpath.with_suffix(".zip"))
7676
ask = self.console.config.option("ENCRYPT_PROJECT").value
7777
try:
7878
archive.load(ask=ask)
79-
self.logger.success("'{}' loaded".format(project))
79+
self.logger.success(f"'{project}' loaded")
8080
except Exception as e:
81-
logger.error("Bad password" if "error -3" in str(e) else str(e))
82-
self.logger.failure("'{}' not loaded".format(project))
81+
self.logger.error("Bad password" if "error -3" in str(e) else str(e))
82+
self.logger.failure(f"'{project}' not loaded")
8383

8484
def validate(self, project):
8585
if project not in self.complete_values():
@@ -100,9 +100,9 @@ def run(self, project):
100100
"do you want to load the archive instead ?"):
101101
loader.run(project)
102102
if not p.exists():
103-
self.logger.debug("Creating project '{}'...".format(project))
103+
self.logger.debug(f"Creating project '{project}'...")
104104
p.mkdir()
105-
self.logger.success("'{}' created".format(project))
105+
self.logger.success(f"'{project}' created")
106106
ProjectConsole(self.console, project).start()
107107
self.config['WORKSPACE'] = str(Path(self.config['WORKSPACE']).parent)
108108

src/sploitkit/base/commands/recording.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RecordStatus(Command):
1414
values = ["status"]
1515

1616
def run(self, status):
17-
self.logger.info("Recording is {}".format(["disabled", "enabled"][self.recorder.enabled]))
17+
self.logger.info(f"Recording is {['disabled', 'enabled'][self.recorder.enabled]}")
1818

1919

2020
# ------------------------------ ROOT-LEVEL COMMANDS ---------------------------
@@ -38,7 +38,7 @@ def run(self, key, rcfile=None):
3838
elif key == "stop":
3939
self.recorder.stop()
4040
elif key == "status":
41-
self.logger.info("Recording is {}".format(["disabled", "enabled"][self.recorder.enabled]))
41+
self.logger.info(f"Recording is {['disabled', 'enabled'][self.recorder.enabled]}")
4242

4343
def validate(self, key, rcfile=None):
4444
if key == "start":
@@ -57,6 +57,6 @@ def complete_values(self, key=None):
5757
return [x.name for x in Path(self.workspace).iterfiles(".rc")]
5858

5959
def run(self, rcfile):
60-
self.logger.debug("Replaying commands from file '{}'...".format(rcfile))
60+
self.logger.debug(f"Replaying commands from file '{rcfile}'...")
6161
self.console.replay(rcfile)
6262

src/sploitkit/base/commands/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class State(DebugCommand):
121121
""" Display console's shared state """
122122
def run(self):
123123
for k, v in self.console.state.items():
124-
print_formatted_text("\n{}:".format(k))
124+
print_formatted_text(f"\n{k}:")
125125
v = v or ""
126126
if len(v) == 0:
127127
continue

src/sploitkit/base/models/organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Meta:
2323

2424
@property
2525
def fullname(self):
26-
return "{} {} ({})".format(self.firstname, self.lastname, self.role)
26+
return f"{self.firstname} {self.lastname} ({self.role})"
2727

2828

2929
class EmployeeUnit(BaseModel):

src/sploitkit/core/command.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, *args):
5151
s += " ["
5252
i = []
5353
for a, d in zip(args[len(args)-len(defs):], defs):
54-
i.append("{}={}".format(a, d) if d is not None else a)
54+
i.append(f"{a}={d}" if d is not None else a)
5555
s += " ".join(i) + "]"
5656
self.signature = s
5757
self.args, self.defaults = args, defs
@@ -182,7 +182,7 @@ def get_help(cls, *levels, **kwargs):
182182
continue
183183
d.append([n, getattr(c, "description", "")])
184184
if len(d) > 1:
185-
t = BorderlessTable(d, "{} commands".format(l.capitalize()))
185+
t = BorderlessTable(d, f"{l.capitalize()} commands")
186186
s += t.table + "\n"
187187
i += 1
188188
return "\n" + s.strip() + "\n" if i > 0 else ""
@@ -200,13 +200,13 @@ def register_command(cls, subcls):
200200
Command.commands[l][subcls.name] = subcls
201201
for alias in subcls.aliases:
202202
Command.commands[l][alias] = subcls
203-
logger.detail("Registered command alias '{}'".format(alias))
203+
logger.detail(f"Registered command alias '{alias}'")
204204

205205
@classmethod
206206
def set_style(cls, style):
207207
""" Set the style of command name. """
208208
if style not in COMMAND_STYLES:
209-
raise ValueError("Command style must be one of the followings: [{}]".format("|".join(COMMAND_STYLES)))
209+
raise ValueError(f"Command style must be one of the followings: [{'|'.join(COMMAND_STYLES)}]")
210210
MetaCommand.style = style
211211

212212
@classmethod
@@ -234,7 +234,7 @@ def unregister_command(cls, subcls):
234234
for l in levels:
235235
if len(Command.commands[l]) == 0:
236236
del Command.commands[l]
237-
logger.detail("Unregistered command '{}/{}'".format(l, n))
237+
logger.detail(f"Unregistered command '{l}/{n}'")
238238

239239
@classmethod
240240
def unregister_commands(cls, *identifiers):
@@ -248,7 +248,7 @@ def unregister_commands(cls, *identifiers):
248248
# apply deletions
249249
if n is None:
250250
if f not in cls._functionalities:
251-
raise ValueError("Unknown functionality {}".format(f))
251+
raise ValueError(f"Unknown functionality {f}")
252252
p = Path(__file__).parent.joinpath("../base/commands/" + f + ".py").resolve()
253253
for c in PythonPath(str(p)).get_classes(Command):
254254
Command.unregister_command(c)

src/sploitkit/core/components/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get(self, locator, *args, **kwargs):
7272
with open(path, 'rb') as f:
7373
self[locator] = f.read()
7474
else:
75-
raise ValueError("Unsupported scheme '{}'".format(scheme))
75+
raise ValueError(f"Unsupported scheme '{scheme}'")
7676

7777
def page(self, *filenames):
7878
""" Page a list of files using Less. """

src/sploitkit/core/components/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def snapshot(self, save=True):
118118
self.close()
119119
if save:
120120
self._last_snapshot += 1
121-
s = "{}.snapshot{}".format(self.path, self._last_snapshot)
121+
s = f"{self.path}.snapshot{self._last_snapshot}"
122122
from shutil import copy
123123
copy(self.path, s) if save else copy(s, self.path)
124124
if not save:

src/sploitkit/core/components/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def validate(self, document):
3030
try:
3131
c._validate(*tokens[1:])
3232
except Exception as e:
33-
m = "Command syntax: %s{}" % c.signature.format(cmd)
33+
m = f"Command syntax: {c.signature.format(cmd)}"
3434
e = str(e)
3535
if not e.startswith("validate() "):
3636
m = m.format([" (" + e + ")", ""][len(e) == 0])

0 commit comments

Comments
 (0)