Fix remaining pylint errors. (and disable a few sillies...)
This commit is contained in:
parent
ca992feb21
commit
c1dd4bd23c
9 changed files with 95 additions and 114 deletions
69
dataobjs.py
69
dataobjs.py
|
@ -300,13 +300,16 @@ class PesterProfile:
|
|||
PchumLog.exception("")
|
||||
initials = "XX"
|
||||
PchumLog.debug("initials = " + str(initials))
|
||||
if hasattr(self, "time") and time:
|
||||
if self.time > time:
|
||||
return "F" + initials
|
||||
elif self.time < time:
|
||||
return "P" + initials
|
||||
if hasattr(self, "time"):
|
||||
if time:
|
||||
if self.time > time:
|
||||
return "F" + initials
|
||||
elif self.time < time:
|
||||
return "P" + initials
|
||||
else:
|
||||
return "C" + initials
|
||||
else:
|
||||
return "C" + initials
|
||||
return initials
|
||||
else:
|
||||
return initials
|
||||
|
||||
|
@ -458,44 +461,24 @@ class PesterProfile:
|
|||
)
|
||||
)
|
||||
else:
|
||||
# Is timeGrammar defined? Not sure if this works as intented, added try except block to be safe.
|
||||
try:
|
||||
initials = timeGrammar.pcf + self.initials() + timeGrammar.number
|
||||
if opchum.handle == reason:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo."
|
||||
% (opchum.colorhtml(), opinit, self.colorhtml(), initials)
|
||||
)
|
||||
else:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo: <c=black>[%s]</c>."
|
||||
% (
|
||||
opchum.colorhtml(),
|
||||
opinit,
|
||||
self.colorhtml(),
|
||||
initials,
|
||||
str(reason),
|
||||
)
|
||||
)
|
||||
except:
|
||||
PchumLog.exception("")
|
||||
initials = self.initials()
|
||||
if opchum.handle == reason:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo."
|
||||
% (opchum.colorhtml(), opinit, self.colorhtml(), initials)
|
||||
)
|
||||
else:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo: <c=black>[%s]</c>."
|
||||
% (
|
||||
opchum.colorhtml(),
|
||||
opinit,
|
||||
self.colorhtml(),
|
||||
initials,
|
||||
str(reason),
|
||||
)
|
||||
PchumLog.exception("")
|
||||
initials = self.initials()
|
||||
if opchum.handle == reason:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo."
|
||||
% (opchum.colorhtml(), opinit, self.colorhtml(), initials)
|
||||
)
|
||||
else:
|
||||
return (
|
||||
"<c=%s>%s</c> banned <c=%s>%s</c> from responding to memo: <c=black>[%s]</c>."
|
||||
% (
|
||||
opchum.colorhtml(),
|
||||
opinit,
|
||||
self.colorhtml(),
|
||||
initials,
|
||||
str(reason),
|
||||
)
|
||||
)
|
||||
|
||||
# As far as I'm aware, there's no IRC reply for this, this seems impossible to check for in practice.
|
||||
def memopermabanmsg(self, opchum, opgrammar, syscolor, timeGrammar):
|
||||
|
|
|
@ -27,9 +27,6 @@ class CaseInsensitiveDict(dict):
|
|||
def __contains__(self, key):
|
||||
return super().__contains__(key.lower())
|
||||
|
||||
def has_key(self, key):
|
||||
return key.lower() in super()
|
||||
|
||||
def __delitem__(self, key):
|
||||
super().__delitem__(key.lower())
|
||||
|
||||
|
|
|
@ -168,24 +168,17 @@ _ARGUMENTS = parser.parse_args()
|
|||
try:
|
||||
# PyQt6, QtMultimedia is prefered.
|
||||
from PyQt6 import QtMultimedia
|
||||
|
||||
# print("Audio module is PyQt6 QtMultimedia.")
|
||||
print("Audio module is PyQt6 QtMultimedia.")
|
||||
except ImportError:
|
||||
if ostools.isWin32() or ostools.isOSX():
|
||||
# PyQt5 QtMultimedia has native backends for MacOS and Windows
|
||||
try:
|
||||
from PyQt5 import QtMultimedia
|
||||
|
||||
print(
|
||||
"Using PyQt5 QtMultimedia as sound module. (fallback, PyQt6 QtMultimedia not availible)"
|
||||
)
|
||||
except ImportError:
|
||||
try:
|
||||
try:
|
||||
# Mute pygame support print
|
||||
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
|
||||
except:
|
||||
pass
|
||||
import pygame
|
||||
|
||||
print(
|
||||
|
@ -200,20 +193,13 @@ except ImportError:
|
|||
else:
|
||||
# PyQt5 QtMultimedia needs gstreamer on linux, so pygame is prefered.
|
||||
try:
|
||||
try:
|
||||
# Mute pygame support print
|
||||
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
|
||||
except:
|
||||
pass
|
||||
import pygame
|
||||
|
||||
print(
|
||||
"Using pygame as sound module. (fallback, PyQt6 QtMultimedia not availible)"
|
||||
)
|
||||
except ImportError:
|
||||
try:
|
||||
from PyQt5 import QtMultimedia
|
||||
|
||||
print(
|
||||
"Using PyQt5 QtMultimedia as sound module. (fallback, PyQt6 QtMultimedia and pygame not availible)"
|
||||
)
|
||||
|
@ -2292,7 +2278,7 @@ class PesterWindow(MovingWindow):
|
|||
self.moodsLabel.setStyleSheet(theme["main/moodlabel/style"])
|
||||
|
||||
if hasattr(self, "moods"):
|
||||
self.moods.removeButtons()
|
||||
self.moods.removeButtons() # pylint: disable=access-member-before-definition
|
||||
mood_list = theme["main/moods"]
|
||||
mood_list = [{str(k): v for (k, v) in d.items()} for d in mood_list]
|
||||
self.moods = PesterMoodHandler(
|
||||
|
@ -2345,9 +2331,10 @@ class PesterWindow(MovingWindow):
|
|||
# if self.theme.has_key("main/mychumhandle/currentMood"):
|
||||
try:
|
||||
moodicon = self.profile().mood.icon(theme)
|
||||
if hasattr(self, "currentMoodIcon") and self.currentMoodIcon:
|
||||
self.currentMoodIcon.hide()
|
||||
self.currentMoodIcon = None
|
||||
if hasattr(self, "currentMoodIcon"):
|
||||
if hasattr(self.currentMoodIcon, "hide"): # pylint: disable=E0203
|
||||
self.currentMoodIcon.hide() # pylint: disable=E0203
|
||||
self.currentMoodIcon = None
|
||||
self.currentMoodIcon = QtWidgets.QLabel(self)
|
||||
self.currentMoodIcon.setPixmap(moodicon.pixmap(moodicon.realsize()))
|
||||
self.currentMoodIcon.move(*theme["main/mychumhandle/currentMood"])
|
||||
|
@ -2389,12 +2376,12 @@ class PesterWindow(MovingWindow):
|
|||
# Set up the sounds we're using.
|
||||
try:
|
||||
# Pygame
|
||||
soundclass = pygame.mixer.Sound
|
||||
except:
|
||||
soundclass = pygame.mixer.Sound # pylint: disable=used-before-assignment
|
||||
except (NameError, AttributeError):
|
||||
try:
|
||||
# QtMultimedia
|
||||
soundclass = QtMultimedia.QSoundEffect
|
||||
except:
|
||||
except (NameError, AttributeError):
|
||||
# death
|
||||
soundclass = NoneSound
|
||||
PchumLog.warning("No sound module loaded?")
|
||||
|
@ -3656,8 +3643,9 @@ class PesterWindow(MovingWindow):
|
|||
self.mycolorUpdated.emit()
|
||||
|
||||
def aboutPesterchum(self):
|
||||
if hasattr(self, "aboutwindow") and self.aboutwindow:
|
||||
return
|
||||
if hasattr(self, "aboutwindow"):
|
||||
if self.aboutwindow: # pylint: disable=access-member-before-definition
|
||||
return
|
||||
self.aboutwindow = AboutPesterchum(self)
|
||||
self.aboutwindow.exec()
|
||||
self.aboutwindow = None
|
||||
|
|
|
@ -49,31 +49,31 @@ class Lexeme:
|
|||
raise NotImplementedError
|
||||
|
||||
|
||||
class Message(Lexeme):
|
||||
"""An object designed to represent a message, possibly containing Lexeme
|
||||
objects in their native form as well. Intended to be a combination of a
|
||||
list and a string, combining the former with the latter's methods."""
|
||||
|
||||
def __init__(self, contents, origin):
|
||||
lexer = Lexer.lexer_for(origin)()
|
||||
working = lexer.lex(contents)
|
||||
# TODO: Rebuild all lexemes so that they all 'come from' the same
|
||||
# format (e.g. their .origin values are all the same as the Message's).
|
||||
for i, elt in enumerate(working):
|
||||
try:
|
||||
# Try to rebuild for the new format
|
||||
elt = elt.rebuild(origin)
|
||||
except AttributeError:
|
||||
# It doesn't let us rebuild, so it's probably not a Lexeme
|
||||
continue
|
||||
else:
|
||||
# Assign it to the proper place, replacing the old one
|
||||
working[i] = elt
|
||||
self.origin = origin
|
||||
self.contents = working
|
||||
self.string = "".join(lexer.list_convert(working))
|
||||
|
||||
# TODO: Finish all the rest of this.
|
||||
#class Message(Lexeme):
|
||||
# """An object designed to represent a message, possibly containing Lexeme
|
||||
# objects in their native form as well. Intended to be a combination of a
|
||||
# list and a string, combining the former with the latter's methods."""
|
||||
#
|
||||
# def __init__(self, contents, origin):
|
||||
# lexer = Lexer.lexer_for(origin)()
|
||||
# working = lexer.lex(contents)
|
||||
# # TODO: Rebuild all lexemes so that they all 'come from' the same
|
||||
# # format (e.g. their .origin values are all the same as the Message's).
|
||||
# for i, elt in enumerate(working):
|
||||
# try:
|
||||
# # Try to rebuild for the new format
|
||||
# elt = elt.rebuild(origin)
|
||||
# except AttributeError:
|
||||
# # It doesn't let us rebuild, so it's probably not a Lexeme
|
||||
# continue
|
||||
# else:
|
||||
# # Assign it to the proper place, replacing the old one
|
||||
# working[i] = elt
|
||||
# self.origin = origin
|
||||
# self.contents = working
|
||||
# self.string = "".join(lexer.list_convert(working))
|
||||
#
|
||||
# # TODO: Finish all the rest of this.
|
||||
|
||||
|
||||
class Specifier(Lexeme):
|
||||
|
@ -587,10 +587,11 @@ class RelayChat(Lexer):
|
|||
# Add a </c> since we'll need one anyway
|
||||
|
||||
# Is closecolor accessible here?
|
||||
try:
|
||||
closecolor()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# No. :/
|
||||
# try:
|
||||
# closecolor()
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
|
||||
##if isinstance(color, LineColor):
|
||||
if isinstance(cstack.pop(), LineColor):
|
||||
|
@ -610,10 +611,10 @@ class RelayChat(Lexer):
|
|||
del cstack[-1]
|
||||
# Add a </c>
|
||||
# Is closecolor accessible here?
|
||||
try:
|
||||
closecolor()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# try:
|
||||
# closecolor()
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
else:
|
||||
# It's a line color, so stop searching.
|
||||
# Using break here prevents the 'else'
|
||||
|
|
|
@ -4,7 +4,7 @@ __all__ = ["Color"]
|
|||
# in mind that this may be phased out in the future.
|
||||
|
||||
|
||||
from .dep.attrdict import AttrDict
|
||||
from pnc.dep.attrdict import AttrDict
|
||||
|
||||
import collections
|
||||
import functools
|
||||
|
|
|
@ -20,14 +20,16 @@ class TwmnError(Exception):
|
|||
|
||||
|
||||
def confExists():
|
||||
# FIXME
|
||||
try:
|
||||
from xdg import BaseDirectory
|
||||
|
||||
except ImportError:
|
||||
return False
|
||||
try:
|
||||
return os.path.join(BaseDirectory.xdg_config_home, "twmn/twmn.conf")
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def init(host="127.0.0.1", port=None):
|
||||
if not port:
|
||||
port = 9797
|
||||
|
|
12
quirks.py
12
quirks.py
|
@ -49,7 +49,11 @@ class ScriptQuirks:
|
|||
def load(self):
|
||||
self.last = self.quirks.copy()
|
||||
self.quirks.clear()
|
||||
extension = self.getExtension()
|
||||
try:
|
||||
extension = self.getExtension()
|
||||
except AttributeError:
|
||||
PchumLog.exception("No self.getExtension(), does ScriptQuirks need to be subclassed?")
|
||||
return
|
||||
filenames = []
|
||||
if not os.path.exists(os.path.join(self.home, "quirks")):
|
||||
os.makedirs(os.path.join(self.home, "quirks"), exist_ok=True)
|
||||
|
@ -65,7 +69,11 @@ class ScriptQuirks:
|
|||
|
||||
modules = []
|
||||
for filename in filenames:
|
||||
extension_length = len(self.getExtension())
|
||||
try:
|
||||
extension_length = len(self.getExtension())
|
||||
except AttributeError:
|
||||
PchumLog.exception("No self.getExtension(), does ScriptQuirks need to be subclassed?")
|
||||
return
|
||||
name = os.path.basename(filename)[:-extension_length]
|
||||
try:
|
||||
module = self.loadModule(name, filename)
|
||||
|
|
14
toast.py
14
toast.py
|
@ -1,3 +1,4 @@
|
|||
"""FIXME: not sure how this works exactly but it seems kinda broken!!"""
|
||||
import os
|
||||
|
||||
# import time
|
||||
|
@ -25,7 +26,7 @@ pynotify = None
|
|||
|
||||
|
||||
class DefaultToast:
|
||||
def __init__(self, machine, title, msg, icon):
|
||||
def __init__(self, machine, title, msg, icon, parent=None):
|
||||
self.machine = machine
|
||||
self.title = title
|
||||
self.msg = msg
|
||||
|
@ -148,7 +149,7 @@ class ToastMachine:
|
|||
self.machine, self.title, self.msg, self.icon
|
||||
)
|
||||
else:
|
||||
t = DefaultToast(self.title, self.msg, self.icon)
|
||||
t = DefaultToast(self.machine, self.title, self.msg, self.icon)
|
||||
t.show()
|
||||
|
||||
def __init__(
|
||||
|
@ -201,8 +202,8 @@ class ToastMachine:
|
|||
|
||||
try:
|
||||
pytwmn.init()
|
||||
except pytwmn.ERROR as e:
|
||||
PchumLog.error("Problem initilizing pytwmn: " + str(e))
|
||||
except Exception :
|
||||
PchumLog.exception("Problem initilizing pytwmn.")
|
||||
return
|
||||
# self.type = type = "default"
|
||||
self.type = type
|
||||
|
@ -230,8 +231,9 @@ class ToastMachine:
|
|||
|
||||
class PesterToast(QtWidgets.QWidget, DefaultToast):
|
||||
def __init__(self, machine, title, msg, icon, time=3000, parent=None):
|
||||
kwds = dict(machine=machine, title=title, msg=msg, icon=icon)
|
||||
super().__init__(parent, **kwds)
|
||||
# FIXME: Not sure how this works exactly either xd, can't we init the parents seperately?
|
||||
kwds = dict(parent=parent, machine=machine, title=title, msg=msg, icon=icon)
|
||||
super().__init__(**kwds)
|
||||
|
||||
self.machine = machine
|
||||
self.time = time
|
||||
|
|
Loading…
Reference in a new issue