Skip to content

Commit

Permalink
chore: enable black
Browse files Browse the repository at this point in the history
Abdur-rahmaanJ committed Jul 3, 2023
1 parent b595729 commit 1e040c1
Showing 5 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -12,13 +12,13 @@ repos:
hooks:
- id: isort
name: Reorder Python Imports
args: ["--check-only", "--settings-path", "./pyproject.toml", "src/honeybot/"]
args: ["./pyproject.toml", "src/honeybot/"]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
name: Lint code
args: ["--check", "--preview", "--config", "./pyproject.toml", "src/honeybot/"]
args: ["src/honeybot/"]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
3 changes: 2 additions & 1 deletion src/honeybot/api/commands.py
Original file line number Diff line number Diff line change
@@ -21,5 +21,6 @@ def specific_send(target, msg):
def pong_return(domain):
return f"PONG :{domain}\r\n"


def quit():
return f"QUIT Leaving / \r\n"
return f"QUIT Leaving / \r\n"
24 changes: 12 additions & 12 deletions src/honeybot/api/main.py
Original file line number Diff line number Diff line change
@@ -9,12 +9,11 @@
import time

import pkg_resources
import tomli

from honeybot.api import commands, memory
from honeybot.api.utils import configfile_to_list, get_requirements, prevent_none
from honeybot.api import print as output

import tomli
from honeybot.api.utils import configfile_to_list, get_requirements, prevent_none

plugins = []

@@ -29,7 +28,7 @@
class BotCore:
def __init__(self, info, password=""):
self.info = info
with open(info['toml_path'], 'rb') as f:
with open(info["toml_path"], "rb") as f:
self.configs = tomli.load(f)
self.settings_path = self.info["settings_path"]
self.root_path = self.info["cwd"]
@@ -137,19 +136,19 @@ def is_valid_plug_name(self, name):
"""

def print_running_infos(self):
print(output.status('i')+ " Run infos:")
print(output.status("i") + " Run infos:")
for key in self.info:
print(output.tab()+' '+key, self.info[key])
print(output.tab() + " " + key, self.info[key])
print(output.line())

def load_plugins_from_folder(self, category_folder, from_conf=None, from_dir=None):
if from_dir is True:
dir_path = os.path.join(self.info["plugins_path"], "core")
to_load = [f for f in os.listdir(dir_path) if self.is_valid_plug_name(f)]
elif from_conf is True:
to_load = self.configs['PLUGINS']['downloaded']
to_load = self.configs["PLUGINS"]["downloaded"]

print(output.status('i')+ " Loading from", category_folder)
print(output.status("i") + " Loading from", category_folder)
for folder in to_load:
print(output.tab(), "loading plugin:", folder)
try:
@@ -193,12 +192,12 @@ def load_plugins(self):
TODO
"""

print(output.status('i')+ " Loading plugins...")
print(output.status("i") + " Loading plugins...")

self.load_plugins_from_folder("downloaded", from_conf=True)
self.load_plugins_from_folder("core", from_dir=True)

print(output.status('x')+ " Loaded plugins")
print(output.status("x") + " Loaded plugins")
print(output.line())

def run_plugins(self, incoming):
@@ -239,10 +238,10 @@ def greet(self):
self.send(commands.present(self.name))
for channel in self.autojoin_channels:
self.send(commands.join_channel(channel))
print(output.status('x'), 'Joined channels:', ', '.join(self.autojoin_channels))
print(output.status("x"), "Joined channels:", ", ".join(self.autojoin_channels))

def pull(self):
print(output.status('i'), 'Listening to incoming messages')
print(output.status("i"), "Listening to incoming messages")
while self.is_listen_on:
try:
data = self.irc.recv(2048).decode("UTF-8", errors="replace")
@@ -270,6 +269,7 @@ def quit(self):
"""
ONGOING REQUIREMENT/S
"""

def stay_alive(self, incoming):
if not incoming:
logger.critical("<must handle reconnection - incoming is not True>")
24 changes: 13 additions & 11 deletions src/honeybot/api/print.py
Original file line number Diff line number Diff line change
@@ -14,17 +14,19 @@


def tab(s=3):
return ' ' * s
return " " * s


def line(n=3):
return '-'*3
return "-" * 3


def status(symbol_type):
if symbol_type in '!i>x':
return '[' + symbol_type + ']'
if symbol_type in "!i>x":
return "[" + symbol_type + "]"
else:
raise Exception('Undefined symbol type')
raise Exception("Undefined symbol type")


def print_honeybot_manifesto(info):
print(ascii_message)
@@ -33,17 +35,17 @@ def print_honeybot_manifesto(info):
def print_connect_settings(info):
settings_path = os.path.join(info["settings_path"], "settings.toml")
if not os.path.exists(settings_path):
print('honeybot.api.print :: Could not find settings.toml in', info["settings_path"])
print('Make sure you are in the right folder')
print("honeybot.api.print :: Could not find settings.toml in", info["settings_path"])
print("Make sure you are in the right folder")
sys.exit()
connect_config = configparser.ConfigParser()
connect_config.read(settings_path)
server_url = connect_config["INFO"]["server_url"]
port = connect_config["INFO"]["port"]
name = connect_config["INFO"]["name"]

print(status('i')+" connecting with settings:")
print(tab()+" server url:", server_url)
print(tab()+" port:", port)
print(tab()+" username:", name)
print(status("i") + " connecting with settings:")
print(tab() + " server url:", server_url)
print(tab() + " port:", port)
print(tab() + " username:", name)
print(line())
2 changes: 1 addition & 1 deletion src/honeybot/store.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import os

BASE_DIR = "plugins/downloaded"
STORE_DIR = "../../honeybot-store"
STORE_DIR = "../../honeybot-store" # ...

plugins = {"plugins": []}
dirs = [d for d in os.listdir(BASE_DIR) if not d.startswith("__")]

0 comments on commit 1e040c1

Please sign in to comment.