소스 검색

Use carrot.utils.partition/rpartition for Python 2.4 compatibility.

Ask Solem 15 년 전
부모
커밋
28f47d1fc3
3개의 변경된 파일12개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 1
      celery/backends/__init__.py
  2. 6 2
      celery/tests/test_log.py
  3. 3 1
      celery/worker/buckets.py

+ 3 - 1
celery/backends/__init__.py

@@ -1,6 +1,8 @@
 import sys
 from functools import partial
 
+from carrot.utils import rpartition
+
 from celery import conf
 
 BACKEND_ALIASES = {
@@ -18,7 +20,7 @@ _backend_cache = {}
 
 def resolve_backend(backend):
     backend = BACKEND_ALIASES.get(backend, backend)
-    backend_module_name, _, backend_cls_name = backend.rpartition(".")
+    backend_module_name, _, backend_cls_name = rpartition(backend, ".")
     return backend_module_name, backend_cls_name
 
 

+ 6 - 2
celery/tests/test_log.py

@@ -1,12 +1,16 @@
 from __future__ import with_statement
+
 import os
 import sys
 import logging
 import unittest
+from tempfile import mktemp
 from StringIO import StringIO
+
+from carrot.utils import rpartition
+
 from celery.log import setup_logger, emergency_error
 from celery.tests.utils import override_stdouts
-from tempfile import mktemp
 
 
 class TestLog(unittest.TestCase):
@@ -50,7 +54,7 @@ class TestLog(unittest.TestCase):
     def test_emergency_error(self):
         sio = StringIO()
         emergency_error(sio, "Testing emergency error facility")
-        self.assertEquals(sio.getvalue().rpartition(":")[2].strip(),
+        self.assertEquals(rpartition(sio.getvalue(), ":")[2].strip(),
                              "Testing emergency error facility")
 
     def test_setup_logger_no_handlers_stream(self):

+ 3 - 1
celery/worker/buckets.py

@@ -1,6 +1,8 @@
 import time
 from Queue import Queue, Empty as QueueEmpty
 
+from carrot.utils import partition
+
 RATE_MODIFIER_MAP = {"s": lambda n: n,
                      "m": lambda n: n / 60.0,
                      "h": lambda n: n / 60.0 / 60.0}
@@ -26,7 +28,7 @@ def parse_ratelimit_string(rate_limit):
             try:
                 return int(rate_limit, base)
             except ValueError:
-                ops, _, modifier = rate_limit.partition("/")
+                ops, _, modifier = partition(rate_limit, "/")
                 return RATE_MODIFIER_MAP[modifier](int(ops, base)) or 0
         return rate_limit or 0
     return 0