summaryrefslogtreecommitdiff
path: root/factory/compat.py
diff options
context:
space:
mode:
authornkryptic <nkryptic@gmail.com>2013-03-12 01:08:59 -0400
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-15 01:58:46 +0100
commit6c4f5846c8e21d6e48347b7e661edb72ffabb9f1 (patch)
tree966472532d500451f11a6e63ba27daa1d4d03aeb /factory/compat.py
parent624aedf03974bedb34349d0664fb863935e99969 (diff)
downloadfactory-boy-6c4f5846c8e21d6e48347b7e661edb72ffabb9f1.tar
factory-boy-6c4f5846c8e21d6e48347b7e661edb72ffabb9f1.tar.gz
Add full Python 3 compatibility (Closes #10, #20, #49).
Also: - update travis.yml to build against 2.6-2.7 and 3.2-3.3 - Switch to relative imports Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory/compat.py')
-rw-r--r--factory/compat.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/factory/compat.py b/factory/compat.py
new file mode 100644
index 0000000..a924de0
--- /dev/null
+++ b/factory/compat.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2010 Mark Sandstrom
+# Copyright (c) 2011-2013 Raphaël Barrois
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+
+"""Compatibility tools"""
+
+import sys
+
+is_python2 = (sys.version_info[0] == 2)
+
+if is_python2:
+ string_types = (str, unicode)
+else:
+ string_types = (str,)