poco.sdk.AbstractDumper module

class IDumper[源代码]

基类:object

This interface defines the standard dumper behavior. Dumper class is introduced to get the hierarchy information and convert it into serializable data.

getRoot()[源代码]

Return the root node of the UI Hierarchy. The node information is wrapped by AbstractNode. See definition of AbstractNode for more details.

返回:instance that holds the hierarchy data
返回类型:inherit from AbstractNode
dumpHierarchy(onlyVisibleNode)[源代码]

Return the json serializable dictionary holding the hierarchy data. Refer to sample of returned structure object below.

Structure of the dict:

{
    # name can be duplicated from the original name or just left the default one
    # if it cannot be determined, however providing some meaningful name is preferred
    'name': '<a recognizable string>'

    # All available attributes of this node are in form of key-value pairs
    'payload': {
        'name': '',
        'pos': [0, 0],
        'size': [1, 1],
        ...
    },

    # If there is no child, this part can be omitted
    'children': [
        {...},  # Same structure as this dict.
    ],
}
返回:hierarchy data or None
返回类型:dict or NoneType
class AbstractDumper[源代码]

基类:poco.sdk.AbstractDumper.IDumper

This class partially implements IDumper using general traversal algorithm. In order to dump the hierarchy from the root node, this dumper first retrieves all available attributes of the root node and also the list all its children and then applies the same procedures as described on each child (i.e. treats each child as a root node) until the node that has no child(ren) is reached.

dumpHierarchy(onlyVisibleNode=True)[源代码]
返回:json serializable dict holding the whole hierarchy data
返回类型:dict
dumpHierarchyImpl(node, onlyVisibleNode=True)[源代码]

Crawl the hierarchy tree using the simple DFS algorithm. The dump procedure is the engine independent as the hierarchy structure is wrapped by AbstractNode and therefore the dump procedure can be algorithmized.

Following code demonstrates the simplest implementation. Feel free to implement your own algorithms to optimize the performance.

注解

Do not explicitly call this method as this is an internal function, call dumpHierarchy() function instead if you want to dump the hierarchy.

参数:
  • node (inherit from AbstractNode) – root node of the hierarchy to be dumped
  • onlyVisibleNode (bool) – dump only the visible nodes or all nodes, default to True
返回:

json serializable dict holding the whole hierarchy data

返回类型:

dict