From 98397ea75829e559089a2bd7b61e8bd8e23fd2ae Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Wed, 14 Jun 2017 23:50:28 -0500 Subject: [PATCH] core: provide package_list() and utilize in issue-diff.py. --- issue-diff.py | 11 +---------- osclib/core.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 osclib/core.py diff --git a/issue-diff.py b/issue-diff.py index 1d3e3419..ecfd4c37 100755 --- a/issue-diff.py +++ b/issue-diff.py @@ -21,6 +21,7 @@ import osc.conf import osc.core from osclib.cache import Cache +from osclib.core import package_list # Issue summary can contain unicode characters and therefore a string containing # either summary or one in which ISSUE_SUMMARY is then placed must be unicode. @@ -204,16 +205,6 @@ def issues_get(apiurl, project, package, trackers, db): return issues -def package_list(apiurl, project): - url = osc.core.makeurl(apiurl, ['source', project], { 'expand': 1 }) - root = ET.parse(osc.core.http_GET(url)).getroot() - - packages = [] - for package in root.findall('entry'): - packages.append(package.get('name')) - - return sorted(packages) - def git_clone(url, directory): return_code = subprocess.call(['git', 'clone', url, directory]) if return_code != 0: diff --git a/osclib/core.py b/osclib/core.py new file mode 100644 index 00000000..61f83862 --- /dev/null +++ b/osclib/core.py @@ -0,0 +1,17 @@ +from xml.etree import cElementTree as ET + +from osc.core import http_GET +from osc.core import makeurl + +from osclib.memoize import memoize + +@memoize(session=True) +def package_list(apiurl, project): + url = makeurl(apiurl, ['source', project], { 'expand': 1 }) + root = ET.parse(http_GET(url)).getroot() + + packages = [] + for package in root.findall('entry'): + packages.append(package.get('name')) + + return sorted(packages)