quirk import
This commit is contained in:
parent
766fcb04aa
commit
32333fdc99
3 changed files with 37 additions and 28 deletions
10
dataobjs.py
10
dataobjs.py
|
@ -110,12 +110,14 @@ class pesterQuirks(object):
|
||||||
def __init__(self, quirklist):
|
def __init__(self, quirklist):
|
||||||
self.quirklist = []
|
self.quirklist = []
|
||||||
for q in quirklist:
|
for q in quirklist:
|
||||||
if type(q) == dict:
|
self.addQuirk(q)
|
||||||
self.quirklist.append(pesterQuirk(q))
|
|
||||||
elif type(q) == pesterQuirk:
|
|
||||||
self.quirklist.append(q)
|
|
||||||
def plainList(self):
|
def plainList(self):
|
||||||
return [q.quirk for q in self.quirklist]
|
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):
|
def apply(self, lexed, first=False, last=False):
|
||||||
prefix = [q for q in self.quirklist if q.type=='prefix']
|
prefix = [q for q in self.quirklist if q.type=='prefix']
|
||||||
suffix = [q for q in self.quirklist if q.type=='suffix']
|
suffix = [q for q in self.quirklist if q.type=='suffix']
|
||||||
|
|
|
@ -12,30 +12,6 @@ handle: adiosToreador
|
||||||
color: -5614336
|
color: -5614336
|
||||||
handle: arachnidsGrip
|
handle: arachnidsGrip
|
||||||
color: -6206085
|
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
|
#CHUMROLL END
|
||||||
#QUIRKS BEGIN
|
#QUIRKS BEGIN
|
||||||
search: [p|P]
|
search: [p|P]
|
||||||
|
|
|
@ -1399,12 +1399,43 @@ class PesterWindow(MovingWindow):
|
||||||
if f == "":
|
if f == "":
|
||||||
return
|
return
|
||||||
fp = open(f, 'r')
|
fp = open(f, 'r')
|
||||||
|
regexp_state = None
|
||||||
for l in fp.xreadlines():
|
for l in fp.xreadlines():
|
||||||
# import chumlist
|
# import chumlist
|
||||||
|
l = l.rstrip()
|
||||||
chum_mo = re.match("handle: ([A-Za-z0-9]+)", l)
|
chum_mo = re.match("handle: ([A-Za-z0-9]+)", l)
|
||||||
if chum_mo is not None:
|
if chum_mo is not None:
|
||||||
chum = PesterProfile(chum_mo.group(1))
|
chum = PesterProfile(chum_mo.group(1))
|
||||||
self.addChum(chum)
|
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()
|
@QtCore.pyqtSlot()
|
||||||
def showMemos(self, channel=""):
|
def showMemos(self, channel=""):
|
||||||
if not hasattr(self, 'memochooser'):
|
if not hasattr(self, 'memochooser'):
|
||||||
|
|
Loading…
Reference in a new issue