Skip to content

Commit d0148b9

Browse files
committed
-
1 parent bdd42e0 commit d0148b9

File tree

4 files changed

+1583
-6
lines changed

4 files changed

+1583
-6
lines changed

source_py2/python_toolbox/nifty_collections/cute_enum.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# Copyright 2009-2015 Ram Rachum.
22
# This program is distributed under the MIT license.
33

4-
import enum
4+
from python_toolbox.third_party import enum
55
import functools
66

77
from python_toolbox import caching
88

9+
10+
# @orking around Python bug 22506 that would be fixed in Python 3.5:
11+
del enum.EnumMeta.__dir__
12+
# This makes enum members not appear in `dir` but it also prevents other
13+
# important items from being deleted.
14+
915

1016
class EnumType(enum.EnumMeta):
1117
'''Metaclass for our kickass enum type.'''
12-
def __dir__(cls):
13-
# working around Python bug 22506 that would be fixed in Python 3.5.
14-
return object.__dir__(cls) + cls._member_names_
15-
1618
__getitem__ = lambda self, i: self._values_tuple[i]
1719
# This `__getitem__` is important, so we could feed enum types straight
1820
# into `ProductSpace`.
1921

2022
_values_tuple = caching.CachedProperty(tuple)
2123

2224

23-
2425
@functools.total_ordering
2526
class _OrderableEnumMixin(object):
2627
'''
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Copyright (c) 2013, Ethan Furman.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions
6+
are met:
7+
8+
Redistributions of source code must retain the above
9+
copyright notice, this list of conditions and the
10+
following disclaimer.
11+
12+
Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials
15+
provided with the distribution.
16+
17+
Neither the name Ethan Furman nor the names of any
18+
contributors may be used to endorse or promote products
19+
derived from this software without specific prior written
20+
permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)