From fa2fda80544fc9275a92e6a36bd278f3089148e0 Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 27 Sep 2018 14:40:47 -0400 Subject: [PATCH] whoops! forgot -p for json and xml. --- centos/list_pkgs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/centos/list_pkgs.py b/centos/list_pkgs.py index c53b65b..33095b3 100755 --- a/centos/list_pkgs.py +++ b/centos/list_pkgs.py @@ -96,7 +96,10 @@ class PkgIndexer(object): def _gen_json(self): import json - self.report = json.dumps(self.pkgs, default = str, indent = 4) + if self.args['plain']: + self.report = json.dumps([p['name'] for p in self.pkgs], indent = 4) + else: + self.report = json.dumps(self.pkgs, default = str, indent = 4) return() def _gen_xml(self): @@ -106,7 +109,10 @@ class PkgIndexer(object): _attrib = copy.deepcopy(p) for i in ('built', 'installed', 'sizerpm', 'sizedisk'): _attrib[i] = str(_attrib[i]) - _pkg = etree.Element('package', attrib = _attrib) + if self.args['plain']: + _pkg = etree.Element('package', attrib = {'name': p['name']}) + else: + _pkg = etree.Element('package', attrib = _attrib) _xml.append(_pkg) #del(_attrib['name']) # I started to make it a more complex, nested structure... is that necessary? if self.args['header']: