You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2017/08/06 23:32:31 UTC
svn commit: r1804279 [1/2] - in /poi/site/src/documentation/content/xdocs:
status.copy_module_from_bugzilla.py status.xml
Author: onealj
Date: Sun Aug 6 23:32:31 2017
New Revision: 1804279
URL: http://svn.apache.org/viewvc?rev=1804279&view=rev
Log:
add module (copied from Bugzilla component) to changelog of all older releases
Added:
poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py (with props)
Modified:
poi/site/src/documentation/content/xdocs/status.xml
Added: poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py?rev=1804279&view=auto
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py (added)
+++ poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py Sun Aug 6 23:32:31 2017
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+"""
+ ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ====================================================================
+"""
+
+"""This is a really crude throwaway script to get data out of Bugzilla and into status.xml
+It'd be far better to have Forrest look this information up whenever the site is rebuilt.
+Hopefully this is a one time effort
+If a closed bug's component is changed in Bugzilla, this script could be used to keep the changelog in sync.
+
+requires Python 2.7 or 3.1+
+"""
+
+import csv, io
+import sys
+import requests
+
+def get_fixesbug_attr(line):
+ pieces = [x.strip() for x in line.split('"')]
+ bugs = pieces[pieces.index('fixes-bug=') + 1]
+ return bugs
+
+def get_bugzilla_bug_to_component():
+ bugzilla_bug_to_component = {}
+ r = requests.get('https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__all__&limit=0&no_redirect=1&product=POI&query_format=advanced&ctype=csv&human=1')
+ with io.StringIO(r.text) as f:
+ csvreader = csv.DictReader(f)
+ for row in csvreader:
+ bugzilla_bug_to_component[row['Bug ID']] = row['Component']
+ return bugzilla_bug_to_component
+
+
+def add_module_frombugzilla_attr(line):
+ """Add module_frombugzilla="XSSF" to <action ...> tag
+
+ line is a string, containing the <action> opening tag
+ """
+ global bugzilla_bug_to_component
+ assert 'module-frombugzilla' not in line
+ bugs = [x.strip() for x in get_fixesbug_attr(line).split(',')]
+ modules = filter(bool, [bugzilla_bug_to_component.get(bug) for bug in bugs])
+ module_frombugzilla = ','.join(modules)
+ line_with_module_frombugzilla = line.replace('>', ' module="{}">'.format(module_frombugzilla), 1)
+ return line_with_module_frombugzilla
+
+def add_module_attribute(inputfile, outputfile):
+ with open(inputfile, 'r') as infile, open(outputfile, 'w') as outfile:
+ for line in infile:
+ if '<action ' in line and ' fixes-bug=' in line and ' module=' not in line:
+ # append "module="XXXX" at end of <action> tag
+ outfile.write(add_module_frombugzilla_attr(line))
+ else:
+ outfile.write(line)
+
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print('Usage: python changelog.py inputfile outputfile')
+ else:
+ bugzilla_bug_to_component = get_bugzilla_bug_to_component()
+ add_module_attribute(sys.argv[1], sys.argv[2])
\ No newline at end of file
Propchange: poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/site/src/documentation/content/xdocs/status.copy_module_from_bugzilla.py
------------------------------------------------------------------------------
svn:mime-type = text/x-python
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org