[icinga-checkins] icinga.org: icinga2/master: changelog.py: Sort by category

git at icinga.org git at icinga.org
Fri Nov 18 15:28:47 CET 2016


Module: icinga2
Branch: master
Commit: aca4af801b17b549589f469d01061ee3dbc4db48
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=aca4af801b17b549589f469d01061ee3dbc4db48

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Fri Nov 18 15:28:27 2016 +0100

changelog.py: Sort by category

fixes #13245

---

 changelog.py |   33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/changelog.py b/changelog.py
index 64c8cb5..e06d7a3 100755
--- a/changelog.py
+++ b/changelog.py
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-import urllib2, json, sys, string
+import urllib2, json, sys, string, collections
 from argparse import ArgumentParser
 
 DESCRIPTION="update release changes"
@@ -60,8 +60,11 @@ def print_category(category, entries):
         if args.html:
             print "<ul>"
 
-        for entry in sorted(entries):
-            print format_logentry(entry)
+        tmp_entries = collections.OrderedDict(sorted(entries.items()))
+
+        for cat, entry_list in tmp_entries.iteritems():
+            for entry in entry_list:
+                print format_logentry(entry)
 
         if args.html:
             print "</ul>"
@@ -108,9 +111,10 @@ if changes:
 
 offset = 0
 
-features = []
-bugfixes = []
-support = []
+features = {}
+bugfixes = {}
+support = {}
+category = ""
 
 while True:
     # We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
@@ -136,7 +140,7 @@ while True:
                 continue
 
         if "category" in issue:
-            category = issue["category"]["name"]
+            category = str(issue["category"]["name"])
         else:
             category = "no category"
 
@@ -144,11 +148,20 @@ while True:
         entry = (issue["tracker"]["name"], issue["id"], category, issue["subject"].strip())
 
 	if issue["tracker"]["name"] == "Feature":
-            features.append(entry)
+            try:
+                features[category].append(entry)
+            except KeyError:
+                features[category] = [ entry ]
 	elif issue["tracker"]["name"] == "Bug":
-            bugfixes.append(entry)
+            try:
+                bugfixes[category].append(entry)
+            except KeyError:
+                bugfixes[category] = [ entry ]
 	elif issue["tracker"]["name"] == "Support":
-            support.append(entry)
+            try:
+                support[category].append(entry)
+            except KeyError:
+                support[category] = [ entry ]
 
 print_category("Feature", features)
 print_category("Bugfixes", bugfixes)



More information about the icinga-checkins mailing list