|
|
e94c69 |
From 2f5e186341cef8706c6f720f19142108898e8e93 Mon Sep 17 00:00:00 2001
|
|
|
e94c69 |
From: =?UTF-8?q?Ha=C3=AFkel=20Gu=C3=A9mar?= <hguemar@fedoraproject.org>
|
|
|
e94c69 |
Date: Fri, 5 Sep 2014 14:36:25 +0200
|
|
|
e94c69 |
Subject: [PATCH] Replaced bundled code with using six
|
|
|
e94c69 |
|
|
|
e94c69 |
Conflicts:
|
|
|
e94c69 |
setup.py
|
|
|
e94c69 |
(cherry picked from commit 062c5ba16b414770969871b3494f582402476985)
|
|
|
e94c69 |
---
|
|
|
e94c69 |
requirements.txt | 1 +
|
|
|
e94c69 |
retrying.py | 28 ++--------------------------
|
|
|
e94c69 |
setup.py | 4 ++++
|
|
|
e94c69 |
3 files changed, 7 insertions(+), 26 deletions(-)
|
|
|
e94c69 |
|
|
|
e94c69 |
diff --git a/requirements.txt b/requirements.txt
|
|
|
e94c69 |
index e69de29..ffe2fce 100644
|
|
|
e94c69 |
--- a/requirements.txt
|
|
|
e94c69 |
+++ b/requirements.txt
|
|
|
e94c69 |
@@ -0,0 +1 @@
|
|
|
e94c69 |
+six
|
|
|
e94c69 |
diff --git a/retrying.py b/retrying.py
|
|
|
e94c69 |
index 50fc439..9f0a2a0 100644
|
|
|
e94c69 |
--- a/retrying.py
|
|
|
e94c69 |
+++ b/retrying.py
|
|
|
e94c69 |
@@ -36,35 +36,11 @@
|
|
|
e94c69 |
## ----------------------------------------------------------------------------
|
|
|
e94c69 |
|
|
|
e94c69 |
import random
|
|
|
e94c69 |
+import six
|
|
|
e94c69 |
import sys
|
|
|
e94c69 |
import time
|
|
|
e94c69 |
import traceback
|
|
|
e94c69 |
|
|
|
e94c69 |
-# Python 3 compatibility hacks, pilfered from https://pypi.python.org/pypi/six/1.6.1
|
|
|
e94c69 |
-PY3 = sys.version_info[0] == 3
|
|
|
e94c69 |
-if PY3:
|
|
|
e94c69 |
- def reraise(tp, value, tb=None):
|
|
|
e94c69 |
- if value.__traceback__ is not tb:
|
|
|
e94c69 |
- raise value.with_traceback(tb)
|
|
|
e94c69 |
- raise value
|
|
|
e94c69 |
-
|
|
|
e94c69 |
-else:
|
|
|
e94c69 |
- def exec_(_code_, _globs_=None, _locs_=None):
|
|
|
e94c69 |
- """Execute code in a namespace."""
|
|
|
e94c69 |
- if _globs_ is None:
|
|
|
e94c69 |
- frame = sys._getframe(1)
|
|
|
e94c69 |
- _globs_ = frame.f_globals
|
|
|
e94c69 |
- if _locs_ is None:
|
|
|
e94c69 |
- _locs_ = frame.f_locals
|
|
|
e94c69 |
- del frame
|
|
|
e94c69 |
- elif _locs_ is None:
|
|
|
e94c69 |
- _locs_ = _globs_
|
|
|
e94c69 |
- exec("""exec _code_ in _globs_, _locs_""")
|
|
|
e94c69 |
-
|
|
|
e94c69 |
-
|
|
|
e94c69 |
- exec_("""def reraise(tp, value, tb=None):
|
|
|
e94c69 |
- raise tp, value, tb
|
|
|
e94c69 |
-""")
|
|
|
e94c69 |
|
|
|
e94c69 |
# sys.maxint / 2, since Python 3.2 doesn't have a sys.maxint...
|
|
|
e94c69 |
MAX_WAIT = 1073741823
|
|
|
e94c69 |
@@ -282,7 +258,7 @@ class Attempt(object):
|
|
|
e94c69 |
if wrap_exception:
|
|
|
e94c69 |
raise RetryError(self)
|
|
|
e94c69 |
else:
|
|
|
e94c69 |
- reraise(self.value[0], self.value[1], self.value[2])
|
|
|
e94c69 |
+ six.reraise(self.value[0], self.value[1], self.value[2])
|
|
|
e94c69 |
else:
|
|
|
e94c69 |
return self.value
|
|
|
e94c69 |
|
|
|
e94c69 |
diff --git a/setup.py b/setup.py
|
|
|
e94c69 |
index 7793b8f..1772179 100644
|
|
|
e94c69 |
--- a/setup.py
|
|
|
e94c69 |
+++ b/setup.py
|
|
|
e94c69 |
@@ -29,6 +29,9 @@ CLASSIFIERS = [
|
|
|
e94c69 |
'Topic :: Utilities',
|
|
|
e94c69 |
]
|
|
|
e94c69 |
|
|
|
e94c69 |
+with open('requirements.txt') as file_requirements:
|
|
|
e94c69 |
+ requirements = file_requirements.read().splitlines()
|
|
|
e94c69 |
+
|
|
|
e94c69 |
settings.update(
|
|
|
e94c69 |
name='retrying',
|
|
|
e94c69 |
version='1.2.3',
|
|
|
e94c69 |
@@ -42,6 +45,7 @@ settings.update(
|
|
|
e94c69 |
keywords="decorator decorators retry retrying exception exponential backoff",
|
|
|
e94c69 |
py_modules= ['retrying'],
|
|
|
e94c69 |
test_suite="test_retrying",
|
|
|
e94c69 |
+ install_requires=requirements,
|
|
|
e94c69 |
)
|
|
|
e94c69 |
|
|
|
e94c69 |
|