Commits

Henrique Romano  committed a2dbe0a

trac.patches doesn't need to be dependent of server.get_proxy

  • Participants
  • Parent commits 82fa121

Comments (0)

Files changed (2)

File djangotriager/trac/patches.py

 from subprocess import Popen, PIPE
 
-from djangotriager.trac.server import get_proxy
-
 class Patch(object):
     """A class to help working with patches.
 
     MAX_APPLY_ATTEMPTS = 2
     VALID_EXTENSIONS = ("diff", "patch")
 
-    def __init__(self, config, ticket_id, patch_id):
-        proxy = get_proxy(config.get("trac"))
+    def __init__(self, patch_id, content):
         self._patch_id = patch_id
-        self._content = str(proxy.ticket.getAttachment(ticket_id, patch_id))
+        self._content = content
 
     def __repr__(self):
         return "<Patch %r>" % self._patch_id

File djangotriager/trac/tickets.py

         if not self.__patches:
             proxy = get_proxy(config.get("trac"))
             attachments = proxy.ticket.listAttachments(self._ticket_id)
-            self.__patches = [Patch(config, self._ticket_id, file[0]) 
-                                  for file in attachments 
-                                      if Patch.validate(file[0])]
+            getAttachment = proxy.ticket.getAttachment
+            self.__patches = \
+                [Patch(file[0], str(getAttachment(self._ticket_id, file[0])))
+                     for file in attachments if Patch.validate(file[0])]
             self._reporter.warn("Patches retrieved: %r" % self.__patches)
         return self.__patches