lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fixes to projecthosting_upload.py (issue 5144045)


From: mtsolo
Subject: Fixes to projecthosting_upload.py (issue 5144045)
Date: Tue, 27 Sep 2011 07:34:11 +0000

Reviewers: ,

Message:
Here are some proposed changes to porjecthosting_upload.py that should
help avoid spurious issue creation.

Graham - is there a good way to test this code w/o creating issues on
the tracker, and is there a way I can have push access to your repo on
github so that I can push any changes once you've looked them over.

Cheers,
MS

Description:
Fixes to projecthosting_upload.py

Please review this at http://codereview.appspot.com/5144045/

Affected files:
  M projecthosting_upload.py


Index: projecthosting_upload.py
diff --git a/projecthosting_upload.py b/projecthosting_upload.py
index 6e71d2d3c4bd19c2560d90dc52691490f17bd2e0..803ef8ef16e6d5c6ffd611507118683b6c75f105 100644
--- a/projecthosting_upload.py
+++ b/projecthosting_upload.py
@@ -14,7 +14,12 @@ import gdata.data
 import atom.http_core
 import atom.core

-
+def string_is_number(case):
+  try :
+    int(case)
+    return True
+  except :
+    return False

 class PatchBot():
     client = gdata.projecthosting.client.ProjectHostingClient()
@@ -68,6 +73,11 @@ class PatchBot():
             self.username,
             labels = ["Type-Enhancement", "Patch-new"])

+    def generate_devel_error(self, issue_id) :
+        print "WARNING: could not change issue labels;"
+        print "please email lilypond-devel with the issue",
+        print "number: %i" % issue_id
+
     def update_issue(self, issue_id, description):
         try:
             issue = self.client.update_issue(
@@ -84,8 +94,10 @@ class PatchBot():
                     issue_id,
                     self.username,
                     comment = description)
+                self.generate_devel_error(issue)
                 return issue, "need to email -devel"
             else:
+                self.generate_devel_error(None)
                 issue = None, "need to email -devel"
         return issue, None

@@ -93,24 +105,19 @@ class PatchBot():
         splittext = re.findall(r'\w+', text)
         issue_id = None
         # greedy search for the issue id
-        for i, word in enumerate(splittext):
-            if word in ["fix", "issue", "Fix", "Issue"]:
-                try:
-                    maybe_number = splittext[i+1]
-                    if maybe_number[-1] == ")":
-                        maybe_number = maybe_number[:-1]
-                    issue_id = int(maybe_number)
-                    break
-                except:
-                    pass
-        if not issue_id:
-            try:
-                maybe_number = re.findall(r'\([0-9]+\)', text)
-                issue_id = int(maybe_number[0][1:-1])
-            except:
-                pass
-        return issue_id
-
+        maybe_number = [int(x) for x in re.findall(r'[0-9]+', text)]
+        maybe_number.sort()
+        maybe_number.reverse()
+        return str(issue_id[0]) if maybe_number != [] else None
+
+    def query_user(self, issue = None)
+ query_string1 = "We were not able to associate this patch with a google tracker issue." if issue == None else issue+" will not be used as a google tracker number."
+        print query_string1
+ info = raw_input("Please enter a valid google tracker issue number (or enter nothing to create a new issue): ")
+        while (info != '') and (not string_is_number(info)) :
+ info = raw_input("This is an invalid entry. Please enter either an issue number (just digits, no spaces) or nothing to create an issue: ")
+        return info
+
     def upload(self, issue, patchset, subject="", description=""):
         if not subject:
             subject = "new patch"
@@ -118,13 +125,22 @@ class PatchBot():
         # update or create?
         issue_id = self.find_fix_issue_id(subject+' '+description)
         if issue_id:
-            issue, problem = self.update_issue(issue_id, description)
-            if problem == "need to email -devel":
-                print "WARNING: could not change issue labels;"
-                print "please email lilypond-devel with the issue",
-                print "number: %i" % issue_id
+ print "This has been identified with code.google.com issue "+issue_id+"."
+            correct = raw_input("Is this correct? [y/n (y)]")
+            if correct != 'n' :
+                issue, problem = self.update_issue(issue_id, description)
+            else :
+                issue_id = self.query_user(issue_id)
+                if issue_id :
+ issue, problem = self.update_issue(issue_id, description)
+                else :
+                    self.create_issue(subject, description)
         else:
-            self.create_issue(subject, description)
+            issue_id = self.query_user(issue_id)
+            if issue_id :
+                issue, problem = self.update_issue(issue_id, description)
+            else :
+                self.create_issue(subject, description)
         return True







reply via email to

[Prev in Thread] Current Thread [Next in Thread]