Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Defelo committed Mar 5, 2022
1 parent 368a030 commit 7cbbc73
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 120
ignore = D,E800,F401,F403,F405,I,Q000,RST210,RST213,RST304,WPS,W503
ignore = D,E800,F401,F403,F405,I,N818,Q000,RST210,RST213,RST304,WPS,W503
2 changes: 1 addition & 1 deletion PyCrypCli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def change_password(self, username: str, old_password: str, new_password: str):

self.init()
response: dict = self.request(
{"action": "password", "name": username, "password": old_password, "new": new_password}
{"action": "password", "name": username, "password": old_password, "new": new_password},
)
if "error" in response:
self.close()
Expand Down
17 changes: 14 additions & 3 deletions PyCrypCli/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ def __init__(self, msg: str):

class Command:
def __init__(
self, name: str, func: COMMAND_FUNCTION, description: str, contexts: List[Type[Context]], aliases: List[str]
self,
name: str,
func: COMMAND_FUNCTION,
description: str,
contexts: List[Type[Context]],
aliases: List[str],
):
self.name: str = name
self.func: COMMAND_FUNCTION = func
Expand Down Expand Up @@ -60,7 +65,11 @@ def decorator(func: COMPLETER_FUNCTION) -> COMPLETER_FUNCTION:
return decorator

def subcommand(
self, name: str, *, contexts: List[Type[Context]] = None, aliases: List[str] = None
self,
name: str,
*,
contexts: List[Type[Context]] = None,
aliases: List[str] = None,
) -> Callable[[COMMAND_FUNCTION], "Command"]:
if contexts is None:
contexts = self.contexts
Expand Down Expand Up @@ -90,7 +99,9 @@ def make_subcommands(self):


def command(
name: str, contexts: List[Type[Context]], aliases: List[str] = None
name: str,
contexts: List[Type[Context]],
aliases: List[str] = None,
) -> Callable[[COMMAND_FUNCTION], Command]:
def decorator(func: COMMAND_FUNCTION) -> Command:
if func.__doc__ is None:
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/commands/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_device(context: MainContext, name_or_uuid: str, devices: Optional[List[D
raise CommandError(f"There is no device with the name '{name_or_uuid}'.")
if len(found_devices) > 1:
raise CommandError(
f"There is more than one device with the name '{name_or_uuid}'. You need to specify its UUID."
f"There is more than one device with the name '{name_or_uuid}'. You need to specify its UUID.",
)
return found_devices[0]

Expand Down
5 changes: 4 additions & 1 deletion PyCrypCli/commands/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def handle_rm(context: DeviceContext, args: List[str]):


def check_file_movable(
context: DeviceContext, source: str, destination: str, move: bool
context: DeviceContext,
source: str,
destination: str,
move: bool,
) -> Optional[Tuple[File, str, str]]:
file: Optional[File] = context.path_to_file(source)
if file is None:
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/commands/morphcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def handle_pay(context: DeviceContext, args: List[str]):

if len(args) < 3:
raise CommandError(
"usage: pay <filename> <receiver> <amount> [usage]\n" " or: pay <uuid> <key> <receiver> <amount> [usage]"
"usage: pay <filename> <receiver> <amount> [usage]\n" " or: pay <uuid> <key> <receiver> <amount> [usage]",
)

if extract_wallet(f"{args[0]} {args[1]}") is not None:
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/commands/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def handle_bruteforce(context: DeviceContext, args: List[str]):
else:
raise CommandError(
"usage: service bruteforce <target-device> <target-service> [duration]\n"
" service bruteforce ssh|telnet [duration]"
" service bruteforce ssh|telnet [duration]",
)

if isinstance(duration, str):
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/commands/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def handle_shop_list(context: DeviceContext, _):
for category in categories
for subcategory in category.subcategories
for item in subcategory.items
]
],
)
tree = []
for category in categories:
Expand Down
7 changes: 6 additions & 1 deletion PyCrypCli/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def update_presence(
return
try:
self.root_context.presence.update(
state=state, details=details, start=start, end=end, large_image=large_image, large_text=large_text
state=state,
details=details,
start=start,
end=end,
large_image=large_image,
large_text=large_text,
)
except PyPresenceException:
pass
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/context/main_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ def extract_wallet(self, content: str) -> Wallet:

def get_hacked_devices(self) -> List[Device]:
return list(
{Device.get_device(self.client, service.device) for service in Service.list_part_owner(self.client)}
{Device.get_device(self.client, service.device) for service in Service.list_part_owner(self.client)},
)
4 changes: 2 additions & 2 deletions PyCrypCli/game_objects/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def move(self, new_filename: str, new_parent_dir_uuid: str):
file_uuid=self.uuid,
new_filename=new_filename,
new_parent_dir_uuid=new_parent_dir_uuid,
)
),
)

def edit(self, new_content: str):
Expand All @@ -54,7 +54,7 @@ def edit(self, new_content: str):
device_uuid=self.device,
file_uuid=self.uuid,
content=new_content,
)
),
)

def delete(self):
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/game_objects/service/bruteforce_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def progress(self) -> Optional[float]:
@staticmethod
def get_bruteforce_service(client: Client, device_uuid: str) -> "BruteforceService":
service: BruteforceService = Service.get_service_by_name(client, device_uuid, "bruteforce").clone(
BruteforceService
BruteforceService,
)
service._update(service.get_bruteforce_details())
return service
Expand Down
3 changes: 2 additions & 1 deletion PyCrypCli/game_objects/service/public_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def running_port(self) -> int:
@staticmethod
def get_public_service(client: Client, device_uuid: str, service_uuid: str) -> "PublicService":
return PublicService(
client, client.ms("service", ["public_info"], device_uuid=device_uuid, service_uuid=service_uuid)
client,
client.ms("service", ["public_info"], device_uuid=device_uuid, service_uuid=service_uuid),
)

def update(self):
Expand Down
3 changes: 2 additions & 1 deletion PyCrypCli/game_objects/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def get_services(client: Client, device_uuid: str) -> List["Service"]:
@staticmethod
def get_service(client: Client, device_uuid: str, service_uuid: str) -> "Service":
return Service(
client, client.ms("service", ["private_info"], device_uuid=device_uuid, service_uuid=service_uuid)
client,
client.ms("service", ["private_info"], device_uuid=device_uuid, service_uuid=service_uuid),
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion PyCrypCli/pycrypcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def main():
\____/_/ \__, / .___/\__/_/\___/
/____/_/
"""
"\033[0m"
"\033[0m",
)
print("Python Cryptic Game Client (https://github.com/Defelo/PyCrypCli)")
print("You can always type `help` for a list of available commands.")
Expand Down

0 comments on commit 7cbbc73

Please sign in to comment.