diff --git a/generic.py b/generic.py index 7901394..db7ed1e 100644 --- a/generic.py +++ b/generic.py @@ -9,6 +9,17 @@ class mysteryTime(timedelta): def __neq__(self, other): return (type(other) is not mysteryTime) +class CaseInsensitiveDict(dict): + def __setitem__(self, key, value): + super(CaseInsensitiveDict, self).__setitem__(key.lower(), value) + def __getitem__(self, key): + return super(CaseInsensitiveDict, self).__getitem__(key.lower()) + def __contains__(self, key): + return super(CaseInsensitiveDict, self).__contains__(key.lower()) + def has_key(self, key): + return super(CaseInsensitiveDict, self).has_key(key.lower()) + def __delitem__(self, key): + super(CaseInsensitiveDict, self).__delitem__(key.lower()) class PesterList(list): def __init__(self, l): self.extend(l) diff --git a/memos.py b/memos.py index 66aff11..36066e1 100644 --- a/memos.py +++ b/memos.py @@ -218,10 +218,10 @@ class MemoTabWindow(PesterTabWindow): def __init__(self, mainwindow, parent=None): PesterTabWindow.__init__(self, mainwindow, parent, "memos") def addChat(self, convo): - self.convos[convo.channel.upper()] = convo + self.convos[convo.channel] = convo # either addTab or setCurrentIndex will trigger changed() - newindex = self.tabs.addTab(convo.channel.upper()) - self.tabIndices[convo.channel.upper()] = newindex + newindex = self.tabs.addTab(convo.channel) + self.tabIndices[convo.channel] = newindex self.tabs.setCurrentIndex(newindex) self.tabs.setTabIcon(newindex, PesterIcon(self.mainwindow.theme["memos/memoicon"])) def updateBlocked(self): @@ -291,16 +291,16 @@ class MemoText(PesterText): grammar = time.getGrammar() joinmsg = chum.memojoinmsg(systemColor, time.getTime(), grammar, window.theme["convo/text/joinmemo"]) self.append(convertTags(joinmsg)) - parent.mainwindow.chatlog.log(parent.channel.upper(), joinmsg) + parent.mainwindow.chatlog.log(parent.channel, joinmsg) time.openCurrentTime() if type(lexmsg[0]) is mecmd: memsg = chum.memsg(systemColor, lexmsg, time=time.getGrammar()) - window.chatlog.log(parent.channel.upper(), memsg) + window.chatlog.log(parent.channel, memsg) self.append(convertTags(memsg)) else: self.append(convertTags(lexmsg)) - window.chatlog.log(parent.channel.upper(), lexmsg) + window.chatlog.log(parent.channel, lexmsg) def changeTheme(self, theme): self.initTheme(theme) @@ -417,7 +417,7 @@ class PesterMemo(PesterConvo): msg = p.memoopenmsg(systemColor, self.time.getTime(), timeGrammar, self.mainwindow.theme["convo/text/openmemo"], self.channel) self.time.openCurrentTime() self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) self.op = False self.newmessage = False @@ -425,7 +425,7 @@ class PesterMemo(PesterConvo): self.applyquirks = True def title(self): - return self.channel.upper() + return self.channel def icon(self): return PesterIcon(self.mainwindow.theme["memos/memoicon"]) @@ -555,7 +555,7 @@ class PesterMemo(PesterConvo): self.times[handle].removeTime(close) msg = chum.memoclosemsg(systemColor, grammar, window.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) elif timed not in self.times[handle]: self.times[handle].addTime(timed) else: @@ -601,7 +601,7 @@ class PesterMemo(PesterConvo): namesdb = self.mainwindow.namesdb # reload names self.userlist.clear() - for n in self.mainwindow.namesdb[self.channel.upper()]: + for n in self.mainwindow.namesdb[self.channel]: self.addUser(n) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) @@ -635,7 +635,7 @@ class PesterMemo(PesterConvo): grammar = t.getGrammar() msg = chum.memoclosemsg(systemColor, grammar, self.mainwindow.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) self.times[h].removeTime(t.getTime()) if update == "nick": self.addUser(newnick) @@ -663,7 +663,7 @@ class PesterMemo(PesterConvo): opgrammar = TimeGrammar("CURRENT", "C", "RIGHT NOW") msg = chum.memobanmsg(opchum, opgrammar, systemColor, grammar) self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) ttracker.removeTime(ttracker.getTime()) if chum is self.mainwindow.profile(): @@ -682,10 +682,10 @@ class PesterMemo(PesterConvo): self.time.openCurrentTime() msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel) self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) elif ret == QtGui.QMessageBox.Cancel: if self.parent(): - i = self.parent().tabIndices[self.channel.upper()] + i = self.parent().tabIndices[self.channel] self.parent().tabClose(i) else: self.close() @@ -749,7 +749,7 @@ class PesterMemo(PesterConvo): systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) msg = me.memoclosemsg(systemColor, grammar, self.mainwindow.theme["convo/text/closememo"]) self.textArea.append(convertTags(msg)) - self.mainwindow.chatlog.log(self.channel.upper(), msg) + self.mainwindow.chatlog.log(self.channel, msg) newtime = self.time.getTime() if newtime is None: diff --git a/menus.py b/menus.py index 175e644..2402705 100644 --- a/menus.py +++ b/menus.py @@ -656,7 +656,7 @@ class PesterUserlist(QtGui.QDialog): self.updateUsers() @QtCore.pyqtSlot() def updateUsers(self): - names = self.mainwindow.namesdb["#PESTERCHUM"] + names = self.mainwindow.namesdb["#pesterchum"] self.userarea.clear() for n in names: item = QtGui.QListWidgetItem(n) diff --git a/parsetools.py b/parsetools.py index 8dfaec1..813706c 100644 --- a/parsetools.py +++ b/parsetools.py @@ -319,7 +319,6 @@ class parseLeaf(object): def append(self, node): self.nodes.append(node) def expand(self, mo): - print "starting expand" out = "" for n in self.nodes: if type(n) == parseLeaf: @@ -328,9 +327,7 @@ class parseLeaf(object): out += mo.group(int(n.number)) else: out += n - print "out: %s" % (out) out = self.function(out) - print "returning %s" % (out) return out class backreference(object): def __init__(self, number): diff --git a/pesterchum.js b/pesterchum.js index 1dbea1d..f8731ef 100644 --- a/pesterchum.js +++ b/pesterchum.js @@ -1 +1 @@ -{"hideOfflineChums": true, "time12Format": true, "tabs": true, "soundon": true, "server": "irc.mindfang.org", "showSeconds": false, "showTimeStamps": false, "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "grayscaleVisionary", "corruptedInsanity", "stupidlyBrilliant", "artsyGyarados", "obliviousCrafter", "sporadicAgent", "subtleChaotician", "nareSolee", "apostateCourier", "nocturnalTherapist", "herpaDerp", "clockworkUtopia", "digitalSamurai", "astronomicalMaster", "slipshodBrisant", "genialDustbuster", "hyperdriveTyphoon", "magnificentMiser", "gentleRuffian", "riskRepeats", "globalsoftPrika", "globalsoftPirka", "devonianCritter", "lethargicSerpent", "laughingShisa", "bluntInstrument", "sunilaSeed", "bluntInstrument", "nickServ", "ghostBinoculars", "alGore", "evacipatedBox", "acrylicEmulator", "prettyGemmaiden", "calSprite", "fairytalePorn", "brooklynRage"], "defaultprofile": "testProfile", "block": []} \ No newline at end of file +{"hideOfflineChums": false, "time12Format": true, "tabs": true, "soundon": true, "server": "irc.mindfang.org", "showSeconds": false, "showTimeStamps": false, "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "grayscaleVisionary", "corruptedInsanity", "stupidlyBrilliant", "artsyGyarados", "obliviousCrafter", "sporadicAgent", "subtleChaotician", "nareSolee", "apostateCourier", "nocturnalTherapist", "herpaDerp", "clockworkUtopia", "digitalSamurai", "astronomicalMaster", "slipshodBrisant", "genialDustbuster", "hyperdriveTyphoon", "magnificentMiser", "gentleRuffian", "riskRepeats", "globalsoftPrika", "globalsoftPirka", "devonianCritter", "lethargicSerpent", "laughingShisa", "bluntInstrument", "sunilaSeed", "bluntInstrument", "nickServ", "ghostBinoculars", "alGore", "evacipatedBox", "acrylicEmulator", "prettyGemmaiden", "calSprite", "fairytalePorn", "brooklynRage", "computerCyanide"], "defaultprofile": "testProfile", "block": []} \ No newline at end of file diff --git a/pesterchum.py b/pesterchum.py index 8ea4e71..c3db8db 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -18,7 +18,7 @@ from menus import PesterChooseQuirks, PesterChooseTheme, \ PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \ LoadingScreen, AboutPesterchum from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks -from generic import PesterIcon, RightClickList, RightClickTree, MultiTextDialog, PesterList +from generic import PesterIcon, RightClickList, RightClickTree, MultiTextDialog, PesterList, CaseInsensitiveDict from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo from parsetools import convertTags, addTimeInitial from memos import PesterMemo, MemoTabWindow, TimeTracker @@ -1188,8 +1188,8 @@ class PesterWindow(MovingWindow): MovingWindow.__init__(self, parent, (QtCore.Qt.CustomizeWindowHint | QtCore.Qt.FramelessWindowHint)) - self.convos = {} - self.memos = {} + self.convos = CaseInsensitiveDict() + self.memos = CaseInsensitiveDict() self.tabconvo = None self.tabmemo = None @@ -1309,7 +1309,7 @@ class PesterWindow(MovingWindow): self.connect(self.miniButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('showMinimized()')) - self.namesdb = {} + self.namesdb = CaseInsensitiveDict() self.chumdb = PesterProfileDB() chums = [PesterProfile(c, chumdb=self.chumdb) for c in set(self.config.chums())] @@ -1421,10 +1421,10 @@ class PesterWindow(MovingWindow): else: self.alarm.play() def newMemoMsg(self, chan, handle, msg): - if not self.memos.has_key(chan.upper()): + if not self.memos.has_key(chan): # silently ignore in case we forgot to /part return - memo = self.memos[chan.upper()] + memo = self.memos[chan] msg = unicode(msg) if not memo.times.has_key(handle): # new chum! time current @@ -1492,8 +1492,8 @@ class PesterWindow(MovingWindow): def newMemo(self, channel, timestr, secret=False): if channel == "#pesterchum": return - if self.memos.has_key(channel.upper()): - self.memos[channel.upper()].showChat() + if self.memos.has_key(channel): + self.memos[channel].showChat() return # do slider dialog then set if self.config.tabs(): @@ -1514,7 +1514,7 @@ class PesterWindow(MovingWindow): QtCore.SIGNAL('userPresentSignal(QString, QString, QString)'), memoWindow, QtCore.SLOT('userPresentChange(QString, QString, QString)')) # chat client send memo open - self.memos[channel.upper()] = memoWindow + self.memos[channel] = memoWindow self.joinChannel.emit(channel) # race condition? self.secret = secret if self.secret: @@ -1745,7 +1745,7 @@ class PesterWindow(MovingWindow): c = unicode(channel) self.chatlog.finish(c) self.leftChannel.emit(channel) - del self.memos[c.upper()] + del self.memos[c] @QtCore.pyqtSlot() def tabsClosed(self): del self.tabconvo @@ -1777,19 +1777,19 @@ class PesterWindow(MovingWindow): @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) def timeCommand(self, chan, handle, command): (c, h, cmd) = (unicode(chan), unicode(handle), unicode(command)) - if self.memos[c.upper()]: - self.memos[c.upper()].timeUpdate(h, cmd) + if self.memos[c]: + self.memos[c].timeUpdate(h, cmd) @QtCore.pyqtSlot(QtCore.QString, PesterList) def updateNames(self, channel, names): - c = unicode(channel).upper() + c = unicode(channel) # update name DB self.namesdb[c] = names # warn interested party of names self.namesUpdated.emit() @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) def userPresentUpdate(self, handle, channel, update): - c = unicode(channel).upper() + c = unicode(channel) n = unicode(handle) if update == "nick": l = n.split(":")