Skip to content

Commit 95563bd

Browse files
committed
Remove unused Selection and TimeDict classes.
1 parent d36642e commit 95563bd

File tree

1 file changed

+0
-66
lines changed

1 file changed

+0
-66
lines changed

sc2reader/utils.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -449,72 +449,6 @@ def __setitem__(self, key, value):
449449
super(PersonDict, self).__setitem__(value.pid, value)
450450

451451

452-
453-
class TimeDict(dict):
454-
""" Dict with frames as key """
455-
456-
def __init__(self, *args, **kwargs):
457-
dict.__init__(self, *args, **kwargs)
458-
self.current = None
459-
self.current_key = None
460-
461-
def __getitem__(self, key):
462-
if key == self.current_key:
463-
return self.current
464-
try:
465-
return dict.__getitem__(self, key)
466-
except KeyError:
467-
stamps = filter(lambda x: x<=key, sorted(self.keys()))
468-
if stamps:
469-
return dict.__getitem__(self, stamps[-1])
470-
else:
471-
return self.current
472-
473-
def __setitem__(self, key, value):
474-
if self.current_key is not None and key < self.current_key:
475-
raise ValueError("Cannot assign before last item (%s)" % (max(self.keys()),))
476-
else:
477-
self.current = value
478-
self.current_key = key
479-
dict.__setitem__(self, key, value)
480-
481-
482-
483-
class Selection(TimeDict):
484-
""" Buffer for tracking selections in-game """
485-
486-
def __init__(self):
487-
super(Selection, self).__init__()
488-
self[0] = []
489-
490-
@classmethod
491-
def replace(cls, selection, indexes):
492-
""" Deselect objects according to indexes """
493-
return [ selection[i] for i in indexes ]
494-
495-
@classmethod
496-
def deselect(cls, selection, indexes):
497-
""" Deselect objects according to indexes """
498-
return [ selection[i] for i in range(len(selection)) if i not in indexes ]
499-
500-
@classmethod
501-
def mask(cls, selection, mask):
502-
""" Deselect objects according to deselect mask """
503-
if len(mask) < len(selection):
504-
# pad to the right
505-
mask = mask+[False,]*(len(selection)-len(mask))
506-
return [ obj for (slct, obj) in filter(lambda (slct, obj): not slct, zip(mask, selection)) ]
507-
508-
def __setitem__(self, key, value):
509-
# keep things sorted by id
510-
super(Selection, self).__setitem__(key, list(sorted(value, key=lambda obj: obj.id)))
511-
512-
def __repr__(self):
513-
return '<Selection %s>' % (', '.join([str(obj) for obj in self.current]),)
514-
515-
def get_types(self):
516-
return ', '.join([ u'%s %sx' % (name.name, len(list(objs))) for (name, objs) in groupby(self.current, lambda obj: obj.__class__)])
517-
518452
def windows_to_unix(windows_time):
519453
# This windows timestamp measures the number of 100 nanosecond periods since
520454
# January 1st, 1601. First we subtract the number of nanosecond periods from

0 commit comments

Comments
 (0)