results sorting

master
JoYo 2022-01-20 12:24:33 -05:00
parent 197aff4402
commit 8640a29b3b
3 changed files with 21 additions and 7 deletions

View File

@ -49,6 +49,9 @@ class _CapstoneBase:
def __len__(self) -> int:
return len(self.disassembly)
def __lt__(self, other):
return len(self) < len(other)
@property
def objdump(self) -> str:
opcodes = str()

View File

@ -28,6 +28,12 @@ class Disassembly(Base):
def __repr__(self):
return f"<Disassembly {json.dumps(self.values, indent=1)}>"
def __len__(self) -> int:
return self.count
def __lt__(self, other):
return len(self) < len(other)
@property
def values(self) -> dict:
values_dict = {

View File

@ -116,13 +116,18 @@ def subdisassem_script():
session.commit()
count = session.query(Disassembly).order_by(desc("count")).first()
tops = (
session.query(Disassembly)
.filter(Disassembly.count == count.count)
.order_by(desc("size"))
.all()
)
tops = list()
for arch in archs:
top = (
session.query(Disassembly)
.filter(Disassembly.arch == arch.__name__)
.order_by(desc("count"))
.first()
)
tops.append(top)
tops = sorted(tops, key=len, reverse=True)
for top in tops[:3]:
logging.info(top)