diff --git a/dataobjs.py b/dataobjs.py index a359be4..ffa2828 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -110,12 +110,14 @@ class pesterQuirks(object): def __init__(self, quirklist): self.quirklist = [] for q in quirklist: - if type(q) == dict: - self.quirklist.append(pesterQuirk(q)) - elif type(q) == pesterQuirk: - self.quirklist.append(q) + self.addQuirk(q) def plainList(self): return [q.quirk for q in self.quirklist] + def addQuirk(self, q): + if type(q) == dict: + self.quirklist.append(pesterQuirk(q)) + elif type(q) == pesterQuirk: + self.quirklist.append(q) def apply(self, lexed, first=False, last=False): prefix = [q for q in self.quirklist if q.type=='prefix'] suffix = [q for q in self.quirklist if q.type=='suffix'] diff --git a/pesterchum.cfg b/pesterchum.cfg index dd22402..7763cfe 100644 --- a/pesterchum.cfg +++ b/pesterchum.cfg @@ -12,30 +12,6 @@ handle: adiosToreador color: -5614336 handle: arachnidsGrip color: -6206085 -handle: carcinoGeneticist -color: -10066330 -handle: dodecahedronCipher -color: -10091259 -handle: gamblingGenocider -color: -16711936 -handle: gardenGnostic -color: -16711936 -handle: ghostDunk -color: -65281 -handle: globalsoftPirka -color: -16384 -handle: insipidTranscient -color: -15445916 -handle: irrelevantDeveloper -color: -5097614 -handle: mechanicalSpectacle -color: -16776961 -handle: poisonedRationality -color: -16356757 -handle: rainbowAssfactory -color: -10197916 -handle: temporalWizard -color: -3288817 #CHUMROLL END #QUIRKS BEGIN search: [p|P] diff --git a/pesterchum.py b/pesterchum.py index 2e8d478..b9a49cd 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -1399,12 +1399,43 @@ class PesterWindow(MovingWindow): if f == "": return fp = open(f, 'r') + regexp_state = None for l in fp.xreadlines(): # import chumlist + l = l.rstrip() chum_mo = re.match("handle: ([A-Za-z0-9]+)", l) if chum_mo is not None: chum = PesterProfile(chum_mo.group(1)) self.addChum(chum) + continue + if regexp_state is not None: + replace_mo = re.match("replace: (.+)", l) + if replace_mo is not None: + replace = replace_mo.group(1) + try: + re.compile(regexp_state) + except re.error, e: + continue + newquirk = pesterQuirk({"type": "regexp", + "from": regexp_state, + "to": replace}) + qs = self.userprofile.quirks + qs.addQuirk(newquirk) + self.userprofile.setQuirks(qs) + regexp_state = None + continue + search_mo = re.match("search: (.+)", l) + if search_mo is not None: + regexp_state = search_mo.group(1) + continue + other_mo = re.match("(prefix|suffix): (.+)", l) + if other_mo is not None: + newquirk = pesterQuirk({"type": other_mo.group(1), + "value": other_mo.group(2)}) + qs = self.userprofile.quirks + qs.addQuirk(newquirk) + self.userprofile.setQuirks(qs) + @QtCore.pyqtSlot() def showMemos(self, channel=""): if not hasattr(self, 'memochooser'):