From 0a6ca4f6c262750251b97f930c798af19f4170a5 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Fri, 25 Dec 2009 17:37:53 +0100 Subject: [PATCH] - useless use of StringIO() --- osc/commandline.py | 10 +++++----- osc/core.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 6e69699b..87c96368 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4010,12 +4010,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. if len(args) == 1: prj = args[0] m = show_project_meta(conf.config['apiurl'], prj) - tree = ET.parse(StringIO(''.join(m))) + tree = ET.fromstring(''.join(m)) elif len(args) == 2: prj = args[0] pac = args[1] m = show_package_meta(conf.config['apiurl'], prj, pac) - tree = ET.parse(StringIO(''.join(m))) + tree = ET.fromstring(''.join(m)) if not opts.nodevelproject and not opts.delete and not opts.add: while tree.findall('devel'): d = tree.find('devel') @@ -4024,11 +4024,11 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.verbose: print "Following to the development space:", prj, "/", pac m = show_package_meta(conf.config['apiurl'], prj, pac) - tree = ET.parse(StringIO(''.join(m))) + tree = ET.fromstring(''.join(m)) if not tree.findall('person'): print "No dedicated persons in package defined, showing the project persons !" m = show_project_meta(conf.config['apiurl'], prj) - tree = ET.parse(StringIO(''.join(m))) + tree = ET.fromstring(''.join(m)) else: raise oscerr.WrongArgs('I need at least one argument.') @@ -4205,7 +4205,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. u = makeurl(apiurl, ['source', prj, package], query=query) f = http_GET(u) meta = f.readlines() - root_new = ET.parse(StringIO(''.join(meta))).getroot() + root_new = ET.fromstring(''.join(meta)).getroot() dir_new = { 'apiurl': apiurl, 'project': prj, 'package': package } dir_new['srcmd5'] = root_new.get('srcmd5') dir_new['entries'] = [[n.get('name'), n.get('md5')] for n in root_new.findall('entry')] diff --git a/osc/core.py b/osc/core.py index 22e649f5..cb4be65b 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2097,7 +2097,7 @@ def show_attribute_meta(apiurl, prj, pac, subpac, attribute, with_defaults, with def show_develproject(apiurl, prj, pac): m = show_package_meta(apiurl, prj, pac) try: - return ET.parse(StringIO(''.join(m))).getroot().find('devel').get('project') + return ET.fromstring(''.join(m)).getroot().find('devel').get('project') except: return None @@ -2301,14 +2301,14 @@ def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, def show_upstream_srcmd5(apiurl, prj, pac, expand=False, revision=None): m = show_files_meta(apiurl, prj, pac, expand=expand, revision=revision) - return ET.parse(StringIO(''.join(m))).getroot().get('srcmd5') + return ET.fromstring(''.join(m)).getroot().get('srcmd5') def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrepair=False): m = show_files_meta(apiurl, prj, pac, revision=revision, linkrev=linkrev, linkrepair=linkrepair) try: # only source link packages have a element. - li_node = ET.parse(StringIO(''.join(m))).getroot().find('linkinfo') + li_node = ET.fromstring(''.join(m)).getroot().find('linkinfo') except: return None @@ -2322,7 +2322,7 @@ def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrep def show_upstream_rev(apiurl, prj, pac): m = show_files_meta(apiurl, prj, pac) - return ET.parse(StringIO(''.join(m))).getroot().get('rev') + return ET.fromstring(''.join(m)).getroot().get('rev') def read_meta_from_spec(specfile, *args): @@ -3320,7 +3320,7 @@ def get_platforms_of_project(apiurl, prj): def get_repositories_of_project(apiurl, prj): f = show_project_meta(apiurl, prj) - tree = ET.parse(StringIO(''.join(f))) + tree = ET.fromstring(''.join(f)) r = [ node.get('name') for node in tree.findall('repository')] return r @@ -3338,7 +3338,7 @@ class Repo: def get_repos_of_project(apiurl, prj): f = show_project_meta(apiurl, prj) - tree = ET.parse(StringIO(''.join(f))) + tree = ET.fromstring(''.join(f)) for node in tree.findall('repository'): for node2 in node.findall('arch'): @@ -3396,7 +3396,7 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]): result_line_templ = '%(rep)-15s %(arch)-10s %(status)s' f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch) - tree = ET.parse(StringIO(''.join(f))) + tree = ET.fromstring(''.join(f)) root = tree.getroot() for node in root.findall('result'): @@ -3431,7 +3431,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non result_line_templ = '%(rep)-15s %(arch)-10s %(status)s' f = show_prj_results_meta(apiurl, prj) - tree = ET.parse(StringIO(''.join(f))) + tree = ET.fromstring(''.join(f)) root = tree.getroot() pacs = []