[asterisk-dev] Change in repotools[master]: mapmantis: Remove dependency on digium_jira

Matt Jordan (Code Review) asteriskteam at digium.com
Sun Apr 12 16:02:45 CDT 2015


Matt Jordan has uploaded a new change for review.

  https://gerrit.asterisk.org/68

Change subject: mapmantis: Remove dependency on digium_jira
......................................................................

mapmantis: Remove dependency on digium_jira

This patch removes the dependency of mapmantis from the digium_jira
module. The DigiumJIRA class, which uses a SOAP library for its
connection back to JIRA, was not strictly necessary as the Mantis
mapping function made no connection back to the JIRA instance.

Change-Id: I0ae337d24e3db7d552406a57a740d260d5c4d2d7
---
M digium_jira.py
M mapmantis.py
2 files changed, 36 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/68/68/1

diff --git a/digium_jira.py b/digium_jira.py
index abbbfaa..bd4734f 100644
--- a/digium_jira.py
+++ b/digium_jira.py
@@ -137,28 +137,6 @@
                 return f["id"]
         return None
 
-    def map_mantis_to_jira(self, mantis_id):
-        if self.mantis_map is None:
-            try:
-                f = open("mantis-to-jira-map.txt", "r")
-            except:
-                try:
-                    f = open(os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                                  "mantis-to-jira-map.txt"), "r")
-                except:
-                    print "Failed to find mantis-to-jira-map.txt"
-                    return 1
-            self.mantis_map = {}
-            for line in f:
-                fields = line.split("\t")
-                self.mantis_map[fields[0]] = fields[1].strip()
-            f.close()
-
-        if mantis_id in self.mantis_map:
-            return self.mantis_map[mantis_id]
-        else:
-            return None
-
     def status_to_str(self, status):
         if self.status_map is None:
             statuses = self.jira.getStatuses(self.auth)
diff --git a/mapmantis.py b/mapmantis.py
index 243bd35..450bdea 100755
--- a/mapmantis.py
+++ b/mapmantis.py
@@ -1,16 +1,43 @@
 #!/usr/bin/env python
+"""Find a JIRA issue ID based on the Mantis ID
 
-'''
-This module is deprecated since mantis is no longer in use and it requires digium_jira which has been
-deprecated in favor of jira-python
-'''
-
+Copyright (C) 2011-2015, Digium Inc.
+Russell Bryant <russell at russellbryant.com>
+"""
 import sys
 import os
 
 sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__))))
 
-from digium_jira import DigiumJIRA
+
+def map_mantis_to_jira(mantis_id):
+    """Maps a Mantis issue ID to an Atlassian JIRA ID
+
+    Keyword Arguments:
+    mantis_id - the Mantis ID to look up
+
+    Returns:
+    None if no Atlassian JIRA issue is found
+    The Atlassian JIRA issue that maps to the Mantis issue
+    """
+
+    mantis_map = {}
+    try:
+        f = open("mantis-to-jira-map.txt", "r")
+    except:
+        try:
+            f = open(os.path.join(os.path.dirname(os.path.realpath(__file__)),
+                                                  "mantis-to-jira-map.txt"), "r")
+        except:
+            print "Failed to find mantis-to-jira-map.txt"
+            return 1
+
+    for line in f:
+        fields = line.split("\t")
+        mantis_map[fields[0]] = fields[1].strip()
+    f.close()
+
+    return mantis_map.get(mantis_id)
 
 
 def main(argv=None):
@@ -18,12 +45,12 @@
         argv = sys.argv
 
     if len(argv) != 2:
-        print "usage: %s <mantis id>" % os.path.basename(argv[0])
+        print "Usage: %s <mantis id>" % os.path.basename(argv[0])
         return 1
 
-    print DigiumJIRA(soap_access=False).map_mantis_to_jira(argv[1]) or "not found"
-
+    print map_mantis_to_jira(argv[1]) or "No JIRA issue found."
     return 0
 
+
 if __name__ == "__main__":
     sys.exit(main())

-- 
To view, visit https://gerrit.asterisk.org/68
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ae337d24e3db7d552406a57a740d260d5c4d2d7
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>



More information about the asterisk-dev mailing list