Sort fix,, i forgor 💀

This commit is contained in:
Dpeta 2022-06-24 04:55:18 +02:00
parent ce54787062
commit 7c7d406d4f

View file

@ -146,6 +146,9 @@ class pesterQuirks(object):
checkstate = int(q.checkstate)
except Exception:
checkstate = 0
# Exclude option is checked
if checkstate == 2:
# Check for substring that should be excluded.
excludes = list()
# Check for links, store in list.
@ -161,23 +164,10 @@ class pesterQuirks(object):
for match in re.finditer(_memore, string):
excludes.append(match)
# Checkstate == 0 means the exclude option is unchecked.
if (checkstate == 0) or (len(excludes) == 0):
# No split, apply like normal.
if q.type != 'prefix' and q.type != 'suffix':
if q.type == 'regexp' or q.type == 'random':
string = q.apply(string,
first=(i==0),
last=lastStr)
else:
string = q.apply(string)
elif q.type == 'prefix' and i == 0:
string = q.apply(string)
elif q.type == 'suffix' and lastStr:
string = q.apply(string)
# Exclude option is checked, split string and only quirk
# the parts without links/smilies/@handle/#memo
elif (checkstate == 2) and (len(excludes) >= 1):
if len(excludes) >= 1:
# SORT !!!
excludes.sort(key=lambda exclude: exclude.start())
# Seperate parts to be quirked.
sendparts = list()
# Add string until start of exclude at index 0.
@ -208,12 +198,42 @@ class pesterQuirks(object):
recvparts.append(q.apply(part))
# Reconstruct and update string.
string = ''
#print("sendparts: " + str(sendparts))
#print("recvparts: " + str(recvparts))
print("excludes: " + str(excludes))
print("sendparts: " + str(sendparts))
print("recvparts: " + str(recvparts))
for part in range(0, len(excludes)):
string += recvparts[part]
string += excludes[part].group()
string += recvparts[-1]
else:
# No split, apply like normal.
if q.type != 'prefix' and q.type != 'suffix':
if q.type == 'regexp' or q.type == 'random':
string = q.apply(string,
first=(i==0),
last=lastStr)
else:
string = q.apply(string)
elif q.type == 'prefix' and i == 0:
string = q.apply(string)
elif q.type == 'suffix' and lastStr:
string = q.apply(string)
else:
# No split, apply like normal.
if q.type != 'prefix' and q.type != 'suffix':
if q.type == 'regexp' or q.type == 'random':
string = q.apply(string,
first=(i==0),
last=lastStr)
else:
string = q.apply(string)
elif q.type == 'prefix' and i == 0:
string = q.apply(string)
elif q.type == 'suffix' and lastStr:
string = q.apply(string)
newlist.append(string)
final = []