Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386765 )

Change subject: Add script to manipulate clover.xml files
......................................................................

Add script to manipulate clover.xml files

Can be used to shrink the size of extremely large clover.xml
files if we only want the cumulative information, and set
a name on the main <project> tag.

Change-Id: I1275e1a50c5992581b914a058159a5c84386d893
---
A bin/clover-edit.py
1 file changed, 52 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins 
refs/changes/65/386765/1

diff --git a/bin/clover-edit.py b/bin/clover-edit.py
new file mode 100755
index 0000000..c4f1c3e
--- /dev/null
+++ b/bin/clover-edit.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+"""
+Edit clover.xml files
+Copyright (C) 2017 Kunal Mehta <lego...@member.fsf.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+"""
+
+import argparse
+import xml.etree.cElementTree as etree
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('clover', help='Path to clover.xml')
+    parser.add_argument('--name', help='Set name in <project> element')
+    parser.add_argument('--remove-full-info',
+                        help='Remove full coverage information, '
+                             'leaving cumulative metrics',
+                        action='store_true')
+    parser.add_argument('--save', help='Location to save to, '
+                                       'otherwise will overrite clover.xml')
+    args = parser.parse_args()
+    tree = etree.parse(args.clover)
+    root = tree.getroot()
+    project = root.getchildren()[0]
+    assert project.tag == 'project'
+    if args.remove_full_info:
+        for child in project.getchildren():
+            # All we want to keep is the final <metrics> tag
+            if child.tag != 'metrics':
+                project.remove(child)
+    if args.name:
+        project.set('name', args.name)
+    save = args.save or args.clover
+    tree.write(save)
+
+
+if __name__ == '__main__':
+    main()

-- 
To view, visit https://gerrit.wikimedia.org/r/386765
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1275e1a50c5992581b914a058159a5c84386d893
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to