2 # Copyright (c) 2016 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """A small library that contains libraries equivalent to six
24 This function is pending upstreaming in six.
28 from __future__
import (
29 absolute_import
, division
, print_function
, unicode_literals
34 def python_2_bool_compatible(class_
):
35 """A decorator to fix __bool__/__nonzero__ name changes."""
38 class_
.__nonzero
__ = class_
.__bool
__
39 except AttributeError:
41 "@python_2_bool_compatible cannot be applied to {} because "
42 "it doesn't define __bool__().".format(class_
.__name
__))
46 # Some version of six don't have this function
48 from six
import python_2_unicode_compatible
50 def python_2_unicode_compatible(class_
):
51 """A decorator to fix __str/__bytes__/__unicode__ name changes."""
55 class_
.__unicode
__ = class_
.__str
__
56 except AttributeError:
60 class_
.__str
__ = class_
.__bytes
__
61 except AttributeError:
64 "@python_2_unicode_compatible cannot be applied to {} "
65 "because it doesn't define __str__() "
66 "or __bytes__().".format(class_
.__name
__))
71 from six
import viewvalues
74 viewvalues
= lambda d
: d
.viewvalues()
76 viewvalues
= lambda d
: d
.values()