Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codebase lint for migrate all CI to pre-commit #188

Merged
merged 3 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/honeybot/api/commands.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
def set_nick(name):
return "NICK {0} \r\n".format(name)
return f"NICK {name} \r\n"


def present(name):
return "USER {0} {0} {0} : {0} IRC\r\n".format(name)


def identify(password):
return "msg NickServ identify {0} \r\n".format(password)
return f"msg NickServ identify {password} \r\n"


def join_channel(channel):
return "JOIN {0} \r\n".format(channel)
return f"JOIN {channel} \r\n"


def specific_send(target, msg):
return "PRIVMSG {0} :{1}\r\n".format(target, msg)
return f"PRIVMSG {target} :{msg}\r\n"


def pong_return(domain):
return "PONG :{}\r\n".format(domain)
return f"PONG :{domain}\r\n"
10 changes: 3 additions & 7 deletions src/honeybot/api/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import configparser
import importlib
import logging
Expand Down Expand Up @@ -29,7 +27,7 @@
"""


class Bot_core(object):
class Bot_core:
def __init__(self, info, password=""):
self.info = info
connect_config = configparser.ConfigParser()
Expand Down Expand Up @@ -159,9 +157,7 @@ def load_plugins_from_folder(self, category_folder, from_conf=None, from_dir=Non
print("loading plugin:", folder)
try:
sys.path.append(self.root_path)
module = importlib.import_module(
"plugins.{}.{}.main".format(category_folder, folder)
)
module = importlib.import_module(f"plugins.{category_folder}.{folder}.main")
obj = module
self.plugins.append(obj)
except ModuleNotFoundError as e:
Expand Down Expand Up @@ -277,7 +273,7 @@ def stay_alive(self, incoming):
sys.exit()
parts = incoming.split(":")
if parts[0].strip().lower() == "ping":
logger.warning("ping detected from: {}".format(parts[1]))
logger.warning(f"ping detected from: {parts[1]}")
self.send(commands.pong_return(self.domain))
self.send(commands.pong_return(parts[1]))

Expand Down
10 changes: 5 additions & 5 deletions src/honeybot/api/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@


def add_value(memfile, section, key, value):
memory_reader.read("memory/{}.txt".format(memfile))
memory_reader.read(f"memory/{memfile}.txt")
memory_reader[section][key] = value
with open("memory/{}.txt".format(memfile), "w") as file:
with open(f"memory/{memfile}.txt", "w") as file:
memory_reader.write(file)


def remove_value(memfile, section, key):
memory_reader.read("memory/{}.txt".format(memfile))
memory_reader.read(f"memory/{memfile}.txt")
memory_reader.remove_option(section, key)
with open("memory/{}.txt".format(memfile), "w") as file:
with open(f"memory/{memfile}.txt", "w") as file:
memory_reader.write(file)


def fetch_value(memfile, section, key):
memory_reader.read("memory/{}.txt".format(memfile))
memory_reader.read(f"memory/{memfile}.txt")
return memory_reader[section][key]
2 changes: 1 addition & 1 deletion src/honeybot/api/print.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
import os

ascii_message = """
ascii_message = r"""
_ _ _ _
_ __ _ _| || |___ _ _ ___ _ _| |__ ___| |_
| '_ \ || | __ / _ \ ' \/ -_) || | '_ \/ _ \ _|
Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def prevent_none(x):

def configfile_to_list(settings_path, filename):
elements = []
with open(os.path.join(settings_path, "{}.conf".format(filename))) as f:
with open(os.path.join(settings_path, f"{filename}.conf")) as f:
elements = f.read().split("\n")
elements = list(filter(lambda x: x != "", elements))
return elements
Expand Down
8 changes: 5 additions & 3 deletions src/honeybot/gui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def get_unique_text(text):
uniques = sorted(set([i.strip() for i in text.split("\n") if i]))
uniques = sorted({i.strip() for i in text.split("\n") if i})
uniques_text = "\n".join(uniques)
return uniques_text

Expand Down Expand Up @@ -82,8 +82,10 @@ def exit_app(self):
"MainLabel",
Label(
window,
text="Select the plugins you wish to \
load and add them to the config file",
text=(
"Select the plugins you wish to load and add them to"
" the config file"
),
),
]
],
Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/lab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Commands:
def set_nick(name):
return "NICK {0} \r\n".format(name)
return f"NICK {name} \r\n"


print(Commands.set_nick("abc"))
1 change: 0 additions & 1 deletion src/honeybot/memory/global.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ c = 3
q = 1
w = 7
flower = hibiscus

5 changes: 2 additions & 3 deletions src/honeybot/plugins/core/joins/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[joins.py]
Joins Plugin
Expand Down Expand Up @@ -28,8 +27,8 @@ def run(self, incoming, methods, info, bot_info):

# Greets joined user
channel = info["args"][0]
greet = "Hello {} welcome to {} !".format(user, channel)
methods["send"](info["address"], "{}".format(greet))
greet = f"Hello {user} welcome to {channel} !"
methods["send"](info["address"], f"{greet}")

except Exception as e:
print("woops plugin error ", e)
7 changes: 3 additions & 4 deletions src/honeybot/plugins/core/log/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[log.py]
Log Plugin
Expand All @@ -19,7 +18,7 @@

# Makes a new log dir if not existent
# Change according to where you have honeybot dir
log_path = "{}/log".format(os.getcwd())
log_path = f"{os.getcwd()}/log"
if not os.path.exists(log_path):
os.makedirs("log")

Expand All @@ -36,7 +35,7 @@ def run(self, incoming, methods, info, bot_info):
try:
if info["command"] == "PRIVMSG":
# Make log file (if not existent) using current date
f = open("log/{}.txt".format(curr_date), "a+")
f = open(f"log/{curr_date}.txt", "a+")

# Current time
curr_time = datetime.now().strftime("%H:%M:%S")
Expand All @@ -47,7 +46,7 @@ def run(self, incoming, methods, info, bot_info):
user = raw_user[0:user_index]

# Logging the chat into txt file
f.write("{}: {}: {}\r\n".format(curr_time, user, msgs[0]))
f.write(f"{curr_time}: {user}: {msgs[0]}\r\n")

except Exception as e:
print("woops plugin error ", e)
3 changes: 1 addition & 2 deletions src/honeybot/plugins/core/uptime/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[uptime.py]
Uptime Plugin
Expand Down Expand Up @@ -33,7 +32,7 @@ def __convert_time(start_time):
uptime -= mins * 60
sec = int(uptime)

msg = "Bot has been up for {0} hr, {1} min, and {2} sec.".format(hrs, mins, sec)
msg = f"Bot has been up for {hrs} hr, {mins} min, and {sec} sec."
return msg

def run(self, incoming, methods, info, bot_info):
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/abbreviation/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[abbreviation.py]
Abbreviation Plugin
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/age/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[age.py]
Age Plugin
Expand Down Expand Up @@ -28,7 +27,7 @@ def __age(day, mo, yr):
if months < 0 or (months == 0 and day < 0):
years -= 1

msg = "You are {0}yrs. {1}mo. and {2} days old.".format(years, abs(months), abs(days))
msg = f"You are {years}yrs. {abs(months)}mo. and {abs(days)} days old."
return msg

def run(self, incoming, methods, info, bot_info):
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/bitcoin/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[bitcoin.py]
Bitcoin Price Checking Plugin
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/blackjack/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[blackjack.py]
Blackjack Plugin
Expand Down Expand Up @@ -146,7 +145,7 @@ def initGame(methods, info):
Plugin.DECK = poker_assets.deck.Deck()
methods["send"](
info["address"],
name + " has started a game of blackjack! " "Use .blackjack join to join in!",
name + " has started a game of blackjack! Use .blackjack join to join in!",
)
else:
methods["send"](info["address"], "A game already exists!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=E1601


class Board(object):
class Board:
"""board class"""

def __init__(self, board):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=E1601


class Card(object):
class Card:
"""card class"""

def __init__(self, card):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import card


class Deck(object):
class Deck:
"""deck class"""

colors = ["C", "D", "H", "S"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# import card


class Hand(object):
class Hand:
"""hand class"""

def __init__(self, hand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import game_init


class Player(object):
class Player:
"""player class"""

def __init__(self, nr, chips, username):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=E1601


class Pot(object):
class Pot:
"""pot class"""

def __init__(self):
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/caesar_cipher/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[calc.py]
Caesar Cipher plugin
Expand Down Expand Up @@ -30,6 +29,6 @@ def run(self, incoming, methods, info, bot_info):
expr = msgs[1]
encoded = codecs.encode(expr, "rot-13")
print(encoded)
methods["send"](info["address"], "{}".format(encoded))
methods["send"](info["address"], f"{encoded}")
except Exception as e:
print("woops plugin", __file__, e)
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/calc/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[calc.py]
Maths Operation Plugin
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/channeljoin/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[channeljoin.py]
Join Plugin
Expand Down Expand Up @@ -26,7 +25,7 @@ def run(self, incoming, methods, info, bot_info):
raw_user = info["prefix"]
user_index = raw_user.find("!")
user = raw_user[0:user_index]
with open("settings/OWNERS.conf", "r") as f:
with open("settings/OWNERS.conf") as f:
for owner in f:
if owner.strip() == user:
methods["join"](msgs[1])
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/comic/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[comic.py]
Image search plugin
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/conv_sniff/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[conv_sniff.py]
Conversation Sniffer Plugin
Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/converter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def is_number(char):

part1 = soup.find(class_="ccOutputTrail").previous_sibling
part2 = soup.find(class_="ccOutputTrail").get_text(strip=True)
converted = "{}{}".format(part1, part2)
converted = f"{part1}{part2}"
return str(amount) + base_cur + " is equal to " + converted + target_cur

def run(self, incoming, methods, info, bot_info):
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/corona/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[corona.py]
Coronavirus Plugin
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/country/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[countries.py]
Country-Capital Plugin
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/dadjoke/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[dadjoke.py]
Dad joke plugin
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/date/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[date.py]
Date Plugin
Expand Down Expand Up @@ -28,7 +27,7 @@ def __date():
day = curr_date.strftime("%d")
month = curr_date.strftime("%B")
year = curr_date.strftime("%Y")
return "Today is {} {}, {}".format(month, day, year)
return f"Today is {month} {day}, {year}"

def run(self, incoming, methods, info, bot_info):
try:
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/debug/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[debug.py]
Debug plugin : Un
Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/plugins/downloaded/diary/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[diary.py]
Diary Plugin
Expand Down Expand Up @@ -90,7 +89,7 @@ def delete(self, time):
"""check if entry exists and if it does delete it"""
path = Plugin.get_path(self, time)
if not os.path.exists(path):
return "There is no diary entry for that date. " "Check the date is entered correctly!"
return "There is no diary entry for that date. Check the date is entered correctly!"
else:
os.remove(path)
return "Entry deleted successfully!"
Expand Down
1 change: 0 additions & 1 deletion src/honeybot/plugins/downloaded/dictionary/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
[dictionary.py]
Dictionary Plugin
Expand Down
Loading