Ladsgroup has submitted this change and it was merged.
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, 47 insertions(+), 4 deletions(-)
Approvals:
Ladsgroup: Verified; Looks good to me, approved
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..c44bc44 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
@@ -123,6 +122,8 @@
t += 'Originally from: {0}\n'.format(self.human_url())
t += 'Created on:
{0}\n'.format(parse_ts(self.json['ticket']['created_date']))
t += 'Subject: {0}\n'.format(self.summary())
+ if len(self.labels()) > 1:
+ t+= 'Original labels: ' + ', '.join(self.labels())
t += 'Original description:\n{0}\n'.format(self.description())
#for cmt in self.comments():
# t += '---------\n'
--
To view, visit https://gerrit.wikimedia.org/r/81176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I23bfd2a49c83ffdc18860631f41776b485399d9f
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/sf-export
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits