jenkins-bot has submitted this change and it was merged.

Change subject: Disentangle tag lists for filtering vs display
......................................................................


Disentangle tag lists for filtering vs display

Bug: T1316
Change-Id: I1170f32bd612f22e27522a2ce75d5491a4b29d2b
---
M channelfilter.py
M messagebuilder.py
M wikibugs.py
3 files changed, 13 insertions(+), 11 deletions(-)

Approvals:
  Yuvipanda: Looks good to me, approved
  Merlijn van Deen: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/channelfilter.py b/channelfilter.py
index b1352c4..6fa0ad4 100644
--- a/channelfilter.py
+++ b/channelfilter.py
@@ -59,7 +59,7 @@
     def channels_for(self, projects):
         """
         :param project: Get all channels to spam for given projects
-        :type project: list
+        :type project: iterable
         """
         channels = set()
         for channel in self.config['channels']:
diff --git a/messagebuilder.py b/messagebuilder.py
index 94b5269..4de168d 100644
--- a/messagebuilder.py
+++ b/messagebuilder.py
@@ -25,6 +25,8 @@
         'resolved': 'Resolved',
     }
 
+    OUTPUT_PROJECT_TYPES = ['briefcase', 'users', 'umbrella']
+
     def colorify(self, text, foreground=None, background=None):
         outtext = "\x03"
         if foreground:
@@ -54,7 +56,15 @@
     def build_message(self, useful_info):
         text = ''
         if useful_info['projects']:
-            text += self.colorify(', '.join(useful_info['projects']), 'green')
+            # This could be either a dict (if we are able to scrape all the 
info)
+            # Or a list, if it could not scrape all the info. Handle both 
cases.
+            if isinstance(useful_info['projects'], dict):
+                visible_projects = [
+                    p for p, info in useful_info['projects'].items()
+                    if info['tagtype'] in self.OUTPUT_PROJECT_TYPES and not 
info['disabled']]
+            else:
+                visible_projects = useful_info['projects']
+            text += self.colorify(', '.join(visible_projects), 'green')
             text += ': '
         text += useful_info['title']
         text += ' - ' + useful_info['url']
diff --git a/wikibugs.py b/wikibugs.py
index d8430d0..58c6219 100644
--- a/wikibugs.py
+++ b/wikibugs.py
@@ -157,14 +157,6 @@
 
         return alltags
 
-    def get_tags_to_display(self, task_page):
-        return [
-            tag
-            for tag, info
-            in self.get_tags(task_page).items()
-            if info["tagtype"] in ["briefcase", "users", "umbrella"] and not 
info["disabled"]
-        ]
-
     def get_anchors_for_task(self, task_page):
         """
         :param url: url to task
@@ -237,7 +229,7 @@
             anchor = ""
 
         try:
-            projects = self.get_tags_to_display(task_page)
+            projects = self.get_tags(task_page)
         except Exception as e:
             if self.raise_errors:
                 raise

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1170f32bd612f22e27522a2ce75d5491a4b29d2b
Gerrit-PatchSet: 4
Gerrit-Project: labs/tools/wikibugs2
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to