mirror of
https://github.com/lilydjwg/nvchecker
synced 2024-12-27 09:02:19 +00:00
Improve android_sdk version extractor
* Add README * Update author info * Cache repo manifests
This commit is contained in:
parent
bb3fa58481
commit
5df11f7b1a
11
README.rst
11
README.rst
@ -37,6 +37,7 @@ Contents
|
||||
* `Check Debian Linux official packages <#check-debian-linux-official-packages>`_
|
||||
* `Check Ubuntu Linux official packages <#check-ubuntu-linux-official-packages>`_
|
||||
* `Check Anitya (release-monitoring.org) <#check-anitya>`_
|
||||
* `Check Android SDK <#check-android-sdk>`_
|
||||
* `Manually updating <#manually-updating>`_
|
||||
* `Version Control System (VCS) (git, hg, svn, bzr) <#version-control-system-vcs-git-hg-svn-bzr>`_
|
||||
* `Other <#other>`_
|
||||
@ -380,6 +381,16 @@ This enables you to track updates from `Anitya <https://release-monitoring.org/>
|
||||
anitya
|
||||
``distro/package``, where ``distro`` can be a lot of things like "fedora", "arch linux", "gentoo", etc. ``package`` is the package name of the chosen distribution.
|
||||
|
||||
Check Android SDK
|
||||
-----------------
|
||||
This enables you to track updates of Android SDK packages listed in ``sdkmanager --list``.
|
||||
|
||||
android_sdk
|
||||
The package path prefix. This value is matched against the ``path`` attribute in all <remotePackage> nodes in an SDK manifest XML. The first match is used for version comparisions.
|
||||
|
||||
repo
|
||||
Should be one of ``addon`` or ``package``. Packages in ``addon2-1.xml`` use ``addon`` and packages in ``repository2-1.xml`` use ``package``.
|
||||
|
||||
Manually updating
|
||||
-----------------
|
||||
This enables you to manually specify the version (maybe because you want to approve each release before it gets to the script).
|
||||
|
@ -1,5 +1,5 @@
|
||||
# MIT licensed
|
||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||
# Copyright (c) 2017 Yen Chi Hsuan <yan12125 at gmail dot com>
|
||||
|
||||
import os
|
||||
import re
|
||||
@ -7,19 +7,33 @@ from xml.etree import ElementTree
|
||||
|
||||
from . import session
|
||||
|
||||
ANDROID_REPO_MANIFESTS = {
|
||||
_ANDROID_REPO_MANIFESTS = {
|
||||
'addon': 'https://dl.google.com/android/repository/addon2-1.xml',
|
||||
'package': 'https://dl.google.com/android/repository/repository2-1.xml',
|
||||
}
|
||||
|
||||
async def get_version(name, conf):
|
||||
repo_xml_url = ANDROID_REPO_MANIFESTS[conf['repo']]
|
||||
pkg_path_prefix = conf['android_sdk']
|
||||
_repo_manifests_cache = {}
|
||||
|
||||
async def _get_repo_manifest(repo):
|
||||
if repo in _repo_manifests_cache:
|
||||
return _repo_manifests_cache[repo]
|
||||
|
||||
repo_xml_url = _ANDROID_REPO_MANIFESTS[repo]
|
||||
|
||||
async with session.get(repo_xml_url) as res:
|
||||
data = (await res.read()).decode('utf-8')
|
||||
|
||||
repo_manifest = ElementTree.fromstring(data)
|
||||
_repo_manifests_cache[repo] = repo_manifest
|
||||
|
||||
return repo_manifest
|
||||
|
||||
async def get_version(name, conf):
|
||||
repo = conf['repo']
|
||||
pkg_path_prefix = conf['android_sdk']
|
||||
|
||||
repo_manifest = await _get_repo_manifest(repo)
|
||||
|
||||
for pkg in repo_manifest.findall('.//remotePackage'):
|
||||
if not pkg.attrib['path'].startswith(pkg_path_prefix):
|
||||
continue
|
||||
|
@ -1,5 +1,5 @@
|
||||
# MIT licensed
|
||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||
# Copyright (c) 2017 Yen Chi Hsuan <yan12125 at gmail dot com>
|
||||
|
||||
import pytest
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
Loading…
Reference in New Issue
Block a user