コード例 #1
0
def permissions(app_id: str,
                lang: str = "en",
                country: str = "us") -> Dict[str, list]:
    dom = post(
        Formats.Permissions.build(lang=lang, country=country),
        Formats.Permissions.build_body(app_id),
        {"content-type": "application/x-www-form-urlencoded"},
    )

    matches = json.loads(Regex.PERMISSIONS.findall(dom)[0])
    container = json.loads(matches[0][2])

    result = {}

    for permission_items in container:
        if isinstance(permission_items, list):
            if len(permission_items[0]) == 2:
                # rearrange layout to fit ElementSpecs
                permission_items = [[
                    "Uncategorized", None, permission_items, None
                ]]

            for permission in permission_items:
                result[ElementSpecs.Permission_Type.extract_content(
                    permission
                )] = ElementSpecs.Permission_List.extract_content(permission)

    return result
コード例 #2
0
def permissions(app_id, lang="en", country="us"):
    # type: (str, str, str) -> dict

    url = Formats.Permissions.build(lang=lang, country=country)
    payload = Formats.PermissionsBodyData.build(app_id)

    dom = post(url, payload,
               {"content-type": "application/x-www-form-urlencoded"})

    matches = json.loads(Regex.PERMISSIONS.findall(dom)[0])
    container = json.loads(matches[0][2])

    result = list()

    for permission_items in container:
        if isinstance(permission_items, list) and len(
                permission_items[0]) == 2:
            #rearrange layout of to fit ElementSpecs
            permission_items = [[
                "Uncategorized", None, permission_items, None
            ]]

        if isinstance(permission_items, list):
            for permission in permission_items:
                group_dict = {}

                for k, spec in ElementSpecs.PermissionGroup.items():
                    group_dict[k] = spec.extract_content(permission)

                for permission in group_dict['permissions']:
                    result.append((group_dict['type'], permission))

    return result
コード例 #3
0
def _fetch_review_items(url, app_id, sort, count, filter_score_with,
                        pagination_token):
    dom = post(
        url,
        Formats.ReviewPayload.build(
            app_id,
            sort,
            count,
            "null" if filter_score_with is None else filter_score_with,
            pagination_token,
        ),
        {"content-type": "application/x-www-form-urlencoded"},
    )

    match = json.loads(Regex.REVIEWS.findall(dom)[0])

    return json.loads(match[0][2])[0], json.loads(match[0][2])[-1][-1]