32 lines
980 B
Python
32 lines
980 B
Python
from dataclasses import dataclass, astuple, fields
|
|
from typing import Self
|
|
|
|
|
|
@dataclass
|
|
class ApkData:
|
|
sha256: str
|
|
nb_duplicate_classes: int
|
|
nb_platform_32_classes: int
|
|
nb_platform_non_sdk_32_classes: int
|
|
nb_sdk_32_classes: int
|
|
nb_platform_33_classes: int
|
|
nb_platform_non_sdk_33_classes: int
|
|
nb_sdk_33_classes: int
|
|
nb_platform_34_classes: int
|
|
nb_platform_non_sdk_34_classes: int
|
|
nb_sdk_34_classes: int
|
|
has_classes0_dex: bool
|
|
has_classes1_dex: bool
|
|
has_classes0X_dex: bool
|
|
has_classes_dex_over_10: bool
|
|
has_non_numeric_classes_dex: bool
|
|
has_non_consecutive_classes_dex: bool
|
|
|
|
def to_string(self) -> str:
|
|
return "|".join(map(str, astuple(self)))
|
|
|
|
@staticmethod
|
|
def from_string(val: str) -> "ApkData":
|
|
return ApkData(
|
|
*(map(lambda f_v: f_v[1] == "True" if f_v[0].type is bool else f_v[0].type(f_v[1]), zip(fields(ApkData), val.strip().split("|")))) # type: ignore
|
|
)
|