pyaxml package

Subpackages

Submodules

pyaxml.axml module

class pyaxml.axml.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.axml.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, ate: ARSCResTableEntry, config) 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, 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

convert_id(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

from_axml(proto=None)

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

Args:

buff (str): 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)
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

get_local_id_from_id() int
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=None, fallback: bool = True) list
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
get_type_configs(package_name, type_name=None)
get_type_from_id() int
get_value(package: str, rid: int)
list_packages()

print all package content

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

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

Bases: object

compute()

Compute all fields to have all AXML elements

from_axml(proto=None)

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.axml.ARSCResStringPoolRef(proto: ARSCResStringPoolRef = None)

Bases: object

compute()

Compute all fields to have all AXML elements

from_axml(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.axml.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

from_axml(proto=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_density() str
get_language() 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)
class pyaxml.axml.ARSCResTableEntry(proto: ARSCResTableEntry = None)

Bases: object

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

Compute all fields to have all ARSCResTableEntry elements

create_element(data: int)

Create a new ARSCResTableEntry element

Args:

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

Returns:

pyaxml.ARSCResTableEntry: _description_

from_axml(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.axml.ARSCResTypeSpec(proto: ARSCResTypeSpec = None)

Bases: object

compute(hnd: AXMLHeader)

Compute all fields to have all AXML elements

from_axml(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.axml.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.

create_element()
from_axml(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

_summary_

Returns:

_type_: _description_

pack() bytes

pack the AXML element

Returns:

bytes: return the AXML element packed

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

Bases: object

add_all_attrib(root)

Create Resource Map

Args:

root (etree.ElementBase): XML representation of AXML

add_xml_elt(res_xml: Classical_RES_XML, header_xml: AXMLHeader_RES_XML)

Function to add an element in function of the type

Args:

res_xml (Classical_RES_XML): Element header_xml (AXMLHeader_RES_XML): 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

from_axml(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.AXMLHeader(type: int = 0, size: int = 0, proto: AXMLHeader = None, base_proto: AXMLHeader = None)

Bases: object

AXMLHeader class to build an AXMLHeader

from_axml(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.axml.AXMLHeader_END_ELEMENT(size: int)

Bases: AXMLHeader_RES_XML

AXMLHeader_END_ELEMENT class to build an header of End element

class pyaxml.axml.AXMLHeader_END_NAMESPACE(size: int)

Bases: AXMLHeader_RES_XML

AXMLHeader_END_NAMESPACE class to build an header of End namespace

class pyaxml.axml.AXMLHeader_RES_TABLE(size: int = 0, package_count: int = 0, proto: AXMLHeader_RES_TABLE = None)

Bases: object

AXMLHeader_RES_TABLE class to build an AXMLHeader with the type RES_RES_TABLE_TYPE

from_axml(proto=None)

Convert AXMLHeader_RES_TABLE buffer to AXMLHeader_RES_TABLE object

Args:

buff (bytes): buffer contain AXMLHeader_RES_TABLE object

Returns:

tuple[pyaxml.AXMLHeader_RES_TABLE, bytes]: return AXMLHeader_RES_TABLE 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.axml.AXMLHeader_RES_XML(type=0, size=0, proto: AXMLHeader = None)

Bases: AXMLHeader

AXMLHeader_RES_XML class to build an header of RES_XML

class pyaxml.axml.AXMLHeader_START_ELEMENT(size: int)

Bases: AXMLHeader_RES_XML

AXMLHeader_START_ELEMENT class to build an header of Start element

class pyaxml.axml.AXMLHeader_START_NAMESPACE(size: int)

Bases: AXMLHeader_RES_XML

AXMLHeader_START_NAMESPACE class to build an header of Start namespace

class pyaxml.axml.AXMLHeader_STRING_POOL(sb: list = None, size: int = 0, proto: AXMLHeader_STRING_POOL = None)

Bases: object

AXMLHeader_STRING_POOL class to build an AXMLHeader_STRING_POOL element

compute()

Compute all fields to have a Stringpool element

from_axml(proto=None)

Convert AXMLHeader_STRING_POOL buffer to AXMLHeader_STRING_POOL object

Args:

buff (bytes): buffer contain AXMLHeader_STRING_POOL object

Returns:

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

pack() bytes

pack the AXMLHeader_STRING_POOL element

Returns:

bytes: return the AXMLHeader_STRING_POOL element packed

class pyaxml.axml.AXMLHeader_XML(size: int = 0, proto: AXMLHeader = None)

Bases: AXMLHeader

AXMLHeader_XML class to build an AXMLHeader with the type RES_XML_TYPE

from_axml(proto=None)

Convert AXMLHeader_XML buffer to AXMLHeader_XML object

Args:

buff (bytes): buffer contain AXMLHeader_XML object

Returns:

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

class pyaxml.axml.AXML_Res_Table_Package(proto: AXML_Res_Table_Package = 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.

from_axml(proto=None)

Convert AXML_Res_Table_Package buffer to AXML_Res_Table_Package object

Args:

buff (bytes): buffer contain AXML_Res_Table_Package object

Returns:

tuple[pyaxml.AXML_Res_Table_Package, bytes]: return AXML_Res_Table_Package 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

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

class pyaxml.axml.AXML_guess

Bases: object

from_axml()
class pyaxml.axml.Attribute(namespaceURI: int = 4294967295, name: int = 4294967295, value: int = 4294967295, type: int = 4294967295, data: int = 4294967295, proto: Attribute = None)

Bases: object

from_axml(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.axml.Classical_RES_XML(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
from_axml(class_xml)

Convert Classical_RES_XML buffer to Classical_RES_XML object

Args:

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

Returns:

tuple[pyaxml.Classical_RES_XML, bytes]: return Classical_RES_XML 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

class pyaxml.axml.RES_XML_CDATA(proto: ResXMLCDATA = None)

Bases: Classical_RES_XML

property content

_summary_

Returns:

_type_: _description_

from_axml(proto=None)

Convert RES_XML_CDATA buffer to RES_XML_CDATA object

Args:

buff (bytes): buffer contain RES_XML_CDATA object

Returns:

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

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

Bases: Classical_RES_XML

property content: bytes

_summary_

Returns:

bytes: _description_

from_axml(proto=None)

Convert RES_XML_END_ELEMENT buffer to RES_XML_END_ELEMENT object

Args:

buff (bytes): buffer contain RES_XML_END_ELEMENT object

Returns:

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

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

Bases: Classical_RES_XML

property content

_summary_

Returns:

_type_: _description_

from_axml(proto=None)

Convert RES_XML_END_NAMESPACE buffer to RES_XML_END_NAMESPACE object

Args:

buff (bytes): buffer contain RES_XML_END_NAMESPACE object

Returns:

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

class pyaxml.axml.RES_XML_START_ELEMENT(namespaceURI: int = 4294967295, name: int = 4294967295, attributes: list = [], styleAttribute: int = -1, classAttribute: int = -1, lineNumber: int = 0, Comment: int = 4294967295, at_start=20, at_size=20, proto: ResXMLStartElement = None)

Bases: Classical_RES_XML

compute()

Compute all fields to have all RES_XML_START_ELEMENT elements

property content: bytes

_summary_

Returns:

bytes: _description_

from_axml(proto=None)

Convert RES_XML_START_ELEMENT buffer to RES_XML_START_ELEMENT object

Args:

buff (bytes): buffer contain RES_XML_START_ELEMENT object

Returns:

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

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

Bases: Classical_RES_XML

property content: bytes

_summary_

Returns:

bytes: _description_

from_axml(proto=None)

Convert RES_XML_START_NAMESPACE buffer to RES_XML_START_NAMESPACE object

Args:

buff (bytes): buffer contain RES_XML_START_NAMESPACE object

Returns:

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

class pyaxml.axml.ResourceMap(res: [<class 'pyaxml.axml.StringBlock'>] = [], proto: ~src.pyaxml.proto.axml_pb2.ResourceMap = None)

Bases: object

ResourceMap class to build all ResourceMap elements

from_axml(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

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

Bases: object

from_axml(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

class pyaxml.axml.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

from_axml(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.axml.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
from_axml(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)
switch(name1: str, name2: str)
update(index: int, name: str)
class pyaxml.axml.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
coerceToString(data: int)
complexToFloat()
get_type()

pyaxml.conf module

Module contents