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) checkstate = int(q.checkstate)
except Exception: except Exception:
checkstate = 0 checkstate = 0
# Exclude option is checked
if checkstate == 2:
# Check for substring that should be excluded. # Check for substring that should be excluded.
excludes = list() excludes = list()
# Check for links, store in list. # Check for links, store in list.
@ -161,23 +164,10 @@ class pesterQuirks(object):
for match in re.finditer(_memore, string): for match in re.finditer(_memore, string):
excludes.append(match) excludes.append(match)
# Checkstate == 0 means the exclude option is unchecked. if len(excludes) >= 1:
if (checkstate == 0) or (len(excludes) == 0): # SORT !!!
# No split, apply like normal. excludes.sort(key=lambda exclude: exclude.start())
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):
# Seperate parts to be quirked. # Seperate parts to be quirked.
sendparts = list() sendparts = list()
# Add string until start of exclude at index 0. # Add string until start of exclude at index 0.
@ -208,12 +198,42 @@ class pesterQuirks(object):
recvparts.append(q.apply(part)) recvparts.append(q.apply(part))
# Reconstruct and update string. # Reconstruct and update string.
string = '' string = ''
#print("sendparts: " + str(sendparts)) print("excludes: " + str(excludes))
#print("recvparts: " + str(recvparts)) print("sendparts: " + str(sendparts))
print("recvparts: " + str(recvparts))
for part in range(0, len(excludes)): for part in range(0, len(excludes)):
string += recvparts[part] string += recvparts[part]
string += excludes[part].group() string += excludes[part].group()
string += recvparts[-1] 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) newlist.append(string)
final = [] final = []