Skip to content

Instantly share code, notes, and snippets.

@cylian914
Last active January 2, 2024 21:09
Show Gist options
  • Save cylian914/a9192fe5fcc1e795a7e2e0a2de066f10 to your computer and use it in GitHub Desktop.
Save cylian914/a9192fe5fcc1e795a7e2e0a2de066f10 to your computer and use it in GitHub Desktop.
Py code to manage crash
class creport:
def __init__(self, string):
if isinstance(string,list):
self.modlist = string;
else: # assume its a string
self.modlist = string.split('\n');
for i in range(len(self.modlist)):
self.modlist[i] = self.modlist[i].split('|')[0:-1]
for j in range(len(self.modlist[i])):
self.modlist[i][j] = self.modlist[i][j].strip();
def getList(self):
return self.modlist;
def getError(self):
for i in range(len(self.modlist)):
if self.modlist[i][3] == 'ERROR':
return self.modlist[i];
def getColStr(self, collum):
string=''
for i in self.modlist:
string+=i[collum] + "\n"
return string
def common(self, other, diff = False): # by name
common = []
for i in self.modlist:
for j in other.modlist:
if i[1] == j[1]:
k = i.copy()
# version and state fusion with '/'
if diff:
if i[4] != j[4]:
k[4] = i[4] + '/' + j[4]
if i[2] != j[2]:
k[3] = i[3] + '/' + j[3]
if i[0] != j[0]:
k[0] = i[0] + '/' + j[0]
common.append(k)
return creport(common);
def toString(self):
string = ''
max= []
for i in range(len(self.modlist[0])):
max.append(getMaxSize(self.modlist,i))
# get the biggest length of each column
for i in self.modlist:
for j in range(len(i)):
string += i[j] + ' '*(max[j]-len(i[j])) + ' | '
string += '\n'
return string;
def getMaxSize(lst, colum):
max=0
for i in lst:
if len(i[colum]) > max:
max=len(i[colum])
return max;
###
#
#
# example:
# report = creport("""sons-of-sins-1.20.1-2.0.5.jar |Sons of Sins |sons_of_sins |2.0.5 |COMMON_SET|Manifest: NOSIGNATURE
# smoothchunk-1.20.1-3.5.jar |Smoothchunk mod |smoothchunk |1.20.1-3.5 |COMMON_SET|Manifest: NOSIGNATURE
# voicechat-forge-1.20.1-2.4.28.jar |Simple Voice Chat |voicechat |1.20.1-2.4.28 |COMMON_SET|Manifest: NOSIGNATURE
# theoneprobe-1.20.1-10.0.1.jar |The One Probe |theoneprobe |1.20.1-10.0.1 |ERROR |Manifest: NOSIGNATURE""")
#
# report2 = creport("""hearths-v1.0.0-mc1.20u1.20.1.jar |Hearths |hearths |1.0.0-mc1.20u1.20.1 |COMMON_SET|Manifest: NOSIGNATURE
# voicechat-forge-1.20.1-2.4.28.jar |Simple Voice Chat |voicechat |1.20.1-2.4.EXAMPLE |COMMON_SET|Manifest: NOSIGNATURE
# theoneprobe-1.20.1-10.0.1.jar |The One Probe |theoneprobe |1.20.1-10.0.1 |ERROR""")
# print error mods:
# print(report.getError())
# print common mods:
# print(report.common(report2).toString())
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment