pyaxml package

Subpackages

Submodules

pyaxml.arscobject module

class pyaxml.arscobject.ARSC(proto: ARSC = None)

Bases: object

class ResourceResolver(android_resources, config=None)

Bases: object

Resolves resources by ID and configuration. This resolver deals with complex resources as well as with references.

put_ate_value(result: list[str | tuple[ARSCResTableConfig, list] | None], ate: ARSCResTableEntry, config: ARSCResTableConfig | None) None

Put a ResTableEntry into the list of results :param list result: results array :param ARSCResTableEntry ate: :param ARSCResTableConfig config: :return:

put_item_value(result: list[str | tuple[ARSCResTableConfig, list] | None], item, config, parent, complex_: bool) None

Put the tuple (ARSCResTableConfig, resolved string) into the result set

Parameters:
Returns:

resolve(res_id: int) list

the given ID into the Resource and returns a list of matching resources.

Parameters:

res_id (int) – numerical ID of the resource

Returns:

a list of tuples of (ARSCResTableConfig, str)

add_id_public(package: str, type_: str, name: str, path: str) int | None

Add a new id in public string on ARSC resource

Args:

package (str): target package type_ (str): type of public element name (str): name of public element path (str): value of element

Returns:

int | None: return the id injected

compute(recursive=True)

Compute all fields to have all AXML elements

static convert_id(type_id: int, id_: int) int

convert id and type to a general id used on AXML file to refer to resources

Args:

type_id (int): type of value (xml, string, etc.) id (int): index from the list of type value

Returns:

int: the id built

static from_axml(buff: bytes, proto=None)

read an AXML ARSC file to convert in pyaxml.ARSC object

Args:

buff (bytes): the string buffer to read

Returns:

ARSC: the ARSC object str: index of the reading string, if it’s a valid file it should be the EOF.

get_id(package: str, rid: int) tuple[str | None, str | None, int | None]

get id

Args:

package (str): target package rid (int): target rid

Returns:

tuple[str, str, int]: type, key and rid

get_id_public(package: str, type_: str, name: str) tuple[int, int] | None

get ID public from resource

Args:

package (str): package name type_ (str): type string name (str): name of value

Returns:

tuple[int, int] | None: return the id and the stringblock index of the value

static get_local_id_from_id(id_: int) int

get local id from full id

Args:

id_ (int): full id

Returns:

int: id

get_packages() list[str]

get in a list all package name of the resources.

Returns:

list[str]: the list of all packages

property get_proto

_summary_

Returns:

_type_: _description_

get_res_configs(rid: int, config: str | None = None, fallback: bool = True) list[tuple[ARSCResTableConfig, ARSCResTableEntry]]

get ressource configuration

Args:

rid (int): rid value config (_type_, optional): config value. Defaults to None. fallback (bool, optional): fallback value. Defaults to True.

Raises:

ValueError: if rid is not set ValueError: if rid is not the correct type (int)

Returns:

list[tuple[ARSCResTableConfig, ARSCResTableEntry]]: the list of ressource configuration

get_resolved_res_configs(rid: int, config=None) list[tuple]

Return a list of resolved resource IDs with their corresponding configuration. It has a similar return type as get_res_configs() but also handles complex entries and references. Also instead of returning ARSCResTableEntry in the tuple, the actual values are resolved.

This is the preferred way of resolving resource IDs to their resources.

Parameters:
  • rid (int) – the numerical ID of the resource

  • config (ARSCTableResConfig) – the desired configuration or None to retrieve all

Returns:

A list of tuples of (ARSCResTableConfig, str)

get_resource_xml_name(r_id: int, package: str | None = None) str | None

get resource xml name

Args:

r_id (int): rid target package (Union[str, None], optional): target package. Defaults to None.

Returns:

str: xml name from resource

get_type_configs(package_name: str, type_name: str | None = None) dict[str, ARSCResTableConfig]

get type configuration

Args:

package_name (str): _description_ type_name (str, optional): _description_. Defaults to None.

Returns:

dict[str, axml_pb2.ARSCResTableConfig]: type configs

static get_type_from_id(id_: int) int

get type from id

Args:

id_ (int): full id

Returns:

int: type

get_value(package: str, rid: int) str

get value of resource

Args:

package (str): target package rid (int): target rid

Raises:

ValueError: if rid could not be decoded

Returns:

str: value decoded

list_packages()

print all package content

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

class pyaxml.arscobject.AXMLResTablePackage(proto: AXMLResTablePackage = None)

Bases: object

add_id_public(type_: str, name: str, id_path: int)

Add a public id in ARSC

Args:

type_ (str): type of public element name (str): name of public element id_path (int): id of element value to add in public

Returns:

_type_: return the id of this element

compute(recursive: bool = True)

Compute all fields to have all AXML elements

Args:

recursive (bool, optional): need to recompute field recursively. Defaults to True.

static from_axml(buff: bytes, proto=None)

Convert AXMLResTablePackage buffer to AXMLResTablePackage object

Args:

buff (bytes): buffer contain AXMLResTablePackage object

Returns:

tuple[pyaxml.AXMLResTablePackage, bytes]: return AXMLResTablePackage element and buffer offset at the end of the reading

property get_proto

get proto of AXMLResTablePackage

Returns:

_type_: _description_

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

set_spec_entry(id_: int, entry: int, index: int)

Add a spec entry

Args:

id_ (int): id of spec entry entry (int): _description_ index (int): index in typetype stringblock of the element to set

pyaxml.arsctableconfig module

class pyaxml.arsctableconfig.ARSCResTableConfig(proto: ARSCResTableConfig = None)

Bases: object

DENSITY_ANY = 65534
DENSITY_DEFAULT = 0
DENSITY_HIGH = 240
DENSITY_LOW = 120
DENSITY_MEDIUM = 160
DENSITY_NONE = 65535
DENSITY_TV = 213
DENSITY_XHIGH = 320
DENSITY_XXHIGH = 480
DENSITY_XXXHIGH = 640
HDR_ANY = 0
HDR_NO = 4
HDR_YES = 8
KEYBOARD_12KEY = 3
KEYBOARD_ANY = 0
KEYBOARD_NOKEYS = 1
KEYBOARD_QWERTY = 2
KEYSHIDDEN_ANY = 0
KEYSHIDDEN_NO = 1
KEYSHIDDEN_SOFT = 3
KEYSHIDDEN_YES = 2
LAYOUTDIR_ANY = 0
LAYOUTDIR_LTR = 64
LAYOUTDIR_RTL = 128
MASK_HDR = 12
MASK_KEYSHIDDEN = 3
MASK_LAYOUTDIR = 192
MASK_NAVHIDDEN = 12
MASK_SCREENLONG = 48
MASK_SCREENROUND = 3
MASK_SCREENSIZE = 15
MASK_UI_MODE_NIGHT = 48
MASK_UI_MODE_TYPE = 15
MASK_WIDE_COLOR_GAMUT = 3
MINORVERSION_ANY = 0
NAVHIDDEN_ANY = 0
NAVHIDDEN_NO = 4
NAVHIDDEN_YES = 8
NAVIGATION_ANY = 0
NAVIGATION_DPAD = 2
NAVIGATION_NONAV = 1
NAVIGATION_TRACKBALL = 3
NAVIGATION_WHEEL = 4
ORIENTATION_ANY = 0
ORIENTATION_LAND = 2
ORIENTATION_PORT = 1
ORIENTATION_SQUARE = 3
SCREENHEIGHT_ANY = 0
SCREENLONG_ANY = 0
SCREENLONG_NO = 16
SCREENLONG_YES = 32
SCREENROUND_ANY = 0
SCREENROUND_NO = 1
SCREENROUND_YES = 2
SCREENSIZE_ANY = 0
SCREENSIZE_LARGE = 3
SCREENSIZE_NORMAL = 2
SCREENSIZE_SMALL = 1
SCREENSIZE_XLARGE = 4
SCREENWIDTH_ANY = 0
SDKVERSION_ANY = 0
SHIFT_HDR = 2
SHIFT_LAYOUTDIR = 6
SHIFT_NAVHIDDEN = 2
SHIFT_SCREENLONG = 4
SHIFT_UI_MODE_NIGHT = 4
TOUCHSCREEN_ANY = 0
TOUCHSCREEN_FINGER = 3
TOUCHSCREEN_NOTOUCH = 1
TOUCHSCREEN_STYLUS = 2
UI_MODE_NIGHT_ANY = 0
UI_MODE_NIGHT_NO = 16
UI_MODE_NIGHT_YES = 32
UI_MODE_TYPE_ANY = 0
UI_MODE_TYPE_APPLIANCE = 5
UI_MODE_TYPE_CAR = 3
UI_MODE_TYPE_DESK = 2
UI_MODE_TYPE_NORMAL = 1
UI_MODE_TYPE_TELEVISION = 4
UI_MODE_TYPE_VR_HEADSET = 7
UI_MODE_TYPE_WATCH = 6
WIDE_COLOR_GAMUT_ANY = 0
WIDE_COLOR_GAMUT_NO = 1
WIDE_COLOR_GAMUT_YES = 2
compute()

Compute all fields to have all AXML elements

static from_axml(buff: bytes, proto: ARSCResTableConfig = None)

Convert ARSCResTableConfig buffer to ARSCResTableConfig object

Args:

buff (bytes): buffer contain ARSCResTableConfig object

Returns:
tuple[pyaxml.ARSCResTableConfig, bytes]:

return ARSCResTableConfig element and buffer offset at the end of the reading

get_config_name_friendly() str

Here for legacy reasons.

use get_qualifier() instead.

get_country() str

get country

Returns:

str: return country in str

get_density() str

get density

Returns:

str: return density in str

get_language() str

get language

Returns:

str: return language in str

get_language_and_region() str

Returns the combined language+region string or for the default locale :return:

property get_proto

_summary_

Returns:

_type_: _description_

get_qualifier() str

Return resource name qualifier for the current configuration. for example * ldpi-v4 * hdpi-v4

All possible qualifiers are listed in table 2 of https://developer.android.com/guide/topics/resources/providing-resources

You can find how android process this at http://aospxref.com/android-13.0.0_r3/xref/frameworks/base/libs/androidfw/ResourceTypes.cpp#3243

Returns:

str

is_default() bool

Test if this is a default resource, which matches all

This is indicated that all fields are zero. :return: True if default, False otherwise

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

set_language_and_region(language_region: str) None

set language and region

Args:

language_region (str): language region

pyaxml.arsctype module

class pyaxml.arsctype.ARSCComplex(proto: ARSCComplex = None)

Bases: object

compute()

Compute all fields to have all AXML elements

static from_axml(buff: bytes, proto=None) tuple[ARSCComplex, bytes]

Convert ARSCComplex buffer to ARSCComplex object

Args:

buff (bytes): buffer contain ARSCComplex object

Returns:

tuple[pyaxml.ARSCComplex, bytes]: return ARSCComplex element and buffer offset at the end of the reading

property get_proto

_summary_

Returns:

_type_: _description_

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

class pyaxml.arsctype.ARSCResStringPoolRef(proto: ARSCResStringPoolRef = None)

Bases: object

compute()

Compute all fields to have all AXML elements

static from_axml(buff: bytes, proto=None)

Convert ARSCResStringPoolRef buffer to ARSCResStringPoolRef object

Args:

buff (bytes): buffer contain ARSCResStringPoolRef object

Returns:

tuple[pyaxml.ARSCResStringPoolRef, bytes]: return ARSCResStringPoolRef element and buffer offset at the end of the reading

property get_proto

_summary_

Returns:

_type_: _description_

is_reference() bool

Returns True if the Res_value is actually a reference to another resource

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

class pyaxml.arsctype.ARSCResTableEntry(proto: ARSCResTableEntry = None)

Bases: object

FLAG_COMPLEX = 1
FLAG_PUBLIC = 2
FLAG_WEAK = 4
compute()

Compute all fields to have all ARSCResTableEntry elements

static create_element(index_name: int, data: int)

Create a new ARSCResTableEntry element

Args:

index_name (int): The index element data (int): index of data element

Returns:

pyaxml.ARSCResTableEntry: _description_

static from_axml(buff: bytes, proto=None)

Convert ARSCResTableEntry buffer to ARSCResTableEntry object

Args:

buff (bytes): buffer contain ARSCResTableEntry object

Returns:

tuple[pyaxml.ARSCResTableEntry, bytes]: return ARSCResTableEntry element and buffer offset at the end of the reading

property get_proto

_summary_

Returns:

_type_: _description_

is_complex() bool

check if element is complex

Returns:

bool: True if element is complex

is_public() bool

check if element is public

Returns:

bool: True if element is public

is_weak() bool

check if element is weak

Returns:

bool: True if element is weak

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

class pyaxml.arsctype.ARSCResTypeSpec(proto: ARSCResTypeSpec = None)

Bases: object

compute(hnd: AXMLHeader)

Compute all fields to have all AXML elements

static from_axml(buff: bytes, proto=None)

Convert ARSCResTypeSpec buffer to ARSCResTypeSpec object

Args:

buff (bytes): buffer contain ARSCResTypeSpec object

Returns:

tuple[pyaxml.ARSCResTypeSpec, bytes]: return ARSCResTypeSpec element and buffer offset at the end of the reading

property get_proto

_summary_

Returns:

_type_: _description_

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

class pyaxml.arsctype.ARSCResTypeType(proto: ARSCResTypeType = None)

Bases: object

compute(hnd: AXMLHeader, recursive=True)

Compute all fields to have all ARSCResTypeType elements

Args:

hnd (axml_pb2.AXMLHeader): header of ARSCResTypeType element recursive (bool, optional): need to compute all field recursively. Defaults to True.

static create_element(id_: int) ARSCResTypeType

create element ARSCResTypeType

Args:

id_ (int): id

Returns:

ARSCResTypeType: the ARSCResTypeType created

static from_axml(buff: bytes, proto=None)

Convert ARSCResTypeType buffer to ARSCResTypeType object

Args:

buff (bytes): buffer contain ARSCResTypeType object

Returns:

tuple[pyaxml.ARSCResTypeType, bytes]: return ARSCResTypeType element and buffer offset at the end of the reading

property get_proto: ARSCResTypeType

protobuf of ARSCResTypeType

Returns:

axml_pb2.ARSCResTypeType: protobuf of ARSCResTypeType

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

pyaxml.axml module

class pyaxml.axml.AXML(proto: AXML = None)

Bases: object

AXML object to parse AXML and generate AXML

add_all_attrib(root)

Create Resource Map

Args:

root (etree.ElementBase): XML representation of AXML

add_xml_elt(res_xml: ClassicalResXml, header_xml: type[AXMLHeaderResXml])

Function to add an element in function of the type

Args:

res_xml (ClassicalResXml): Element header_xml (AXMLHeaderResXml): Header

compute()

Compute all fields to have all AXML elements

end(attrib: str)

Create end of element

Args:

attrib (str): name of end element

end_namespace(prefix: str, uri: str)

Create end of namespace

Args:

prefix (str): prefix of namespace uri (str): uri of namespace

static from_axml(buff: bytes, proto=None)

Convert AXML buffer to AXML object

Args:

buff (bytes): buffer contain AXML object

Returns:
tuple[pyaxml.AXML, bytes]:

return AXML element and buffer offset at the end of the reading

from_xml(root)

Convert Xml to Axml object

Args:

root (etree.ElementBase): Xml representation of AXML object

get_elt_string(index: int) str

Get string element decoded at index

Args:

index (int): index of target element

Returns:

str: the string element decoded

property get_proto

_summary_

Returns:

_type_: _description_

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

start(root: str, attrib: dict)

Create start of element

Args:

root (str): Name of element attrib (dict): dict of all attribute of this element

start_namespace(prefix: str, uri: str)

Create start of namespace

Args:

prefix (str): prefix of namespace uri (str): uri of namespace

to_xml() Element

Convert AXML to XML to manipulate XML Tree

Returns:

etree.Element: XML element of all AXML files

class pyaxml.axml.AXMLGuess

Bases: object

Guess the AXML type file (AXML or ARSC) and parse it

static from_axml(buff: bytes) AXML | ARSC | None

Guess the AXML type file (AXML or ARSC) and parse it

Returns:

Union[“AXML”, “ARSC”]: the Object AXML file

class pyaxml.axml.ResourceMap(res: List[StringBlock] | None = None, proto: ResourceMap | None = None)

Bases: object

ResourceMap class to build all ResourceMap elements

static from_axml(buff: bytes, proto=None)

Convert ResourceMap buffer to ResourceMap object

Args:

buff (bytes): buffer contain ResourceMap object

Returns:
tuple[pyaxml.ResourceMap, bytes]:

return ResourceMap element and buffer offset at the end of the reading

pack() bytes

pack the ResourceMap element

Returns:

bytes: return the ResourceMap element packed

pyaxml.conf module

Module Configuration.

pyaxml.header module

class pyaxml.header.AConfiguration

Bases: object

COLOR_MODE = 65536
DENSITY = 256
DENSITY_ANY = 65534
DENSITY_DEFAULT = 0
DENSITY_HIGH = 240
DENSITY_LOW = 120
DENSITY_MEDIUM = 160
DENSITY_NONE = 65535
DENSITY_TV = 213
DENSITY_XHIGH = 320
DENSITY_XXHIGH = 480
DENSITY_XXXHIGH = 640
HDR_ANY = 0
HDR_NO = 1
HDR_YES = 2
KEYBOARD = 16
KEYBOARD_12KEY = 3
KEYBOARD_ANY = 0
KEYBOARD_HIDDEN = 32
KEYBOARD_NOKEYS = 1
KEYBOARD_QWERTY = 2
KEYSHIDDEN_ANY = 0
KEYSHIDDEN_NO = 1
KEYSHIDDEN_SOFT = 3
KEYSHIDDEN_YES = 2
LAYOUTDIR = 16384
LAYOUTDIR_ANY = 0
LAYOUTDIR_LTR = 1
LAYOUTDIR_RTL = 2
LOCALE = 4
MCC = 1
MNC = 2
MNC_ZERO = 65535
NAVHIDDEN_ANY = 0
NAVHIDDEN_NO = 1
NAVHIDDEN_YES = 2
NAVIGATION = 64
NAVIGATION_ANY = 0
NAVIGATION_DPAD = 2
NAVIGATION_NONAV = 1
NAVIGATION_TRACKBALL = 3
NAVIGATION_WHEEL = 4
ORIENTATION = 128
ORIENTATION_ANY = 0
ORIENTATION_LAND = 2
ORIENTATION_PORT = 1
ORIENTATION_SQUARE = 3
SCREENLONG_ANY = 0
SCREENLONG_NO = 1
SCREENLONG_YES = 2
SCREENROUND_ANY = 0
SCREENROUND_NO = 1
SCREENROUND_YES = 2
SCREENSIZE_ANY = 0
SCREENSIZE_LARGE = 3
SCREENSIZE_NORMAL = 2
SCREENSIZE_SMALL = 1
SCREENSIZE_XLARGE = 4
SCREEN_HEIGHT_DP_ANY = 0
SCREEN_LAYOUT = 2048
SCREEN_ROUND = 32768
SCREEN_SIZE = 512
SCREEN_WIDTH_DP_ANY = 0
SMALLEST_SCREEN_SIZE = 8192
SMALLEST_SCREEN_WIDTH_DP_ANY = 0
TOUCHSCREEN = 8
TOUCHSCREEN_ANY = 0
TOUCHSCREEN_FINGER = 3
TOUCHSCREEN_NOTOUCH = 1
TOUCHSCREEN_STYLUS = 2
UI_MODE = 4096
UI_MODE_NIGHT_ANY = 0
UI_MODE_NIGHT_NO = 1
UI_MODE_NIGHT_YES = 2
UI_MODE_TYPE_ANY = 0
UI_MODE_TYPE_APPLIANCE = 5
UI_MODE_TYPE_CAR = 3
UI_MODE_TYPE_DESK = 2
UI_MODE_TYPE_NORMAL = 1
UI_MODE_TYPE_TELEVISION = 4
UI_MODE_TYPE_VR_HEADSET = 7
UI_MODE_TYPE_WATCH = 6
VERSION = 1024
WIDE_COLOR_GAMUT_ANY = 0
WIDE_COLOR_GAMUT_NO = 1
WIDE_COLOR_GAMUT_YES = 2
class pyaxml.header.AXMLHeader(type_: int = 0, size: int = 0, proto: AXMLHeader = None, base_proto: AXMLHeader = None)

Bases: object

AXMLHeader class to build an AXMLHeader

static from_axml(buff: bytes, proto=None)

Convert AXMLHeader buffer to AXMLHeader object

Args:

buff (bytes): buffer contain AXMLHeader object

Returns:
tuple[pyaxml.AXMLHeader, bytes]:

return AXMLHeader element and buffer offset at the end of the reading

pack() bytes

pack the AXMLHeader element

Returns:

bytes: return the AXMLHeader element packed

class pyaxml.header.AXMLHeaderRESTABLE(size: int = 0, package_count: int = 0, proto: AXMLHeaderRESTABLE = None)

Bases: object

AXMLHeaderRESTABLE class to build an AXMLHeader with the type RES_RES_TABLE_TYPE

static from_axml(buff: bytes, proto=None)

Convert AXMLHeaderRESTABLE buffer to AXMLHeaderRESTABLE object

Args:

buff (bytes): buffer contain AXMLHeaderRESTABLE object

Returns:
tuple[pyaxml.AXMLHeaderRESTABLE, bytes]:

return AXMLHeaderRESTABLE element and buffer offset at the end of the reading

pack() bytes

pack the AXMLHeader element

Returns:

bytes: return the AXMLHeader element packed

class pyaxml.header.AXMLHeaderXML(size: int = 0, proto: AXMLHeader = None)

Bases: AXMLHeader

AXMLHeaderXML class to build an AXMLHeader with the type RES_XML_TYPE

static from_axml(buff: bytes, proto=None)

Convert AXMLHeaderXML buffer to AXMLHeaderXML object

Args:

buff (bytes): buffer contain AXMLHeaderXML object

Returns:
tuple[pyaxml.AXMLHeaderXML, bytes]:

return AXMLHeaderXML element and buffer offset at the end of the reading

class pyaxml.header.TypedValue

Bases: object

COMPLEX_MANTISSA_MASK = 16777215
COMPLEX_MANTISSA_SHIFT = 8
COMPLEX_RADIX_MASK = 3
COMPLEX_RADIX_SHIFT = 4
COMPLEX_UNIT_MASK = 15
COMPLEX_UNIT_SHIFT = 0
DIMENSION_UNIT_STRS = ['px', 'dip', 'sp', 'pt', 'in', 'mm']
FRACTION_UNIT_STRS = ['%', '%p']
MANTISSA_MULT = 0.00390625
RADIX_MULTS = [0.00390625, 3.0517578125e-05, 1.1920928955078125e-07, 4.656612873077393e-10]
TYPE_ATTRIBUTE = 2
TYPE_DIMENSION = 5
TYPE_FIRST_COLOR_INT = 28
TYPE_FIRST_INT = 16
TYPE_FLOAT = 4
TYPE_FRACTION = 6
TYPE_INT_BOOLEAN = 18
TYPE_INT_COLOR_ARGB4 = 30
TYPE_INT_COLOR_ARGB8 = 28
TYPE_INT_COLOR_RGB4 = 31
TYPE_INT_COLOR_RGB8 = 29
TYPE_INT_DEC = 16
TYPE_INT_HEX = 17
TYPE_LAST_COLOR_INT = 31
TYPE_LAST_INT = 31
TYPE_NULL = 0
TYPE_REFERENCE = 1
TYPE_STRING = 3
static coerce_to_string(typet: int, data: int) str | None

coerce to string

Args:

typet (int): type of value data (int): data link to type

Returns:

str: coerce string

static complex_to_float(complexe: int) float

convert complex to float

Args:

complexe (int): complex value

Returns:

float: float value

static get_type(t: int)

return type of TypedValue

Args:

t (int): UID

Returns:

_type_: type link to UID

pyaxml.public module

pyaxml.stringblocks module

class pyaxml.stringblocks.AXMLHeaderSTRINGPOOL(sb: list | None = None, size: int = 0, proto: AXMLHeaderSTRINGPOOL = None)

Bases: object

AXMLHeaderSTRINGPOOL class to build an AXMLHeaderSTRINGPOOL element

compute()

Compute all fields to have a Stringpool element

static from_axml(buff: bytes, proto=None)

Convert AXMLHeaderSTRINGPOOL buffer to AXMLHeaderSTRINGPOOL object

Args:

buff (bytes): buffer contain AXMLHeaderSTRINGPOOL object

Returns:
tuple[pyaxml.AXMLHeaderSTRINGPOOL, bytes]:

return AXMLHeaderSTRINGPOOL element and buffer offset at the end of the reading

pack() bytes

pack the AXMLHeaderSTRINGPOOL element

Returns:

bytes: return the AXMLHeaderSTRINGPOOL element packed

class pyaxml.stringblocks.StringBlock(data: str = '', size: int = 0, utf8: bool = False, proto: StringBlock = None)

Bases: object

StringBlock class to build an StringBlock element

compute()

Compute all fields to have a StringBlock element

static from_axml(buff: bytes, utf8: bool, proto=None)

Convert StringBlock buffer to StringBlock object

Args:

buff (bytes): buffer contain StringBlock object utf8 (bool) : specify the encoding of string

Returns:
tuple[pyaxml.StringBlock, bytes]:

return StringBlock element and buffer offset at the end of the reading

pack() bytes

pack the StringBlock element

Returns:

bytes: return the StringBlock element packed

class pyaxml.stringblocks.StringBlocks(proto: StringBlocks = None)

Bases: object

StringBlocks class to build all StringBlocks elements

align(buf: bytes) bytes

Align stringblocks elements

Args:

buf (bytes): align the buffer given in input

Returns:

bytes: return the element with padding to align

compute(update_size=False)

Compute all fields to have all StringBlocks elements

decode_str(index: int) str

Decode a stringblock and show its representation in string

Args:

index (int): index of stringblock

Returns:

str: string representation

static from_axml(buff: bytes, proto=None)

Convert StringBlocks buffer to StringBlocks object

Args:

buff (bytes): buffer contain StringBlocks object

Returns:
tuple[pyaxml.StringBlocks, bytes]:

return StringBlocks element and buffer offset at the end of the reading

get(name: str) int

Get index of a stringblock or if it doesn’t exist append a new one.

Args:

name (str): the name of the stringblock

Returns:

int: return the index of the stringblock

index(name: str) int

Get index of a stringblock or if it doesn’t exist raise an error

Args:

name (str): the name of the stringblock

Raises:

ValueError: raise ValueError if this element didn’t exist

Returns:

int: return the index of the stringblock

pack() bytes

pack the StringBlocks element

Returns:

bytes: return the StringBlocks element packed

replace(old_name: str, new_name: str) None

Replace a stringblock by a new one

Args:

old_name (str): old stringblock new_name (str): new stringblock

switch(name1: str, name2: str) None

Switch a name1 stringblock by name2 stringblock

Args:

name1 (str): stringblock 1 name2 (str): stringblock 2

update(index: int, name: str) None

Update the value of stringblock index with the value name

Args:

index (int): index of stringblock name (str): value of stringblock

pyaxml.xmlelement module

class pyaxml.xmlelement.AXMLHeaderEndElement(size: int)

Bases: AXMLHeaderResXml

AXMLHeaderEndElement class to build an header of End element

class pyaxml.xmlelement.AXMLHeaderEndNamespace(size: int)

Bases: AXMLHeaderResXml

AXMLHeaderEndNamespace class to build an header of End namespace

class pyaxml.xmlelement.AXMLHeaderResXml(type_=0, size=0, proto: AXMLHeader = None)

Bases: AXMLHeader

AXMLHeaderResXml class to build an header of RES_XML

class pyaxml.xmlelement.AXMLHeaderStartElement(size: int)

Bases: AXMLHeaderResXml

AXMLHeaderStartElement class to build an header of Start element

class pyaxml.xmlelement.AXMLHeaderStartNamespace(size: int)

Bases: AXMLHeaderResXml

AXMLHeaderStartNamespace class to build an header of Start namespace

class pyaxml.xmlelement.Attribute(namespaceuri: int = 4294967295, name: int = 4294967295, value: int = 4294967295, type_: int = 4294967295, data: int = 4294967295, proto: Attribute = None)

Bases: object

static from_axml(buff, padding=0, proto=None)

Convert Attribute buffer to Attribute object

Args:

buff (bytes): buffer contain Attribute object

Returns:

tuple[pyaxml.Attribute, bytes]: return Attribute element and buffer offset at the end of the reading

pack() bytes

pack the Attribute element

Returns:

bytes: return the Attribute element packed

class pyaxml.xmlelement.ClassicalResXml(linenumber: int = 0, comment: int = 4294967295, proto: ResXML = None)

Bases: object

RES_XML class to build RES_XML element

compute()

Compute all fields to have all RES_XML elements

property content: bytes

get content of classical res XML

Returns:

bytes: content packed

static from_axml(buff: bytes, class_xml=None)

Convert ClassicalResXml buffer to ClassicalResXml object

Args:

buff (bytes): buffer contain ClassicalResXml object class_xml (pyaxml.ClassicalResXml): _description_

Returns:

tuple[pyaxml.ClassicalResXml, bytes]: return ClassicalResXml element and buffer offset at the end of the reading

pack() bytes

pack the RES_XML element

Returns:

bytes: return the RES_XML element packed

proto: ResXML = None
class pyaxml.xmlelement.ResXmlCDATA(proto: ResXMLCDATA = None, lineNumber: int = 0, Comment: int = 4294967295)

Bases: ClassicalResXml

property content

_summary_

Returns:

_type_: _description_

static from_axml(buff, class_xml=None, proto=None)

Convert ResXmlCDATA buffer to ResXmlCDATA object

Args:

buff (bytes): buffer contain ResXmlCDATA object

Returns:

tuple[pyaxml.ResXmlCDATA, bytes]: return ResXmlCDATA element and buffer offset at the end of the reading

class pyaxml.xmlelement.ResXmlEndElement(namespaceURI: int = 4294967295, name: int = 4294967295, lineNumber: int = 0, Comment: int = 4294967295, proto: ResXMLEndElement = None)

Bases: ClassicalResXml

property content: bytes

_summary_

Returns:

bytes: _description_

static from_axml(buff, class_xml=None, proto=None)

Convert ResXmlEndElement buffer to ResXmlEndElement object

Args:

buff (bytes): buffer contain ResXmlEndElement object

Returns:

tuple[pyaxml.ResXmlEndElement, bytes]: return ResXmlEndElement element and buffer offset at the end of the reading

class pyaxml.xmlelement.ResXmlEndNamespace(prefix: int = 4294967295, uri: int = 4294967295, lineNumber: int = 0, Comment: int = 4294967295, proto: ResXMLEndNamespace = None)

Bases: ClassicalResXml

property content

_summary_

Returns:

_type_: _description_

static from_axml(buff: bytes, class_xml=None, proto=None)

Convert ResXmlEndNamespace buffer to ResXmlEndNamespace object

Args:

buff (bytes): buffer contain ResXmlEndNamespace object

Returns:

tuple[pyaxml.ResXmlEndNamespace, bytes]: return ResXmlEndNamespace element and buffer offset at the end of the reading

class pyaxml.xmlelement.ResXmlStartElement(namespaceuri: int = 4294967295, name: int = 4294967295, attributes: list | None = None, styleAttribute: int = -1, classAttribute: int = -1, lineNumber: int = 0, Comment: int = 4294967295, at_start=20, at_size=20, proto: ResXMLStartElement = None)

Bases: ClassicalResXml

compute()

Compute all fields to have all ResXmlStartElement elements

property content: bytes

_summary_

Returns:

bytes: _description_

static from_axml(buff: bytes, class_xml=None, proto=None)

Convert ResXmlStartElement buffer to ResXmlStartElement object

Args:

buff (bytes): buffer contain ResXmlStartElement object

Returns:

tuple[pyaxml.ResXmlStartElement, bytes]: return ResXmlStartElement element and buffer offset at the end of the reading

class pyaxml.xmlelement.ResXmlStartNamespace(prefix: int = 4294967295, uri: int = 4294967295, lineNumber: int = 0, Comment: int = 4294967295, proto: ResXMLStartNamespace = None)

Bases: ClassicalResXml

property content: bytes

_summary_

Returns:

bytes: _description_

static from_axml(buff: bytes, class_xml=None, proto=None)

Convert ResXmlStartNamespace buffer to ResXmlStartNamespace object

Args:

buff (bytes): buffer contain ResXmlStartNamespace object

Returns:

tuple[pyaxml.ResXmlStartNamespace, bytes]: return ResXmlStartNamespace element and buffer offset at the end of the reading

class pyaxml.xmlelement.ResourceXML(proto: ResourceXML = None)

Bases: object

static from_axml(buff: bytes, proto=None)

Convert ResourceXML buffer to ResourceXML object

Args:

buff (bytes): buffer contain ResourceXML object

Returns:

tuple[pyaxml.ResourceXML, bytes]: return ResourceXML element and buffer offset at the end of the reading

pack() bytes

pack the ResourceXML element

Returns:

bytes: return the ResourceXML element packed

Module contents