|
| 1 | +from __future__ import absolute_import |
| 2 | +import six |
| 3 | +from six.moves import range |
1 | 4 |
|
2 | 5 |
|
3 | 6 | class OpenShiftPythonException(Exception): |
@@ -116,16 +119,16 @@ def _element_can_match( master, test, case_insensitive=False): |
116 | 119 | return master is test |
117 | 120 |
|
118 | 121 | if isinstance(master, str): |
119 | | - master = unicode(master) # Turn str into unicode |
| 122 | + master = six.text_type(master) # Turn str into unicode |
120 | 123 | if case_insensitive: |
121 | 124 | master = master.lower() |
122 | 125 |
|
123 | 126 | if isinstance(test, str): |
124 | | - test = unicode(test) # Turn str into unicode |
| 127 | + test = six.text_type(test) # Turn str into unicode |
125 | 128 | if case_insensitive: |
126 | 129 | test = test.lower() |
127 | 130 |
|
128 | | - for prim in [bool, int, unicode, float]: |
| 131 | + for prim in [bool, int, six.text_type, float]: |
129 | 132 | if isinstance(master, prim): |
130 | 133 | return master == test or str(master) == str(test) |
131 | 134 |
|
@@ -240,7 +243,7 @@ def __init__(self, dict_to_model=None, case_insensitive=False): |
240 | 243 |
|
241 | 244 | def __getattr__(self, attr): |
242 | 245 |
|
243 | | - if isinstance(attr, basestring): |
| 246 | + if isinstance(attr, six.string_types): |
244 | 247 | if attr.startswith('_Model__'): # e.g. _Model__case_insensitive |
245 | 248 | raise AttributeError |
246 | 249 |
|
@@ -283,7 +286,7 @@ def _primitive(self): |
283 | 286 | :rtype: dict |
284 | 287 | """ |
285 | 288 | d = {} |
286 | | - for k, v in self.iteritems(): |
| 289 | + for k, v in six.iteritems(self): |
287 | 290 | if isinstance(v, Model) or isinstance(v, ListModel): |
288 | 291 | v = v._primitive() |
289 | 292 | d[k] = v |
|
0 commit comments