prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): <|fim_middle|> def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
return [(key, self[key]) for key in self]
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): <|fim_middle|> def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items()))
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): <|fim_middle|> @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
return self.__class__(self)
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): <|fim_middle|> def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
d = cls() for key in iterable: d[key] = value return d
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): <|fim_middle|> # End class OrderedDict <|fim▁end|>
if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other)
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: <|fim_middle|> if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
raise TypeError('expected at most 1 arguments, got %d' % len(args))
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): <|fim_middle|> self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
self._keys = []
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: <|fim_middle|> dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
self._keys.append(key)
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: <|fim_middle|> key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
raise KeyError('dictionary is empty')
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): <|fim_middle|> else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
for key in other.keys(): self[key] = other[key]
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: <|fim_middle|> for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
for key, value in other: self[key] = value
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: <|fim_middle|> return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
raise
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: <|fim_middle|> def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
del self[key] return value
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: <|fim_middle|> return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
return '%s()' % (self.__class__.__name__,)
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): <|fim_middle|> return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
return all(p==q for p, q in _zip_longest(self.items(), other.items()))
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def <|fim_middle|>(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
_zip_longest
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def <|fim_middle|>(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
sentinel
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def <|fim_middle|>(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__init__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def <|fim_middle|>(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
clear
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def <|fim_middle|>(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__setitem__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def <|fim_middle|>(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__delitem__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def <|fim_middle|>(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__iter__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def <|fim_middle|>(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__reversed__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def <|fim_middle|>(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
popitem
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def <|fim_middle|>(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__reduce__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def <|fim_middle|>(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
setdefault
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def <|fim_middle|>(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
update
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def <|fim_middle|>(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
pop
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def <|fim_middle|>(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
keys
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def <|fim_middle|>(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
values
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def <|fim_middle|>(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
items
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def <|fim_middle|>(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__repr__
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def <|fim_middle|>(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
copy
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def <|fim_middle|>(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
fromkeys
<|file_name|>ordereddict.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """Backport from python2.7 to python <= 2.6.""" from itertools import repeat as _repeat, chain as _chain, starmap as _starmap try: from itertools import izip_longest as _zip_longest except ImportError: from itertools import izip def _zip_longest(*args, **kwds): # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') def sentinel(counter = ([fillvalue]*(len(args)-1)).pop): yield counter() # yields the fillvalue, or raises IndexError fillers = _repeat(fillvalue) iters = [_chain(it, sentinel(), fillers) for it in args] try: for tup in izip(*iters): yield tup except IndexError: pass class OrderedDict(dict): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError('dictionary is empty') key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def update(self, other=(), **kwds): if hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def keys(self): return list(self) def values(self): return [self[key] for key in self] def items(self): return [(key, self[key]) for key in self] def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def <|fim_middle|>(self, other): if isinstance(other, OrderedDict): return all(p==q for p, q in _zip_longest(self.items(), other.items())) return dict.__eq__(self, other) # End class OrderedDict <|fim▁end|>
__eq__
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x')<|fim▁hole|> with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main()<|fim▁end|>
self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record()
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): d<|fim_middle|> class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
ef setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y']))
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): p<|fim_middle|> def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
ass
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a<|fim_middle|> def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b)
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s<|fim_middle|> def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), [])
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s<|fim_middle|> def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record() with self.assertRaises(KeyError): s.get('foo')
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s<|fim_middle|> def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo')
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): d<|fim_middle|> def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
ata = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b)
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x<|fim_middle|> def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y)
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x<|fim_middle|> class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y']))
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): d<|fim_middle|> if __name__ == '__main__': unittest.main() <|fim▁end|>
ef test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2)
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x<|fim_middle|> if __name__ == '__main__': unittest.main() <|fim▁end|>
= config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2)
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': u <|fim_middle|> <|fim▁end|>
nittest.main()
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def s<|fim_middle|>self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
etUp(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def t<|fim_middle|>self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_init_with_args(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def t<|fim_middle|>self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_setget(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def t<|fim_middle|>self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_nonexistent_key(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def t<|fim_middle|>self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_delete(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def t<|fim_middle|>self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_eq(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def t<|fim_middle|>self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_sub(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def t<|fim_middle|>self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def test_getset(self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_children(
<|file_name|>config.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (C) 2015 Luis López <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. import unittest from ldotcommons import config class TestRecord(unittest.TestCase): def setUp(self): pass def test_init_with_args(self): a = config.Record({'foo': 1, 'bar': 'x'}) self.assertEqual(a.get('foo'), 1) b = config.Record() b.set('foo', 1) b.set('bar', 'x') self.assertEqual(a, b) def test_setget(self): s = config.Record() s.set('foo', 1) s.set('bar', 'x') s.set('x.y', []) self.assertEqual(s.get('foo'), 1) self.assertEqual(s.get('bar'), 'x') self.assertEqual(s.get('x.y'), []) def test_nonexistent_key(self): s = config.Record() with self.assertRaises(KeyError): s.get('foo') def test_delete(self): s = config.Record() s.set('foo', 1) s.set('foo.bar', 2) s.delete('foo') with self.assertRaises(KeyError): s.get('foo.bar') with self.assertRaises(KeyError): s.get('foo') def test_eq(self): data = { 'foo': 1, 'x.y': 'z', 'dict': {'a': 'b'} } a = config.Record(**data.copy()) b = config.Record(**data.copy()) self.assertEqual(a, b) def test_sub(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) y = config.Record({ 'x': 'x', 'y': 'y', }) self.assertEqual(x.sub('bar'), y) def test_children(self): x = config.Record({ 'foo': 1, 'bar.x': 'x', 'bar.y': 'y', }) self.assertEqual(set(x.children('bar')), set(['x', 'y'])) class TestRecordAttr(unittest.TestCase): def t<|fim_middle|>self): x = config.RecordAttr({'foo': 1, 'bar': 'x', 'a.b': 2}) self.assertEqual(x.foo, 1) self.assertEqual(x.a.b, 2) if __name__ == '__main__': unittest.main() <|fim▁end|>
est_getset(
<|file_name|>fractions.py<|end_file_name|><|fim▁begin|># Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles backports of the standard library's `fractions.py`. <|fim▁hole|>This functionality is required by the FITS unit format generator, since the FITS unit format handles only rational, not decimal point, powers. """ from __future__ import absolute_import import sys if sys.version_info[:2] == (2, 6): from ._fractions_py2 import * else: from fractions import *<|fim▁end|>
The fractions module in 2.6 does not handle being instantiated using a float and then calculating an approximate fraction based on that.
<|file_name|>fractions.py<|end_file_name|><|fim▁begin|># Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles backports of the standard library's `fractions.py`. The fractions module in 2.6 does not handle being instantiated using a float and then calculating an approximate fraction based on that. This functionality is required by the FITS unit format generator, since the FITS unit format handles only rational, not decimal point, powers. """ from __future__ import absolute_import import sys if sys.version_info[:2] == (2, 6): <|fim_middle|> else: from fractions import * <|fim▁end|>
from ._fractions_py2 import *
<|file_name|>fractions.py<|end_file_name|><|fim▁begin|># Licensed under a 3-clause BSD style license - see LICENSE.rst """ Handles backports of the standard library's `fractions.py`. The fractions module in 2.6 does not handle being instantiated using a float and then calculating an approximate fraction based on that. This functionality is required by the FITS unit format generator, since the FITS unit format handles only rational, not decimal point, powers. """ from __future__ import absolute_import import sys if sys.version_info[:2] == (2, 6): from ._fractions_py2 import * else: <|fim_middle|> <|fim▁end|>
from fractions import *
<|file_name|>basic_effect.py<|end_file_name|><|fim▁begin|>from razer.client import DeviceManager from razer.client import constants as razer_constants # Create a DeviceManager. This is used to get specific devices<|fim▁hole|>device_manager = DeviceManager() print("Found {} Razer devices".format(len(device_manager.devices))) print() # Disable daemon effect syncing. # Without this, the daemon will try to set the lighting effect to every device. device_manager.sync_effects = False # Iterate over each device and set the wave effect for device in device_manager.devices: print("Setting {} to wave".format(device.name)) # Set the effect to wave. # wave requires a direction, but different effect have different arguments. device.fx.wave(razer_constants.WAVE_LEFT)<|fim▁end|>
<|file_name|>get_data.py<|end_file_name|><|fim▁begin|>from pymacy.db import get_db from bson.json_util import dumps db = get_db() results = [] count = 0<|fim▁hole|> if count > 100: break results.append(i) print(results[0]) with open("Ni.json", 'w') as f: file = dumps(results) f.write(file)<|fim▁end|>
for i in db.benchmark.find({"element": "Ni"}): count += 1
<|file_name|>get_data.py<|end_file_name|><|fim▁begin|>from pymacy.db import get_db from bson.json_util import dumps db = get_db() results = [] count = 0 for i in db.benchmark.find({"element": "Ni"}): count += 1 if count > 100: <|fim_middle|> results.append(i) print(results[0]) with open("Ni.json", 'w') as f: file = dumps(results) f.write(file)<|fim▁end|>
break
<|file_name|>0003_auto_20150326_1435.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration):<|fim▁hole|> dependencies = [ ('api', '0002_auto_20150326_1433'), ] operations = [ migrations.RemoveField( model_name='problem', name='id', ), migrations.AlterField( model_name='problem', name='problemId', field=models.IntegerField(serialize=False, primary_key=True), preserve_default=True, ), ]<|fim▁end|>
<|file_name|>0003_auto_20150326_1435.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): <|fim_middle|> <|fim▁end|>
dependencies = [ ('api', '0002_auto_20150326_1433'), ] operations = [ migrations.RemoveField( model_name='problem', name='id', ), migrations.AlterField( model_name='problem', name='problemId', field=models.IntegerField(serialize=False, primary_key=True), preserve_default=True, ), ]
<|file_name|>string_repalce_by_resub.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*- from re import sub from itertools import islice <|fim▁hole|>如何调整字符串的文本格式 ''' # 将日志文件中的日期格式转变为美国日期格式mm/dd/yyyy # 使用正则表达式模块中的sub函数进行替换字符串 with open("./log.log","r") as f: for line in islice(f,0,None): #print sub("(\d{4})-(\d{2})-(\d{2})",r"\2/\3/\1",line) # 可以为每个匹配组起一个别名 print sub("(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})",r"\g<month>/\g<day>/\g<>",line)<|fim▁end|>
'''
<|file_name|>image-patches-differential-rotation-scale.py<|end_file_name|><|fim▁begin|># Image Patches Differential Optical Flow Rotation/Scale # # This example shows off using your OpenMV Cam to measure # rotation/scale by comparing the current and the previous # image against each other. Note that only rotation/scale is # handled - not X and Y translation in this mode. # # However, this examples goes beyond doing optical flow on the whole # image at once. Instead it breaks up the process by working on groups # of pixels in the image. This gives you a "new" image of results.<|fim▁hole|># algorithm to work. A featureless surface produces crazy results. # NOTE: Unless you have a very nice test rig this example is hard to see usefulness of... BLOCK_W = 16 # pow2 BLOCK_H = 16 # pow2 # To run this demo effectively please mount your OpenMV Cam on a steady # base and SLOWLY rotate the camera around the lens and move the camera # forward/backwards to see the numbers change. # I.e. Z direction changes only. import sensor, image, time, math # NOTE!!! You have to use a small power of 2 resolution when using # find_displacement(). This is because the algorithm is powered by # something called phase correlation which does the image comparison # using FFTs. A non-power of 2 resolution requires padding to a power # of 2 which reduces the usefulness of the algorithm results. Please # use a resolution like B128X128 or B128X64 (2x faster). # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create # it by doing "img.pool(2, 2)" on a 64x64 image. sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE (or RGB565) sensor.set_framesize(sensor.B128X128) # Set frame size to 128x128... (or 128x64)... sensor.skip_frames(time = 2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. # Take from the main frame buffer's RAM to allocate a second frame buffer. # There's a lot more RAM in the frame buffer than in the MicroPython heap. # However, after doing this you have a lot less RAM for some algorithms... # So, be aware that it's a lot easier to get out of RAM issues now. extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE) extra_fb.replace(sensor.snapshot()) while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. for y in range(0, sensor.height(), BLOCK_H): for x in range(0, sensor.width(), BLOCK_W): displacement = extra_fb.find_displacement(img, logpolar=True, \ roi = (x, y, BLOCK_W, BLOCK_H), template_roi = (x, y, BLOCK_W, BLOCK_H)) # Below 0.1 or so (YMMV) and the results are just noise. if(displacement.response() > 0.1): rotation_change = displacement.rotation() zoom_amount = 1.0 + displacement.scale() pixel_x = x + (BLOCK_W//2) + int(math.sin(rotation_change) * zoom_amount * (BLOCK_W//4)) pixel_y = y + (BLOCK_H//2) + int(math.cos(rotation_change) * zoom_amount * (BLOCK_H//4)) img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, pixel_x, pixel_y), \ color = 255) else: img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, x + BLOCK_W//2, y + BLOCK_H//2), \ color = 0) extra_fb.replace(img) print(clock.fps())<|fim▁end|>
# # NOTE that surfaces need to have some type of "edge" on them for the
<|file_name|>image-patches-differential-rotation-scale.py<|end_file_name|><|fim▁begin|># Image Patches Differential Optical Flow Rotation/Scale # # This example shows off using your OpenMV Cam to measure # rotation/scale by comparing the current and the previous # image against each other. Note that only rotation/scale is # handled - not X and Y translation in this mode. # # However, this examples goes beyond doing optical flow on the whole # image at once. Instead it breaks up the process by working on groups # of pixels in the image. This gives you a "new" image of results. # # NOTE that surfaces need to have some type of "edge" on them for the # algorithm to work. A featureless surface produces crazy results. # NOTE: Unless you have a very nice test rig this example is hard to see usefulness of... BLOCK_W = 16 # pow2 BLOCK_H = 16 # pow2 # To run this demo effectively please mount your OpenMV Cam on a steady # base and SLOWLY rotate the camera around the lens and move the camera # forward/backwards to see the numbers change. # I.e. Z direction changes only. import sensor, image, time, math # NOTE!!! You have to use a small power of 2 resolution when using # find_displacement(). This is because the algorithm is powered by # something called phase correlation which does the image comparison # using FFTs. A non-power of 2 resolution requires padding to a power # of 2 which reduces the usefulness of the algorithm results. Please # use a resolution like B128X128 or B128X64 (2x faster). # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create # it by doing "img.pool(2, 2)" on a 64x64 image. sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE (or RGB565) sensor.set_framesize(sensor.B128X128) # Set frame size to 128x128... (or 128x64)... sensor.skip_frames(time = 2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. # Take from the main frame buffer's RAM to allocate a second frame buffer. # There's a lot more RAM in the frame buffer than in the MicroPython heap. # However, after doing this you have a lot less RAM for some algorithms... # So, be aware that it's a lot easier to get out of RAM issues now. extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE) extra_fb.replace(sensor.snapshot()) while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. for y in range(0, sensor.height(), BLOCK_H): for x in range(0, sensor.width(), BLOCK_W): displacement = extra_fb.find_displacement(img, logpolar=True, \ roi = (x, y, BLOCK_W, BLOCK_H), template_roi = (x, y, BLOCK_W, BLOCK_H)) # Below 0.1 or so (YMMV) and the results are just noise. if(displacement.response() > 0.1): <|fim_middle|> else: img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, x + BLOCK_W//2, y + BLOCK_H//2), \ color = 0) extra_fb.replace(img) print(clock.fps()) <|fim▁end|>
rotation_change = displacement.rotation() zoom_amount = 1.0 + displacement.scale() pixel_x = x + (BLOCK_W//2) + int(math.sin(rotation_change) * zoom_amount * (BLOCK_W//4)) pixel_y = y + (BLOCK_H//2) + int(math.cos(rotation_change) * zoom_amount * (BLOCK_H//4)) img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, pixel_x, pixel_y), \ color = 255)
<|file_name|>image-patches-differential-rotation-scale.py<|end_file_name|><|fim▁begin|># Image Patches Differential Optical Flow Rotation/Scale # # This example shows off using your OpenMV Cam to measure # rotation/scale by comparing the current and the previous # image against each other. Note that only rotation/scale is # handled - not X and Y translation in this mode. # # However, this examples goes beyond doing optical flow on the whole # image at once. Instead it breaks up the process by working on groups # of pixels in the image. This gives you a "new" image of results. # # NOTE that surfaces need to have some type of "edge" on them for the # algorithm to work. A featureless surface produces crazy results. # NOTE: Unless you have a very nice test rig this example is hard to see usefulness of... BLOCK_W = 16 # pow2 BLOCK_H = 16 # pow2 # To run this demo effectively please mount your OpenMV Cam on a steady # base and SLOWLY rotate the camera around the lens and move the camera # forward/backwards to see the numbers change. # I.e. Z direction changes only. import sensor, image, time, math # NOTE!!! You have to use a small power of 2 resolution when using # find_displacement(). This is because the algorithm is powered by # something called phase correlation which does the image comparison # using FFTs. A non-power of 2 resolution requires padding to a power # of 2 which reduces the usefulness of the algorithm results. Please # use a resolution like B128X128 or B128X64 (2x faster). # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create # it by doing "img.pool(2, 2)" on a 64x64 image. sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE (or RGB565) sensor.set_framesize(sensor.B128X128) # Set frame size to 128x128... (or 128x64)... sensor.skip_frames(time = 2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. # Take from the main frame buffer's RAM to allocate a second frame buffer. # There's a lot more RAM in the frame buffer than in the MicroPython heap. # However, after doing this you have a lot less RAM for some algorithms... # So, be aware that it's a lot easier to get out of RAM issues now. extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE) extra_fb.replace(sensor.snapshot()) while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. for y in range(0, sensor.height(), BLOCK_H): for x in range(0, sensor.width(), BLOCK_W): displacement = extra_fb.find_displacement(img, logpolar=True, \ roi = (x, y, BLOCK_W, BLOCK_H), template_roi = (x, y, BLOCK_W, BLOCK_H)) # Below 0.1 or so (YMMV) and the results are just noise. if(displacement.response() > 0.1): rotation_change = displacement.rotation() zoom_amount = 1.0 + displacement.scale() pixel_x = x + (BLOCK_W//2) + int(math.sin(rotation_change) * zoom_amount * (BLOCK_W//4)) pixel_y = y + (BLOCK_H//2) + int(math.cos(rotation_change) * zoom_amount * (BLOCK_H//4)) img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, pixel_x, pixel_y), \ color = 255) else: <|fim_middle|> extra_fb.replace(img) print(clock.fps()) <|fim▁end|>
img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, x + BLOCK_W//2, y + BLOCK_H//2), \ color = 0)
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context <|fim▁hole|>GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown()<|fim▁end|>
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): <|fim_middle|> <|fim▁end|>
""" System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown()
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): <|fim_middle|> @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1")
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): <|fim_middle|> @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER)
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): <|fim_middle|> @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER)
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): <|fim_middle|> <|fim▁end|>
self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown()
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def <|fim_middle|>(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
setUp
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def <|fim_middle|>(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
test_run_example_dag_memorystore_redis
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def <|fim_middle|>(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def tearDown(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
test_run_example_dag_memorystore_memcached
<|file_name|>test_cloud_memorystore_system.py<|end_file_name|><|fim▁begin|># # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. """System tests for Google Cloud Memorystore operators""" import os from urllib.parse import urlparse import pytest from tests.providers.google.cloud.utils.gcp_authenticator import GCP_MEMORYSTORE from tests.test_utils.gcp_system_helpers import CLOUD_DAG_FOLDER, GoogleSystemTest, provide_gcp_context GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") GCP_ARCHIVE_URL = os.environ.get("GCP_MEMORYSTORE_EXPORT_GCS_URL", "gs://test-memorystore/my-export.rdb") GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) GCP_BUCKET_NAME = GCP_ARCHIVE_URL_PARTS.netloc @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GCP_MEMORYSTORE) class CloudMemorystoreSystemTest(GoogleSystemTest): """ System tests for Google Cloud Memorystore operators It use a real service. """ @provide_gcp_context(GCP_MEMORYSTORE) def setUp(self): super().setUp() self.create_gcs_bucket(GCP_BUCKET_NAME, location="europe-north1") @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_redis(self): self.run_dag('gcp_cloud_memorystore_redis', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def test_run_example_dag_memorystore_memcached(self): self.run_dag('gcp_cloud_memorystore_memcached', CLOUD_DAG_FOLDER) @provide_gcp_context(GCP_MEMORYSTORE) def <|fim_middle|>(self): self.delete_gcs_bucket(GCP_BUCKET_NAME) super().tearDown() <|fim▁end|>
tearDown
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride <|fim▁hole|> return 'JAVA_HOME="%s"' def _get_default_format(self): return '' def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK"<|fim▁end|>
class JdkOverride(AbstractOverride): def _get_override_format(self):
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): <|fim_middle|> <|fim▁end|>
def _get_override_format(self): return 'JAVA_HOME="%s"' def _get_default_format(self): return '' def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK"
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def _get_override_format(self): <|fim_middle|> def _get_default_format(self): return '' def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK" <|fim▁end|>
return 'JAVA_HOME="%s"'
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def _get_override_format(self): return 'JAVA_HOME="%s"' def _get_default_format(self): <|fim_middle|> def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK" <|fim▁end|>
return ''
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def _get_override_format(self): return 'JAVA_HOME="%s"' def _get_default_format(self): return '' def __init__(self, *args): <|fim_middle|> <|fim▁end|>
AbstractOverride.__init__(self, *args) self.name = "JDK"
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def <|fim_middle|>(self): return 'JAVA_HOME="%s"' def _get_default_format(self): return '' def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK" <|fim▁end|>
_get_override_format
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def _get_override_format(self): return 'JAVA_HOME="%s"' def <|fim_middle|>(self): return '' def __init__(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK" <|fim▁end|>
_get_default_format
<|file_name|>jdk_override.py<|end_file_name|><|fim▁begin|>""" The MIT License (MIT) Copyright (c) 2016 Louis-Philippe Querel [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from utility.abstract_override import AbstractOverride class JdkOverride(AbstractOverride): def _get_override_format(self): return 'JAVA_HOME="%s"' def _get_default_format(self): return '' def <|fim_middle|>(self, *args): AbstractOverride.__init__(self, *args) self.name = "JDK" <|fim▁end|>
__init__
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None:<|fim▁hole|> def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register()<|fim▁end|>
return True return False
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): <|fim_middle|> AmmoToDmgPattern.register() <|fim▁end|>
visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): <|fim_middle|> def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): <|fim_middle|> def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): <|fim_middle|> def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item")
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): <|fim_middle|> def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,)))
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): <|fim_middle|> AmmoToDmgPattern.register() <|fim▁end|>
return None
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: <|fim_middle|> if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
return False
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: <|fim_middle|> for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
return False
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: <|fim_middle|> return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
return True
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def <|fim_middle|>(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
__init__
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def <|fim_middle|>(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def getText(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
display
<|file_name|>ammoToDmgPattern.py<|end_file_name|><|fim▁begin|># noinspection PyPackageRequirements import wx import gui.globalEvents as GE import gui.mainFrame from gui.contextMenu import ContextMenuSingle from service.fit import Fit class AmmoToDmgPattern(ContextMenuSingle): visibilitySetting = 'ammoPattern' def __init__(self): self.mainFrame = gui.mainFrame.MainFrame.getInstance() def display(self, callingWindow, srcContext, mainItem): if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None: return False if mainItem is None: return False for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"): if mainItem.getAttribute(attr) is not None: return True return False def <|fim_middle|>(self, callingWindow, itmContext, mainItem): return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item") def activate(self, callingWindow, fullContext, mainItem, i): fitID = self.mainFrame.getActiveFit() Fit.getInstance().setAsPattern(fitID, mainItem) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,))) def getBitmap(self, callingWindow, context, mainItem): return None AmmoToDmgPattern.register() <|fim▁end|>
getText