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