Skip to content

Commit 1519f25

Browse files
committed
-
1 parent ae94a53 commit 1519f25

File tree

12 files changed

+206
-703
lines changed

12 files changed

+206
-703
lines changed

source_py2/python_toolbox/arguments_profiling.py

Lines changed: 0 additions & 505 deletions
This file was deleted.

source_py2/python_toolbox/collection_tools.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

source_py2/python_toolbox/comparison_tools.py

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,8 @@
88

99
def underscore_hating_key(string):
1010
'''Key function for sorting that treats `_` as last character.'''
11-
assert isinstance(string, basestring)
12-
return unicode(string).replace('_', unichr(sys.maxunicode))
13-
14-
15-
def total_ordering(cls):
16-
'''
17-
Add full arsenal of ordering methods to a class based on existing subset.
18-
'''
19-
convert = {
20-
'__lt__': [('__gt__', lambda self, other:
21-
not (self < other or self == other)),
22-
('__le__', lambda self, other:
23-
self < other or self == other),
24-
('__ge__', lambda self, other:
25-
not self < other)],
26-
'__le__': [('__ge__', lambda self, other:
27-
not self <= other or self == other),
28-
('__lt__', lambda self, other:
29-
self <= other and not self == other),
30-
('__gt__', lambda self, other:
31-
not self <= other)],
32-
'__gt__': [('__lt__', lambda self, other:
33-
not (self > other or self == other)),
34-
('__ge__', lambda self, other:
35-
self > other or self == other),
36-
('__le__', lambda self, other:
37-
not self > other)],
38-
'__ge__': [('__le__', lambda self, other:
39-
(not self >= other) or self == other),
40-
('__gt__', lambda self, other:
41-
self >= other and not self == other),
42-
('__lt__', lambda self, other:
43-
not self >= other)]
44-
}
45-
roots = set(dir(cls)) & set(convert)
46-
if not roots:
47-
raise ValueError('Must define at least one ordering operation: `<`, '
48-
'`>`, `<=`, or `>=`.')
49-
root = max(roots) # We prefer __lt__ to __le__ to __gt__ to __ge__
50-
for opname, opfunc in convert[root]:
51-
if opname not in roots:
52-
opfunc.__name__ = opname
53-
opfunc.__doc__ = getattr(float, opname).__doc__
54-
setattr(cls, opname, opfunc)
55-
return cls
11+
assert isinstance(string, str)
12+
return str(string).replace('_', chr(sys.maxunicode))
5613

5714

5815
def process_key_function_or_attribute_name(key_function_or_attribute_name):

source_py2/python_toolbox/copy_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def deepcopy_as_simple_object(thing, memo=None):
1919
memo[id(thing)] = new_thing
2020
for (name, subthing) in vars(thing).iteritems():
2121
new_thing.__dict__[name] = copy.deepcopy(subthing, memo)
22-
return(new_thing)
22+
return new_thing
2323

2424

0 commit comments

Comments
 (0)