Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81176


Change subject: Implement mapping of labels to components
......................................................................

Implement mapping of labels to components

Change-Id: I23bfd2a49c83ffdc18860631f41776b485399d9f
---
M bz.py
M sf.py
2 files changed, 45 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/sf-export 
refs/changes/76/81176/1

diff --git a/bz.py b/bz.py
index 7a82b32..7fced3b 100644
--- a/bz.py
+++ b/bz.py
@@ -17,7 +17,7 @@
     """
     params = {
         'product': 'Pywikibot',
-        'component': '',  # Need to map this
+        'component': find_valid_component(ticket.labels()),  # Need to map this
         'summary': ticket.summary(),
         'version': '',  # ???
         'description': ticket.export(),
@@ -53,4 +53,46 @@
                                 desc,  # Simple description of file
                                 file_name=desc,  # Does this even make sense?
                                 content_type='text/plain'  # python-bugzilla 
says we need to do this
-        )
\ No newline at end of file
+        )
+
+
+def find_valid_component(labels):
+    """
+    Modified slightly from Amir's list...
+    @param labels: current labels on the ticket
+    @return: component to add
+    """
+    components = [
+        'category.py',
+        'copyright.py',
+        'Cosmetic changes',
+        'General',
+        'i18n',
+        'interwiki.py',
+        'login.py',
+        'network',
+        'redirect.py',
+        'solve_disambiguation.py',
+        'weblinkchecker.py',
+        'Wikidata',
+    ]
+    mapping = {
+        'interwiki': 'interwiki.py',
+        'category': 'category.py',
+        'copyright': 'copyright.py',
+        'cosmetic_changes': 'Cosmetic changes',
+        'GUI': 'General',  # GUI is deprecated
+        'login': 'login.py',
+        'other': 'General',
+        'redirect': 'redirect.py',
+        'rewrite': 'General',
+        'solve_disambiguation': 'solve_disambiguation.py',
+        'weblinkchecker': 'weblinkchecker.py',
+    }
+    for label in labels:
+        if label in mapping:
+            return mapping[label]
+        if label in components:
+            return label
+
+    return 'General'
diff --git a/sf.py b/sf.py
index b79e67c..d73dde2 100644
--- a/sf.py
+++ b/sf.py
@@ -7,7 +7,6 @@
 import StringIO
 
 
-
 def parse_ts(ts):
     #2013-08-10 23:36:31.812000
     fmt = "%Y-%m-%d %H:%M:%S.%f"
@@ -59,7 +58,7 @@
             self._json = r.json()
         return self._json
 
-    def label(self):
+    def labels(self):
         return self.json['ticket']['labels']
 
     @property

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23bfd2a49c83ffdc18860631f41776b485399d9f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/sf-export
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

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

Reply via email to