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
pexip/os-django-auth-ldap
django_auth_ldap/backend.py
2
29666
# Copyright (c) 2009, Peter Sagerson # 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. # # 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 HOLDER 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. """ LDAP authentication backend Complete documentation can be found in docs/howto/auth-ldap.txt (or the thing it compiles to). Use of this backend requires the python-ldap module. To support unit tests, we import ldap in a single centralized place (config._LDAPConfig) so that the test harness can insert a mock object. A few notes on naming conventions. If an identifier ends in _dn, it is a string representation of a distinguished name. If it ends in _info, it is a 2-tuple containing a DN and a dictionary of lists of attributes. ldap.search_s returns a list of such structures. An identifier that ends in _attrs is the dictionary of attributes from the _info structure. A connection is an LDAPObject that has been successfully bound with a DN and password. The identifier 'user' always refers to a User model object; LDAP user information will be user_dn or user_info. Additional classes can be found in the config module next to this one. """ import ldap import sys import traceback import pprint import copy from django.contrib.auth.models import User, Group, Permission, SiteProfileNotAvailable from django.core.cache import cache from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist import django.dispatch # Support Django 1.5's custom user models try: from django.contrib.auth import get_user_model get_user_username = lambda u: u.get_username() except ImportError: get_user_model = lambda: User # noqa get_user_username = lambda u: u.username from django_auth_ldap.config import _LDAPConfig, LDAPSearch logger = _LDAPConfig.get_logger() # Signals for populating user objects. populate_user = django.dispatch.Signal(providing_args=["user", "ldap_user"]) populate_user_profile = django.dispatch.Signal(providing_args=["profile", "ldap_user"]) class LDAPBackend(object): """ The main backend class. This implements the auth backend API, although it actually delegates most of its work to _LDAPUser, which is defined next. """ supports_anonymous_user = False supports_object_permissions = True supports_inactive_user = False _settings = None _ldap = None # The cached ldap module (or mock object) # This is prepended to our internal setting names to produce the names we # expect in Django's settings file. Subclasses can change this in order to # support multiple collections of settings. settings_prefix = 'AUTH_LDAP_' def __getstate__(self): """ Exclude certain cached properties from pickling. """ state = filter( lambda (k, v): k not in ['_settings', '_ldap'], self.__dict__.iteritems() ) return dict(state) def _get_settings(self): if self._settings is None: self._settings = LDAPSettings(self.settings_prefix) return self._settings def _set_settings(self, settings): self._settings = settings settings = property(_get_settings, _set_settings) def _get_ldap(self): if self._ldap is None: from django.conf import settings options = getattr(settings, 'AUTH_LDAP_GLOBAL_OPTIONS', None) self._ldap = _LDAPConfig.get_ldap(options) return self._ldap ldap = property(_get_ldap) def get_user_model(self): """ By default, this will return the model class configured by AUTH_USER_MODEL. Subclasses may wish to override it and return a proxy model. """ return get_user_model() # # The Django auth backend API # def authenticate(self, username, password): if len(password) == 0 and not self.settings.PERMIT_EMPTY_PASSWORD: logger.debug('Rejecting empty password for %s' % username) return None ldap_user = _LDAPUser(self, username=username.strip()) user = ldap_user.authenticate(password) return user def get_user(self, user_id): user = None try: user = self.get_user_model().objects.get(pk=user_id) _LDAPUser(self, user=user) # This sets user.ldap_user except ObjectDoesNotExist: pass return user def has_perm(self, user, perm, obj=None): return perm in self.get_all_permissions(user, obj) def has_module_perms(self, user, app_label): for perm in self.get_all_permissions(user): if perm[:perm.index('.')] == app_label: return True return False def get_all_permissions(self, user, obj=None): return self.get_group_permissions(user, obj) def get_group_permissions(self, user, obj=None): if not hasattr(user, 'ldap_user') and self.settings.AUTHORIZE_ALL_USERS: _LDAPUser(self, user=user) # This sets user.ldap_user if hasattr(user, 'ldap_user'): return user.ldap_user.get_group_permissions() else: return set() # # Bonus API: populate the Django user from LDAP without authenticating. # def populate_user(self, username): ldap_user = _LDAPUser(self, username=username) user = ldap_user.populate_user() return user # # Hooks for subclasses # def get_or_create_user(self, username, ldap_user): """ This must return a (User, created) 2-tuple for the given LDAP user. username is the Django-friendly username of the user. ldap_user.dn is the user's DN and ldap_user.attrs contains all of their LDAP attributes. """ model = self.get_user_model() username_field = getattr(model, 'USERNAME_FIELD', 'username') kwargs = { username_field + '__iexact': username, 'defaults': {username_field: username.lower()} } return model.objects.get_or_create(**kwargs) def ldap_to_django_username(self, username): return username def django_to_ldap_username(self, username): return username class _LDAPUser(object): """ Represents an LDAP user and ultimately fields all requests that the backend receives. This class exists for two reasons. First, it's convenient to have a separate object for each request so that we can use object attributes without running into threading problems. Second, these objects get attached to the User objects, which allows us to cache expensive LDAP information, especially around groups and permissions. self.backend is a reference back to the LDAPBackend instance, which we need to access the ldap module and any hooks that a subclass has overridden. """ class AuthenticationFailed(Exception): pass # Defaults _user = None _user_dn = None _user_attrs = None _groups = None _group_permissions = None _connection = None _connection_bound = False # # Initialization # def __init__(self, backend, username=None, user=None): """ A new LDAPUser must be initialized with either a username or an authenticated User object. If a user is given, the username will be ignored. """ self.backend = backend self._username = username if user is not None: self._set_authenticated_user(user) if username is None and user is None: raise Exception("Internal error: _LDAPUser improperly initialized.") def __deepcopy__(self, memo): obj = object.__new__(self.__class__) obj.backend = self.backend obj._user = copy.deepcopy(self._user, memo) # This is all just cached immutable data. There's no point copying it. obj._username = self._username obj._user_dn = self._user_dn obj._user_attrs = self._user_attrs obj._groups = self._groups obj._group_permissions = self._group_permissions # The connection couldn't be copied even if we wanted to obj._connection = self._connection obj._connection_bound = self._connection_bound return obj def __getstate__(self): """ Most of our properties are cached from the LDAP server. We only want to pickle a few crucial things. """ state = filter( lambda (k, v): k in ['backend', '_username', '_user'], self.__dict__.iteritems() ) return dict(state) def _set_authenticated_user(self, user): self._user = user self._username = self.backend.django_to_ldap_username(get_user_username(user)) user.ldap_user = self user.ldap_username = self._username def _get_ldap(self): return self.backend.ldap ldap = property(_get_ldap) def _get_settings(self): return self.backend.settings settings = property(_get_settings) # # Entry points # def authenticate(self, password): """ Authenticates against the LDAP directory and returns the corresponding User object if successful. Returns None on failure. """ user = None try: self._authenticate_user_dn(password) self._check_requirements() self._get_or_create_user() user = self._user except self.AuthenticationFailed, e: logger.debug(u"Authentication failed for %s" % self._username) except ldap.LDAPError, e: logger.warning(u"Caught LDAPError while authenticating %s: %s", self._username, pprint.pformat(e)) except Exception: logger.exception(u"Caught Exception while authenticating %s", self._username) raise return user def get_group_permissions(self): """ If allowed by the configuration, this returns the set of permissions defined by the user's LDAP group memberships. """ if self._group_permissions is None: self._group_permissions = set() if self.settings.FIND_GROUP_PERMS: try: self._load_group_permissions() except ldap.LDAPError, e: logger.warning("Caught LDAPError loading group permissions: %s", pprint.pformat(e)) return self._group_permissions def populate_user(self): """ Populates the Django user object using the default bind credentials. """ user = None try: # self.attrs will only be non-None if we were able to load this user # from the LDAP directory, so this filters out nonexistent users. if self.attrs is not None: self._get_or_create_user(force_populate=True) user = self._user except ldap.LDAPError, e: logger.warning(u"Caught LDAPError while authenticating %s: %s", self._username, pprint.pformat(e)) except Exception, e: logger.error(u"Caught Exception while authenticating %s: %s", self._username, pprint.pformat(e)) logger.error(''.join(traceback.format_tb(sys.exc_info()[2]))) raise return user # # Public properties (callbacks). These are all lazy for performance reasons. # def _get_user_dn(self): if self._user_dn is None: self._load_user_dn() return self._user_dn dn = property(_get_user_dn) def _get_user_attrs(self): if self._user_attrs is None: self._load_user_attrs() return self._user_attrs attrs = property(_get_user_attrs) def _get_group_dns(self): return self._get_groups().get_group_dns() group_dns = property(_get_group_dns) def _get_group_names(self): return self._get_groups().get_group_names() group_names = property(_get_group_names) def _get_bound_connection(self): if not self._connection_bound: self._bind() return self._get_connection() connection = property(_get_bound_connection) # # Authentication # def _authenticate_user_dn(self, password): """ Binds to the LDAP server with the user's DN and password. Raises AuthenticationFailed on failure. """ if self.dn is None: raise self.AuthenticationFailed("Failed to map the username to a DN.") try: sticky = self.settings.BIND_AS_AUTHENTICATING_USER self._bind_as(self.dn, password, sticky=sticky) except ldap.INVALID_CREDENTIALS: raise self.AuthenticationFailed("User DN/password rejected by LDAP server.") def _load_user_attrs(self): if self.dn is not None: search = LDAPSearch(self.dn, ldap.SCOPE_BASE) results = search.execute(self.connection) if results is not None and len(results) > 0: self._user_attrs = results[0][1] def _load_user_dn(self): """ Populates self._user_dn with the distinguished name of our user. This will either construct the DN from a template in AUTH_LDAP_USER_DN_TEMPLATE or connect to the server and search for it. """ if self._using_simple_bind_mode(): self._construct_simple_user_dn() else: self._search_for_user_dn() def _using_simple_bind_mode(self): return (self.settings.USER_DN_TEMPLATE is not None) def _construct_simple_user_dn(self): template = self.settings.USER_DN_TEMPLATE username = ldap.dn.escape_dn_chars(self._username) self._user_dn = template % {'user': username} def _search_for_user_dn(self): """ Searches the directory for a user matching AUTH_LDAP_USER_SEARCH. Populates self._user_dn and self._user_attrs. """ search = self.settings.USER_SEARCH if search is None: raise ImproperlyConfigured('AUTH_LDAP_USER_SEARCH must be an LDAPSearch instance.') results = search.execute(self.connection, {'user': self._username}) if results is not None and len(results) == 1: (self._user_dn, self._user_attrs) = results[0] def _check_requirements(self): """ Checks all authentication requirements beyond credentials. Raises AuthenticationFailed on failure. """ self._check_required_group() self._check_denied_group() def _check_required_group(self): """ Returns True if the group requirement (AUTH_LDAP_REQUIRE_GROUP) is met. Always returns True if AUTH_LDAP_REQUIRE_GROUP is None. """ required_group_dn = self.settings.REQUIRE_GROUP if required_group_dn is not None: is_member = self._get_groups().is_member_of(required_group_dn) if not is_member: raise self.AuthenticationFailed("User is not a member of AUTH_LDAP_REQUIRE_GROUP") return True def _check_denied_group(self): """ Returns True if the negative group requirement (AUTH_LDAP_DENY_GROUP) is met. Always returns True if AUTH_LDAP_DENY_GROUP is None. """ denied_group_dn = self.settings.DENY_GROUP if denied_group_dn is not None: is_member = self._get_groups().is_member_of(denied_group_dn) if is_member: raise self.AuthenticationFailed("User is a member of AUTH_LDAP_DENY_GROUP") return True # # User management # def _get_or_create_user(self, force_populate=False): """ Loads the User model object from the database or creates it if it doesn't exist. Also populates the fields, subject to AUTH_LDAP_ALWAYS_UPDATE_USER. """ save_user = False username = self.backend.ldap_to_django_username(self._username) self._user, created = self.backend.get_or_create_user(username, self) self._user.ldap_user = self self._user.ldap_username = self._username should_populate = force_populate or self.settings.ALWAYS_UPDATE_USER or created if created: logger.debug("Created Django user %s", username) self._user.set_unusable_password() save_user = True if should_populate: logger.debug("Populating Django user %s", username) self._populate_user() save_user = True if self.settings.MIRROR_GROUPS: self._mirror_groups() # Give the client a chance to finish populating the user just before # saving. if should_populate: signal_responses = populate_user.send(self.backend.__class__, user=self._user, ldap_user=self) if len(signal_responses) > 0: save_user = True if save_user: self._user.save() # We populate the profile after the user model is saved to give the # client a chance to create the profile. Custom user models in Django # 1.5 probably won't have a get_profile method. if should_populate and hasattr(self._user, 'get_profile'): self._populate_and_save_user_profile() def _populate_user(self): """ Populates our User object with information from the LDAP directory. """ self._populate_user_from_attributes() self._populate_user_from_group_memberships() def _populate_user_from_attributes(self): for field, attr in self.settings.USER_ATTR_MAP.iteritems(): try: setattr(self._user, field, self.attrs[attr][0]) except StandardError: logger.warning("%s does not have a value for the attribute %s", self.dn, attr) def _populate_user_from_group_memberships(self): for field, group_dns in self.settings.USER_FLAGS_BY_GROUP.iteritems(): if isinstance(group_dns, basestring): group_dns = [group_dns] value = any(self._get_groups().is_member_of(dn) for dn in group_dns) setattr(self._user, field, value) def _populate_and_save_user_profile(self): """ Populates a User profile object with fields from the LDAP directory. """ try: profile = self._user.get_profile() save_profile = False logger.debug("Populating Django user profile for %s", get_user_username(self._user)) save_profile = self._populate_profile_from_attributes(profile) or save_profile save_profile = self._populate_profile_from_group_memberships(profile) or save_profile signal_responses = populate_user_profile.send(self.backend.__class__, profile=profile, ldap_user=self) if len(signal_responses) > 0: save_profile = True if save_profile: profile.save() except (SiteProfileNotAvailable, ObjectDoesNotExist): logger.debug("Django user %s does not have a profile to populate", get_user_username(self._user)) def _populate_profile_from_attributes(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_ATTR_MAP. Returns True if the profile was modified. """ save_profile = False for field, attr in self.settings.PROFILE_ATTR_MAP.iteritems(): try: # user_attrs is a hash of lists of attribute values setattr(profile, field, self.attrs[attr][0]) save_profile = True except StandardError: logger.warning("%s does not have a value for the attribute %s", self.dn, attr) return save_profile def _populate_profile_from_group_memberships(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_FLAGS_BY_GROUP. Returns True if the profile was modified. """ save_profile = False for field, group_dns in self.settings.PROFILE_FLAGS_BY_GROUP.iteritems(): if isinstance(group_dns, basestring): group_dns = [group_dns] value = any(self._get_groups().is_member_of(dn) for dn in group_dns) setattr(profile, field, value) save_profile = True return save_profile def _mirror_groups(self): """ Mirrors the user's LDAP groups in the Django database and updates the user's membership. """ group_names = self._get_groups().get_group_names() groups = [Group.objects.get_or_create(name=group_name)[0] for group_name in group_names] self._user.groups = groups # # Group information # def _load_group_permissions(self): """ Populates self._group_permissions based on LDAP group membership and Django group permissions. """ group_names = self._get_groups().get_group_names() perms = Permission.objects.filter(group__name__in=group_names) perms = perms.values_list('content_type__app_label', 'codename') perms = perms.order_by() self._group_permissions = set(["%s.%s" % (ct, name) for ct, name in perms]) def _get_groups(self): """ Returns an _LDAPUserGroups object, which can determine group membership. """ if self._groups is None: self._groups = _LDAPUserGroups(self) return self._groups # # LDAP connection # def _bind(self): """ Binds to the LDAP server with AUTH_LDAP_BIND_DN and AUTH_LDAP_BIND_PASSWORD. """ self._bind_as(self.settings.BIND_DN, self.settings.BIND_PASSWORD, sticky=True) def _bind_as(self, bind_dn, bind_password, sticky=False): """ Binds to the LDAP server with the given credentials. This does not trap exceptions. If sticky is True, then we will consider the connection to be bound for the life of this object. If False, then the caller only wishes to test the credentials, after which the connection will be considered unbound. """ self._get_connection().simple_bind_s(bind_dn.encode('utf-8'), bind_password.encode('utf-8')) self._connection_bound = sticky def _get_connection(self): """ Returns our cached LDAPObject, which may or may not be bound. """ if self._connection is None: uri = self.settings.SERVER_URI if callable(uri): uri = uri() self._connection = self.backend.ldap.initialize(uri) for opt, value in self.settings.CONNECTION_OPTIONS.iteritems(): self._connection.set_option(opt, value) if self.settings.START_TLS: logger.debug("Initiating TLS") self._connection.start_tls_s() return self._connection class _LDAPUserGroups(object): """ Represents the set of groups that a user belongs to. """ def __init__(self, ldap_user): self.settings = ldap_user.settings self._ldap_user = ldap_user self._group_type = None self._group_search = None self._group_infos = None self._group_dns = None self._group_names = None self._init_group_settings() def _init_group_settings(self): """ Loads the settings we need to deal with groups. Raises ImproperlyConfigured if anything's not right. """ self._group_type = self.settings.GROUP_TYPE if self._group_type is None: raise ImproperlyConfigured("AUTH_LDAP_GROUP_TYPE must be an LDAPGroupType instance.") self._group_search = self.settings.GROUP_SEARCH if self._group_search is None: raise ImproperlyConfigured("AUTH_LDAP_GROUP_SEARCH must be an LDAPSearch instance.") def get_group_names(self): """ Returns the set of Django group names that this user belongs to by virtue of LDAP group memberships. """ if self._group_names is None: self._load_cached_attr("_group_names") if self._group_names is None: group_infos = self._get_group_infos() self._group_names = set( self._group_type.group_name_from_info(group_info) for group_info in group_infos ) self._cache_attr("_group_names") return self._group_names def is_member_of(self, group_dn): """ Returns true if our user is a member of the given group. """ is_member = None # Normalize the DN group_dn = group_dn.lower() # If we have self._group_dns, we'll use it. Otherwise, we'll try to # avoid the cost of loading it. if self._group_dns is None: is_member = self._group_type.is_member(self._ldap_user, group_dn) if is_member is None: is_member = (group_dn in self.get_group_dns()) logger.debug("%s is%sa member of %s", self._ldap_user.dn, is_member and " " or " not ", group_dn) return is_member def get_group_dns(self): """ Returns a (cached) set of the distinguished names in self._group_infos. """ if self._group_dns is None: group_infos = self._get_group_infos() self._group_dns = set(group_info[0] for group_info in group_infos) return self._group_dns def _get_group_infos(self): """ Returns a (cached) list of group_info structures for the groups that our user is a member of. """ if self._group_infos is None: self._group_infos = self._group_type.user_groups(self._ldap_user, self._group_search) return self._group_infos def _load_cached_attr(self, attr_name): if self.settings.CACHE_GROUPS: key = self._cache_key(attr_name) value = cache.get(key) setattr(self, attr_name, value) def _cache_attr(self, attr_name): if self.settings.CACHE_GROUPS: key = self._cache_key(attr_name) value = getattr(self, attr_name, None) cache.set(key, value, self.settings.GROUP_CACHE_TIMEOUT) def _cache_key(self, attr_name): """ Memcache keys can't have spaces in them, so we'll remove them from the DN for maximum compatibility. """ dn = self._ldap_user.dn.replace(' ', '%20') key = u'auth_ldap.%s.%s.%s' % (self.__class__.__name__, attr_name, dn) return key class LDAPSettings(object): """ This is a simple class to take the place of the global settings object. An instance will contain all of our settings as attributes, with default values if they are not specified by the configuration. """ defaults = { 'ALWAYS_UPDATE_USER': True, 'AUTHORIZE_ALL_USERS': False, 'BIND_AS_AUTHENTICATING_USER': False, 'BIND_DN': '', 'BIND_PASSWORD': '', 'CACHE_GROUPS': False, 'CONNECTION_OPTIONS': {}, 'DENY_GROUP': None, 'FIND_GROUP_PERMS': False, 'GROUP_CACHE_TIMEOUT': None, 'GROUP_SEARCH': None, 'GROUP_TYPE': None, 'MIRROR_GROUPS': False, 'PERMIT_EMPTY_PASSWORD': False, 'PROFILE_ATTR_MAP': {}, 'PROFILE_FLAGS_BY_GROUP': {}, 'REQUIRE_GROUP': None, 'SERVER_URI': 'ldap://localhost', 'START_TLS': False, 'USER_ATTR_MAP': {}, 'USER_DN_TEMPLATE': None, 'USER_FLAGS_BY_GROUP': {}, 'USER_SEARCH': None, } def __init__(self, prefix='AUTH_LDAP_'): """ Loads our settings from django.conf.settings, applying defaults for any that are omitted. """ from django.conf import settings for name, default in self.defaults.iteritems(): value = getattr(settings, prefix + name, default) setattr(self, name, value)
bsd-2-clause
[ 3, 1898, 334, 67, 9, 8937, 12, 22912, 428, 1456, 834, 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, 7647, 26, 199, 3, 199, 3, 446, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 446, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 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, 199, 19534, 6299, 4865, 199, 199, 14175, 3794, 883, 506, 1911, 315, 9149, 15, 21232, 15, 1178, 13, 9642, 14, 2424, 334, 269, 314, 8377, 652, 199, 2014, 83, 370, 680, 199, 199, 6119, 402, 642, 4865, 5074, 314, 2366, 13, 9642, 859, 14, 4005, 2291, 4137, 2295, 12, 781, 199, 646, 13727, 315, 282, 2849, 18796, 1759, 4192, 334, 888, 423, 19534, 2028, 9, 880, 626, 314, 511, 199, 23569, 883, 5518, 282, 1683, 909, 14, 199, 199, 33, 9284, 12681, 641, 19720, 8758, 852, 14, 982, 376, 5148, 11187, 315, 485, 4272, 12, 652, 365, 282, 1059, 199, 22903, 402, 282, 2917, 14659, 4387, 536, 14, 982, 652, 11187, 315, 485, 815, 12, 652, 365, 282, 499, 13, 2960, 199, 16133, 282, 24842, 436, 282, 2600, 402, 5548, 402, 3004, 14, 13727, 14, 1733, 63, 83, 2529, 282, 199, 513, 402, 4066, 13955, 14, 1626, 5148, 626, 11187, 315, 485, 3288, 365, 314, 2600, 402, 199, 2987, 687, 314, 485, 815, 5523, 14, 199, 199, 33, 1950, 365, 376, 20717, 1692, 626, 965, 2757, 8792, 3914, 543, 282, 24842, 436, 199, 2060, 14, 710, 5148, 283, 751, 7, 3544, 15724, 370, 282, 2876, 1402, 909, 27, 20717, 922, 199, 11697, 911, 506, 922, 63, 4272, 503, 922, 63, 815, 14, 199, 199, 8824, 3992, 883, 506, 1911, 315, 314, 1101, 859, 2163, 370, 642, 1373, 14, 199, 624, 199, 199, 646, 13727, 199, 646, 984, 199, 646, 5190, 199, 646, 10933, 199, 646, 1331, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 12, 8779, 12, 11666, 5736, 1763, 11464, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 24803, 199, 646, 1639, 14, 6052, 199, 199, 3, 12502, 5634, 413, 14, 21, 1159, 3537, 922, 1709, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 272, 664, 63, 751, 63, 2473, 275, 2400, 399, 26, 399, 14, 362, 63, 2473, 342, 199, 2590, 3545, 26, 272, 664, 63, 751, 63, 1238, 275, 2400, 26, 2876, 2476, 263, 327, 8151, 272, 664, 63, 751, 63, 2473, 275, 2400, 399, 26, 399, 14, 2473, 421, 199, 504, 1639, 63, 1178, 63, 9642, 14, 888, 492, 485, 19534, 2028, 12, 20717, 5278, 421, 199, 2921, 275, 485, 19534, 2028, 14, 362, 63, 2921, 342, 421, 199, 3, 6632, 2551, 367, 4560, 20529, 922, 2251, 14, 199, 13817, 63, 751, 275, 1639, 14, 6052, 14, 11274, 8, 496, 11604, 63, 589, 6270, 751, 401, 298, 9642, 63, 751, 3135, 199, 13817, 63, 751, 63, 2913, 275, 1639, 14, 6052, 14, 11274, 8, 496, 11604, 63, 589, 6270, 2913, 401, 298, 9642, 63, 751, 3135, 421, 199, 533, 20717, 8447, 8, 785, 304, 272, 408, 272, 710, 2446, 4865, 1021, 14, 961, 9031, 314, 1790, 4865, 3261, 12, 22160, 652, 272, 5965, 18703, 2335, 4750, 402, 2399, 1736, 370, 485, 19534, 1899, 12, 1314, 365, 3247, 2163, 14, 272, 408, 272, 5171, 63, 12628, 63, 751, 275, 756, 272, 5171, 63, 785, 63, 6060, 275, 715, 272, 5171, 63, 16856, 63, 751, 275, 756, 339, 485, 1751, 275, 488, 272, 485, 9642, 275, 488, 221, 327, 710, 6328, 13727, 859, 334, 269, 1683, 909, 9, 339, 327, 961, 365, 20247, 370, 4154, 5007, 4260, 1561, 370, 7389, 314, 1561, 781, 272, 327, 4282, 315, 5634, 1159, 2202, 570, 14, 20196, 883, 1570, 642, 315, 1865, 370, 272, 327, 2291, 3663, 5055, 402, 2202, 14, 272, 2202, 63, 1861, 275, 283, 5580, 63, 19534, 8650, 339, 347, 636, 16011, 721, 277, 304, 267, 408, 267, 28554, 9842, 6328, 4382, 687, 24394, 14, 267, 408, 267, 1174, 275, 2457, 8, 288, 2400, 334, 75, 12, 373, 304, 1022, 440, 315, 4044, 1751, 297, 2513, 9642, 995, 288, 291, 855, 807, 4343, 4611, 342, 267, 776, 398, 372, 1211, 8, 929, 9, 339, 347, 485, 362, 63, 1751, 8, 277, 304, 267, 340, 291, 423, 1751, 365, 488, 26, 288, 291, 423, 1751, 275, 20717, 5268, 8, 277, 14, 1751, 63, 1861, 9, 398, 372, 291, 423, 1751, 339, 347, 485, 409, 63, 1751, 8, 277, 12, 2202, 304, 267, 291, 423, 1751, 275, 2202, 339, 2202, 275, 3324, 1547, 362, 63, 1751, 12, 485, 409, 63, 1751, 9, 339, 347, 485, 362, 63, 9642, 8, 277, 304, 267, 340, 291, 423, 9642, 365, 488, 26, 288, 687, 1639, 14, 2190, 492, 2202, 953, 1511 ]
[ 1898, 334, 67, 9, 8937, 12, 22912, 428, 1456, 834, 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, 7647, 26, 199, 3, 199, 3, 446, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 446, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 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, 199, 19534, 6299, 4865, 199, 199, 14175, 3794, 883, 506, 1911, 315, 9149, 15, 21232, 15, 1178, 13, 9642, 14, 2424, 334, 269, 314, 8377, 652, 199, 2014, 83, 370, 680, 199, 199, 6119, 402, 642, 4865, 5074, 314, 2366, 13, 9642, 859, 14, 4005, 2291, 4137, 2295, 12, 781, 199, 646, 13727, 315, 282, 2849, 18796, 1759, 4192, 334, 888, 423, 19534, 2028, 9, 880, 626, 314, 511, 199, 23569, 883, 5518, 282, 1683, 909, 14, 199, 199, 33, 9284, 12681, 641, 19720, 8758, 852, 14, 982, 376, 5148, 11187, 315, 485, 4272, 12, 652, 365, 282, 1059, 199, 22903, 402, 282, 2917, 14659, 4387, 536, 14, 982, 652, 11187, 315, 485, 815, 12, 652, 365, 282, 499, 13, 2960, 199, 16133, 282, 24842, 436, 282, 2600, 402, 5548, 402, 3004, 14, 13727, 14, 1733, 63, 83, 2529, 282, 199, 513, 402, 4066, 13955, 14, 1626, 5148, 626, 11187, 315, 485, 3288, 365, 314, 2600, 402, 199, 2987, 687, 314, 485, 815, 5523, 14, 199, 199, 33, 1950, 365, 376, 20717, 1692, 626, 965, 2757, 8792, 3914, 543, 282, 24842, 436, 199, 2060, 14, 710, 5148, 283, 751, 7, 3544, 15724, 370, 282, 2876, 1402, 909, 27, 20717, 922, 199, 11697, 911, 506, 922, 63, 4272, 503, 922, 63, 815, 14, 199, 199, 8824, 3992, 883, 506, 1911, 315, 314, 1101, 859, 2163, 370, 642, 1373, 14, 199, 624, 199, 199, 646, 13727, 199, 646, 984, 199, 646, 5190, 199, 646, 10933, 199, 646, 1331, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 12, 8779, 12, 11666, 5736, 1763, 11464, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 24803, 199, 646, 1639, 14, 6052, 199, 199, 3, 12502, 5634, 413, 14, 21, 1159, 3537, 922, 1709, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 272, 664, 63, 751, 63, 2473, 275, 2400, 399, 26, 399, 14, 362, 63, 2473, 342, 199, 2590, 3545, 26, 272, 664, 63, 751, 63, 1238, 275, 2400, 26, 2876, 2476, 263, 327, 8151, 272, 664, 63, 751, 63, 2473, 275, 2400, 399, 26, 399, 14, 2473, 421, 199, 504, 1639, 63, 1178, 63, 9642, 14, 888, 492, 485, 19534, 2028, 12, 20717, 5278, 421, 199, 2921, 275, 485, 19534, 2028, 14, 362, 63, 2921, 342, 421, 199, 3, 6632, 2551, 367, 4560, 20529, 922, 2251, 14, 199, 13817, 63, 751, 275, 1639, 14, 6052, 14, 11274, 8, 496, 11604, 63, 589, 6270, 751, 401, 298, 9642, 63, 751, 3135, 199, 13817, 63, 751, 63, 2913, 275, 1639, 14, 6052, 14, 11274, 8, 496, 11604, 63, 589, 6270, 2913, 401, 298, 9642, 63, 751, 3135, 421, 199, 533, 20717, 8447, 8, 785, 304, 272, 408, 272, 710, 2446, 4865, 1021, 14, 961, 9031, 314, 1790, 4865, 3261, 12, 22160, 652, 272, 5965, 18703, 2335, 4750, 402, 2399, 1736, 370, 485, 19534, 1899, 12, 1314, 365, 3247, 2163, 14, 272, 408, 272, 5171, 63, 12628, 63, 751, 275, 756, 272, 5171, 63, 785, 63, 6060, 275, 715, 272, 5171, 63, 16856, 63, 751, 275, 756, 339, 485, 1751, 275, 488, 272, 485, 9642, 275, 488, 221, 327, 710, 6328, 13727, 859, 334, 269, 1683, 909, 9, 339, 327, 961, 365, 20247, 370, 4154, 5007, 4260, 1561, 370, 7389, 314, 1561, 781, 272, 327, 4282, 315, 5634, 1159, 2202, 570, 14, 20196, 883, 1570, 642, 315, 1865, 370, 272, 327, 2291, 3663, 5055, 402, 2202, 14, 272, 2202, 63, 1861, 275, 283, 5580, 63, 19534, 8650, 339, 347, 636, 16011, 721, 277, 304, 267, 408, 267, 28554, 9842, 6328, 4382, 687, 24394, 14, 267, 408, 267, 1174, 275, 2457, 8, 288, 2400, 334, 75, 12, 373, 304, 1022, 440, 315, 4044, 1751, 297, 2513, 9642, 995, 288, 291, 855, 807, 4343, 4611, 342, 267, 776, 398, 372, 1211, 8, 929, 9, 339, 347, 485, 362, 63, 1751, 8, 277, 304, 267, 340, 291, 423, 1751, 365, 488, 26, 288, 291, 423, 1751, 275, 20717, 5268, 8, 277, 14, 1751, 63, 1861, 9, 398, 372, 291, 423, 1751, 339, 347, 485, 409, 63, 1751, 8, 277, 12, 2202, 304, 267, 291, 423, 1751, 275, 2202, 339, 2202, 275, 3324, 1547, 362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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 ]
poojavade/Genomics_Docker
Dockerfiles/gedlab-khmer-filter-abund/pymodules/python2.7/lib/python/ipython-2.2.0-py2.7.egg/IPython/testing/iptestcontroller.py
7
21202
# -*- coding: utf-8 -*- """IPython Test Process Controller This module runs one or more subprocesses which will actually run the IPython test suite. """ #----------------------------------------------------------------------------- # Copyright (C) 2009-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- from __future__ import print_function import argparse import json import multiprocessing.pool import os import shutil import signal import sys import subprocess import time from .iptest import have, test_group_names as py_test_group_names, test_sections, StreamCapturer from IPython.utils.path import compress_user from IPython.utils.py3compat import bytes_to_str from IPython.utils.sysinfo import get_sys_info from IPython.utils.tempdir import TemporaryDirectory class TestController(object): """Run tests in a subprocess """ #: str, IPython test suite to be executed. section = None #: list, command line arguments to be executed cmd = None #: dict, extra environment variables to set for the subprocess env = None #: list, TemporaryDirectory instances to clear up when the process finishes dirs = None #: subprocess.Popen instance process = None #: str, process stdout+stderr stdout = None def __init__(self): self.cmd = [] self.env = {} self.dirs = [] def setup(self): """Create temporary directories etc. This is only called when we know the test group will be run. Things created here may be cleaned up by self.cleanup(). """ pass def launch(self, buffer_output=False): # print('*** ENV:', self.env) # dbg # print('*** CMD:', self.cmd) # dbg env = os.environ.copy() env.update(self.env) output = subprocess.PIPE if buffer_output else None stdout = subprocess.STDOUT if buffer_output else None self.process = subprocess.Popen(self.cmd, stdout=output, stderr=stdout, env=env) def wait(self): self.stdout, _ = self.process.communicate() return self.process.returncode def print_extra_info(self): """Print extra information about this test run. If we're running in parallel and showing the concise view, this is only called if the test group fails. Otherwise, it's called before the test group is started. The base implementation does nothing, but it can be overridden by subclasses. """ return def cleanup_process(self): """Cleanup on exit by killing any leftover processes.""" subp = self.process if subp is None or (subp.poll() is not None): return # Process doesn't exist, or is already dead. try: print('Cleaning up stale PID: %d' % subp.pid) subp.kill() except: # (OSError, WindowsError) ? # This is just a best effort, if we fail or the process was # really gone, ignore it. pass else: for i in range(10): if subp.poll() is None: time.sleep(0.1) else: break if subp.poll() is None: # The process did not die... print('... failed. Manual cleanup may be required.') def cleanup(self): "Kill process if it's still alive, and clean up temporary directories" self.cleanup_process() for td in self.dirs: td.cleanup() __del__ = cleanup class PyTestController(TestController): """Run Python tests using IPython.testing.iptest""" #: str, Python command to execute in subprocess pycmd = None def __init__(self, section, options): """Create new test runner.""" TestController.__init__(self) self.section = section # pycmd is put into cmd[2] in PyTestController.launch() self.cmd = [sys.executable, '-c', None, section] self.pycmd = "from IPython.testing.iptest import run_iptest; run_iptest()" self.options = options def setup(self): ipydir = TemporaryDirectory() self.dirs.append(ipydir) self.env['IPYTHONDIR'] = ipydir.name self.workingdir = workingdir = TemporaryDirectory() self.dirs.append(workingdir) self.env['IPTEST_WORKING_DIR'] = workingdir.name # This means we won't get odd effects from our own matplotlib config self.env['MPLCONFIGDIR'] = workingdir.name # From options: if self.options.xunit: self.add_xunit() if self.options.coverage: self.add_coverage() self.env['IPTEST_SUBPROC_STREAMS'] = self.options.subproc_streams self.cmd.extend(self.options.extra_args) @property def will_run(self): try: return test_sections[self.section].will_run except KeyError: return True def add_xunit(self): xunit_file = os.path.abspath(self.section + '.xunit.xml') self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file]) def add_coverage(self): try: sources = test_sections[self.section].includes except KeyError: sources = ['IPython'] coverage_rc = ("[run]\n" "data_file = {data_file}\n" "source =\n" " {source}\n" ).format(data_file=os.path.abspath('.coverage.'+self.section), source="\n ".join(sources)) config_file = os.path.join(self.workingdir.name, '.coveragerc') with open(config_file, 'w') as f: f.write(coverage_rc) self.env['COVERAGE_PROCESS_START'] = config_file self.pycmd = "import coverage; coverage.process_startup(); " + self.pycmd def launch(self, buffer_output=False): self.cmd[2] = self.pycmd super(PyTestController, self).launch(buffer_output=buffer_output) js_prefix = 'js/' def get_js_test_dir(): import IPython.html.tests as t return os.path.join(os.path.dirname(t.__file__), '') def all_js_groups(): import glob test_dir = get_js_test_dir() all_subdirs = glob.glob(test_dir + '*/') return [js_prefix+os.path.relpath(x, test_dir) for x in all_subdirs if os.path.relpath(x, test_dir) != '__pycache__'] class JSController(TestController): """Run CasperJS tests """ def __init__(self, section): """Create new test runner.""" TestController.__init__(self) self.section = section js_test_dir = get_js_test_dir() includes = '--includes=' + os.path.join(js_test_dir,'util.js') test_cases = os.path.join(js_test_dir, self.section[len(js_prefix):]) self.cmd = ['casperjs', 'test', includes, test_cases] def setup(self): self.ipydir = TemporaryDirectory() self.nbdir = TemporaryDirectory() self.dirs.append(self.ipydir) self.dirs.append(self.nbdir) os.makedirs(os.path.join(self.nbdir.name, os.path.join(u'sub ∂ir1', u'sub ∂ir 1a'))) os.makedirs(os.path.join(self.nbdir.name, os.path.join(u'sub ∂ir2', u'sub ∂ir 1b'))) # start the ipython notebook, so we get the port number self.server_port = 0 self._init_server() if self.server_port: self.cmd.append("--port=%i" % self.server_port) else: # don't launch tests if the server didn't start self.cmd = [sys.executable, '-c', 'raise SystemExit(1)'] def print_extra_info(self): print("Running tests with notebook directory %r" % self.nbdir.name) @property def will_run(self): return all(have[a] for a in ['zmq', 'tornado', 'jinja2', 'casperjs', 'sqlite3']) def _init_server(self): "Start the notebook server in a separate process" self.server_command = command = [sys.executable, '-m', 'IPython.html', '--no-browser', '--ipython-dir', self.ipydir.name, '--notebook-dir', self.nbdir.name, ] # ipc doesn't work on Windows, and darwin has crazy-long temp paths, # which run afoul of ipc's maximum path length. if sys.platform.startswith('linux'): command.append('--KernelManager.transport=ipc') self.stream_capturer = c = StreamCapturer() c.start() self.server = subprocess.Popen(command, stdout=c.writefd, stderr=subprocess.STDOUT) self.server_info_file = os.path.join(self.ipydir.name, 'profile_default', 'security', 'nbserver-%i.json' % self.server.pid ) self._wait_for_server() def _wait_for_server(self): """Wait 30 seconds for the notebook server to start""" for i in range(300): if self.server.poll() is not None: return self._failed_to_start() if os.path.exists(self.server_info_file): self._load_server_info() return time.sleep(0.1) print("Notebook server-info file never arrived: %s" % self.server_info_file, file=sys.stderr ) def _failed_to_start(self): """Notebook server exited prematurely""" captured = self.stream_capturer.get_buffer().decode('utf-8', 'replace') print("Notebook failed to start: ", file=sys.stderr) print(self.server_command) print(captured, file=sys.stderr) def _load_server_info(self): """Notebook server started, load connection info from JSON""" with open(self.server_info_file) as f: info = json.load(f) self.server_port = info['port'] def cleanup(self): try: self.server.terminate() except OSError: # already dead pass self.server.wait() self.stream_capturer.halt() TestController.cleanup(self) def prepare_controllers(options): """Returns two lists of TestController instances, those to run, and those not to run.""" testgroups = options.testgroups if testgroups: py_testgroups = [g for g in testgroups if (g in py_test_group_names) \ or g.startswith('IPython.')] if 'js' in testgroups: js_testgroups = all_js_groups() else: js_testgroups = [g for g in testgroups if g not in py_testgroups] else: py_testgroups = py_test_group_names js_testgroups = all_js_groups() if not options.all: test_sections['parallel'].enabled = False c_js = [JSController(name) for name in js_testgroups] c_py = [PyTestController(name, options) for name in py_testgroups] controllers = c_py + c_js to_run = [c for c in controllers if c.will_run] not_run = [c for c in controllers if not c.will_run] return to_run, not_run def do_run(controller, buffer_output=True): """Setup and run a test controller. If buffer_output is True, no output is displayed, to avoid it appearing interleaved. In this case, the caller is responsible for displaying test output on failure. Returns ------- controller : TestController The same controller as passed in, as a convenience for using map() type APIs. exitcode : int The exit code of the test subprocess. Non-zero indicates failure. """ try: try: controller.setup() if not buffer_output: controller.print_extra_info() controller.launch(buffer_output=buffer_output) except Exception: import traceback traceback.print_exc() return controller, 1 # signal failure exitcode = controller.wait() return controller, exitcode except KeyboardInterrupt: return controller, -signal.SIGINT finally: controller.cleanup() def report(): """Return a string with a summary report of test-related variables.""" inf = get_sys_info() out = [] def _add(name, value): out.append((name, value)) _add('IPython version', inf['ipython_version']) _add('IPython commit', "{} ({})".format(inf['commit_hash'], inf['commit_source'])) _add('IPython package', compress_user(inf['ipython_path'])) _add('Python version', inf['sys_version'].replace('\n','')) _add('sys.executable', compress_user(inf['sys_executable'])) _add('Platform', inf['platform']) width = max(len(n) for (n,v) in out) out = ["{:<{width}}: {}\n".format(n, v, width=width) for (n,v) in out] avail = [] not_avail = [] for k, is_avail in have.items(): if is_avail: avail.append(k) else: not_avail.append(k) if avail: out.append('\nTools and libraries available at test time:\n') avail.sort() out.append(' ' + ' '.join(avail)+'\n') if not_avail: out.append('\nTools and libraries NOT available at test time:\n') not_avail.sort() out.append(' ' + ' '.join(not_avail)+'\n') return ''.join(out) def run_iptestall(options): """Run the entire IPython test suite by calling nose and trial. This function constructs :class:`IPTester` instances for all IPython modules and package and then runs each of them. This causes the modules and packages of IPython to be tested each in their own subprocess using nose. Parameters ---------- All parameters are passed as attributes of the options object. testgroups : list of str Run only these sections of the test suite. If empty, run all the available sections. fast : int or None Run the test suite in parallel, using n simultaneous processes. If None is passed, one process is used per CPU core. Default 1 (i.e. sequential) inc_slow : bool Include slow tests, like IPython.parallel. By default, these tests aren't run. xunit : bool Produce Xunit XML output. This is written to multiple foo.xunit.xml files. coverage : bool or str Measure code coverage from tests. True will store the raw coverage data, or pass 'html' or 'xml' to get reports. extra_args : list Extra arguments to pass to the test subprocesses, e.g. '-v' """ to_run, not_run = prepare_controllers(options) def justify(ltext, rtext, width=70, fill='-'): ltext += ' ' rtext = (' ' + rtext).rjust(width - len(ltext), fill) return ltext + rtext # Run all test runners, tracking execution time failed = [] t_start = time.time() print() if options.fast == 1: # This actually means sequential, i.e. with 1 job for controller in to_run: print('Test group:', controller.section) sys.stdout.flush() # Show in correct order when output is piped controller, res = do_run(controller, buffer_output=False) if res: failed.append(controller) if res == -signal.SIGINT: print("Interrupted") break print() else: # Run tests concurrently try: pool = multiprocessing.pool.ThreadPool(options.fast) for (controller, res) in pool.imap_unordered(do_run, to_run): res_string = 'OK' if res == 0 else 'FAILED' print(justify('Test group: ' + controller.section, res_string)) if res: controller.print_extra_info() print(bytes_to_str(controller.stdout)) failed.append(controller) if res == -signal.SIGINT: print("Interrupted") break except KeyboardInterrupt: return for controller in not_run: print(justify('Test group: ' + controller.section, 'NOT RUN')) t_end = time.time() t_tests = t_end - t_start nrunners = len(to_run) nfail = len(failed) # summarize results print('_'*70) print('Test suite completed for system with the following information:') print(report()) took = "Took %.3fs." % t_tests print('Status: ', end='') if not failed: print('OK (%d test groups).' % nrunners, took) else: # If anything went wrong, point out what command to rerun manually to # see the actual errors and individual summary failed_sections = [c.section for c in failed] print('ERROR - {} out of {} test groups failed ({}).'.format(nfail, nrunners, ', '.join(failed_sections)), took) print() print('You may wish to rerun these, with:') print(' iptest', *failed_sections) print() if options.coverage: from coverage import coverage cov = coverage(data_file='.coverage') cov.combine() cov.save() # Coverage HTML report if options.coverage == 'html': html_dir = 'ipy_htmlcov' shutil.rmtree(html_dir, ignore_errors=True) print("Writing HTML coverage report to %s/ ... " % html_dir, end="") sys.stdout.flush() # Custom HTML reporter to clean up module names. from coverage.html import HtmlReporter class CustomHtmlReporter(HtmlReporter): def find_code_units(self, morfs): super(CustomHtmlReporter, self).find_code_units(morfs) for cu in self.code_units: nameparts = cu.name.split(os.sep) if 'IPython' not in nameparts: continue ix = nameparts.index('IPython') cu.name = '.'.join(nameparts[ix:]) # Reimplement the html_report method with our custom reporter cov._harvest_data() cov.config.from_args(omit='*{0}tests{0}*'.format(os.sep), html_dir=html_dir, html_title='IPython test coverage', ) reporter = CustomHtmlReporter(cov, cov.config) reporter.report(None) print('done.') # Coverage XML report elif options.coverage == 'xml': cov.xml_report(outfile='ipy_coverage.xml') if failed: # Ensure that our exit code indicates failure sys.exit(1) argparser = argparse.ArgumentParser(description='Run IPython test suite') argparser.add_argument('testgroups', nargs='*', help='Run specified groups of tests. If omitted, run ' 'all tests.') argparser.add_argument('--all', action='store_true', help='Include slow tests not run by default.') argparser.add_argument('-j', '--fast', nargs='?', const=None, default=1, type=int, help='Run test sections in parallel. This starts as many ' 'processes as you have cores, or you can specify a number.') argparser.add_argument('--xunit', action='store_true', help='Produce Xunit XML results') argparser.add_argument('--coverage', nargs='?', const=True, default=False, help="Measure test coverage. Specify 'html' or " "'xml' to get reports.") argparser.add_argument('--subproc-streams', default='capture', help="What to do with stdout/stderr from subprocesses. " "'capture' (default), 'show' and 'discard' are the options.") def default_options(): """Get an argparse Namespace object with the default arguments, to pass to :func:`run_iptestall`. """ options = argparser.parse_args([]) options.extra_args = [] return options def main(): # iptest doesn't work correctly if the working directory is the # root of the IPython source tree. Tell the user to avoid # frustration. if os.path.exists(os.path.join(os.getcwd(), 'IPython', 'testing', '__main__.py')): print("Don't run iptest from the IPython source directory", file=sys.stderr) sys.exit(1) # Arguments after -- should be passed through to nose. Argparse treats # everything after -- as regular positional arguments, so we separate them # first. try: ix = sys.argv.index('--') except ValueError: to_parse = sys.argv[1:] extra_args = [] else: to_parse = sys.argv[1:ix] extra_args = sys.argv[ix+1:] options = argparser.parse_args(to_parse) options.extra_args = extra_args run_iptestall(options) if __name__ == '__main__': main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 1772, 11361, 1379, 7132, 16282, 199, 199, 2765, 859, 7858, 1373, 503, 1655, 1007, 11816, 1314, 911, 5965, 1255, 314, 16243, 199, 396, 5241, 14, 199, 199, 624, 199, 199, 18045, 199, 3, 221, 1898, 334, 35, 9, 8937, 13, 8128, 221, 710, 16243, 15290, 11682, 199, 3, 199, 3, 221, 17484, 1334, 314, 2895, 402, 314, 6289, 844, 14, 221, 710, 2615, 4190, 365, 315, 199, 3, 221, 314, 570, 9685, 12, 1854, 465, 1777, 402, 642, 2032, 14, 199, 18045, 199, 199, 18045, 199, 3, 24339, 199, 18045, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 12866, 14, 2293, 199, 646, 747, 199, 646, 5145, 199, 646, 4673, 199, 646, 984, 199, 646, 3873, 199, 646, 900, 199, 199, 504, 1275, 711, 396, 492, 1172, 12, 511, 63, 923, 63, 1247, 465, 1134, 63, 396, 63, 923, 63, 1247, 12, 511, 63, 7786, 12, 8271, 16640, 82, 199, 504, 16243, 14, 1208, 14, 515, 492, 11029, 63, 751, 199, 504, 16243, 14, 1208, 14, 647, 19, 5819, 492, 2783, 63, 475, 63, 495, 199, 504, 16243, 14, 1208, 14, 1274, 815, 492, 664, 63, 1274, 63, 815, 199, 504, 16243, 14, 1208, 14, 11567, 492, 21791, 6231, 421, 199, 533, 1379, 7506, 8, 785, 304, 272, 408, 2540, 2295, 315, 282, 3873, 272, 408, 272, 6079, 620, 12, 16243, 511, 5241, 370, 506, 7934, 14, 272, 3420, 275, 488, 272, 6079, 769, 12, 1414, 1004, 2368, 370, 506, 7934, 272, 2088, 275, 488, 272, 6079, 1211, 12, 2402, 3734, 2860, 370, 663, 367, 314, 3873, 272, 2589, 275, 488, 272, 6079, 769, 12, 21791, 6231, 4454, 370, 5436, 1536, 1380, 314, 2112, 9578, 397, 272, 7606, 275, 488, 272, 6079, 3873, 14, 7942, 1256, 272, 2112, 275, 488, 272, 6079, 620, 12, 2112, 3839, 11, 3083, 272, 3839, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1760, 275, 942, 267, 291, 14, 1813, 275, 1052, 267, 291, 14, 3220, 275, 942, 339, 347, 3272, 8, 277, 304, 267, 408, 2499, 7937, 6602, 5423, 14, 2728, 961, 365, 1454, 2797, 1380, 781, 5715, 314, 511, 1572, 911, 506, 1255, 14, 3868, 780, 267, 2737, 2348, 1443, 506, 12364, 1536, 701, 291, 14, 7661, 1252, 267, 408, 267, 986, 339, 347, 10623, 8, 277, 12, 3335, 63, 1199, 29, 797, 304, 267, 327, 870, 360, 9153, 5070, 54, 6536, 291, 14, 1813, 9, 221, 327, 24465, 267, 327, 870, 360, 9153, 25548, 6536, 291, 14, 1760, 9, 221, 327, 24465, 267, 2589, 275, 747, 14, 2314, 14, 1574, 342, 267, 2589, 14, 873, 8, 277, 14, 1813, 9, 267, 1072, 275, 3873, 14, 6089, 340, 3335, 63, 1199, 587, 488, 267, 3839, 275, 3873, 14, 13850, 340, 3335, 63, 1199, 587, 488, 267, 291, 14, 1412, 275, 3873, 14, 7942, 8, 277, 14, 1760, 12, 3839, 29, 1199, 12, 355, 4635, 29, 2703, 12, 2589, 29, 1813, 9, 339, 347, 3618, 8, 277, 304, 267, 291, 14, 2703, 12, 485, 275, 291, 14, 1412, 14, 10664, 342, 267, 372, 291, 14, 1412, 14, 9913, 339, 347, 870, 63, 2911, 63, 815, 8, 277, 304, 267, 408, 5375, 2402, 2556, 3595, 642, 511, 1255, 14, 2728, 982, 781, 3984, 3879, 315, 9861, 436, 21207, 314, 406, 11900, 2455, 12, 642, 365, 1454, 267, 2797, 340, 314, 511, 1572, 6918, 14, 6630, 12, 652, 1159, 2797, 2544, 314, 511, 267, 1572, 365, 8239, 14, 2728, 710, 1300, 4514, 1630, 6548, 12, 1325, 652, 883, 506, 10087, 701, 267, 9180, 14, 267, 408, 267, 372, 339, 347, 9058, 63, 1412, 8, 277, 304, 267, 408, 7891, 641, 4458, 701, 1022, 12687, 1263, 32196, 10358, 1041, 267, 1007, 80, 275, 291, 14, 1412, 267, 340, 1007, 80, 365, 488, 503, 334, 954, 80, 14, 6843, 342, 365, 440, 488, 304, 288, 372, 221, 327, 7132, 3181, 1133, 2187, 12, 503, 365, 2575, 12314, 14, 398, 862, 26, 288, 870, 360, 6580, 316, 1536, 20149, 20674, 26, 450, 68, 7, 450, 1007, 80, 14, 3150, 9, 288, 1007, 80, 14, 8997, 342, 267, 871, 26, 327, 334, 16719, 12, 23950, 9, 5805, 288, 327, 961, 365, 2951, 282, 5526, 28058, 12, 340, 781, 2449, 503, 314, 2112, 1990, 288, 327, 7710, 21737, 12, 3686, 652, 14, 288, 986, 267, 587, 26, 288, 367, 284, 315, 1425, 8, 709, 304, 355, 340, 1007, 80, 14, 6843, 342, 365, 488, 26, 490, 900, 14, 4532, 8, 16, 14, 17, 9, 355, 587, 26, 490, 2059, 398, 340, 1007, 80, 14, 6843, 342, 365, 488, 26, 288, 327, 710, 2112, 8103, 440, 18833, 1396, 288, 870, 360, 1396, 3405, 14, 30247, 9058, 1443, 506, 1415, 2659, 339, 347, 9058, 8, 277, 304, 267, 298, 31464, 2112, 340, 652, 1159, 5139, 19708, 12, 436, 3633, 1536, 7937, 6602, 2, 267, 291, 14, 7661, 63, 1412, 342, 267, 367, 12749, 315, 291, 14, 3220, 26, 288, 12749, 14, 7661, 342, 339, 636, 2264, 363, 275, 9058, 199, 199, 533, 1611, 774, 7506, 8, 774, 7506, 304, 272, 408, 2540, 2018, 2295, 1808, 16243, 14, 4776, 14, 711, 396, 624, 272, 6079, 620, 12, 2018, 1414, 370, 5341, 315, 3873, 272, 1134, 1760, 275, 488, 339, 347, 636, 826, 721, 277, 12, 3420, 12, 1511, 304, 267, 408, 2499, 892, 511, 7876, 1041, 267, 1379, 7506, 855, 826, 721, 277, 9, 267, 291, 14, 2792, 275, 3420, 267, 327, 1134, 1760, 365, 5324, 1901, 2088, 59, 18, 61, 315, 1611, 774, 7506, 14, 9850, 342, 267, 291, 14, 1760, 275, 359, 1274, 14, 5904, 12, 2475, 67, 297, 488, 12, 3420, 61, 267, 291, 14, 647, 1760, 275, 298, 504, 16243, 14, 4776, 14, 711, 396, 492, 1255, 63, 711, 396, 27, 1255, 63, 711, 396, 16493, 267, 291, 14, 1419, 275, 1511, 339, 347, 3272, 8, 277, 304, 267, 284, 647, 694, 275, 21791, 6231, 342, 267, 291, 14, 3220, 14, 740, 8, 73, 647, 694, 9, 267, 291, 14, 1813, 459, 1772, 57, 8472, 3022, 418, 275, 284, 647, 694, 14, 354, 267, 291, 14, 9818, 694, 275, 6449 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 1772, 11361, 1379, 7132, 16282, 199, 199, 2765, 859, 7858, 1373, 503, 1655, 1007, 11816, 1314, 911, 5965, 1255, 314, 16243, 199, 396, 5241, 14, 199, 199, 624, 199, 199, 18045, 199, 3, 221, 1898, 334, 35, 9, 8937, 13, 8128, 221, 710, 16243, 15290, 11682, 199, 3, 199, 3, 221, 17484, 1334, 314, 2895, 402, 314, 6289, 844, 14, 221, 710, 2615, 4190, 365, 315, 199, 3, 221, 314, 570, 9685, 12, 1854, 465, 1777, 402, 642, 2032, 14, 199, 18045, 199, 199, 18045, 199, 3, 24339, 199, 18045, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 12866, 14, 2293, 199, 646, 747, 199, 646, 5145, 199, 646, 4673, 199, 646, 984, 199, 646, 3873, 199, 646, 900, 199, 199, 504, 1275, 711, 396, 492, 1172, 12, 511, 63, 923, 63, 1247, 465, 1134, 63, 396, 63, 923, 63, 1247, 12, 511, 63, 7786, 12, 8271, 16640, 82, 199, 504, 16243, 14, 1208, 14, 515, 492, 11029, 63, 751, 199, 504, 16243, 14, 1208, 14, 647, 19, 5819, 492, 2783, 63, 475, 63, 495, 199, 504, 16243, 14, 1208, 14, 1274, 815, 492, 664, 63, 1274, 63, 815, 199, 504, 16243, 14, 1208, 14, 11567, 492, 21791, 6231, 421, 199, 533, 1379, 7506, 8, 785, 304, 272, 408, 2540, 2295, 315, 282, 3873, 272, 408, 272, 6079, 620, 12, 16243, 511, 5241, 370, 506, 7934, 14, 272, 3420, 275, 488, 272, 6079, 769, 12, 1414, 1004, 2368, 370, 506, 7934, 272, 2088, 275, 488, 272, 6079, 1211, 12, 2402, 3734, 2860, 370, 663, 367, 314, 3873, 272, 2589, 275, 488, 272, 6079, 769, 12, 21791, 6231, 4454, 370, 5436, 1536, 1380, 314, 2112, 9578, 397, 272, 7606, 275, 488, 272, 6079, 3873, 14, 7942, 1256, 272, 2112, 275, 488, 272, 6079, 620, 12, 2112, 3839, 11, 3083, 272, 3839, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1760, 275, 942, 267, 291, 14, 1813, 275, 1052, 267, 291, 14, 3220, 275, 942, 339, 347, 3272, 8, 277, 304, 267, 408, 2499, 7937, 6602, 5423, 14, 2728, 961, 365, 1454, 2797, 1380, 781, 5715, 314, 511, 1572, 911, 506, 1255, 14, 3868, 780, 267, 2737, 2348, 1443, 506, 12364, 1536, 701, 291, 14, 7661, 1252, 267, 408, 267, 986, 339, 347, 10623, 8, 277, 12, 3335, 63, 1199, 29, 797, 304, 267, 327, 870, 360, 9153, 5070, 54, 6536, 291, 14, 1813, 9, 221, 327, 24465, 267, 327, 870, 360, 9153, 25548, 6536, 291, 14, 1760, 9, 221, 327, 24465, 267, 2589, 275, 747, 14, 2314, 14, 1574, 342, 267, 2589, 14, 873, 8, 277, 14, 1813, 9, 267, 1072, 275, 3873, 14, 6089, 340, 3335, 63, 1199, 587, 488, 267, 3839, 275, 3873, 14, 13850, 340, 3335, 63, 1199, 587, 488, 267, 291, 14, 1412, 275, 3873, 14, 7942, 8, 277, 14, 1760, 12, 3839, 29, 1199, 12, 355, 4635, 29, 2703, 12, 2589, 29, 1813, 9, 339, 347, 3618, 8, 277, 304, 267, 291, 14, 2703, 12, 485, 275, 291, 14, 1412, 14, 10664, 342, 267, 372, 291, 14, 1412, 14, 9913, 339, 347, 870, 63, 2911, 63, 815, 8, 277, 304, 267, 408, 5375, 2402, 2556, 3595, 642, 511, 1255, 14, 2728, 982, 781, 3984, 3879, 315, 9861, 436, 21207, 314, 406, 11900, 2455, 12, 642, 365, 1454, 267, 2797, 340, 314, 511, 1572, 6918, 14, 6630, 12, 652, 1159, 2797, 2544, 314, 511, 267, 1572, 365, 8239, 14, 2728, 710, 1300, 4514, 1630, 6548, 12, 1325, 652, 883, 506, 10087, 701, 267, 9180, 14, 267, 408, 267, 372, 339, 347, 9058, 63, 1412, 8, 277, 304, 267, 408, 7891, 641, 4458, 701, 1022, 12687, 1263, 32196, 10358, 1041, 267, 1007, 80, 275, 291, 14, 1412, 267, 340, 1007, 80, 365, 488, 503, 334, 954, 80, 14, 6843, 342, 365, 440, 488, 304, 288, 372, 221, 327, 7132, 3181, 1133, 2187, 12, 503, 365, 2575, 12314, 14, 398, 862, 26, 288, 870, 360, 6580, 316, 1536, 20149, 20674, 26, 450, 68, 7, 450, 1007, 80, 14, 3150, 9, 288, 1007, 80, 14, 8997, 342, 267, 871, 26, 327, 334, 16719, 12, 23950, 9, 5805, 288, 327, 961, 365, 2951, 282, 5526, 28058, 12, 340, 781, 2449, 503, 314, 2112, 1990, 288, 327, 7710, 21737, 12, 3686, 652, 14, 288, 986, 267, 587, 26, 288, 367, 284, 315, 1425, 8, 709, 304, 355, 340, 1007, 80, 14, 6843, 342, 365, 488, 26, 490, 900, 14, 4532, 8, 16, 14, 17, 9, 355, 587, 26, 490, 2059, 398, 340, 1007, 80, 14, 6843, 342, 365, 488, 26, 288, 327, 710, 2112, 8103, 440, 18833, 1396, 288, 870, 360, 1396, 3405, 14, 30247, 9058, 1443, 506, 1415, 2659, 339, 347, 9058, 8, 277, 304, 267, 298, 31464, 2112, 340, 652, 1159, 5139, 19708, 12, 436, 3633, 1536, 7937, 6602, 2, 267, 291, 14, 7661, 63, 1412, 342, 267, 367, 12749, 315, 291, 14, 3220, 26, 288, 12749, 14, 7661, 342, 339, 636, 2264, 363, 275, 9058, 199, 199, 533, 1611, 774, 7506, 8, 774, 7506, 304, 272, 408, 2540, 2018, 2295, 1808, 16243, 14, 4776, 14, 711, 396, 624, 272, 6079, 620, 12, 2018, 1414, 370, 5341, 315, 3873, 272, 1134, 1760, 275, 488, 339, 347, 636, 826, 721, 277, 12, 3420, 12, 1511, 304, 267, 408, 2499, 892, 511, 7876, 1041, 267, 1379, 7506, 855, 826, 721, 277, 9, 267, 291, 14, 2792, 275, 3420, 267, 327, 1134, 1760, 365, 5324, 1901, 2088, 59, 18, 61, 315, 1611, 774, 7506, 14, 9850, 342, 267, 291, 14, 1760, 275, 359, 1274, 14, 5904, 12, 2475, 67, 297, 488, 12, 3420, 61, 267, 291, 14, 647, 1760, 275, 298, 504, 16243, 14, 4776, 14, 711, 396, 492, 1255, 63, 711, 396, 27, 1255, 63, 711, 396, 16493, 267, 291, 14, 1419, 275, 1511, 339, 347, 3272, 8, 277, 304, 267, 284, 647, 694, 275, 21791, 6231, 342, 267, 291, 14, 3220, 14, 740, 8, 73, 647, 694, 9, 267, 291, 14, 1813, 459, 1772, 57, 8472, 3022, 418, 275, 284, 647, 694, 14, 354, 267, 291, 14, 9818, 694, 275, 6449, 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, 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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 ]
mindcandy/thrift
test/py/TestClient.py
36
8786
#!/usr/bin/env python # # 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 sys, glob, os sys.path.insert(0, glob.glob(os.path.join(os.path.dirname(__file__),'../../lib/py/build/lib.*'))[0]) import unittest import time from optparse import OptionParser parser = OptionParser() parser.add_option('--genpydir', type='string', dest='genpydir', default='gen-py', help='include this local directory in sys.path for locating generated code') parser.add_option("--port", type="int", dest="port", help="connect to server at port") parser.add_option("--host", type="string", dest="host", help="connect to server") parser.add_option("--zlib", action="store_true", dest="zlib", help="use zlib wrapper for compressed transport") parser.add_option("--ssl", action="store_true", dest="ssl", help="use SSL for encrypted transport") parser.add_option("--http", dest="http_path", help="Use the HTTP transport with the specified path") parser.add_option('-v', '--verbose', action="store_const", dest="verbose", const=2, help="verbose output") parser.add_option('-q', '--quiet', action="store_const", dest="verbose", const=0, help="minimal output") parser.add_option('--protocol', dest="proto", type="string", help="protocol to use, one of: accel, binary, compact, json") parser.add_option('--transport', dest="trans", type="string", help="transport to use, one of: buffered, framed") parser.set_defaults(framed=False, http_path=None, verbose=1, host='localhost', port=9090, proto='binary') options, args = parser.parse_args() script_dir = os.path.dirname(__file__) sys.path.insert(0, os.path.join(script_dir, options.genpydir)) from ThriftTest import ThriftTest, SecondService from ThriftTest.ttypes import * from thrift.transport import TTransport from thrift.transport import TSocket from thrift.transport import THttpClient from thrift.transport import TZlibTransport from thrift.protocol import TBinaryProtocol from thrift.protocol import TCompactProtocol from thrift.protocol import TJSONProtocol class AbstractTest(unittest.TestCase): def setUp(self): if options.http_path: self.transport = THttpClient.THttpClient(options.host, port=options.port, path=options.http_path) else: if options.ssl: from thrift.transport import TSSLSocket socket = TSSLSocket.TSSLSocket(options.host, options.port, validate=False) else: socket = TSocket.TSocket(options.host, options.port) # frame or buffer depending upon args self.transport = TTransport.TBufferedTransport(socket) if options.trans == 'framed': self.transport = TTransport.TFramedTransport(socket) elif options.trans == 'buffered': self.transport = TTransport.TBufferedTransport(socket) elif options.trans == '': raise AssertionError('Unknown --transport option: %s' % options.trans) if options.zlib: self.transport = TZlibTransport.TZlibTransport(self.transport, 9) self.transport.open() protocol = self.protocol_factory.getProtocol(self.transport) self.client = ThriftTest.Client(protocol) def tearDown(self): # Close! self.transport.close() def testVoid(self): self.client.testVoid() def testString(self): self.assertEqual(self.client.testString('Python' * 20), 'Python' * 20) self.assertEqual(self.client.testString(''), '') def testByte(self): self.assertEqual(self.client.testByte(63), 63) self.assertEqual(self.client.testByte(-127), -127) def testI32(self): self.assertEqual(self.client.testI32(-1), -1) self.assertEqual(self.client.testI32(0), 0) def testI64(self): self.assertEqual(self.client.testI64(1), 1) self.assertEqual(self.client.testI64(-34359738368), -34359738368) def testDouble(self): self.assertEqual(self.client.testDouble(-5.235098235), -5.235098235) self.assertEqual(self.client.testDouble(0), 0) self.assertEqual(self.client.testDouble(-1), -1) # TODO: def testBinary(self) ... def testStruct(self): x = Xtruct() x.string_thing = "Zero" x.byte_thing = 1 x.i32_thing = -3 x.i64_thing = -5 y = self.client.testStruct(x) self.assertEqual(y, x) def testNest(self): inner = Xtruct(string_thing="Zero", byte_thing=1, i32_thing=-3, i64_thing=-5) x = Xtruct2(struct_thing=inner, byte_thing=0, i32_thing=0) y = self.client.testNest(x) self.assertEqual(y, x) def testMap(self): x = {0:1, 1:2, 2:3, 3:4, -1:-2} y = self.client.testMap(x) self.assertEqual(y, x) def testSet(self): x = set([8, 1, 42]) y = self.client.testSet(x) self.assertEqual(y, x) def testList(self): x = [1, 4, 9, -42] y = self.client.testList(x) self.assertEqual(y, x) def testEnum(self): x = Numberz.FIVE y = self.client.testEnum(x) self.assertEqual(y, x) def testTypedef(self): x = 0xffffffffffffff # 7 bytes of 0xff y = self.client.testTypedef(x) self.assertEqual(y, x) def testMapMap(self): # does not work: dict() is not a hashable type, so a dict() cannot be used as a key in another dict() #x = { {1:10, 2:20}, {1:100, 2:200, 3:300}, {1:1000, 2:2000, 3:3000, 4:4000} } try: y = self.client.testMapMap() except: pass def testMulti(self): xpected = Xtruct(string_thing='Hello2', byte_thing=74, i32_thing=0xff00ff, i64_thing=0xffffffffd0d0) y = self.client.testMulti(xpected.byte_thing, xpected.i32_thing, xpected.i64_thing, { 0:'abc' }, Numberz.FIVE, 0xf0f0f0) self.assertEqual(y, xpected) def testException(self): self.client.testException('Safe') try: self.client.testException('Xception') self.fail("should have gotten exception") except Xception, x: self.assertEqual(x.errorCode, 1001) self.assertEqual(x.message, 'Xception') # TODO ensure same behavior for repr within generated python variants # ensure exception's repr method works #x_repr = repr(x) #self.assertEqual(x_repr, 'Xception(errorCode=1001, message=\'Xception\')') try: self.client.testException("throw_undeclared") self.fail("should have thrown exception") except Exception: # type is undefined pass def testOneway(self): start = time.time() self.client.testOneway(1) # type is int, not float end = time.time() self.assertTrue(end - start < 3, "oneway sleep took %f sec" % (end - start)) def testOnewayThenNormal(self): self.client.testOneway(1) # type is int, not float self.assertEqual(self.client.testString('Python'), 'Python') class NormalBinaryTest(AbstractTest): protocol_factory = TBinaryProtocol.TBinaryProtocolFactory() class CompactTest(AbstractTest): protocol_factory = TCompactProtocol.TCompactProtocolFactory() class JSONTest(AbstractTest): protocol_factory = TJSONProtocol.TJSONProtocolFactory() class AcceleratedBinaryTest(AbstractTest): protocol_factory = TBinaryProtocol.TBinaryProtocolAcceleratedFactory() def suite(): suite = unittest.TestSuite() loader = unittest.TestLoader() if options.proto == 'binary': # look for --proto on cmdline suite.addTest(loader.loadTestsFromTestCase(NormalBinaryTest)) elif options.proto == 'accel': suite.addTest(loader.loadTestsFromTestCase(AcceleratedBinaryTest)) elif options.proto == 'compact': suite.addTest(loader.loadTestsFromTestCase(CompactTest)) elif options.proto == 'json': suite.addTest(loader.loadTestsFromTestCase(JSONTest)) else: raise AssertionError('Unknown protocol given with --protocol: %s' % options.proto) return suite class OwnArgsTestProgram(unittest.TestProgram): def parseArgs(self, argv): if args: self.testNames = args else: self.testNames = (self.defaultTest,) self.createTests() if __name__ == "__main__": OwnArgsTestProgram(defaultTest="suite", testRunner=unittest.TextTestRunner(verbosity=1))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 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, 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, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 984, 12, 5739, 12, 747, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 7, 9707, 773, 15, 647, 15, 1506, 15, 773, 2795, 1333, 59, 16, 566, 199, 199, 646, 2882, 199, 646, 900, 199, 504, 8691, 492, 13491, 199, 199, 2087, 275, 13491, 342, 199, 2087, 14, 525, 63, 1422, 4517, 2268, 647, 694, 297, 730, 534, 875, 297, 2053, 534, 2268, 647, 694, 297, 2116, 849, 534, 2268, 13, 647, 297, 2116, 1720, 534, 2613, 642, 2257, 2082, 315, 984, 14, 515, 367, 4355, 1958, 4046, 1233, 358, 199, 2087, 14, 525, 63, 1422, 6739, 719, 401, 730, 628, 442, 401, 2053, 628, 719, 401, 272, 1720, 628, 2242, 370, 1654, 737, 1844, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1102, 401, 730, 628, 875, 401, 2053, 628, 1102, 401, 272, 1720, 628, 2242, 370, 1654, 531, 199, 2087, 14, 525, 63, 1422, 6739, 15371, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 15371, 401, 272, 1720, 628, 1180, 12472, 4975, 367, 12335, 7773, 531, 199, 2087, 14, 525, 63, 1422, 6739, 4266, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 4266, 401, 272, 1720, 628, 1180, 7799, 367, 14862, 7773, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1014, 401, 2053, 628, 1014, 63, 515, 401, 272, 1720, 628, 6119, 314, 3101, 7773, 543, 314, 2013, 931, 531, 199, 2087, 14, 525, 63, 1422, 3654, 86, 297, 2850, 3832, 297, 1595, 628, 1617, 63, 1297, 401, 272, 2053, 628, 3832, 401, 950, 29, 18, 12, 272, 1720, 628, 3832, 1072, 531, 199, 2087, 14, 525, 63, 1422, 3654, 81, 297, 2850, 10243, 297, 1595, 628, 1617, 63, 1297, 401, 272, 2053, 628, 3832, 401, 950, 29, 16, 12, 272, 1720, 628, 21508, 1072, 531, 199, 2087, 14, 525, 63, 1422, 4517, 3922, 297, 221, 2053, 628, 2625, 401, 730, 628, 875, 401, 272, 1720, 628, 3922, 370, 675, 12, 1373, 402, 26, 1066, 6067, 12, 3366, 12, 23314, 12, 2022, 531, 199, 2087, 14, 525, 63, 1422, 4517, 5545, 297, 221, 2053, 628, 1515, 401, 730, 628, 875, 401, 272, 1720, 628, 5545, 370, 675, 12, 1373, 402, 26, 20224, 12, 2787, 68, 531, 199, 2087, 14, 409, 63, 4322, 8, 1943, 68, 29, 797, 12, 1455, 63, 515, 29, 403, 12, 3376, 29, 17, 12, 1591, 534, 5967, 297, 1844, 29, 25, 18526, 12, 4104, 534, 3008, 358, 199, 1419, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 1579, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 1511, 14, 2268, 647, 694, 430, 199, 199, 504, 3868, 6501, 774, 492, 3868, 6501, 774, 12, 16707, 3167, 199, 504, 3868, 6501, 774, 14, 21776, 492, 627, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 5545, 492, 377, 3869, 199, 504, 17199, 14, 5545, 492, 4221, 3370, 3041, 199, 504, 17199, 14, 5545, 492, 377, 58, 773, 7836, 199, 504, 17199, 14, 3922, 492, 15934, 199, 504, 17199, 14, 3922, 492, 377, 2404, 2442, 3658, 199, 504, 17199, 14, 3922, 492, 377, 6243, 3658, 199, 199, 533, 11836, 774, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 340, 1511, 14, 1014, 63, 515, 26, 489, 291, 14, 5545, 275, 4221, 3370, 3041, 14, 2080, 3370, 3041, 8, 1419, 14, 1102, 12, 1844, 29, 1419, 14, 719, 12, 931, 29, 1419, 14, 1014, 63, 515, 9, 272, 587, 26, 489, 340, 1511, 14, 4266, 26, 267, 687, 17199, 14, 5545, 492, 377, 5413, 3869, 267, 2838, 275, 377, 5413, 3869, 14, 52, 5413, 3869, 8, 1419, 14, 1102, 12, 1511, 14, 719, 12, 4107, 29, 797, 9, 489, 587, 26, 267, 2838, 275, 377, 3869, 14, 52, 3869, 8, 1419, 14, 1102, 12, 1511, 14, 719, 9, 489, 327, 2787, 503, 3335, 10298, 12188, 1249, 489, 291, 14, 5545, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 489, 340, 1511, 14, 1515, 508, 283, 1943, 68, 356, 267, 291, 14, 5545, 275, 19391, 14, 52, 3160, 68, 7836, 8, 3450, 9, 489, 916, 1511, 14, 1515, 508, 283, 17605, 356, 267, 291, 14, 5545, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 489, 916, 1511, 14, 1515, 508, 8061, 267, 746, 9070, 360, 5912, 1553, 5545, 945, 26, 450, 83, 7, 450, 1511, 14, 1515, 9, 489, 340, 1511, 14, 15371, 26, 267, 291, 14, 5545, 275, 377, 58, 773, 7836, 14, 14226, 773, 7836, 8, 277, 14, 5545, 12, 1749, 9, 272, 291, 14, 5545, 14, 1490, 342, 272, 4113, 275, 291, 14, 3922, 63, 3702, 14, 362, 3658, 8, 277, 14, 5545, 9, 272, 291, 14, 1258, 275, 3868, 6501, 774, 14, 3041, 8, 3922, 9, 819, 347, 6766, 8, 277, 304, 272, 327, 15524, 1, 272, 291, 14, 5545, 14, 1600, 342 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 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, 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, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 984, 12, 5739, 12, 747, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 7, 9707, 773, 15, 647, 15, 1506, 15, 773, 2795, 1333, 59, 16, 566, 199, 199, 646, 2882, 199, 646, 900, 199, 504, 8691, 492, 13491, 199, 199, 2087, 275, 13491, 342, 199, 2087, 14, 525, 63, 1422, 4517, 2268, 647, 694, 297, 730, 534, 875, 297, 2053, 534, 2268, 647, 694, 297, 2116, 849, 534, 2268, 13, 647, 297, 2116, 1720, 534, 2613, 642, 2257, 2082, 315, 984, 14, 515, 367, 4355, 1958, 4046, 1233, 358, 199, 2087, 14, 525, 63, 1422, 6739, 719, 401, 730, 628, 442, 401, 2053, 628, 719, 401, 272, 1720, 628, 2242, 370, 1654, 737, 1844, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1102, 401, 730, 628, 875, 401, 2053, 628, 1102, 401, 272, 1720, 628, 2242, 370, 1654, 531, 199, 2087, 14, 525, 63, 1422, 6739, 15371, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 15371, 401, 272, 1720, 628, 1180, 12472, 4975, 367, 12335, 7773, 531, 199, 2087, 14, 525, 63, 1422, 6739, 4266, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 4266, 401, 272, 1720, 628, 1180, 7799, 367, 14862, 7773, 531, 199, 2087, 14, 525, 63, 1422, 6739, 1014, 401, 2053, 628, 1014, 63, 515, 401, 272, 1720, 628, 6119, 314, 3101, 7773, 543, 314, 2013, 931, 531, 199, 2087, 14, 525, 63, 1422, 3654, 86, 297, 2850, 3832, 297, 1595, 628, 1617, 63, 1297, 401, 272, 2053, 628, 3832, 401, 950, 29, 18, 12, 272, 1720, 628, 3832, 1072, 531, 199, 2087, 14, 525, 63, 1422, 3654, 81, 297, 2850, 10243, 297, 1595, 628, 1617, 63, 1297, 401, 272, 2053, 628, 3832, 401, 950, 29, 16, 12, 272, 1720, 628, 21508, 1072, 531, 199, 2087, 14, 525, 63, 1422, 4517, 3922, 297, 221, 2053, 628, 2625, 401, 730, 628, 875, 401, 272, 1720, 628, 3922, 370, 675, 12, 1373, 402, 26, 1066, 6067, 12, 3366, 12, 23314, 12, 2022, 531, 199, 2087, 14, 525, 63, 1422, 4517, 5545, 297, 221, 2053, 628, 1515, 401, 730, 628, 875, 401, 272, 1720, 628, 5545, 370, 675, 12, 1373, 402, 26, 20224, 12, 2787, 68, 531, 199, 2087, 14, 409, 63, 4322, 8, 1943, 68, 29, 797, 12, 1455, 63, 515, 29, 403, 12, 3376, 29, 17, 12, 1591, 534, 5967, 297, 1844, 29, 25, 18526, 12, 4104, 534, 3008, 358, 199, 1419, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 1579, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 1511, 14, 2268, 647, 694, 430, 199, 199, 504, 3868, 6501, 774, 492, 3868, 6501, 774, 12, 16707, 3167, 199, 504, 3868, 6501, 774, 14, 21776, 492, 627, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 5545, 492, 377, 3869, 199, 504, 17199, 14, 5545, 492, 4221, 3370, 3041, 199, 504, 17199, 14, 5545, 492, 377, 58, 773, 7836, 199, 504, 17199, 14, 3922, 492, 15934, 199, 504, 17199, 14, 3922, 492, 377, 2404, 2442, 3658, 199, 504, 17199, 14, 3922, 492, 377, 6243, 3658, 199, 199, 533, 11836, 774, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 340, 1511, 14, 1014, 63, 515, 26, 489, 291, 14, 5545, 275, 4221, 3370, 3041, 14, 2080, 3370, 3041, 8, 1419, 14, 1102, 12, 1844, 29, 1419, 14, 719, 12, 931, 29, 1419, 14, 1014, 63, 515, 9, 272, 587, 26, 489, 340, 1511, 14, 4266, 26, 267, 687, 17199, 14, 5545, 492, 377, 5413, 3869, 267, 2838, 275, 377, 5413, 3869, 14, 52, 5413, 3869, 8, 1419, 14, 1102, 12, 1511, 14, 719, 12, 4107, 29, 797, 9, 489, 587, 26, 267, 2838, 275, 377, 3869, 14, 52, 3869, 8, 1419, 14, 1102, 12, 1511, 14, 719, 9, 489, 327, 2787, 503, 3335, 10298, 12188, 1249, 489, 291, 14, 5545, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 489, 340, 1511, 14, 1515, 508, 283, 1943, 68, 356, 267, 291, 14, 5545, 275, 19391, 14, 52, 3160, 68, 7836, 8, 3450, 9, 489, 916, 1511, 14, 1515, 508, 283, 17605, 356, 267, 291, 14, 5545, 275, 19391, 14, 52, 23139, 7836, 8, 3450, 9, 489, 916, 1511, 14, 1515, 508, 8061, 267, 746, 9070, 360, 5912, 1553, 5545, 945, 26, 450, 83, 7, 450, 1511, 14, 1515, 9, 489, 340, 1511, 14, 15371, 26, 267, 291, 14, 5545, 275, 377, 58, 773, 7836, 14, 14226, 773, 7836, 8, 277, 14, 5545, 12, 1749, 9, 272, 291, 14, 5545, 14, 1490, 342, 272, 4113, 275, 291, 14, 3922, 63, 3702, 14, 362, 3658, 8, 277, 14, 5545, 9, 272, 291, 14, 1258, 275, 3868, 6501, 774, 14, 3041, 8, 3922, 9, 819, 347, 6766, 8, 277, 304, 272, 327, 15524, 1, 272, 291, 14, 5545, 14, 1600, 342, 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 ]
graingert/aiohttp_session
setup.py
2
1582
import codecs from setuptools import setup, find_packages import os import re with codecs.open(os.path.join(os.path.abspath(os.path.dirname( __file__)), 'aiohttp_session', '__init__.py'), 'r', 'latin1') as fp: try: version = re.findall(r"^__version__ = '([^']+)'$", fp.read(), re.M)[0] except IndexError: raise RuntimeError('Unable to determine version.') def read(f): return open(os.path.join(os.path.dirname(__file__), f)).read().strip() install_requires = ['aiohttp>=0.14'] tests_require = install_requires + ['nose'] extras_require = {'aioredis': ['aioredis>=0.1.4'], 'pycrypto': ['pycrypto']} setup(name='aiohttp_session', version=version, description=("sessions for aiohttp.web"), long_description='\n\n'.join((read('README.rst'), read('CHANGES.txt'))), classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Developers', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Topic :: Internet :: WWW/HTTP'], author='Andrew Svetlov', author_email='andrew.svetlov@gmail.com', url='https://github.com/aio-libs/aiohttp_session/', license='Apache 2', packages=find_packages(), install_requires=install_requires, tests_require=tests_require, test_suite='nose.collector', include_package_data=True, extras_require=extras_require)
apache-2.0
[ 646, 6010, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 646, 747, 199, 646, 295, 421, 199, 1045, 6010, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 8, 267, 636, 493, 22159, 283, 65, 24134, 63, 1730, 297, 2560, 826, 4343, 647, 659, 283, 82, 297, 283, 10378, 17, 358, 465, 4090, 26, 272, 862, 26, 267, 1015, 275, 295, 14, 6452, 8, 82, 16136, 363, 1023, 363, 275, 283, 7059, 21899, 3171, 11918, 4090, 14, 739, 1062, 295, 14, 45, 2788, 16, 61, 272, 871, 7888, 26, 267, 746, 6064, 360, 6005, 370, 6705, 1015, 2659, 421, 199, 318, 1586, 8, 70, 304, 272, 372, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 289, 4992, 739, 1252, 1913, 342, 199, 199, 3174, 63, 6537, 275, 788, 65, 24134, 8119, 16, 14, 1079, 418, 199, 2219, 63, 4365, 275, 3907, 63, 6537, 435, 788, 21085, 418, 199, 9975, 63, 4365, 275, 791, 5789, 720, 2297, 356, 788, 5789, 720, 2297, 8119, 16, 14, 17, 14, 20, 995, 2116, 283, 647, 10316, 356, 788, 647, 10316, 12074, 421, 199, 2758, 8, 354, 534, 65, 24134, 63, 1730, 297, 489, 1015, 29, 1023, 12, 489, 1369, 15387, 11676, 367, 30274, 14, 2520, 1288, 489, 1846, 63, 1802, 17115, 78, 60, 78, 1370, 904, 1332, 739, 360, 18195, 14, 8332, 659, 1586, 360, 17858, 654, 14, 2424, 22645, 489, 19137, 1524, 881, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 881, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 995, 489, 4132, 534, 3325, 5257, 428, 28350, 32555, 297, 489, 4132, 63, 2123, 534, 460, 5257, 14, 2772, 386, 32555, 32, 6799, 14, 957, 297, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 65, 2308, 13, 8450, 15, 65, 24134, 63, 1730, 3678, 489, 4190, 534, 28993, 499, 297, 489, 6117, 29, 1623, 63, 5154, 1062, 489, 3907, 63, 6537, 29, 3174, 63, 6537, 12, 489, 2295, 63, 4365, 29, 2219, 63, 4365, 12, 489, 511, 63, 5768, 534, 21085, 14, 10946, 297, 489, 2387, 63, 2491, 63, 576, 29, 549, 12, 489, 13751, 63, 4365, 29, 9975, 63, 4365, 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 ]
[ 6010, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 646, 747, 199, 646, 295, 421, 199, 1045, 6010, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 8, 267, 636, 493, 22159, 283, 65, 24134, 63, 1730, 297, 2560, 826, 4343, 647, 659, 283, 82, 297, 283, 10378, 17, 358, 465, 4090, 26, 272, 862, 26, 267, 1015, 275, 295, 14, 6452, 8, 82, 16136, 363, 1023, 363, 275, 283, 7059, 21899, 3171, 11918, 4090, 14, 739, 1062, 295, 14, 45, 2788, 16, 61, 272, 871, 7888, 26, 267, 746, 6064, 360, 6005, 370, 6705, 1015, 2659, 421, 199, 318, 1586, 8, 70, 304, 272, 372, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 289, 4992, 739, 1252, 1913, 342, 199, 199, 3174, 63, 6537, 275, 788, 65, 24134, 8119, 16, 14, 1079, 418, 199, 2219, 63, 4365, 275, 3907, 63, 6537, 435, 788, 21085, 418, 199, 9975, 63, 4365, 275, 791, 5789, 720, 2297, 356, 788, 5789, 720, 2297, 8119, 16, 14, 17, 14, 20, 995, 2116, 283, 647, 10316, 356, 788, 647, 10316, 12074, 421, 199, 2758, 8, 354, 534, 65, 24134, 63, 1730, 297, 489, 1015, 29, 1023, 12, 489, 1369, 15387, 11676, 367, 30274, 14, 2520, 1288, 489, 1846, 63, 1802, 17115, 78, 60, 78, 1370, 904, 1332, 739, 360, 18195, 14, 8332, 659, 1586, 360, 17858, 654, 14, 2424, 22645, 489, 19137, 1524, 881, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 881, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 995, 489, 4132, 534, 3325, 5257, 428, 28350, 32555, 297, 489, 4132, 63, 2123, 534, 460, 5257, 14, 2772, 386, 32555, 32, 6799, 14, 957, 297, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 65, 2308, 13, 8450, 15, 65, 24134, 63, 1730, 3678, 489, 4190, 534, 28993, 499, 297, 489, 6117, 29, 1623, 63, 5154, 1062, 489, 3907, 63, 6537, 29, 3174, 63, 6537, 12, 489, 2295, 63, 4365, 29, 2219, 63, 4365, 12, 489, 511, 63, 5768, 534, 21085, 14, 10946, 297, 489, 2387, 63, 2491, 63, 576, 29, 549, 12, 489, 13751, 63, 4365, 29, 9975, 63, 4365, 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, 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 ]
effigies/mne-python
mne/minimum_norm/tests/test_psf_ctf.py
1
3160
import os.path as op import mne from mne.datasets import testing from mne import read_forward_solution, pick_types_forward from mne.minimum_norm import (read_inverse_operator, point_spread_function, cross_talk_function) from nose.tools import assert_true data_path = op.join(testing.data_path(download=False), 'MEG', 'sample') fname_inv = op.join(data_path, 'sample_audvis_trunc-meg-eeg-oct-6-meg-inv.fif') fname_fwd = op.join(data_path, 'sample_audvis_trunc-meg-eeg-oct-6-fwd.fif') fname_label = [op.join(data_path, 'labels', 'Aud-rh.label'), op.join(data_path, 'labels', 'Aud-lh.label')] snr = 3.0 lambda2 = 1.0 / snr ** 2 @testing.requires_testing_data def test_psf_ctf(): """Test computation of PSFs and CTFs for linear estimators """ inverse_operator = read_inverse_operator(fname_inv) forward = read_forward_solution(fname_fwd, force_fixed=False, surf_ori=True) forward = pick_types_forward(forward, meg=True, eeg=False) labels = [mne.read_label(ss) for ss in fname_label] method = 'MNE' n_svd_comp = 2 # Test PSFs (then CTFs) for mode in ('sum', 'svd'): stc_psf, psf_ev = point_spread_function(inverse_operator, forward, method=method, labels=labels, lambda2=lambda2, pick_ori='normal', mode=mode, n_svd_comp=n_svd_comp) n_vert, n_samples = stc_psf.shape should_n_vert = (inverse_operator['src'][1]['vertno'].shape[0] + inverse_operator['src'][0]['vertno'].shape[0]) if mode == 'svd': should_n_samples = len(labels) * n_svd_comp + 1 else: should_n_samples = len(labels) + 1 assert_true(n_vert == should_n_vert) assert_true(n_samples == should_n_samples) n_chan, n_samples = psf_ev.data.shape assert_true(n_chan == forward['nchan']) forward = read_forward_solution(fname_fwd, force_fixed=True, surf_ori=True) forward = pick_types_forward(forward, meg=True, eeg=False) # Test CTFs for mode in ('sum', 'svd'): stc_ctf = cross_talk_function(inverse_operator, forward, labels, method=method, lambda2=lambda2, signed=False, mode=mode, n_svd_comp=n_svd_comp) n_vert, n_samples = stc_ctf.shape should_n_vert = (inverse_operator['src'][1]['vertno'].shape[0] + inverse_operator['src'][0]['vertno'].shape[0]) if mode == 'svd': should_n_samples = len(labels) * n_svd_comp + 1 else: should_n_samples = len(labels) + 1 assert_true(n_vert == should_n_vert) assert_true(n_samples == should_n_samples)
bsd-3-clause
[ 199, 646, 747, 14, 515, 465, 1687, 199, 646, 18250, 199, 504, 18250, 14, 12281, 492, 5343, 199, 504, 18250, 492, 1586, 63, 6688, 63, 14458, 12, 3732, 63, 1313, 63, 6688, 199, 504, 18250, 14, 10700, 63, 4791, 492, 334, 739, 63, 11668, 63, 3856, 12, 2892, 2376, 63, 29889, 63, 1593, 12, 8059, 63, 21890, 63, 1593, 9, 199, 199, 504, 11354, 14, 2537, 492, 702, 63, 2052, 199, 199, 576, 63, 515, 275, 1687, 14, 904, 8, 4776, 14, 576, 63, 515, 8, 4249, 29, 797, 395, 283, 3635, 39, 297, 283, 3271, 358, 199, 5252, 63, 5350, 275, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3271, 63, 32024, 5068, 63, 8208, 13, 32177, 13, 1024, 71, 13, 15560, 13, 22, 13, 32177, 13, 5350, 14, 25533, 358, 199, 5252, 63, 27912, 275, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3271, 63, 32024, 5068, 63, 8208, 13, 32177, 13, 1024, 71, 13, 15560, 13, 22, 13, 27912, 14, 25533, 358, 199, 199, 5252, 63, 1302, 275, 359, 411, 14, 904, 8, 576, 63, 515, 12, 283, 3512, 297, 283, 33, 1181, 13, 17157, 14, 1302, 659, 2049, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3512, 297, 283, 33, 1181, 13, 25514, 14, 1302, 5440, 199, 199, 5167, 82, 275, 650, 14, 16, 199, 2734, 18, 275, 413, 14, 16, 1182, 6895, 82, 1011, 499, 421, 199, 32, 4776, 14, 6537, 63, 4776, 63, 576, 199, 318, 511, 63, 1190, 70, 63, 319, 70, 837, 272, 408, 774, 14009, 402, 29770, 83, 436, 445, 6145, 83, 367, 7798, 23155, 272, 408, 339, 11484, 63, 3856, 275, 1586, 63, 11668, 63, 3856, 8, 5252, 63, 5350, 9, 272, 7568, 275, 1586, 63, 6688, 63, 14458, 8, 5252, 63, 27912, 12, 3542, 63, 5964, 29, 797, 12, 2511, 24802, 63, 16039, 29, 549, 9, 272, 7568, 275, 3732, 63, 1313, 63, 6688, 8, 6688, 12, 562, 71, 29, 549, 12, 325, 5902, 29, 797, 9, 272, 3628, 275, 359, 22599, 14, 739, 63, 1302, 8, 385, 9, 367, 10110, 315, 6748, 63, 1302, 61, 339, 1083, 275, 283, 45, 6388, 7, 272, 302, 63, 18675, 63, 863, 275, 499, 339, 327, 1379, 29770, 83, 334, 12726, 445, 6145, 83, 9, 272, 367, 818, 315, 661, 1838, 297, 283, 18675, 735, 267, 410, 67, 63, 1190, 70, 12, 7347, 70, 63, 6857, 275, 2376, 63, 29889, 63, 1593, 8, 11668, 63, 3856, 12, 6059, 7568, 12, 6059, 1083, 29, 765, 12, 6059, 3628, 29, 3512, 12, 6059, 2400, 18, 29, 2734, 18, 12, 6059, 3732, 63, 16039, 534, 3302, 297, 6059, 818, 29, 632, 12, 6059, 302, 63, 18675, 63, 863, 29, 78, 63, 18675, 63, 863, 9, 398, 302, 63, 1884, 12, 302, 63, 3356, 275, 410, 67, 63, 1190, 70, 14, 1392, 267, 1077, 63, 78, 63, 1884, 275, 334, 11668, 63, 3856, 459, 2164, 3488, 17, 2733, 1884, 889, 2278, 1392, 59, 16, 61, 435, 586, 11484, 63, 3856, 459, 2164, 3488, 16, 2733, 1884, 889, 2278, 1392, 59, 16, 566, 267, 340, 818, 508, 283, 18675, 356, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 627, 302, 63, 18675, 63, 863, 435, 413, 267, 587, 26, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 435, 413, 398, 702, 63, 2052, 8, 78, 63, 1884, 508, 1077, 63, 78, 63, 1884, 9, 267, 702, 63, 2052, 8, 78, 63, 3356, 508, 1077, 63, 78, 63, 3356, 9, 398, 302, 63, 11984, 12, 302, 63, 3356, 275, 7347, 70, 63, 6857, 14, 576, 14, 1392, 267, 702, 63, 2052, 8, 78, 63, 11984, 508, 7568, 459, 78, 11984, 1105, 339, 7568, 275, 1586, 63, 6688, 63, 14458, 8, 5252, 63, 27912, 12, 3542, 63, 5964, 29, 549, 12, 24802, 63, 16039, 29, 549, 9, 272, 7568, 275, 3732, 63, 1313, 63, 6688, 8, 6688, 12, 562, 71, 29, 549, 12, 325, 5902, 29, 797, 9, 339, 327, 1379, 445, 6145, 83, 272, 367, 818, 315, 661, 1838, 297, 283, 18675, 735, 267, 410, 67, 63, 319, 70, 275, 8059, 63, 21890, 63, 1593, 8, 11668, 63, 3856, 12, 7568, 12, 4228, 3628, 12, 1083, 29, 765, 12, 4228, 2400, 18, 29, 2734, 18, 12, 4228, 10514, 29, 797, 12, 818, 29, 632, 12, 4228, 302, 63, 18675, 63, 863, 29, 78, 63, 18675, 63, 863, 9, 398, 302, 63, 1884, 12, 302, 63, 3356, 275, 410, 67, 63, 319, 70, 14, 1392, 267, 1077, 63, 78, 63, 1884, 275, 334, 11668, 63, 3856, 459, 2164, 3488, 17, 2733, 1884, 889, 2278, 1392, 59, 16, 61, 435, 586, 11484, 63, 3856, 459, 2164, 3488, 16, 2733, 1884, 889, 2278, 1392, 59, 16, 566, 267, 340, 818, 508, 283, 18675, 356, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 627, 302, 63, 18675, 63, 863, 435, 413, 267, 587, 26, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 435, 413, 398, 702, 63, 2052, 8, 78, 63, 1884, 508, 1077, 63, 78, 63, 1884, 9, 267, 702, 63, 2052, 8, 78, 63, 3356, 508, 1077, 63, 78, 63, 3356, 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 ]
[ 646, 747, 14, 515, 465, 1687, 199, 646, 18250, 199, 504, 18250, 14, 12281, 492, 5343, 199, 504, 18250, 492, 1586, 63, 6688, 63, 14458, 12, 3732, 63, 1313, 63, 6688, 199, 504, 18250, 14, 10700, 63, 4791, 492, 334, 739, 63, 11668, 63, 3856, 12, 2892, 2376, 63, 29889, 63, 1593, 12, 8059, 63, 21890, 63, 1593, 9, 199, 199, 504, 11354, 14, 2537, 492, 702, 63, 2052, 199, 199, 576, 63, 515, 275, 1687, 14, 904, 8, 4776, 14, 576, 63, 515, 8, 4249, 29, 797, 395, 283, 3635, 39, 297, 283, 3271, 358, 199, 5252, 63, 5350, 275, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3271, 63, 32024, 5068, 63, 8208, 13, 32177, 13, 1024, 71, 13, 15560, 13, 22, 13, 32177, 13, 5350, 14, 25533, 358, 199, 5252, 63, 27912, 275, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3271, 63, 32024, 5068, 63, 8208, 13, 32177, 13, 1024, 71, 13, 15560, 13, 22, 13, 27912, 14, 25533, 358, 199, 199, 5252, 63, 1302, 275, 359, 411, 14, 904, 8, 576, 63, 515, 12, 283, 3512, 297, 283, 33, 1181, 13, 17157, 14, 1302, 659, 2049, 1687, 14, 904, 8, 576, 63, 515, 12, 283, 3512, 297, 283, 33, 1181, 13, 25514, 14, 1302, 5440, 199, 199, 5167, 82, 275, 650, 14, 16, 199, 2734, 18, 275, 413, 14, 16, 1182, 6895, 82, 1011, 499, 421, 199, 32, 4776, 14, 6537, 63, 4776, 63, 576, 199, 318, 511, 63, 1190, 70, 63, 319, 70, 837, 272, 408, 774, 14009, 402, 29770, 83, 436, 445, 6145, 83, 367, 7798, 23155, 272, 408, 339, 11484, 63, 3856, 275, 1586, 63, 11668, 63, 3856, 8, 5252, 63, 5350, 9, 272, 7568, 275, 1586, 63, 6688, 63, 14458, 8, 5252, 63, 27912, 12, 3542, 63, 5964, 29, 797, 12, 2511, 24802, 63, 16039, 29, 549, 9, 272, 7568, 275, 3732, 63, 1313, 63, 6688, 8, 6688, 12, 562, 71, 29, 549, 12, 325, 5902, 29, 797, 9, 272, 3628, 275, 359, 22599, 14, 739, 63, 1302, 8, 385, 9, 367, 10110, 315, 6748, 63, 1302, 61, 339, 1083, 275, 283, 45, 6388, 7, 272, 302, 63, 18675, 63, 863, 275, 499, 339, 327, 1379, 29770, 83, 334, 12726, 445, 6145, 83, 9, 272, 367, 818, 315, 661, 1838, 297, 283, 18675, 735, 267, 410, 67, 63, 1190, 70, 12, 7347, 70, 63, 6857, 275, 2376, 63, 29889, 63, 1593, 8, 11668, 63, 3856, 12, 6059, 7568, 12, 6059, 1083, 29, 765, 12, 6059, 3628, 29, 3512, 12, 6059, 2400, 18, 29, 2734, 18, 12, 6059, 3732, 63, 16039, 534, 3302, 297, 6059, 818, 29, 632, 12, 6059, 302, 63, 18675, 63, 863, 29, 78, 63, 18675, 63, 863, 9, 398, 302, 63, 1884, 12, 302, 63, 3356, 275, 410, 67, 63, 1190, 70, 14, 1392, 267, 1077, 63, 78, 63, 1884, 275, 334, 11668, 63, 3856, 459, 2164, 3488, 17, 2733, 1884, 889, 2278, 1392, 59, 16, 61, 435, 586, 11484, 63, 3856, 459, 2164, 3488, 16, 2733, 1884, 889, 2278, 1392, 59, 16, 566, 267, 340, 818, 508, 283, 18675, 356, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 627, 302, 63, 18675, 63, 863, 435, 413, 267, 587, 26, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 435, 413, 398, 702, 63, 2052, 8, 78, 63, 1884, 508, 1077, 63, 78, 63, 1884, 9, 267, 702, 63, 2052, 8, 78, 63, 3356, 508, 1077, 63, 78, 63, 3356, 9, 398, 302, 63, 11984, 12, 302, 63, 3356, 275, 7347, 70, 63, 6857, 14, 576, 14, 1392, 267, 702, 63, 2052, 8, 78, 63, 11984, 508, 7568, 459, 78, 11984, 1105, 339, 7568, 275, 1586, 63, 6688, 63, 14458, 8, 5252, 63, 27912, 12, 3542, 63, 5964, 29, 549, 12, 24802, 63, 16039, 29, 549, 9, 272, 7568, 275, 3732, 63, 1313, 63, 6688, 8, 6688, 12, 562, 71, 29, 549, 12, 325, 5902, 29, 797, 9, 339, 327, 1379, 445, 6145, 83, 272, 367, 818, 315, 661, 1838, 297, 283, 18675, 735, 267, 410, 67, 63, 319, 70, 275, 8059, 63, 21890, 63, 1593, 8, 11668, 63, 3856, 12, 7568, 12, 4228, 3628, 12, 1083, 29, 765, 12, 4228, 2400, 18, 29, 2734, 18, 12, 4228, 10514, 29, 797, 12, 818, 29, 632, 12, 4228, 302, 63, 18675, 63, 863, 29, 78, 63, 18675, 63, 863, 9, 398, 302, 63, 1884, 12, 302, 63, 3356, 275, 410, 67, 63, 319, 70, 14, 1392, 267, 1077, 63, 78, 63, 1884, 275, 334, 11668, 63, 3856, 459, 2164, 3488, 17, 2733, 1884, 889, 2278, 1392, 59, 16, 61, 435, 586, 11484, 63, 3856, 459, 2164, 3488, 16, 2733, 1884, 889, 2278, 1392, 59, 16, 566, 267, 340, 818, 508, 283, 18675, 356, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 627, 302, 63, 18675, 63, 863, 435, 413, 267, 587, 26, 288, 1077, 63, 78, 63, 3356, 275, 822, 8, 3512, 9, 435, 413, 398, 702, 63, 2052, 8, 78, 63, 1884, 508, 1077, 63, 78, 63, 1884, 9, 267, 702, 63, 2052, 8, 78, 63, 3356, 508, 1077, 63, 78, 63, 3356, 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, 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, 0 ]
CopeX/odoo
openerp/addons/test_inherits/tests/test_inherits.py
266
1066
# -*- coding: utf-8 -*- from openerp.tests import common class test_inherits(common.TransactionCase): def test_create_3_levels_inherits(self): """ Check that we can create an inherits on 3 levels """ pallet = self.env['test.pallet'].create({ 'name': 'B', 'field_in_box': 'box', 'field_in_pallet': 'pallet', }) self.assertTrue(pallet) self.assertEqual(pallet.name, 'B') self.assertEqual(pallet.field_in_box, 'box') self.assertEqual(pallet.field_in_pallet, 'pallet') def test_read_3_levels_inherits(self): """ Check that we can read an inherited field on 3 levels """ pallet = self.env.ref('test_inherits.pallet_a') self.assertEqual(pallet.read(['name']), [{'id': pallet.id, 'name': 'Unit A'}]) def test_write_3_levels_inherits(self): """ Check that we can create an inherits on 3 levels """ pallet = self.env.ref('test_inherits.pallet_a') pallet.write({'name': 'C'}) self.assertEqual(pallet.name, 'C')
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 5166, 14, 2219, 492, 2863, 421, 199, 533, 511, 63, 20882, 8, 2330, 14, 10161, 1538, 304, 339, 347, 511, 63, 981, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1218, 376, 21592, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 459, 396, 14, 80, 9478, 2278, 981, 2561, 288, 283, 354, 356, 283, 34, 297, 288, 283, 698, 63, 262, 63, 1977, 356, 283, 1977, 297, 288, 283, 698, 63, 262, 63, 80, 9478, 356, 283, 80, 9478, 297, 267, 3828, 267, 291, 14, 1815, 8, 80, 9478, 9, 267, 291, 14, 629, 8, 80, 9478, 14, 354, 12, 283, 34, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 698, 63, 262, 63, 1977, 12, 283, 1977, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 698, 63, 262, 63, 80, 9478, 12, 283, 80, 9478, 358, 339, 347, 511, 63, 739, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1586, 376, 12623, 901, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 20882, 14, 80, 9478, 63, 65, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 739, 2941, 354, 3815, 9016, 344, 356, 299, 9478, 14, 344, 12, 283, 354, 356, 283, 5072, 437, 936, 566, 339, 347, 511, 63, 952, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1218, 376, 21592, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 20882, 14, 80, 9478, 63, 65, 358, 267, 299, 9478, 14, 952, 3252, 354, 356, 283, 35, 3071, 267, 291, 14, 629, 8, 80, 9478, 14, 354, 12, 283, 35, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 5166, 14, 2219, 492, 2863, 421, 199, 533, 511, 63, 20882, 8, 2330, 14, 10161, 1538, 304, 339, 347, 511, 63, 981, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1218, 376, 21592, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 459, 396, 14, 80, 9478, 2278, 981, 2561, 288, 283, 354, 356, 283, 34, 297, 288, 283, 698, 63, 262, 63, 1977, 356, 283, 1977, 297, 288, 283, 698, 63, 262, 63, 80, 9478, 356, 283, 80, 9478, 297, 267, 3828, 267, 291, 14, 1815, 8, 80, 9478, 9, 267, 291, 14, 629, 8, 80, 9478, 14, 354, 12, 283, 34, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 698, 63, 262, 63, 1977, 12, 283, 1977, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 698, 63, 262, 63, 80, 9478, 12, 283, 80, 9478, 358, 339, 347, 511, 63, 739, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1586, 376, 12623, 901, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 20882, 14, 80, 9478, 63, 65, 358, 267, 291, 14, 629, 8, 80, 9478, 14, 739, 2941, 354, 3815, 9016, 344, 356, 299, 9478, 14, 344, 12, 283, 354, 356, 283, 5072, 437, 936, 566, 339, 347, 511, 63, 952, 63, 19, 63, 11402, 63, 20882, 8, 277, 304, 267, 408, 2670, 626, 781, 883, 1218, 376, 21592, 641, 650, 11106, 408, 267, 299, 9478, 275, 291, 14, 1813, 14, 1121, 360, 396, 63, 20882, 14, 80, 9478, 63, 65, 358, 267, 299, 9478, 14, 952, 3252, 354, 356, 283, 35, 3071, 267, 291, 14, 629, 8, 80, 9478, 14, 354, 12, 283, 35, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
dulems/hue
desktop/core/ext-py/pytidylib-0.2.1/setup.py
38
3296
# Copyright 2009 Jason Stitt # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from distutils.core import setup longdesc = """\ 0.2.0: Works on Windows! See documentation for available DLL download locations. Documentation rewritten and expanded. `PyTidyLib`_ is a Python package that wraps the `HTML Tidy`_ library. This allows you, from Python code, to "fix" invalid (X)HTML markup. Some of the library's many capabilities include: * Clean up unclosed tags and unescaped characters such as ampersands * Output HTML 4 or XHTML, strict or transitional, and add missing doctypes * Convert named entities to numeric entities, which can then be used in XML documents without an HTML doctype. * Clean up HTML from programs such as Word (to an extent) * Indent the output, including proper (i.e. no) indenting for ``pre`` elements, which some (X)HTML indenting code overlooks. Small example of use ==================== The following code cleans up an invalid HTML document and sets an option:: from tidylib import tidy_document document, errors = tidy_document('''<p>f&otilde;o <img src="bar.jpg">''', options={'numeric-entities':1}) print document print errors Docs ==== Documentation is shipped with the source distribution and is available at the `PyTidyLib`_ web page. .. _`HTML Tidy`: http://tidy.sourceforge.net/ .. _`PyTidyLib`: http://countergram.com/open-source/pytidylib/ """ VERSION = "0.2.1" setup( name="pytidylib", version=VERSION, description="Python wrapper for HTML Tidy (tidylib)", long_description=longdesc, author="Jason Stitt", author_email="js@jasonstitt.com", url="http://countergram.com/open-source/pytidylib/", download_url="http://cloud.github.com/downloads/countergram/pytidylib/pytidylib-%s.tar.gz" % VERSION, packages=['tidylib'], classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Other Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Natural Language :: English', 'Topic :: Utilities', 'Topic :: Text Processing :: Markup :: HTML', 'Topic :: Text Processing :: Markup :: XML', ], )
apache-2.0
[ 3, 1898, 8937, 1603, 2660, 428, 280, 6215, 199, 3, 221, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 221, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 199, 504, 7065, 14, 1018, 492, 3272, 199, 199, 2809, 3257, 275, 9638, 199, 16, 14, 18, 14, 16, 26, 28099, 641, 5417, 1, 1666, 3794, 367, 2808, 577, 4464, 5235, 199, 8022, 14, 15249, 28286, 436, 11507, 14, 199, 199, 64, 2713, 32487, 89, 4728, 18417, 365, 282, 2018, 2559, 626, 14018, 314, 658, 4943, 377, 344, 89, 18417, 3555, 14, 961, 199, 24077, 1265, 12, 687, 2018, 1233, 12, 370, 298, 970, 2, 3866, 334, 56, 9, 4943, 9189, 14, 6601, 402, 314, 199, 4342, 1159, 5002, 14918, 2387, 26, 199, 199, 10, 12762, 1536, 625, 5938, 3762, 436, 625, 13572, 4110, 4066, 465, 15204, 1192, 5915, 199, 10, 7242, 4163, 841, 503, 26223, 12, 7478, 503, 14116, 279, 12, 436, 1050, 4124, 886, 9798, 199, 10, 7905, 4310, 9045, 370, 8950, 9045, 12, 1314, 883, 2066, 506, 1202, 315, 4692, 523, 8247, 1928, 376, 4163, 13265, 14, 199, 10, 12762, 1536, 4163, 687, 18572, 4066, 465, 14644, 334, 475, 376, 13675, 9, 199, 10, 1010, 1326, 314, 1072, 12, 5893, 5576, 334, 73, 14, 69, 14, 949, 9, 4363, 316, 367, 1124, 657, 1040, 4008, 12, 523, 1314, 2005, 334, 56, 9, 4943, 4363, 316, 1233, 1806, 11660, 83, 14, 199, 199, 10712, 2893, 402, 675, 199, 1280, 532, 199, 199, 1918, 2569, 1233, 15158, 796, 1536, 376, 3866, 4163, 2213, 436, 5951, 376, 945, 447, 339, 687, 3367, 22305, 492, 3367, 8161, 63, 3554, 272, 2213, 12, 2552, 275, 3367, 8161, 63, 3554, 10505, 28, 80, 30, 70, 6, 79, 16488, 27, 79, 665, 4060, 2928, 628, 1700, 14, 8476, 1743, 18108, 489, 1511, 3713, 6677, 13, 8327, 356, 17, 1552, 272, 870, 2213, 272, 870, 2552, 1362, 199, 27858, 199, 532, 199, 199, 17763, 365, 15924, 1915, 543, 314, 1350, 4084, 436, 365, 2808, 737, 199, 1589, 658, 2713, 32487, 89, 4728, 18417, 3330, 2034, 14, 199, 199, 703, 485, 64, 4943, 377, 344, 89, 8340, 1455, 921, 5700, 89, 14, 22943, 14, 846, 15, 199, 703, 485, 64, 2713, 32487, 89, 4728, 8340, 1455, 921, 5337, 1679, 14, 957, 15, 1490, 13, 1365, 15, 647, 5700, 89, 773, 15, 199, 624, 199, 199, 4612, 275, 298, 16, 14, 18, 14, 17, 2, 199, 199, 2758, 8, 272, 536, 628, 647, 5700, 89, 773, 401, 272, 1015, 29, 4612, 12, 272, 1369, 628, 4718, 4975, 367, 4163, 377, 344, 89, 334, 5700, 89, 773, 4186, 272, 1846, 63, 1802, 29, 2809, 3257, 12, 272, 4132, 628, 42, 2660, 428, 280, 6215, 401, 272, 4132, 63, 2123, 628, 3596, 32, 74, 2660, 6329, 84, 14, 957, 401, 272, 1166, 628, 1014, 921, 5337, 1679, 14, 957, 15, 1490, 13, 1365, 15, 647, 5700, 89, 773, 10665, 272, 5235, 63, 633, 628, 1014, 921, 4091, 14, 5031, 14, 957, 15, 20373, 15, 5337, 1679, 15, 647, 5700, 89, 773, 15, 647, 5700, 89, 773, 3295, 83, 14, 5369, 14, 6838, 2, 450, 15945, 12, 272, 6117, 2968, 5700, 89, 773, 995, 272, 19137, 1524, 881, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 881, 283, 8263, 3800, 5439, 9711, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 23604, 4889, 8466, 3800, 20144, 297, 881, 283, 12157, 3800, 738, 17933, 297, 881, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4163, 297, 881, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4692, 297, 881, 2156, 272, 776, 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 ]
[ 1898, 8937, 1603, 2660, 428, 280, 6215, 199, 3, 221, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 221, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 221, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 199, 504, 7065, 14, 1018, 492, 3272, 199, 199, 2809, 3257, 275, 9638, 199, 16, 14, 18, 14, 16, 26, 28099, 641, 5417, 1, 1666, 3794, 367, 2808, 577, 4464, 5235, 199, 8022, 14, 15249, 28286, 436, 11507, 14, 199, 199, 64, 2713, 32487, 89, 4728, 18417, 365, 282, 2018, 2559, 626, 14018, 314, 658, 4943, 377, 344, 89, 18417, 3555, 14, 961, 199, 24077, 1265, 12, 687, 2018, 1233, 12, 370, 298, 970, 2, 3866, 334, 56, 9, 4943, 9189, 14, 6601, 402, 314, 199, 4342, 1159, 5002, 14918, 2387, 26, 199, 199, 10, 12762, 1536, 625, 5938, 3762, 436, 625, 13572, 4110, 4066, 465, 15204, 1192, 5915, 199, 10, 7242, 4163, 841, 503, 26223, 12, 7478, 503, 14116, 279, 12, 436, 1050, 4124, 886, 9798, 199, 10, 7905, 4310, 9045, 370, 8950, 9045, 12, 1314, 883, 2066, 506, 1202, 315, 4692, 523, 8247, 1928, 376, 4163, 13265, 14, 199, 10, 12762, 1536, 4163, 687, 18572, 4066, 465, 14644, 334, 475, 376, 13675, 9, 199, 10, 1010, 1326, 314, 1072, 12, 5893, 5576, 334, 73, 14, 69, 14, 949, 9, 4363, 316, 367, 1124, 657, 1040, 4008, 12, 523, 1314, 2005, 334, 56, 9, 4943, 4363, 316, 1233, 1806, 11660, 83, 14, 199, 199, 10712, 2893, 402, 675, 199, 1280, 532, 199, 199, 1918, 2569, 1233, 15158, 796, 1536, 376, 3866, 4163, 2213, 436, 5951, 376, 945, 447, 339, 687, 3367, 22305, 492, 3367, 8161, 63, 3554, 272, 2213, 12, 2552, 275, 3367, 8161, 63, 3554, 10505, 28, 80, 30, 70, 6, 79, 16488, 27, 79, 665, 4060, 2928, 628, 1700, 14, 8476, 1743, 18108, 489, 1511, 3713, 6677, 13, 8327, 356, 17, 1552, 272, 870, 2213, 272, 870, 2552, 1362, 199, 27858, 199, 532, 199, 199, 17763, 365, 15924, 1915, 543, 314, 1350, 4084, 436, 365, 2808, 737, 199, 1589, 658, 2713, 32487, 89, 4728, 18417, 3330, 2034, 14, 199, 199, 703, 485, 64, 4943, 377, 344, 89, 8340, 1455, 921, 5700, 89, 14, 22943, 14, 846, 15, 199, 703, 485, 64, 2713, 32487, 89, 4728, 8340, 1455, 921, 5337, 1679, 14, 957, 15, 1490, 13, 1365, 15, 647, 5700, 89, 773, 15, 199, 624, 199, 199, 4612, 275, 298, 16, 14, 18, 14, 17, 2, 199, 199, 2758, 8, 272, 536, 628, 647, 5700, 89, 773, 401, 272, 1015, 29, 4612, 12, 272, 1369, 628, 4718, 4975, 367, 4163, 377, 344, 89, 334, 5700, 89, 773, 4186, 272, 1846, 63, 1802, 29, 2809, 3257, 12, 272, 4132, 628, 42, 2660, 428, 280, 6215, 401, 272, 4132, 63, 2123, 628, 3596, 32, 74, 2660, 6329, 84, 14, 957, 401, 272, 1166, 628, 1014, 921, 5337, 1679, 14, 957, 15, 1490, 13, 1365, 15, 647, 5700, 89, 773, 10665, 272, 5235, 63, 633, 628, 1014, 921, 4091, 14, 5031, 14, 957, 15, 20373, 15, 5337, 1679, 15, 647, 5700, 89, 773, 15, 647, 5700, 89, 773, 3295, 83, 14, 5369, 14, 6838, 2, 450, 15945, 12, 272, 6117, 2968, 5700, 89, 773, 995, 272, 19137, 1524, 881, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 881, 283, 8263, 3800, 5439, 9711, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 23604, 4889, 8466, 3800, 20144, 297, 881, 283, 12157, 3800, 738, 17933, 297, 881, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4163, 297, 881, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4692, 297, 881, 2156, 272, 776, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ischeinfeld/py_nlp
tests_deprecated/test.py
1
1056
"""Tests examples of the parameters q and e""" from preprocessing import import_wsj, replace_rarities from parameters import sx_counts, uvs_counts, uv_counts, s_counts, q, e sentences = import_wsj("train") #print(sentences[0]) new_sentences = replace_rarities(sentences) #print(new_sentences[0]) sx_counts = sx_counts(new_sentences) uvs_counts = uvs_counts(new_sentences) s_counts = s_counts(new_sentences) uv_counts = uv_counts(new_sentences) num_tags = 0 for key in s_counts: num_tags += 1 print() print("There are " + str(num_tags) + " tags.") print() print("c(s,x) -> c(DT, the): ", sx_counts['DT']['the']) print() print("c(u,v,s) -> c(<START>, NN, NNS): ", uvs_counts['<START>']['NN']['NNS']) print() print("c(s) -> c(DT): ", s_counts['DT']) print() print("c(u,v) -> c(<START>, NN): ", uv_counts['<START>']['NN']) print() print() q_suv = q(uvs_counts, uv_counts, "NNS", "<START>", "NN") e_xs = e(sx_counts, s_counts, "the", "DT") print("q(s|u,v) -> q(NNS, <START>, NN): ", q_suv) print() print("e(x|s) -> e(the, DT): ", e_xs) print()
mit
[ 624, 2925, 7251, 402, 314, 2633, 1894, 436, 325, 624, 199, 199, 504, 26471, 492, 492, 63, 3569, 74, 12, 3350, 63, 82, 27894, 199, 504, 2633, 492, 23132, 63, 6851, 12, 399, 3122, 63, 6851, 12, 20879, 63, 6851, 12, 308, 63, 6851, 12, 1894, 12, 325, 199, 199, 25669, 275, 492, 63, 3569, 74, 480, 2834, 531, 199, 3, 1361, 8, 25669, 59, 16, 566, 199, 199, 1222, 63, 25669, 275, 3350, 63, 82, 27894, 8, 25669, 9, 199, 3, 1361, 8, 1222, 63, 25669, 59, 16, 566, 199, 199, 12915, 63, 6851, 275, 23132, 63, 6851, 8, 1222, 63, 25669, 9, 199, 25793, 63, 6851, 275, 399, 3122, 63, 6851, 8, 1222, 63, 25669, 9, 199, 83, 63, 6851, 275, 308, 63, 6851, 8, 1222, 63, 25669, 9, 199, 9154, 63, 6851, 275, 20879, 63, 6851, 8, 1222, 63, 25669, 9, 199, 199, 1507, 63, 2969, 275, 378, 199, 509, 790, 315, 308, 63, 6851, 26, 272, 1967, 63, 2969, 847, 413, 199, 199, 1361, 342, 199, 1361, 480, 10924, 787, 298, 435, 620, 8, 1507, 63, 2969, 9, 435, 298, 3762, 2685, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 83, 12, 88, 9, 1035, 286, 8, 7438, 12, 314, 304, 3872, 23132, 63, 6851, 459, 7438, 2545, 1589, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 85, 12, 86, 12, 83, 9, 1035, 286, 27530, 7363, 6244, 31242, 12, 653, 2709, 304, 3872, 399, 3122, 63, 6851, 459, 28, 7363, 30, 2545, 7178, 2545, 46, 2709, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 83, 9, 1035, 286, 8, 7438, 304, 3872, 308, 63, 6851, 459, 7438, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 85, 12, 86, 9, 1035, 286, 27530, 7363, 6244, 31242, 304, 3872, 20879, 63, 6851, 459, 28, 7363, 30, 2545, 7178, 1105, 199, 199, 1361, 342, 199, 1361, 342, 199, 199, 81, 63, 83, 9154, 275, 1894, 8, 25793, 63, 6851, 12, 20879, 63, 6851, 12, 298, 46, 2709, 401, 3886, 7363, 7166, 298, 7178, 531, 199, 69, 63, 7977, 275, 325, 8, 12915, 63, 6851, 12, 308, 63, 6851, 12, 298, 1589, 401, 298, 7438, 531, 199, 199, 1361, 480, 81, 8, 83, 92, 85, 12, 86, 9, 1035, 1894, 8, 46, 2709, 12, 665, 7363, 6244, 31242, 304, 3872, 1894, 63, 83, 9154, 9, 199, 1361, 342, 199, 199, 1361, 480, 69, 8, 88, 92, 83, 9, 1035, 325, 8, 1589, 12, 19852, 304, 3872, 325, 63, 7977, 9, 199, 1361, 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 ]
[ 2925, 7251, 402, 314, 2633, 1894, 436, 325, 624, 199, 199, 504, 26471, 492, 492, 63, 3569, 74, 12, 3350, 63, 82, 27894, 199, 504, 2633, 492, 23132, 63, 6851, 12, 399, 3122, 63, 6851, 12, 20879, 63, 6851, 12, 308, 63, 6851, 12, 1894, 12, 325, 199, 199, 25669, 275, 492, 63, 3569, 74, 480, 2834, 531, 199, 3, 1361, 8, 25669, 59, 16, 566, 199, 199, 1222, 63, 25669, 275, 3350, 63, 82, 27894, 8, 25669, 9, 199, 3, 1361, 8, 1222, 63, 25669, 59, 16, 566, 199, 199, 12915, 63, 6851, 275, 23132, 63, 6851, 8, 1222, 63, 25669, 9, 199, 25793, 63, 6851, 275, 399, 3122, 63, 6851, 8, 1222, 63, 25669, 9, 199, 83, 63, 6851, 275, 308, 63, 6851, 8, 1222, 63, 25669, 9, 199, 9154, 63, 6851, 275, 20879, 63, 6851, 8, 1222, 63, 25669, 9, 199, 199, 1507, 63, 2969, 275, 378, 199, 509, 790, 315, 308, 63, 6851, 26, 272, 1967, 63, 2969, 847, 413, 199, 199, 1361, 342, 199, 1361, 480, 10924, 787, 298, 435, 620, 8, 1507, 63, 2969, 9, 435, 298, 3762, 2685, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 83, 12, 88, 9, 1035, 286, 8, 7438, 12, 314, 304, 3872, 23132, 63, 6851, 459, 7438, 2545, 1589, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 85, 12, 86, 12, 83, 9, 1035, 286, 27530, 7363, 6244, 31242, 12, 653, 2709, 304, 3872, 399, 3122, 63, 6851, 459, 28, 7363, 30, 2545, 7178, 2545, 46, 2709, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 83, 9, 1035, 286, 8, 7438, 304, 3872, 308, 63, 6851, 459, 7438, 1105, 199, 199, 1361, 342, 199, 1361, 480, 67, 8, 85, 12, 86, 9, 1035, 286, 27530, 7363, 6244, 31242, 304, 3872, 20879, 63, 6851, 459, 28, 7363, 30, 2545, 7178, 1105, 199, 199, 1361, 342, 199, 1361, 342, 199, 199, 81, 63, 83, 9154, 275, 1894, 8, 25793, 63, 6851, 12, 20879, 63, 6851, 12, 298, 46, 2709, 401, 3886, 7363, 7166, 298, 7178, 531, 199, 69, 63, 7977, 275, 325, 8, 12915, 63, 6851, 12, 308, 63, 6851, 12, 298, 1589, 401, 298, 7438, 531, 199, 199, 1361, 480, 81, 8, 83, 92, 85, 12, 86, 9, 1035, 1894, 8, 46, 2709, 12, 665, 7363, 6244, 31242, 304, 3872, 1894, 63, 83, 9154, 9, 199, 1361, 342, 199, 199, 1361, 480, 69, 8, 88, 92, 83, 9, 1035, 325, 8, 1589, 12, 19852, 304, 3872, 325, 63, 7977, 9, 199, 1361, 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, 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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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 ]
petewarden/tensorflow
third_party/gpus/compress_find_rocm_config.py
10
1172
# Copyright 2020 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. # ============================================================================== """Compresses the contents of 'find_rocm_config.py'. The compressed file is what is actually being used. It works around remote config not being able to upload files yet. """ import base64 import zlib def main(): with open('find_rocm_config.py', 'rb') as f: data = f.read() compressed = zlib.compress(data) b64encoded = base64.b64encode(compressed) with open('find_rocm_config.py.gz.base64', 'wb') as f: f.write(b64encoded) if __name__ == '__main__': main()
apache-2.0
[ 3, 1898, 25455, 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, 2404, 4357, 314, 4072, 402, 283, 1623, 63, 293, 4400, 63, 888, 14, 647, 1370, 199, 199, 1918, 12335, 570, 365, 4052, 365, 5965, 3769, 1202, 14, 2779, 5419, 6818, 3982, 199, 888, 440, 3769, 7688, 370, 5802, 1584, 5966, 14, 199, 624, 199, 646, 1300, 772, 199, 646, 12472, 421, 199, 318, 2446, 837, 523, 543, 1551, 360, 1623, 63, 293, 4400, 63, 888, 14, 647, 297, 283, 4848, 358, 465, 289, 26, 272, 666, 275, 289, 14, 739, 342, 819, 12335, 275, 12472, 14, 6447, 8, 576, 9, 523, 330, 772, 8167, 275, 1300, 772, 14, 66, 772, 2143, 8, 10895, 9, 819, 543, 1551, 360, 1623, 63, 293, 4400, 63, 888, 14, 647, 14, 6838, 14, 1095, 772, 297, 283, 6603, 358, 465, 289, 26, 272, 289, 14, 952, 8, 66, 772, 8167, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 25455, 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, 2404, 4357, 314, 4072, 402, 283, 1623, 63, 293, 4400, 63, 888, 14, 647, 1370, 199, 199, 1918, 12335, 570, 365, 4052, 365, 5965, 3769, 1202, 14, 2779, 5419, 6818, 3982, 199, 888, 440, 3769, 7688, 370, 5802, 1584, 5966, 14, 199, 624, 199, 646, 1300, 772, 199, 646, 12472, 421, 199, 318, 2446, 837, 523, 543, 1551, 360, 1623, 63, 293, 4400, 63, 888, 14, 647, 297, 283, 4848, 358, 465, 289, 26, 272, 666, 275, 289, 14, 739, 342, 819, 12335, 275, 12472, 14, 6447, 8, 576, 9, 523, 330, 772, 8167, 275, 1300, 772, 14, 66, 772, 2143, 8, 10895, 9, 819, 543, 1551, 360, 1623, 63, 293, 4400, 63, 888, 14, 647, 14, 6838, 14, 1095, 772, 297, 283, 6603, 358, 465, 289, 26, 272, 289, 14, 952, 8, 66, 772, 8167, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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path.dirname(os.path.abspath(__file__)) DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'demo', 'USER': 'postgres', } } TIME_ZONE = 'America/Vancouver' LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = True SECRET_KEY = '%$gy=knpq2essdfsfsdf_kedoi-j1es=$o02nc*v$^=^8zs*&s@@nij@zev%m2' ROOT_URLCONF = 'mm3demo.urls' TEMPLATE_DIRS = ( os.path.realpath(os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/')), ) INSTALLED_APPS += ( 'lingcod.raster_stats', 'mlpa', 'lingcod.analysistools') # For some reason, running the raster_stats tests causes # the xml test runner to fail to output the xml EXCLUDE_FROM_TESTS.append('lingcod.raster_stats') KML_EXTRUDE_HEIGHT = 700 import os MEDIA_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__),'mediaroot')) POSTGIS_TEMPLATE='template1' APP_NAME = "MarineMap 3.0 Demo" KML_ALTITUDEMODE_DEFAULT = 'clampToGround' try: from settings_local import * except: pass
bsd-3-clause
[ 3, 5634, 2202, 367, 312, 1135, 265, 2199, 14, 199, 504, 634, 316, 7889, 14, 2330, 14, 885, 63, 1751, 492, 627, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 2828, 14, 5668, 14, 697, 14, 7765, 14, 1932, 5668, 297, 267, 283, 2339, 356, 283, 8768, 297, 267, 283, 3791, 356, 283, 10675, 297, 1362, 789, 199, 93, 199, 199, 4961, 63, 15353, 275, 283, 8841, 15, 54, 290, 331, 85, 422, 7, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 7917, 63, 998, 275, 413, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 12961, 63, 3078, 275, 1543, 4, 4312, 29, 75, 1590, 81, 18, 16709, 10434, 2319, 1587, 63, 25503, 16142, 13, 74, 17, 397, 28617, 79, 996, 7966, 10, 86, 4, 62, 29, 62, 24, 31765, 10, 6, 83, 7492, 78, 7879, 32, 806, 86, 5, 77, 18, 7, 199, 199, 5441, 63, 18125, 275, 283, 596, 19, 8768, 14, 3603, 7, 199, 199, 7433, 63, 14455, 275, 334, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 1959, 1814, 11671, 32381, 3855, 776, 199, 199, 15942, 63, 14219, 847, 334, 283, 2983, 7889, 14, 20876, 63, 3200, 297, 283, 757, 387, 297, 283, 2983, 7889, 14, 4797, 11734, 5998, 358, 199, 199, 3, 2104, 2005, 4499, 12, 3879, 314, 19775, 63, 3200, 2295, 14486, 199, 3, 314, 2748, 511, 7876, 370, 2449, 370, 1072, 314, 2748, 199, 1438, 13958, 63, 12491, 63, 7569, 14, 740, 360, 2983, 7889, 14, 20876, 63, 3200, 358, 199, 199, 43, 1698, 63, 1438, 1766, 11749, 63, 13509, 275, 30071, 199, 199, 646, 747, 199, 13669, 63, 5441, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 7, 3700, 285, 26974, 1333, 199, 199, 4030, 11092, 63, 7433, 534, 1160, 17, 7, 199, 7121, 63, 2339, 275, 298, 10570, 1132, 2956, 650, 14, 16, 28939, 2, 199, 199, 43, 1698, 63, 19600, 28742, 6963, 63, 3472, 275, 283, 3995, 311, 1378, 39, 2363, 7, 199, 893, 26, 272, 687, 2202, 63, 1832, 492, 627, 199, 2590, 26, 272, 986, 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 ]
[ 5634, 2202, 367, 312, 1135, 265, 2199, 14, 199, 504, 634, 316, 7889, 14, 2330, 14, 885, 63, 1751, 492, 627, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 2828, 14, 5668, 14, 697, 14, 7765, 14, 1932, 5668, 297, 267, 283, 2339, 356, 283, 8768, 297, 267, 283, 3791, 356, 283, 10675, 297, 1362, 789, 199, 93, 199, 199, 4961, 63, 15353, 275, 283, 8841, 15, 54, 290, 331, 85, 422, 7, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 7917, 63, 998, 275, 413, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 12961, 63, 3078, 275, 1543, 4, 4312, 29, 75, 1590, 81, 18, 16709, 10434, 2319, 1587, 63, 25503, 16142, 13, 74, 17, 397, 28617, 79, 996, 7966, 10, 86, 4, 62, 29, 62, 24, 31765, 10, 6, 83, 7492, 78, 7879, 32, 806, 86, 5, 77, 18, 7, 199, 199, 5441, 63, 18125, 275, 283, 596, 19, 8768, 14, 3603, 7, 199, 199, 7433, 63, 14455, 275, 334, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 1959, 1814, 11671, 32381, 3855, 776, 199, 199, 15942, 63, 14219, 847, 334, 283, 2983, 7889, 14, 20876, 63, 3200, 297, 283, 757, 387, 297, 283, 2983, 7889, 14, 4797, 11734, 5998, 358, 199, 199, 3, 2104, 2005, 4499, 12, 3879, 314, 19775, 63, 3200, 2295, 14486, 199, 3, 314, 2748, 511, 7876, 370, 2449, 370, 1072, 314, 2748, 199, 1438, 13958, 63, 12491, 63, 7569, 14, 740, 360, 2983, 7889, 14, 20876, 63, 3200, 358, 199, 199, 43, 1698, 63, 1438, 1766, 11749, 63, 13509, 275, 30071, 199, 199, 646, 747, 199, 13669, 63, 5441, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 7, 3700, 285, 26974, 1333, 199, 199, 4030, 11092, 63, 7433, 534, 1160, 17, 7, 199, 7121, 63, 2339, 275, 298, 10570, 1132, 2956, 650, 14, 16, 28939, 2, 199, 199, 43, 1698, 63, 19600, 28742, 6963, 63, 3472, 275, 283, 3995, 311, 1378, 39, 2363, 7, 199, 893, 26, 272, 687, 2202, 63, 1832, 492, 627, 199, 2590, 26, 272, 986, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
maelnor/nova
nova/conductor/tasks/live_migrate.py
14
8059
# 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.config import cfg from nova.compute import power_state from nova.compute import rpcapi as compute_rpcapi from nova.compute import utils as compute_utils from nova import db from nova import exception from nova.i18n import _ from nova import image from nova.openstack.common import log as logging from nova.scheduler import client as scheduler_client from nova.scheduler import utils as scheduler_utils from nova import servicegroup LOG = logging.getLogger(__name__) migrate_opt = cfg.IntOpt('migrate_max_retries', default=-1, help='Number of times to retry live-migration before failing. ' 'If == -1, try until out of hosts. ' 'If == 0, only try once, no retries.') CONF = cfg.CONF CONF.register_opt(migrate_opt) class LiveMigrationTask(object): def __init__(self, context, instance, destination, block_migration, disk_over_commit): self.context = context self.instance = instance self.destination = destination self.block_migration = block_migration self.disk_over_commit = disk_over_commit self.source = instance.host self.migrate_data = None self.compute_rpcapi = compute_rpcapi.ComputeAPI() self.servicegroup_api = servicegroup.API() self.scheduler_client = scheduler_client.SchedulerClient() self.image_api = image.API() def execute(self): self._check_instance_is_running() self._check_host_is_up(self.source) if not self.destination: self.destination = self._find_destination() else: self._check_requested_destination() # TODO(johngarbutt) need to move complexity out of compute manager # TODO(johngarbutt) disk_over_commit? return self.compute_rpcapi.live_migration(self.context, host=self.source, instance=self.instance, dest=self.destination, block_migration=self.block_migration, migrate_data=self.migrate_data) def rollback(self): # TODO(johngarbutt) need to implement the clean up operation # but this will make sense only once we pull in the compute # calls, since this class currently makes no state changes, # except to call the compute method, that has no matching # rollback call right now. raise NotImplementedError() def _check_instance_is_running(self): if self.instance.power_state != power_state.RUNNING: raise exception.InstanceNotRunning( instance_id=self.instance.uuid) def _check_host_is_up(self, host): try: service = db.service_get_by_compute_host(self.context, host) except exception.NotFound: raise exception.ComputeServiceUnavailable(host=host) if not self.servicegroup_api.service_is_up(service): raise exception.ComputeServiceUnavailable(host=host) def _check_requested_destination(self): self._check_destination_is_not_source() self._check_host_is_up(self.destination) self._check_destination_has_enough_memory() self._check_compatible_with_source_hypervisor(self.destination) self._call_livem_checks_on_host(self.destination) def _check_destination_is_not_source(self): if self.destination == self.source: raise exception.UnableToMigrateToSelf( instance_id=self.instance.uuid, host=self.destination) def _check_destination_has_enough_memory(self): avail = self._get_compute_info(self.destination)['free_ram_mb'] mem_inst = self.instance.memory_mb if not mem_inst or avail <= mem_inst: instance_uuid = self.instance.uuid dest = self.destination reason = _("Unable to migrate %(instance_uuid)s to %(dest)s: " "Lack of memory(host:%(avail)s <= " "instance:%(mem_inst)s)") raise exception.MigrationPreCheckError(reason=reason % dict( instance_uuid=instance_uuid, dest=dest, avail=avail, mem_inst=mem_inst)) def _get_compute_info(self, host): service_ref = db.service_get_by_compute_host(self.context, host) return service_ref['compute_node'][0] def _check_compatible_with_source_hypervisor(self, destination): source_info = self._get_compute_info(self.source) destination_info = self._get_compute_info(destination) source_type = source_info['hypervisor_type'] destination_type = destination_info['hypervisor_type'] if source_type != destination_type: raise exception.InvalidHypervisorType() source_version = source_info['hypervisor_version'] destination_version = destination_info['hypervisor_version'] if source_version > destination_version: raise exception.DestinationHypervisorTooOld() def _call_livem_checks_on_host(self, destination): self.migrate_data = self.compute_rpcapi.\ check_can_live_migrate_destination(self.context, self.instance, destination, self.block_migration, self.disk_over_commit) def _find_destination(self): # TODO(johngarbutt) this retry loop should be shared attempted_hosts = [self.source] image = None if self.instance.image_ref: image = compute_utils.get_image_metadata(self.context, self.image_api, self.instance.image_ref, self.instance) request_spec = scheduler_utils.build_request_spec(self.context, image, [self.instance]) host = None while host is None: self._check_not_over_max_retries(attempted_hosts) filter_properties = {'ignore_hosts': attempted_hosts} host = self.scheduler_client.select_destinations(self.context, request_spec, filter_properties)[0]['host'] try: self._check_compatible_with_source_hypervisor(host) self._call_livem_checks_on_host(host) except exception.Invalid as e: LOG.debug("Skipping host: %(host)s because: %(e)s", {"host": host, "e": e}) attempted_hosts.append(host) host = None return host def _check_not_over_max_retries(self, attempted_hosts): if CONF.migrate_max_retries == -1: return retries = len(attempted_hosts) - 1 if retries > CONF.migrate_max_retries: msg = (_('Exceeded max scheduling retries %(max_retries)d for ' 'instance %(instance_uuid)s during live migration') % {'max_retries': retries, 'instance_uuid': self.instance.uuid}) raise exception.NoValidHost(reason=msg) def execute(context, instance, destination, block_migration, disk_over_commit): task = LiveMigrationTask(context, instance, destination, block_migration, disk_over_commit) # TODO(johngarbutt) create a superclass that contains a safe_execute call return task.execute()
apache-2.0
[ 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, 14, 888, 492, 4810, 199, 199, 504, 5913, 14, 3357, 492, 7074, 63, 929, 199, 504, 5913, 14, 3357, 492, 8985, 1246, 465, 4526, 63, 20776, 199, 504, 5913, 14, 3357, 492, 3778, 465, 4526, 63, 1208, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 492, 1834, 199, 504, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 5913, 14, 8874, 492, 1890, 465, 11899, 63, 1258, 199, 504, 5913, 14, 8874, 492, 3778, 465, 11899, 63, 1208, 199, 504, 5913, 492, 2435, 923, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 8462, 63, 2992, 275, 4810, 14, 3241, 9985, 360, 8462, 63, 988, 63, 10937, 297, 267, 849, 4022, 17, 12, 267, 1720, 534, 3259, 402, 5431, 370, 7269, 12166, 13, 8998, 2544, 18648, 14, 283, 1467, 283, 3917, 508, 446, 17, 12, 862, 5133, 734, 402, 7057, 14, 283, 1467, 283, 3917, 508, 378, 12, 1454, 862, 5403, 12, 949, 10086, 2659, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 2992, 8, 8462, 63, 2992, 9, 421, 199, 533, 24683, 9816, 4476, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1067, 12, 1256, 12, 5724, 12, 326, 1853, 63, 8998, 12, 4543, 63, 1883, 63, 3543, 304, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 842, 275, 1256, 267, 291, 14, 6881, 275, 5724, 267, 291, 14, 1457, 63, 8998, 275, 1853, 63, 8998, 267, 291, 14, 4032, 63, 1883, 63, 3543, 275, 4543, 63, 1883, 63, 3543, 267, 291, 14, 1365, 275, 1256, 14, 1102, 267, 291, 14, 8462, 63, 576, 275, 488, 267, 291, 14, 3357, 63, 20776, 275, 4526, 63, 20776, 14, 8564, 3735, 342, 267, 291, 14, 29409, 63, 1246, 275, 2435, 923, 14, 3735, 342, 267, 291, 14, 8874, 63, 1258, 275, 11899, 63, 1258, 14, 11251, 3041, 342, 267, 291, 14, 1569, 63, 1246, 275, 1834, 14, 3735, 342, 339, 347, 5341, 8, 277, 304, 267, 291, 423, 1074, 63, 842, 63, 374, 63, 5720, 342, 267, 291, 423, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 14, 1365, 9, 398, 340, 440, 291, 14, 6881, 26, 288, 291, 14, 6881, 275, 291, 423, 1623, 63, 6881, 342, 267, 587, 26, 288, 291, 423, 1074, 63, 11151, 63, 6881, 342, 398, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 1929, 370, 4057, 6114, 1209, 734, 402, 4526, 5256, 267, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 4543, 63, 1883, 63, 3543, 31, 267, 372, 291, 14, 3357, 63, 20776, 14, 6442, 63, 8998, 8, 277, 14, 1100, 12, 355, 1591, 29, 277, 14, 1365, 12, 355, 1256, 29, 277, 14, 842, 12, 355, 2053, 29, 277, 14, 6881, 12, 355, 1853, 63, 8998, 29, 277, 14, 1457, 63, 8998, 12, 355, 12810, 63, 576, 29, 277, 14, 8462, 63, 576, 9, 339, 347, 16475, 8, 277, 304, 267, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 1929, 370, 5669, 314, 3633, 1536, 3439, 267, 327, 1325, 642, 911, 1852, 12249, 1454, 5403, 781, 10299, 315, 314, 4526, 267, 327, 4882, 12, 3967, 642, 1021, 5544, 7704, 949, 1174, 4493, 12, 267, 327, 871, 370, 1240, 314, 4526, 1083, 12, 626, 965, 949, 4877, 267, 327, 16475, 1240, 2451, 3063, 14, 267, 746, 4279, 342, 339, 347, 485, 1074, 63, 842, 63, 374, 63, 5720, 8, 277, 304, 267, 340, 291, 14, 842, 14, 5652, 63, 929, 1137, 7074, 63, 929, 14, 17305, 26, 288, 746, 1919, 14, 3244, 1763, 9602, 8, 490, 1256, 63, 344, 29, 277, 14, 842, 14, 2580, 9, 339, 347, 485, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 12, 1591, 304, 267, 862, 26, 288, 2435, 275, 1592, 14, 1364, 63, 362, 63, 991, 63, 3357, 63, 1102, 8, 277, 14, 1100, 12, 1591, 9, 267, 871, 1919, 14, 4667, 26, 288, 746, 1919, 14, 8564, 3167, 28049, 8, 1102, 29, 1102, 9, 398, 340, 440, 291, 14, 29409, 63, 1246, 14, 1364, 63, 374, 63, 384, 8, 1364, 304, 288, 746, 1919, 14, 8564, 3167, 28049, 8, 1102, 29, 1102, 9, 339, 347, 485, 1074, 63, 11151, 63, 6881, 8, 277, 304, 267, 291, 423, 1074, 63, 6881, 63, 374, 63, 1397, 63, 1365, 342, 267, 291, 423, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 14, 6881, 9, 267, 291, 423, 1074, 63, 6881, 63, 1989, 63, 30881, 63, 4844, 342, 267, 291, 423, 1074, 63, 6490, 63, 1045, 63, 1365, 63, 18237, 8, 277, 14, 6881, 9, 267, 291, 423, 1250, 63, 6442, 77, 63, 8625, 63, 265, 63, 1102, 8, 277, 14, 6881, 9, 339, 347, 485, 1074, 63, 6881, 63, 374, 63, 1397, 63, 1365, 8, 277, 304, 267, 340, 291, 14, 6881, 508, 291, 14, 1365, 26, 288, 746, 1919, 14, 6005, 1378, 26641, 1378, 12887, 8, 490, 1256, 63, 344, 29, 277, 14, 842, 14, 2580, 12, 1591, 29, 277, 14, 6881, 9, 339, 347, 485, 1074, 63, 6881, 63, 1989, 63, 30881, 63, 4844, 8, 277, 304, 267, 21006, 275, 291, 423, 362, 63, 3357, 63, 815, 8, 277, 14, 6881, 11820, 4624, 63, 5975, 63, 887, 418, 267, 7573, 63, 3615, 275, 291, 14, 842, 14, 4844, 63 ]
[ 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, 14, 888, 492, 4810, 199, 199, 504, 5913, 14, 3357, 492, 7074, 63, 929, 199, 504, 5913, 14, 3357, 492, 8985, 1246, 465, 4526, 63, 20776, 199, 504, 5913, 14, 3357, 492, 3778, 465, 4526, 63, 1208, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 492, 1834, 199, 504, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 5913, 14, 8874, 492, 1890, 465, 11899, 63, 1258, 199, 504, 5913, 14, 8874, 492, 3778, 465, 11899, 63, 1208, 199, 504, 5913, 492, 2435, 923, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 8462, 63, 2992, 275, 4810, 14, 3241, 9985, 360, 8462, 63, 988, 63, 10937, 297, 267, 849, 4022, 17, 12, 267, 1720, 534, 3259, 402, 5431, 370, 7269, 12166, 13, 8998, 2544, 18648, 14, 283, 1467, 283, 3917, 508, 446, 17, 12, 862, 5133, 734, 402, 7057, 14, 283, 1467, 283, 3917, 508, 378, 12, 1454, 862, 5403, 12, 949, 10086, 2659, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 2992, 8, 8462, 63, 2992, 9, 421, 199, 533, 24683, 9816, 4476, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1067, 12, 1256, 12, 5724, 12, 326, 1853, 63, 8998, 12, 4543, 63, 1883, 63, 3543, 304, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 842, 275, 1256, 267, 291, 14, 6881, 275, 5724, 267, 291, 14, 1457, 63, 8998, 275, 1853, 63, 8998, 267, 291, 14, 4032, 63, 1883, 63, 3543, 275, 4543, 63, 1883, 63, 3543, 267, 291, 14, 1365, 275, 1256, 14, 1102, 267, 291, 14, 8462, 63, 576, 275, 488, 267, 291, 14, 3357, 63, 20776, 275, 4526, 63, 20776, 14, 8564, 3735, 342, 267, 291, 14, 29409, 63, 1246, 275, 2435, 923, 14, 3735, 342, 267, 291, 14, 8874, 63, 1258, 275, 11899, 63, 1258, 14, 11251, 3041, 342, 267, 291, 14, 1569, 63, 1246, 275, 1834, 14, 3735, 342, 339, 347, 5341, 8, 277, 304, 267, 291, 423, 1074, 63, 842, 63, 374, 63, 5720, 342, 267, 291, 423, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 14, 1365, 9, 398, 340, 440, 291, 14, 6881, 26, 288, 291, 14, 6881, 275, 291, 423, 1623, 63, 6881, 342, 267, 587, 26, 288, 291, 423, 1074, 63, 11151, 63, 6881, 342, 398, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 1929, 370, 4057, 6114, 1209, 734, 402, 4526, 5256, 267, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 4543, 63, 1883, 63, 3543, 31, 267, 372, 291, 14, 3357, 63, 20776, 14, 6442, 63, 8998, 8, 277, 14, 1100, 12, 355, 1591, 29, 277, 14, 1365, 12, 355, 1256, 29, 277, 14, 842, 12, 355, 2053, 29, 277, 14, 6881, 12, 355, 1853, 63, 8998, 29, 277, 14, 1457, 63, 8998, 12, 355, 12810, 63, 576, 29, 277, 14, 8462, 63, 576, 9, 339, 347, 16475, 8, 277, 304, 267, 327, 3254, 8, 31073, 2753, 285, 7911, 84, 9, 1929, 370, 5669, 314, 3633, 1536, 3439, 267, 327, 1325, 642, 911, 1852, 12249, 1454, 5403, 781, 10299, 315, 314, 4526, 267, 327, 4882, 12, 3967, 642, 1021, 5544, 7704, 949, 1174, 4493, 12, 267, 327, 871, 370, 1240, 314, 4526, 1083, 12, 626, 965, 949, 4877, 267, 327, 16475, 1240, 2451, 3063, 14, 267, 746, 4279, 342, 339, 347, 485, 1074, 63, 842, 63, 374, 63, 5720, 8, 277, 304, 267, 340, 291, 14, 842, 14, 5652, 63, 929, 1137, 7074, 63, 929, 14, 17305, 26, 288, 746, 1919, 14, 3244, 1763, 9602, 8, 490, 1256, 63, 344, 29, 277, 14, 842, 14, 2580, 9, 339, 347, 485, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 12, 1591, 304, 267, 862, 26, 288, 2435, 275, 1592, 14, 1364, 63, 362, 63, 991, 63, 3357, 63, 1102, 8, 277, 14, 1100, 12, 1591, 9, 267, 871, 1919, 14, 4667, 26, 288, 746, 1919, 14, 8564, 3167, 28049, 8, 1102, 29, 1102, 9, 398, 340, 440, 291, 14, 29409, 63, 1246, 14, 1364, 63, 374, 63, 384, 8, 1364, 304, 288, 746, 1919, 14, 8564, 3167, 28049, 8, 1102, 29, 1102, 9, 339, 347, 485, 1074, 63, 11151, 63, 6881, 8, 277, 304, 267, 291, 423, 1074, 63, 6881, 63, 374, 63, 1397, 63, 1365, 342, 267, 291, 423, 1074, 63, 1102, 63, 374, 63, 384, 8, 277, 14, 6881, 9, 267, 291, 423, 1074, 63, 6881, 63, 1989, 63, 30881, 63, 4844, 342, 267, 291, 423, 1074, 63, 6490, 63, 1045, 63, 1365, 63, 18237, 8, 277, 14, 6881, 9, 267, 291, 423, 1250, 63, 6442, 77, 63, 8625, 63, 265, 63, 1102, 8, 277, 14, 6881, 9, 339, 347, 485, 1074, 63, 6881, 63, 374, 63, 1397, 63, 1365, 8, 277, 304, 267, 340, 291, 14, 6881, 508, 291, 14, 1365, 26, 288, 746, 1919, 14, 6005, 1378, 26641, 1378, 12887, 8, 490, 1256, 63, 344, 29, 277, 14, 842, 14, 2580, 12, 1591, 29, 277, 14, 6881, 9, 339, 347, 485, 1074, 63, 6881, 63, 1989, 63, 30881, 63, 4844, 8, 277, 304, 267, 21006, 275, 291, 423, 362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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 ]
rifotu/ipv6_trials
gpsd/gpsd_src/gpscap.py
1
8725
""" gpscap - GPS/AIS capability dictionary class. This file is Copyright (c) 2010 by the GPSD project BSD terms apply: see the file COPYING in the distribution root for details. """ import ConfigParser class GPSDictionary(ConfigParser.RawConfigParser): def __init__(self, *files): "Initialize the capability dictionary" ConfigParser.RawConfigParser.__init__(self) if not files: files = ["gpscap.ini", "/usr/share/gpsd/gpscap.ini"] self.read(files) # Resolve uses= members while True: keepgoing = False for section in self.sections(): if self.has_option(section, "uses"): parent = self.get(section, "uses") if self.has_option(parent, "uses"): continue # Found a parent section without a uses = part. for heritable in self.options(parent): if not self.has_option(section, heritable): self.set(section, heritable, self.get(parent, heritable)) keepgoing = True self.remove_option(section, "uses") if not keepgoing: break # Sanity check: All items must have a type field. for section in self.sections(): if not self.has_option(section, "type"): raise ConfigParser.Error("%s has no type" % section) elif self.get(section, "type") not in ("engine", "vendor", "device"): raise ConfigParser.Error("%s has invalid type" % section) # Sanity check: All devices must point at a vendor object. # Side effect: build the lists of vendors and devices. self.vendors = [] self.devices = [] for section in self.sections(): if self.get(section, "type") == "vendor": self.vendors.append(section) if self.get(section, "type") == "device": self.devices.append(section) self.vendors.sort() for section in self.sections(): if self.get(section, "type") == "device": if not self.has_option(section, "vendor"): raise ConfigParser.Error("%s has no vendor" % section) if self.get(section, "vendor") not in self.vendors: raise ConfigParser.Error("%s has invalid vendor" % section) def HTMLDump(self, ofp): thead = """<table style='border:1px solid gray;font-size:small;background-color:#CCCCCC'> <caption>Listing %s devices from %s vendors</caption> <tr> <th>Name</th> <th>Packaging</th> <th>Engine</th> <th>Interface</th> <th>Tested with</th> <th>NMEA version</th> <th>PPS</th> <th style='width:50%%'>Notes</th> </tr> """ vhead1 = "<tr><td style='text-align:center;' colspan='8'><a href='%s'>%s</a></td></tr>\n" vhead2 = "<tr><td style='text-align:center;' colspan='8'><a href='%s'>%s</a><br><p>%s</p></td></tr>\n" hotpluggables = ("pl2303", "CP2101") ofp.write(thead % (len(self.devices), len(self.vendors))) for vendor in self.vendors: if self.has_option(vendor, "notes"): ofp.write(vhead2 % (self.get(vendor, "vendor_site"), vendor, self.get(vendor, "notes"))) else: ofp.write(vhead1 % (self.get(vendor, "vendor_site"), vendor)) relevant = [] for dev in self.devices: if self.get(dev, "vendor") == vendor: relevant.append(dev) relevant.sort() for dev in relevant: rowcolor = "white" if self.get(dev, "packaging") == "OEM module": rowcolor = "#32CD32" elif self.get(dev, "packaging") == "chipset": rowcolor = "#FFFFE0" elif self.get(dev, "packaging") == "handset": rowcolor = "#00FFFF" elif self.get(dev, "packaging") == "hansdfree": rowcolor = "#008B8B" ofp.write("<tr itemscope itemtype='http://schema.org/Product' style='background-color:%s'>\n" % rowcolor) namefield = dev if self.has_option(dev, "techdoc"): namefield = "<a href='%s'>%s</a>" % (self.get(dev, "techdoc"), dev) if self.has_option(dev, "discontinued") and self.getboolean(dev, "discontinued"): namefield = namefield + "&nbsp;<img title='Device discontinued' src='discontinued.png' alt='Discontinued icon'>" ofp.write("<td itemprop='name'>%s</td>\n" % namefield) ofp.write("<td>%s</td>\n" % self.get(dev, "packaging")) engine = self.get(dev, "engine") if self.has_option(engine, "techdoc"): engine = "<a href='%s'>%s</a>" % (self.get(engine, "techdoc"), engine) if self.has_option(dev, "subtype"): engine += " (" + self.get(dev, "subtype") + ")" ofp.write("<td>%s</td>\n" % engine) interfaces = self.get(dev, "interfaces") if self.has_option(dev, "pps"): interfaces += ",PPS" ofp.write("<td>%s</td>\n" % interfaces) testfield = "" if self.has_option(dev, "tested"): tested = self.get(dev, "tested") if tested == "regression": testfield += "<img title='Have regression test' src='regression.png' alt='Regression-test icon'>" else: testfield += tested if self.has_option(dev, "configurable") and self.get(dev, "configurable") == 'insane': testfield += "<img title='Requires -b option' src='noconfigure.png' alt='No-configure icon'>" if self.get(dev, "rating") == "excellent": testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "good": testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "fair": testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "poor": testfield += "<img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "broken": testfield += "<img title='Device is broken' src='bomb.png' alt='Bomb icon'>" if self.has_option(dev, "usbchip") and self.get(dev, "usbchip") in hotpluggables: testfield += "<img title='udev hotplug' src='hotplug.png' alt='Hotplug icon'>" ofp.write("<td>%s</td>\n" % testfield) nmea = "&nbsp;" if self.has_option(dev, "nmea"): nmea = self.get(dev, "nmea") ofp.write("<td>%s</td>\n" % nmea) if self.has_option(dev, "pps") and self.get(dev, "pps") == "True": pps_accuracy = time_offset = "" if self.has_option(dev, "pps_accuracy"): pps_accuracy = self.get(dev, "pps_accuracy") if self.has_option(dev, "time_offset"): time_offset = self.get(dev, "time_offset") if pps_accuracy and time_offset: ofp.write("<td>%s<br>%s</td>\n" % (pps_accuracy, time_offset)) else: ofp.write("<td>?<br>\n") else: ofp.write("<td>No</td>\n") if self.has_option(dev, "notes"): notes = self.get(dev, "notes") else: notes = "" if self.has_option(dev, "submitter"): notes += " Reported by %s." % self.get(dev, "submitter").replace("@", "&#x40;").replace("<", "&lt;").replace(">", "&gt;") ofp.write("<td itemscope itemtype='http://schema.org/description'>%s</td>\n" % notes) ofp.write("</tr>\n") ofp.write("</table>\n") if __name__ == "__main__": import sys try: d = GPSDictionary() d.HTMLDump(sys.stdout) except ConfigParser.Error, e: print >>sys.stderr, sys.argv[0]+":", e raise SystemExit, 1
mit
[ 624, 199, 199, 4927, 551, 439, 446, 598, 5067, 15, 33, 1311, 19854, 2600, 1021, 14, 199, 199, 2765, 570, 365, 1898, 334, 67, 9, 7129, 701, 314, 17346, 3693, 2199, 199, 15400, 2895, 4838, 26, 1937, 314, 570, 9685, 315, 314, 4084, 1738, 367, 2436, 14, 199, 624, 199, 646, 14196, 199, 199, 533, 598, 5067, 11728, 8, 15218, 14, 7963, 15218, 304, 272, 347, 636, 826, 721, 277, 12, 627, 1725, 304, 267, 298, 9345, 314, 19854, 2600, 2, 267, 14196, 14, 7963, 15218, 855, 826, 721, 277, 9, 267, 340, 440, 1584, 26, 288, 1584, 275, 2097, 4927, 551, 439, 14, 2730, 401, 3286, 2647, 15, 6251, 15, 25556, 68, 15, 4927, 551, 439, 14, 2730, 937, 267, 291, 14, 739, 8, 1725, 9, 267, 327, 31096, 4440, 29, 7556, 267, 1830, 715, 26, 288, 4215, 10947, 275, 756, 288, 367, 3420, 315, 291, 14, 7786, 837, 355, 340, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 5589, 2349, 490, 1676, 275, 291, 14, 362, 8, 2792, 12, 298, 5589, 531, 490, 340, 291, 14, 1989, 63, 1422, 8, 1708, 12, 298, 5589, 2349, 717, 1980, 490, 327, 2643, 282, 1676, 3420, 1928, 282, 4440, 275, 1777, 14, 490, 367, 14737, 390, 461, 315, 291, 14, 1419, 8, 1708, 304, 717, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 14737, 390, 461, 304, 1169, 291, 14, 409, 8, 2792, 12, 3660, 14737, 390, 461, 12, 3660, 291, 14, 362, 8, 1708, 12, 14737, 390, 461, 430, 1169, 4215, 10947, 275, 715, 490, 291, 14, 2168, 63, 1422, 8, 2792, 12, 298, 5589, 531, 288, 340, 440, 4215, 10947, 26, 355, 2059, 267, 327, 22111, 1104, 26, 2900, 2974, 1471, 1172, 282, 730, 901, 14, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 466, 2349, 355, 746, 14196, 14, 547, 3647, 83, 965, 949, 730, 2, 450, 3420, 9, 288, 916, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 440, 315, 1689, 3908, 401, 298, 9884, 401, 298, 1782, 2349, 355, 746, 14196, 14, 547, 3647, 83, 965, 3866, 730, 2, 450, 3420, 9, 267, 327, 22111, 1104, 26, 2900, 7256, 1471, 2376, 737, 282, 20868, 909, 14, 267, 327, 428, 2655, 7763, 26, 1900, 314, 5548, 402, 373, 500, 1384, 436, 7256, 14, 267, 291, 14, 86, 500, 1384, 275, 942, 267, 291, 14, 6410, 275, 942, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 9884, 582, 355, 291, 14, 86, 500, 1384, 14, 740, 8, 2792, 9, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 1782, 582, 355, 291, 14, 6410, 14, 740, 8, 2792, 9, 267, 291, 14, 86, 500, 1384, 14, 3191, 342, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 1782, 582, 355, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 9884, 2349, 490, 746, 14196, 14, 547, 3647, 83, 965, 949, 20868, 2, 450, 3420, 9, 355, 340, 291, 14, 362, 8, 2792, 12, 298, 9884, 531, 440, 315, 291, 14, 86, 500, 1384, 26, 490, 746, 14196, 14, 547, 3647, 83, 965, 3866, 20868, 2, 450, 3420, 9, 339, 347, 4163, 11772, 8, 277, 12, 15643, 304, 267, 314, 350, 275, 8894, 1224, 3449, 534, 8665, 26, 17, 5326, 18609, 21977, 27, 4246, 13, 890, 26, 7241, 27, 7451, 13, 2326, 15596, 27994, 2571, 8423, 199, 28, 13410, 30, 26138, 450, 83, 7256, 687, 450, 83, 373, 500, 1384, 1108, 13410, 30, 199, 28, 454, 30, 199, 28, 273, 30, 985, 1108, 273, 30, 199, 28, 273, 30, 2305, 7407, 1108, 273, 30, 199, 28, 273, 30, 8524, 1108, 273, 30, 199, 28, 273, 30, 4267, 1108, 273, 30, 199, 28, 273, 30, 52, 3505, 543, 1108, 273, 30, 199, 28, 273, 30, 46, 3635, 33, 1015, 1108, 273, 30, 199, 28, 273, 30, 48, 5067, 1108, 273, 30, 199, 28, 273, 3449, 534, 2063, 26, 1400, 8530, 8423, 18685, 1108, 273, 30, 199, 1108, 454, 30, 199, 624, 267, 373, 2993, 17, 275, 3886, 454, 2535, 2076, 3449, 534, 505, 13, 5743, 26, 4218, 8942, 26384, 534, 24, 7, 2535, 65, 4369, 9569, 83, 7, 6598, 83, 1108, 65, 2957, 2076, 2957, 454, 3072, 78, 2, 267, 373, 2993, 18, 275, 3886, 454, 2535, 2076, 3449, 534, 505, 13, 5743, 26, 4218, 8942, 26384, 534, 24, 7, 2535, 65, 4369, 9569, 83, 7, 6598, 83, 1108, 65, 2535, 3289, 2535, 80, 6598, 83, 1108, 80, 2957, 2076, 2957, 454, 3072, 78, 2, 267, 18469, 13963, 71, 5921, 275, 1689, 1168, 9687, 19, 401, 298, 2890, 2025, 614, 531, 267, 15643, 14, 952, 8, 21519, 450, 334, 552, 8, 277, 14, 6410, 395, 822, 8, 277, 14, 86, 500, 1384, 1724, 267, 367, 20868, 315, 291, 14, 86, 500, 1384, 26, 288, 340, 291, 14, 1989, 63, 1422, 8, 9884, 12, 298, 5983, 2349, 355, 15643, 14, 952, 8, 86, 2993, 18, 450, 334, 277, 14, 362, 8, 9884, 12, 298, 9884, 63, 2124, 1288, 20868, 12, 291, 14, 362, 8, 9884, 12, 298, 5983, 13324, 288, 587, 26, 355, 15643, 14, 952, 8, 86, 2993, 17, 450, 334, 277, 14, 362, 8, 9884, 12, 298, 9884, 63, 2124, 1288, 20868, 430, 288, 12082, 275, 942, 288, 367, 4866, 315, 291, 14, 6410, 26, 355, 340, 291, 14, 362, 8, 2374, 12, 298, 9884, 531, 508, 20868, 26, 490, 12082, 14, 740, 8, 2374, 9, 288, 12082, 14, 3191, 342, 288, 367, 4866, 315, 12082, 26, 355, 1962, 2326, 275, 298, 7510, 2, 355, 340, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 47, 2769, 859, 582, 490, 1962, 2326, 275, 5426, 708, 7695, 708, 2, 355, 916, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 28329, 409, 582, 490, 1962, 2326, 275, 5426, 6968, 37, 16, 2, 355, 916, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 6868, 409, 582, 490, 1962, 2326, 275, 5426 ]
[ 199, 199, 4927, 551, 439, 446, 598, 5067, 15, 33, 1311, 19854, 2600, 1021, 14, 199, 199, 2765, 570, 365, 1898, 334, 67, 9, 7129, 701, 314, 17346, 3693, 2199, 199, 15400, 2895, 4838, 26, 1937, 314, 570, 9685, 315, 314, 4084, 1738, 367, 2436, 14, 199, 624, 199, 646, 14196, 199, 199, 533, 598, 5067, 11728, 8, 15218, 14, 7963, 15218, 304, 272, 347, 636, 826, 721, 277, 12, 627, 1725, 304, 267, 298, 9345, 314, 19854, 2600, 2, 267, 14196, 14, 7963, 15218, 855, 826, 721, 277, 9, 267, 340, 440, 1584, 26, 288, 1584, 275, 2097, 4927, 551, 439, 14, 2730, 401, 3286, 2647, 15, 6251, 15, 25556, 68, 15, 4927, 551, 439, 14, 2730, 937, 267, 291, 14, 739, 8, 1725, 9, 267, 327, 31096, 4440, 29, 7556, 267, 1830, 715, 26, 288, 4215, 10947, 275, 756, 288, 367, 3420, 315, 291, 14, 7786, 837, 355, 340, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 5589, 2349, 490, 1676, 275, 291, 14, 362, 8, 2792, 12, 298, 5589, 531, 490, 340, 291, 14, 1989, 63, 1422, 8, 1708, 12, 298, 5589, 2349, 717, 1980, 490, 327, 2643, 282, 1676, 3420, 1928, 282, 4440, 275, 1777, 14, 490, 367, 14737, 390, 461, 315, 291, 14, 1419, 8, 1708, 304, 717, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 14737, 390, 461, 304, 1169, 291, 14, 409, 8, 2792, 12, 3660, 14737, 390, 461, 12, 3660, 291, 14, 362, 8, 1708, 12, 14737, 390, 461, 430, 1169, 4215, 10947, 275, 715, 490, 291, 14, 2168, 63, 1422, 8, 2792, 12, 298, 5589, 531, 288, 340, 440, 4215, 10947, 26, 355, 2059, 267, 327, 22111, 1104, 26, 2900, 2974, 1471, 1172, 282, 730, 901, 14, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 466, 2349, 355, 746, 14196, 14, 547, 3647, 83, 965, 949, 730, 2, 450, 3420, 9, 288, 916, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 440, 315, 1689, 3908, 401, 298, 9884, 401, 298, 1782, 2349, 355, 746, 14196, 14, 547, 3647, 83, 965, 3866, 730, 2, 450, 3420, 9, 267, 327, 22111, 1104, 26, 2900, 7256, 1471, 2376, 737, 282, 20868, 909, 14, 267, 327, 428, 2655, 7763, 26, 1900, 314, 5548, 402, 373, 500, 1384, 436, 7256, 14, 267, 291, 14, 86, 500, 1384, 275, 942, 267, 291, 14, 6410, 275, 942, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 9884, 582, 355, 291, 14, 86, 500, 1384, 14, 740, 8, 2792, 9, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 1782, 582, 355, 291, 14, 6410, 14, 740, 8, 2792, 9, 267, 291, 14, 86, 500, 1384, 14, 3191, 342, 267, 367, 3420, 315, 291, 14, 7786, 837, 288, 340, 291, 14, 362, 8, 2792, 12, 298, 466, 531, 508, 298, 1782, 582, 355, 340, 440, 291, 14, 1989, 63, 1422, 8, 2792, 12, 298, 9884, 2349, 490, 746, 14196, 14, 547, 3647, 83, 965, 949, 20868, 2, 450, 3420, 9, 355, 340, 291, 14, 362, 8, 2792, 12, 298, 9884, 531, 440, 315, 291, 14, 86, 500, 1384, 26, 490, 746, 14196, 14, 547, 3647, 83, 965, 3866, 20868, 2, 450, 3420, 9, 339, 347, 4163, 11772, 8, 277, 12, 15643, 304, 267, 314, 350, 275, 8894, 1224, 3449, 534, 8665, 26, 17, 5326, 18609, 21977, 27, 4246, 13, 890, 26, 7241, 27, 7451, 13, 2326, 15596, 27994, 2571, 8423, 199, 28, 13410, 30, 26138, 450, 83, 7256, 687, 450, 83, 373, 500, 1384, 1108, 13410, 30, 199, 28, 454, 30, 199, 28, 273, 30, 985, 1108, 273, 30, 199, 28, 273, 30, 2305, 7407, 1108, 273, 30, 199, 28, 273, 30, 8524, 1108, 273, 30, 199, 28, 273, 30, 4267, 1108, 273, 30, 199, 28, 273, 30, 52, 3505, 543, 1108, 273, 30, 199, 28, 273, 30, 46, 3635, 33, 1015, 1108, 273, 30, 199, 28, 273, 30, 48, 5067, 1108, 273, 30, 199, 28, 273, 3449, 534, 2063, 26, 1400, 8530, 8423, 18685, 1108, 273, 30, 199, 1108, 454, 30, 199, 624, 267, 373, 2993, 17, 275, 3886, 454, 2535, 2076, 3449, 534, 505, 13, 5743, 26, 4218, 8942, 26384, 534, 24, 7, 2535, 65, 4369, 9569, 83, 7, 6598, 83, 1108, 65, 2957, 2076, 2957, 454, 3072, 78, 2, 267, 373, 2993, 18, 275, 3886, 454, 2535, 2076, 3449, 534, 505, 13, 5743, 26, 4218, 8942, 26384, 534, 24, 7, 2535, 65, 4369, 9569, 83, 7, 6598, 83, 1108, 65, 2535, 3289, 2535, 80, 6598, 83, 1108, 80, 2957, 2076, 2957, 454, 3072, 78, 2, 267, 18469, 13963, 71, 5921, 275, 1689, 1168, 9687, 19, 401, 298, 2890, 2025, 614, 531, 267, 15643, 14, 952, 8, 21519, 450, 334, 552, 8, 277, 14, 6410, 395, 822, 8, 277, 14, 86, 500, 1384, 1724, 267, 367, 20868, 315, 291, 14, 86, 500, 1384, 26, 288, 340, 291, 14, 1989, 63, 1422, 8, 9884, 12, 298, 5983, 2349, 355, 15643, 14, 952, 8, 86, 2993, 18, 450, 334, 277, 14, 362, 8, 9884, 12, 298, 9884, 63, 2124, 1288, 20868, 12, 291, 14, 362, 8, 9884, 12, 298, 5983, 13324, 288, 587, 26, 355, 15643, 14, 952, 8, 86, 2993, 17, 450, 334, 277, 14, 362, 8, 9884, 12, 298, 9884, 63, 2124, 1288, 20868, 430, 288, 12082, 275, 942, 288, 367, 4866, 315, 291, 14, 6410, 26, 355, 340, 291, 14, 362, 8, 2374, 12, 298, 9884, 531, 508, 20868, 26, 490, 12082, 14, 740, 8, 2374, 9, 288, 12082, 14, 3191, 342, 288, 367, 4866, 315, 12082, 26, 355, 1962, 2326, 275, 298, 7510, 2, 355, 340, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 47, 2769, 859, 582, 490, 1962, 2326, 275, 5426, 708, 7695, 708, 2, 355, 916, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 28329, 409, 582, 490, 1962, 2326, 275, 5426, 6968, 37, 16, 2, 355, 916, 291, 14, 362, 8, 2374, 12, 298, 27796, 531, 508, 298, 6868, 409, 582, 490, 1962, 2326, 275, 5426, 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,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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 ]
zuck/prometeo-erp
core/filebrowser/signals.py
3
1772
#!/usr/bin/env python # -*- coding: utf-8 -*- """This file is part of the prometeo project. This program 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. 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 Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/> """ __author__ = 'Emanuele Bertoldi <emanuele.bertoldi@gmail.com>' __copyright__ = 'Copyright (c) 2011 Emanuele Bertoldi' __version__ = '0.0.5' import os import shutil import django.dispatch from django.db import models from django.conf import settings ## UTILS ## def manage_files(cls): """Connects handlers for files management. """ models.signals.post_save.connect(create_files_root, cls) models.signals.pre_delete.connect(delete_files_root, cls) ## HANDLERS ## def create_files_root(sender, instance, *args, **kwargs): """Creates the root which contains all the files associated with this object. """ if 'created' in kwargs: root_path = instance.get_files_root() if not os.access(root_path, os.F_OK): os.makedirs(root_path) def delete_files_root(sender, instance, *args, **kwargs): """Deletes the root which contains all the files associated with this object. """ root_path = instance.get_files_root() if os.access(root_path, os.F_OK): shutil.rmtree(root_path)
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2765, 570, 365, 1777, 402, 314, 557, 278, 266, 79, 2199, 14, 199, 199, 2765, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 221, 199, 7138, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 10146, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 199, 1422, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 8974, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 38, 3061, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 199, 6878, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 37, 1237, 310, 274, 23207, 6896, 328, 665, 69, 1237, 310, 274, 14, 605, 6896, 328, 32, 6799, 14, 957, 3524, 199, 363, 7307, 363, 275, 283, 7384, 334, 67, 9, 7760, 662, 1237, 310, 274, 23207, 6896, 328, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 16, 14, 21, 7, 199, 199, 646, 747, 199, 646, 5145, 199, 199, 646, 1639, 14, 6052, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 309, 738, 52, 1193, 51, 925, 199, 199, 318, 9635, 63, 1725, 8, 1886, 304, 272, 408, 8631, 83, 8297, 367, 1584, 10041, 14, 272, 408, 272, 1709, 14, 10458, 14, 1932, 63, 2117, 14, 2242, 8, 981, 63, 1725, 63, 1231, 12, 843, 9, 272, 1709, 14, 10458, 14, 657, 63, 1807, 14, 2242, 8, 1807, 63, 1725, 63, 1231, 12, 843, 9, 199, 199, 309, 23276, 28778, 925, 199, 199, 318, 1218, 63, 1725, 63, 1231, 8, 8114, 12, 1256, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 10607, 314, 1738, 1314, 3509, 1006, 314, 1584, 4568, 543, 642, 909, 14, 272, 408, 272, 340, 283, 3966, 7, 315, 2074, 26, 267, 1738, 63, 515, 275, 1256, 14, 362, 63, 1725, 63, 1231, 342, 267, 340, 440, 747, 14, 2732, 8, 1231, 63, 515, 12, 747, 14, 38, 63, 3593, 304, 288, 747, 14, 8347, 8, 1231, 63, 515, 9, 199, 199, 318, 3145, 63, 1725, 63, 1231, 8, 8114, 12, 1256, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 26372, 314, 1738, 1314, 3509, 1006, 314, 1584, 4568, 543, 642, 909, 14, 272, 408, 272, 1738, 63, 515, 275, 1256, 14, 362, 63, 1725, 63, 1231, 342, 272, 340, 747, 14, 2732, 8, 1231, 63, 515, 12, 747, 14, 38, 63, 3593, 304, 267, 5145, 14, 9242, 8, 1231, 63, 515, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2765, 570, 365, 1777, 402, 314, 557, 278, 266, 79, 2199, 14, 199, 199, 2765, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 221, 199, 7138, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 10146, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 199, 1422, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 8974, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 38, 3061, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 199, 6878, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 37, 1237, 310, 274, 23207, 6896, 328, 665, 69, 1237, 310, 274, 14, 605, 6896, 328, 32, 6799, 14, 957, 3524, 199, 363, 7307, 363, 275, 283, 7384, 334, 67, 9, 7760, 662, 1237, 310, 274, 23207, 6896, 328, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 16, 14, 21, 7, 199, 199, 646, 747, 199, 646, 5145, 199, 199, 646, 1639, 14, 6052, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 309, 738, 52, 1193, 51, 925, 199, 199, 318, 9635, 63, 1725, 8, 1886, 304, 272, 408, 8631, 83, 8297, 367, 1584, 10041, 14, 272, 408, 272, 1709, 14, 10458, 14, 1932, 63, 2117, 14, 2242, 8, 981, 63, 1725, 63, 1231, 12, 843, 9, 272, 1709, 14, 10458, 14, 657, 63, 1807, 14, 2242, 8, 1807, 63, 1725, 63, 1231, 12, 843, 9, 199, 199, 309, 23276, 28778, 925, 199, 199, 318, 1218, 63, 1725, 63, 1231, 8, 8114, 12, 1256, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 10607, 314, 1738, 1314, 3509, 1006, 314, 1584, 4568, 543, 642, 909, 14, 272, 408, 272, 340, 283, 3966, 7, 315, 2074, 26, 267, 1738, 63, 515, 275, 1256, 14, 362, 63, 1725, 63, 1231, 342, 267, 340, 440, 747, 14, 2732, 8, 1231, 63, 515, 12, 747, 14, 38, 63, 3593, 304, 288, 747, 14, 8347, 8, 1231, 63, 515, 9, 199, 199, 318, 3145, 63, 1725, 63, 1231, 8, 8114, 12, 1256, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 26372, 314, 1738, 1314, 3509, 1006, 314, 1584, 4568, 543, 642, 909, 14, 272, 408, 272, 1738, 63, 515, 275, 1256, 14, 362, 63, 1725, 63, 1231, 342, 272, 340, 747, 14, 2732, 8, 1231, 63, 515, 12, 747, 14, 38, 63, 3593, 304, 267, 5145, 14, 9242, 8, 1231, 63, 515, 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, 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, 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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 ]
sander76/home-assistant
homeassistant/components/philips_js/__init__.py
3
5069
"""The Philips TV integration.""" from __future__ import annotations import asyncio from datetime import timedelta import logging from typing import Any, Callable from haphilipsjs import ConnectionFailure, PhilipsTV from homeassistant.components.automation import AutomationActionType from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_API_VERSION, CONF_HOST, CONF_PASSWORD, CONF_USERNAME, ) from homeassistant.core import CALLBACK_TYPE, Context, HassJob, HomeAssistant, callback from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from .const import DOMAIN PLATFORMS = ["media_player", "remote"] LOGGER = logging.getLogger(__name__) async def async_setup(hass: HomeAssistant, config: dict): """Set up the Philips TV component.""" hass.data[DOMAIN] = {} return True async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Philips TV from a config entry.""" tvapi = PhilipsTV( entry.data[CONF_HOST], entry.data[CONF_API_VERSION], username=entry.data.get(CONF_USERNAME), password=entry.data.get(CONF_PASSWORD), ) coordinator = PhilipsTVDataUpdateCoordinator(hass, tvapi) await coordinator.async_refresh() hass.data[DOMAIN][entry.entry_id] = coordinator for platform in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, platform) ) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ] ) ) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok class PluggableAction: """A pluggable action handler.""" def __init__(self, update: Callable[[], None]): """Initialize.""" self._update = update self._actions: dict[Any, AutomationActionType] = {} def __bool__(self): """Return if we have something attached.""" return bool(self._actions) @callback def async_attach(self, action: AutomationActionType, variables: dict[str, Any]): """Attach a device trigger for turn on.""" @callback def _remove(): del self._actions[_remove] self._update() job = HassJob(action) self._actions[_remove] = (job, variables) self._update() return _remove async def async_run(self, hass: HomeAssistantType, context: Context | None = None): """Run all turn on triggers.""" for job, variables in self._actions.values(): hass.async_run_hass_job(job, variables, context) class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]): """Coordinator to update data.""" def __init__(self, hass, api: PhilipsTV) -> None: """Set up the coordinator.""" self.api = api self._notify_future: asyncio.Task | None = None @callback def _update_listeners(): for update_callback in self._listeners: update_callback() self.turn_on = PluggableAction(_update_listeners) super().__init__( hass, LOGGER, name=DOMAIN, update_interval=timedelta(seconds=30), request_refresh_debouncer=Debouncer( hass, LOGGER, cooldown=2.0, immediate=False ), ) async def _notify_task(self): while self.api.on and self.api.notify_change_supported: if await self.api.notifyChange(130): self.async_set_updated_data(None) @callback def _async_notify_stop(self): if self._notify_future: self._notify_future.cancel() self._notify_future = None @callback def _async_notify_schedule(self): if ( (self._notify_future is None or self._notify_future.done()) and self.api.on and self.api.notify_change_supported ): self._notify_future = asyncio.create_task(self._notify_task()) @callback def async_remove_listener(self, update_callback: CALLBACK_TYPE) -> None: """Remove data update.""" super().async_remove_listener(update_callback) if not self._listeners: self._async_notify_stop() @callback def _async_stop_refresh(self, event: asyncio.Event) -> None: super()._async_stop_refresh(event) self._async_notify_stop() @callback async def _async_update_data(self): """Fetch the latest data from the source.""" try: await self.api.update() self._async_notify_schedule() except ConnectionFailure: pass
apache-2.0
[ 624, 1918, 11308, 1638, 1190, 26990, 13150, 1041, 199, 504, 636, 2443, 363, 492, 15538, 199, 199, 646, 16195, 199, 504, 2197, 492, 6871, 199, 646, 2050, 199, 504, 14090, 492, 6184, 12, 16975, 199, 199, 504, 394, 439, 72, 1638, 1190, 3596, 492, 8113, 6782, 12, 11308, 1638, 1190, 12764, 199, 199, 504, 8846, 14, 4608, 14, 23867, 492, 9195, 1615, 3310, 804, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 3735, 63, 4612, 12, 272, 6392, 63, 5449, 12, 272, 6392, 63, 9032, 12, 272, 6392, 63, 11958, 12, 199, 9, 199, 504, 8846, 14, 1018, 492, 24251, 7111, 63, 2711, 12, 9470, 12, 869, 405, 6694, 12, 29913, 12, 3233, 199, 504, 8846, 14, 7546, 14, 271, 32587, 492, 1487, 656, 31794, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 504, 8846, 14, 7546, 14, 873, 63, 27380, 492, 3918, 4152, 13940, 707, 199, 199, 504, 1275, 1297, 492, 15265, 199, 199, 2749, 619, 11518, 275, 2097, 4603, 63, 6147, 401, 298, 3846, 937, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 4146, 347, 5316, 63, 2758, 8, 5387, 26, 29913, 12, 1101, 26, 1211, 304, 272, 408, 1084, 1536, 314, 11308, 1638, 1190, 26990, 3931, 1041, 272, 6298, 14, 576, 59, 7378, 61, 275, 1052, 272, 372, 715, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 26, 29913, 12, 2397, 26, 4094, 3900, 304, 272, 408, 1084, 1536, 11308, 1638, 1190, 26990, 687, 282, 1101, 2397, 1041, 339, 13466, 1246, 275, 11308, 1638, 1190, 12764, 8, 267, 2397, 14, 576, 59, 3103, 63, 5449, 467, 267, 2397, 14, 576, 59, 3103, 63, 3735, 63, 4612, 467, 267, 3434, 29, 2373, 14, 576, 14, 362, 8, 3103, 63, 11958, 395, 267, 2505, 29, 2373, 14, 576, 14, 362, 8, 3103, 63, 9032, 395, 272, 776, 339, 29186, 275, 11308, 1638, 1190, 12764, 1451, 4152, 13940, 707, 8, 5387, 12, 13466, 1246, 9, 339, 5517, 29186, 14, 4146, 63, 6635, 342, 272, 6298, 14, 576, 59, 7378, 1527, 2373, 14, 2373, 63, 344, 61, 275, 29186, 339, 367, 4298, 315, 10092, 619, 11518, 26, 267, 6298, 14, 4146, 63, 981, 63, 1765, 8, 288, 6298, 14, 888, 63, 3189, 14, 4146, 63, 6688, 63, 2373, 63, 2758, 8, 2373, 12, 4298, 9, 267, 776, 339, 372, 715, 421, 199, 4146, 347, 5316, 63, 25477, 63, 2373, 8, 5387, 26, 29913, 12, 2397, 26, 4094, 3900, 304, 272, 408, 31470, 282, 1101, 2397, 1041, 272, 625, 912, 63, 745, 275, 1006, 8, 267, 5517, 16195, 14, 13737, 8, 288, 627, 59, 355, 6298, 14, 888, 63, 3189, 14, 4146, 63, 6688, 63, 2373, 63, 25477, 8, 2373, 12, 4298, 9, 355, 367, 4298, 315, 10092, 619, 11518, 288, 1622, 267, 776, 272, 776, 272, 340, 625, 912, 63, 745, 26, 267, 6298, 14, 576, 59, 7378, 1055, 1935, 8, 2373, 14, 2373, 63, 344, 9, 339, 372, 625, 912, 63, 745, 421, 199, 533, 7497, 1518, 16725, 3310, 26, 272, 408, 33, 14202, 16725, 1595, 3016, 1041, 339, 347, 636, 826, 721, 277, 12, 1678, 26, 16975, 9046, 467, 488, 4682, 267, 408, 9345, 1041, 267, 291, 423, 873, 275, 1678, 267, 291, 423, 3723, 26, 1211, 59, 9874, 12, 9195, 1615, 3310, 804, 61, 275, 1052, 339, 347, 636, 2245, 721, 277, 304, 267, 408, 1767, 340, 781, 1172, 6020, 10102, 1041, 267, 372, 2155, 8, 277, 423, 3723, 9, 339, 768, 3058, 272, 347, 5316, 63, 5040, 8, 277, 12, 1595, 26, 9195, 1615, 3310, 804, 12, 2860, 26, 1211, 59, 495, 12, 6184, 4682, 267, 408, 13240, 282, 2243, 6804, 367, 7485, 641, 1041, 398, 768, 3058, 267, 347, 485, 2168, 837, 288, 2150, 291, 423, 3723, 13040, 2168, 61, 288, 291, 423, 873, 342, 398, 3906, 275, 869, 405, 6694, 8, 1287, 9, 398, 291, 423, 3723, 13040, 2168, 61, 275, 334, 2423, 12, 2860, 9, 267, 291, 423, 873, 342, 398, 372, 485, 2168, 339, 5316, 347, 5316, 63, 1065, 8, 277, 12, 6298, 26, 29913, 804, 12, 1067, 26, 9470, 1204, 488, 275, 488, 304, 267, 408, 2540, 1006, 7485, 641, 18899, 1041, 267, 367, 3906, 12, 2860, 315, 291, 423, 3723, 14, 1459, 837, 288, 6298, 14, 4146, 63, 1065, 63, 5387, 63, 2423, 8, 2423, 12, 2860, 12, 1067, 9, 421, 199, 533, 11308, 1638, 1190, 12764, 1451, 4152, 13940, 707, 8, 1451, 4152, 13940, 707, 59, 403, 4682, 272, 408, 13940, 707, 370, 1678, 666, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 2986, 26, 11308, 1638, 1190, 12764, 9, 1035, 488, 26, 267, 408, 1084, 1536, 314, 29186, 1041, 267, 291, 14, 1246, 275, 2986, 267, 291, 423, 6814, 63, 2443, 26, 16195, 14, 4476, 1204, 488, 275, 488, 398, 768, 3058, 267, 347, 485, 873, 63, 17301, 837, 288, 367, 1678, 63, 3058, 315, 291, 423, 17301, 26, 355, 1678, 63, 3058, 342, 398, 291, 14, 353, 63, 265, 275, 7497, 1518, 16725, 3310, 1547, 873, 63, 17301, 9, 398, 1613, 11027, 826, 721, 288, 6298, 12, 288, 20184, 12, 288, 536, 29, 7378, 12, 288, 1678, 63, 4284, 29, 7473, 8, 4515, 29, 1216, 395, 288, 1056, 63, 6635, 63, 271, 656, 31794, 29, 872, 656, 31794, 8, 355, 6298, 12, 20184, 12, 512, 27898, 29, 18, 14, 16, 12, 8569, 29, 797, 288, 2318, 267, 776, 339, 5316, 347, 485, 6814, 63, 1765, 8, 277, 304, 267, 1830, 291, 14, 1246, 14, 265, 436, 291, 14, 1246, 14, 6814, 63, 1461, 63, 4946, 26, 288, 340, 5517, 291, 14, 1246, 14, 6814, 4001, 8, 9056, 304, 355, 291, 14, 4146, 63, 409, 63, 5334, 63, 576, 8, 403, 9, 339, 768, 3058, 272, 347, 485, 4146, 63, 6814, 63, 2379, 8, 277, 304, 267, 340, 291, 423, 6814, 63, 2443, 26, 288, 291, 423, 6814, 63, 2443, 14, 6406, 342, 288, 291, 423, 6814, 63, 2443, 275, 488, 339, 768, 3058, 272, 347, 485, 4146, 63, 6814, 63, 7211, 8, 277, 304, 267, 340, 334, 288, 334, 277, 423, 6814, 63, 2443, 365, 488, 503, 291 ]
[ 1918, 11308, 1638, 1190, 26990, 13150, 1041, 199, 504, 636, 2443, 363, 492, 15538, 199, 199, 646, 16195, 199, 504, 2197, 492, 6871, 199, 646, 2050, 199, 504, 14090, 492, 6184, 12, 16975, 199, 199, 504, 394, 439, 72, 1638, 1190, 3596, 492, 8113, 6782, 12, 11308, 1638, 1190, 12764, 199, 199, 504, 8846, 14, 4608, 14, 23867, 492, 9195, 1615, 3310, 804, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 3735, 63, 4612, 12, 272, 6392, 63, 5449, 12, 272, 6392, 63, 9032, 12, 272, 6392, 63, 11958, 12, 199, 9, 199, 504, 8846, 14, 1018, 492, 24251, 7111, 63, 2711, 12, 9470, 12, 869, 405, 6694, 12, 29913, 12, 3233, 199, 504, 8846, 14, 7546, 14, 271, 32587, 492, 1487, 656, 31794, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 504, 8846, 14, 7546, 14, 873, 63, 27380, 492, 3918, 4152, 13940, 707, 199, 199, 504, 1275, 1297, 492, 15265, 199, 199, 2749, 619, 11518, 275, 2097, 4603, 63, 6147, 401, 298, 3846, 937, 199, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 4146, 347, 5316, 63, 2758, 8, 5387, 26, 29913, 12, 1101, 26, 1211, 304, 272, 408, 1084, 1536, 314, 11308, 1638, 1190, 26990, 3931, 1041, 272, 6298, 14, 576, 59, 7378, 61, 275, 1052, 272, 372, 715, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 26, 29913, 12, 2397, 26, 4094, 3900, 304, 272, 408, 1084, 1536, 11308, 1638, 1190, 26990, 687, 282, 1101, 2397, 1041, 339, 13466, 1246, 275, 11308, 1638, 1190, 12764, 8, 267, 2397, 14, 576, 59, 3103, 63, 5449, 467, 267, 2397, 14, 576, 59, 3103, 63, 3735, 63, 4612, 467, 267, 3434, 29, 2373, 14, 576, 14, 362, 8, 3103, 63, 11958, 395, 267, 2505, 29, 2373, 14, 576, 14, 362, 8, 3103, 63, 9032, 395, 272, 776, 339, 29186, 275, 11308, 1638, 1190, 12764, 1451, 4152, 13940, 707, 8, 5387, 12, 13466, 1246, 9, 339, 5517, 29186, 14, 4146, 63, 6635, 342, 272, 6298, 14, 576, 59, 7378, 1527, 2373, 14, 2373, 63, 344, 61, 275, 29186, 339, 367, 4298, 315, 10092, 619, 11518, 26, 267, 6298, 14, 4146, 63, 981, 63, 1765, 8, 288, 6298, 14, 888, 63, 3189, 14, 4146, 63, 6688, 63, 2373, 63, 2758, 8, 2373, 12, 4298, 9, 267, 776, 339, 372, 715, 421, 199, 4146, 347, 5316, 63, 25477, 63, 2373, 8, 5387, 26, 29913, 12, 2397, 26, 4094, 3900, 304, 272, 408, 31470, 282, 1101, 2397, 1041, 272, 625, 912, 63, 745, 275, 1006, 8, 267, 5517, 16195, 14, 13737, 8, 288, 627, 59, 355, 6298, 14, 888, 63, 3189, 14, 4146, 63, 6688, 63, 2373, 63, 25477, 8, 2373, 12, 4298, 9, 355, 367, 4298, 315, 10092, 619, 11518, 288, 1622, 267, 776, 272, 776, 272, 340, 625, 912, 63, 745, 26, 267, 6298, 14, 576, 59, 7378, 1055, 1935, 8, 2373, 14, 2373, 63, 344, 9, 339, 372, 625, 912, 63, 745, 421, 199, 533, 7497, 1518, 16725, 3310, 26, 272, 408, 33, 14202, 16725, 1595, 3016, 1041, 339, 347, 636, 826, 721, 277, 12, 1678, 26, 16975, 9046, 467, 488, 4682, 267, 408, 9345, 1041, 267, 291, 423, 873, 275, 1678, 267, 291, 423, 3723, 26, 1211, 59, 9874, 12, 9195, 1615, 3310, 804, 61, 275, 1052, 339, 347, 636, 2245, 721, 277, 304, 267, 408, 1767, 340, 781, 1172, 6020, 10102, 1041, 267, 372, 2155, 8, 277, 423, 3723, 9, 339, 768, 3058, 272, 347, 5316, 63, 5040, 8, 277, 12, 1595, 26, 9195, 1615, 3310, 804, 12, 2860, 26, 1211, 59, 495, 12, 6184, 4682, 267, 408, 13240, 282, 2243, 6804, 367, 7485, 641, 1041, 398, 768, 3058, 267, 347, 485, 2168, 837, 288, 2150, 291, 423, 3723, 13040, 2168, 61, 288, 291, 423, 873, 342, 398, 3906, 275, 869, 405, 6694, 8, 1287, 9, 398, 291, 423, 3723, 13040, 2168, 61, 275, 334, 2423, 12, 2860, 9, 267, 291, 423, 873, 342, 398, 372, 485, 2168, 339, 5316, 347, 5316, 63, 1065, 8, 277, 12, 6298, 26, 29913, 804, 12, 1067, 26, 9470, 1204, 488, 275, 488, 304, 267, 408, 2540, 1006, 7485, 641, 18899, 1041, 267, 367, 3906, 12, 2860, 315, 291, 423, 3723, 14, 1459, 837, 288, 6298, 14, 4146, 63, 1065, 63, 5387, 63, 2423, 8, 2423, 12, 2860, 12, 1067, 9, 421, 199, 533, 11308, 1638, 1190, 12764, 1451, 4152, 13940, 707, 8, 1451, 4152, 13940, 707, 59, 403, 4682, 272, 408, 13940, 707, 370, 1678, 666, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 2986, 26, 11308, 1638, 1190, 12764, 9, 1035, 488, 26, 267, 408, 1084, 1536, 314, 29186, 1041, 267, 291, 14, 1246, 275, 2986, 267, 291, 423, 6814, 63, 2443, 26, 16195, 14, 4476, 1204, 488, 275, 488, 398, 768, 3058, 267, 347, 485, 873, 63, 17301, 837, 288, 367, 1678, 63, 3058, 315, 291, 423, 17301, 26, 355, 1678, 63, 3058, 342, 398, 291, 14, 353, 63, 265, 275, 7497, 1518, 16725, 3310, 1547, 873, 63, 17301, 9, 398, 1613, 11027, 826, 721, 288, 6298, 12, 288, 20184, 12, 288, 536, 29, 7378, 12, 288, 1678, 63, 4284, 29, 7473, 8, 4515, 29, 1216, 395, 288, 1056, 63, 6635, 63, 271, 656, 31794, 29, 872, 656, 31794, 8, 355, 6298, 12, 20184, 12, 512, 27898, 29, 18, 14, 16, 12, 8569, 29, 797, 288, 2318, 267, 776, 339, 5316, 347, 485, 6814, 63, 1765, 8, 277, 304, 267, 1830, 291, 14, 1246, 14, 265, 436, 291, 14, 1246, 14, 6814, 63, 1461, 63, 4946, 26, 288, 340, 5517, 291, 14, 1246, 14, 6814, 4001, 8, 9056, 304, 355, 291, 14, 4146, 63, 409, 63, 5334, 63, 576, 8, 403, 9, 339, 768, 3058, 272, 347, 485, 4146, 63, 6814, 63, 2379, 8, 277, 304, 267, 340, 291, 423, 6814, 63, 2443, 26, 288, 291, 423, 6814, 63, 2443, 14, 6406, 342, 288, 291, 423, 6814, 63, 2443, 275, 488, 339, 768, 3058, 272, 347, 485, 4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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 ]
omni5cience/django-inlineformfield
.tox/py27/lib/python2.7/site-packages/django/contrib/admindocs/views.py
9
15550
from importlib import import_module import inspect import os import re import warnings from django import template from django.apps import apps from django.conf import settings from django.contrib import admin from django.contrib.admin.views.decorators import staff_member_required from django.db import models from django.core.exceptions import ViewDoesNotExist from django.http import Http404 from django.core import urlresolvers from django.contrib.admindocs import utils from django.utils.decorators import method_decorator from django.utils.deprecation import RemovedInDjango18Warning from django.utils._os import upath from django.utils import six from django.utils.translation import ugettext as _ from django.views.generic import TemplateView # Exclude methods starting with these strings from documentation MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_') if getattr(settings, 'ADMIN_FOR', None): warnings.warn('The ADMIN_FOR setting has been removed, you can remove ' 'this setting from your configuration.', RemovedInDjango18Warning, stacklevel=2) class BaseAdminDocsView(TemplateView): """ Base view for admindocs views. """ @method_decorator(staff_member_required) def dispatch(self, *args, **kwargs): if not utils.docutils_is_available: # Display an error message for people without docutils self.template_name = 'admin_doc/missing_docutils.html' return self.render_to_response(admin.site.each_context()) return super(BaseAdminDocsView, self).dispatch(*args, **kwargs) def get_context_data(self, **kwargs): kwargs.update({'root_path': urlresolvers.reverse('admin:index')}) kwargs.update(admin.site.each_context()) return super(BaseAdminDocsView, self).get_context_data(**kwargs) class BookmarkletsView(BaseAdminDocsView): template_name = 'admin_doc/bookmarklets.html' def get_context_data(self, **kwargs): context = super(BookmarkletsView, self).get_context_data(**kwargs) context.update({ 'admin_url': "%s://%s%s" % ( self.request.scheme, self.request.get_host(), context['root_path']) }) return context class TemplateTagIndexView(BaseAdminDocsView): template_name = 'admin_doc/template_tag_index.html' def get_context_data(self, **kwargs): load_all_installed_template_libraries() tags = [] app_libs = list(six.iteritems(template.libraries)) builtin_libs = [(None, lib) for lib in template.builtins] for module_name, library in builtin_libs + app_libs: for tag_name, tag_func in library.tags.items(): title, body, metadata = utils.parse_docstring(tag_func.__doc__) if title: title = utils.parse_rst(title, 'tag', _('tag:') + tag_name) if body: body = utils.parse_rst(body, 'tag', _('tag:') + tag_name) for key in metadata: metadata[key] = utils.parse_rst(metadata[key], 'tag', _('tag:') + tag_name) if library in template.builtins: tag_library = '' else: tag_library = module_name.split('.')[-1] tags.append({ 'name': tag_name, 'title': title, 'body': body, 'meta': metadata, 'library': tag_library, }) kwargs.update({'tags': tags}) return super(TemplateTagIndexView, self).get_context_data(**kwargs) class TemplateFilterIndexView(BaseAdminDocsView): template_name = 'admin_doc/template_filter_index.html' def get_context_data(self, **kwargs): load_all_installed_template_libraries() filters = [] app_libs = list(six.iteritems(template.libraries)) builtin_libs = [(None, lib) for lib in template.builtins] for module_name, library in builtin_libs + app_libs: for filter_name, filter_func in library.filters.items(): title, body, metadata = utils.parse_docstring(filter_func.__doc__) if title: title = utils.parse_rst(title, 'filter', _('filter:') + filter_name) if body: body = utils.parse_rst(body, 'filter', _('filter:') + filter_name) for key in metadata: metadata[key] = utils.parse_rst(metadata[key], 'filter', _('filter:') + filter_name) if library in template.builtins: tag_library = '' else: tag_library = module_name.split('.')[-1] filters.append({ 'name': filter_name, 'title': title, 'body': body, 'meta': metadata, 'library': tag_library, }) kwargs.update({'filters': filters}) return super(TemplateFilterIndexView, self).get_context_data(**kwargs) class ViewIndexView(BaseAdminDocsView): template_name = 'admin_doc/view_index.html' def get_context_data(self, **kwargs): views = [] urlconf = import_module(settings.ROOT_URLCONF) view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns) for (func, regex, namespace, name) in view_functions: views.append({ 'full_name': '%s.%s' % (func.__module__, getattr(func, '__name__', func.__class__.__name__)), 'url': simplify_regex(regex), 'url_name': ':'.join((namespace or []) + (name and [name] or [])), 'namespace': ':'.join((namespace or [])), 'name': name, }) kwargs.update({'views': views}) return super(ViewIndexView, self).get_context_data(**kwargs) class ViewDetailView(BaseAdminDocsView): template_name = 'admin_doc/view_detail.html' def get_context_data(self, **kwargs): view = self.kwargs['view'] urlconf = urlresolvers.get_urlconf() if urlresolvers.get_resolver(urlconf)._is_callback(view): mod, func = urlresolvers.get_mod_func(view) view_func = getattr(import_module(mod), func) else: raise Http404 title, body, metadata = utils.parse_docstring(view_func.__doc__) if title: title = utils.parse_rst(title, 'view', _('view:') + view) if body: body = utils.parse_rst(body, 'view', _('view:') + view) for key in metadata: metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view) kwargs.update({ 'name': view, 'summary': title, 'body': body, 'meta': metadata, }) return super(ViewDetailView, self).get_context_data(**kwargs) class ModelIndexView(BaseAdminDocsView): template_name = 'admin_doc/model_index.html' def get_context_data(self, **kwargs): m_list = [m._meta for m in apps.get_models()] kwargs.update({'models': m_list}) return super(ModelIndexView, self).get_context_data(**kwargs) class ModelDetailView(BaseAdminDocsView): template_name = 'admin_doc/model_detail.html' def get_context_data(self, **kwargs): # Get the model class. try: app_config = apps.get_app_config(self.kwargs['app_label']) except LookupError: raise Http404(_("App %(app_label)r not found") % self.kwargs) try: model = app_config.get_model(self.kwargs['model_name']) except LookupError: raise Http404(_("Model %(model_name)r not found in app %(app_label)r") % self.kwargs) opts = model._meta # Gather fields/field descriptions. fields = [] for field in opts.fields: # ForeignKey is a special case since the field will actually be a # descriptor that returns the other object if isinstance(field, models.ForeignKey): data_type = field.rel.to.__name__ app_label = field.rel.to._meta.app_label verbose = utils.parse_rst( (_("the related `%(app_label)s.%(data_type)s` object") % { 'app_label': app_label, 'data_type': data_type, }), 'model', _('model:') + data_type, ) else: data_type = get_readable_field_data_type(field) verbose = field.verbose_name fields.append({ 'name': field.name, 'data_type': data_type, 'verbose': verbose, 'help_text': field.help_text, }) # Gather many-to-many fields. for field in opts.many_to_many: data_type = field.rel.to.__name__ app_label = field.rel.to._meta.app_label verbose = _("related `%(app_label)s.%(object_name)s` objects") % {'app_label': app_label, 'object_name': data_type} fields.append({ 'name': "%s.all" % field.name, "data_type": 'List', 'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name), }) fields.append({ 'name': "%s.count" % field.name, 'data_type': 'Integer', 'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name), }) # Gather model methods. for func_name, func in model.__dict__.items(): if (inspect.isfunction(func) and len(inspect.getargspec(func)[0]) == 1): try: for exclude in MODEL_METHODS_EXCLUDE: if func_name.startswith(exclude): raise StopIteration except StopIteration: continue verbose = func.__doc__ if verbose: verbose = utils.parse_rst(utils.trim_docstring(verbose), 'model', _('model:') + opts.model_name) fields.append({ 'name': func_name, 'data_type': get_return_data_type(func_name), 'verbose': verbose, }) # Gather related objects for rel in opts.get_all_related_objects() + opts.get_all_related_many_to_many_objects(): verbose = _("related `%(app_label)s.%(object_name)s` objects") % {'app_label': rel.opts.app_label, 'object_name': rel.opts.object_name} accessor = rel.get_accessor_name() fields.append({ 'name': "%s.all" % accessor, 'data_type': 'List', 'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name), }) fields.append({ 'name': "%s.count" % accessor, 'data_type': 'Integer', 'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name), }) kwargs.update({ 'name': '%s.%s' % (opts.app_label, opts.object_name), # Translators: %s is an object type name 'summary': _("Attributes on %s objects") % opts.object_name, 'description': model.__doc__, 'fields': fields, }) return super(ModelDetailView, self).get_context_data(**kwargs) class TemplateDetailView(BaseAdminDocsView): template_name = 'admin_doc/template_detail.html' def get_context_data(self, **kwargs): template = self.kwargs['template'] templates = [] for dir in settings.TEMPLATE_DIRS: template_file = os.path.join(dir, template) templates.append({ 'file': template_file, 'exists': os.path.exists(template_file), 'contents': lambda: open(template_file).read() if os.path.exists(template_file) else '', 'order': list(settings.TEMPLATE_DIRS).index(dir), }) kwargs.update({ 'name': template, 'templates': templates, }) return super(TemplateDetailView, self).get_context_data(**kwargs) #################### # Helper functions # #################### def load_all_installed_template_libraries(): # Load/register all template tag libraries from installed apps. for module_name in template.get_templatetags_modules(): mod = import_module(module_name) try: libraries = [ os.path.splitext(p)[0] for p in os.listdir(os.path.dirname(upath(mod.__file__))) if p.endswith('.py') and p[0].isalpha() ] except OSError: libraries = [] for library_name in libraries: try: template.get_library(library_name) except template.InvalidTemplateLibrary: pass def get_return_data_type(func_name): """Return a somewhat-helpful data type given a function name""" if func_name.startswith('get_'): if func_name.endswith('_list'): return 'List' elif func_name.endswith('_count'): return 'Integer' return '' def get_readable_field_data_type(field): """Returns the description for a given field type, if it exists, Fields' descriptions can contain format strings, which will be interpolated against the values of field.__dict__ before being output.""" return field.description % field.__dict__ def extract_views_from_urlpatterns(urlpatterns, base='', namespace=None): """ Return a list of views from a list of urlpatterns. Each object in the returned list is a two-tuple: (view_func, regex) """ views = [] for p in urlpatterns: if hasattr(p, 'url_patterns'): try: patterns = p.url_patterns except ImportError: continue views.extend(extract_views_from_urlpatterns( patterns, base + p.regex.pattern, (namespace or []) + (p.namespace and [p.namespace] or []) )) elif hasattr(p, 'callback'): try: views.append((p.callback, base + p.regex.pattern, namespace, p.name)) except ViewDoesNotExist: continue else: raise TypeError(_("%s does not appear to be a urlpattern object") % p) return views named_group_matcher = re.compile(r'\(\?P(<\w+>).+?\)') non_named_group_matcher = re.compile(r'\(.*?\)') def simplify_regex(pattern): """ Clean up urlpattern regexes into something somewhat readable by Mere Humans: turns something like "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$" into "<sport_slug>/athletes/<athlete_slug>/" """ # handle named groups first pattern = named_group_matcher.sub(lambda m: m.group(1), pattern) # handle non-named groups pattern = non_named_group_matcher.sub("<var>", pattern) # clean up any outstanding regex-y characters. pattern = pattern.replace('^', '').replace('$', '').replace('?', '').replace('//', '/').replace('\\', '') if not pattern.startswith('/'): pattern = '/' + pattern return pattern
mit
[ 504, 14802, 492, 492, 63, 578, 199, 646, 6485, 199, 646, 747, 199, 646, 295, 199, 646, 3598, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 4196, 14, 11582, 492, 12622, 63, 1114, 63, 2427, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1018, 14, 3924, 492, 10935, 7400, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 2828, 14, 14464, 688, 14851, 492, 3778, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1083, 63, 11547, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 199, 199, 3, 28554, 3102, 6617, 543, 3520, 3326, 687, 3794, 199, 11429, 63, 18383, 63, 1438, 13958, 275, 12331, 297, 283, 525, 14474, 283, 1807, 297, 283, 2117, 297, 283, 409, 15452, 199, 199, 692, 2519, 8, 1751, 12, 283, 14288, 63, 2707, 297, 488, 304, 272, 3598, 14, 4050, 360, 1918, 29948, 63, 2707, 4260, 965, 2757, 4829, 12, 1265, 883, 2813, 283, 2116, 283, 3749, 4260, 687, 2195, 2897, 3130, 23687, 1085, 3849, 12, 2116, 13232, 29, 18, 9, 421, 199, 533, 3523, 4880, 27858, 2768, 8, 4231, 2768, 304, 272, 408, 272, 3523, 2455, 367, 1503, 77, 688, 14851, 6858, 14, 272, 408, 272, 768, 765, 63, 11547, 8, 7018, 63, 1114, 63, 2427, 9, 272, 347, 7634, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 3778, 14, 27114, 63, 374, 63, 4561, 26, 288, 327, 12175, 376, 1125, 1245, 367, 13135, 1928, 18382, 288, 291, 14, 1160, 63, 354, 275, 283, 2113, 63, 1301, 15, 4752, 63, 27114, 14, 1360, 7, 288, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 2113, 14, 2124, 14, 10885, 63, 1100, 1012, 267, 372, 1613, 8, 1563, 4880, 27858, 2768, 12, 291, 680, 6052, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2074, 14, 873, 3252, 1231, 63, 515, 356, 32403, 14, 4471, 360, 2113, 26, 1080, 22220, 267, 2074, 14, 873, 8, 2113, 14, 2124, 14, 10885, 63, 1100, 1012, 267, 372, 1613, 8, 1563, 4880, 27858, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 421, 199, 533, 8944, 1657, 16537, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 17341, 16537, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 8696, 1657, 16537, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1067, 14, 873, 2561, 288, 283, 2113, 63, 633, 356, 2071, 83, 13827, 83, 5, 83, 2, 450, 334, 355, 291, 14, 1069, 14, 5512, 12, 291, 14, 1069, 14, 362, 63, 1102, 1062, 1067, 459, 1231, 63, 515, 1105, 267, 3828, 267, 372, 1067, 421, 199, 533, 5458, 1931, 2681, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 1160, 63, 1450, 63, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2248, 63, 452, 63, 7657, 63, 1160, 63, 10159, 342, 398, 3762, 275, 942, 267, 1145, 63, 8450, 275, 769, 8, 4174, 14, 4611, 8, 1160, 14, 10159, 430, 267, 6762, 63, 8450, 275, 3842, 403, 12, 1973, 9, 367, 1973, 315, 1978, 14, 10372, 61, 267, 367, 859, 63, 354, 12, 3555, 315, 6762, 63, 8450, 435, 1145, 63, 8450, 26, 288, 367, 1947, 63, 354, 12, 1947, 63, 1532, 315, 3555, 14, 2969, 14, 1744, 837, 355, 2538, 12, 2396, 12, 3341, 275, 3778, 14, 1122, 63, 12485, 8, 1450, 63, 1532, 855, 1301, 3368, 355, 340, 2538, 26, 490, 2538, 275, 3778, 14, 1122, 63, 8332, 8, 1213, 12, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 340, 2396, 26, 490, 2396, 275, 3778, 14, 1122, 63, 8332, 8, 2030, 12, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 367, 790, 315, 3341, 26, 490, 3341, 59, 498, 61, 275, 3778, 14, 1122, 63, 8332, 8, 2343, 59, 498, 467, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 340, 3555, 315, 1978, 14, 10372, 26, 490, 1947, 63, 4342, 275, 2125, 355, 587, 26, 490, 1947, 63, 4342, 275, 859, 63, 354, 14, 1294, 29084, 17, 61, 355, 3762, 14, 740, 2561, 490, 283, 354, 356, 1947, 63, 354, 12, 490, 283, 1213, 356, 2538, 12, 490, 283, 2030, 356, 2396, 12, 490, 283, 2024, 356, 3341, 12, 490, 283, 4342, 356, 1947, 63, 4342, 12, 355, 3828, 267, 2074, 14, 873, 3252, 2969, 356, 3762, 1552, 267, 372, 1613, 8, 4231, 1931, 2681, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 421, 199, 533, 5458, 4131, 2681, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 1160, 63, 1541, 63, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2248, 63, 452, 63, 7657, 63, 1160, 63, 10159, 342, 398, 4766, 275, 942, 267, 1145, 63, 8450, 275, 769, 8, 4174, 14, 4611, 8, 1160, 14, 10159, 430, 267, 6762, 63, 8450, 275, 3842, 403, 12, 1973, 9, 367, 1973, 315, 1978, 14, 10372, 61, 267, 367, 859, 63, 354, 12, 3555, 315, 6762, 63, 8450, 435, 1145, 63, 8450, 26, 288, 367, 2457, 63, 354, 12, 2457, 63, 1532, 315, 3555, 14, 4273, 14, 1744, 837, 355, 2538, 12, 2396, 12, 3341, 275, 3778, 14, 1122, 63, 12485, 8, 1541, 63, 1532, 855, 1301, 3368, 355, 340, 2538, 26, 490, 2538, 275, 3778, 14, 1122, 63, 8332, 8, 1213, 12, 283 ]
[ 14802, 492, 492, 63, 578, 199, 646, 6485, 199, 646, 747, 199, 646, 295, 199, 646, 3598, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 4196, 14, 11582, 492, 12622, 63, 1114, 63, 2427, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1018, 14, 3924, 492, 10935, 7400, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 2828, 14, 14464, 688, 14851, 492, 3778, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1083, 63, 11547, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 199, 199, 3, 28554, 3102, 6617, 543, 3520, 3326, 687, 3794, 199, 11429, 63, 18383, 63, 1438, 13958, 275, 12331, 297, 283, 525, 14474, 283, 1807, 297, 283, 2117, 297, 283, 409, 15452, 199, 199, 692, 2519, 8, 1751, 12, 283, 14288, 63, 2707, 297, 488, 304, 272, 3598, 14, 4050, 360, 1918, 29948, 63, 2707, 4260, 965, 2757, 4829, 12, 1265, 883, 2813, 283, 2116, 283, 3749, 4260, 687, 2195, 2897, 3130, 23687, 1085, 3849, 12, 2116, 13232, 29, 18, 9, 421, 199, 533, 3523, 4880, 27858, 2768, 8, 4231, 2768, 304, 272, 408, 272, 3523, 2455, 367, 1503, 77, 688, 14851, 6858, 14, 272, 408, 272, 768, 765, 63, 11547, 8, 7018, 63, 1114, 63, 2427, 9, 272, 347, 7634, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 3778, 14, 27114, 63, 374, 63, 4561, 26, 288, 327, 12175, 376, 1125, 1245, 367, 13135, 1928, 18382, 288, 291, 14, 1160, 63, 354, 275, 283, 2113, 63, 1301, 15, 4752, 63, 27114, 14, 1360, 7, 288, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 2113, 14, 2124, 14, 10885, 63, 1100, 1012, 267, 372, 1613, 8, 1563, 4880, 27858, 2768, 12, 291, 680, 6052, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2074, 14, 873, 3252, 1231, 63, 515, 356, 32403, 14, 4471, 360, 2113, 26, 1080, 22220, 267, 2074, 14, 873, 8, 2113, 14, 2124, 14, 10885, 63, 1100, 1012, 267, 372, 1613, 8, 1563, 4880, 27858, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 421, 199, 533, 8944, 1657, 16537, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 17341, 16537, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 8696, 1657, 16537, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1067, 14, 873, 2561, 288, 283, 2113, 63, 633, 356, 2071, 83, 13827, 83, 5, 83, 2, 450, 334, 355, 291, 14, 1069, 14, 5512, 12, 291, 14, 1069, 14, 362, 63, 1102, 1062, 1067, 459, 1231, 63, 515, 1105, 267, 3828, 267, 372, 1067, 421, 199, 533, 5458, 1931, 2681, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 1160, 63, 1450, 63, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2248, 63, 452, 63, 7657, 63, 1160, 63, 10159, 342, 398, 3762, 275, 942, 267, 1145, 63, 8450, 275, 769, 8, 4174, 14, 4611, 8, 1160, 14, 10159, 430, 267, 6762, 63, 8450, 275, 3842, 403, 12, 1973, 9, 367, 1973, 315, 1978, 14, 10372, 61, 267, 367, 859, 63, 354, 12, 3555, 315, 6762, 63, 8450, 435, 1145, 63, 8450, 26, 288, 367, 1947, 63, 354, 12, 1947, 63, 1532, 315, 3555, 14, 2969, 14, 1744, 837, 355, 2538, 12, 2396, 12, 3341, 275, 3778, 14, 1122, 63, 12485, 8, 1450, 63, 1532, 855, 1301, 3368, 355, 340, 2538, 26, 490, 2538, 275, 3778, 14, 1122, 63, 8332, 8, 1213, 12, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 340, 2396, 26, 490, 2396, 275, 3778, 14, 1122, 63, 8332, 8, 2030, 12, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 367, 790, 315, 3341, 26, 490, 3341, 59, 498, 61, 275, 3778, 14, 1122, 63, 8332, 8, 2343, 59, 498, 467, 283, 1450, 297, 4018, 1450, 10993, 435, 1947, 63, 354, 9, 355, 340, 3555, 315, 1978, 14, 10372, 26, 490, 1947, 63, 4342, 275, 2125, 355, 587, 26, 490, 1947, 63, 4342, 275, 859, 63, 354, 14, 1294, 29084, 17, 61, 355, 3762, 14, 740, 2561, 490, 283, 354, 356, 1947, 63, 354, 12, 490, 283, 1213, 356, 2538, 12, 490, 283, 2030, 356, 2396, 12, 490, 283, 2024, 356, 3341, 12, 490, 283, 4342, 356, 1947, 63, 4342, 12, 355, 3828, 267, 2074, 14, 873, 3252, 2969, 356, 3762, 1552, 267, 372, 1613, 8, 4231, 1931, 2681, 2768, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 421, 199, 533, 5458, 4131, 2681, 2768, 8, 1563, 4880, 27858, 2768, 304, 272, 1978, 63, 354, 275, 283, 2113, 63, 1301, 15, 1160, 63, 1541, 63, 1080, 14, 1360, 7, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 2248, 63, 452, 63, 7657, 63, 1160, 63, 10159, 342, 398, 4766, 275, 942, 267, 1145, 63, 8450, 275, 769, 8, 4174, 14, 4611, 8, 1160, 14, 10159, 430, 267, 6762, 63, 8450, 275, 3842, 403, 12, 1973, 9, 367, 1973, 315, 1978, 14, 10372, 61, 267, 367, 859, 63, 354, 12, 3555, 315, 6762, 63, 8450, 435, 1145, 63, 8450, 26, 288, 367, 2457, 63, 354, 12, 2457, 63, 1532, 315, 3555, 14, 4273, 14, 1744, 837, 355, 2538, 12, 2396, 12, 3341, 275, 3778, 14, 1122, 63, 12485, 8, 1541, 63, 1532, 855, 1301, 3368, 355, 340, 2538, 26, 490, 2538, 275, 3778, 14, 1122, 63, 8332, 8, 1213, 12, 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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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 ]
achang97/YouTunes
lib/python2.7/site-packages/youtube_dl/extractor/nowness.py
54
6024
# coding: utf-8 from __future__ import unicode_literals from .brightcove import ( BrightcoveLegacyIE, BrightcoveNewIE, ) from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, sanitized_Request, ) class NownessBaseIE(InfoExtractor): def _extract_url_result(self, post): if post['type'] == 'video': for media in post['media']: if media['type'] == 'video': video_id = media['content'] source = media['source'] if source == 'brightcove': player_code = self._download_webpage( 'http://www.nowness.com/iframe?id=%s' % video_id, video_id, note='Downloading player JavaScript', errnote='Unable to download player JavaScript') bc_url = BrightcoveLegacyIE._extract_brightcove_url(player_code) if bc_url: return self.url_result(bc_url, BrightcoveLegacyIE.ie_key()) bc_url = BrightcoveNewIE._extract_url(self, player_code) if bc_url: return self.url_result(bc_url, BrightcoveNewIE.ie_key()) raise ExtractorError('Could not find player definition') elif source == 'vimeo': return self.url_result('http://vimeo.com/%s' % video_id, 'Vimeo') elif source == 'youtube': return self.url_result(video_id, 'Youtube') elif source == 'cinematique': # youtube-dl currently doesn't support cinematique # return self.url_result('http://cinematique.com/embed/%s' % video_id, 'Cinematique') pass def _api_request(self, url, request_path): display_id = self._match_id(url) request = sanitized_Request( 'http://api.nowness.com/api/' + request_path % display_id, headers={ 'X-Nowness-Language': 'zh-cn' if 'cn.nowness.com' in url else 'en-us', }) return display_id, self._download_json(request, display_id) class NownessIE(NownessBaseIE): IE_NAME = 'nowness' _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/(?:story|(?:series|category)/[^/]+)/(?P<id>[^/]+?)(?:$|[?#])' _TESTS = [{ 'url': 'https://www.nowness.com/story/candor-the-art-of-gesticulation', 'md5': '068bc0202558c2e391924cb8cc470676', 'info_dict': { 'id': '2520295746001', 'ext': 'mp4', 'title': 'Candor: The Art of Gesticulation', 'description': 'Candor: The Art of Gesticulation', 'thumbnail': r're:^https?://.*\.jpg', 'timestamp': 1446745676, 'upload_date': '20151105', 'uploader_id': '2385340575001', }, 'add_ie': ['BrightcoveNew'], }, { 'url': 'https://cn.nowness.com/story/kasper-bjorke-ft-jaakko-eino-kalevi-tnr', 'md5': 'e79cf125e387216f86b2e0a5b5c63aa3', 'info_dict': { 'id': '3716354522001', 'ext': 'mp4', 'title': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR', 'description': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR', 'thumbnail': r're:^https?://.*\.jpg', 'timestamp': 1407315371, 'upload_date': '20140806', 'uploader_id': '2385340575001', }, 'add_ie': ['BrightcoveNew'], }, { # vimeo 'url': 'https://www.nowness.com/series/nowness-picks/jean-luc-godard-supercut', 'md5': '9a5a6a8edf806407e411296ab6bc2a49', 'info_dict': { 'id': '130020913', 'ext': 'mp4', 'title': 'Bleu, Blanc, Rouge - A Godard Supercut', 'description': 'md5:f0ea5f1857dffca02dbd37875d742cec', 'thumbnail': r're:^https?://.*\.jpg', 'upload_date': '20150607', 'uploader': 'Cinema Sem Lei', 'uploader_id': 'cinemasemlei', }, 'add_ie': ['Vimeo'], }] def _real_extract(self, url): _, post = self._api_request(url, 'post/getBySlug/%s') return self._extract_url_result(post) class NownessPlaylistIE(NownessBaseIE): IE_NAME = 'nowness:playlist' _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/playlist/(?P<id>\d+)' _TEST = { 'url': 'https://www.nowness.com/playlist/3286/i-guess-thats-why-they-call-it-the-blues', 'info_dict': { 'id': '3286', }, 'playlist_mincount': 8, } def _real_extract(self, url): playlist_id, playlist = self._api_request(url, 'post?PlaylistId=%s') entries = [self._extract_url_result(item) for item in playlist['items']] return self.playlist_result(entries, playlist_id) class NownessSeriesIE(NownessBaseIE): IE_NAME = 'nowness:series' _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/series/(?P<id>[^/]+?)(?:$|[?#])' _TEST = { 'url': 'https://www.nowness.com/series/60-seconds', 'info_dict': { 'id': '60', 'title': '60 Seconds', 'description': 'One-minute wisdom in a new NOWNESS series', }, 'playlist_mincount': 4, } def _real_extract(self, url): display_id, series = self._api_request(url, 'series/getBySlug/%s') entries = [self._extract_url_result(post) for post in series['posts']] series_title = None series_description = None translations = series.get('translations', []) if translations: series_title = translations[0].get('title') or translations[0]['seoTitle'] series_description = translations[0].get('seoDescription') return self.playlist_result( entries, compat_str(series['id']), series_title, series_description)
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 27454, 24617, 492, 334, 272, 699, 1019, 24617, 22628, 4332, 12, 272, 699, 1019, 24617, 4665, 4332, 12, 199, 9, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 8434, 63, 495, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 31734, 63, 2017, 12, 199, 9, 421, 199, 533, 7356, 4171, 1563, 4332, 8, 18283, 304, 272, 347, 485, 5005, 63, 633, 63, 1099, 8, 277, 12, 2963, 304, 267, 340, 2963, 459, 466, 418, 508, 283, 3722, 356, 288, 367, 5898, 315, 2963, 459, 4603, 2565, 355, 340, 5898, 459, 466, 418, 508, 283, 3722, 356, 490, 3991, 63, 344, 275, 5898, 459, 1317, 418, 490, 1350, 275, 5898, 459, 1365, 418, 490, 340, 1350, 508, 283, 27454, 24617, 356, 717, 7748, 63, 600, 275, 291, 423, 4249, 63, 12022, 8, 1169, 283, 1014, 921, 1544, 14, 2131, 4171, 14, 957, 15, 20052, 31, 344, 2458, 83, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 1169, 5317, 534, 18085, 7748, 15250, 297, 1169, 2329, 4610, 534, 6005, 370, 5235, 7748, 15250, 358, 717, 16604, 63, 633, 275, 699, 1019, 24617, 22628, 4332, 423, 5005, 63, 27454, 24617, 63, 633, 8, 6147, 63, 600, 9, 717, 340, 16604, 63, 633, 26, 1169, 372, 291, 14, 633, 63, 1099, 8, 3776, 63, 633, 12, 699, 1019, 24617, 22628, 4332, 14, 1873, 63, 498, 1012, 717, 16604, 63, 633, 275, 699, 1019, 24617, 4665, 4332, 423, 5005, 63, 633, 8, 277, 12, 7748, 63, 600, 9, 717, 340, 16604, 63, 633, 26, 1169, 372, 291, 14, 633, 63, 1099, 8, 3776, 63, 633, 12, 699, 1019, 24617, 4665, 4332, 14, 1873, 63, 498, 1012, 717, 746, 19783, 360, 6531, 440, 2342, 7748, 5492, 358, 490, 916, 1350, 508, 283, 433, 278, 79, 356, 717, 372, 291, 14, 633, 63, 1099, 360, 1014, 921, 433, 278, 79, 14, 957, 3149, 83, 7, 450, 3991, 63, 344, 12, 283, 54, 1036, 79, 358, 490, 916, 1350, 508, 283, 9788, 356, 717, 372, 291, 14, 633, 63, 1099, 8, 3722, 63, 344, 12, 283, 57, 7715, 358, 490, 916, 1350, 508, 283, 67, 1132, 391, 280, 544, 356, 717, 327, 22378, 13, 5030, 5544, 3181, 1133, 2291, 286, 1132, 391, 280, 544, 717, 327, 372, 291, 14, 633, 63, 1099, 360, 1014, 921, 67, 1132, 391, 280, 544, 14, 957, 15, 6427, 3149, 83, 7, 450, 3991, 63, 344, 12, 283, 35, 1132, 391, 280, 544, 358, 717, 986, 339, 347, 485, 1246, 63, 1069, 8, 277, 12, 1166, 12, 1056, 63, 515, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 1056, 275, 31734, 63, 2017, 8, 288, 283, 1014, 921, 1246, 14, 2131, 4171, 14, 957, 15, 1246, 4805, 435, 1056, 63, 515, 450, 2929, 63, 344, 12, 288, 2323, 3126, 355, 283, 56, 13, 14351, 4171, 13, 8493, 356, 283, 3951, 13, 6413, 7, 340, 283, 6413, 14, 2131, 4171, 14, 957, 7, 315, 1166, 587, 283, 287, 13, 527, 297, 288, 3828, 267, 372, 2929, 63, 344, 12, 291, 423, 4249, 63, 1001, 8, 1069, 12, 2929, 63, 344, 9, 421, 199, 533, 7356, 4171, 4332, 8, 14351, 4171, 1563, 4332, 304, 272, 15292, 63, 2339, 275, 283, 2131, 4171, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 5169, 1544, 92, 6413, 2862, 4959, 31, 2131, 4171, 4537, 957, 32576, 17372, 92, 5169, 5602, 92, 3710, 2447, 26285, 2447, 2229, 48, 28, 344, 26906, 17076, 5169, 4, 17884, 31, 3, 566, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 2131, 4171, 14, 957, 15, 17372, 15, 67, 460, 269, 13, 1589, 13, 580, 13, 1618, 13, 3199, 530, 5332, 297, 267, 283, 1064, 21, 356, 283, 19846, 3776, 10173, 821, 2010, 67, 18, 69, 1355, 1167, 1194, 2894, 24, 2055, 2417, 1690, 2114, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 821, 4999, 2720, 17718, 4587, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 35, 460, 269, 26, 710, 1952, 84, 402, 598, 597, 530, 5332, 297, 288, 283, 1802, 356, 283, 35, 460, 269, 26, 710, 1952, 84, 402, 598, 597, 530, 5332, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 3954, 356, 21771, 10393, 1367, 2114, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 2869, 7320, 297, 288, 283, 13671, 63, 344, 356, 283, 12332, 21, 13424, 14781, 4587, 297, 267, 1660, 267, 283, 525, 63, 1873, 356, 788, 34, 1019, 24617, 4665, 995, 272, 1660, 469, 267, 283, 633, 356, 283, 2859, 921, 6413, 14, 2131, 4171, 14, 957, 15, 17372, 15, 75, 305, 529, 13, 468, 269, 415, 13, 856, 13, 3387, 1151, 7697, 13, 69, 10175, 13, 75, 1895, 433, 13, 5889, 82, 297, 267, 283, 1064, 21, 356, 283, 69, 1965, 2177, 6889, 69, 12399, 9669, 70, 1184, 66, 18, 69, 16, 65, 21, 66, 21, 67, 2766, 2158, 19, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1401, 975, 1276, 2322, 1081, 4587, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 43, 305, 529, 699, 74, 31087, 82, 415, 18133, 14, 1603, 65, 1151, 7697, 662, 10175, 1804, 1895, 433, 26, 377, 17774, 297, 288, 283, 1802, 356, 283, 43, 305, 529, 699, 74, 31087, 82, 415, 18133, 14, 1603, 65, 1151, 7697, 662, 10175, 1804, 1895, 433, 26, 377, 17774, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 3954, 356, 4329, 1780, 9927, 16124, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 2167, 11901, 297, 288, 283, 13671, 63, 344, 356, 283, 12332, 21, 13424, 14781, 4587, 297, 267, 1660, 267, 283, 525, 63, 1873, 356, 788, 34, 1019, 24617, 4665, 995, 272, 1660, 469, 267, 327, 373, 1036, 79, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 2131, 4171, 14, 957, 15, 5602, 15, 2131, 4171, 13, 4510 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 27454, 24617, 492, 334, 272, 699, 1019, 24617, 22628, 4332, 12, 272, 699, 1019, 24617, 4665, 4332, 12, 199, 9, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 8434, 63, 495, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 31734, 63, 2017, 12, 199, 9, 421, 199, 533, 7356, 4171, 1563, 4332, 8, 18283, 304, 272, 347, 485, 5005, 63, 633, 63, 1099, 8, 277, 12, 2963, 304, 267, 340, 2963, 459, 466, 418, 508, 283, 3722, 356, 288, 367, 5898, 315, 2963, 459, 4603, 2565, 355, 340, 5898, 459, 466, 418, 508, 283, 3722, 356, 490, 3991, 63, 344, 275, 5898, 459, 1317, 418, 490, 1350, 275, 5898, 459, 1365, 418, 490, 340, 1350, 508, 283, 27454, 24617, 356, 717, 7748, 63, 600, 275, 291, 423, 4249, 63, 12022, 8, 1169, 283, 1014, 921, 1544, 14, 2131, 4171, 14, 957, 15, 20052, 31, 344, 2458, 83, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 1169, 5317, 534, 18085, 7748, 15250, 297, 1169, 2329, 4610, 534, 6005, 370, 5235, 7748, 15250, 358, 717, 16604, 63, 633, 275, 699, 1019, 24617, 22628, 4332, 423, 5005, 63, 27454, 24617, 63, 633, 8, 6147, 63, 600, 9, 717, 340, 16604, 63, 633, 26, 1169, 372, 291, 14, 633, 63, 1099, 8, 3776, 63, 633, 12, 699, 1019, 24617, 22628, 4332, 14, 1873, 63, 498, 1012, 717, 16604, 63, 633, 275, 699, 1019, 24617, 4665, 4332, 423, 5005, 63, 633, 8, 277, 12, 7748, 63, 600, 9, 717, 340, 16604, 63, 633, 26, 1169, 372, 291, 14, 633, 63, 1099, 8, 3776, 63, 633, 12, 699, 1019, 24617, 4665, 4332, 14, 1873, 63, 498, 1012, 717, 746, 19783, 360, 6531, 440, 2342, 7748, 5492, 358, 490, 916, 1350, 508, 283, 433, 278, 79, 356, 717, 372, 291, 14, 633, 63, 1099, 360, 1014, 921, 433, 278, 79, 14, 957, 3149, 83, 7, 450, 3991, 63, 344, 12, 283, 54, 1036, 79, 358, 490, 916, 1350, 508, 283, 9788, 356, 717, 372, 291, 14, 633, 63, 1099, 8, 3722, 63, 344, 12, 283, 57, 7715, 358, 490, 916, 1350, 508, 283, 67, 1132, 391, 280, 544, 356, 717, 327, 22378, 13, 5030, 5544, 3181, 1133, 2291, 286, 1132, 391, 280, 544, 717, 327, 372, 291, 14, 633, 63, 1099, 360, 1014, 921, 67, 1132, 391, 280, 544, 14, 957, 15, 6427, 3149, 83, 7, 450, 3991, 63, 344, 12, 283, 35, 1132, 391, 280, 544, 358, 717, 986, 339, 347, 485, 1246, 63, 1069, 8, 277, 12, 1166, 12, 1056, 63, 515, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 1056, 275, 31734, 63, 2017, 8, 288, 283, 1014, 921, 1246, 14, 2131, 4171, 14, 957, 15, 1246, 4805, 435, 1056, 63, 515, 450, 2929, 63, 344, 12, 288, 2323, 3126, 355, 283, 56, 13, 14351, 4171, 13, 8493, 356, 283, 3951, 13, 6413, 7, 340, 283, 6413, 14, 2131, 4171, 14, 957, 7, 315, 1166, 587, 283, 287, 13, 527, 297, 288, 3828, 267, 372, 2929, 63, 344, 12, 291, 423, 4249, 63, 1001, 8, 1069, 12, 2929, 63, 344, 9, 421, 199, 533, 7356, 4171, 4332, 8, 14351, 4171, 1563, 4332, 304, 272, 15292, 63, 2339, 275, 283, 2131, 4171, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 5169, 1544, 92, 6413, 2862, 4959, 31, 2131, 4171, 4537, 957, 32576, 17372, 92, 5169, 5602, 92, 3710, 2447, 26285, 2447, 2229, 48, 28, 344, 26906, 17076, 5169, 4, 17884, 31, 3, 566, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 2131, 4171, 14, 957, 15, 17372, 15, 67, 460, 269, 13, 1589, 13, 580, 13, 1618, 13, 3199, 530, 5332, 297, 267, 283, 1064, 21, 356, 283, 19846, 3776, 10173, 821, 2010, 67, 18, 69, 1355, 1167, 1194, 2894, 24, 2055, 2417, 1690, 2114, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 821, 4999, 2720, 17718, 4587, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 35, 460, 269, 26, 710, 1952, 84, 402, 598, 597, 530, 5332, 297, 288, 283, 1802, 356, 283, 35, 460, 269, 26, 710, 1952, 84, 402, 598, 597, 530, 5332, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 3954, 356, 21771, 10393, 1367, 2114, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 2869, 7320, 297, 288, 283, 13671, 63, 344, 356, 283, 12332, 21, 13424, 14781, 4587, 297, 267, 1660, 267, 283, 525, 63, 1873, 356, 788, 34, 1019, 24617, 4665, 995, 272, 1660, 469, 267, 283, 633, 356, 283, 2859, 921, 6413, 14, 2131, 4171, 14, 957, 15, 17372, 15, 75, 305, 529, 13, 468, 269, 415, 13, 856, 13, 3387, 1151, 7697, 13, 69, 10175, 13, 75, 1895, 433, 13, 5889, 82, 297, 267, 283, 1064, 21, 356, 283, 69, 1965, 2177, 6889, 69, 12399, 9669, 70, 1184, 66, 18, 69, 16, 65, 21, 66, 21, 67, 2766, 2158, 19, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1401, 975, 1276, 2322, 1081, 4587, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 43, 305, 529, 699, 74, 31087, 82, 415, 18133, 14, 1603, 65, 1151, 7697, 662, 10175, 1804, 1895, 433, 26, 377, 17774, 297, 288, 283, 1802, 356, 283, 43, 305, 529, 699, 74, 31087, 82, 415, 18133, 14, 1603, 65, 1151, 7697, 662, 10175, 1804, 1895, 433, 26, 377, 17774, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 297, 288, 283, 3954, 356, 4329, 1780, 9927, 16124, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 2167, 11901, 297, 288, 283, 13671, 63, 344, 356, 283, 12332, 21, 13424, 14781, 4587, 297, 267, 1660, 267, 283, 525, 63, 1873, 356, 788, 34, 1019, 24617, 4665, 995, 272, 1660, 469, 267, 327, 373, 1036, 79, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 2131, 4171, 14, 957, 15, 5602, 15, 2131, 4171, 13, 4510, 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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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 ]
yiwen-luo/LeetCode
Python/word-ladder.py
1
1785
# Time: O(n * d), n is length of string, d is size of dictionary # Space: O(d) # # Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: # # Only one letter can be changed at a time # Each intermediate word must exist in the dictionary # For example, # # Given: # start = "hit" # end = "cog" # dict = ["hot","dot","dog","lot","log"] # As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", # return its length 5. # # Note: # Return 0 if there is no such transformation sequence. # All words have the same length. # All words contain only lowercase alphabetic characters. # # BFS class Solution(object): def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ distance, cur, visited, lookup = 0, [beginWord], set([beginWord]), set(wordList) while cur: next_queue = [] for word in cur: if word == endWord: return distance + 1 for i in xrange(len(word)): for j in 'abcdefghijklmnopqrstuvwxyz': candidate = word[:i] + j + word[i + 1:] if candidate not in visited and candidate in lookup: next_queue.append(candidate) visited.add(candidate) distance += 1 cur = next_queue return 0 if __name__ == "__main__": print Solution().ladderLength("hit", "cog", set(["hot", "dot", "dog", "lot", "log"])) print Solution().ladderLength("hit", "cog", set(["hot", "dot", "dog", "lot", "log", "cog"]))
mit
[ 3, 4703, 26, 221, 593, 8, 78, 627, 366, 395, 302, 365, 2582, 402, 1059, 12, 366, 365, 1568, 402, 2600, 199, 3, 19326, 26, 593, 8, 68, 9, 199, 3, 199, 3, 9138, 2877, 5932, 334, 928, 436, 1284, 395, 436, 282, 2600, 12, 2342, 314, 2582, 402, 26564, 13315, 3414, 687, 1343, 370, 1284, 12, 4066, 626, 26, 199, 3, 221, 199, 3, 5972, 1373, 8082, 883, 506, 2896, 737, 282, 900, 199, 3, 7048, 13197, 4349, 1471, 2187, 315, 314, 2600, 199, 3, 2104, 2893, 12, 199, 3, 221, 199, 3, 9138, 26, 199, 3, 1343, 275, 298, 12948, 2, 199, 3, 1284, 275, 298, 23147, 2, 199, 3, 1211, 275, 2097, 8885, 2266, 3287, 2266, 13889, 2266, 1653, 2266, 793, 937, 199, 3, 3709, 1373, 26564, 13315, 365, 298, 12948, 2, 1035, 298, 8885, 2, 1035, 298, 3287, 2, 1035, 298, 13889, 2, 1035, 298, 23147, 401, 199, 3, 372, 2399, 2582, 959, 14, 199, 3, 221, 199, 3, 3390, 26, 199, 3, 1432, 378, 340, 2337, 365, 949, 4066, 13315, 3414, 14, 199, 3, 2900, 5932, 1172, 314, 2011, 2582, 14, 199, 3, 2900, 5932, 1395, 1454, 12141, 23331, 764, 4110, 14, 199, 3, 199, 199, 3, 699, 7079, 199, 533, 9274, 8, 785, 304, 272, 347, 634, 28874, 4625, 8, 277, 12, 5386, 10155, 12, 1284, 10155, 12, 4349, 1296, 304, 267, 408, 267, 520, 466, 5386, 10155, 26, 620, 267, 520, 466, 1284, 10155, 26, 620, 267, 520, 466, 4349, 1296, 26, 3820, 59, 495, 61, 267, 520, 4500, 26, 1109, 267, 408, 267, 6033, 12, 1094, 12, 15867, 12, 4237, 275, 378, 12, 359, 5037, 10155, 467, 663, 779, 5037, 10155, 2522, 663, 8, 1027, 1296, 9, 398, 1830, 1094, 26, 288, 2163, 63, 1825, 275, 942, 953, 367, 4349, 315, 1094, 26, 355, 340, 4349, 508, 1284, 10155, 26, 490, 372, 6033, 435, 413, 355, 367, 284, 315, 4945, 8, 552, 8, 1027, 2298, 490, 367, 1335, 315, 283, 23459, 356, 717, 7627, 275, 4349, 1491, 73, 61, 435, 1335, 435, 4349, 59, 73, 435, 413, 2938, 717, 340, 7627, 440, 315, 15867, 436, 7627, 315, 4237, 26, 1169, 2163, 63, 1825, 14, 740, 8, 9007, 9, 1169, 15867, 14, 525, 8, 9007, 9, 288, 6033, 847, 413, 288, 1094, 275, 2163, 63, 1825, 398, 372, 378, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 870, 9274, 1252, 76, 28874, 4625, 480, 12948, 401, 298, 23147, 401, 663, 5234, 8885, 401, 298, 3287, 401, 298, 13889, 401, 298, 1653, 401, 298, 793, 13045, 272, 870, 9274, 1252, 76, 28874, 4625, 480, 12948, 401, 298, 23147, 401, 663, 5234, 8885, 401, 298, 3287, 401, 298, 13889, 401, 298, 1653, 401, 298, 793, 401, 298, 23147, 13045, 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 ]
[ 4703, 26, 221, 593, 8, 78, 627, 366, 395, 302, 365, 2582, 402, 1059, 12, 366, 365, 1568, 402, 2600, 199, 3, 19326, 26, 593, 8, 68, 9, 199, 3, 199, 3, 9138, 2877, 5932, 334, 928, 436, 1284, 395, 436, 282, 2600, 12, 2342, 314, 2582, 402, 26564, 13315, 3414, 687, 1343, 370, 1284, 12, 4066, 626, 26, 199, 3, 221, 199, 3, 5972, 1373, 8082, 883, 506, 2896, 737, 282, 900, 199, 3, 7048, 13197, 4349, 1471, 2187, 315, 314, 2600, 199, 3, 2104, 2893, 12, 199, 3, 221, 199, 3, 9138, 26, 199, 3, 1343, 275, 298, 12948, 2, 199, 3, 1284, 275, 298, 23147, 2, 199, 3, 1211, 275, 2097, 8885, 2266, 3287, 2266, 13889, 2266, 1653, 2266, 793, 937, 199, 3, 3709, 1373, 26564, 13315, 365, 298, 12948, 2, 1035, 298, 8885, 2, 1035, 298, 3287, 2, 1035, 298, 13889, 2, 1035, 298, 23147, 401, 199, 3, 372, 2399, 2582, 959, 14, 199, 3, 221, 199, 3, 3390, 26, 199, 3, 1432, 378, 340, 2337, 365, 949, 4066, 13315, 3414, 14, 199, 3, 2900, 5932, 1172, 314, 2011, 2582, 14, 199, 3, 2900, 5932, 1395, 1454, 12141, 23331, 764, 4110, 14, 199, 3, 199, 199, 3, 699, 7079, 199, 533, 9274, 8, 785, 304, 272, 347, 634, 28874, 4625, 8, 277, 12, 5386, 10155, 12, 1284, 10155, 12, 4349, 1296, 304, 267, 408, 267, 520, 466, 5386, 10155, 26, 620, 267, 520, 466, 1284, 10155, 26, 620, 267, 520, 466, 4349, 1296, 26, 3820, 59, 495, 61, 267, 520, 4500, 26, 1109, 267, 408, 267, 6033, 12, 1094, 12, 15867, 12, 4237, 275, 378, 12, 359, 5037, 10155, 467, 663, 779, 5037, 10155, 2522, 663, 8, 1027, 1296, 9, 398, 1830, 1094, 26, 288, 2163, 63, 1825, 275, 942, 953, 367, 4349, 315, 1094, 26, 355, 340, 4349, 508, 1284, 10155, 26, 490, 372, 6033, 435, 413, 355, 367, 284, 315, 4945, 8, 552, 8, 1027, 2298, 490, 367, 1335, 315, 283, 23459, 356, 717, 7627, 275, 4349, 1491, 73, 61, 435, 1335, 435, 4349, 59, 73, 435, 413, 2938, 717, 340, 7627, 440, 315, 15867, 436, 7627, 315, 4237, 26, 1169, 2163, 63, 1825, 14, 740, 8, 9007, 9, 1169, 15867, 14, 525, 8, 9007, 9, 288, 6033, 847, 413, 288, 1094, 275, 2163, 63, 1825, 398, 372, 378, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 870, 9274, 1252, 76, 28874, 4625, 480, 12948, 401, 298, 23147, 401, 663, 5234, 8885, 401, 298, 3287, 401, 298, 13889, 401, 298, 1653, 401, 298, 793, 13045, 272, 870, 9274, 1252, 76, 28874, 4625, 480, 12948, 401, 298, 23147, 401, 663, 5234, 8885, 401, 298, 3287, 401, 298, 13889, 401, 298, 1653, 401, 298, 793, 401, 298, 23147, 13045, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cewood/ansible-modules-core
cloud/docker/docker_login.py
39
9349
#!/usr/bin/python # # (c) 2016 Olaf Kilian <olaf.kilian@symanex.com> # Chris Houseknecht, <house@redhat.com> # James Tanner, <jtanner@redhat.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: docker_login short_description: Log into a Docker registry. version_added: "2.0" description: - Provides functionality similar to the "docker login" command. - Authenticate with a docker registry and add the credentials to your local Docker config file. Adding the credentials to the config files allows future connections to the registry using tools such as Ansible's Docker modules, the Docker CLI and docker-py without needing to provide credentials. - Running in check mode will perform the authentication without updating the config file. options: registry_url: description: - The registry URL. default: "https://index.docker.io/v1/" aliases: - registry - url username: description: - The username for the registry account required: true default: null password: description: - The plaintext password for the registry account required: true default: null email: description: - "The email address for the registry account. NOTE: private registries may not require this, but Docker Hub requires it." default: None reauthorize: description: - Refresh exiting authentication found in the configuration file. default: false aliases: - reauth config_path: description: - Custom path to the Docker CLI configuration file. default: ~/.docker/config.json aliases: - self.config_path - dockercfg_path extends_documentation_fragment: - docker requirements: - "python >= 2.6" - "docker-py >= 1.7.0" - "Docker API >= 1.20" authors: - "Olaf Kilian <olaf.kilian@symanex.com>" - "Chris Houseknecht (@chouseknecht)" - "James Tanner (@jctanner)" ''' EXAMPLES = ''' - name: Log into DockerHub docker_login: username: docker password: rekcod email: docker@docker.io - name: Log into private registry and force re-authorization docker_login: registry: your.private.registry.io username: yourself password: secrets3 reauthorize: yes - name: Log into DockerHub using a custom config file docker_login: username: docker password: rekcod email: docker@docker.io config_path: /tmp/.mydockercfg ''' RETURN = ''' actions: description: List of actions taken by the module. returned: always type: list sample: [ "Log into https://index.docker.io/v1/", "Updated config file /Users/chouseknecht/.docker/config.json with new authorization for https://index.docker.io/v1/" ] login_results: description: Results from the login. returned: always type: dict sample: { "email": "testuer@yahoo.com", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "serveraddress": "localhost:5000", "username": "testuser" } ''' import base64 from ansible.module_utils.docker_common import * class LoginManager(DockerBaseClass): def __init__(self, client, results): super(LoginManager, self).__init__() self.client = client self.results = results parameters = self.client.module.params self.check_mode = self.client.check_mode self.registry_url = parameters.get('registry_url') self.username = parameters.get('username') self.password = parameters.get('password') self.email = parameters.get('email') self.reauthorize = parameters.get('reauthorize') self.config_path = parameters.get('config_path') self.login() def fail(self, msg): self.client.fail(msg) def login(self): ''' Log into the registry with provided username/password. On success update the config file with the new authorization. :return: None ''' if self.email and not re.match(EMAIL_REGEX, self.email): self.fail("Parameter error: the email address appears to be incorrect. Expecting it to match " "/%s/" % (EMAIL_REGEX)) self.results['actions'].append("Logged into %s" % (self.registry_url)) self.log("Log into %s with username %s" % (self.registry_url, self.username)) try: response = self.client.login( self.username, password=self.password, email=self.email, registry=self.registry_url, reauth=self.reauthorize, dockercfg_path=self.config_path ) except Exception as exc: self.fail("Logging into %s for user %s failed - %s" % (self.registry_url, self.username, str(exc))) self.results['login_result'] = response if not self.check_mode: self.update_config_file() def config_file_exists(self, path): if os.path.exists(path): self.log("Configuration file %s exists" % (path)) return True self.log("Configuration file %s not found." % (path)) return False def create_config_file(self, path): ''' Create a config file with a JSON blob containing an auths key. :return: None ''' self.log("Creating docker config file %s" % (path)) config_path_dir = os.path.dirname(path) if not os.path.exists(config_path_dir): try: os.makedirs(config_path_dir) except Exception as exc: self.fail("Error: failed to create %s - %s" % (config_path_dir, str(exc))) self.write_config(path, dict(auths=dict())) def write_config(self, path, config): try: json.dump(config, open(path, "w"), indent=5, sort_keys=True) except Exception as exc: self.fail("Error: failed to write config to %s - %s" % (path, str(exc))) def update_config_file(self): ''' If the authorization not stored in the config file or reauthorize is True, update the config file with the new authorization. :return: None ''' path = os.path.expanduser(self.config_path) if not self.config_file_exists(path): self.create_config_file(path) try: # read the existing config config = json.load(open(path, "r")) except ValueError: self.log("Error reading config from %s" % (path)) config = dict() if not config.get('auths'): self.log("Adding auths dict to config.") config['auths'] = dict() if not config['auths'].get(self.registry_url): self.log("Adding registry_url %s to auths." % (self.registry_url)) config['auths'][self.registry_url] = dict() encoded_credentials = dict( auth=base64.b64encode(self.username + b':' + self.password), email=self.email ) if config['auths'][self.registry_url] != encoded_credentials or self.reauthorize: # Update the config file with the new authorization config['auths'][self.registry_url] = encoded_credentials self.log("Updating config file %s with new authorization for %s" % (path, self.registry_url)) self.results['actions'].append("Updated config file %s with new authorization for %s" % ( path, self.registry_url)) self.results['changed'] = True self.write_config(path, config) def main(): argument_spec=dict( registry_url=dict(type='str', required=False, default=DEFAULT_DOCKER_REGISTRY, aliases=['registry', 'url']), username=dict(type='str', required=True), password=dict(type='str', required=True, no_log=True), email=dict(type='str'), reauthorize=dict(type='bool', default=False, aliases=['reauth']), config_path=dict(type='str', default='~/.docker/config.json', aliases=['self.config_path', 'dockercfg_path']), ) required_if = [ ('registry_url', DEFAULT_DOCKER_REGISTRY, ['email']) ] client = AnsibleDockerClient( argument_spec=argument_spec, supports_check_mode=True, required_if=required_if ) results = dict( changed=False, actions=[], login_result={} ) LoginManager(client, results) client.module.exit_json(**results) # import module snippets from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 334, 67, 9, 7800, 593, 416, 70, 1804, 1638, 290, 665, 393, 2756, 14, 75, 1638, 290, 32, 1786, 1237, 476, 14, 957, 30, 199, 3, 3515, 2799, 5719, 869, 7130, 75, 685, 335, 84, 12, 665, 6740, 32, 17164, 14, 957, 30, 199, 3, 3515, 1603, 14015, 377, 5161, 12, 665, 26002, 5161, 32, 17164, 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, 199, 3, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12424, 63, 2886, 199, 199, 3612, 63, 1802, 26, 5297, 1901, 282, 22067, 7086, 14, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 199, 1802, 26, 272, 446, 21552, 9330, 8545, 370, 314, 298, 9991, 4676, 2, 1414, 14, 272, 446, 3590, 7672, 543, 282, 12424, 7086, 436, 1050, 314, 6235, 370, 2195, 2257, 22067, 1101, 570, 14, 12934, 314, 489, 6235, 370, 314, 1101, 1584, 6127, 6466, 6947, 370, 314, 7086, 1808, 7249, 4066, 465, 2622, 1159, 22067, 489, 4621, 12, 314, 22067, 14214, 436, 12424, 13, 647, 1928, 1929, 316, 370, 5647, 6235, 14, 272, 446, 26848, 315, 1104, 818, 911, 5147, 314, 6299, 1928, 12928, 314, 1101, 570, 14, 199, 199, 1419, 26, 523, 7086, 63, 633, 26, 272, 1369, 26, 489, 446, 710, 7086, 2851, 14, 272, 849, 26, 298, 2859, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 6687, 272, 5481, 26, 489, 446, 7086, 489, 446, 1166, 523, 3434, 26, 272, 1369, 26, 489, 446, 710, 3434, 367, 314, 7086, 2933, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 2505, 26, 272, 1369, 26, 489, 446, 710, 18577, 2505, 367, 314, 7086, 2933, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 3031, 26, 272, 1369, 26, 489, 446, 298, 1918, 3031, 2287, 367, 314, 7086, 2933, 14, 6944, 26, 5726, 25483, 1996, 1443, 440, 4409, 642, 12, 267, 1325, 22067, 869, 456, 5074, 652, 2122, 272, 849, 26, 488, 523, 295, 14204, 26, 272, 1369, 26, 489, 446, 30345, 24234, 6299, 1911, 315, 314, 2897, 570, 14, 272, 849, 26, 3055, 272, 5481, 26, 489, 446, 295, 1178, 523, 1101, 63, 515, 26, 272, 1369, 26, 489, 446, 8388, 931, 370, 314, 22067, 14214, 2897, 570, 14, 272, 849, 26, 25975, 9991, 15, 888, 14, 1001, 272, 5481, 26, 489, 446, 291, 14, 888, 63, 515, 489, 446, 12424, 4128, 63, 515, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 12424, 199, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 9991, 13, 647, 2356, 413, 14, 23, 14, 16, 2, 272, 446, 298, 31463, 3261, 2356, 413, 14, 1165, 2, 199, 199, 8149, 26, 272, 446, 298, 47, 416, 70, 1804, 1638, 290, 665, 393, 2756, 14, 75, 1638, 290, 32, 1786, 1237, 476, 14, 957, 4335, 272, 446, 298, 1049, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 2924, 272, 446, 298, 42, 14015, 377, 5161, 8593, 74, 319, 5161, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 13, 536, 26, 5297, 1901, 22067, 15338, 523, 12424, 63, 2886, 26, 272, 3434, 26, 12424, 272, 2505, 26, 295, 75, 7889, 272, 3031, 26, 12424, 32, 9991, 14, 2308, 199, 199, 13, 536, 26, 5297, 1901, 5726, 7086, 436, 3542, 295, 13, 15846, 523, 12424, 63, 2886, 26, 272, 7086, 26, 2195, 14, 4239, 14, 5189, 14, 2308, 272, 3434, 26, 28225, 272, 2505, 26, 25563, 19, 272, 295, 14204, 26, 9456, 199, 199, 13, 536, 26, 5297, 1901, 22067, 15338, 1808, 282, 3537, 1101, 570, 523, 12424, 63, 2886, 26, 272, 3434, 26, 12424, 272, 2505, 26, 295, 75, 7889, 272, 3031, 26, 12424, 32, 9991, 14, 2308, 272, 1101, 63, 515, 26, 1182, 2791, 8083, 1662, 9991, 4128, 199, 199, 2344, 199, 199, 9677, 275, 1449, 199, 3723, 26, 272, 1369, 26, 3820, 402, 5445, 9394, 701, 314, 859, 14, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 359, 267, 298, 2445, 1901, 4178, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 10665, 267, 298, 19920, 1101, 570, 1182, 12117, 15, 335, 7130, 75, 685, 335, 84, 8083, 9991, 15, 888, 14, 1001, 543, 892, 13448, 367, 4178, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 6687, 272, 1622, 199, 2886, 63, 2604, 26, 272, 1369, 26, 24288, 687, 314, 4676, 14, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2123, 582, 298, 396, 14262, 32, 27231, 14, 957, 401, 267, 298, 2060, 582, 298, 7041, 63, 22917, 19679, 63, 568, 63, 2826, 63, 4947, 63, 14472, 401, 267, 298, 1000, 1562, 582, 298, 5967, 26, 13128, 401, 267, 298, 2473, 582, 298, 21029, 2, 272, 789, 199, 2344, 199, 199, 646, 1300, 772, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9991, 63, 2330, 492, 627, 421, 199, 533, 16430, 2988, 8, 31463, 1563, 2543, 304, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 2058, 304, 398, 1613, 8, 8880, 2988, 12, 291, 2843, 826, 4533, 398, 291, 14, 1258, 275, 1890, 267, 291, 14, 2604, 275, 2058, 267, 2633, 275, 291, 14, 1258, 14, 578, 14, 1162, 267 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 334, 67, 9, 7800, 593, 416, 70, 1804, 1638, 290, 665, 393, 2756, 14, 75, 1638, 290, 32, 1786, 1237, 476, 14, 957, 30, 199, 3, 3515, 2799, 5719, 869, 7130, 75, 685, 335, 84, 12, 665, 6740, 32, 17164, 14, 957, 30, 199, 3, 3515, 1603, 14015, 377, 5161, 12, 665, 26002, 5161, 32, 17164, 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, 199, 3, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12424, 63, 2886, 199, 199, 3612, 63, 1802, 26, 5297, 1901, 282, 22067, 7086, 14, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 199, 1802, 26, 272, 446, 21552, 9330, 8545, 370, 314, 298, 9991, 4676, 2, 1414, 14, 272, 446, 3590, 7672, 543, 282, 12424, 7086, 436, 1050, 314, 6235, 370, 2195, 2257, 22067, 1101, 570, 14, 12934, 314, 489, 6235, 370, 314, 1101, 1584, 6127, 6466, 6947, 370, 314, 7086, 1808, 7249, 4066, 465, 2622, 1159, 22067, 489, 4621, 12, 314, 22067, 14214, 436, 12424, 13, 647, 1928, 1929, 316, 370, 5647, 6235, 14, 272, 446, 26848, 315, 1104, 818, 911, 5147, 314, 6299, 1928, 12928, 314, 1101, 570, 14, 199, 199, 1419, 26, 523, 7086, 63, 633, 26, 272, 1369, 26, 489, 446, 710, 7086, 2851, 14, 272, 849, 26, 298, 2859, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 6687, 272, 5481, 26, 489, 446, 7086, 489, 446, 1166, 523, 3434, 26, 272, 1369, 26, 489, 446, 710, 3434, 367, 314, 7086, 2933, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 2505, 26, 272, 1369, 26, 489, 446, 710, 18577, 2505, 367, 314, 7086, 2933, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 3031, 26, 272, 1369, 26, 489, 446, 298, 1918, 3031, 2287, 367, 314, 7086, 2933, 14, 6944, 26, 5726, 25483, 1996, 1443, 440, 4409, 642, 12, 267, 1325, 22067, 869, 456, 5074, 652, 2122, 272, 849, 26, 488, 523, 295, 14204, 26, 272, 1369, 26, 489, 446, 30345, 24234, 6299, 1911, 315, 314, 2897, 570, 14, 272, 849, 26, 3055, 272, 5481, 26, 489, 446, 295, 1178, 523, 1101, 63, 515, 26, 272, 1369, 26, 489, 446, 8388, 931, 370, 314, 22067, 14214, 2897, 570, 14, 272, 849, 26, 25975, 9991, 15, 888, 14, 1001, 272, 5481, 26, 489, 446, 291, 14, 888, 63, 515, 489, 446, 12424, 4128, 63, 515, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 12424, 199, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 9991, 13, 647, 2356, 413, 14, 23, 14, 16, 2, 272, 446, 298, 31463, 3261, 2356, 413, 14, 1165, 2, 199, 199, 8149, 26, 272, 446, 298, 47, 416, 70, 1804, 1638, 290, 665, 393, 2756, 14, 75, 1638, 290, 32, 1786, 1237, 476, 14, 957, 4335, 272, 446, 298, 1049, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 2924, 272, 446, 298, 42, 14015, 377, 5161, 8593, 74, 319, 5161, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 13, 536, 26, 5297, 1901, 22067, 15338, 523, 12424, 63, 2886, 26, 272, 3434, 26, 12424, 272, 2505, 26, 295, 75, 7889, 272, 3031, 26, 12424, 32, 9991, 14, 2308, 199, 199, 13, 536, 26, 5297, 1901, 5726, 7086, 436, 3542, 295, 13, 15846, 523, 12424, 63, 2886, 26, 272, 7086, 26, 2195, 14, 4239, 14, 5189, 14, 2308, 272, 3434, 26, 28225, 272, 2505, 26, 25563, 19, 272, 295, 14204, 26, 9456, 199, 199, 13, 536, 26, 5297, 1901, 22067, 15338, 1808, 282, 3537, 1101, 570, 523, 12424, 63, 2886, 26, 272, 3434, 26, 12424, 272, 2505, 26, 295, 75, 7889, 272, 3031, 26, 12424, 32, 9991, 14, 2308, 272, 1101, 63, 515, 26, 1182, 2791, 8083, 1662, 9991, 4128, 199, 199, 2344, 199, 199, 9677, 275, 1449, 199, 3723, 26, 272, 1369, 26, 3820, 402, 5445, 9394, 701, 314, 859, 14, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 359, 267, 298, 2445, 1901, 4178, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 10665, 267, 298, 19920, 1101, 570, 1182, 12117, 15, 335, 7130, 75, 685, 335, 84, 8083, 9991, 15, 888, 14, 1001, 543, 892, 13448, 367, 4178, 921, 1080, 14, 9991, 14, 2308, 15, 86, 17, 6687, 272, 1622, 199, 2886, 63, 2604, 26, 272, 1369, 26, 24288, 687, 314, 4676, 14, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2123, 582, 298, 396, 14262, 32, 27231, 14, 957, 401, 267, 298, 2060, 582, 298, 7041, 63, 22917, 19679, 63, 568, 63, 2826, 63, 4947, 63, 14472, 401, 267, 298, 1000, 1562, 582, 298, 5967, 26, 13128, 401, 267, 298, 2473, 582, 298, 21029, 2, 272, 789, 199, 2344, 199, 199, 646, 1300, 772, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9991, 63, 2330, 492, 627, 421, 199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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 ]
ARPASMR/IRIS_lombardia
html/GXM-0.1/tools/BeautifulSoup.py
307
69566
"""Beautiful Soup Elixir and Tonic "The Screen-Scraper's Friend" http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup parses a (possibly invalid) XML or HTML document into a tree representation. It provides methods and Pythonic idioms that make it easy to navigate, search, and modify the tree. A well-formed XML/HTML document yields a well-formed data structure. An ill-formed XML/HTML document yields a correspondingly ill-formed data structure. If your document is only locally well-formed, you can use this library to find and process the well-formed part of it. The BeautifulSoup class Beautiful Soup works with Python 2.2 and up. It has no external dependencies, but you'll have more success at converting data to UTF-8 if you also install these three packages: * chardet, for auto-detecting character encodings http://chardet.feedparser.org/ * cjkcodecs and iconv_codec, which add more encodings to the ones supported by stock Python. http://cjkpython.i18n.org/ Beautiful Soup defines classes for two main parsing strategies: * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific language that kind of looks like XML. * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid or invalid. This class has web browser-like heuristics for obtaining a sensible parse tree in the face of common HTML errors. Beautiful Soup also defines a class (UnicodeDammit) for autodetecting the encoding of an HTML or XML document, and converting it to Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser. For more than you ever wanted to know about Beautiful Soup, see the documentation: http://www.crummy.com/software/BeautifulSoup/documentation.html """ from __future__ import generators __author__ = "Leonard Richardson (leonardr@segfault.org)" __version__ = "3.0.4" __copyright__ = "Copyright (c) 2004-2007 Leonard Richardson" __license__ = "PSF" from sgmllib import SGMLParser, SGMLParseError import codecs import types import re import sgmllib try: from htmlentitydefs import name2codepoint except ImportError: name2codepoint = {} #This hack makes Beautiful Soup able to parse XML with namespaces sgmllib.tagfind = re.compile('[a-zA-Z][-_.:a-zA-Z0-9]*') DEFAULT_OUTPUT_ENCODING = "utf-8" # First, the classes that represent markup elements. class PageElement: """Contains the navigational information for some part of the page (either a tag or a piece of text)""" def setup(self, parent=None, previous=None): """Sets up the initial relations between this element and other elements.""" self.parent = parent self.previous = previous self.next = None self.previousSibling = None self.nextSibling = None if self.parent and self.parent.contents: self.previousSibling = self.parent.contents[-1] self.previousSibling.nextSibling = self def replaceWith(self, replaceWith): oldParent = self.parent myIndex = self.parent.contents.index(self) if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent: # We're replacing this element with one of its siblings. index = self.parent.contents.index(replaceWith) if index and index < myIndex: # Furthermore, it comes before this element. That # means that when we extract it, the index of this # element will change. myIndex = myIndex - 1 self.extract() oldParent.insert(myIndex, replaceWith) def extract(self): """Destructively rips this element out of the tree.""" if self.parent: try: self.parent.contents.remove(self) except ValueError: pass #Find the two elements that would be next to each other if #this element (and any children) hadn't been parsed. Connect #the two. lastChild = self._lastRecursiveChild() nextElement = lastChild.next if self.previous: self.previous.next = nextElement if nextElement: nextElement.previous = self.previous self.previous = None lastChild.next = None self.parent = None if self.previousSibling: self.previousSibling.nextSibling = self.nextSibling if self.nextSibling: self.nextSibling.previousSibling = self.previousSibling self.previousSibling = self.nextSibling = None def _lastRecursiveChild(self): "Finds the last element beneath this object to be parsed." lastChild = self while hasattr(lastChild, 'contents') and lastChild.contents: lastChild = lastChild.contents[-1] return lastChild def insert(self, position, newChild): if (isinstance(newChild, basestring) or isinstance(newChild, unicode)) \ and not isinstance(newChild, NavigableString): newChild = NavigableString(newChild) position = min(position, len(self.contents)) if hasattr(newChild, 'parent') and newChild.parent != None: # We're 'inserting' an element that's already one # of this object's children. if newChild.parent == self: index = self.find(newChild) if index and index < position: # Furthermore we're moving it further down the # list of this object's children. That means that # when we extract this element, our target index # will jump down one. position = position - 1 newChild.extract() newChild.parent = self previousChild = None if position == 0: newChild.previousSibling = None newChild.previous = self else: previousChild = self.contents[position-1] newChild.previousSibling = previousChild newChild.previousSibling.nextSibling = newChild newChild.previous = previousChild._lastRecursiveChild() if newChild.previous: newChild.previous.next = newChild newChildsLastElement = newChild._lastRecursiveChild() if position >= len(self.contents): newChild.nextSibling = None parent = self parentsNextSibling = None while not parentsNextSibling: parentsNextSibling = parent.nextSibling parent = parent.parent if not parent: # This is the last element in the document. break if parentsNextSibling: newChildsLastElement.next = parentsNextSibling else: newChildsLastElement.next = None else: nextChild = self.contents[position] newChild.nextSibling = nextChild if newChild.nextSibling: newChild.nextSibling.previousSibling = newChild newChildsLastElement.next = nextChild if newChildsLastElement.next: newChildsLastElement.next.previous = newChildsLastElement self.contents.insert(position, newChild) def findNext(self, name=None, attrs={}, text=None, **kwargs): """Returns the first item that matches the given criteria and appears after this Tag in the document.""" return self._findOne(self.findAllNext, name, attrs, text, **kwargs) def findAllNext(self, name=None, attrs={}, text=None, limit=None, **kwargs): """Returns all items that match the given criteria and appear before after Tag in the document.""" return self._findAll(name, attrs, text, limit, self.nextGenerator) def findNextSibling(self, name=None, attrs={}, text=None, **kwargs): """Returns the closest sibling to this Tag that matches the given criteria and appears after this Tag in the document.""" return self._findOne(self.findNextSiblings, name, attrs, text, **kwargs) def findNextSiblings(self, name=None, attrs={}, text=None, limit=None, **kwargs): """Returns the siblings of this Tag that match the given criteria and appear after this Tag in the document.""" return self._findAll(name, attrs, text, limit, self.nextSiblingGenerator, **kwargs) fetchNextSiblings = findNextSiblings # Compatibility with pre-3.x def findPrevious(self, name=None, attrs={}, text=None, **kwargs): """Returns the first item that matches the given criteria and appears before this Tag in the document.""" return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs) def findAllPrevious(self, name=None, attrs={}, text=None, limit=None, **kwargs): """Returns all items that match the given criteria and appear before this Tag in the document.""" return self._findAll(name, attrs, text, limit, self.previousGenerator, **kwargs) fetchPrevious = findAllPrevious # Compatibility with pre-3.x def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs): """Returns the closest sibling to this Tag that matches the given criteria and appears before this Tag in the document.""" return self._findOne(self.findPreviousSiblings, name, attrs, text, **kwargs) def findPreviousSiblings(self, name=None, attrs={}, text=None, limit=None, **kwargs): """Returns the siblings of this Tag that match the given criteria and appear before this Tag in the document.""" return self._findAll(name, attrs, text, limit, self.previousSiblingGenerator, **kwargs) fetchPreviousSiblings = findPreviousSiblings # Compatibility with pre-3.x def findParent(self, name=None, attrs={}, **kwargs): """Returns the closest parent of this Tag that matches the given criteria.""" # NOTE: We can't use _findOne because findParents takes a different # set of arguments. r = None l = self.findParents(name, attrs, 1) if l: r = l[0] return r def findParents(self, name=None, attrs={}, limit=None, **kwargs): """Returns the parents of this Tag that match the given criteria.""" return self._findAll(name, attrs, None, limit, self.parentGenerator, **kwargs) fetchParents = findParents # Compatibility with pre-3.x #These methods do the real heavy lifting. def _findOne(self, method, name, attrs, text, **kwargs): r = None l = method(name, attrs, text, 1, **kwargs) if l: r = l[0] return r def _findAll(self, name, attrs, text, limit, generator, **kwargs): "Iterates over a generator looking for things that match." if isinstance(name, SoupStrainer): strainer = name else: # Build a SoupStrainer strainer = SoupStrainer(name, attrs, text, **kwargs) results = ResultSet(strainer) g = generator() while True: try: i = g.next() except StopIteration: break if i: found = strainer.search(i) if found: results.append(found) if limit and len(results) >= limit: break return results #These Generators can be used to navigate starting from both #NavigableStrings and Tags. def nextGenerator(self): i = self while i: i = i.next yield i def nextSiblingGenerator(self): i = self while i: i = i.nextSibling yield i def previousGenerator(self): i = self while i: i = i.previous yield i def previousSiblingGenerator(self): i = self while i: i = i.previousSibling yield i def parentGenerator(self): i = self while i: i = i.parent yield i # Utility methods def substituteEncoding(self, str, encoding=None): encoding = encoding or "utf-8" return str.replace("%SOUP-ENCODING%", encoding) def toEncoding(self, s, encoding=None): """Encodes an object to a string in some encoding, or to Unicode. .""" if isinstance(s, unicode): if encoding: s = s.encode(encoding) elif isinstance(s, str): if encoding: s = s.encode(encoding) else: s = unicode(s) else: if encoding: s = self.toEncoding(str(s), encoding) else: s = unicode(s) return s class NavigableString(unicode, PageElement): def __getattr__(self, attr): """text.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.""" if attr == 'string': return self else: raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr) def __unicode__(self): return self.__str__(None) def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): if encoding: return self.encode(encoding) else: return self class CData(NavigableString): def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): return "<![CDATA[%s]]>" % NavigableString.__str__(self, encoding) class ProcessingInstruction(NavigableString): def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): output = self if "%SOUP-ENCODING%" in output: output = self.substituteEncoding(output, encoding) return "<?%s?>" % self.toEncoding(output, encoding) class Comment(NavigableString): def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): return "<!--%s-->" % NavigableString.__str__(self, encoding) class Declaration(NavigableString): def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): return "<!%s>" % NavigableString.__str__(self, encoding) class Tag(PageElement): """Represents a found HTML tag with its attributes and contents.""" XML_SPECIAL_CHARS_TO_ENTITIES = { "'" : "squot", '"' : "quote", "&" : "amp", "<" : "lt", ">" : "gt" } def __init__(self, parser, name, attrs=None, parent=None, previous=None): "Basic constructor." # We don't actually store the parser object: that lets extracted # chunks be garbage-collected self.parserClass = parser.__class__ self.isSelfClosing = parser.isSelfClosingTag(name) self.name = name if attrs == None: attrs = [] self.attrs = attrs self.contents = [] self.setup(parent, previous) self.hidden = False self.containsSubstitutions = False def get(self, key, default=None): """Returns the value of the 'key' attribute for the tag, or the value given for 'default' if it doesn't have that attribute.""" return self._getAttrMap().get(key, default) def has_key(self, key): return self._getAttrMap().has_key(key) def __getitem__(self, key): """tag[key] returns the value of the 'key' attribute for the tag, and throws an exception if it's not there.""" return self._getAttrMap()[key] def __iter__(self): "Iterating over a tag iterates over its contents." return iter(self.contents) def __len__(self): "The length of a tag is the length of its list of contents." return len(self.contents) def __contains__(self, x): return x in self.contents def __nonzero__(self): "A tag is non-None even if it has no contents." return True def __setitem__(self, key, value): """Setting tag[key] sets the value of the 'key' attribute for the tag.""" self._getAttrMap() self.attrMap[key] = value found = False for i in range(0, len(self.attrs)): if self.attrs[i][0] == key: self.attrs[i] = (key, value) found = True if not found: self.attrs.append((key, value)) self._getAttrMap()[key] = value def __delitem__(self, key): "Deleting tag[key] deletes all 'key' attributes for the tag." for item in self.attrs: if item[0] == key: self.attrs.remove(item) #We don't break because bad HTML can define the same #attribute multiple times. self._getAttrMap() if self.attrMap.has_key(key): del self.attrMap[key] def __call__(self, *args, **kwargs): """Calling a tag like a function is the same as calling its findAll() method. Eg. tag('a') returns a list of all the A tags found within this tag.""" return apply(self.findAll, args, kwargs) def __getattr__(self, tag): #print "Getattr %s.%s" % (self.__class__, tag) if len(tag) > 3 and tag.rfind('Tag') == len(tag)-3: return self.find(tag[:-3]) elif tag.find('__') != 0: return self.find(tag) def __eq__(self, other): """Returns true iff this tag has the same name, the same attributes, and the same contents (recursively) as the given tag. NOTE: right now this will return false if two tags have the same attributes in a different order. Should this be fixed?""" if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other): return False for i in range(0, len(self.contents)): if self.contents[i] != other.contents[i]: return False return True def __ne__(self, other): """Returns true iff this tag is not identical to the other tag, as defined in __eq__.""" return not self == other def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING): """Renders this tag as a string.""" return self.__str__(encoding) def __unicode__(self): return self.__str__(None) def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0): """Returns a string or Unicode representation of this tag and its contents. To get Unicode, pass None for encoding. NOTE: since Python's HTML parser consumes whitespace, this method is not certain to reproduce the whitespace present in the original string.""" encodedName = self.toEncoding(self.name, encoding) attrs = [] if self.attrs: for key, val in self.attrs: fmt = '%s="%s"' if isString(val): if self.containsSubstitutions and '%SOUP-ENCODING%' in val: val = self.substituteEncoding(val, encoding) # The attribute value either: # # * Contains no embedded double quotes or single quotes. # No problem: we enclose it in double quotes. # * Contains embedded single quotes. No problem: # double quotes work here too. # * Contains embedded double quotes. No problem: # we enclose it in single quotes. # * Embeds both single _and_ double quotes. This # can't happen naturally, but it can happen if # you modify an attribute value after parsing # the document. Now we have a bit of a # problem. We solve it by enclosing the # attribute in single quotes, and escaping any # embedded single quotes to XML entities. if '"' in val: fmt = "%s='%s'" # This can't happen naturally, but it can happen # if you modify an attribute value after parsing. if "'" in val: val = val.replace("'", "&squot;") # Now we're okay w/r/t quotes. But the attribute # value might also contain angle brackets, or # ampersands that aren't part of entities. We need # to escape those to XML entities too. val = re.sub("([<>]|&(?![^\s]+;))", lambda x: "&" + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]] + ";", val) attrs.append(fmt % (self.toEncoding(key, encoding), self.toEncoding(val, encoding))) close = '' closeTag = '' if self.isSelfClosing: close = ' /' else: closeTag = '</%s>' % encodedName indentTag, indentContents = 0, 0 if prettyPrint: indentTag = indentLevel space = (' ' * (indentTag-1)) indentContents = indentTag + 1 contents = self.renderContents(encoding, prettyPrint, indentContents) if self.hidden: s = contents else: s = [] attributeString = '' if attrs: attributeString = ' ' + ' '.join(attrs) if prettyPrint: s.append(space) s.append('<%s%s%s>' % (encodedName, attributeString, close)) if prettyPrint: s.append("\n") s.append(contents) if prettyPrint and contents and contents[-1] != "\n": s.append("\n") if prettyPrint and closeTag: s.append(space) s.append(closeTag) if prettyPrint and closeTag and self.nextSibling: s.append("\n") s = ''.join(s) return s def prettify(self, encoding=DEFAULT_OUTPUT_ENCODING): return self.__str__(encoding, True) def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0): """Renders the contents of this tag as a string in the given encoding. If encoding is None, returns a Unicode string..""" s=[] for c in self: text = None if isinstance(c, NavigableString): text = c.__str__(encoding) elif isinstance(c, Tag): s.append(c.__str__(encoding, prettyPrint, indentLevel)) if text and prettyPrint: text = text.strip() if text: if prettyPrint: s.append(" " * (indentLevel-1)) s.append(text) if prettyPrint: s.append("\n") return ''.join(s) #Soup methods def find(self, name=None, attrs={}, recursive=True, text=None, **kwargs): """Return only the first child of this Tag matching the given criteria.""" r = None l = self.findAll(name, attrs, recursive, text, 1, **kwargs) if l: r = l[0] return r findChild = find def findAll(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs): """Extracts a list of Tag objects that match the given criteria. You can specify the name of the Tag and any attributes you want the Tag to have. The value of a key-value pair in the 'attrs' map can be a string, a list of strings, a regular expression object, or a callable that takes a string and returns whether or not the string matches for some custom definition of 'matches'. The same is true of the tag name.""" generator = self.recursiveChildGenerator if not recursive: generator = self.childGenerator return self._findAll(name, attrs, text, limit, generator, **kwargs) findChildren = findAll # Pre-3.x compatibility methods first = find fetch = findAll def fetchText(self, text=None, recursive=True, limit=None): return self.findAll(text=text, recursive=recursive, limit=limit) def firstText(self, text=None, recursive=True): return self.find(text=text, recursive=recursive) #Utility methods def append(self, tag): """Appends the given tag to the contents of this tag.""" self.contents.append(tag) #Private methods def _getAttrMap(self): """Initializes a map representation of this tag's attributes, if not already initialized.""" if not getattr(self, 'attrMap'): self.attrMap = {} for (key, value) in self.attrs: self.attrMap[key] = value return self.attrMap #Generator methods def childGenerator(self): for i in range(0, len(self.contents)): yield self.contents[i] raise StopIteration def recursiveChildGenerator(self): stack = [(self, 0)] while stack: tag, start = stack.pop() if isinstance(tag, Tag): for i in range(start, len(tag.contents)): a = tag.contents[i] yield a if isinstance(a, Tag) and tag.contents: if i < len(tag.contents) - 1: stack.append((tag, i+1)) stack.append((a, 0)) break raise StopIteration # Next, a couple classes to represent queries and their results. class SoupStrainer: """Encapsulates a number of ways of matching a markup element (tag or text).""" def __init__(self, name=None, attrs={}, text=None, **kwargs): self.name = name if isString(attrs): kwargs['class'] = attrs attrs = None if kwargs: if attrs: attrs = attrs.copy() attrs.update(kwargs) else: attrs = kwargs self.attrs = attrs self.text = text def __str__(self): if self.text: return self.text else: return "%s|%s" % (self.name, self.attrs) def searchTag(self, markupName=None, markupAttrs={}): found = None markup = None if isinstance(markupName, Tag): markup = markupName markupAttrs = markup callFunctionWithTagData = callable(self.name) \ and not isinstance(markupName, Tag) if (not self.name) \ or callFunctionWithTagData \ or (markup and self._matches(markup, self.name)) \ or (not markup and self._matches(markupName, self.name)): if callFunctionWithTagData: match = self.name(markupName, markupAttrs) else: match = True markupAttrMap = None for attr, matchAgainst in self.attrs.items(): if not markupAttrMap: if hasattr(markupAttrs, 'get'): markupAttrMap = markupAttrs else: markupAttrMap = {} for k,v in markupAttrs: markupAttrMap[k] = v attrValue = markupAttrMap.get(attr) if not self._matches(attrValue, matchAgainst): match = False break if match: if markup: found = markup else: found = markupName return found def search(self, markup): #print 'looking for %s in %s' % (self, markup) found = None # If given a list of items, scan it for a text element that # matches. if isList(markup) and not isinstance(markup, Tag): for element in markup: if isinstance(element, NavigableString) \ and self.search(element): found = element break # If it's a Tag, make sure its name or attributes match. # Don't bother with Tags if we're searching for text. elif isinstance(markup, Tag): if not self.text: found = self.searchTag(markup) # If it's text, make sure the text matches. elif isinstance(markup, NavigableString) or \ isString(markup): if self._matches(markup, self.text): found = markup else: raise Exception, "I don't know how to match against a %s" \ % markup.__class__ return found def _matches(self, markup, matchAgainst): #print "Matching %s against %s" % (markup, matchAgainst) result = False if matchAgainst == True and type(matchAgainst) == types.BooleanType: result = markup != None elif callable(matchAgainst): result = matchAgainst(markup) else: #Custom match methods take the tag as an argument, but all #other ways of matching match the tag name as a string. if isinstance(markup, Tag): markup = markup.name if markup and not isString(markup): markup = unicode(markup) #Now we know that chunk is either a string, or None. if hasattr(matchAgainst, 'match'): # It's a regexp object. result = markup and matchAgainst.search(markup) elif isList(matchAgainst): result = markup in matchAgainst elif hasattr(matchAgainst, 'items'): result = markup.has_key(matchAgainst) elif matchAgainst and isString(markup): if isinstance(markup, unicode): matchAgainst = unicode(matchAgainst) else: matchAgainst = str(matchAgainst) if not result: result = matchAgainst == markup return result class ResultSet(list): """A ResultSet is just a list that keeps track of the SoupStrainer that created it.""" def __init__(self, source): list.__init__([]) self.source = source # Now, some helper functions. def isList(l): """Convenience method that works with all 2.x versions of Python to determine whether or not something is listlike.""" return hasattr(l, '__iter__') \ or (type(l) in (types.ListType, types.TupleType)) def isString(s): """Convenience method that works with all 2.x versions of Python to determine whether or not something is stringlike.""" try: return isinstance(s, unicode) or isintance(s, basestring) except NameError: return isinstance(s, str) def buildTagMap(default, *args): """Turns a list of maps, lists, or scalars into a single map. Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and NESTING_RESET_TAGS maps out of lists and partial maps.""" built = {} for portion in args: if hasattr(portion, 'items'): #It's a map. Merge it. for k,v in portion.items(): built[k] = v elif isList(portion): #It's a list. Map each item to the default. for k in portion: built[k] = default else: #It's a scalar. Map it to the default. built[portion] = default return built # Now, the parser classes. class BeautifulStoneSoup(Tag, SGMLParser): """This class contains the basic parser and search code. It defines a parser that knows nothing about tag behavior except for the following: You can't close a tag without closing all the tags it encloses. That is, "<foo><bar></foo>" actually means "<foo><bar></bar></foo>". [Another possible explanation is "<foo><bar /></foo>", but since this class defines no SELF_CLOSING_TAGS, it will never use that explanation.] This class is useful for parsing XML or made-up markup languages, or when BeautifulSoup makes an assumption counter to what you were expecting.""" XML_ENTITY_LIST = {} for i in Tag.XML_SPECIAL_CHARS_TO_ENTITIES.values(): XML_ENTITY_LIST[i] = True SELF_CLOSING_TAGS = {} NESTABLE_TAGS = {} RESET_NESTING_TAGS = {} QUOTE_TAGS = {} MARKUP_MASSAGE = [(re.compile('(<[^<>]*)/>'), lambda x: x.group(1) + ' />'), (re.compile('<!\s+([^<>]*)>'), lambda x: '<!' + x.group(1) + '>') ] ROOT_TAG_NAME = u'[document]' HTML_ENTITIES = "html" XML_ENTITIES = "xml" def __init__(self, markup="", parseOnlyThese=None, fromEncoding=None, markupMassage=True, smartQuotesTo=XML_ENTITIES, convertEntities=None, selfClosingTags=None): """The Soup object is initialized as the 'root tag', and the provided markup (which can be a string or a file-like object) is fed into the underlying parser. sgmllib will process most bad HTML, and the BeautifulSoup class has some tricks for dealing with some HTML that kills sgmllib, but Beautiful Soup can nonetheless choke or lose data if your data uses self-closing tags or declarations incorrectly. By default, Beautiful Soup uses regexes to sanitize input, avoiding the vast majority of these problems. If the problems don't apply to you, pass in False for markupMassage, and you'll get better performance. The default parser massage techniques fix the two most common instances of invalid HTML that choke sgmllib: <br/> (No space between name of closing tag and tag close) <! --Comment--> (Extraneous whitespace in declaration) You can pass in a custom list of (RE object, replace method) tuples to get Beautiful Soup to scrub your input the way you want.""" self.parseOnlyThese = parseOnlyThese self.fromEncoding = fromEncoding self.smartQuotesTo = smartQuotesTo self.convertEntities = convertEntities if self.convertEntities: # It doesn't make sense to convert encoded characters to # entities even while you're converting entities to Unicode. # Just convert it all to Unicode. self.smartQuotesTo = None self.instanceSelfClosingTags = buildTagMap(None, selfClosingTags) SGMLParser.__init__(self) if hasattr(markup, 'read'): # It's a file-type object. markup = markup.read() self.markup = markup self.markupMassage = markupMassage try: self._feed() except StopParsing: pass self.markup = None # The markup can now be GCed def _feed(self, inDocumentEncoding=None): # Convert the document to Unicode. markup = self.markup if isinstance(markup, unicode): if not hasattr(self, 'originalEncoding'): self.originalEncoding = None else: dammit = UnicodeDammit\ (markup, [self.fromEncoding, inDocumentEncoding], smartQuotesTo=self.smartQuotesTo) markup = dammit.unicode self.originalEncoding = dammit.originalEncoding if markup: if self.markupMassage: if not isList(self.markupMassage): self.markupMassage = self.MARKUP_MASSAGE for fix, m in self.markupMassage: markup = fix.sub(m, markup) self.reset() SGMLParser.feed(self, markup) # Close out any unfinished strings and close all the open tags. self.endData() while self.currentTag.name != self.ROOT_TAG_NAME: self.popTag() def __getattr__(self, methodName): """This method routes method call requests to either the SGMLParser superclass or the Tag superclass, depending on the method name.""" #print "__getattr__ called on %s.%s" % (self.__class__, methodName) if methodName.find('start_') == 0 or methodName.find('end_') == 0 \ or methodName.find('do_') == 0: return SGMLParser.__getattr__(self, methodName) elif methodName.find('__') != 0: return Tag.__getattr__(self, methodName) else: raise AttributeError def isSelfClosingTag(self, name): """Returns true iff the given string is the name of a self-closing tag according to this parser.""" return self.SELF_CLOSING_TAGS.has_key(name) \ or self.instanceSelfClosingTags.has_key(name) def reset(self): Tag.__init__(self, self, self.ROOT_TAG_NAME) self.hidden = 1 SGMLParser.reset(self) self.currentData = [] self.currentTag = None self.tagStack = [] self.quoteStack = [] self.pushTag(self) def popTag(self): tag = self.tagStack.pop() # Tags with just one string-owning child get the child as a # 'string' property, so that soup.tag.string is shorthand for # soup.tag.contents[0] if len(self.currentTag.contents) == 1 and \ isinstance(self.currentTag.contents[0], NavigableString): self.currentTag.string = self.currentTag.contents[0] #print "Pop", tag.name if self.tagStack: self.currentTag = self.tagStack[-1] return self.currentTag def pushTag(self, tag): #print "Push", tag.name if self.currentTag: self.currentTag.append(tag) self.tagStack.append(tag) self.currentTag = self.tagStack[-1] def endData(self, containerClass=NavigableString): if self.currentData: currentData = ''.join(self.currentData) if not currentData.strip(): if '\n' in currentData: currentData = '\n' else: currentData = ' ' self.currentData = [] if self.parseOnlyThese and len(self.tagStack) <= 1 and \ (not self.parseOnlyThese.text or \ not self.parseOnlyThese.search(currentData)): return o = containerClass(currentData) o.setup(self.currentTag, self.previous) if self.previous: self.previous.next = o self.previous = o self.currentTag.contents.append(o) def _popToTag(self, name, inclusivePop=True): """Pops the tag stack up to and including the most recent instance of the given tag. If inclusivePop is false, pops the tag stack up to but *not* including the most recent instqance of the given tag.""" #print "Popping to %s" % name if name == self.ROOT_TAG_NAME: return numPops = 0 mostRecentTag = None for i in range(len(self.tagStack)-1, 0, -1): if name == self.tagStack[i].name: numPops = len(self.tagStack)-i break if not inclusivePop: numPops = numPops - 1 for i in range(0, numPops): mostRecentTag = self.popTag() return mostRecentTag def _smartPop(self, name): """We need to pop up to the previous tag of this type, unless one of this tag's nesting reset triggers comes between this tag and the previous tag of this type, OR unless this tag is a generic nesting trigger and another generic nesting trigger comes between this tag and the previous tag of this type. Examples: <p>Foo<b>Bar<p> should pop to 'p', not 'b'. <p>Foo<table>Bar<p> should pop to 'table', not 'p'. <p>Foo<table><tr>Bar<p> should pop to 'tr', not 'p'. <p>Foo<b>Bar<p> should pop to 'p', not 'b'. <li><ul><li> *<li>* should pop to 'ul', not the first 'li'. <tr><table><tr> *<tr>* should pop to 'table', not the first 'tr' <td><tr><td> *<td>* should pop to 'tr', not the first 'td' """ nestingResetTriggers = self.NESTABLE_TAGS.get(name) isNestable = nestingResetTriggers != None isResetNesting = self.RESET_NESTING_TAGS.has_key(name) popTo = None inclusive = True for i in range(len(self.tagStack)-1, 0, -1): p = self.tagStack[i] if (not p or p.name == name) and not isNestable: #Non-nestable tags get popped to the top or to their #last occurance. popTo = name break if (nestingResetTriggers != None and p.name in nestingResetTriggers) \ or (nestingResetTriggers == None and isResetNesting and self.RESET_NESTING_TAGS.has_key(p.name)): #If we encounter one of the nesting reset triggers #peculiar to this tag, or we encounter another tag #that causes nesting to reset, pop up to but not #including that tag. popTo = p.name inclusive = False break p = p.parent if popTo: self._popToTag(popTo, inclusive) def unknown_starttag(self, name, attrs, selfClosing=0): #print "Start tag %s: %s" % (name, attrs) if self.quoteStack: #This is not a real tag. #print "<%s> is not real!" % name attrs = ''.join(map(lambda(x, y): ' %s="%s"' % (x, y), attrs)) self.handle_data('<%s%s>' % (name, attrs)) return self.endData() if not self.isSelfClosingTag(name) and not selfClosing: self._smartPop(name) if self.parseOnlyThese and len(self.tagStack) <= 1 \ and (self.parseOnlyThese.text or not self.parseOnlyThese.searchTag(name, attrs)): return tag = Tag(self, name, attrs, self.currentTag, self.previous) if self.previous: self.previous.next = tag self.previous = tag self.pushTag(tag) if selfClosing or self.isSelfClosingTag(name): self.popTag() if name in self.QUOTE_TAGS: #print "Beginning quote (%s)" % name self.quoteStack.append(name) self.literal = 1 return tag def unknown_endtag(self, name): #print "End tag %s" % name if self.quoteStack and self.quoteStack[-1] != name: #This is not a real end tag. #print "</%s> is not real!" % name self.handle_data('</%s>' % name) return self.endData() self._popToTag(name) if self.quoteStack and self.quoteStack[-1] == name: self.quoteStack.pop() self.literal = (len(self.quoteStack) > 0) def handle_data(self, data): self.currentData.append(data) def _toStringSubclass(self, text, subclass): """Adds a certain piece of text to the tree as a NavigableString subclass.""" self.endData() self.handle_data(text) self.endData(subclass) def handle_pi(self, text): """Handle a processing instruction as a ProcessingInstruction object, possibly one with a %SOUP-ENCODING% slot into which an encoding will be plugged later.""" if text[:3] == "xml": text = "xml version='1.0' encoding='%SOUP-ENCODING%'" self._toStringSubclass(text, ProcessingInstruction) def handle_comment(self, text): "Handle comments as Comment objects." self._toStringSubclass(text, Comment) def handle_charref(self, ref): "Handle character references as data." if self.convertEntities in [self.HTML_ENTITIES, self.XML_ENTITIES]: data = unichr(int(ref)) else: data = '&#%s;' % ref self.handle_data(data) def handle_entityref(self, ref): """Handle entity references as data, possibly converting known HTML entity references to the corresponding Unicode characters.""" data = None if self.convertEntities == self.HTML_ENTITIES or \ (self.convertEntities == self.XML_ENTITIES and \ self.XML_ENTITY_LIST.get(ref)): try: data = unichr(name2codepoint[ref]) except KeyError: pass if not data: data = '&%s;' % ref self.handle_data(data) def handle_decl(self, data): "Handle DOCTYPEs and the like as Declaration objects." self._toStringSubclass(data, Declaration) def parse_declaration(self, i): """Treat a bogus SGML declaration as raw data. Treat a CDATA declaration as a CData object.""" j = None if self.rawdata[i:i+9] == '<![CDATA[': k = self.rawdata.find(']]>', i) if k == -1: k = len(self.rawdata) data = self.rawdata[i+9:k] j = k+3 self._toStringSubclass(data, CData) else: try: j = SGMLParser.parse_declaration(self, i) except SGMLParseError: toHandle = self.rawdata[i:] self.handle_data(toHandle) j = i + len(toHandle) return j class BeautifulSoup(BeautifulStoneSoup): """This parser knows the following facts about HTML: * Some tags have no closing tag and should be interpreted as being closed as soon as they are encountered. * The text inside some tags (ie. 'script') may contain tags which are not really part of the document and which should be parsed as text, not tags. If you want to parse the text as tags, you can always fetch it and parse it explicitly. * Tag nesting rules: Most tags can't be nested at all. For instance, the occurance of a <p> tag should implicitly close the previous <p> tag. <p>Para1<p>Para2 should be transformed into: <p>Para1</p><p>Para2 Some tags can be nested arbitrarily. For instance, the occurance of a <blockquote> tag should _not_ implicitly close the previous <blockquote> tag. Alice said: <blockquote>Bob said: <blockquote>Blah should NOT be transformed into: Alice said: <blockquote>Bob said: </blockquote><blockquote>Blah Some tags can be nested, but the nesting is reset by the interposition of other tags. For instance, a <tr> tag should implicitly close the previous <tr> tag within the same <table>, but not close a <tr> tag in another table. <table><tr>Blah<tr>Blah should be transformed into: <table><tr>Blah</tr><tr>Blah but, <tr>Blah<table><tr>Blah should NOT be transformed into <tr>Blah<table></tr><tr>Blah Differing assumptions about tag nesting rules are a major source of problems with the BeautifulSoup class. If BeautifulSoup is not treating as nestable a tag your page author treats as nestable, try ICantBelieveItsBeautifulSoup, MinimalSoup, or BeautifulStoneSoup before writing your own subclass.""" def __init__(self, *args, **kwargs): if not kwargs.has_key('smartQuotesTo'): kwargs['smartQuotesTo'] = self.HTML_ENTITIES BeautifulStoneSoup.__init__(self, *args, **kwargs) SELF_CLOSING_TAGS = buildTagMap(None, ['br' , 'hr', 'input', 'img', 'meta', 'spacer', 'link', 'frame', 'base']) QUOTE_TAGS = {'script': None} #According to the HTML standard, each of these inline tags can #contain another tag of the same type. Furthermore, it's common #to actually use these tags this way. NESTABLE_INLINE_TAGS = ['span', 'font', 'q', 'object', 'bdo', 'sub', 'sup', 'center'] #According to the HTML standard, these block tags can contain #another tag of the same type. Furthermore, it's common #to actually use these tags this way. NESTABLE_BLOCK_TAGS = ['blockquote', 'div', 'fieldset', 'ins', 'del'] #Lists can contain other lists, but there are restrictions. NESTABLE_LIST_TAGS = { 'ol' : [], 'ul' : [], 'li' : ['ul', 'ol'], 'dl' : [], 'dd' : ['dl'], 'dt' : ['dl'] } #Tables can contain other tables, but there are restrictions. NESTABLE_TABLE_TAGS = {'table' : [], 'tr' : ['table', 'tbody', 'tfoot', 'thead'], 'td' : ['tr'], 'th' : ['tr'], 'thead' : ['table'], 'tbody' : ['table'], 'tfoot' : ['table'], } NON_NESTABLE_BLOCK_TAGS = ['address', 'form', 'p', 'pre'] #If one of these tags is encountered, all tags up to the next tag of #this type are popped. RESET_NESTING_TAGS = buildTagMap(None, NESTABLE_BLOCK_TAGS, 'noscript', NON_NESTABLE_BLOCK_TAGS, NESTABLE_LIST_TAGS, NESTABLE_TABLE_TAGS) NESTABLE_TAGS = buildTagMap([], NESTABLE_INLINE_TAGS, NESTABLE_BLOCK_TAGS, NESTABLE_LIST_TAGS, NESTABLE_TABLE_TAGS) # Used to detect the charset in a META tag; see start_meta CHARSET_RE = re.compile("((^|;)\s*charset=)([^;]*)") def start_meta(self, attrs): """Beautiful Soup can detect a charset included in a META tag, try to convert the document to that charset, and re-parse the document from the beginning.""" httpEquiv = None contentType = None contentTypeIndex = None tagNeedsEncodingSubstitution = False for i in range(0, len(attrs)): key, value = attrs[i] key = key.lower() if key == 'http-equiv': httpEquiv = value elif key == 'content': contentType = value contentTypeIndex = i if httpEquiv and contentType: # It's an interesting meta tag. match = self.CHARSET_RE.search(contentType) if match: if getattr(self, 'declaredHTMLEncoding') or \ (self.originalEncoding == self.fromEncoding): # This is our second pass through the document, or # else an encoding was specified explicitly and it # worked. Rewrite the meta tag. newAttr = self.CHARSET_RE.sub\ (lambda(match):match.group(1) + "%SOUP-ENCODING%", value) attrs[contentTypeIndex] = (attrs[contentTypeIndex][0], newAttr) tagNeedsEncodingSubstitution = True else: # This is our first pass through the document. # Go through it again with the new information. newCharset = match.group(3) if newCharset and newCharset != self.originalEncoding: self.declaredHTMLEncoding = newCharset self._feed(self.declaredHTMLEncoding) raise StopParsing tag = self.unknown_starttag("meta", attrs) if tag and tagNeedsEncodingSubstitution: tag.containsSubstitutions = True class StopParsing(Exception): pass class ICantBelieveItsBeautifulSoup(BeautifulSoup): """The BeautifulSoup class is oriented towards skipping over common HTML errors like unclosed tags. However, sometimes it makes errors of its own. For instance, consider this fragment: <b>Foo<b>Bar</b></b> This is perfectly valid (if bizarre) HTML. However, the BeautifulSoup class will implicitly close the first b tag when it encounters the second 'b'. It will think the author wrote "<b>Foo<b>Bar", and didn't close the first 'b' tag, because there's no real-world reason to bold something that's already bold. When it encounters '</b></b>' it will close two more 'b' tags, for a grand total of three tags closed instead of two. This can throw off the rest of your document structure. The same is true of a number of other tags, listed below. It's much more common for someone to forget to close a 'b' tag than to actually use nested 'b' tags, and the BeautifulSoup class handles the common case. This class handles the not-co-common case: where you can't believe someone wrote what they did, but it's valid HTML and BeautifulSoup screwed up by assuming it wouldn't be.""" I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS = \ ['em', 'big', 'i', 'small', 'tt', 'abbr', 'acronym', 'strong', 'cite', 'code', 'dfn', 'kbd', 'samp', 'strong', 'var', 'b', 'big'] I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS = ['noscript'] NESTABLE_TAGS = buildTagMap([], BeautifulSoup.NESTABLE_TAGS, I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS, I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS) class MinimalSoup(BeautifulSoup): """The MinimalSoup class is for parsing HTML that contains pathologically bad markup. It makes no assumptions about tag nesting, but it does know which tags are self-closing, that <script> tags contain Javascript and should not be parsed, that META tags may contain encoding information, and so on. This also makes it better for subclassing than BeautifulStoneSoup or BeautifulSoup.""" RESET_NESTING_TAGS = buildTagMap('noscript') NESTABLE_TAGS = {} class BeautifulSOAP(BeautifulStoneSoup): """This class will push a tag with only a single string child into the tag's parent as an attribute. The attribute's name is the tag name, and the value is the string child. An example should give the flavor of the change: <foo><bar>baz</bar></foo> => <foo bar="baz"><bar>baz</bar></foo> You can then access fooTag['bar'] instead of fooTag.barTag.string. This is, of course, useful for scraping structures that tend to use subelements instead of attributes, such as SOAP messages. Note that it modifies its input, so don't print the modified version out. I'm not sure how many people really want to use this class; let me know if you do. Mainly I like the name.""" def popTag(self): if len(self.tagStack) > 1: tag = self.tagStack[-1] parent = self.tagStack[-2] parent._getAttrMap() if (isinstance(tag, Tag) and len(tag.contents) == 1 and isinstance(tag.contents[0], NavigableString) and not parent.attrMap.has_key(tag.name)): parent[tag.name] = tag.contents[0] BeautifulStoneSoup.popTag(self) #Enterprise class names! It has come to our attention that some people #think the names of the Beautiful Soup parser classes are too silly #and "unprofessional" for use in enterprise screen-scraping. We feel #your pain! For such-minded folk, the Beautiful Soup Consortium And #All-Night Kosher Bakery recommends renaming this file to #"RobustParser.py" (or, in cases of extreme enterprisness, #"RobustParserBeanInterface.class") and using the following #enterprise-friendly class aliases: class RobustXMLParser(BeautifulStoneSoup): pass class RobustHTMLParser(BeautifulSoup): pass class RobustWackAssHTMLParser(ICantBelieveItsBeautifulSoup): pass class RobustInsanelyWackAssHTMLParser(MinimalSoup): pass class SimplifyingSOAPParser(BeautifulSOAP): pass ###################################################### # # Bonus library: Unicode, Dammit # # This class forces XML data into a standard format (usually to UTF-8 # or Unicode). It is heavily based on code from Mark Pilgrim's # Universal Feed Parser. It does not rewrite the XML or HTML to # reflect a new encoding: that happens in BeautifulStoneSoup.handle_pi # (XML) and BeautifulSoup.start_meta (HTML). # Autodetects character encodings. # Download from http://chardet.feedparser.org/ try: import chardet # import chardet.constants # chardet.constants._debug = 1 except: chardet = None chardet = None # cjkcodecs and iconv_codec make Python know about more character encodings. # Both are available from http://cjkpython.i18n.org/ # They're built in if you use Python 2.4. try: import cjkcodecs.aliases except: pass try: import iconv_codec except: pass class UnicodeDammit: """A class for detecting the encoding of a *ML document and converting it to a Unicode string. If the source encoding is windows-1252, can replace MS smart quotes with their HTML or XML equivalents.""" # This dictionary maps commonly seen values for "charset" in HTML # meta tags to the corresponding Python codec names. It only covers # values that aren't in Python's aliases and can't be determined # by the heuristics in find_codec. CHARSET_ALIASES = { "macintosh" : "mac-roman", "x-sjis" : "shift-jis" } def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml'): self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) return u = None for proposedEncoding in overrideEncodings: u = self._convertFrom(proposedEncoding) if u: break if not u: for proposedEncoding in (documentEncoding, sniffedEncoding): u = self._convertFrom(proposedEncoding) if u: break # If no luck and we have auto-detection library, try that: if not u and chardet and not isinstance(self.markup, unicode): u = self._convertFrom(chardet.detect(self.markup)['encoding']) # As a last resort, try utf-8 and windows-1252: if not u: for proposed_encoding in ("utf-8", "windows-1252"): u = self._convertFrom(proposed_encoding) if u: break self.unicode = u if not u: self.originalEncoding = None def _subMSChar(self, orig): """Changes a MS smart quote character to an XML or HTML entity.""" sub = self.MS_CHARS.get(orig) if type(sub) == types.TupleType: if self.smartQuotesTo == 'xml': sub = '&#x%s;' % sub[1] else: sub = '&%s;' % sub[0] return sub def _convertFrom(self, proposed): proposed = self.find_codec(proposed) if not proposed or proposed in self.triedEncodings: return None self.triedEncodings.append(proposed) markup = self.markup # Convert smart quotes to HTML if coming from an encoding # that might have them. if self.smartQuotesTo and proposed.lower() in("windows-1252", "iso-8859-1", "iso-8859-2"): markup = re.compile("([\x80-\x9f])").sub \ (lambda(x): self._subMSChar(x.group(1)), markup) try: # print "Trying to convert document to %s" % proposed u = self._toUnicode(markup, proposed) self.markup = u self.originalEncoding = proposed except Exception, e: # print "That didn't work!" # print e return None #print "Correct encoding: %s" % proposed return self.markup def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' # strip Byte Order Mark (if present) if (len(data) >= 4) and (data[:2] == '\xfe\xff') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16be' data = data[2:] elif (len(data) >= 4) and (data[:2] == '\xff\xfe') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16le' data = data[2:] elif data[:3] == '\xef\xbb\xbf': encoding = 'utf-8' data = data[3:] elif data[:4] == '\x00\x00\xfe\xff': encoding = 'utf-32be' data = data[4:] elif data[:4] == '\xff\xfe\x00\x00': encoding = 'utf-32le' data = data[4:] newdata = unicode(data, encoding) return newdata def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) elif xml_data[:4] == '\x00\x3c\x00\x3f': # UTF-16BE sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data, 'utf-16be').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == '\xfe\xff') \ and (xml_data[2:4] != '\x00\x00'): # UTF-16BE with BOM sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data[2:], 'utf-16be').encode('utf-8') elif xml_data[:4] == '\x3c\x00\x3f\x00': # UTF-16LE sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data, 'utf-16le').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == '\xff\xfe') and \ (xml_data[2:4] != '\x00\x00'): # UTF-16LE with BOM sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data[2:], 'utf-16le').encode('utf-8') elif xml_data[:4] == '\x00\x00\x00\x3c': # UTF-32BE sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data, 'utf-32be').encode('utf-8') elif xml_data[:4] == '\x3c\x00\x00\x00': # UTF-32LE sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data, 'utf-32le').encode('utf-8') elif xml_data[:4] == '\x00\x00\xfe\xff': # UTF-32BE with BOM sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data[4:], 'utf-32be').encode('utf-8') elif xml_data[:4] == '\xff\xfe\x00\x00': # UTF-32LE with BOM sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data[4:], 'utf-32le').encode('utf-8') elif xml_data[:3] == '\xef\xbb\xbf': # UTF-8 with BOM sniffed_xml_encoding = 'utf-8' xml_data = unicode(xml_data[3:], 'utf-8').encode('utf-8') else: sniffed_xml_encoding = 'ascii' pass xml_encoding_match = re.compile \ ('^<\?.*encoding=[\'"](.*?)[\'"].*\?>')\ .match(xml_data) except: xml_encoding_match = None if xml_encoding_match: xml_encoding = xml_encoding_match.groups()[0].lower() if sniffed_xml_encoding and \ (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode', 'iso-10646-ucs-4', 'ucs-4', 'csucs4', 'utf-16', 'utf-32', 'utf_16', 'utf_32', 'utf16', 'u16')): xml_encoding = sniffed_xml_encoding return xml_data, xml_encoding, sniffed_xml_encoding def find_codec(self, charset): return self._codec(self.CHARSET_ALIASES.get(charset, charset)) \ or (charset and self._codec(charset.replace("-", ""))) \ or (charset and self._codec(charset.replace("-", "_"))) \ or charset def _codec(self, charset): if not charset: return charset codec = None try: codecs.lookup(charset) codec = charset except LookupError: pass return codec EBCDIC_TO_ASCII_MAP = None def _ebcdic_to_ascii(self, s): c = self.__class__ if not c.EBCDIC_TO_ASCII_MAP: emap = (0,1,2,3,156,9,134,127,151,141,142,11,12,13,14,15, 16,17,18,19,157,133,8,135,24,25,146,143,28,29,30,31, 128,129,130,131,132,10,23,27,136,137,138,139,140,5,6,7, 144,145,22,147,148,149,150,4,152,153,154,155,20,21,158,26, 32,160,161,162,163,164,165,166,167,168,91,46,60,40,43,33, 38,169,170,171,172,173,174,175,176,177,93,36,42,41,59,94, 45,47,178,179,180,181,182,183,184,185,124,44,37,95,62,63, 186,187,188,189,190,191,192,193,194,96,58,35,64,39,61,34, 195,97,98,99,100,101,102,103,104,105,196,197,198,199,200, 201,202,106,107,108,109,110,111,112,113,114,203,204,205, 206,207,208,209,126,115,116,117,118,119,120,121,122,210, 211,212,213,214,215,216,217,218,219,220,221,222,223,224, 225,226,227,228,229,230,231,123,65,66,67,68,69,70,71,72, 73,232,233,234,235,236,237,125,74,75,76,77,78,79,80,81, 82,238,239,240,241,242,243,92,159,83,84,85,86,87,88,89, 90,244,245,246,247,248,249,48,49,50,51,52,53,54,55,56,57, 250,251,252,253,254,255) import string c.EBCDIC_TO_ASCII_MAP = string.maketrans( \ ''.join(map(chr, range(256))), ''.join(map(chr, emap))) return s.translate(c.EBCDIC_TO_ASCII_MAP) MS_CHARS = { '\x80' : ('euro', '20AC'), '\x81' : ' ', '\x82' : ('sbquo', '201A'), '\x83' : ('fnof', '192'), '\x84' : ('bdquo', '201E'), '\x85' : ('hellip', '2026'), '\x86' : ('dagger', '2020'), '\x87' : ('Dagger', '2021'), '\x88' : ('circ', '2C6'), '\x89' : ('permil', '2030'), '\x8A' : ('Scaron', '160'), '\x8B' : ('lsaquo', '2039'), '\x8C' : ('OElig', '152'), '\x8D' : '?', '\x8E' : ('#x17D', '17D'), '\x8F' : '?', '\x90' : '?', '\x91' : ('lsquo', '2018'), '\x92' : ('rsquo', '2019'), '\x93' : ('ldquo', '201C'), '\x94' : ('rdquo', '201D'), '\x95' : ('bull', '2022'), '\x96' : ('ndash', '2013'), '\x97' : ('mdash', '2014'), '\x98' : ('tilde', '2DC'), '\x99' : ('trade', '2122'), '\x9a' : ('scaron', '161'), '\x9b' : ('rsaquo', '203A'), '\x9c' : ('oelig', '153'), '\x9d' : '?', '\x9e' : ('#x17E', '17E'), '\x9f' : ('Yuml', ''),} ####################################################################### #By default, act as an HTML pretty-printer. if __name__ == '__main__': import sys soup = BeautifulSoup(sys.stdin.read()) print soup.prettify()
gpl-3.0
[ 624, 30117, 28028, 199, 37, 20528, 723, 436, 377, 12732, 199, 2, 1918, 17804, 13, 7181, 345, 529, 1159, 481, 8528, 2, 199, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 15619, 15, 30117, 12341, 15, 199, 199, 30117, 28028, 19953, 282, 334, 19614, 3866, 9, 4692, 503, 4163, 2213, 1901, 282, 199, 2350, 6025, 14, 2779, 6571, 3102, 436, 2018, 530, 284, 328, 22491, 626, 1852, 199, 390, 8837, 370, 20850, 12, 2754, 12, 436, 2811, 314, 3123, 14, 199, 199, 33, 5521, 13, 6194, 4692, 15, 4943, 2213, 14801, 282, 5521, 13, 6194, 666, 199, 6976, 14, 1626, 22907, 13, 6194, 4692, 15, 4943, 2213, 14801, 282, 5226, 590, 199, 778, 13, 6194, 666, 5523, 14, 982, 2195, 2213, 365, 1454, 17738, 199, 20501, 13, 6194, 12, 1265, 883, 675, 642, 3555, 370, 2342, 436, 2112, 314, 199, 20501, 13, 6194, 1777, 402, 652, 14, 710, 17132, 1021, 9948, 199, 30117, 28028, 5419, 543, 2018, 499, 14, 18, 436, 1536, 14, 2779, 965, 949, 5957, 199, 5714, 12, 1325, 1265, 7171, 1172, 1655, 3182, 737, 13806, 666, 370, 9094, 13, 24, 199, 692, 1265, 2597, 3907, 3520, 7795, 6117, 26, 199, 199, 10, 28470, 12, 367, 2599, 13, 13552, 316, 4528, 14134, 523, 1455, 921, 1560, 9886, 14, 3871, 2087, 14, 1308, 15, 199, 10, 286, 17421, 8933, 436, 284, 5598, 63, 9276, 12, 1314, 1050, 1655, 14134, 370, 314, 7869, 3748, 523, 701, 10952, 2018, 14, 523, 1455, 921, 67, 17421, 1548, 14, 73, 1085, 78, 14, 1308, 15, 199, 199, 30117, 28028, 7890, 3992, 367, 2877, 2446, 6057, 32647, 26, 16872, 627, 14562, 933, 368, 12341, 12, 367, 6057, 4692, 12, 18868, 1698, 12, 503, 2195, 2881, 13, 6100, 2043, 2637, 626, 4928, 402, 10734, 2839, 4692, 14, 421, 627, 17132, 12, 367, 6057, 1255, 13, 1618, 13, 1589, 13, 77, 778, 4163, 1233, 12, 506, 652, 1686, 2043, 503, 3866, 14, 961, 1021, 965, 3330, 7042, 13, 2930, 946, 300, 631, 2932, 367, 2043, 12408, 282, 27962, 2198, 3123, 315, 314, 8870, 402, 2863, 4163, 2552, 14, 199, 199, 30117, 28028, 2597, 7890, 282, 1021, 334, 7087, 36, 28980, 9, 367, 28537, 5302, 316, 199, 1589, 2644, 402, 376, 4163, 503, 4692, 2213, 12, 436, 13806, 652, 370, 199, 7087, 14, 603, 2133, 402, 642, 1233, 365, 9394, 687, 7173, 19641, 1159, 29347, 16261, 10191, 14, 199, 199, 1858, 1655, 2419, 1265, 14433, 13632, 370, 5715, 3595, 14562, 28028, 12, 1937, 314, 199, 9970, 26, 199, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 15619, 15, 30117, 12341, 15, 9970, 14, 1360, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 16952, 199, 199, 363, 2502, 363, 275, 298, 2553, 265, 1005, 30846, 5596, 265, 334, 274, 265, 1005, 82, 32, 8359, 1879, 14, 1308, 2924, 199, 363, 1023, 363, 275, 298, 19, 14, 16, 14, 20, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8353, 13, 9488, 7005, 265, 1005, 30846, 5596, 265, 2, 199, 363, 1682, 363, 275, 298, 5067, 38, 2, 199, 199, 504, 12578, 25598, 492, 18868, 1698, 2842, 12, 18868, 1698, 9123, 199, 646, 6010, 199, 646, 2943, 199, 646, 295, 199, 646, 12578, 25598, 199, 893, 26, 523, 687, 30010, 552, 1701, 8710, 492, 536, 18, 19300, 199, 2590, 3545, 26, 523, 536, 18, 19300, 275, 1052, 199, 199, 3, 2765, 11176, 7704, 14562, 28028, 7688, 370, 2198, 4692, 543, 10747, 199, 1226, 25598, 14, 1450, 1623, 275, 295, 14, 2014, 11894, 65, 13, 6353, 13, 58, 15898, 3754, 26, 65, 13, 6353, 13, 58, 16, 13, 25, 3672, 358, 199, 199, 3472, 63, 8414, 63, 16314, 275, 298, 1624, 13, 24, 2, 199, 199, 3, 7758, 12, 314, 3992, 626, 2954, 9189, 4008, 14, 199, 199, 533, 10331, 2162, 26, 272, 408, 6906, 314, 19191, 279, 2556, 367, 2005, 1777, 402, 314, 2034, 272, 334, 22051, 282, 1947, 503, 282, 14854, 402, 1318, 9471, 339, 347, 3272, 8, 277, 12, 1676, 29, 403, 12, 4136, 29, 403, 304, 267, 408, 9899, 1536, 314, 2536, 16109, 3382, 642, 1819, 436, 267, 1163, 4008, 1041, 18418, 291, 14, 1708, 275, 1676, 267, 291, 14, 6352, 275, 4136, 267, 291, 14, 2184, 275, 488, 267, 291, 14, 6352, 16016, 275, 488, 267, 291, 14, 30336, 275, 488, 267, 340, 291, 14, 1708, 436, 291, 14, 1708, 14, 4407, 26, 288, 291, 14, 6352, 16016, 275, 291, 14, 1708, 14, 4407, 1988, 17, 61, 288, 291, 14, 6352, 16016, 14, 30336, 275, 291, 339, 347, 3350, 3007, 8, 277, 12, 3350, 3007, 304, 18418, 2269, 6652, 275, 291, 14, 1708, 267, 3002, 2681, 275, 291, 14, 1708, 14, 4407, 14, 1080, 8, 277, 9, 267, 340, 2688, 8, 1814, 3007, 12, 283, 1708, 358, 436, 3350, 3007, 14, 1708, 508, 291, 14, 1708, 26, 288, 327, 2136, 3984, 15810, 642, 1819, 543, 1373, 402, 2399, 31871, 14, 288, 1478, 275, 291, 14, 1708, 14, 4407, 14, 1080, 8, 1814, 3007, 9, 288, 340, 1478, 436, 1478, 665, 3002, 2681, 26, 355, 327, 28876, 6878, 12, 652, 12477, 2544, 642, 1819, 14, 10314, 355, 327, 4910, 626, 1380, 781, 5536, 652, 12, 314, 1478, 402, 642, 355, 327, 1819, 911, 1570, 14, 355, 3002, 2681, 275, 3002, 2681, 446, 413, 267, 291, 14, 5005, 342, 18418, 2269, 6652, 14, 3176, 8, 1662, 2681, 12, 3350, 3007, 9, 5493, 347, 5536, 8, 277, 304, 267, 408, 872, 9853, 9462, 8012, 1190, 642, 1819, 734, 402, 314, 3123, 1041, 18418, 340, 291, 14, 1708, 26, 288, 862, 26, 355, 291, 14, 1708, 14, 4407, 14, 2168, 8, 277, 9, 288, 871, 1722, 26, 355, 986, 398, 327, 6591, 314, 2877, 4008, 626, 3955, 506, 2163, 370, 1924, 1163, 340, 267, 327, 3749, 1819, 334, 460, 1263, 4978, 9, 10530, 78, 1133, 2757, 4565, 14, 15175, 267, 327, 1589, 2877, 14, 18418, 2061, 3493, 275, 291, 423, 2019, 25122, 3493, 342, 267, 2163, 2162, 275, 2061, 3493, 14, 2184, 398, 340, 291, 14, 6352, 26, 288, 291, 14, 6352, 14, 2184, 275, 2163, 2162, 267, 340, 2163, 2162, 26, 288, 2163, 2162, 14, 6352, 275, 291, 14, 6352, 267, 291, 14, 6352, 275, 488, 267 ]
[ 30117, 28028, 199, 37, 20528, 723, 436, 377, 12732, 199, 2, 1918, 17804, 13, 7181, 345, 529, 1159, 481, 8528, 2, 199, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 15619, 15, 30117, 12341, 15, 199, 199, 30117, 28028, 19953, 282, 334, 19614, 3866, 9, 4692, 503, 4163, 2213, 1901, 282, 199, 2350, 6025, 14, 2779, 6571, 3102, 436, 2018, 530, 284, 328, 22491, 626, 1852, 199, 390, 8837, 370, 20850, 12, 2754, 12, 436, 2811, 314, 3123, 14, 199, 199, 33, 5521, 13, 6194, 4692, 15, 4943, 2213, 14801, 282, 5521, 13, 6194, 666, 199, 6976, 14, 1626, 22907, 13, 6194, 4692, 15, 4943, 2213, 14801, 282, 5226, 590, 199, 778, 13, 6194, 666, 5523, 14, 982, 2195, 2213, 365, 1454, 17738, 199, 20501, 13, 6194, 12, 1265, 883, 675, 642, 3555, 370, 2342, 436, 2112, 314, 199, 20501, 13, 6194, 1777, 402, 652, 14, 710, 17132, 1021, 9948, 199, 30117, 28028, 5419, 543, 2018, 499, 14, 18, 436, 1536, 14, 2779, 965, 949, 5957, 199, 5714, 12, 1325, 1265, 7171, 1172, 1655, 3182, 737, 13806, 666, 370, 9094, 13, 24, 199, 692, 1265, 2597, 3907, 3520, 7795, 6117, 26, 199, 199, 10, 28470, 12, 367, 2599, 13, 13552, 316, 4528, 14134, 523, 1455, 921, 1560, 9886, 14, 3871, 2087, 14, 1308, 15, 199, 10, 286, 17421, 8933, 436, 284, 5598, 63, 9276, 12, 1314, 1050, 1655, 14134, 370, 314, 7869, 3748, 523, 701, 10952, 2018, 14, 523, 1455, 921, 67, 17421, 1548, 14, 73, 1085, 78, 14, 1308, 15, 199, 199, 30117, 28028, 7890, 3992, 367, 2877, 2446, 6057, 32647, 26, 16872, 627, 14562, 933, 368, 12341, 12, 367, 6057, 4692, 12, 18868, 1698, 12, 503, 2195, 2881, 13, 6100, 2043, 2637, 626, 4928, 402, 10734, 2839, 4692, 14, 421, 627, 17132, 12, 367, 6057, 1255, 13, 1618, 13, 1589, 13, 77, 778, 4163, 1233, 12, 506, 652, 1686, 2043, 503, 3866, 14, 961, 1021, 965, 3330, 7042, 13, 2930, 946, 300, 631, 2932, 367, 2043, 12408, 282, 27962, 2198, 3123, 315, 314, 8870, 402, 2863, 4163, 2552, 14, 199, 199, 30117, 28028, 2597, 7890, 282, 1021, 334, 7087, 36, 28980, 9, 367, 28537, 5302, 316, 199, 1589, 2644, 402, 376, 4163, 503, 4692, 2213, 12, 436, 13806, 652, 370, 199, 7087, 14, 603, 2133, 402, 642, 1233, 365, 9394, 687, 7173, 19641, 1159, 29347, 16261, 10191, 14, 199, 199, 1858, 1655, 2419, 1265, 14433, 13632, 370, 5715, 3595, 14562, 28028, 12, 1937, 314, 199, 9970, 26, 199, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 15619, 15, 30117, 12341, 15, 9970, 14, 1360, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 16952, 199, 199, 363, 2502, 363, 275, 298, 2553, 265, 1005, 30846, 5596, 265, 334, 274, 265, 1005, 82, 32, 8359, 1879, 14, 1308, 2924, 199, 363, 1023, 363, 275, 298, 19, 14, 16, 14, 20, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8353, 13, 9488, 7005, 265, 1005, 30846, 5596, 265, 2, 199, 363, 1682, 363, 275, 298, 5067, 38, 2, 199, 199, 504, 12578, 25598, 492, 18868, 1698, 2842, 12, 18868, 1698, 9123, 199, 646, 6010, 199, 646, 2943, 199, 646, 295, 199, 646, 12578, 25598, 199, 893, 26, 523, 687, 30010, 552, 1701, 8710, 492, 536, 18, 19300, 199, 2590, 3545, 26, 523, 536, 18, 19300, 275, 1052, 199, 199, 3, 2765, 11176, 7704, 14562, 28028, 7688, 370, 2198, 4692, 543, 10747, 199, 1226, 25598, 14, 1450, 1623, 275, 295, 14, 2014, 11894, 65, 13, 6353, 13, 58, 15898, 3754, 26, 65, 13, 6353, 13, 58, 16, 13, 25, 3672, 358, 199, 199, 3472, 63, 8414, 63, 16314, 275, 298, 1624, 13, 24, 2, 199, 199, 3, 7758, 12, 314, 3992, 626, 2954, 9189, 4008, 14, 199, 199, 533, 10331, 2162, 26, 272, 408, 6906, 314, 19191, 279, 2556, 367, 2005, 1777, 402, 314, 2034, 272, 334, 22051, 282, 1947, 503, 282, 14854, 402, 1318, 9471, 339, 347, 3272, 8, 277, 12, 1676, 29, 403, 12, 4136, 29, 403, 304, 267, 408, 9899, 1536, 314, 2536, 16109, 3382, 642, 1819, 436, 267, 1163, 4008, 1041, 18418, 291, 14, 1708, 275, 1676, 267, 291, 14, 6352, 275, 4136, 267, 291, 14, 2184, 275, 488, 267, 291, 14, 6352, 16016, 275, 488, 267, 291, 14, 30336, 275, 488, 267, 340, 291, 14, 1708, 436, 291, 14, 1708, 14, 4407, 26, 288, 291, 14, 6352, 16016, 275, 291, 14, 1708, 14, 4407, 1988, 17, 61, 288, 291, 14, 6352, 16016, 14, 30336, 275, 291, 339, 347, 3350, 3007, 8, 277, 12, 3350, 3007, 304, 18418, 2269, 6652, 275, 291, 14, 1708, 267, 3002, 2681, 275, 291, 14, 1708, 14, 4407, 14, 1080, 8, 277, 9, 267, 340, 2688, 8, 1814, 3007, 12, 283, 1708, 358, 436, 3350, 3007, 14, 1708, 508, 291, 14, 1708, 26, 288, 327, 2136, 3984, 15810, 642, 1819, 543, 1373, 402, 2399, 31871, 14, 288, 1478, 275, 291, 14, 1708, 14, 4407, 14, 1080, 8, 1814, 3007, 9, 288, 340, 1478, 436, 1478, 665, 3002, 2681, 26, 355, 327, 28876, 6878, 12, 652, 12477, 2544, 642, 1819, 14, 10314, 355, 327, 4910, 626, 1380, 781, 5536, 652, 12, 314, 1478, 402, 642, 355, 327, 1819, 911, 1570, 14, 355, 3002, 2681, 275, 3002, 2681, 446, 413, 267, 291, 14, 5005, 342, 18418, 2269, 6652, 14, 3176, 8, 1662, 2681, 12, 3350, 3007, 9, 5493, 347, 5536, 8, 277, 304, 267, 408, 872, 9853, 9462, 8012, 1190, 642, 1819, 734, 402, 314, 3123, 1041, 18418, 340, 291, 14, 1708, 26, 288, 862, 26, 355, 291, 14, 1708, 14, 4407, 14, 2168, 8, 277, 9, 288, 871, 1722, 26, 355, 986, 398, 327, 6591, 314, 2877, 4008, 626, 3955, 506, 2163, 370, 1924, 1163, 340, 267, 327, 3749, 1819, 334, 460, 1263, 4978, 9, 10530, 78, 1133, 2757, 4565, 14, 15175, 267, 327, 1589, 2877, 14, 18418, 2061, 3493, 275, 291, 423, 2019, 25122, 3493, 342, 267, 2163, 2162, 275, 2061, 3493, 14, 2184, 398, 340, 291, 14, 6352, 26, 288, 291, 14, 6352, 14, 2184, 275, 2163, 2162, 267, 340, 2163, 2162, 26, 288, 2163, 2162, 14, 6352, 275, 291, 14, 6352, 267, 291, 14, 6352, 275, 488, 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,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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 ]
arantebillywilson/python-snippets
py2/htp/ch10/fig10_09.py
2
1896
#!/usr/bin/env python # -*- coding: utf-8 -*- # fig10_09.py # Radiobuttons demonstration. # # Author: Billy Wilson Arante # Created: 2016/10/17 EDT (America/New York) # # Attribution: Python How to Program, 1st Ed. by Deitel & Deitel from Tkinter import * class RadioFont(Frame): """An area of text with Radiobutton controlled font""" def __init__(self): """Create an Entry and four Radiobuttons""" Frame.__init__(self) self.pack(expand=YES, fill=BOTH) self.master.title("Radiobutton Demo") # self.master.geometry("300x150") # Window size test self.frame1 = Frame(self) self.frame1.pack() self.text = Entry(self.frame1, font="Monospace 10", width=40) self.text.insert(INSERT, "The quick brown fox jumps over the lazy") self.text.pack(padx=10, pady=10) self.frame2 = Frame(self) self.frame2.pack() font_selections = ["Plain", "Bold", "Italic", "Bold/Italic"] self.chosen_font = StringVar() self.chosen_font.set(font_selections[0]) # Initial font for style in font_selections: a_button = Radiobutton(self.frame2, text=style, value=style, variable=self.chosen_font, command=self.change_font) a_button.pack(side=LEFT, padx=10, pady=5) def change_font(self): """Change the font based on selected Radiobutton""" desired_font = "Monospace 10" if self.chosen_font.get() == "Bold": desired_font = desired_font + " bold" elif self.chosen_font.get() == "Italic": desired_font = desired_font + " italic" elif self.chosen_font.get() == "Bold/Italic": desired_font = desired_font + " bold italic" self.text.config(font=desired_font) def main(): """Main""" RadioFont().mainloop() if __name__ == "__main__": main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 6085, 709, 63, 1643, 14, 647, 199, 3, 3898, 328, 2873, 2471, 83, 23789, 270, 1754, 14, 199, 3, 199, 3, 6529, 26, 699, 382, 590, 644, 382, 834, 437, 1312, 266, 199, 3, 18208, 26, 7800, 15, 709, 15, 1196, 662, 7438, 334, 8841, 15, 4665, 1488, 4708, 9, 199, 3, 199, 3, 2854, 15980, 26, 2018, 7494, 370, 18841, 12, 413, 270, 17379, 14, 701, 1487, 1175, 76, 1253, 1487, 1175, 76, 199, 199, 504, 16826, 492, 627, 199, 199, 533, 13514, 6986, 8, 3160, 304, 272, 408, 2493, 9150, 402, 1318, 543, 3898, 328, 2873, 2471, 22284, 5023, 624, 339, 347, 636, 826, 721, 277, 304, 267, 408, 2499, 376, 11855, 436, 11648, 3898, 328, 2873, 2471, 83, 624, 398, 11726, 855, 826, 721, 277, 9, 267, 291, 14, 1389, 8, 4441, 29, 15641, 12, 5554, 29, 28784, 9, 267, 291, 14, 4133, 14, 1213, 480, 26647, 2873, 2471, 28939, 531, 398, 327, 291, 14, 4133, 14, 7660, 480, 5863, 88, 8251, 531, 221, 327, 15689, 1568, 511, 398, 291, 14, 1943, 17, 275, 11726, 8, 277, 9, 267, 291, 14, 1943, 17, 14, 1389, 342, 398, 291, 14, 505, 275, 11855, 8, 277, 14, 1943, 17, 12, 5023, 628, 6671, 17601, 1616, 401, 3462, 29, 2167, 9, 267, 291, 14, 505, 14, 3176, 8, 10258, 12, 298, 1918, 12530, 330, 18406, 7090, 88, 14882, 83, 1806, 314, 9617, 531, 267, 291, 14, 505, 14, 1389, 8, 6226, 88, 29, 709, 12, 22626, 29, 709, 9, 398, 291, 14, 1943, 18, 275, 11726, 8, 277, 9, 267, 291, 14, 1943, 18, 14, 1389, 342, 398, 5023, 63, 5592, 83, 275, 2097, 20711, 401, 298, 26395, 401, 298, 7940, 17999, 401, 298, 26395, 15, 7940, 17999, 937, 267, 291, 14, 29671, 63, 4246, 275, 2624, 5894, 342, 267, 291, 14, 29671, 63, 4246, 14, 409, 8, 4246, 63, 5592, 83, 59, 16, 566, 221, 327, 6026, 5023, 398, 367, 3449, 315, 5023, 63, 5592, 83, 26, 288, 282, 63, 3887, 275, 3898, 328, 2873, 2471, 8, 277, 14, 1943, 18, 12, 1318, 29, 2487, 12, 574, 29, 2487, 12, 355, 1750, 29, 277, 14, 29671, 63, 4246, 12, 1414, 29, 277, 14, 1461, 63, 4246, 9, 288, 282, 63, 3887, 14, 1389, 8, 2441, 29, 9894, 12, 21729, 29, 709, 12, 22626, 29, 21, 9, 339, 347, 1570, 63, 4246, 8, 277, 304, 267, 408, 4001, 314, 5023, 4079, 641, 4895, 3898, 328, 2873, 2471, 624, 398, 6387, 63, 4246, 275, 298, 6671, 17601, 1616, 2, 398, 340, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 26395, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 17268, 2, 267, 916, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 7940, 17999, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 652, 17999, 2, 267, 916, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 26395, 15, 7940, 17999, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 17268, 652, 17999, 2, 398, 291, 14, 505, 14, 888, 8, 4246, 29, 16035, 63, 4246, 9, 421, 199, 318, 2446, 837, 272, 408, 6756, 624, 339, 13514, 6986, 1252, 22644, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 3, 6085, 709, 63, 1643, 14, 647, 199, 3, 3898, 328, 2873, 2471, 83, 23789, 270, 1754, 14, 199, 3, 199, 3, 6529, 26, 699, 382, 590, 644, 382, 834, 437, 1312, 266, 199, 3, 18208, 26, 7800, 15, 709, 15, 1196, 662, 7438, 334, 8841, 15, 4665, 1488, 4708, 9, 199, 3, 199, 3, 2854, 15980, 26, 2018, 7494, 370, 18841, 12, 413, 270, 17379, 14, 701, 1487, 1175, 76, 1253, 1487, 1175, 76, 199, 199, 504, 16826, 492, 627, 199, 199, 533, 13514, 6986, 8, 3160, 304, 272, 408, 2493, 9150, 402, 1318, 543, 3898, 328, 2873, 2471, 22284, 5023, 624, 339, 347, 636, 826, 721, 277, 304, 267, 408, 2499, 376, 11855, 436, 11648, 3898, 328, 2873, 2471, 83, 624, 398, 11726, 855, 826, 721, 277, 9, 267, 291, 14, 1389, 8, 4441, 29, 15641, 12, 5554, 29, 28784, 9, 267, 291, 14, 4133, 14, 1213, 480, 26647, 2873, 2471, 28939, 531, 398, 327, 291, 14, 4133, 14, 7660, 480, 5863, 88, 8251, 531, 221, 327, 15689, 1568, 511, 398, 291, 14, 1943, 17, 275, 11726, 8, 277, 9, 267, 291, 14, 1943, 17, 14, 1389, 342, 398, 291, 14, 505, 275, 11855, 8, 277, 14, 1943, 17, 12, 5023, 628, 6671, 17601, 1616, 401, 3462, 29, 2167, 9, 267, 291, 14, 505, 14, 3176, 8, 10258, 12, 298, 1918, 12530, 330, 18406, 7090, 88, 14882, 83, 1806, 314, 9617, 531, 267, 291, 14, 505, 14, 1389, 8, 6226, 88, 29, 709, 12, 22626, 29, 709, 9, 398, 291, 14, 1943, 18, 275, 11726, 8, 277, 9, 267, 291, 14, 1943, 18, 14, 1389, 342, 398, 5023, 63, 5592, 83, 275, 2097, 20711, 401, 298, 26395, 401, 298, 7940, 17999, 401, 298, 26395, 15, 7940, 17999, 937, 267, 291, 14, 29671, 63, 4246, 275, 2624, 5894, 342, 267, 291, 14, 29671, 63, 4246, 14, 409, 8, 4246, 63, 5592, 83, 59, 16, 566, 221, 327, 6026, 5023, 398, 367, 3449, 315, 5023, 63, 5592, 83, 26, 288, 282, 63, 3887, 275, 3898, 328, 2873, 2471, 8, 277, 14, 1943, 18, 12, 1318, 29, 2487, 12, 574, 29, 2487, 12, 355, 1750, 29, 277, 14, 29671, 63, 4246, 12, 1414, 29, 277, 14, 1461, 63, 4246, 9, 288, 282, 63, 3887, 14, 1389, 8, 2441, 29, 9894, 12, 21729, 29, 709, 12, 22626, 29, 21, 9, 339, 347, 1570, 63, 4246, 8, 277, 304, 267, 408, 4001, 314, 5023, 4079, 641, 4895, 3898, 328, 2873, 2471, 624, 398, 6387, 63, 4246, 275, 298, 6671, 17601, 1616, 2, 398, 340, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 26395, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 17268, 2, 267, 916, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 7940, 17999, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 652, 17999, 2, 267, 916, 291, 14, 29671, 63, 4246, 14, 362, 342, 508, 298, 26395, 15, 7940, 17999, 582, 288, 6387, 63, 4246, 275, 6387, 63, 4246, 435, 298, 17268, 652, 17999, 2, 398, 291, 14, 505, 14, 888, 8, 4246, 29, 16035, 63, 4246, 9, 421, 199, 318, 2446, 837, 272, 408, 6756, 624, 339, 13514, 6986, 1252, 22644, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
sfagmenos/ker
scripts/tracing/draw_functrace.py
14676
3560
#!/usr/bin/python """ Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com> Licensed under the terms of the GNU GPL License version 2 This script parses a trace provided by the function tracer in kernel/trace/trace_functions.c The resulted trace is processed into a tree to produce a more human view of the call stack by drawing textual but hierarchical tree of calls. Only the functions's names and the the call time are provided. Usage: Be sure that you have CONFIG_FUNCTION_TRACER # mount -t debugfs nodev /sys/kernel/debug # echo function > /sys/kernel/debug/tracing/current_tracer $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func Wait some times but not too much, the script is a bit slow. Break the pipe (Ctrl + Z) $ scripts/draw_functrace.py < raw_trace_func > draw_functrace Then you have your drawn trace in draw_functrace """ import sys, re class CallTree: """ This class provides a tree representation of the functions call stack. If a function has no parent in the kernel (interrupt, syscall, kernel thread...) then it is attached to a virtual parent called ROOT. """ ROOT = None def __init__(self, func, time = None, parent = None): self._func = func self._time = time if parent is None: self._parent = CallTree.ROOT else: self._parent = parent self._children = [] def calls(self, func, calltime): """ If a function calls another one, call this method to insert it into the tree at the appropriate place. @return: A reference to the newly created child node. """ child = CallTree(func, calltime, self) self._children.append(child) return child def getParent(self, func): """ Retrieve the last parent of the current node that has the name given by func. If this function is not on a parent, then create it as new child of root @return: A reference to the parent. """ tree = self while tree != CallTree.ROOT and tree._func != func: tree = tree._parent if tree == CallTree.ROOT: child = CallTree.ROOT.calls(func, None) return child return tree def __repr__(self): return self.__toString("", True) def __toString(self, branch, lastChild): if self._time is not None: s = "%s----%s (%s)\n" % (branch, self._func, self._time) else: s = "%s----%s\n" % (branch, self._func) i = 0 if lastChild: branch = branch[:-1] + " " while i < len(self._children): if i != len(self._children) - 1: s += "%s" % self._children[i].__toString(branch +\ " |", False) else: s += "%s" % self._children[i].__toString(branch +\ " |", True) i += 1 return s class BrokenLineException(Exception): """If the last line is not complete because of the pipe breakage, we want to stop the processing and ignore this line. """ pass class CommentLineException(Exception): """ If the line is a comment (as in the beginning of the trace file), just ignore it. """ pass def parseLine(line): line = line.strip() if line.startswith("#"): raise CommentLineException m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line) if m is None: raise BrokenLineException return (m.group(1), m.group(2), m.group(3)) def main(): CallTree.ROOT = CallTree("Root (Nowhere)", None, None) tree = CallTree.ROOT for line in sys.stdin: try: calltime, callee, caller = parseLine(line) except BrokenLineException: break except CommentLineException: continue tree = tree.getParent(caller) tree = tree.calls(callee, calltime) print CallTree.ROOT if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604, 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,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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 ]
ntduong/ML
Twitter-Analysis/top_ten.py
1
1032
''' Created on May 6, 2013 @author: Administrator ''' import json import sys from collections import defaultdict def parseTweets(tweet_file='tweets.txt'): parsed_tweets = [] with open(tweet_file, 'r') as fin: for line in fin: tweet = json.loads(line) if 'text' in tweet: parsed_tweets.append(tweet) return parsed_tweets def getTags(tweet): if 'entities' in tweet: if 'hashtags' in tweet['entities']: return tweet['entities']['hashtags'] def getAllTags(tweets): hashtags = defaultdict(float) for tweet in tweets: tags = getTags(tweet) if tags: for item in tags: hashtags[item['text']] += 1.0 return hashtags def main(): tweets = parseTweets(sys.argv[1]) hashtags = getAllTags(tweets) cnt = 0 for t in sorted(hashtags, key=hashtags.get, reverse=True): if cnt == 10: break print t, hashtags[t] cnt += 1 if __name__ == '__main__': main()
mit
[ 2344, 199, 10502, 641, 10162, 1227, 12, 6171, 199, 32, 2502, 26, 30660, 199, 2344, 199, 199, 646, 2022, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 318, 2198, 52, 18588, 8, 23508, 63, 493, 534, 84, 18588, 14, 2424, 735, 272, 4565, 63, 84, 18588, 275, 942, 272, 543, 1551, 8, 23508, 63, 493, 12, 283, 82, 358, 465, 2583, 26, 267, 367, 1004, 315, 2583, 26, 288, 21217, 275, 2022, 14, 3640, 8, 604, 9, 288, 340, 283, 505, 7, 315, 21217, 26, 355, 4565, 63, 84, 18588, 14, 740, 8, 23508, 9, 2286, 372, 4565, 63, 84, 18588, 199, 199, 318, 664, 9440, 8, 23508, 304, 272, 340, 283, 8327, 7, 315, 21217, 26, 267, 340, 283, 2227, 2969, 7, 315, 21217, 459, 8327, 2565, 288, 372, 21217, 459, 8327, 2545, 2227, 2969, 418, 199, 199, 318, 664, 2422, 9440, 8, 84, 18588, 304, 272, 2631, 2969, 275, 10018, 8, 1609, 9, 272, 367, 21217, 315, 307, 18588, 26, 267, 3762, 275, 664, 9440, 8, 23508, 9, 267, 340, 3762, 26, 288, 367, 1242, 315, 3762, 26, 355, 2631, 2969, 59, 1053, 459, 505, 6538, 847, 413, 14, 16, 272, 372, 2631, 2969, 199, 199, 318, 2446, 837, 272, 307, 18588, 275, 2198, 52, 18588, 8, 1274, 14, 3020, 59, 17, 566, 272, 2631, 2969, 275, 664, 2422, 9440, 8, 84, 18588, 9, 272, 12703, 275, 378, 272, 367, 307, 315, 3355, 8, 2227, 2969, 12, 790, 29, 2227, 2969, 14, 362, 12, 3837, 29, 549, 304, 267, 340, 12703, 508, 1616, 26, 2059, 267, 870, 307, 12, 2631, 2969, 59, 84, 61, 267, 12703, 847, 413, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 10502, 641, 10162, 1227, 12, 6171, 199, 32, 2502, 26, 30660, 199, 2344, 199, 199, 646, 2022, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 318, 2198, 52, 18588, 8, 23508, 63, 493, 534, 84, 18588, 14, 2424, 735, 272, 4565, 63, 84, 18588, 275, 942, 272, 543, 1551, 8, 23508, 63, 493, 12, 283, 82, 358, 465, 2583, 26, 267, 367, 1004, 315, 2583, 26, 288, 21217, 275, 2022, 14, 3640, 8, 604, 9, 288, 340, 283, 505, 7, 315, 21217, 26, 355, 4565, 63, 84, 18588, 14, 740, 8, 23508, 9, 2286, 372, 4565, 63, 84, 18588, 199, 199, 318, 664, 9440, 8, 23508, 304, 272, 340, 283, 8327, 7, 315, 21217, 26, 267, 340, 283, 2227, 2969, 7, 315, 21217, 459, 8327, 2565, 288, 372, 21217, 459, 8327, 2545, 2227, 2969, 418, 199, 199, 318, 664, 2422, 9440, 8, 84, 18588, 304, 272, 2631, 2969, 275, 10018, 8, 1609, 9, 272, 367, 21217, 315, 307, 18588, 26, 267, 3762, 275, 664, 9440, 8, 23508, 9, 267, 340, 3762, 26, 288, 367, 1242, 315, 3762, 26, 355, 2631, 2969, 59, 1053, 459, 505, 6538, 847, 413, 14, 16, 272, 372, 2631, 2969, 199, 199, 318, 2446, 837, 272, 307, 18588, 275, 2198, 52, 18588, 8, 1274, 14, 3020, 59, 17, 566, 272, 2631, 2969, 275, 664, 2422, 9440, 8, 84, 18588, 9, 272, 12703, 275, 378, 272, 367, 307, 315, 3355, 8, 2227, 2969, 12, 790, 29, 2227, 2969, 14, 362, 12, 3837, 29, 549, 304, 267, 340, 12703, 508, 1616, 26, 2059, 267, 870, 307, 12, 2631, 2969, 59, 84, 61, 267, 12703, 847, 413, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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, 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,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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 ]
kursitet/edx-ora2
openassessment/xblock/test/test_message.py
7
29377
# -*- coding: utf-8 -*- """ Tests for message handlers in Open Assessment XBlock. """ import copy import mock import pytz import datetime as dt from openassessment.xblock.openassessmentblock import OpenAssessmentBlock from .base import XBlockHandlerTestCase, scenario class TestMessageRender(XBlockHandlerTestCase): """ Tests for the Message XBlock Handler """ # Sets up all of the pre-set dates. Uses base day of today in order to allow # comparison regardless of true date. For this reason, the dates in the XML are # ignored and irrelevant (because we patch is_closed) TODAY = dt.datetime.utcnow().replace(tzinfo=pytz.utc) TOMORROW = TODAY + dt.timedelta(days=1) FUTURE = TODAY + dt.timedelta(days=10) FAR_FUTURE = TODAY + dt.timedelta(days=100) YESTERDAY = TODAY - dt.timedelta(days=1) PAST = TODAY - dt.timedelta(days=10) FAR_PAST = TODAY - dt.timedelta(days=100) DEFAULT_STATUS_DETAILS = { 'peer': { 'completed': TODAY, 'graded': TODAY, }, 'ai': { 'completed': TODAY, 'graded': TODAY, }, } def _assert_path_and_context( self, xblock, expected_path, expected_context, workflow_status, deadline_information, has_peers_to_grade, workflow_status_details=DEFAULT_STATUS_DETAILS ): """ Complete all of the logic behind rendering the message and verify 1) The correct template and context were used 2) The rendering occured without an error Args: xblock (OpenAssessmentBlock): The XBlock we are testing expected_path (str): The expected template path expected_context (dict): The expected template context workflow_status (str or None): The cannonical workflow status deadline_information (dict): has the following properties - deadline_information.get("submission") has the same properties as is_closed("submission") - deadline_information.get("peer-assessment") has the same properties as is_closed("peer-assessment") - deadline_information.get("self-assessment") has the same properties as is_closed("self-assessment") - (WILL BE DEFAULT) deadline_information.get("over-all") has the same properties as is_closed() has_peers_to_grade (bool): A boolean which indicates whether the queue of peer responses is empty workflow_status_details (dict): A dictionary of status details """ # Simulate the response from the workflow API workflow_info = { 'status': workflow_status, 'status_details': workflow_status_details, } xblock.get_workflow_info = mock.Mock(return_value=workflow_info) # Mock out the actual rendering of the assessment (we will check what it is called with) xblock.render_assessment = mock.Mock() # Simulate the field of no_peers based on our test input xblock.no_peers = not has_peers_to_grade # Mock out the is_closed method from the OpenAssessmentClass with mock.patch.object(OpenAssessmentBlock, 'is_closed') as mock_is_closed: def closed_side_effect(step="over-all"): # The method which will patch xblock.is_closed. Returns values in the form of is_closed, and takes # its information from the paramater deadline_information of _assert_path_and_context. # Note that if no parameter is provided, we assume the user is asking for is_closed() return deadline_information.get(step, "not-found") # Sets the side effect of is_closed to be our custom method, completing the patch mock_is_closed.side_effect = closed_side_effect xblock.render_message(None, '') # Asserts that the message_mixin correctly derived the path and context to be rendered xblock.render_assessment.assert_called_with(expected_path, expected_context) @scenario('data/message_scenario.xml', user_id = "Linda") def test_submission(self, xblock): status = None deadline_information = { 'submission': (False, None, self.FAR_PAST, self.FUTURE), 'peer-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_open.html' expected_context = { "approaching": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_peer.xml', user_id = "Linda") def test_submission_no_peer(self, xblock): status = None deadline_information = { 'submission': (False, None, self.FAR_PAST, self.FUTURE), 'self-assessment': (True, 'start', self.FUTURE, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_open.html' expected_context = { "approaching": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_submission_approaching(self, xblock): status = None deadline_information = { 'submission': (False, None, self.FAR_PAST, self.TOMORROW), 'peer-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'self-assessment': (True, 'start', self.FUTURE, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_open.html' expected_context = { "approaching": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_self.xml', user_id = "Linda") def test_submission_no_self_approaching(self, xblock): status = None deadline_information = { 'submission': (False, None, self.FAR_PAST, self.TOMORROW), 'peer-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_open.html' expected_context = { "approaching": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_submission_not_yet_open(self, xblock): status = None deadline_information = { 'submission': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'peer-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (True, 'start', self.TOMORROW, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_submission_incomplete(self, xblock): status = None deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.TODAY), 'peer-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_student_training.xml', user_id = "Linda") def test_training(self, xblock): status = 'training' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'student-training': (False, None, self.YESTERDAY, self.FUTURE), 'peer-assessment': (False, None, self.YESTERDAY, self.FUTURE), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_training.html' expected_context = { "approaching": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_student_training.xml', user_id = "Linda") def test_training_approaching(self, xblock): status = 'training' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'student-training': (False, None, self.YESTERDAY, self.TOMORROW), 'peer-assessment': (False, None, self.YESTERDAY, self.TOMORROW), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_training.html' expected_context = { "approaching": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_student_training.xml', user_id = "Linda") def test_training_not_released(self, xblock): status = 'training' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.TOMORROW), 'student-training': (True, 'start', self.TOMORROW, self.FUTURE), 'peer-assessment': (True, 'start', self.TOMORROW, self.FUTURE), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_student_training.xml', user_id = "Linda") def test_training_closed(self, xblock): status = 'training' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.PAST), 'student-training': (True, 'due', self.FAR_PAST, self.PAST), 'peer-assessment': (True, 'due', self.PAST, self.YESTERDAY), 'self-assessment': (False, None, self.YESTERDAY, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (False, None, self.FAR_PAST, self.FUTURE), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_peer.html' expected_context = { "has_self": True, "waiting": False, "peer_approaching": False, "peer_closed": False, "peer_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_self.xml', user_id = "Linda") def test_peer_no_self(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (False, None, self.FAR_PAST, self.FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_peer.html' expected_context = { "has_self": False, "waiting": False, "peer_approaching": False, "peer_closed": False, "peer_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_self.xml', user_id = "Linda") def test_peer_no_self_approaching(self, xblock): status = 'peer' deadline_information = { 'submission': (False, None, self.FAR_PAST, self.TOMORROW), 'peer-assessment': (False, None, self.FAR_PAST, self.TOMORROW), 'over-all': (False, None, self.FAR_PAST, self.TOMORROW) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_peer.html' expected_context = { "has_self": False, "waiting": False, "peer_approaching": True, "peer_closed": False, "peer_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer_not_released(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'start', self.TOMORROW, self.FUTURE), 'self-assessment': (True, 'start', self.TOMORROW, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer_incomplete(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.PAST, self.TODAY), 'self-assessment': (False, None, self.TODAY, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer_no_peers_to_assess(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (False, None, self.FAR_PAST, self.FUTURE), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_peer.html' expected_context = { "has_self": True, "waiting": True, "peer_approaching": False, "peer_closed": False, "peer_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer_no_peers_to_assess_approaching(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (False, None, self.FAR_PAST, self.TOMORROW), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_peer.html' expected_context = { "has_self": True, "waiting": True, "peer_approaching": True, "peer_closed": False, "peer_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_peer_not_open_approaching(self, xblock): status = 'peer' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'start', self.TOMORROW, self.FUTURE), 'self-assessment': (False, None, self.FUTURE, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_self(self, xblock): status = 'self' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (False, None, self.FAR_PAST, self.FUTURE), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_self.html' expected_context = { "has_peer": True, "self_approaching": False, "self_closed": False, "self_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_peer.xml', user_id = "Linda") def test_self_no_peer(self, xblock): status = 'self' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'self-assessment': (False, None, self.FAR_PAST, self.FAR_FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FAR_FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_self.html' expected_context = { "has_peer": False, "self_approaching": False, "self_closed": False, "self_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_peer.xml', user_id = "Linda") def test_self_no_peer_approaching(self, xblock): status = 'self' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'self-assessment': (False, None, self.FAR_PAST, self.TOMORROW), 'over-all': (False, None, self.FAR_PAST, self.TOMORROW) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_self.html' expected_context = { "has_peer": False, "self_approaching": True, "self_closed": False, "self_not_released": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_self_closed(self, xblock): status = 'self' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (True, 'start', self.TOMORROW, self.FUTURE), 'over-all': (False, None, self.FAR_PAST, self.FUTURE) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": True } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario_no_peer.xml', user_id = "Linda") def test_self_no_peer_incomplete(self, xblock): status = 'self' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'self-assessment': (True, 'due', self.PAST, self.YESTERDAY), 'over-all': (True, 'due', self.FAR_PAST, self.YESTERDAY) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_closed.html' expected_context = { "not_yet_open": False } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_waiting_due(self, xblock): status = 'waiting' status_details = copy.deepcopy(self.DEFAULT_STATUS_DETAILS) status_details["peer"]["graded"] = None deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'over-all': (True, 'due', self.FAR_PAST, self.TODAY) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": "peer" } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade, status_details ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_waiting_not_due(self, xblock): status = 'waiting' status_details = copy.deepcopy(self.DEFAULT_STATUS_DETAILS) status_details["peer"]["graded"] = None deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (False, None, self.YESTERDAY, self.TOMORROW), 'over-all': (False, None, self.FAR_PAST, self.TOMORROW) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": "peer" } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade, status_details ) @scenario('data/message_scenario.xml', user_id="Linda") def test_waiting_on_ai(self, xblock): status = 'waiting' status_details = copy.deepcopy(self.DEFAULT_STATUS_DETAILS) status_details["ai"]["graded"] = None deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'over-all': (True, 'due', self.FAR_PAST, self.TODAY) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": "example-based" } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade, status_details ) @scenario('data/message_scenario.xml', user_id="Linda") def test_waiting_on_all(self, xblock): status = 'waiting' status_details = copy.deepcopy(self.DEFAULT_STATUS_DETAILS) status_details["ai"]["graded"] = None status_details["peer"]["graded"] = None deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'over-all': (True, 'due', self.FAR_PAST, self.TODAY) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": "all" } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade, status_details ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_done_due(self, xblock): status = 'done' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'over-all': (True, 'due', self.FAR_PAST, self.TODAY) } has_peers_to_grade = True expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": None } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade ) @scenario('data/message_scenario.xml', user_id = "Linda") def test_done_not_due(self, xblock): status = 'done' deadline_information = { 'submission': (True, 'due', self.FAR_PAST, self.YESTERDAY), 'peer-assessment': (True, 'due', self.YESTERDAY, self.TODAY), 'self-assessment': (False, None, self.YESTERDAY, self.TOMORROW), 'over-all': (False, None, self.FAR_PAST, self.TOMORROW) } has_peers_to_grade = False expected_path = 'openassessmentblock/message/oa_message_complete.html' expected_context = { "waiting": None } self._assert_path_and_context( xblock, expected_path, expected_context, status, deadline_information, has_peers_to_grade )
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2925, 367, 1245, 8297, 315, 3232, 3709, 12104, 15398, 14, 199, 624, 199, 646, 1331, 199, 199, 646, 1683, 199, 646, 15444, 199, 199, 646, 2197, 465, 4487, 199, 504, 1551, 17452, 14, 11283, 14, 1490, 17452, 1457, 492, 3232, 2822, 12104, 3142, 199, 504, 1275, 1095, 492, 15398, 2461, 1746, 12, 15728, 421, 199, 533, 1379, 2209, 9216, 8, 24784, 2461, 1746, 304, 272, 408, 272, 6496, 367, 314, 6430, 15398, 18599, 272, 408, 339, 327, 10729, 1536, 1006, 402, 314, 876, 13, 409, 10831, 14, 221, 14911, 1300, 5382, 402, 11168, 315, 1865, 370, 2040, 272, 327, 9132, 15270, 402, 2549, 1434, 14, 221, 2104, 642, 4499, 12, 314, 10831, 315, 314, 4692, 787, 272, 327, 5525, 436, 8190, 21906, 334, 20684, 781, 3371, 365, 63, 5938, 9, 272, 2296, 11655, 275, 4487, 14, 2083, 14, 10779, 1252, 1814, 8, 9374, 29, 21948, 14, 5834, 9, 272, 2296, 45, 726, 11415, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 17, 9, 272, 481, 934, 3942, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 709, 9, 272, 481, 689, 63, 20254, 3942, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 1960, 9, 272, 1488, 654, 1157, 11655, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 17, 9, 272, 510, 11307, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 709, 9, 272, 481, 689, 63, 8470, 840, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 1960, 9, 339, 6186, 63, 6305, 63, 25081, 51, 275, 469, 267, 283, 7866, 356, 469, 288, 283, 12634, 356, 2296, 11655, 12, 288, 283, 13688, 356, 2296, 11655, 12, 267, 1660, 267, 283, 5789, 356, 469, 288, 283, 12634, 356, 2296, 11655, 12, 288, 283, 13688, 356, 2296, 11655, 12, 267, 1660, 272, 789, 339, 347, 485, 479, 63, 515, 63, 460, 63, 1100, 8, 267, 291, 12, 12971, 12, 1420, 63, 515, 12, 1420, 63, 1100, 12, 267, 10431, 63, 1205, 12, 23081, 63, 11697, 12, 965, 63, 22416, 63, 475, 63, 4523, 12, 267, 10431, 63, 1205, 63, 5087, 29, 3472, 63, 6305, 63, 25081, 51, 272, 3461, 267, 408, 267, 28393, 1006, 402, 314, 9661, 22172, 14066, 314, 1245, 436, 4911, 288, 413, 9, 710, 3211, 1978, 436, 1067, 4898, 1202, 288, 499, 9, 710, 14066, 28408, 1928, 376, 1125, 398, 3033, 26, 288, 12971, 334, 4299, 2822, 12104, 3142, 304, 710, 15398, 781, 787, 5343, 288, 1420, 63, 515, 334, 495, 304, 710, 1420, 1978, 931, 288, 1420, 63, 1100, 334, 807, 304, 710, 1420, 1978, 1067, 288, 10431, 63, 1205, 334, 495, 503, 488, 304, 710, 883, 2865, 2652, 10431, 2004, 288, 23081, 63, 11697, 334, 807, 304, 965, 314, 2569, 4382, 355, 446, 23081, 63, 11697, 14, 362, 480, 12542, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 12542, 531, 355, 446, 23081, 63, 11697, 14, 362, 480, 7866, 13, 17452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 7866, 13, 17452, 531, 355, 446, 23081, 63, 11697, 14, 362, 480, 277, 13, 17452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 277, 13, 17452, 531, 355, 446, 334, 55, 14961, 6262, 6186, 9, 23081, 63, 11697, 14, 362, 480, 1883, 13, 452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 342, 288, 965, 63, 22416, 63, 475, 63, 4523, 334, 2245, 304, 437, 5046, 1314, 9126, 3775, 314, 4126, 402, 9104, 9320, 365, 2701, 288, 10431, 63, 1205, 63, 5087, 334, 807, 304, 437, 2600, 402, 2004, 2436, 398, 408, 398, 327, 10751, 5434, 314, 1177, 687, 314, 10431, 3261, 267, 10431, 63, 815, 275, 469, 288, 283, 1205, 356, 10431, 63, 1205, 12, 288, 283, 1205, 63, 5087, 356, 10431, 63, 1205, 63, 5087, 12, 267, 789, 267, 12971, 14, 362, 63, 8856, 63, 815, 275, 1683, 14, 3346, 8, 1107, 63, 585, 29, 8856, 63, 815, 9, 398, 327, 4420, 734, 314, 3503, 14066, 402, 314, 28273, 334, 1129, 911, 1104, 4052, 652, 365, 2797, 543, 9, 267, 12971, 14, 3352, 63, 17452, 275, 1683, 14, 3346, 342, 398, 327, 10751, 5434, 314, 901, 402, 949, 63, 22416, 4079, 641, 4154, 511, 1324, 267, 12971, 14, 889, 63, 22416, 275, 440, 965, 63, 22416, 63, 475, 63, 4523, 398, 327, 4420, 734, 314, 365, 63, 5938, 1083, 687, 314, 3232, 2822, 12104, 2543, 267, 543, 1683, 14, 2068, 14, 785, 8, 4299, 2822, 12104, 3142, 12, 283, 374, 63, 5938, 358, 465, 1683, 63, 374, 63, 5938, 26, 953, 347, 6876, 63, 2441, 63, 5881, 8, 2926, 628, 1883, 13, 452, 2349, 355, 327, 710, 1083, 1314, 911, 3371, 12971, 14, 374, 63, 5938, 14, 1803, 1338, 315, 314, 1824, 402, 365, 63, 5938, 12, 436, 6181, 355, 327, 2399, 2556, 687, 314, 1215, 6618, 23081, 63, 11697, 402, 485, 479, 63, 515, 63, 460, 63, 1100, 14, 355, 327, 3390, 626, 340, 949, 2725, 365, 2741, 12, 781, 5534, 314, 922, 365, 7198, 316, 367, 365, 63, 5938, 342, 2234, 372, 23081, 63, 11697, 14, 362, 8, 2926, 12, 298, 1397, 13, 4214, 531, 953, 327, 10729, 314, 5366, 7763, 402, 365, 63, 5938, 370, 506, 4154, 3537, 1083, 12, 2831, 1337, 314, 3371, 288, 1683, 63, 374, 63, 5938, 14, 2441, 63, 5881, 275, 6876, 63, 2441, 63, 5881, 953, 12971, 14, 3352, 63, 1188, 8, 403, 12, 4074, 953, 327, 10716, 83, 626, 314, 1245, 63, 20406, 6657, 7131, 314, 931, 436, 1067, 370, 506, 8018, 288, 12971, 14, 3352, 63, 17452, 14, 479, 63, 3527, 63, 1045, 8, 2062, 63, 515, 12, 1420, 63, 1100, 9, 2378, 768, 13444, 360, 576, 15, 1188, 63, 13444, 14, 1652, 297, 922, 63, 344, 275, 298, 44, 688, 65, 531, 272, 347, 511, 63, 12542, 8, 277, 12, 12971, 304, 398, 2004, 275, 488, 398, 23081, 63, 11697, 275, 469, 288, 283, 12542, 356, 334, 797, 12, 488, 12, 291, 14, 38, 689, 63, 8470, 840, 12, 291, 14, 20254, 3942, 395, 288, 283, 7866, 13, 17452, 356, 334, 797, 12, 488, 12, 291, 14, 38, 689 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2925, 367, 1245, 8297, 315, 3232, 3709, 12104, 15398, 14, 199, 624, 199, 646, 1331, 199, 199, 646, 1683, 199, 646, 15444, 199, 199, 646, 2197, 465, 4487, 199, 504, 1551, 17452, 14, 11283, 14, 1490, 17452, 1457, 492, 3232, 2822, 12104, 3142, 199, 504, 1275, 1095, 492, 15398, 2461, 1746, 12, 15728, 421, 199, 533, 1379, 2209, 9216, 8, 24784, 2461, 1746, 304, 272, 408, 272, 6496, 367, 314, 6430, 15398, 18599, 272, 408, 339, 327, 10729, 1536, 1006, 402, 314, 876, 13, 409, 10831, 14, 221, 14911, 1300, 5382, 402, 11168, 315, 1865, 370, 2040, 272, 327, 9132, 15270, 402, 2549, 1434, 14, 221, 2104, 642, 4499, 12, 314, 10831, 315, 314, 4692, 787, 272, 327, 5525, 436, 8190, 21906, 334, 20684, 781, 3371, 365, 63, 5938, 9, 272, 2296, 11655, 275, 4487, 14, 2083, 14, 10779, 1252, 1814, 8, 9374, 29, 21948, 14, 5834, 9, 272, 2296, 45, 726, 11415, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 17, 9, 272, 481, 934, 3942, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 709, 9, 272, 481, 689, 63, 20254, 3942, 275, 2296, 11655, 435, 4487, 14, 7473, 8, 4899, 29, 1960, 9, 272, 1488, 654, 1157, 11655, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 17, 9, 272, 510, 11307, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 709, 9, 272, 481, 689, 63, 8470, 840, 275, 2296, 11655, 446, 4487, 14, 7473, 8, 4899, 29, 1960, 9, 339, 6186, 63, 6305, 63, 25081, 51, 275, 469, 267, 283, 7866, 356, 469, 288, 283, 12634, 356, 2296, 11655, 12, 288, 283, 13688, 356, 2296, 11655, 12, 267, 1660, 267, 283, 5789, 356, 469, 288, 283, 12634, 356, 2296, 11655, 12, 288, 283, 13688, 356, 2296, 11655, 12, 267, 1660, 272, 789, 339, 347, 485, 479, 63, 515, 63, 460, 63, 1100, 8, 267, 291, 12, 12971, 12, 1420, 63, 515, 12, 1420, 63, 1100, 12, 267, 10431, 63, 1205, 12, 23081, 63, 11697, 12, 965, 63, 22416, 63, 475, 63, 4523, 12, 267, 10431, 63, 1205, 63, 5087, 29, 3472, 63, 6305, 63, 25081, 51, 272, 3461, 267, 408, 267, 28393, 1006, 402, 314, 9661, 22172, 14066, 314, 1245, 436, 4911, 288, 413, 9, 710, 3211, 1978, 436, 1067, 4898, 1202, 288, 499, 9, 710, 14066, 28408, 1928, 376, 1125, 398, 3033, 26, 288, 12971, 334, 4299, 2822, 12104, 3142, 304, 710, 15398, 781, 787, 5343, 288, 1420, 63, 515, 334, 495, 304, 710, 1420, 1978, 931, 288, 1420, 63, 1100, 334, 807, 304, 710, 1420, 1978, 1067, 288, 10431, 63, 1205, 334, 495, 503, 488, 304, 710, 883, 2865, 2652, 10431, 2004, 288, 23081, 63, 11697, 334, 807, 304, 965, 314, 2569, 4382, 355, 446, 23081, 63, 11697, 14, 362, 480, 12542, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 12542, 531, 355, 446, 23081, 63, 11697, 14, 362, 480, 7866, 13, 17452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 7866, 13, 17452, 531, 355, 446, 23081, 63, 11697, 14, 362, 480, 277, 13, 17452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 480, 277, 13, 17452, 531, 355, 446, 334, 55, 14961, 6262, 6186, 9, 23081, 63, 11697, 14, 362, 480, 1883, 13, 452, 531, 965, 314, 2011, 4382, 465, 365, 63, 5938, 342, 288, 965, 63, 22416, 63, 475, 63, 4523, 334, 2245, 304, 437, 5046, 1314, 9126, 3775, 314, 4126, 402, 9104, 9320, 365, 2701, 288, 10431, 63, 1205, 63, 5087, 334, 807, 304, 437, 2600, 402, 2004, 2436, 398, 408, 398, 327, 10751, 5434, 314, 1177, 687, 314, 10431, 3261, 267, 10431, 63, 815, 275, 469, 288, 283, 1205, 356, 10431, 63, 1205, 12, 288, 283, 1205, 63, 5087, 356, 10431, 63, 1205, 63, 5087, 12, 267, 789, 267, 12971, 14, 362, 63, 8856, 63, 815, 275, 1683, 14, 3346, 8, 1107, 63, 585, 29, 8856, 63, 815, 9, 398, 327, 4420, 734, 314, 3503, 14066, 402, 314, 28273, 334, 1129, 911, 1104, 4052, 652, 365, 2797, 543, 9, 267, 12971, 14, 3352, 63, 17452, 275, 1683, 14, 3346, 342, 398, 327, 10751, 5434, 314, 901, 402, 949, 63, 22416, 4079, 641, 4154, 511, 1324, 267, 12971, 14, 889, 63, 22416, 275, 440, 965, 63, 22416, 63, 475, 63, 4523, 398, 327, 4420, 734, 314, 365, 63, 5938, 1083, 687, 314, 3232, 2822, 12104, 2543, 267, 543, 1683, 14, 2068, 14, 785, 8, 4299, 2822, 12104, 3142, 12, 283, 374, 63, 5938, 358, 465, 1683, 63, 374, 63, 5938, 26, 953, 347, 6876, 63, 2441, 63, 5881, 8, 2926, 628, 1883, 13, 452, 2349, 355, 327, 710, 1083, 1314, 911, 3371, 12971, 14, 374, 63, 5938, 14, 1803, 1338, 315, 314, 1824, 402, 365, 63, 5938, 12, 436, 6181, 355, 327, 2399, 2556, 687, 314, 1215, 6618, 23081, 63, 11697, 402, 485, 479, 63, 515, 63, 460, 63, 1100, 14, 355, 327, 3390, 626, 340, 949, 2725, 365, 2741, 12, 781, 5534, 314, 922, 365, 7198, 316, 367, 365, 63, 5938, 342, 2234, 372, 23081, 63, 11697, 14, 362, 8, 2926, 12, 298, 1397, 13, 4214, 531, 953, 327, 10729, 314, 5366, 7763, 402, 365, 63, 5938, 370, 506, 4154, 3537, 1083, 12, 2831, 1337, 314, 3371, 288, 1683, 63, 374, 63, 5938, 14, 2441, 63, 5881, 275, 6876, 63, 2441, 63, 5881, 953, 12971, 14, 3352, 63, 1188, 8, 403, 12, 4074, 953, 327, 10716, 83, 626, 314, 1245, 63, 20406, 6657, 7131, 314, 931, 436, 1067, 370, 506, 8018, 288, 12971, 14, 3352, 63, 17452, 14, 479, 63, 3527, 63, 1045, 8, 2062, 63, 515, 12, 1420, 63, 1100, 9, 2378, 768, 13444, 360, 576, 15, 1188, 63, 13444, 14, 1652, 297, 922, 63, 344, 275, 298, 44, 688, 65, 531, 272, 347, 511, 63, 12542, 8, 277, 12, 12971,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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 ]
BT-rmartin/odoo
addons/hr_payroll/__init__.py
433
1137
#-*- coding:utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # d$ # # 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 hr_payroll import report import wizard import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 13, 1837, 2803, 26, 1624, 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, 2900, 5924, 5702, 199, 3, 259, 366, 4, 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, 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, 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, 646, 16140, 63, 5989, 2827, 199, 646, 3622, 199, 646, 12262, 199, 199, 646, 522, 63, 888, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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 ]
[ 13, 1837, 2803, 26, 1624, 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, 2900, 5924, 5702, 199, 3, 259, 366, 4, 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, 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, 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, 646, 16140, 63, 5989, 2827, 199, 646, 3622, 199, 646, 12262, 199, 199, 646, 522, 63, 888, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 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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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 ]
xpoft/babel
babel/messages/tests/mofile.py
2
3421
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. import doctest import gettext import os import unittest from babel.compat import BytesIO, u, text_type from babel.messages import mofile, Catalog class ReadMoTestCase(unittest.TestCase): def setUp(self): self.datadir = os.path.join(os.path.dirname(__file__), 'data') def test_basics(self): mo_file = open(os.path.join(self.datadir, 'project', 'i18n', 'de', 'LC_MESSAGES', 'messages.mo'), 'rb') try: catalog = mofile.read_mo(mo_file) self.assertEqual(2, len(catalog)) self.assertEqual('TestProject', catalog.project) self.assertEqual('0.1', catalog.version) self.assertEqual('Stange', catalog['bar'].string) self.assertEqual(['Fuhstange', 'Fuhstangen'], catalog['foobar'].string) finally: mo_file.close() class WriteMoTestCase(unittest.TestCase): def test_sorting(self): # Ensure the header is sorted to the first entry so that its charset # can be applied to all subsequent messages by GNUTranslations # (ensuring all messages are safely converted to unicode) catalog = Catalog(locale='en_US') catalog.add(u(''), '''\ "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n''') catalog.add(u('foo'), 'Voh') catalog.add((u('There is'), u('There are')), (u('Es gibt'), u('Es gibt'))) catalog.add(u('Fizz'), '') catalog.add(('Fuzz', 'Fuzzes'), ('', '')) buf = BytesIO() mofile.write_mo(buf, catalog) buf.seek(0) translations = gettext.GNUTranslations(fp=buf) self.assertEqual(u('Voh'), translations.ugettext('foo')) assert isinstance(translations.ugettext('foo'), text_type) self.assertEqual(u('Es gibt'), translations.ungettext('There is', 'There are', 1)) assert isinstance(translations.ungettext('There is', 'There are', 1), text_type) self.assertEqual(u('Fizz'), translations.ugettext('Fizz')) assert isinstance(translations.ugettext('Fizz'), text_type) self.assertEqual(u('Fuzz'), translations.ugettext('Fuzz')) assert isinstance(translations.ugettext('Fuzz'), text_type) self.assertEqual(u('Fuzzes'), translations.ugettext('Fuzzes')) assert isinstance(translations.ugettext('Fuzzes'), text_type) def test_more_plural_forms(self): catalog2 = Catalog(locale='ru_RU') catalog2.add(('Fuzz', 'Fuzzes'), ('', '', '')) buf = BytesIO() mofile.write_mo(buf, catalog2) def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(mofile, optionflags=doctest.ELLIPSIS)) suite.addTest(unittest.makeSuite(ReadMoTestCase)) suite.addTest(unittest.makeSuite(WriteMoTestCase)) return suite if __name__ == '__main__': unittest.main(defaultTest='suite')
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 13, 8128, 25155, 7567, 2290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 710, 2895, 199, 3, 787, 2597, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 6797, 15, 3761, 14, 199, 3, 199, 3, 961, 2032, 18581, 402, 5236, 638, 695, 406, 26675, 6326, 701, 5002, 199, 3, 8212, 83, 14, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6974, 199, 3, 7994, 436, 9610, 12, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 793, 8083, 199, 199, 646, 8868, 199, 646, 9796, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 29178, 14, 5819, 492, 11808, 12, 399, 12, 1318, 63, 466, 199, 504, 29178, 14, 3431, 492, 1303, 493, 12, 22881, 421, 199, 533, 5574, 3716, 1746, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 18259, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 358, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 1303, 63, 493, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 18259, 12, 283, 1715, 297, 283, 73, 1085, 78, 297, 283, 271, 297, 2511, 283, 7027, 63, 23229, 297, 283, 3431, 14, 573, 659, 283, 4848, 358, 267, 862, 26, 288, 10594, 275, 1303, 493, 14, 739, 63, 573, 8, 573, 63, 493, 9, 288, 291, 14, 629, 8, 18, 12, 822, 8, 7959, 430, 288, 291, 14, 629, 360, 774, 4761, 297, 10594, 14, 1715, 9, 288, 291, 14, 629, 360, 16, 14, 17, 297, 10594, 14, 1023, 9, 288, 291, 14, 629, 360, 933, 618, 297, 10594, 459, 1700, 2278, 875, 9, 288, 291, 14, 629, 2941, 19590, 72, 270, 618, 297, 283, 19590, 72, 270, 621, 287, 995, 2490, 10594, 459, 9664, 2278, 875, 9, 267, 3753, 26, 288, 1303, 63, 493, 14, 1600, 342, 421, 199, 533, 6990, 3716, 1746, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 29411, 8, 277, 304, 267, 327, 7523, 314, 1406, 365, 3355, 370, 314, 1642, 2397, 880, 626, 2399, 5960, 267, 327, 883, 506, 6781, 370, 1006, 13372, 3788, 701, 27650, 934, 1320, 6011, 267, 327, 334, 8764, 4039, 1006, 3788, 787, 19353, 6702, 370, 2649, 9, 267, 10594, 275, 22881, 8, 5508, 534, 287, 63, 1668, 358, 267, 10594, 14, 525, 8, 85, 31150, 18087, 199, 2, 2714, 13, 804, 26, 1318, 15, 6104, 27, 5960, 29, 1624, 13, 24, 60, 78, 2, 199, 2, 2714, 13, 11761, 13, 7630, 26, 1695, 2075, 60, 78, 12310, 267, 10594, 14, 525, 8, 85, 360, 1421, 659, 283, 54, 19194, 358, 267, 10594, 14, 525, 1332, 85, 360, 10924, 365, 659, 399, 360, 10924, 787, 3855, 334, 85, 360, 21658, 486, 1892, 84, 659, 399, 360, 21658, 486, 1892, 84, 7058, 267, 10594, 14, 525, 8, 85, 360, 38, 28981, 659, 4074, 267, 10594, 14, 525, 4725, 19590, 4348, 297, 283, 19590, 4348, 397, 659, 13134, 12381, 267, 4123, 275, 11808, 342, 267, 1303, 493, 14, 952, 63, 573, 8, 1436, 12, 10594, 9, 267, 4123, 14, 5507, 8, 16, 9, 267, 15547, 275, 9796, 14, 15306, 934, 1320, 6011, 8, 3997, 29, 1436, 9, 267, 291, 14, 629, 8, 85, 360, 54, 19194, 659, 15547, 14, 23499, 360, 1421, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 1421, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 21658, 486, 1892, 84, 659, 15547, 14, 324, 5152, 360, 10924, 365, 297, 283, 10924, 787, 297, 413, 430, 267, 702, 1228, 8, 13982, 14, 324, 5152, 360, 10924, 365, 297, 283, 10924, 787, 297, 413, 395, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 38, 28981, 659, 15547, 14, 23499, 360, 38, 28981, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 38, 28981, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 19590, 4348, 659, 15547, 14, 23499, 360, 19590, 4348, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 19590, 4348, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 19590, 4348, 397, 659, 15547, 14, 23499, 360, 19590, 4348, 397, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 19590, 4348, 397, 659, 1318, 63, 466, 9, 339, 347, 511, 63, 6878, 63, 10019, 63, 3351, 8, 277, 304, 267, 10594, 18, 275, 22881, 8, 5508, 534, 6558, 63, 9500, 358, 267, 10594, 18, 14, 525, 4725, 19590, 4348, 297, 283, 19590, 4348, 397, 659, 13134, 3260, 12381, 267, 4123, 275, 11808, 342, 267, 1303, 493, 14, 952, 63, 573, 8, 1436, 12, 10594, 18, 9, 421, 199, 318, 5241, 837, 272, 5241, 275, 2882, 14, 10591, 342, 272, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 573, 493, 12, 22942, 29, 11390, 14, 21677, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3284, 3716, 1746, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3534, 3716, 1746, 430, 272, 372, 5241, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 885, 774, 534, 5768, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 13, 8128, 25155, 7567, 2290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 710, 2895, 199, 3, 787, 2597, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 6797, 15, 3761, 14, 199, 3, 199, 3, 961, 2032, 18581, 402, 5236, 638, 695, 406, 26675, 6326, 701, 5002, 199, 3, 8212, 83, 14, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6974, 199, 3, 7994, 436, 9610, 12, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 793, 8083, 199, 199, 646, 8868, 199, 646, 9796, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 29178, 14, 5819, 492, 11808, 12, 399, 12, 1318, 63, 466, 199, 504, 29178, 14, 3431, 492, 1303, 493, 12, 22881, 421, 199, 533, 5574, 3716, 1746, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 18259, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 358, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 1303, 63, 493, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 18259, 12, 283, 1715, 297, 283, 73, 1085, 78, 297, 283, 271, 297, 2511, 283, 7027, 63, 23229, 297, 283, 3431, 14, 573, 659, 283, 4848, 358, 267, 862, 26, 288, 10594, 275, 1303, 493, 14, 739, 63, 573, 8, 573, 63, 493, 9, 288, 291, 14, 629, 8, 18, 12, 822, 8, 7959, 430, 288, 291, 14, 629, 360, 774, 4761, 297, 10594, 14, 1715, 9, 288, 291, 14, 629, 360, 16, 14, 17, 297, 10594, 14, 1023, 9, 288, 291, 14, 629, 360, 933, 618, 297, 10594, 459, 1700, 2278, 875, 9, 288, 291, 14, 629, 2941, 19590, 72, 270, 618, 297, 283, 19590, 72, 270, 621, 287, 995, 2490, 10594, 459, 9664, 2278, 875, 9, 267, 3753, 26, 288, 1303, 63, 493, 14, 1600, 342, 421, 199, 533, 6990, 3716, 1746, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 29411, 8, 277, 304, 267, 327, 7523, 314, 1406, 365, 3355, 370, 314, 1642, 2397, 880, 626, 2399, 5960, 267, 327, 883, 506, 6781, 370, 1006, 13372, 3788, 701, 27650, 934, 1320, 6011, 267, 327, 334, 8764, 4039, 1006, 3788, 787, 19353, 6702, 370, 2649, 9, 267, 10594, 275, 22881, 8, 5508, 534, 287, 63, 1668, 358, 267, 10594, 14, 525, 8, 85, 31150, 18087, 199, 2, 2714, 13, 804, 26, 1318, 15, 6104, 27, 5960, 29, 1624, 13, 24, 60, 78, 2, 199, 2, 2714, 13, 11761, 13, 7630, 26, 1695, 2075, 60, 78, 12310, 267, 10594, 14, 525, 8, 85, 360, 1421, 659, 283, 54, 19194, 358, 267, 10594, 14, 525, 1332, 85, 360, 10924, 365, 659, 399, 360, 10924, 787, 3855, 334, 85, 360, 21658, 486, 1892, 84, 659, 399, 360, 21658, 486, 1892, 84, 7058, 267, 10594, 14, 525, 8, 85, 360, 38, 28981, 659, 4074, 267, 10594, 14, 525, 4725, 19590, 4348, 297, 283, 19590, 4348, 397, 659, 13134, 12381, 267, 4123, 275, 11808, 342, 267, 1303, 493, 14, 952, 63, 573, 8, 1436, 12, 10594, 9, 267, 4123, 14, 5507, 8, 16, 9, 267, 15547, 275, 9796, 14, 15306, 934, 1320, 6011, 8, 3997, 29, 1436, 9, 267, 291, 14, 629, 8, 85, 360, 54, 19194, 659, 15547, 14, 23499, 360, 1421, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 1421, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 21658, 486, 1892, 84, 659, 15547, 14, 324, 5152, 360, 10924, 365, 297, 283, 10924, 787, 297, 413, 430, 267, 702, 1228, 8, 13982, 14, 324, 5152, 360, 10924, 365, 297, 283, 10924, 787, 297, 413, 395, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 38, 28981, 659, 15547, 14, 23499, 360, 38, 28981, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 38, 28981, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 19590, 4348, 659, 15547, 14, 23499, 360, 19590, 4348, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 19590, 4348, 659, 1318, 63, 466, 9, 267, 291, 14, 629, 8, 85, 360, 19590, 4348, 397, 659, 15547, 14, 23499, 360, 19590, 4348, 397, 1333, 267, 702, 1228, 8, 13982, 14, 23499, 360, 19590, 4348, 397, 659, 1318, 63, 466, 9, 339, 347, 511, 63, 6878, 63, 10019, 63, 3351, 8, 277, 304, 267, 10594, 18, 275, 22881, 8, 5508, 534, 6558, 63, 9500, 358, 267, 10594, 18, 14, 525, 4725, 19590, 4348, 297, 283, 19590, 4348, 397, 659, 13134, 3260, 12381, 267, 4123, 275, 11808, 342, 267, 1303, 493, 14, 952, 63, 573, 8, 1436, 12, 10594, 18, 9, 421, 199, 318, 5241, 837, 272, 5241, 275, 2882, 14, 10591, 342, 272, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 573, 493, 12, 22942, 29, 11390, 14, 21677, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3284, 3716, 1746, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3534, 3716, 1746, 430, 272, 372, 5241, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 885, 774, 534, 5768, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
epssy/hue
desktop/core/src/desktop/migrations/0011_auto__chg_field_document2_uuid.py
35
8668
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'Document2.uuid' db.alter_column(u'desktop_document2', 'uuid', self.gf('django.db.models.fields.CharField')(max_length=36)) def backwards(self, orm): # Changing field 'Document2.uuid' db.alter_column(u'desktop_document2', 'uuid', self.gf('django.db.models.fields.CharField')(max_length=32)) models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, u'desktop.document': { 'Meta': {'object_name': 'Document'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), 'description': ('django.db.models.fields.TextField', [], {'default': "''"}), 'extra': ('django.db.models.fields.TextField', [], {'default': "''"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'doc_owner'", 'to': u"orm['auth.User']"}), 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['desktop.DocumentTag']", 'db_index': 'True', 'symmetrical': 'False'}), 'version': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}) }, u'desktop.document2': { 'Meta': {'object_name': 'Document2'}, 'data': ('django.db.models.fields.TextField', [], {'default': "'{}'"}), 'dependencies': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'dependencies_rel_+'", 'db_index': 'True', 'to': u"orm['desktop.Document2']"}), 'description': ('django.db.models.fields.TextField', [], {'default': "''"}), 'extra': ('django.db.models.fields.TextField', [], {'default': "''"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_history': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'doc2_owner'", 'to': u"orm['auth.User']"}), 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'tags_rel_+'", 'db_index': 'True', 'to': u"orm['desktop.Document2']"}), 'type': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'db_index': 'True'}), 'uuid': ('django.db.models.fields.CharField', [], {'default': "'cf6e8b84-d8c8-4b44-a390-f2bd30b178ef'", 'max_length': '36', 'db_index': 'True'}), 'version': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'db_index': 'True'}) }, u'desktop.documentpermission': { 'Meta': {'object_name': 'DocumentPermission'}, 'doc': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['desktop.Document']"}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'db_index': 'True', 'to': u"orm['auth.Group']", 'db_table': "'documentpermission_groups'", 'symmetrical': 'False'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'perms': ('django.db.models.fields.TextField', [], {'default': "'read'"}), 'users': ('django.db.models.fields.related.ManyToManyField', [], {'db_index': 'True', 'to': u"orm['auth.User']", 'db_table': "'documentpermission_users'", 'symmetrical': 'False'}) }, u'desktop.documenttag': { 'Meta': {'object_name': 'DocumentTag'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}), 'tag': ('django.db.models.fields.SlugField', [], {'max_length': '50'}) }, u'desktop.settings': { 'Meta': {'object_name': 'Settings'}, 'collect_usage': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'tours_and_tutorials': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}) }, u'desktop.userpreferences': { 'Meta': {'object_name': 'UserPreferences'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'key': ('django.db.models.fields.CharField', [], {'max_length': '20'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}), 'value': ('django.db.models.fields.TextField', [], {'max_length': '4096'}) } } complete_apps = ['desktop']
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5564, 18, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 5121, 397, 17827, 63, 3554, 18, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1344, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5564, 18, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 5121, 397, 17827, 63, 3554, 18, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5564, 18, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 5121, 397, 17827, 63, 3554, 18, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 1344, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5564, 18, 14, 2580, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 5121, 397, 17827, 63, 3554, 18, 297, 283, 2580, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 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,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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 ]
dhoffman34/django
django/contrib/sessions/middleware.py
44
2589
from importlib import import_module import time from django.conf import settings from django.utils.cache import patch_vary_headers from django.utils.http import cookie_date class SessionMiddleware(object): def __init__(self): engine = import_module(settings.SESSION_ENGINE) self.SessionStore = engine.SessionStore def process_request(self, request): session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) request.session = self.SessionStore(session_key) def process_response(self, request, response): """ If request.session was modified, or if the configuration is to save the session every time, save the changes and set a session cookie or delete the session cookie if the session has been emptied. """ try: accessed = request.session.accessed modified = request.session.modified empty = request.session.is_empty() except AttributeError: pass else: # First check if we need to delete this cookie. # The session should be deleted only if the session is entirely empty if settings.SESSION_COOKIE_NAME in request.COOKIES and empty: response.delete_cookie(settings.SESSION_COOKIE_NAME) else: if accessed: patch_vary_headers(response, ('Cookie',)) if modified or settings.SESSION_SAVE_EVERY_REQUEST: if request.session.get_expire_at_browser_close(): max_age = None expires = None else: max_age = request.session.get_expiry_age() expires_time = time.time() + max_age expires = cookie_date(expires_time) # Save the session data and refresh the client cookie. # Skip session save for 500 responses, refs #3881. if response.status_code != 500: request.session.save() response.set_cookie(settings.SESSION_COOKIE_NAME, request.session.session_key, max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, path=settings.SESSION_COOKIE_PATH, secure=settings.SESSION_COOKIE_SECURE or None, httponly=settings.SESSION_COOKIE_HTTPONLY or None) return response
bsd-3-clause
[ 504, 14802, 492, 492, 63, 578, 199, 646, 900, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 1637, 492, 3371, 63, 21989, 63, 2139, 199, 504, 1639, 14, 1208, 14, 1014, 492, 5494, 63, 602, 421, 199, 533, 8596, 6608, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6869, 275, 492, 63, 578, 8, 1751, 14, 12763, 63, 15956, 9, 267, 291, 14, 4434, 5502, 275, 6869, 14, 4434, 5502, 339, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 2351, 63, 498, 275, 1056, 14, 12189, 2563, 14, 362, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 12, 488, 9, 267, 1056, 14, 1730, 275, 291, 14, 4434, 5502, 8, 1730, 63, 498, 9, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 408, 267, 982, 1056, 14, 1730, 1990, 6042, 12, 503, 340, 314, 2897, 365, 370, 3354, 314, 267, 2351, 4036, 900, 12, 3354, 314, 4493, 436, 663, 282, 2351, 5494, 503, 3145, 267, 314, 2351, 5494, 340, 314, 2351, 965, 2757, 9052, 29307, 14, 267, 408, 267, 862, 26, 288, 13810, 275, 1056, 14, 1730, 14, 29433, 288, 6042, 275, 1056, 14, 1730, 14, 5540, 288, 2701, 275, 1056, 14, 1730, 14, 374, 63, 1667, 342, 267, 871, 4281, 26, 288, 986, 267, 587, 26, 288, 327, 7758, 1104, 340, 781, 1929, 370, 3145, 642, 5494, 14, 288, 327, 710, 2351, 1077, 506, 5463, 1454, 340, 314, 2351, 365, 21926, 2701, 288, 340, 2202, 14, 12763, 63, 13665, 63, 2339, 315, 1056, 14, 12189, 2563, 436, 2701, 26, 355, 1177, 14, 1807, 63, 5306, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 9, 288, 587, 26, 355, 340, 13810, 26, 490, 3371, 63, 21989, 63, 2139, 8, 1310, 12, 661, 7810, 16829, 355, 340, 6042, 503, 2202, 14, 12763, 63, 19318, 63, 27362, 57, 63, 6780, 26, 490, 340, 1056, 14, 1730, 14, 362, 63, 14691, 63, 292, 63, 5750, 63, 1600, 837, 717, 1390, 63, 474, 275, 488, 717, 12261, 275, 488, 490, 587, 26, 717, 1390, 63, 474, 275, 1056, 14, 1730, 14, 362, 63, 16844, 63, 474, 342, 717, 12261, 63, 521, 275, 900, 14, 521, 342, 435, 1390, 63, 474, 717, 12261, 275, 5494, 63, 602, 8, 12342, 63, 521, 9, 490, 327, 11063, 314, 2351, 666, 436, 9236, 314, 1890, 5494, 14, 490, 327, 8232, 2351, 3354, 367, 6891, 9320, 12, 15749, 327, 11403, 17, 14, 490, 340, 1177, 14, 1205, 63, 600, 1137, 6891, 26, 717, 1056, 14, 1730, 14, 2117, 342, 717, 1177, 14, 409, 63, 5306, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 12, 1816, 1056, 14, 1730, 14, 1730, 63, 498, 12, 1390, 63, 474, 29, 988, 63, 474, 12, 1816, 12261, 29, 12342, 12, 2881, 29, 1751, 14, 12763, 63, 13665, 63, 7378, 12, 1816, 931, 29, 1751, 14, 12763, 63, 13665, 63, 3243, 12, 1816, 11153, 29, 1751, 14, 12763, 63, 13665, 63, 20696, 503, 488, 12, 1816, 22768, 26960, 29, 1751, 14, 12763, 63, 13665, 63, 2856, 10452, 503, 488, 9, 267, 372, 1177, 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 ]
[ 14802, 492, 492, 63, 578, 199, 646, 900, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 1637, 492, 3371, 63, 21989, 63, 2139, 199, 504, 1639, 14, 1208, 14, 1014, 492, 5494, 63, 602, 421, 199, 533, 8596, 6608, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6869, 275, 492, 63, 578, 8, 1751, 14, 12763, 63, 15956, 9, 267, 291, 14, 4434, 5502, 275, 6869, 14, 4434, 5502, 339, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 2351, 63, 498, 275, 1056, 14, 12189, 2563, 14, 362, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 12, 488, 9, 267, 1056, 14, 1730, 275, 291, 14, 4434, 5502, 8, 1730, 63, 498, 9, 339, 347, 2112, 63, 1310, 8, 277, 12, 1056, 12, 1177, 304, 267, 408, 267, 982, 1056, 14, 1730, 1990, 6042, 12, 503, 340, 314, 2897, 365, 370, 3354, 314, 267, 2351, 4036, 900, 12, 3354, 314, 4493, 436, 663, 282, 2351, 5494, 503, 3145, 267, 314, 2351, 5494, 340, 314, 2351, 965, 2757, 9052, 29307, 14, 267, 408, 267, 862, 26, 288, 13810, 275, 1056, 14, 1730, 14, 29433, 288, 6042, 275, 1056, 14, 1730, 14, 5540, 288, 2701, 275, 1056, 14, 1730, 14, 374, 63, 1667, 342, 267, 871, 4281, 26, 288, 986, 267, 587, 26, 288, 327, 7758, 1104, 340, 781, 1929, 370, 3145, 642, 5494, 14, 288, 327, 710, 2351, 1077, 506, 5463, 1454, 340, 314, 2351, 365, 21926, 2701, 288, 340, 2202, 14, 12763, 63, 13665, 63, 2339, 315, 1056, 14, 12189, 2563, 436, 2701, 26, 355, 1177, 14, 1807, 63, 5306, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 9, 288, 587, 26, 355, 340, 13810, 26, 490, 3371, 63, 21989, 63, 2139, 8, 1310, 12, 661, 7810, 16829, 355, 340, 6042, 503, 2202, 14, 12763, 63, 19318, 63, 27362, 57, 63, 6780, 26, 490, 340, 1056, 14, 1730, 14, 362, 63, 14691, 63, 292, 63, 5750, 63, 1600, 837, 717, 1390, 63, 474, 275, 488, 717, 12261, 275, 488, 490, 587, 26, 717, 1390, 63, 474, 275, 1056, 14, 1730, 14, 362, 63, 16844, 63, 474, 342, 717, 12261, 63, 521, 275, 900, 14, 521, 342, 435, 1390, 63, 474, 717, 12261, 275, 5494, 63, 602, 8, 12342, 63, 521, 9, 490, 327, 11063, 314, 2351, 666, 436, 9236, 314, 1890, 5494, 14, 490, 327, 8232, 2351, 3354, 367, 6891, 9320, 12, 15749, 327, 11403, 17, 14, 490, 340, 1177, 14, 1205, 63, 600, 1137, 6891, 26, 717, 1056, 14, 1730, 14, 2117, 342, 717, 1177, 14, 409, 63, 5306, 8, 1751, 14, 12763, 63, 13665, 63, 2339, 12, 1816, 1056, 14, 1730, 14, 1730, 63, 498, 12, 1390, 63, 474, 29, 988, 63, 474, 12, 1816, 12261, 29, 12342, 12, 2881, 29, 1751, 14, 12763, 63, 13665, 63, 7378, 12, 1816, 931, 29, 1751, 14, 12763, 63, 13665, 63, 3243, 12, 1816, 11153, 29, 1751, 14, 12763, 63, 13665, 63, 20696, 503, 488, 12, 1816, 22768, 26960, 29, 1751, 14, 12763, 63, 13665, 63, 2856, 10452, 503, 488, 9, 267, 372, 1177, 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, 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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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 ]
mbauskar/phrerp
erpnext/support/doctype/support_email_settings/support_email_settings.py
36
1438
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt # For license information, please see license.txt from __future__ import unicode_literals import frappe from frappe import _ from frappe.utils import cint from frappe.model.document import Document from frappe.utils.email_lib.receive import POP3Mailbox import _socket, poplib class SupportEmailSettings(Document): def validate(self): """ Checks support ticket email settings """ if cint(self.sync_support_mails) and self.mail_server and not frappe.local.flags.in_patch: inc_email = frappe._dict(self.as_dict()) # inc_email.encode() inc_email.host = self.mail_server inc_email.use_ssl = self.use_ssl try: err_msg = _('User Name or Support Password missing. Please enter and try again.') if not (self.mail_login and self.mail_password): raise AttributeError, err_msg inc_email.username = self.mail_login inc_email.password = self.mail_password except AttributeError, e: frappe.msgprint(err_msg) raise pop_mb = POP3Mailbox(inc_email) try: pop_mb.connect() except _socket.error, e: # Invalid mail server -- due to refusing connection frappe.msgprint(_('Invalid Mail Server. Please rectify and try again.')) raise except poplib.error_proto, e: frappe.msgprint(_('Invalid User Name or Support Password. Please rectify and try again.')) raise
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 6950, 492, 485, 199, 504, 6950, 14, 1208, 492, 286, 442, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 6950, 14, 1208, 14, 2123, 63, 773, 14, 9391, 492, 510, 1938, 19, 13681, 1977, 199, 646, 485, 3450, 12, 4560, 773, 199, 199, 533, 12502, 7035, 5268, 8, 5564, 304, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 624, 686, 198, 11834, 2291, 12052, 3031, 2202, 507, 198, 624, 507, 198, 692, 286, 442, 8, 277, 14, 5186, 63, 4058, 63, 1198, 83, 9, 436, 291, 14, 1198, 63, 1000, 436, 440, 6950, 14, 1832, 14, 2469, 14, 262, 63, 2068, 26, 686, 198, 6559, 63, 2123, 275, 6950, 423, 807, 8, 277, 14, 305, 63, 807, 1012, 686, 198, 3, 12864, 63, 2123, 14, 2143, 342, 686, 198, 6559, 63, 2123, 14, 1102, 275, 291, 14, 1198, 63, 1000, 686, 198, 6559, 63, 2123, 14, 1180, 63, 4266, 275, 291, 14, 1180, 63, 4266, 686, 198, 893, 26, 1585, 198, 1508, 63, 1328, 275, 4018, 1899, 2812, 503, 12502, 13635, 4124, 14, 7754, 9509, 436, 862, 4020, 2659, 1585, 198, 692, 440, 334, 277, 14, 1198, 63, 2886, 436, 291, 14, 1198, 63, 2060, 304, 1871, 198, 3730, 4281, 12, 2329, 63, 1328, 1585, 198, 6559, 63, 2123, 14, 2473, 275, 291, 14, 1198, 63, 2886, 1585, 198, 6559, 63, 2123, 14, 2060, 275, 291, 14, 1198, 63, 2060, 686, 198, 2590, 4281, 12, 325, 26, 1585, 198, 9098, 14, 1328, 1361, 8, 1508, 63, 1328, 9, 1585, 198, 3730, 6319, 198, 1935, 63, 887, 275, 510, 1938, 19, 13681, 1977, 8, 6559, 63, 2123, 9, 6319, 198, 893, 26, 1585, 198, 1935, 63, 887, 14, 2242, 342, 686, 198, 2590, 485, 3450, 14, 705, 12, 325, 26, 1585, 198, 3, 6378, 6016, 1654, 1553, 7037, 370, 2984, 4941, 1950, 1585, 198, 9098, 14, 1328, 1361, 6723, 3364, 18027, 7146, 14, 7754, 6488, 3338, 436, 862, 4020, 12459, 1585, 198, 3730, 686, 198, 2590, 4560, 773, 14, 705, 63, 2625, 12, 325, 26, 1585, 198, 9098, 14, 1328, 1361, 6723, 3364, 2876, 2812, 503, 12502, 13635, 14, 7754, 6488, 3338, 436, 862, 4020, 12459, 1585, 198, 3730, 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 ]
[ 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 6950, 492, 485, 199, 504, 6950, 14, 1208, 492, 286, 442, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 6950, 14, 1208, 14, 2123, 63, 773, 14, 9391, 492, 510, 1938, 19, 13681, 1977, 199, 646, 485, 3450, 12, 4560, 773, 199, 199, 533, 12502, 7035, 5268, 8, 5564, 304, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 624, 686, 198, 11834, 2291, 12052, 3031, 2202, 507, 198, 624, 507, 198, 692, 286, 442, 8, 277, 14, 5186, 63, 4058, 63, 1198, 83, 9, 436, 291, 14, 1198, 63, 1000, 436, 440, 6950, 14, 1832, 14, 2469, 14, 262, 63, 2068, 26, 686, 198, 6559, 63, 2123, 275, 6950, 423, 807, 8, 277, 14, 305, 63, 807, 1012, 686, 198, 3, 12864, 63, 2123, 14, 2143, 342, 686, 198, 6559, 63, 2123, 14, 1102, 275, 291, 14, 1198, 63, 1000, 686, 198, 6559, 63, 2123, 14, 1180, 63, 4266, 275, 291, 14, 1180, 63, 4266, 686, 198, 893, 26, 1585, 198, 1508, 63, 1328, 275, 4018, 1899, 2812, 503, 12502, 13635, 4124, 14, 7754, 9509, 436, 862, 4020, 2659, 1585, 198, 692, 440, 334, 277, 14, 1198, 63, 2886, 436, 291, 14, 1198, 63, 2060, 304, 1871, 198, 3730, 4281, 12, 2329, 63, 1328, 1585, 198, 6559, 63, 2123, 14, 2473, 275, 291, 14, 1198, 63, 2886, 1585, 198, 6559, 63, 2123, 14, 2060, 275, 291, 14, 1198, 63, 2060, 686, 198, 2590, 4281, 12, 325, 26, 1585, 198, 9098, 14, 1328, 1361, 8, 1508, 63, 1328, 9, 1585, 198, 3730, 6319, 198, 1935, 63, 887, 275, 510, 1938, 19, 13681, 1977, 8, 6559, 63, 2123, 9, 6319, 198, 893, 26, 1585, 198, 1935, 63, 887, 14, 2242, 342, 686, 198, 2590, 485, 3450, 14, 705, 12, 325, 26, 1585, 198, 3, 6378, 6016, 1654, 1553, 7037, 370, 2984, 4941, 1950, 1585, 198, 9098, 14, 1328, 1361, 6723, 3364, 18027, 7146, 14, 7754, 6488, 3338, 436, 862, 4020, 12459, 1585, 198, 3730, 686, 198, 2590, 4560, 773, 14, 705, 63, 2625, 12, 325, 26, 1585, 198, 9098, 14, 1328, 1361, 6723, 3364, 2876, 2812, 503, 12502, 13635, 14, 7754, 6488, 3338, 436, 862, 4020, 12459, 1585, 198, 3730, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Reuben-Thorpe/Code.Eval
code.eval/01-hard/as_quick_as_a_flash/as.quick.as.a.flash.py
1
1235
# Reuben Thorpe (2016), CodeEval [As Quick As A Flash v1.0] from sys import argv def swap(seq, x, y): seq[x], seq[y] = seq[y], seq[x] def q_sort_pivots(seq, begin, end): """ Code Evals implimentation of the quick sort algorithm, returns the number of pivots enacted during a complete sort. """ if begin < end: pivot = seq[begin] pivot_pos = begin left = begin+1 right = end while left < right: while (left < right and seq[right] >= pivot): right -= 1 if seq[right] < pivot: swap(seq, pivot_pos, right) pivot_pos = right if left < right: while (left < right and seq[left] <= pivot): left += 1 if seq[left] > pivot: swap(seq, pivot_pos, left) pivot_pos = left return(1 + q_sort_pivots(seq, begin, pivot_pos-1) + q_sort_pivots(seq, pivot_pos+1, end)) else: return(0) if __name__ == "__main__": for seq in open(argv[1], "r"): seq = [int(num) for num in seq.split()] N = len(seq) - 1 print(q_sort_pivots(seq, 0, N))
gpl-3.0
[ 3, 799, 456, 287, 3868, 269, 321, 334, 9261, 395, 5495, 10006, 359, 2822, 27534, 3709, 437, 11040, 1119, 373, 17, 14, 16, 61, 199, 504, 984, 492, 9238, 421, 199, 318, 11413, 8, 3610, 12, 671, 12, 612, 304, 272, 5412, 59, 88, 467, 5412, 59, 89, 61, 275, 5412, 59, 89, 467, 5412, 59, 88, 61, 421, 199, 318, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 5386, 12, 1284, 304, 272, 408, 267, 5495, 662, 3643, 1742, 317, 3117, 402, 314, 12530, 4069, 5563, 12, 2529, 314, 267, 1329, 402, 22292, 83, 655, 645, 471, 5309, 282, 4890, 4069, 14, 272, 408, 339, 340, 5386, 665, 1284, 26, 267, 22292, 275, 5412, 59, 5037, 61, 267, 22292, 63, 1712, 275, 5386, 267, 3602, 275, 5386, 11, 17, 267, 2451, 275, 1284, 398, 1830, 3602, 665, 2451, 26, 288, 1830, 334, 3039, 665, 2451, 436, 5412, 59, 1019, 61, 2356, 22292, 304, 355, 2451, 4862, 413, 953, 340, 5412, 59, 1019, 61, 665, 22292, 26, 355, 11413, 8, 3610, 12, 22292, 63, 1712, 12, 2451, 9, 355, 22292, 63, 1712, 275, 2451, 953, 340, 3602, 665, 2451, 26, 355, 1830, 334, 3039, 665, 2451, 436, 5412, 59, 3039, 61, 2695, 22292, 304, 490, 3602, 847, 413, 2234, 340, 5412, 59, 3039, 61, 690, 22292, 26, 490, 11413, 8, 3610, 12, 22292, 63, 1712, 12, 3602, 9, 490, 22292, 63, 1712, 275, 3602, 398, 372, 8, 17, 435, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 5386, 12, 22292, 63, 1712, 13, 17, 9, 435, 2049, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 22292, 63, 1712, 11, 17, 12, 1284, 430, 339, 587, 26, 267, 372, 8, 16, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 367, 5412, 315, 1551, 8, 3020, 59, 17, 467, 298, 82, 2349, 267, 5412, 275, 359, 442, 8, 1507, 9, 367, 1967, 315, 5412, 14, 1294, 5106, 267, 653, 275, 822, 8, 3610, 9, 446, 413, 267, 870, 8, 81, 63, 3191, 63, 21558, 83, 8, 3610, 12, 378, 12, 653, 430, 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 ]
[ 799, 456, 287, 3868, 269, 321, 334, 9261, 395, 5495, 10006, 359, 2822, 27534, 3709, 437, 11040, 1119, 373, 17, 14, 16, 61, 199, 504, 984, 492, 9238, 421, 199, 318, 11413, 8, 3610, 12, 671, 12, 612, 304, 272, 5412, 59, 88, 467, 5412, 59, 89, 61, 275, 5412, 59, 89, 467, 5412, 59, 88, 61, 421, 199, 318, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 5386, 12, 1284, 304, 272, 408, 267, 5495, 662, 3643, 1742, 317, 3117, 402, 314, 12530, 4069, 5563, 12, 2529, 314, 267, 1329, 402, 22292, 83, 655, 645, 471, 5309, 282, 4890, 4069, 14, 272, 408, 339, 340, 5386, 665, 1284, 26, 267, 22292, 275, 5412, 59, 5037, 61, 267, 22292, 63, 1712, 275, 5386, 267, 3602, 275, 5386, 11, 17, 267, 2451, 275, 1284, 398, 1830, 3602, 665, 2451, 26, 288, 1830, 334, 3039, 665, 2451, 436, 5412, 59, 1019, 61, 2356, 22292, 304, 355, 2451, 4862, 413, 953, 340, 5412, 59, 1019, 61, 665, 22292, 26, 355, 11413, 8, 3610, 12, 22292, 63, 1712, 12, 2451, 9, 355, 22292, 63, 1712, 275, 2451, 953, 340, 3602, 665, 2451, 26, 355, 1830, 334, 3039, 665, 2451, 436, 5412, 59, 3039, 61, 2695, 22292, 304, 490, 3602, 847, 413, 2234, 340, 5412, 59, 3039, 61, 690, 22292, 26, 490, 11413, 8, 3610, 12, 22292, 63, 1712, 12, 3602, 9, 490, 22292, 63, 1712, 275, 3602, 398, 372, 8, 17, 435, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 5386, 12, 22292, 63, 1712, 13, 17, 9, 435, 2049, 1894, 63, 3191, 63, 21558, 83, 8, 3610, 12, 22292, 63, 1712, 11, 17, 12, 1284, 430, 339, 587, 26, 267, 372, 8, 16, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 367, 5412, 315, 1551, 8, 3020, 59, 17, 467, 298, 82, 2349, 267, 5412, 275, 359, 442, 8, 1507, 9, 367, 1967, 315, 5412, 14, 1294, 5106, 267, 653, 275, 822, 8, 3610, 9, 446, 413, 267, 870, 8, 81, 63, 3191, 63, 21558, 83, 8, 3610, 12, 378, 12, 653, 430, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
migueldsw/TL-DA-TF
NETWORKS/vgg.py
1
10291
# from tflearn examples: https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py """ Very Deep Convolutional Networks for Large-Scale Visual Recognition. Applying VGG 11 and 16-layers convolutional network to MNIST and SVHN Dataset classification task. 28x28x3 shape References: Very Deep Convolutional Networks for Large-Scale Image Recognition. K. Simonyan, A. Zisserman. arXiv technical report, 2014. Links: http://arxiv.org/pdf/1409.1556 """ from __future__ import division, print_function, absolute_import from .model_helper import transfer_params_decode, define_layers from tflearn.layers.core import input_data, dropout, fully_connected from tflearn.layers.conv import conv_2d, max_pool_2d from tflearn.layers.estimator import regression # Building 'VGG-16 Network' def build_vgg16(learning_rate,num_class=10): network = input_data(shape=[None, 28, 28, 3], name='input') network = conv_2d(network, 8, 3, activation='relu', scope='conv1_1') network = conv_2d(network, 8, 3, activation='relu', scope='conv1_2') network = max_pool_2d(network, 2, strides=2, name='maxpool1') network = conv_2d(network, 16, 3, activation='relu', scope='conv2_1') network = conv_2d(network, 16, 3, activation='relu', scope='conv2_2') network = max_pool_2d(network, 2, strides=2, name='maxpool2') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_1') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_2') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_3') network = max_pool_2d(network, 2, strides=2, name='maxpool3') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_1') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_2') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_3') network = max_pool_2d(network, 2, strides=2, name='maxpool4') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_1') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_2') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_3') network = max_pool_2d(network, 2, strides=2, name='maxpool5') network = fully_connected(network, 512, activation='relu', scope='fc6') network = dropout(network, 0.5, name='dropout1') network = fully_connected(network, 512, activation='relu', scope='fc7') network = dropout(network, 0.5, name='dropout2') network = fully_connected(network, num_class, activation='softmax', scope='fc8') network = regression(network, optimizer='rmsprop', loss='categorical_crossentropy', learning_rate=learning_rate) return network # Building 'VGG-11 Network' def build_vgg11(learning_rate, num_class=10): network = input_data(shape=[None, 28, 28, 3], name='input') network = conv_2d(network, 8, 3, activation='relu', scope='conv1_1') network = max_pool_2d(network, 2, strides=2, name='maxpool1') network = conv_2d(network, 16, 3, activation='relu', scope='conv2_1') network = max_pool_2d(network, 2, strides=2, name='maxpool2') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_1') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_2') network = max_pool_2d(network, 2, strides=2, name='maxpool3') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_1') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_2') network = max_pool_2d(network, 2, strides=2, name='maxpool4') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_1') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_2') network = max_pool_2d(network, 2, strides=2, name='maxpool5') network = fully_connected(network, 512, activation='relu', scope='fc6') network = dropout(network, 0.5, name='dropout1') network = fully_connected(network, 512, activation='relu', scope='fc7') network = dropout(network, 0.5, name='dropout2') network = fully_connected(network, num_class, activation='softmax', scope='fc8') network = regression(network, optimizer='rmsprop', loss='categorical_crossentropy', learning_rate=learning_rate) return network # # Retraining (Finetuning) Example with vgg.tflearn. Using weights from VGG-11 or 16 model to retrain # network for a new task.All weights are restored except # last layer (softmax) that will be retrained to match the new task (finetuning). # " def vgg11(input, num_class, transf_params_encoded=None): if transf_params_encoded is None: transf_params_encoded = define_layers(11) transf_params = transfer_params_decode(transf_params_encoded) network = conv_2d(input, 8, 3, activation='relu', scope='conv1_1', restore=transf_params[0][0], trainable=transf_params[0][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool1') network = conv_2d(network, 16, 3, activation='relu', scope='conv2_1', restore=transf_params[1][0], trainable=transf_params[1][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool2') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_1', restore=transf_params[2][0], trainable=transf_params[2][1]) network = conv_2d(network, 32, 3, activation='relu', scope='conv3_2', restore=transf_params[3][0], trainable=transf_params[3][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool3') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_1', restore=transf_params[4][0], trainable=transf_params[4][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv4_2', restore=transf_params[5][0], trainable=transf_params[5][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool4') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_1', restore=transf_params[6][0], trainable=transf_params[6][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv5_2', restore=transf_params[7][0], trainable=transf_params[7][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool5') network = fully_connected(network, 512, activation='relu', scope='fc6', restore=transf_params[8][0], trainable=transf_params[8][1]) network = dropout(network, 0.5, name='dropout1') network = fully_connected(network, 512, activation='relu', scope='fc7', restore=transf_params[9][0], trainable=transf_params[9][1]) network = dropout(network, 0.5, name='dropout2') network = fully_connected(network, num_class, activation='softmax', scope='fc8', restore=transf_params[10][0], trainable=transf_params[10][1]) return network def vgg16(input, num_class, transf_params_encoded=None): if transf_params_encoded is None: transf_params_encoded = define_layers(16) transf_params = transfer_params_decode(transf_params_encoded) network = conv_2d(input, 8, 3, activation='relu', scope='conv1_1', restore=transf_params[0][0], trainable=transf_params[0][1]) network = conv_2d(network, 8, 3, activation='relu', scope='conv1_2', restore=transf_params[1][0], trainable=transf_params[1][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool1') network = conv_2d(network, 16, 3, activation='relu', scope='conv2_1', restore=transf_params[2][0], trainable=transf_params[2][1]) network = conv_2d(network, 16, 3, activation='relu', scope='conv2_2', restore=transf_params[3][0], trainable=transf_params[3][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool2') network = conv_2d(network, 32, 3, activation='relu', scope='conv3_1', restore=transf_params[4][0], trainable=transf_params[4][1]) network = conv_2d(network, 32, 3, activation='relu', scope='conv3_2', restore=transf_params[5][0], trainable=transf_params[5][1]) network = conv_2d(network, 32, 3, activation='relu', scope='conv3_3', restore=transf_params[6][0], trainable=transf_params[6][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool3') network = conv_2d(network, 64, 3, activation='relu', scope='conv4_1', restore=transf_params[7][0], trainable=transf_params[7][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv4_2', restore=transf_params[8][0], trainable=transf_params[8][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv4_3', restore=transf_params[9][0], trainable=transf_params[9][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool4') network = conv_2d(network, 64, 3, activation='relu', scope='conv5_1', restore=transf_params[10][0], trainable=transf_params[10][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv5_2', restore=transf_params[11][0], trainable=transf_params[11][1]) network = conv_2d(network, 64, 3, activation='relu', scope='conv5_3', restore=transf_params[12][0], trainable=transf_params[12][1]) network = max_pool_2d(network, 2, strides=2, name='maxpool5') network = fully_connected(network, 512, activation='relu', scope='fc6', restore=transf_params[13][0], trainable=transf_params[13][1]) network = dropout(network, 0.5, name='dropout1') network = fully_connected(network, 512, activation='relu', scope='fc7', restore=transf_params[14][0], trainable=transf_params[14][1]) network = dropout(network, 0.5, name='dropout2') network = fully_connected(network, num_class, activation='softmax', scope='fc8', restore=transf_params[15][0], trainable=transf_params[15][1]) return network
apache-2.0
[ 3, 687, 2833, 4643, 7251, 26, 4178, 921, 5031, 14, 957, 15, 3249, 4643, 15, 3249, 4643, 15, 6582, 15, 4133, 15, 8589, 15, 4782, 15, 27948, 63, 1200, 14, 647, 199, 199, 624, 812, 994, 577, 7840, 19140, 3347, 279, 17138, 367, 29095, 13, 9944, 14702, 799, 6862, 15415, 14, 199, 2640, 6670, 812, 2916, 4119, 436, 3193, 13, 4359, 17461, 279, 2784, 370, 603, 25392, 436, 14056, 23084, 199, 9271, 12505, 2120, 14, 7294, 88, 1651, 88, 19, 2215, 199, 15242, 26, 272, 812, 994, 577, 7840, 19140, 3347, 279, 17138, 367, 29095, 13, 9944, 6047, 799, 6862, 15415, 14, 272, 1804, 14, 10751, 5220, 290, 12, 437, 14, 3107, 374, 332, 1237, 14, 601, 56, 1003, 32742, 3622, 12, 6927, 14, 199, 16974, 26, 272, 1455, 921, 27290, 14, 1308, 15, 5607, 15, 1079, 1643, 14, 1046, 1367, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 504, 1275, 1238, 63, 3676, 492, 9307, 63, 1162, 63, 2708, 12, 5627, 63, 4359, 199, 504, 2833, 4643, 14, 4359, 14, 1018, 492, 1324, 63, 576, 12, 19795, 12, 9999, 63, 7113, 199, 504, 2833, 4643, 14, 4359, 14, 5598, 492, 8260, 63, 18, 68, 12, 1390, 63, 2293, 63, 18, 68, 199, 504, 2833, 4643, 14, 4359, 14, 8627, 492, 10864, 421, 199, 3, 6516, 316, 283, 54, 2916, 13, 975, 7220, 7, 199, 318, 1900, 63, 27948, 975, 8, 10546, 63, 1866, 12, 1507, 63, 533, 29, 709, 304, 272, 2784, 275, 1324, 63, 576, 8, 1392, 1524, 403, 12, 7294, 12, 7294, 12, 650, 467, 536, 534, 1210, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 18, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 17, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 18, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 18, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 19, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 20, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 21, 358, 339, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 10574, 12, 10361, 534, 12833, 297, 4194, 534, 3003, 22, 358, 272, 2784, 275, 19795, 8, 1200, 12, 378, 14, 21, 12, 536, 534, 17953, 17, 358, 272, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 10574, 12, 10361, 534, 12833, 297, 4194, 534, 3003, 23, 358, 272, 2784, 275, 19795, 8, 1200, 12, 378, 14, 21, 12, 536, 534, 17953, 18, 358, 272, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 1967, 63, 533, 12, 10361, 534, 16395, 297, 4194, 534, 3003, 24, 358, 339, 2784, 275, 10864, 8, 1200, 12, 586, 10736, 534, 24444, 4469, 297, 586, 5621, 534, 16810, 63, 20363, 1150, 7537, 297, 586, 9328, 63, 1866, 29, 10546, 63, 1866, 9, 272, 372, 2784, 421, 199, 3, 6516, 316, 283, 54, 2916, 13, 845, 7220, 7, 199, 318, 1900, 63, 27948, 845, 8, 10546, 63, 1866, 12, 1967, 63, 533, 29, 709, 304, 272, 2784, 275, 1324, 63, 576, 8, 1392, 1524, 403, 12, 7294, 12, 7294, 12, 650, 467, 536, 534, 1210, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 17, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 17, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 17, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 18, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 17, 358, 272, 2784, 275, 8260, 63 ]
[ 687, 2833, 4643, 7251, 26, 4178, 921, 5031, 14, 957, 15, 3249, 4643, 15, 3249, 4643, 15, 6582, 15, 4133, 15, 8589, 15, 4782, 15, 27948, 63, 1200, 14, 647, 199, 199, 624, 812, 994, 577, 7840, 19140, 3347, 279, 17138, 367, 29095, 13, 9944, 14702, 799, 6862, 15415, 14, 199, 2640, 6670, 812, 2916, 4119, 436, 3193, 13, 4359, 17461, 279, 2784, 370, 603, 25392, 436, 14056, 23084, 199, 9271, 12505, 2120, 14, 7294, 88, 1651, 88, 19, 2215, 199, 15242, 26, 272, 812, 994, 577, 7840, 19140, 3347, 279, 17138, 367, 29095, 13, 9944, 6047, 799, 6862, 15415, 14, 272, 1804, 14, 10751, 5220, 290, 12, 437, 14, 3107, 374, 332, 1237, 14, 601, 56, 1003, 32742, 3622, 12, 6927, 14, 199, 16974, 26, 272, 1455, 921, 27290, 14, 1308, 15, 5607, 15, 1079, 1643, 14, 1046, 1367, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 504, 1275, 1238, 63, 3676, 492, 9307, 63, 1162, 63, 2708, 12, 5627, 63, 4359, 199, 504, 2833, 4643, 14, 4359, 14, 1018, 492, 1324, 63, 576, 12, 19795, 12, 9999, 63, 7113, 199, 504, 2833, 4643, 14, 4359, 14, 5598, 492, 8260, 63, 18, 68, 12, 1390, 63, 2293, 63, 18, 68, 199, 504, 2833, 4643, 14, 4359, 14, 8627, 492, 10864, 421, 199, 3, 6516, 316, 283, 54, 2916, 13, 975, 7220, 7, 199, 318, 1900, 63, 27948, 975, 8, 10546, 63, 1866, 12, 1507, 63, 533, 29, 709, 304, 272, 2784, 275, 1324, 63, 576, 8, 1392, 1524, 403, 12, 7294, 12, 7294, 12, 650, 467, 536, 534, 1210, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 18, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 17, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 18, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 18, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 4337, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 19, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 19, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 20, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 20, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 17, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 18, 358, 272, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 5049, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 21, 63, 19, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 21, 358, 339, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 10574, 12, 10361, 534, 12833, 297, 4194, 534, 3003, 22, 358, 272, 2784, 275, 19795, 8, 1200, 12, 378, 14, 21, 12, 536, 534, 17953, 17, 358, 272, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 10574, 12, 10361, 534, 12833, 297, 4194, 534, 3003, 23, 358, 272, 2784, 275, 19795, 8, 1200, 12, 378, 14, 21, 12, 536, 534, 17953, 18, 358, 272, 2784, 275, 9999, 63, 7113, 8, 1200, 12, 1967, 63, 533, 12, 10361, 534, 16395, 297, 4194, 534, 3003, 24, 358, 339, 2784, 275, 10864, 8, 1200, 12, 586, 10736, 534, 24444, 4469, 297, 586, 5621, 534, 16810, 63, 20363, 1150, 7537, 297, 586, 9328, 63, 1866, 29, 10546, 63, 1866, 9, 272, 372, 2784, 421, 199, 3, 6516, 316, 283, 54, 2916, 13, 845, 7220, 7, 199, 318, 1900, 63, 27948, 845, 8, 10546, 63, 1866, 12, 1967, 63, 533, 29, 709, 304, 272, 2784, 275, 1324, 63, 576, 8, 1392, 1524, 403, 12, 7294, 12, 7294, 12, 650, 467, 536, 534, 1210, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 1695, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 17, 63, 17, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 17, 358, 339, 2784, 275, 8260, 63, 18, 68, 8, 1200, 12, 3193, 12, 650, 12, 10361, 534, 12833, 297, 4194, 534, 5598, 18, 63, 17, 358, 272, 2784, 275, 1390, 63, 2293, 63, 18, 68, 8, 1200, 12, 499, 12, 11883, 29, 18, 12, 536, 534, 988, 2293, 18, 358, 339, 2784, 275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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 ]
pprett/scikit-learn
sklearn/neural_network/rbm.py
46
12291
"""Restricted Boltzmann Machine """ # Authors: Yann N. Dauphin <dauphiya@iro.umontreal.ca> # Vlad Niculae # Gabriel Synnaeve # Lars Buitinck # License: BSD 3 clause import time import numpy as np import scipy.sparse as sp from ..base import BaseEstimator from ..base import TransformerMixin from ..externals.six.moves import xrange from ..utils import check_array from ..utils import check_random_state from ..utils import gen_even_slices from ..utils import issparse from ..utils.extmath import safe_sparse_dot from ..utils.extmath import log_logistic from ..utils.fixes import expit # logistic function from ..utils.validation import check_is_fitted class BernoulliRBM(BaseEstimator, TransformerMixin): """Bernoulli Restricted Boltzmann Machine (RBM). A Restricted Boltzmann Machine with binary visible units and binary hidden units. Parameters are estimated using Stochastic Maximum Likelihood (SML), also known as Persistent Contrastive Divergence (PCD) [2]. The time complexity of this implementation is ``O(d ** 2)`` assuming d ~ n_features ~ n_components. Read more in the :ref:`User Guide <rbm>`. Parameters ---------- n_components : int, optional Number of binary hidden units. learning_rate : float, optional The learning rate for weight updates. It is *highly* recommended to tune this hyper-parameter. Reasonable values are in the 10**[0., -3.] range. batch_size : int, optional Number of examples per minibatch. n_iter : int, optional Number of iterations/sweeps over the training dataset to perform during training. verbose : int, optional The verbosity level. The default, zero, means silent mode. random_state : integer or numpy.RandomState, optional A random number generator instance to define the state of the random permutations generator. If an integer is given, it fixes the seed. Defaults to the global numpy random number generator. Attributes ---------- intercept_hidden_ : array-like, shape (n_components,) Biases of the hidden units. intercept_visible_ : array-like, shape (n_features,) Biases of the visible units. components_ : array-like, shape (n_components, n_features) Weight matrix, where n_features in the number of visible units and n_components is the number of hidden units. Examples -------- >>> import numpy as np >>> from sklearn.neural_network import BernoulliRBM >>> X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) >>> model = BernoulliRBM(n_components=2) >>> model.fit(X) BernoulliRBM(batch_size=10, learning_rate=0.1, n_components=2, n_iter=10, random_state=None, verbose=0) References ---------- [1] Hinton, G. E., Osindero, S. and Teh, Y. A fast learning algorithm for deep belief nets. Neural Computation 18, pp 1527-1554. http://www.cs.toronto.edu/~hinton/absps/fastnc.pdf [2] Tieleman, T. Training Restricted Boltzmann Machines using Approximations to the Likelihood Gradient. International Conference on Machine Learning (ICML) 2008 """ def __init__(self, n_components=256, learning_rate=0.1, batch_size=10, n_iter=10, verbose=0, random_state=None): self.n_components = n_components self.learning_rate = learning_rate self.batch_size = batch_size self.n_iter = n_iter self.verbose = verbose self.random_state = random_state def transform(self, X): """Compute the hidden layer activation probabilities, P(h=1|v=X). Parameters ---------- X : {array-like, sparse matrix} shape (n_samples, n_features) The data to be transformed. Returns ------- h : array, shape (n_samples, n_components) Latent representations of the data. """ check_is_fitted(self, "components_") X = check_array(X, accept_sparse='csr', dtype=np.float64) return self._mean_hiddens(X) def _mean_hiddens(self, v): """Computes the probabilities P(h=1|v). Parameters ---------- v : array-like, shape (n_samples, n_features) Values of the visible layer. Returns ------- h : array-like, shape (n_samples, n_components) Corresponding mean field values for the hidden layer. """ p = safe_sparse_dot(v, self.components_.T) p += self.intercept_hidden_ return expit(p, out=p) def _sample_hiddens(self, v, rng): """Sample from the distribution P(h|v). Parameters ---------- v : array-like, shape (n_samples, n_features) Values of the visible layer to sample from. rng : RandomState Random number generator to use. Returns ------- h : array-like, shape (n_samples, n_components) Values of the hidden layer. """ p = self._mean_hiddens(v) return (rng.random_sample(size=p.shape) < p) def _sample_visibles(self, h, rng): """Sample from the distribution P(v|h). Parameters ---------- h : array-like, shape (n_samples, n_components) Values of the hidden layer to sample from. rng : RandomState Random number generator to use. Returns ------- v : array-like, shape (n_samples, n_features) Values of the visible layer. """ p = np.dot(h, self.components_) p += self.intercept_visible_ expit(p, out=p) return (rng.random_sample(size=p.shape) < p) def _free_energy(self, v): """Computes the free energy F(v) = - log sum_h exp(-E(v,h)). Parameters ---------- v : array-like, shape (n_samples, n_features) Values of the visible layer. Returns ------- free_energy : array-like, shape (n_samples,) The value of the free energy. """ return (- safe_sparse_dot(v, self.intercept_visible_) - np.logaddexp(0, safe_sparse_dot(v, self.components_.T) + self.intercept_hidden_).sum(axis=1)) def gibbs(self, v): """Perform one Gibbs sampling step. Parameters ---------- v : array-like, shape (n_samples, n_features) Values of the visible layer to start from. Returns ------- v_new : array-like, shape (n_samples, n_features) Values of the visible layer after one Gibbs step. """ check_is_fitted(self, "components_") if not hasattr(self, "random_state_"): self.random_state_ = check_random_state(self.random_state) h_ = self._sample_hiddens(v, self.random_state_) v_ = self._sample_visibles(h_, self.random_state_) return v_ def partial_fit(self, X, y=None): """Fit the model to the data X which should contain a partial segment of the data. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data. Returns ------- self : BernoulliRBM The fitted model. """ X = check_array(X, accept_sparse='csr', dtype=np.float64) if not hasattr(self, 'random_state_'): self.random_state_ = check_random_state(self.random_state) if not hasattr(self, 'components_'): self.components_ = np.asarray( self.random_state_.normal( 0, 0.01, (self.n_components, X.shape[1]) ), order='F') if not hasattr(self, 'intercept_hidden_'): self.intercept_hidden_ = np.zeros(self.n_components, ) if not hasattr(self, 'intercept_visible_'): self.intercept_visible_ = np.zeros(X.shape[1], ) if not hasattr(self, 'h_samples_'): self.h_samples_ = np.zeros((self.batch_size, self.n_components)) self._fit(X, self.random_state_) def _fit(self, v_pos, rng): """Inner fit for one mini-batch. Adjust the parameters to maximize the likelihood of v using Stochastic Maximum Likelihood (SML). Parameters ---------- v_pos : array-like, shape (n_samples, n_features) The data to use for training. rng : RandomState Random number generator to use for sampling. """ h_pos = self._mean_hiddens(v_pos) v_neg = self._sample_visibles(self.h_samples_, rng) h_neg = self._mean_hiddens(v_neg) lr = float(self.learning_rate) / v_pos.shape[0] update = safe_sparse_dot(v_pos.T, h_pos, dense_output=True).T update -= np.dot(h_neg.T, v_neg) self.components_ += lr * update self.intercept_hidden_ += lr * (h_pos.sum(axis=0) - h_neg.sum(axis=0)) self.intercept_visible_ += lr * (np.asarray( v_pos.sum(axis=0)).squeeze() - v_neg.sum(axis=0)) h_neg[rng.uniform(size=h_neg.shape) < h_neg] = 1.0 # sample binomial self.h_samples_ = np.floor(h_neg, h_neg) def score_samples(self, X): """Compute the pseudo-likelihood of X. Parameters ---------- X : {array-like, sparse matrix} shape (n_samples, n_features) Values of the visible layer. Must be all-boolean (not checked). Returns ------- pseudo_likelihood : array-like, shape (n_samples,) Value of the pseudo-likelihood (proxy for likelihood). Notes ----- This method is not deterministic: it computes a quantity called the free energy on X, then on a randomly corrupted version of X, and returns the log of the logistic function of the difference. """ check_is_fitted(self, "components_") v = check_array(X, accept_sparse='csr') rng = check_random_state(self.random_state) # Randomly corrupt one feature in each sample in v. ind = (np.arange(v.shape[0]), rng.randint(0, v.shape[1], v.shape[0])) if issparse(v): data = -2 * v[ind] + 1 v_ = v + sp.csr_matrix((data.A.ravel(), ind), shape=v.shape) else: v_ = v.copy() v_[ind] = 1 - v_[ind] fe = self._free_energy(v) fe_ = self._free_energy(v_) return v.shape[1] * log_logistic(fe_ - fe) def fit(self, X, y=None): """Fit the model to the data X. Parameters ---------- X : {array-like, sparse matrix} shape (n_samples, n_features) Training data. Returns ------- self : BernoulliRBM The fitted model. """ X = check_array(X, accept_sparse='csr', dtype=np.float64) n_samples = X.shape[0] rng = check_random_state(self.random_state) self.components_ = np.asarray( rng.normal(0, 0.01, (self.n_components, X.shape[1])), order='F') self.intercept_hidden_ = np.zeros(self.n_components, ) self.intercept_visible_ = np.zeros(X.shape[1], ) self.h_samples_ = np.zeros((self.batch_size, self.n_components)) n_batches = int(np.ceil(float(n_samples) / self.batch_size)) batch_slices = list(gen_even_slices(n_batches * self.batch_size, n_batches, n_samples)) verbose = self.verbose begin = time.time() for iteration in xrange(1, self.n_iter + 1): for batch_slice in batch_slices: self._fit(X[batch_slice], rng) if verbose: end = time.time() print("[%s] Iteration %d, pseudo-likelihood = %.2f," " time = %.2fs" % (type(self).__name__, iteration, self.score_samples(X).mean(), end - begin)) begin = end return self
bsd-3-clause
[ 624, 28850, 699, 393, 3903, 20059, 18722, 199, 624, 199, 199, 3, 6642, 26, 1488, 1189, 653, 14, 577, 65, 384, 72, 262, 665, 983, 384, 5812, 11552, 32, 14352, 14, 453, 1888, 3093, 14, 696, 30, 199, 3, 3515, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 3515, 598, 371, 322, 352, 29988, 3540, 4754, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 2508, 1095, 492, 30486, 4256, 199, 504, 2508, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 199, 504, 2508, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 492, 3805, 63, 12056, 63, 14865, 199, 504, 2508, 1208, 492, 365, 4421, 199, 504, 2508, 1208, 14, 832, 3442, 492, 5048, 63, 4421, 63, 3287, 199, 504, 2508, 1208, 14, 832, 3442, 492, 943, 63, 23452, 199, 504, 2508, 1208, 14, 26205, 492, 1437, 390, 3777, 327, 30360, 805, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 421, 199, 533, 23207, 24992, 50, 15225, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 24947, 24992, 32491, 1522, 699, 393, 3903, 20059, 18722, 334, 50, 15225, 680, 339, 437, 32491, 1522, 699, 393, 3903, 20059, 18722, 543, 3366, 8917, 6204, 436, 272, 3366, 8752, 6204, 14, 3897, 787, 20077, 1808, 9785, 21913, 14212, 272, 16485, 12761, 334, 51, 1698, 395, 2597, 6040, 465, 3492, 6082, 1448, 1239, 270, 1912, 3757, 23803, 334, 4222, 36, 9, 272, 359, 18, 1055, 339, 710, 900, 6114, 1209, 402, 642, 4514, 365, 1124, 47, 8, 68, 1011, 499, 9719, 18002, 272, 366, 6146, 302, 63, 3179, 6146, 302, 63, 4608, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 4848, 77, 14943, 339, 3897, 272, 4143, 272, 302, 63, 4608, 520, 1109, 12, 2716, 267, 4860, 402, 3366, 8752, 6204, 14, 339, 9328, 63, 1866, 520, 2069, 12, 2716, 267, 710, 9328, 6634, 367, 5401, 7029, 14, 2779, 365, 627, 6260, 590, 10, 14318, 267, 370, 307, 11474, 642, 10342, 13, 5329, 14, 799, 2660, 461, 1338, 787, 315, 314, 267, 1616, 538, 59, 16, 2020, 446, 19, 19784, 1425, 14, 339, 3522, 63, 890, 520, 1109, 12, 2716, 267, 4860, 402, 7251, 1126, 30829, 14, 339, 302, 63, 1661, 520, 1109, 12, 2716, 267, 4860, 402, 10615, 15, 3519, 1024, 1190, 1806, 314, 6093, 4789, 370, 5147, 267, 5309, 6093, 14, 339, 3376, 520, 1109, 12, 2716, 267, 710, 8661, 2166, 14, 710, 849, 12, 4697, 12, 4910, 10866, 818, 14, 339, 2196, 63, 929, 520, 3000, 503, 2680, 14, 15726, 12, 2716, 267, 437, 2196, 1329, 4306, 1256, 370, 5627, 314, 1174, 402, 314, 267, 2196, 26899, 4306, 14, 982, 376, 3000, 365, 1627, 12, 652, 25079, 314, 267, 6347, 14, 7827, 370, 314, 2288, 2680, 2196, 1329, 4306, 14, 339, 9382, 272, 4143, 272, 13926, 63, 5642, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 4608, 4258, 267, 699, 3994, 402, 314, 8752, 6204, 14, 339, 13926, 63, 6604, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3179, 4258, 267, 699, 3994, 402, 314, 8917, 6204, 14, 339, 7323, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 4608, 12, 302, 63, 3179, 9, 267, 2136, 1070, 3634, 12, 2382, 302, 63, 3179, 315, 314, 1329, 402, 267, 8917, 6204, 436, 302, 63, 4608, 365, 314, 1329, 402, 8752, 6204, 14, 339, 6058, 272, 3001, 339, 1306, 492, 2680, 465, 980, 272, 1306, 687, 6357, 14, 685, 4889, 63, 1200, 492, 23207, 24992, 50, 15225, 272, 1306, 1323, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 378, 467, 359, 16, 12, 413, 12, 413, 467, 359, 17, 12, 378, 12, 413, 467, 359, 17, 12, 413, 12, 413, 3934, 272, 1306, 1402, 275, 23207, 24992, 50, 15225, 8, 78, 63, 4608, 29, 18, 9, 272, 1306, 1402, 14, 3269, 8, 56, 9, 272, 23207, 24992, 50, 15225, 8, 2912, 63, 890, 29, 709, 12, 9328, 63, 1866, 29, 16, 14, 17, 12, 302, 63, 4608, 29, 18, 12, 302, 63, 1661, 29, 709, 12, 1779, 2196, 63, 929, 29, 403, 12, 3376, 29, 16, 9, 339, 14504, 272, 4143, 339, 359, 17, 61, 869, 442, 265, 12, 598, 14, 662, 2020, 593, 5911, 271, 293, 12, 428, 14, 436, 5773, 72, 12, 1488, 14, 437, 7377, 9328, 5563, 367, 267, 13217, 506, 317, 2829, 1851, 83, 14, 5612, 4889, 3599, 10326, 6155, 12, 11618, 4114, 1465, 13, 1046, 1477, 14, 267, 1455, 921, 1544, 14, 1259, 14, 8270, 26296, 14, 8654, 22500, 6479, 265, 15, 371, 681, 83, 15, 7015, 7966, 14, 5607, 339, 359, 18, 61, 377, 1873, 274, 1237, 12, 377, 14, 22859, 32491, 1522, 699, 393, 3903, 20059, 30611, 3746, 1808, 267, 19615, 6865, 21953, 370, 314, 16485, 12761, 19603, 14, 28220, 1448, 1769, 267, 641, 18722, 29127, 334, 948, 1698, 9, 9079, 272, 408, 272, 347, 636, 826, 721, 277, 12, 302, 63, 4608, 29, 3912, 12, 9328, 63, 1866, 29, 16, 14, 17, 12, 3522, 63, 890, 29, 709, 12, 326, 302, 63, 1661, 29, 709, 12, 3376, 29, 16, 12, 2196, 63, 929, 29, 403, 304, 267, 291, 14, 78, 63, 4608, 275, 302, 63, 4608, 267, 291, 14, 10546, 63, 1866, 275, 9328, 63, 1866, 267, 291, 14, 2912, 63, 890, 275, 3522, 63, 890, 267, 291, 14, 78, 63, 1661, 275, 302, 63, 1661, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 2355, 63, 929, 275, 2196, 63, 929, 339, 347, 5793, 8, 277, 12, 1323, 304, 267, 408, 8564, 314, 8752, 4045, 10361, 19555, 12, 510, 8, 72, 29, 17, 92, 86, 29, 56, 680, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 93, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 710, 666, 370, 506, 14834, 14, 398, 1803, 267, 5514, 267, 394, 520, 1625, 12, 2215, 334, 78, 63, 3356, 12, 302, 63, 4608 ]
[ 28850, 699, 393, 3903, 20059, 18722, 199, 624, 199, 199, 3, 6642, 26, 1488, 1189, 653, 14, 577, 65, 384, 72, 262, 665, 983, 384, 5812, 11552, 32, 14352, 14, 453, 1888, 3093, 14, 696, 30, 199, 3, 3515, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 3515, 598, 371, 322, 352, 29988, 3540, 4754, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 2508, 1095, 492, 30486, 4256, 199, 504, 2508, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 199, 504, 2508, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 492, 3805, 63, 12056, 63, 14865, 199, 504, 2508, 1208, 492, 365, 4421, 199, 504, 2508, 1208, 14, 832, 3442, 492, 5048, 63, 4421, 63, 3287, 199, 504, 2508, 1208, 14, 832, 3442, 492, 943, 63, 23452, 199, 504, 2508, 1208, 14, 26205, 492, 1437, 390, 3777, 327, 30360, 805, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 421, 199, 533, 23207, 24992, 50, 15225, 8, 1563, 13183, 12, 30486, 4256, 304, 272, 408, 24947, 24992, 32491, 1522, 699, 393, 3903, 20059, 18722, 334, 50, 15225, 680, 339, 437, 32491, 1522, 699, 393, 3903, 20059, 18722, 543, 3366, 8917, 6204, 436, 272, 3366, 8752, 6204, 14, 3897, 787, 20077, 1808, 9785, 21913, 14212, 272, 16485, 12761, 334, 51, 1698, 395, 2597, 6040, 465, 3492, 6082, 1448, 1239, 270, 1912, 3757, 23803, 334, 4222, 36, 9, 272, 359, 18, 1055, 339, 710, 900, 6114, 1209, 402, 642, 4514, 365, 1124, 47, 8, 68, 1011, 499, 9719, 18002, 272, 366, 6146, 302, 63, 3179, 6146, 302, 63, 4608, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 4848, 77, 14943, 339, 3897, 272, 4143, 272, 302, 63, 4608, 520, 1109, 12, 2716, 267, 4860, 402, 3366, 8752, 6204, 14, 339, 9328, 63, 1866, 520, 2069, 12, 2716, 267, 710, 9328, 6634, 367, 5401, 7029, 14, 2779, 365, 627, 6260, 590, 10, 14318, 267, 370, 307, 11474, 642, 10342, 13, 5329, 14, 799, 2660, 461, 1338, 787, 315, 314, 267, 1616, 538, 59, 16, 2020, 446, 19, 19784, 1425, 14, 339, 3522, 63, 890, 520, 1109, 12, 2716, 267, 4860, 402, 7251, 1126, 30829, 14, 339, 302, 63, 1661, 520, 1109, 12, 2716, 267, 4860, 402, 10615, 15, 3519, 1024, 1190, 1806, 314, 6093, 4789, 370, 5147, 267, 5309, 6093, 14, 339, 3376, 520, 1109, 12, 2716, 267, 710, 8661, 2166, 14, 710, 849, 12, 4697, 12, 4910, 10866, 818, 14, 339, 2196, 63, 929, 520, 3000, 503, 2680, 14, 15726, 12, 2716, 267, 437, 2196, 1329, 4306, 1256, 370, 5627, 314, 1174, 402, 314, 267, 2196, 26899, 4306, 14, 982, 376, 3000, 365, 1627, 12, 652, 25079, 314, 267, 6347, 14, 7827, 370, 314, 2288, 2680, 2196, 1329, 4306, 14, 339, 9382, 272, 4143, 272, 13926, 63, 5642, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 4608, 4258, 267, 699, 3994, 402, 314, 8752, 6204, 14, 339, 13926, 63, 6604, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3179, 4258, 267, 699, 3994, 402, 314, 8917, 6204, 14, 339, 7323, 63, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 4608, 12, 302, 63, 3179, 9, 267, 2136, 1070, 3634, 12, 2382, 302, 63, 3179, 315, 314, 1329, 402, 267, 8917, 6204, 436, 302, 63, 4608, 365, 314, 1329, 402, 8752, 6204, 14, 339, 6058, 272, 3001, 339, 1306, 492, 2680, 465, 980, 272, 1306, 687, 6357, 14, 685, 4889, 63, 1200, 492, 23207, 24992, 50, 15225, 272, 1306, 1323, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 378, 467, 359, 16, 12, 413, 12, 413, 467, 359, 17, 12, 378, 12, 413, 467, 359, 17, 12, 413, 12, 413, 3934, 272, 1306, 1402, 275, 23207, 24992, 50, 15225, 8, 78, 63, 4608, 29, 18, 9, 272, 1306, 1402, 14, 3269, 8, 56, 9, 272, 23207, 24992, 50, 15225, 8, 2912, 63, 890, 29, 709, 12, 9328, 63, 1866, 29, 16, 14, 17, 12, 302, 63, 4608, 29, 18, 12, 302, 63, 1661, 29, 709, 12, 1779, 2196, 63, 929, 29, 403, 12, 3376, 29, 16, 9, 339, 14504, 272, 4143, 339, 359, 17, 61, 869, 442, 265, 12, 598, 14, 662, 2020, 593, 5911, 271, 293, 12, 428, 14, 436, 5773, 72, 12, 1488, 14, 437, 7377, 9328, 5563, 367, 267, 13217, 506, 317, 2829, 1851, 83, 14, 5612, 4889, 3599, 10326, 6155, 12, 11618, 4114, 1465, 13, 1046, 1477, 14, 267, 1455, 921, 1544, 14, 1259, 14, 8270, 26296, 14, 8654, 22500, 6479, 265, 15, 371, 681, 83, 15, 7015, 7966, 14, 5607, 339, 359, 18, 61, 377, 1873, 274, 1237, 12, 377, 14, 22859, 32491, 1522, 699, 393, 3903, 20059, 30611, 3746, 1808, 267, 19615, 6865, 21953, 370, 314, 16485, 12761, 19603, 14, 28220, 1448, 1769, 267, 641, 18722, 29127, 334, 948, 1698, 9, 9079, 272, 408, 272, 347, 636, 826, 721, 277, 12, 302, 63, 4608, 29, 3912, 12, 9328, 63, 1866, 29, 16, 14, 17, 12, 3522, 63, 890, 29, 709, 12, 326, 302, 63, 1661, 29, 709, 12, 3376, 29, 16, 12, 2196, 63, 929, 29, 403, 304, 267, 291, 14, 78, 63, 4608, 275, 302, 63, 4608, 267, 291, 14, 10546, 63, 1866, 275, 9328, 63, 1866, 267, 291, 14, 2912, 63, 890, 275, 3522, 63, 890, 267, 291, 14, 78, 63, 1661, 275, 302, 63, 1661, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 2355, 63, 929, 275, 2196, 63, 929, 339, 347, 5793, 8, 277, 12, 1323, 304, 267, 408, 8564, 314, 8752, 4045, 10361, 19555, 12, 510, 8, 72, 29, 17, 92, 86, 29, 56, 680, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 93, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 710, 666, 370, 506, 14834, 14, 398, 1803, 267, 5514, 267, 394, 520, 1625, 12, 2215, 334, 78, 63, 3356, 12, 302, 63, 4608, 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, 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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 ]
danny88br/cjdns
node_build/dependencies/libuv/build/gyp/test/cflags/gyptest-cflags.py
120
2628
#!/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 build of an executable with C++ define specified by a gyp define, and the use of the environment during regeneration when the gyp file changes. """ import os import sys import TestGyp env_stack = [] def PushEnv(): env_copy = os.environ.copy() env_stack.append(env_copy) def PopEnv(): os.environ.clear() os.environ.update(env_stack.pop()) formats = ['make', 'ninja'] test = TestGyp.TestGyp(formats=formats) try: PushEnv() os.environ['CFLAGS'] = '' os.environ['GYP_CROSSCOMPILE'] = '1' test.run_gyp('cflags.gyp') test.build('cflags.gyp') finally: # We clear the environ after calling gyp. When the auto-regeneration happens, # the same define should be reused anyway. Reset to empty string first in # case the platform doesn't support unsetenv. PopEnv() expect = """FOO not defined\n""" test.run_built_executable('cflags', stdout=expect) test.run_built_executable('cflags_host', stdout=expect) test.sleep() try: PushEnv() os.environ['CFLAGS'] = '-DFOO=1' os.environ['GYP_CROSSCOMPILE'] = '1' test.run_gyp('cflags.gyp') test.build('cflags.gyp') finally: # We clear the environ after calling gyp. When the auto-regeneration happens, # the same define should be reused anyway. Reset to empty string first in # case the platform doesn't support unsetenv. PopEnv() expect = """FOO defined\n""" test.run_built_executable('cflags', stdout=expect) # Environment variables shouldn't influence the flags for the host. expect = """FOO not defined\n""" test.run_built_executable('cflags_host', stdout=expect) test.sleep() try: PushEnv() os.environ['CFLAGS'] = '' test.run_gyp('cflags.gyp') test.build('cflags.gyp') finally: # We clear the environ after calling gyp. When the auto-regeneration happens, # the same define should be reused anyway. Reset to empty string first in # case the platform doesn't support unsetenv. PopEnv() expect = """FOO not defined\n""" test.run_built_executable('cflags', stdout=expect) test.sleep() try: PushEnv() os.environ['CFLAGS'] = '-DFOO=1' test.run_gyp('cflags.gyp') test.build('cflags.gyp') finally: # We clear the environ after calling gyp. When the auto-regeneration happens, # the same define should be reused anyway. Reset to empty string first in # case the platform doesn't support unsetenv. PopEnv() expect = """FOO defined\n""" test.run_built_executable('cflags', stdout=expect) test.pass_test()
gpl-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, 1900, 402, 376, 7286, 543, 445, 4176, 5627, 2013, 701, 282, 4902, 5627, 12, 436, 199, 1589, 675, 402, 314, 3734, 5309, 1295, 27976, 1380, 314, 4902, 570, 4493, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 25688, 199, 199, 1813, 63, 2340, 275, 942, 421, 199, 318, 22643, 7744, 837, 523, 2589, 63, 1574, 275, 747, 14, 2314, 14, 1574, 342, 523, 2589, 63, 2340, 14, 740, 8, 1813, 63, 1574, 9, 199, 199, 318, 13244, 7744, 837, 523, 747, 14, 2314, 14, 3584, 342, 523, 747, 14, 2314, 14, 873, 8, 1813, 63, 2340, 14, 1935, 1012, 199, 199, 6321, 275, 788, 1875, 297, 283, 8675, 418, 199, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 29, 6321, 9, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2125, 523, 747, 14, 2314, 459, 14884, 63, 28368, 29911, 418, 275, 283, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 63, 1102, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2475, 36, 13046, 29, 17, 7, 523, 747, 14, 2314, 459, 14884, 63, 28368, 29911, 418, 275, 283, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 199, 3, 9711, 2860, 9296, 1133, 315, 24585, 314, 3285, 367, 314, 1591, 14, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 63, 1102, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2125, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2475, 36, 13046, 29, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 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 ]
[ 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, 1900, 402, 376, 7286, 543, 445, 4176, 5627, 2013, 701, 282, 4902, 5627, 12, 436, 199, 1589, 675, 402, 314, 3734, 5309, 1295, 27976, 1380, 314, 4902, 570, 4493, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 25688, 199, 199, 1813, 63, 2340, 275, 942, 421, 199, 318, 22643, 7744, 837, 523, 2589, 63, 1574, 275, 747, 14, 2314, 14, 1574, 342, 523, 2589, 63, 2340, 14, 740, 8, 1813, 63, 1574, 9, 199, 199, 318, 13244, 7744, 837, 523, 747, 14, 2314, 14, 3584, 342, 523, 747, 14, 2314, 14, 873, 8, 1813, 63, 2340, 14, 1935, 1012, 199, 199, 6321, 275, 788, 1875, 297, 283, 8675, 418, 199, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 29, 6321, 9, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2125, 523, 747, 14, 2314, 459, 14884, 63, 28368, 29911, 418, 275, 283, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 63, 1102, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2475, 36, 13046, 29, 17, 7, 523, 747, 14, 2314, 459, 14884, 63, 28368, 29911, 418, 275, 283, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 199, 3, 9711, 2860, 9296, 1133, 315, 24585, 314, 3285, 367, 314, 1591, 14, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 63, 1102, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2125, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 440, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 199, 396, 14, 4532, 342, 199, 199, 893, 26, 523, 22643, 7744, 342, 523, 747, 14, 2314, 459, 14804, 418, 275, 2475, 36, 13046, 29, 17, 7, 523, 511, 14, 1065, 63, 6179, 360, 14002, 14, 6179, 358, 523, 511, 14, 1506, 360, 14002, 14, 6179, 358, 199, 15172, 26, 523, 327, 2136, 5436, 314, 6160, 2410, 6358, 4902, 14, 221, 3979, 314, 2599, 13, 1135, 27976, 10986, 12, 523, 327, 314, 2011, 5627, 1077, 506, 24826, 15988, 14, 221, 15510, 370, 2701, 1059, 1642, 315, 523, 327, 1930, 314, 4298, 3181, 1133, 2291, 625, 261, 9072, 14, 523, 13244, 7744, 342, 421, 199, 4921, 275, 408, 13046, 3247, 60, 78, 624, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 14002, 297, 3839, 29, 4921, 9, 199, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nburn42/tensorflow
tensorflow/contrib/autograph/pyct/inspect_utils.py
17
5497
# 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. # ============================================================================== """Live entity inspection utilities. This module contains whatever inspect doesn't offer out of the box. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import itertools import types import six from tensorflow.python.util import tf_inspect def isbuiltin(f): # Note these return false for isinstance(f, types.BuiltinFunctionType) so we # need to specifically check for them. if f in (range, int, float): return True if isinstance(f, types.BuiltinFunctionType): return True if tf_inspect.isbuiltin(f): return True return False def getnamespace(f): """Returns the complete namespace of a function. Namespace is defined here as the mapping of all non-local variables to values. This includes the globals and the closure variables. Note that this captures the entire globals collection of the function, and may contain extra symbols that it does not actually use. Args: f: User defined function. Returns: A dict mapping symbol names to values. """ namespace = dict(six.get_function_globals(f)) closure = six.get_function_closure(f) freevars = six.get_function_code(f).co_freevars if freevars and closure: for name, cell in zip(freevars, closure): namespace[name] = cell.cell_contents return namespace def _get_unbound_function(m): # TODO(mdan): Figure out why six.get_unbound_function fails in some cases. # The failure case is for tf.keras.Model. if hasattr(m, 'im_func'): return m.im_func return m def getdefiningclass(m, owner_class): """Resolves the class (e.g. one of the superclasses) that defined a method.""" # Normalize bound functions to their respective unbound versions. m = _get_unbound_function(m) for superclass in owner_class.__bases__: if hasattr(superclass, m.__name__): superclass_m = getattr(superclass, m.__name__) if _get_unbound_function(superclass_m) is m: return superclass elif hasattr(m, '__self__') and m.__self__ == owner_class: # Python 3 class methods only work this way it seems :S return superclass return owner_class def getmethodclass(m): """Resolves a function's owner, e.g. a method's class. Note that this returns the object that the function was retrieved from, not necessarily the class where it was defined. This function relies on Python stack frame support in the interpreter, and has the same limitations that inspect.currentframe. Limitations. This function will only work correctly if the owned class is visible in the caller's global or local variables. Args: m: A user defined function Returns: The class that this function was retrieved from, or None if the function is not an object or class method, or the class that owns the object or method is not visible to m. Raises: ValueError: if the class could not be resolved for any unexpected reason. """ # Callable objects: return their own class. if (not hasattr(m, '__name__') and hasattr(m, '__class__') and hasattr(m, '__call__')): if isinstance(m.__class__, six.class_types): return m.__class__ # Instance method and class methods: should be bound to a non-null "self". # If self is a class, then it's a class method. if hasattr(m, '__self__'): if m.__self__: if tf_inspect.isclass(m.__self__): return m.__self__ return type(m.__self__) # Class, static and unbound methods: search all defined classes in any # namespace. This is inefficient but more robust method. owners = [] caller_frame = tf_inspect.currentframe().f_back try: # TODO(mdan): This doesn't consider cell variables. # TODO(mdan): This won't work if the owner is hidden inside a container. # Cell variables may be pulled using co_freevars and the closure. for v in itertools.chain(caller_frame.f_locals.values(), caller_frame.f_globals.values()): if hasattr(v, m.__name__): candidate = getattr(v, m.__name__) # Py2 methods may be bound or unbound, extract im_func to get the # underlying function. if hasattr(candidate, 'im_func'): candidate = candidate.im_func if hasattr(m, 'im_func'): m = m.im_func if candidate is m: owners.append(v) finally: del caller_frame if owners: if len(owners) == 1: return owners[0] # If multiple owners are found, and are not subclasses, raise an error. owner_types = tuple(o if tf_inspect.isclass(o) else type(o) for o in owners) for o in owner_types: if tf_inspect.isclass(o) and issubclass(o, tuple(owner_types)): return o raise ValueError('Found too many owners of %s: %s' % (m, owners)) return None
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, 17458, 4642, 5261, 10303, 15841, 14, 199, 199, 2765, 859, 3509, 15685, 6485, 3181, 1133, 19793, 734, 402, 314, 5689, 14, 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, 7975, 199, 646, 2943, 199, 199, 646, 3816, 199, 199, 504, 3228, 14, 1548, 14, 1974, 492, 2833, 63, 10955, 421, 199, 318, 365, 5351, 8, 70, 304, 523, 327, 3390, 3520, 372, 3055, 367, 1228, 8, 70, 12, 2943, 14, 12306, 26371, 9, 880, 781, 523, 327, 1929, 370, 22543, 1104, 367, 3062, 14, 523, 340, 289, 315, 334, 1842, 12, 1109, 12, 2069, 304, 272, 372, 715, 523, 340, 1228, 8, 70, 12, 2943, 14, 12306, 26371, 304, 272, 372, 715, 523, 340, 2833, 63, 10955, 14, 374, 5351, 8, 70, 304, 272, 372, 715, 523, 372, 756, 421, 199, 318, 664, 3251, 8, 70, 304, 523, 408, 3407, 314, 4890, 3231, 402, 282, 805, 14, 819, 19317, 365, 3247, 2348, 465, 314, 4412, 402, 1006, 2222, 13, 1832, 2860, 370, 1338, 14, 523, 961, 6952, 314, 7992, 436, 314, 17903, 2860, 14, 3390, 626, 642, 12162, 1482, 523, 314, 8039, 7992, 3245, 402, 314, 805, 12, 436, 1443, 1395, 2402, 6698, 523, 626, 652, 1630, 440, 5965, 675, 14, 819, 3033, 26, 272, 289, 26, 2876, 3247, 805, 14, 523, 1803, 26, 272, 437, 1211, 4412, 5272, 1561, 370, 1338, 14, 523, 408, 523, 3231, 275, 1211, 8, 4174, 14, 362, 63, 1593, 63, 8473, 8, 70, 430, 523, 17903, 275, 3816, 14, 362, 63, 1593, 63, 13008, 8, 70, 9, 523, 2867, 2936, 275, 3816, 14, 362, 63, 1593, 63, 600, 8, 70, 680, 331, 63, 4624, 2936, 523, 340, 2867, 2936, 436, 17903, 26, 272, 367, 536, 12, 4917, 315, 3482, 8, 4624, 2936, 12, 17903, 304, 489, 3231, 59, 354, 61, 275, 4917, 14, 3890, 63, 4407, 523, 372, 3231, 421, 199, 318, 485, 362, 63, 18124, 63, 1593, 8, 77, 304, 523, 327, 3254, 8, 1064, 290, 304, 16266, 734, 10842, 3816, 14, 362, 63, 18124, 63, 1593, 6918, 315, 2005, 5560, 14, 523, 327, 710, 5988, 1930, 365, 367, 2833, 14, 8811, 14, 1685, 14, 523, 340, 2688, 8, 77, 12, 283, 1017, 63, 1532, 735, 272, 372, 333, 14, 1017, 63, 1532, 523, 372, 333, 421, 199, 318, 664, 318, 7969, 533, 8, 77, 12, 5771, 63, 533, 304, 523, 408, 1322, 393, 2310, 314, 1021, 334, 69, 14, 71, 14, 1373, 402, 314, 1613, 2888, 9, 626, 3247, 282, 1083, 1041, 523, 327, 21017, 3914, 3423, 370, 3932, 26820, 22334, 5459, 14, 523, 333, 275, 485, 362, 63, 18124, 63, 1593, 8, 77, 9, 523, 367, 17035, 315, 5771, 63, 533, 855, 12087, 10651, 272, 340, 2688, 8, 4792, 533, 12, 333, 855, 354, 18580, 489, 17035, 63, 77, 275, 2519, 8, 4792, 533, 12, 333, 855, 354, 3368, 489, 340, 485, 362, 63, 18124, 63, 1593, 8, 4792, 533, 63, 77, 9, 365, 333, 26, 267, 372, 17035, 489, 916, 2688, 8, 77, 12, 2560, 277, 13766, 436, 333, 855, 277, 363, 508, 5771, 63, 533, 26, 267, 327, 2018, 650, 1021, 3102, 1454, 1736, 642, 4340, 652, 12237, 520, 51, 267, 372, 17035, 523, 372, 5771, 63, 533, 421, 199, 318, 664, 765, 533, 8, 77, 304, 523, 408, 1322, 393, 2310, 282, 805, 1159, 5771, 12, 325, 14, 71, 14, 282, 1083, 1159, 1021, 14, 819, 3390, 626, 642, 2529, 314, 909, 626, 314, 805, 1990, 12396, 687, 12, 440, 523, 20513, 314, 1021, 2382, 652, 1990, 3247, 14, 819, 961, 805, 25749, 641, 2018, 3464, 2787, 2291, 315, 314, 12693, 12, 436, 523, 965, 314, 2011, 4204, 626, 6485, 14, 1818, 1943, 14, 819, 22672, 1298, 14, 961, 805, 911, 1454, 1736, 6657, 340, 314, 23191, 1021, 365, 523, 8917, 315, 314, 8025, 1159, 2288, 503, 2257, 2860, 14, 819, 3033, 26, 272, 333, 26, 437, 922, 3247, 805, 819, 1803, 26, 272, 710, 1021, 626, 642, 805, 1990, 12396, 687, 12, 503, 488, 340, 314, 805, 272, 365, 440, 376, 909, 503, 1021, 1083, 12, 503, 314, 1021, 626, 22182, 561, 314, 909, 503, 272, 1083, 365, 440, 8917, 370, 333, 14, 819, 6218, 26, 272, 1722, 26, 340, 314, 1021, 4293, 440, 506, 12152, 367, 1263, 10537, 4499, 14, 523, 408, 819, 327, 16975, 2251, 26, 372, 3932, 5705, 1021, 14, 523, 340, 334, 1397, 2688, 8, 77, 12, 2560, 354, 13766, 436, 2688, 8, 77, 12, 2560, 533, 13766, 436, 489, 2688, 8, 77, 12, 2560, 1250, 363, 8109, 272, 340, 1228, 8, 77, 855, 533, 3108, 3816, 14, 533, 63, 1313, 304, 489, 372, 333, 855, 533, 363, 819, 327, 10066, 1083, 436, 1021, 3102, 26, 1077, 506, 3914, 370, 282, 2222, 13, 2307, 298, 277, 1674, 523, 327, 982, 291, 365, 282, 1021, 12, 2066, 652, 1159, 282, 1021, 1083, 14, 523, 340, 2688, 8, 77, 12, 2560, 277, 12168, 272, 340, 333, 855, 277, 10651, 489, 340, 2833, 63, 10955, 14, 28450, 8, 77, 855, 277, 18580, 267, 372, 333, 855, 277, 363, 489, 372, 730, 8, 77, 855, 277, 3368, 819, 327, 8089, 12, 2955, 436, 22334, 3102, 26, 2754, 1006, 3247, 3992, 315 ]
[ 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, 17458, 4642, 5261, 10303, 15841, 14, 199, 199, 2765, 859, 3509, 15685, 6485, 3181, 1133, 19793, 734, 402, 314, 5689, 14, 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, 7975, 199, 646, 2943, 199, 199, 646, 3816, 199, 199, 504, 3228, 14, 1548, 14, 1974, 492, 2833, 63, 10955, 421, 199, 318, 365, 5351, 8, 70, 304, 523, 327, 3390, 3520, 372, 3055, 367, 1228, 8, 70, 12, 2943, 14, 12306, 26371, 9, 880, 781, 523, 327, 1929, 370, 22543, 1104, 367, 3062, 14, 523, 340, 289, 315, 334, 1842, 12, 1109, 12, 2069, 304, 272, 372, 715, 523, 340, 1228, 8, 70, 12, 2943, 14, 12306, 26371, 304, 272, 372, 715, 523, 340, 2833, 63, 10955, 14, 374, 5351, 8, 70, 304, 272, 372, 715, 523, 372, 756, 421, 199, 318, 664, 3251, 8, 70, 304, 523, 408, 3407, 314, 4890, 3231, 402, 282, 805, 14, 819, 19317, 365, 3247, 2348, 465, 314, 4412, 402, 1006, 2222, 13, 1832, 2860, 370, 1338, 14, 523, 961, 6952, 314, 7992, 436, 314, 17903, 2860, 14, 3390, 626, 642, 12162, 1482, 523, 314, 8039, 7992, 3245, 402, 314, 805, 12, 436, 1443, 1395, 2402, 6698, 523, 626, 652, 1630, 440, 5965, 675, 14, 819, 3033, 26, 272, 289, 26, 2876, 3247, 805, 14, 523, 1803, 26, 272, 437, 1211, 4412, 5272, 1561, 370, 1338, 14, 523, 408, 523, 3231, 275, 1211, 8, 4174, 14, 362, 63, 1593, 63, 8473, 8, 70, 430, 523, 17903, 275, 3816, 14, 362, 63, 1593, 63, 13008, 8, 70, 9, 523, 2867, 2936, 275, 3816, 14, 362, 63, 1593, 63, 600, 8, 70, 680, 331, 63, 4624, 2936, 523, 340, 2867, 2936, 436, 17903, 26, 272, 367, 536, 12, 4917, 315, 3482, 8, 4624, 2936, 12, 17903, 304, 489, 3231, 59, 354, 61, 275, 4917, 14, 3890, 63, 4407, 523, 372, 3231, 421, 199, 318, 485, 362, 63, 18124, 63, 1593, 8, 77, 304, 523, 327, 3254, 8, 1064, 290, 304, 16266, 734, 10842, 3816, 14, 362, 63, 18124, 63, 1593, 6918, 315, 2005, 5560, 14, 523, 327, 710, 5988, 1930, 365, 367, 2833, 14, 8811, 14, 1685, 14, 523, 340, 2688, 8, 77, 12, 283, 1017, 63, 1532, 735, 272, 372, 333, 14, 1017, 63, 1532, 523, 372, 333, 421, 199, 318, 664, 318, 7969, 533, 8, 77, 12, 5771, 63, 533, 304, 523, 408, 1322, 393, 2310, 314, 1021, 334, 69, 14, 71, 14, 1373, 402, 314, 1613, 2888, 9, 626, 3247, 282, 1083, 1041, 523, 327, 21017, 3914, 3423, 370, 3932, 26820, 22334, 5459, 14, 523, 333, 275, 485, 362, 63, 18124, 63, 1593, 8, 77, 9, 523, 367, 17035, 315, 5771, 63, 533, 855, 12087, 10651, 272, 340, 2688, 8, 4792, 533, 12, 333, 855, 354, 18580, 489, 17035, 63, 77, 275, 2519, 8, 4792, 533, 12, 333, 855, 354, 3368, 489, 340, 485, 362, 63, 18124, 63, 1593, 8, 4792, 533, 63, 77, 9, 365, 333, 26, 267, 372, 17035, 489, 916, 2688, 8, 77, 12, 2560, 277, 13766, 436, 333, 855, 277, 363, 508, 5771, 63, 533, 26, 267, 327, 2018, 650, 1021, 3102, 1454, 1736, 642, 4340, 652, 12237, 520, 51, 267, 372, 17035, 523, 372, 5771, 63, 533, 421, 199, 318, 664, 765, 533, 8, 77, 304, 523, 408, 1322, 393, 2310, 282, 805, 1159, 5771, 12, 325, 14, 71, 14, 282, 1083, 1159, 1021, 14, 819, 3390, 626, 642, 2529, 314, 909, 626, 314, 805, 1990, 12396, 687, 12, 440, 523, 20513, 314, 1021, 2382, 652, 1990, 3247, 14, 819, 961, 805, 25749, 641, 2018, 3464, 2787, 2291, 315, 314, 12693, 12, 436, 523, 965, 314, 2011, 4204, 626, 6485, 14, 1818, 1943, 14, 819, 22672, 1298, 14, 961, 805, 911, 1454, 1736, 6657, 340, 314, 23191, 1021, 365, 523, 8917, 315, 314, 8025, 1159, 2288, 503, 2257, 2860, 14, 819, 3033, 26, 272, 333, 26, 437, 922, 3247, 805, 819, 1803, 26, 272, 710, 1021, 626, 642, 805, 1990, 12396, 687, 12, 503, 488, 340, 314, 805, 272, 365, 440, 376, 909, 503, 1021, 1083, 12, 503, 314, 1021, 626, 22182, 561, 314, 909, 503, 272, 1083, 365, 440, 8917, 370, 333, 14, 819, 6218, 26, 272, 1722, 26, 340, 314, 1021, 4293, 440, 506, 12152, 367, 1263, 10537, 4499, 14, 523, 408, 819, 327, 16975, 2251, 26, 372, 3932, 5705, 1021, 14, 523, 340, 334, 1397, 2688, 8, 77, 12, 2560, 354, 13766, 436, 2688, 8, 77, 12, 2560, 533, 13766, 436, 489, 2688, 8, 77, 12, 2560, 1250, 363, 8109, 272, 340, 1228, 8, 77, 855, 533, 3108, 3816, 14, 533, 63, 1313, 304, 489, 372, 333, 855, 533, 363, 819, 327, 10066, 1083, 436, 1021, 3102, 26, 1077, 506, 3914, 370, 282, 2222, 13, 2307, 298, 277, 1674, 523, 327, 982, 291, 365, 282, 1021, 12, 2066, 652, 1159, 282, 1021, 1083, 14, 523, 340, 2688, 8, 77, 12, 2560, 277, 12168, 272, 340, 333, 855, 277, 10651, 489, 340, 2833, 63, 10955, 14, 28450, 8, 77, 855, 277, 18580, 267, 372, 333, 855, 277, 363, 489, 372, 730, 8, 77, 855, 277, 3368, 819, 327, 8089, 12, 2955, 436, 22334, 3102, 26, 2754, 1006, 3247, 3992, 315, 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, 1 ]
fnordahl/nova
nova/openstack/common/policy.py
32
31030
# -*- coding: utf-8 -*- # # Copyright (c) 2012 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. """ Common Policy Engine Implementation Policies can be expressed in one of two forms: A list of lists, or a string written in the new policy language. In the list-of-lists representation, each check inside the innermost list is combined as with an "and" conjunction--for that check to pass, all the specified checks must pass. These innermost lists are then combined as with an "or" conjunction. As an example, take the following rule, expressed in the list-of-lists representation:: [["role:admin"], ["project_id:%(project_id)s", "role:projectadmin"]] This is the original way of expressing policies, but there now exists a new way: the policy language. In the policy language, each check is specified the same way as in the list-of-lists representation: a simple "a:b" pair that is matched to the correct class to perform that check:: +===========================================================================+ | TYPE | SYNTAX | +===========================================================================+ |User's Role | role:admin | +---------------------------------------------------------------------------+ |Rules already defined on policy | rule:admin_required | +---------------------------------------------------------------------------+ |Against URL's¹ | http://my-url.org/check | +---------------------------------------------------------------------------+ |User attributes² | project_id:%(target.project.id)s | +---------------------------------------------------------------------------+ |Strings | <variable>:'xpto2035abc' | | | 'myproject':<variable> | +---------------------------------------------------------------------------+ | | project_id:xpto2035abc | |Literals | domain_id:20 | | | True:%(user.enabled)s | +===========================================================================+ ¹URL checking must return 'True' to be valid ²User attributes (obtained through the token): user_id, domain_id or project_id Conjunction operators are available, allowing for more expressiveness in crafting policies. So, in the policy language, the previous check in list-of-lists becomes:: role:admin or (project_id:%(project_id)s and role:projectadmin) The policy language also has the "not" operator, allowing a richer policy rule:: project_id:%(project_id)s and not role:dunce Attributes sent along with API calls can be used by the policy engine (on the right side of the expression), by using the following syntax:: <some_value>:%(user.id)s Contextual attributes of objects identified by their IDs are loaded from the database. They are also available to the policy engine and can be checked through the `target` keyword:: <some_value>:%(target.role.name)s Finally, two special policy checks should be mentioned; the policy check "@" will always accept an access, and the policy check "!" will always reject an access. (Note that if a rule is either the empty list ("[]") or the empty string, this is equivalent to the "@" policy check.) Of these, the "!" policy check is probably the most useful, as it allows particular rules to be explicitly disabled. """ import abc import ast import copy import logging import os import re from oslo_config import cfg from oslo_serialization import jsonutils import six import six.moves.urllib.parse as urlparse import six.moves.urllib.request as urlrequest from nova.openstack.common._i18n import _, _LE from nova import utils policy_opts = [ cfg.StrOpt('policy_file', default='policy.json', help=_('The JSON file that defines policies.')), cfg.StrOpt('policy_default_rule', default='default', help=_('Default rule. Enforced when a requested rule is not ' 'found.')), cfg.MultiStrOpt('policy_dirs', default=['policy.d'], help=_('Directories where policy configuration files are ' 'stored. They can be relative to any directory ' 'in the search path defined by the config_dir ' 'option, or absolute paths. The file defined by ' 'policy_file must exist for these directories to ' 'be searched. Missing or empty directories are ' 'ignored.')), ] CONF = cfg.CONF CONF.register_opts(policy_opts) LOG = logging.getLogger(__name__) _checks = {} def list_opts(): """Entry point for oslo-config-generator.""" return [(None, copy.deepcopy(policy_opts))] class PolicyNotAuthorized(Exception): def __init__(self, rule): msg = _("Policy doesn't allow %s to be performed.") % rule super(PolicyNotAuthorized, self).__init__(msg) class Rules(dict): """A store for rules. Handles the default_rule setting directly.""" @classmethod def load_json(cls, data, default_rule=None): """Allow loading of JSON rule data.""" # Suck in the JSON data and parse the rules rules = dict((k, parse_rule(v)) for k, v in jsonutils.loads(data).items()) return cls(rules, default_rule) def __init__(self, rules=None, default_rule=None): """Initialize the Rules store.""" super(Rules, self).__init__(rules or {}) self.default_rule = default_rule def __missing__(self, key): """Implements the default rule handling.""" if isinstance(self.default_rule, dict): raise KeyError(key) # If the default rule isn't actually defined, do something # reasonably intelligent if not self.default_rule: raise KeyError(key) if isinstance(self.default_rule, BaseCheck): return self.default_rule # We need to check this or we can get infinite recursion if self.default_rule not in self: raise KeyError(key) elif isinstance(self.default_rule, six.string_types): return self[self.default_rule] def __str__(self): """Dumps a string representation of the rules.""" # Start by building the canonical strings for the rules out_rules = {} for key, value in self.items(): # Use empty string for singleton TrueCheck instances if isinstance(value, TrueCheck): out_rules[key] = '' else: out_rules[key] = str(value) # Dump a pretty-printed JSON representation return jsonutils.dumps(out_rules, indent=4) class Enforcer(object): """Responsible for loading and enforcing rules. :param policy_file: Custom policy file to use, if none is specified, `CONF.policy_file` will be used. :param rules: Default dictionary / Rules to use. It will be considered just in the first instantiation. If `load_rules(True)`, `clear()` or `set_rules(True)` is called this will be overwritten. :param default_rule: Default rule to use, CONF.default_rule will be used if none is specified. :param use_conf: Whether to load rules from cache or config file. :param overwrite: Whether to overwrite existing rules when reload rules from config file. """ def __init__(self, policy_file=None, rules=None, default_rule=None, use_conf=True, overwrite=True): self.default_rule = default_rule or CONF.policy_default_rule self.rules = Rules(rules, self.default_rule) self.policy_path = None self.policy_file = policy_file or CONF.policy_file self.use_conf = use_conf self.overwrite = overwrite def set_rules(self, rules, overwrite=True, use_conf=False): """Create a new Rules object based on the provided dict of rules. :param rules: New rules to use. It should be an instance of dict. :param overwrite: Whether to overwrite current rules or update them with the new rules. :param use_conf: Whether to reload rules from cache or config file. """ if not isinstance(rules, dict): raise TypeError(_("Rules must be an instance of dict or Rules, " "got %s instead") % type(rules)) self.use_conf = use_conf if overwrite: self.rules = Rules(rules, self.default_rule) else: self.rules.update(rules) def clear(self): """Clears Enforcer rules, policy's cache and policy's path.""" self.set_rules({}) utils.delete_cached_file(self.policy_path) self.default_rule = None self.policy_path = None def load_rules(self, force_reload=False): """Loads policy_path's rules. Policy file is cached and will be reloaded if modified. :param force_reload: Whether to reload rules from config file. """ if force_reload: self.use_conf = force_reload if self.use_conf: if not self.policy_path: self.policy_path = self._get_policy_path(self.policy_file) self._load_policy_file(self.policy_path, force_reload, overwrite=self.overwrite) for path in CONF.policy_dirs: try: path = self._get_policy_path(path) except cfg.ConfigFilesNotFoundError: continue self._walk_through_policy_directory(path, self._load_policy_file, force_reload, False) @staticmethod def _walk_through_policy_directory(path, func, *args): # We do not iterate over sub-directories. policy_files = next(os.walk(path))[2] policy_files.sort() for policy_file in [p for p in policy_files if not p.startswith('.')]: func(os.path.join(path, policy_file), *args) def _load_policy_file(self, path, force_reload, overwrite=True): reloaded, data = utils.read_cached_file( path, force_reload=force_reload) if reloaded or not self.rules or not overwrite: rules = Rules.load_json(data, self.default_rule) self.set_rules(rules, overwrite=overwrite, use_conf=True) LOG.debug("Reloaded policy file: %(path)s", {'path': path}) def _get_policy_path(self, path): """Locate the policy json data file/path. :param path: It's value can be a full path or related path. When full path specified, this function just returns the full path. When related path specified, this function will search configuration directories to find one that exists. :returns: The policy path :raises: ConfigFilesNotFoundError if the file/path couldn't be located. """ policy_path = CONF.find_file(path) if policy_path: return policy_path raise cfg.ConfigFilesNotFoundError((path,)) def enforce(self, rule, target, creds, do_raise=False, exc=None, *args, **kwargs): """Checks authorization of a rule against the target and credentials. :param rule: A string or BaseCheck instance specifying the rule to evaluate. :param target: As much information about the object being operated on as possible, as a dictionary. :param creds: As much information about the user performing the action as possible, as a dictionary. :param do_raise: Whether to raise an exception or not if check fails. :param exc: Class of the exception to raise if the check fails. Any remaining arguments passed to enforce() (both positional and keyword arguments) will be passed to the exception class. If not specified, PolicyNotAuthorized will be used. :return: Returns False if the policy does not allow the action and exc is not provided; otherwise, returns a value that evaluates to True. Note: for rules using the "case" expression, this True value will be the specified string from the expression. """ self.load_rules() # Allow the rule to be a Check tree if isinstance(rule, BaseCheck): result = rule(target, creds, self) elif not self.rules: # No rules to reference means we're going to fail closed result = False else: try: # Evaluate the rule result = self.rules[rule](target, creds, self) except KeyError: LOG.debug("Rule [%s] doesn't exist" % rule) # If the rule doesn't exist, fail closed result = False # If it is False, raise the exception if requested if do_raise and not result: if exc: raise exc(*args, **kwargs) raise PolicyNotAuthorized(rule) return result @six.add_metaclass(abc.ABCMeta) class BaseCheck(object): """Abstract base class for Check classes.""" @abc.abstractmethod def __str__(self): """String representation of the Check tree rooted at this node.""" pass @abc.abstractmethod def __call__(self, target, cred, enforcer): """Triggers if instance of the class is called. Performs the check. Returns False to reject the access or a true value (not necessary True) to accept the access. """ pass class FalseCheck(BaseCheck): """A policy check that always returns False (disallow).""" def __str__(self): """Return a string representation of this check.""" return "!" def __call__(self, target, cred, enforcer): """Check the policy.""" return False class TrueCheck(BaseCheck): """A policy check that always returns True (allow).""" def __str__(self): """Return a string representation of this check.""" return "@" def __call__(self, target, cred, enforcer): """Check the policy.""" return True class Check(BaseCheck): """A base class to allow for user-defined policy checks.""" def __init__(self, kind, match): """Initiates Check instance. :param kind: The kind of the check, i.e., the field before the ':'. :param match: The match of the check, i.e., the field after the ':'. """ self.kind = kind self.match = match def __str__(self): """Return a string representation of this check.""" return "%s:%s" % (self.kind, self.match) class NotCheck(BaseCheck): """Implements the "not" logical operator. A policy check that inverts the result of another policy check. """ def __init__(self, rule): """Initialize the 'not' check. :param rule: The rule to negate. Must be a Check. """ self.rule = rule def __str__(self): """Return a string representation of this check.""" return "not %s" % self.rule def __call__(self, target, cred, enforcer): """Check the policy. Returns the logical inverse of the wrapped check. """ return not self.rule(target, cred, enforcer) class AndCheck(BaseCheck): """Implements the "and" logical operator. A policy check that requires that a list of other checks all return True. """ def __init__(self, rules): """Initialize the 'and' check. :param rules: A list of rules that will be tested. """ self.rules = rules def __str__(self): """Return a string representation of this check.""" return "(%s)" % ' and '.join(str(r) for r in self.rules) def __call__(self, target, cred, enforcer): """Check the policy. Requires that all rules accept in order to return True. """ for rule in self.rules: if not rule(target, cred, enforcer): return False return True def add_check(self, rule): """Adds rule to be tested. Allows addition of another rule to the list of rules that will be tested. Returns the AndCheck object for convenience. """ self.rules.append(rule) return self class OrCheck(BaseCheck): """Implements the "or" operator. A policy check that requires that at least one of a list of other checks returns True. """ def __init__(self, rules): """Initialize the 'or' check. :param rules: A list of rules that will be tested. """ self.rules = rules def __str__(self): """Return a string representation of this check.""" return "(%s)" % ' or '.join(str(r) for r in self.rules) def __call__(self, target, cred, enforcer): """Check the policy. Requires that at least one rule accept in order to return True. """ for rule in self.rules: if rule(target, cred, enforcer): return True return False def add_check(self, rule): """Adds rule to be tested. Allows addition of another rule to the list of rules that will be tested. Returns the OrCheck object for convenience. """ self.rules.append(rule) return self def _parse_check(rule): """Parse a single base check rule into an appropriate Check object.""" # Handle the special checks if rule == '!': return FalseCheck() elif rule == '@': return TrueCheck() try: kind, match = rule.split(':', 1) except Exception: LOG.exception(_LE("Failed to understand rule %s") % rule) # If the rule is invalid, we'll fail closed return FalseCheck() # Find what implements the check if kind in _checks: return _checks[kind](kind, match) elif None in _checks: return _checks[None](kind, match) else: LOG.error(_LE("No handler for matches of kind %s") % kind) return FalseCheck() def _parse_list_rule(rule): """Translates the old list-of-lists syntax into a tree of Check objects. Provided for backwards compatibility. """ # Empty rule defaults to True if not rule: return TrueCheck() # Outer list is joined by "or"; inner list by "and" or_list = [] for inner_rule in rule: # Elide empty inner lists if not inner_rule: continue # Handle bare strings if isinstance(inner_rule, six.string_types): inner_rule = [inner_rule] # Parse the inner rules into Check objects and_list = [_parse_check(r) for r in inner_rule] # Append the appropriate check to the or_list if len(and_list) == 1: or_list.append(and_list[0]) else: or_list.append(AndCheck(and_list)) # If we have only one check, omit the "or" if not or_list: return FalseCheck() elif len(or_list) == 1: return or_list[0] return OrCheck(or_list) # Used for tokenizing the policy language _tokenize_re = re.compile(r'\s+') def _parse_tokenize(rule): """Tokenizer for the policy language. Most of the single-character tokens are specified in the _tokenize_re; however, parentheses need to be handled specially, because they can appear inside a check string. Thankfully, those parentheses that appear inside a check string can never occur at the very beginning or end ("%(variable)s" is the correct syntax). """ for tok in _tokenize_re.split(rule): # Skip empty tokens if not tok or tok.isspace(): continue # Handle leading parens on the token clean = tok.lstrip('(') for i in range(len(tok) - len(clean)): yield '(', '(' # If it was only parentheses, continue if not clean: continue else: tok = clean # Handle trailing parens on the token clean = tok.rstrip(')') trail = len(tok) - len(clean) # Yield the cleaned token lowered = clean.lower() if lowered in ('and', 'or', 'not'): # Special tokens yield lowered, clean elif clean: # Not a special token, but not composed solely of ')' if len(tok) >= 2 and ((tok[0], tok[-1]) in [('"', '"'), ("'", "'")]): # It's a quoted string yield 'string', tok[1:-1] else: yield 'check', _parse_check(clean) # Yield the trailing parens for i in range(trail): yield ')', ')' class ParseStateMeta(type): """Metaclass for the ParseState class. Facilitates identifying reduction methods. """ def __new__(mcs, name, bases, cls_dict): """Create the class. Injects the 'reducers' list, a list of tuples matching token sequences to the names of the corresponding reduction methods. """ reducers = [] for key, value in cls_dict.items(): if not hasattr(value, 'reducers'): continue for reduction in value.reducers: reducers.append((reduction, key)) cls_dict['reducers'] = reducers return super(ParseStateMeta, mcs).__new__(mcs, name, bases, cls_dict) def reducer(*tokens): """Decorator for reduction methods. Arguments are a sequence of tokens, in order, which should trigger running this reduction method. """ def decorator(func): # Make sure we have a list of reducer sequences if not hasattr(func, 'reducers'): func.reducers = [] # Add the tokens to the list of reducer sequences func.reducers.append(list(tokens)) return func return decorator @six.add_metaclass(ParseStateMeta) class ParseState(object): """Implement the core of parsing the policy language. Uses a greedy reduction algorithm to reduce a sequence of tokens into a single terminal, the value of which will be the root of the Check tree. Note: error reporting is rather lacking. The best we can get with this parser formulation is an overall "parse failed" error. Fortunately, the policy language is simple enough that this shouldn't be that big a problem. """ def __init__(self): """Initialize the ParseState.""" self.tokens = [] self.values = [] def reduce(self): """Perform a greedy reduction of the token stream. If a reducer method matches, it will be executed, then the reduce() method will be called recursively to search for any more possible reductions. """ for reduction, methname in self.reducers: if (len(self.tokens) >= len(reduction) and self.tokens[-len(reduction):] == reduction): # Get the reduction method meth = getattr(self, methname) # Reduce the token stream results = meth(*self.values[-len(reduction):]) # Update the tokens and values self.tokens[-len(reduction):] = [r[0] for r in results] self.values[-len(reduction):] = [r[1] for r in results] # Check for any more reductions return self.reduce() def shift(self, tok, value): """Adds one more token to the state. Calls reduce().""" self.tokens.append(tok) self.values.append(value) # Do a greedy reduce... self.reduce() @property def result(self): """Obtain the final result of the parse. Raises ValueError if the parse failed to reduce to a single result. """ if len(self.values) != 1: raise ValueError("Could not parse rule") return self.values[0] @reducer('(', 'check', ')') @reducer('(', 'and_expr', ')') @reducer('(', 'or_expr', ')') def _wrap_check(self, _p1, check, _p2): """Turn parenthesized expressions into a 'check' token.""" return [('check', check)] @reducer('check', 'and', 'check') def _make_and_expr(self, check1, _and, check2): """Create an 'and_expr'. Join two checks by the 'and' operator. """ return [('and_expr', AndCheck([check1, check2]))] @reducer('and_expr', 'and', 'check') def _extend_and_expr(self, and_expr, _and, check): """Extend an 'and_expr' by adding one more check.""" return [('and_expr', and_expr.add_check(check))] @reducer('check', 'or', 'check') def _make_or_expr(self, check1, _or, check2): """Create an 'or_expr'. Join two checks by the 'or' operator. """ return [('or_expr', OrCheck([check1, check2]))] @reducer('or_expr', 'or', 'check') def _extend_or_expr(self, or_expr, _or, check): """Extend an 'or_expr' by adding one more check.""" return [('or_expr', or_expr.add_check(check))] @reducer('not', 'check') def _make_not_expr(self, _not, check): """Invert the result of another check.""" return [('check', NotCheck(check))] def _parse_text_rule(rule): """Parses policy to the tree. Translates a policy written in the policy language into a tree of Check objects. """ # Empty rule means always accept if not rule: return TrueCheck() # Parse the token stream state = ParseState() for tok, value in _parse_tokenize(rule): state.shift(tok, value) try: return state.result except ValueError: # Couldn't parse the rule LOG.exception(_LE("Failed to understand rule %s") % rule) # Fail closed return FalseCheck() def parse_rule(rule): """Parses a policy rule into a tree of Check objects.""" # If the rule is a string, it's in the policy language if isinstance(rule, six.string_types): return _parse_text_rule(rule) return _parse_list_rule(rule) def register(name, func=None): """Register a function or Check class as a policy check. :param name: Gives the name of the check type, e.g., 'rule', 'role', etc. If name is None, a default check type will be registered. :param func: If given, provides the function or class to register. If not given, returns a function taking one argument to specify the function or class to register, allowing use as a decorator. """ # Perform the actual decoration by registering the function or # class. Returns the function or class for compliance with the # decorator interface. def decorator(func): _checks[name] = func return func # If the function or class is given, do the registration if func: return decorator(func) return decorator @register("rule") class RuleCheck(Check): def __call__(self, target, creds, enforcer): """Recursively checks credentials based on the defined rules.""" try: return enforcer.rules[self.match](target, creds, enforcer) except KeyError: # We don't have any matching rule; fail closed return False @register("role") class RoleCheck(Check): def __call__(self, target, creds, enforcer): """Check that there is a matching role in the cred dict.""" return self.match.lower() in [x.lower() for x in creds['roles']] @register('http') class HttpCheck(Check): def __call__(self, target, creds, enforcer): """Check http: rules by calling to a remote server. This example implementation simply verifies that the response is exactly 'True'. """ url = ('http:' + self.match) % target # Convert instances of object() in target temporarily to # empty dict to avoid circular reference detection # errors in jsonutils.dumps(). temp_target = copy.deepcopy(target) for key in target.keys(): element = target.get(key) if type(element) is object: temp_target[key] = {} data = {'target': jsonutils.dumps(temp_target), 'credentials': jsonutils.dumps(creds)} post_data = urlparse.urlencode(data) f = urlrequest.urlopen(url, post_data) return f.read() == "True" @register(None) class GenericCheck(Check): def __call__(self, target, creds, enforcer): """Check an individual match. Matches look like: tenant:%(tenant_id)s role:compute:admin True:%(user.enabled)s 'Member':%(role.name)s """ try: match = self.match % target except KeyError: # While doing GenericCheck if key not # present in Target return false return False try: # Try to interpret self.kind as a literal leftval = ast.literal_eval(self.kind) except ValueError: try: kind_parts = self.kind.split('.') leftval = creds for kind_part in kind_parts: leftval = leftval[kind_part] except KeyError: return False return match == six.text_type(leftval)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 14260, 2752, 14, 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, 624, 199, 7844, 18141, 12580, 24425, 199, 199, 27079, 883, 506, 19147, 315, 1373, 402, 2877, 4513, 26, 437, 769, 402, 5548, 12, 503, 282, 199, 875, 5313, 315, 314, 892, 4592, 2637, 14, 199, 199, 607, 314, 769, 13, 1618, 13, 6717, 6025, 12, 1924, 1104, 6272, 314, 6506, 2786, 199, 513, 365, 12149, 465, 543, 376, 298, 460, 2, 22888, 306, 509, 626, 1104, 370, 986, 12, 199, 452, 314, 2013, 5920, 1471, 986, 14, 221, 5723, 6506, 2786, 5548, 787, 2066, 199, 17583, 465, 543, 376, 298, 269, 2, 22888, 14, 3709, 376, 2893, 12, 5452, 314, 2569, 199, 2200, 12, 19147, 315, 314, 769, 13, 1618, 13, 6717, 6025, 447, 339, 24212, 3756, 26, 2113, 2255, 2097, 1715, 63, 344, 19648, 1715, 63, 344, 9, 83, 401, 298, 3756, 26, 1715, 2113, 15261, 199, 199, 2765, 365, 314, 3379, 4340, 402, 4056, 316, 14118, 12, 1325, 2337, 3063, 3495, 282, 199, 1222, 4340, 26, 314, 4592, 2637, 14, 199, 199, 607, 314, 4592, 2637, 12, 1924, 1104, 365, 2013, 314, 2011, 4340, 465, 315, 314, 199, 513, 13, 1618, 13, 6717, 6025, 26, 282, 3486, 298, 65, 26, 66, 2, 4092, 626, 365, 7838, 370, 199, 1589, 3211, 1021, 370, 5147, 626, 1104, 447, 421, 435, 5695, 21326, 11, 199, 1204, 3322, 11511, 4483, 1204, 4483, 25486, 8540, 1204, 199, 435, 5695, 21326, 11, 199, 1204, 1899, 1159, 18033, 9326, 1204, 4519, 4719, 26, 2113, 8295, 1204, 199, 435, 3606, 27592, 199, 1204, 12920, 2575, 3247, 641, 4592, 1204, 3515, 2332, 26, 2113, 63, 2427, 3777, 1204, 199, 435, 3606, 27592, 199, 1204, 5676, 1581, 270, 2851, 1159, 127, 118, 8295, 1204, 260, 1455, 921, 1662, 13, 633, 14, 1308, 15, 1074, 3515, 1204, 199, 435, 3606, 27592, 199, 1204, 1899, 3004, 127, 111, 4483, 1204, 259, 2199, 63, 344, 19648, 1375, 14, 1715, 14, 344, 9, 83, 420, 1204, 199, 435, 3606, 27592, 199, 1204, 12672, 12793, 1204, 263, 665, 1975, 30, 4881, 88, 5816, 1165, 1276, 3175, 7, 3515, 1204, 199, 1204, 13293, 1204, 260, 283, 1662, 1715, 356, 28, 1975, 30, 3698, 1204, 199, 435, 3606, 27592, 199, 1204, 13293, 1204, 260, 2199, 63, 344, 26, 88, 5816, 1165, 1276, 3175, 3698, 1204, 199, 1204, 44, 1661, 2551, 12788, 1204, 260, 2881, 63, 344, 26, 1165, 9326, 1204, 199, 1204, 13293, 1204, 260, 715, 19648, 751, 14, 3827, 9, 83, 3322, 1204, 199, 435, 5695, 21326, 11, 199, 199, 127, 118, 2632, 7907, 1471, 372, 283, 549, 7, 370, 506, 1686, 199, 127, 111, 1899, 3004, 334, 2873, 877, 379, 4012, 314, 1526, 304, 922, 63, 344, 12, 2881, 63, 344, 503, 2199, 63, 344, 199, 199, 714, 32367, 10211, 787, 2808, 12, 17266, 367, 1655, 1437, 470, 338, 1856, 16709, 199, 262, 286, 4800, 316, 14118, 14, 2002, 12, 315, 314, 4592, 2637, 12, 314, 4136, 1104, 315, 199, 513, 13, 1618, 13, 6717, 15410, 447, 339, 4719, 26, 2113, 503, 334, 1715, 63, 344, 19648, 1715, 63, 344, 9, 83, 436, 4719, 26, 1715, 2113, 9, 199, 199, 1918, 4592, 2637, 2597, 965, 314, 298, 1397, 2, 4182, 12, 17266, 282, 8012, 7641, 199, 3185, 2332, 447, 339, 2199, 63, 344, 19648, 1715, 63, 344, 9, 83, 436, 440, 4719, 26, 68, 10222, 199, 199, 5379, 4847, 3180, 543, 3261, 4882, 883, 506, 1202, 701, 314, 4592, 6869, 199, 8, 265, 314, 2451, 5366, 402, 314, 3965, 395, 701, 1808, 314, 2569, 6302, 447, 339, 665, 3972, 63, 585, 30, 19648, 751, 14, 344, 9, 83, 199, 199, 2998, 1061, 3004, 402, 2251, 15836, 701, 3932, 11449, 787, 6511, 199, 504, 314, 3050, 14, 9322, 787, 2597, 2808, 370, 314, 4592, 6869, 436, 199, 2425, 506, 7923, 4012, 314, 658, 1375, 64, 4252, 447, 339, 665, 3972, 63, 585, 30, 19648, 1375, 14, 3756, 14, 354, 9, 83, 199, 199, 8694, 1183, 12, 2877, 4539, 4592, 5920, 1077, 506, 26239, 27, 314, 4592, 199, 1074, 9244, 2, 911, 3544, 4729, 376, 2879, 12, 436, 314, 4592, 1104, 298, 9539, 911, 199, 9223, 17100, 376, 2879, 14, 221, 334, 7443, 626, 340, 282, 2332, 365, 1902, 314, 2701, 199, 513, 1689, 31346, 503, 314, 2701, 1059, 12, 642, 365, 7353, 370, 314, 9244, 2, 4592, 199, 1074, 4959, 221, 24545, 3520, 12, 314, 298, 9539, 4592, 1104, 365, 8646, 314, 4750, 2997, 12, 199, 305, 652, 6127, 6770, 4713, 370, 506, 7662, 6980, 14, 199, 624, 199, 199, 646, 13022, 199, 646, 6073, 199, 646, 1331, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 3816, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1122, 465, 7097, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1069, 465, 1166, 1069, 199, 199, 504, 5913, 14, 8512, 14, 2330, 423, 73, 1085, 78, 492, 5501, 485, 906, 199, 504, 5913, 492, 3778, 199, 199, 3185, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 3185, 63, 493, 297, 2049, 849, 534, 3185, 14, 1001, 297, 2049, 1720, 12397, 1918, 4840, 570, 626, 7890, 14118, 2659, 395, 272, 4810, 14, 19340, 360, 3185, 63, 885 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 6029, 14260, 2752, 14, 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, 624, 199, 7844, 18141, 12580, 24425, 199, 199, 27079, 883, 506, 19147, 315, 1373, 402, 2877, 4513, 26, 437, 769, 402, 5548, 12, 503, 282, 199, 875, 5313, 315, 314, 892, 4592, 2637, 14, 199, 199, 607, 314, 769, 13, 1618, 13, 6717, 6025, 12, 1924, 1104, 6272, 314, 6506, 2786, 199, 513, 365, 12149, 465, 543, 376, 298, 460, 2, 22888, 306, 509, 626, 1104, 370, 986, 12, 199, 452, 314, 2013, 5920, 1471, 986, 14, 221, 5723, 6506, 2786, 5548, 787, 2066, 199, 17583, 465, 543, 376, 298, 269, 2, 22888, 14, 3709, 376, 2893, 12, 5452, 314, 2569, 199, 2200, 12, 19147, 315, 314, 769, 13, 1618, 13, 6717, 6025, 447, 339, 24212, 3756, 26, 2113, 2255, 2097, 1715, 63, 344, 19648, 1715, 63, 344, 9, 83, 401, 298, 3756, 26, 1715, 2113, 15261, 199, 199, 2765, 365, 314, 3379, 4340, 402, 4056, 316, 14118, 12, 1325, 2337, 3063, 3495, 282, 199, 1222, 4340, 26, 314, 4592, 2637, 14, 199, 199, 607, 314, 4592, 2637, 12, 1924, 1104, 365, 2013, 314, 2011, 4340, 465, 315, 314, 199, 513, 13, 1618, 13, 6717, 6025, 26, 282, 3486, 298, 65, 26, 66, 2, 4092, 626, 365, 7838, 370, 199, 1589, 3211, 1021, 370, 5147, 626, 1104, 447, 421, 435, 5695, 21326, 11, 199, 1204, 3322, 11511, 4483, 1204, 4483, 25486, 8540, 1204, 199, 435, 5695, 21326, 11, 199, 1204, 1899, 1159, 18033, 9326, 1204, 4519, 4719, 26, 2113, 8295, 1204, 199, 435, 3606, 27592, 199, 1204, 12920, 2575, 3247, 641, 4592, 1204, 3515, 2332, 26, 2113, 63, 2427, 3777, 1204, 199, 435, 3606, 27592, 199, 1204, 5676, 1581, 270, 2851, 1159, 127, 118, 8295, 1204, 260, 1455, 921, 1662, 13, 633, 14, 1308, 15, 1074, 3515, 1204, 199, 435, 3606, 27592, 199, 1204, 1899, 3004, 127, 111, 4483, 1204, 259, 2199, 63, 344, 19648, 1375, 14, 1715, 14, 344, 9, 83, 420, 1204, 199, 435, 3606, 27592, 199, 1204, 12672, 12793, 1204, 263, 665, 1975, 30, 4881, 88, 5816, 1165, 1276, 3175, 7, 3515, 1204, 199, 1204, 13293, 1204, 260, 283, 1662, 1715, 356, 28, 1975, 30, 3698, 1204, 199, 435, 3606, 27592, 199, 1204, 13293, 1204, 260, 2199, 63, 344, 26, 88, 5816, 1165, 1276, 3175, 3698, 1204, 199, 1204, 44, 1661, 2551, 12788, 1204, 260, 2881, 63, 344, 26, 1165, 9326, 1204, 199, 1204, 13293, 1204, 260, 715, 19648, 751, 14, 3827, 9, 83, 3322, 1204, 199, 435, 5695, 21326, 11, 199, 199, 127, 118, 2632, 7907, 1471, 372, 283, 549, 7, 370, 506, 1686, 199, 127, 111, 1899, 3004, 334, 2873, 877, 379, 4012, 314, 1526, 304, 922, 63, 344, 12, 2881, 63, 344, 503, 2199, 63, 344, 199, 199, 714, 32367, 10211, 787, 2808, 12, 17266, 367, 1655, 1437, 470, 338, 1856, 16709, 199, 262, 286, 4800, 316, 14118, 14, 2002, 12, 315, 314, 4592, 2637, 12, 314, 4136, 1104, 315, 199, 513, 13, 1618, 13, 6717, 15410, 447, 339, 4719, 26, 2113, 503, 334, 1715, 63, 344, 19648, 1715, 63, 344, 9, 83, 436, 4719, 26, 1715, 2113, 9, 199, 199, 1918, 4592, 2637, 2597, 965, 314, 298, 1397, 2, 4182, 12, 17266, 282, 8012, 7641, 199, 3185, 2332, 447, 339, 2199, 63, 344, 19648, 1715, 63, 344, 9, 83, 436, 440, 4719, 26, 68, 10222, 199, 199, 5379, 4847, 3180, 543, 3261, 4882, 883, 506, 1202, 701, 314, 4592, 6869, 199, 8, 265, 314, 2451, 5366, 402, 314, 3965, 395, 701, 1808, 314, 2569, 6302, 447, 339, 665, 3972, 63, 585, 30, 19648, 751, 14, 344, 9, 83, 199, 199, 2998, 1061, 3004, 402, 2251, 15836, 701, 3932, 11449, 787, 6511, 199, 504, 314, 3050, 14, 9322, 787, 2597, 2808, 370, 314, 4592, 6869, 436, 199, 2425, 506, 7923, 4012, 314, 658, 1375, 64, 4252, 447, 339, 665, 3972, 63, 585, 30, 19648, 1375, 14, 3756, 14, 354, 9, 83, 199, 199, 8694, 1183, 12, 2877, 4539, 4592, 5920, 1077, 506, 26239, 27, 314, 4592, 199, 1074, 9244, 2, 911, 3544, 4729, 376, 2879, 12, 436, 314, 4592, 1104, 298, 9539, 911, 199, 9223, 17100, 376, 2879, 14, 221, 334, 7443, 626, 340, 282, 2332, 365, 1902, 314, 2701, 199, 513, 1689, 31346, 503, 314, 2701, 1059, 12, 642, 365, 7353, 370, 314, 9244, 2, 4592, 199, 1074, 4959, 221, 24545, 3520, 12, 314, 298, 9539, 4592, 1104, 365, 8646, 314, 4750, 2997, 12, 199, 305, 652, 6127, 6770, 4713, 370, 506, 7662, 6980, 14, 199, 624, 199, 199, 646, 13022, 199, 646, 6073, 199, 646, 1331, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 12161, 492, 18705, 199, 646, 3816, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1122, 465, 7097, 199, 646, 3816, 14, 4912, 14, 4078, 14, 1069, 465, 1166, 1069, 199, 199, 504, 5913, 14, 8512, 14, 2330, 423, 73, 1085, 78, 492, 5501, 485, 906, 199, 504, 5913, 492, 3778, 199, 199, 3185, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 3185, 63, 493, 297, 2049, 849, 534, 3185, 14, 1001, 297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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 ]
andeplane/lammps
tools/i-pi/ipi/inputs/ensembles.py
41
8167
"""Deals with creating the ensembles class. Copyright (C) 2013, Joshua More and Michele Ceriotti 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/>. Classes: InputEnsemble: Deals with creating the Ensemble object from a file, and writing the checkpoints. """ import numpy as np import ipi.engine.thermostats import ipi.engine.initializer import ipi.engine.barostats from ipi.engine.ensembles import * from ipi.utils.inputvalue import * from ipi.inputs.barostats import * from ipi.inputs.thermostats import * from ipi.inputs.initializer import * from ipi.utils.units import * __all__ = ['InputEnsemble'] class InputEnsemble(Input): """Ensemble input class. Handles generating the appropriate ensemble class from the xml input file, and generating the xml checkpoint tags and data from an instance of the object. Attributes: mode: An optional string giving the mode of ensemble to be simulated. Defaults to 'unknown'. Fields: thermostat: The thermostat to be used for constant temperature dynamics. barostat: The barostat to be used for constant pressure or stress dynamics. timestep: An optional float giving the size of the timestep in atomic units. Defaults to 1.0. temperature: An optional float giving the temperature in Kelvin. Defaults to 1.0. pressure: An optional float giving the external pressure in atomic units. Defaults to 1.0. fixcom: An optional boolean which decides whether the centre of mass motion will be constrained or not. Defaults to False. replay_file: An optional string that gives an input file name to get a trajectory to be re-run. """ attribs={"mode" : (InputAttribute, {"dtype" : str, "help" : "The ensemble that will be sampled during the simulation. 'replay' means that a simulation is restarted from a previous simulation.", "options" : ['nve', 'nvt', 'npt', 'replay']}) } fields={"thermostat" : (InputThermo, {"default" : input_default(factory=ipi.engine.thermostats.Thermostat), "help" : "The thermostat for the atoms, keeps the atom velocity distribution at the correct temperature."} ), "barostat" : (InputBaro, {"default" : input_default(factory=ipi.engine.barostats.Barostat), "help" : InputBaro.default_help}), "timestep": (InputValue, {"dtype" : float, "default" : 1.0, "help" : "The time step.", "dimension" : "time"}), "temperature" : (InputValue, {"dtype" : float, "default" : 1.0, "help" : "The temperature of the system.", "dimension" : "temperature"}), "pressure" : (InputValue, {"dtype" : float, "default" : 1.0, "help" : "The external pressure.", "dimension" : "pressure"}), "fixcom": (InputValue, {"dtype" : bool, "default" : True, "help" : "This describes whether the centre of mass of the particles is fixed."}), "replay_file": (InputInitFile, {"default" : input_default(factory=ipi.engine.initializer.InitBase), "help" : "This describes the location to read a trajectory file from."}) } default_help = "Holds all the information that is ensemble specific, such as the temperature and the external pressure, and the thermostats and barostats that control it." default_label = "ENSEMBLE" def store(self, ens): """Takes an ensemble instance and stores a minimal representation of it. Args: ens: An ensemble object. """ super(InputEnsemble,self).store(ens) if type(ens) is ReplayEnsemble: self.mode.store("rerun") tens = 0 elif type(ens) is NVEEnsemble: self.mode.store("nve") tens = 1 elif type(ens) is NVTEnsemble: self.mode.store("nvt") tens = 2 elif type(ens) is NPTEnsemble: self.mode.store("npt") tens = 3 self.timestep.store(ens.dt) self.temperature.store(ens.temp) if tens == 0: self.replay_file.store(ens.intraj) if tens > 1: self.thermostat.store(ens.thermostat) self.fixcom.store(ens.fixcom) if tens > 2: self.barostat.store(ens.barostat) if tens == 3: self.pressure.store(ens.pext) def fetch(self): """Creates an ensemble object. Returns: An ensemble object of the appropriate mode and with the appropriate objects given the attributes of the InputEnsemble object. """ super(InputEnsemble,self).fetch() if self.mode.fetch() == "nve" : ens = NVEEnsemble(dt=self.timestep.fetch(), temp=self.temperature.fetch(), fixcom=self.fixcom.fetch()) elif self.mode.fetch() == "nvt" : ens = NVTEnsemble(dt=self.timestep.fetch(), temp=self.temperature.fetch(), thermostat=self.thermostat.fetch(), fixcom=self.fixcom.fetch()) elif self.mode.fetch() == "npt" : ens = NPTEnsemble(dt=self.timestep.fetch(), temp=self.temperature.fetch(), thermostat=self.thermostat.fetch(), fixcom=self.fixcom.fetch(), pext=self.pressure.fetch(), barostat=self.barostat.fetch() ) elif self.mode.fetch() == "replay": ens = ReplayEnsemble(dt=self.timestep.fetch(), temp=self.temperature.fetch(),fixcom=False,intraj=self.replay_file.fetch() ) else: raise ValueError("'" + self.mode.fetch() + "' is not a supported ensemble mode.") return ens def check(self): """Function that deals with optional arguments. Makes sure that if the ensemble requires a thermostat or barostat that they have been defined by the user and not given the default values. """ super(InputEnsemble,self).check() if self.mode.fetch() == "nvt": if self.thermostat._explicit == False: raise ValueError("No thermostat tag supplied for NVT simulation") if self.mode.fetch() == "npt": if self.thermostat._explicit == False: raise ValueError("No thermostat tag supplied for NPT simulation") if self.barostat._explicit == False: raise ValueError("No barostat tag supplied for NPT simulation") if self.barostat.thermostat._explicit == False: raise ValueError("No thermostat tag supplied in barostat for NPT simulation") if self.timestep.fetch() <= 0: raise ValueError("Non-positive timestep specified.") if self.temperature.fetch() <= 0: raise ValueError("Non-positive temperature specified.") if self.mode.fetch() == "npt": if not self.pressure._explicit: raise ValueError("Pressure should be supplied for constant pressure simulation") if self.mode.fetch() == "npt" or self.mode.fetch() == "nvt": if not self.temperature._explicit: raise ValueError("Temperature should be supplied for constant temperature simulation")
gpl-2.0
[ 624, 872, 2551, 543, 6425, 314, 19965, 83, 1021, 14, 199, 199, 7384, 334, 35, 9, 6171, 12, 7135, 609, 1458, 16917, 436, 603, 73, 595, 274, 11002, 73, 357, 280, 199, 199, 2765, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 221, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 14, 501, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 15711, 26, 2043, 6924, 1327, 8834, 26, 1487, 2551, 543, 6425, 314, 3447, 8834, 909, 687, 282, 570, 12, 436, 489, 3575, 314, 1104, 3438, 14, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 646, 284, 1038, 14, 3908, 14, 728, 2786, 1956, 199, 646, 284, 1038, 14, 3908, 14, 6498, 199, 646, 284, 1038, 14, 3908, 14, 1700, 941, 1956, 199, 504, 284, 1038, 14, 3908, 14, 15628, 83, 492, 627, 199, 504, 284, 1038, 14, 1208, 14, 1210, 585, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 1700, 941, 1956, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 728, 2786, 1956, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 6498, 492, 627, 199, 504, 284, 1038, 14, 1208, 14, 5260, 492, 627, 199, 199, 363, 452, 363, 275, 788, 3205, 1327, 8834, 418, 199, 199, 533, 6924, 1327, 8834, 8, 3205, 304, 2043, 408, 1327, 8834, 1324, 1021, 14, 8410, 23873, 12999, 314, 5827, 19965, 1021, 687, 314, 2748, 1324, 570, 12, 2043, 436, 12999, 314, 2748, 9997, 3762, 436, 666, 687, 376, 1256, 402, 314, 2043, 909, 14, 8410, 9382, 26, 489, 818, 26, 1626, 2716, 1059, 15131, 314, 818, 402, 19965, 370, 506, 4389, 8097, 14, 268, 7827, 370, 283, 5187, 1370, 8410, 16424, 26, 489, 23418, 21850, 26, 710, 23418, 21850, 370, 506, 1202, 367, 4413, 14843, 31388, 2932, 14, 489, 4681, 941, 292, 26, 710, 4681, 941, 292, 370, 506, 1202, 367, 4413, 25471, 503, 31692, 268, 31388, 2932, 14, 489, 900, 2926, 26, 1626, 2716, 2069, 15131, 314, 1568, 402, 314, 900, 2926, 315, 15374, 268, 6204, 14, 7827, 370, 413, 14, 16, 14, 489, 14843, 26, 1626, 2716, 2069, 15131, 314, 14843, 315, 1804, 352, 11908, 14, 7827, 268, 370, 413, 14, 16, 14, 489, 25471, 26, 1626, 2716, 2069, 15131, 314, 5957, 25471, 315, 15374, 6204, 14, 268, 7827, 370, 413, 14, 16, 14, 489, 5325, 957, 26, 1626, 2716, 5046, 1314, 12985, 3424, 3775, 314, 13345, 264, 402, 12250, 268, 25134, 911, 506, 28483, 503, 440, 14, 7827, 370, 756, 14, 489, 24331, 63, 493, 26, 1626, 2716, 1059, 626, 10557, 376, 1324, 570, 536, 370, 664, 268, 282, 30595, 370, 506, 295, 13, 1065, 14, 2043, 408, 8410, 737, 19577, 8871, 632, 2, 221, 520, 334, 3205, 1646, 12, 2420, 2271, 2, 257, 520, 620, 12, 2511, 298, 3437, 2, 259, 520, 298, 1918, 19965, 626, 911, 506, 24914, 5309, 314, 17625, 14, 283, 19540, 7, 4910, 626, 282, 17625, 365, 32277, 687, 282, 4136, 17625, 4765, 2511, 298, 1419, 2, 520, 788, 78, 432, 297, 283, 78, 5941, 297, 283, 78, 541, 297, 283, 19540, 13678, 789, 2043, 1504, 8871, 728, 21850, 2, 520, 334, 3205, 31567, 573, 12, 2420, 885, 2, 257, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 728, 2786, 1956, 14, 31567, 21850, 395, 1460, 298, 3437, 2, 420, 520, 298, 1918, 23418, 21850, 367, 314, 14503, 12, 18578, 314, 6222, 20508, 4084, 737, 314, 3211, 14843, 2122, 93, 2318, 1779, 298, 1700, 941, 292, 2, 520, 334, 3205, 5281, 79, 12, 2420, 885, 2, 755, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 1700, 941, 1956, 14, 5281, 941, 292, 395, 3660, 298, 3437, 2, 3515, 520, 6924, 5281, 79, 14, 885, 63, 3437, 8688, 1779, 298, 521, 2926, 582, 334, 3205, 1110, 12, 2420, 2271, 2, 260, 520, 2069, 12, 3660, 298, 885, 2, 755, 520, 413, 14, 16, 12, 3660, 298, 3437, 2, 3515, 520, 298, 1918, 900, 3650, 4765, 3660, 298, 7430, 2, 258, 520, 298, 521, 5593, 1779, 298, 12954, 2, 520, 334, 3205, 1110, 12, 2420, 2271, 2, 258, 520, 2069, 12, 1460, 298, 885, 2, 257, 520, 413, 14, 16, 12, 1460, 298, 3437, 2, 420, 520, 298, 1918, 14843, 402, 314, 2656, 4765, 1460, 298, 7430, 2, 520, 298, 12954, 5593, 1779, 298, 21999, 2, 520, 334, 3205, 1110, 12, 2420, 2271, 2, 263, 520, 2069, 12, 4228, 298, 885, 2, 420, 520, 413, 14, 16, 12, 4228, 298, 3437, 2, 260, 520, 298, 1918, 5957, 25471, 4765, 4228, 298, 7430, 2, 259, 520, 298, 21999, 5593, 1779, 298, 970, 957, 582, 334, 3205, 1110, 12, 2420, 2271, 2, 3698, 520, 2155, 12, 3521, 298, 885, 2, 260, 520, 715, 12, 3521, 298, 3437, 2, 3322, 520, 298, 2765, 23369, 3775, 314, 13345, 264, 402, 12250, 402, 314, 26115, 365, 6317, 2122, 8688, 1779, 298, 19540, 63, 493, 582, 334, 3205, 9346, 1173, 12, 2420, 885, 2, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 6498, 14, 9346, 1563, 395, 2574, 298, 3437, 2, 3322, 520, 298, 2765, 23369, 314, 2909, 370, 1586, 282, 30595, 570, 687, 2122, 1552, 268, 789, 8410, 849, 63, 3437, 275, 298, 40, 8250, 1006, 314, 2556, 626, 365, 19965, 2488, 12, 4066, 465, 314, 14843, 436, 314, 5957, 25471, 12, 436, 314, 23418, 2786, 1956, 436, 4681, 941, 1956, 626, 3304, 652, 2122, 2043, 849, 63, 1302, 275, 298, 2857, 4567, 906, 2, 8410, 347, 3877, 8, 277, 12, 12889, 304, 489, 408, 32488, 376, 19965, 1256 ]
[ 872, 2551, 543, 6425, 314, 19965, 83, 1021, 14, 199, 199, 7384, 334, 35, 9, 6171, 12, 7135, 609, 1458, 16917, 436, 603, 73, 595, 274, 11002, 73, 357, 280, 199, 199, 2765, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 221, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 14, 501, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 15711, 26, 2043, 6924, 1327, 8834, 26, 1487, 2551, 543, 6425, 314, 3447, 8834, 909, 687, 282, 570, 12, 436, 489, 3575, 314, 1104, 3438, 14, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 646, 284, 1038, 14, 3908, 14, 728, 2786, 1956, 199, 646, 284, 1038, 14, 3908, 14, 6498, 199, 646, 284, 1038, 14, 3908, 14, 1700, 941, 1956, 199, 504, 284, 1038, 14, 3908, 14, 15628, 83, 492, 627, 199, 504, 284, 1038, 14, 1208, 14, 1210, 585, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 1700, 941, 1956, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 728, 2786, 1956, 492, 627, 199, 504, 284, 1038, 14, 3711, 14, 6498, 492, 627, 199, 504, 284, 1038, 14, 1208, 14, 5260, 492, 627, 199, 199, 363, 452, 363, 275, 788, 3205, 1327, 8834, 418, 199, 199, 533, 6924, 1327, 8834, 8, 3205, 304, 2043, 408, 1327, 8834, 1324, 1021, 14, 8410, 23873, 12999, 314, 5827, 19965, 1021, 687, 314, 2748, 1324, 570, 12, 2043, 436, 12999, 314, 2748, 9997, 3762, 436, 666, 687, 376, 1256, 402, 314, 2043, 909, 14, 8410, 9382, 26, 489, 818, 26, 1626, 2716, 1059, 15131, 314, 818, 402, 19965, 370, 506, 4389, 8097, 14, 268, 7827, 370, 283, 5187, 1370, 8410, 16424, 26, 489, 23418, 21850, 26, 710, 23418, 21850, 370, 506, 1202, 367, 4413, 14843, 31388, 2932, 14, 489, 4681, 941, 292, 26, 710, 4681, 941, 292, 370, 506, 1202, 367, 4413, 25471, 503, 31692, 268, 31388, 2932, 14, 489, 900, 2926, 26, 1626, 2716, 2069, 15131, 314, 1568, 402, 314, 900, 2926, 315, 15374, 268, 6204, 14, 7827, 370, 413, 14, 16, 14, 489, 14843, 26, 1626, 2716, 2069, 15131, 314, 14843, 315, 1804, 352, 11908, 14, 7827, 268, 370, 413, 14, 16, 14, 489, 25471, 26, 1626, 2716, 2069, 15131, 314, 5957, 25471, 315, 15374, 6204, 14, 268, 7827, 370, 413, 14, 16, 14, 489, 5325, 957, 26, 1626, 2716, 5046, 1314, 12985, 3424, 3775, 314, 13345, 264, 402, 12250, 268, 25134, 911, 506, 28483, 503, 440, 14, 7827, 370, 756, 14, 489, 24331, 63, 493, 26, 1626, 2716, 1059, 626, 10557, 376, 1324, 570, 536, 370, 664, 268, 282, 30595, 370, 506, 295, 13, 1065, 14, 2043, 408, 8410, 737, 19577, 8871, 632, 2, 221, 520, 334, 3205, 1646, 12, 2420, 2271, 2, 257, 520, 620, 12, 2511, 298, 3437, 2, 259, 520, 298, 1918, 19965, 626, 911, 506, 24914, 5309, 314, 17625, 14, 283, 19540, 7, 4910, 626, 282, 17625, 365, 32277, 687, 282, 4136, 17625, 4765, 2511, 298, 1419, 2, 520, 788, 78, 432, 297, 283, 78, 5941, 297, 283, 78, 541, 297, 283, 19540, 13678, 789, 2043, 1504, 8871, 728, 21850, 2, 520, 334, 3205, 31567, 573, 12, 2420, 885, 2, 257, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 728, 2786, 1956, 14, 31567, 21850, 395, 1460, 298, 3437, 2, 420, 520, 298, 1918, 23418, 21850, 367, 314, 14503, 12, 18578, 314, 6222, 20508, 4084, 737, 314, 3211, 14843, 2122, 93, 2318, 1779, 298, 1700, 941, 292, 2, 520, 334, 3205, 5281, 79, 12, 2420, 885, 2, 755, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 1700, 941, 1956, 14, 5281, 941, 292, 395, 3660, 298, 3437, 2, 3515, 520, 6924, 5281, 79, 14, 885, 63, 3437, 8688, 1779, 298, 521, 2926, 582, 334, 3205, 1110, 12, 2420, 2271, 2, 260, 520, 2069, 12, 3660, 298, 885, 2, 755, 520, 413, 14, 16, 12, 3660, 298, 3437, 2, 3515, 520, 298, 1918, 900, 3650, 4765, 3660, 298, 7430, 2, 258, 520, 298, 521, 5593, 1779, 298, 12954, 2, 520, 334, 3205, 1110, 12, 2420, 2271, 2, 258, 520, 2069, 12, 1460, 298, 885, 2, 257, 520, 413, 14, 16, 12, 1460, 298, 3437, 2, 420, 520, 298, 1918, 14843, 402, 314, 2656, 4765, 1460, 298, 7430, 2, 520, 298, 12954, 5593, 1779, 298, 21999, 2, 520, 334, 3205, 1110, 12, 2420, 2271, 2, 263, 520, 2069, 12, 4228, 298, 885, 2, 420, 520, 413, 14, 16, 12, 4228, 298, 3437, 2, 260, 520, 298, 1918, 5957, 25471, 4765, 4228, 298, 7430, 2, 259, 520, 298, 21999, 5593, 1779, 298, 970, 957, 582, 334, 3205, 1110, 12, 2420, 2271, 2, 3698, 520, 2155, 12, 3521, 298, 885, 2, 260, 520, 715, 12, 3521, 298, 3437, 2, 3322, 520, 298, 2765, 23369, 3775, 314, 13345, 264, 402, 12250, 402, 314, 26115, 365, 6317, 2122, 8688, 1779, 298, 19540, 63, 493, 582, 334, 3205, 9346, 1173, 12, 2420, 885, 2, 520, 1324, 63, 885, 8, 3702, 29, 711, 73, 14, 3908, 14, 6498, 14, 9346, 1563, 395, 2574, 298, 3437, 2, 3322, 520, 298, 2765, 23369, 314, 2909, 370, 1586, 282, 30595, 570, 687, 2122, 1552, 268, 789, 8410, 849, 63, 3437, 275, 298, 40, 8250, 1006, 314, 2556, 626, 365, 19965, 2488, 12, 4066, 465, 314, 14843, 436, 314, 5957, 25471, 12, 436, 314, 23418, 2786, 1956, 436, 4681, 941, 1956, 626, 3304, 652, 2122, 2043, 849, 63, 1302, 275, 298, 2857, 4567, 906, 2, 8410, 347, 3877, 8, 277, 12, 12889, 304, 489, 408, 32488, 376, 19965, 1256, 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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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 ]
ghber/My-Django-Nonrel
django/test/simple.py
150
15012
import unittest as real_unittest from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.models import get_app, get_apps from django.test import _doctest as doctest from django.test.utils import setup_test_environment, teardown_test_environment from django.test.testcases import OutputChecker, DocTestRunner, TestCase from django.utils import unittest try: all except NameError: from django.utils.itercompat import all __all__ = ('DjangoTestRunner', 'DjangoTestSuiteRunner', 'run_tests') # The module name for tests outside models.py TEST_MODULE = 'tests' doctestOutputChecker = OutputChecker() class DjangoTestRunner(unittest.TextTestRunner): def __init__(self, *args, **kwargs): import warnings warnings.warn( "DjangoTestRunner is deprecated; it's functionality is indistinguishable from TextTestRunner", PendingDeprecationWarning ) super(DjangoTestRunner, self).__init__(*args, **kwargs) def get_tests(app_module): try: app_path = app_module.__name__.split('.')[:-1] test_module = __import__('.'.join(app_path + [TEST_MODULE]), {}, {}, TEST_MODULE) except ImportError, e: # Couldn't import tests.py. Was it due to a missing file, or # due to an import error in a tests.py that actually exists? import os.path from imp import find_module try: mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)]) except ImportError: # 'tests' module doesn't exist. Move on. test_module = None else: # The module exists, so there must be an import error in the # test module itself. We don't need the module; so if the # module was a single file module (i.e., tests.py), close the file # handle returned by find_module. Otherwise, the test module # is a directory, and there is nothing to close. if mod[0]: mod[0].close() raise return test_module def build_suite(app_module): "Create a complete Django test suite for the provided application module" suite = unittest.TestSuite() # Load unit and doctests in the models.py module. If module has # a suite() method, use it. Otherwise build the test suite ourselves. if hasattr(app_module, 'suite'): suite.addTest(app_module.suite()) else: suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(app_module)) try: suite.addTest(doctest.DocTestSuite(app_module, checker=doctestOutputChecker, runner=DocTestRunner)) except ValueError: # No doc tests in models.py pass # Check to see if a separate 'tests' module exists parallel to the # models module test_module = get_tests(app_module) if test_module: # Load unit and doctests in the tests.py module. If module has # a suite() method, use it. Otherwise build the test suite ourselves. if hasattr(test_module, 'suite'): suite.addTest(test_module.suite()) else: suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_module)) try: suite.addTest(doctest.DocTestSuite(test_module, checker=doctestOutputChecker, runner=DocTestRunner)) except ValueError: # No doc tests in tests.py pass return suite def build_test(label): """Construct a test case with the specified label. Label should be of the form model.TestClass or model.TestClass.test_method. Returns an instantiated test or test suite corresponding to the label provided. """ parts = label.split('.') if len(parts) < 2 or len(parts) > 3: raise ValueError("Test label '%s' should be of the form app.TestCase or app.TestCase.test_method" % label) # # First, look for TestCase instances with a name that matches # app_module = get_app(parts[0]) test_module = get_tests(app_module) TestClass = getattr(app_module, parts[1], None) # Couldn't find the test class in models.py; look in tests.py if TestClass is None: if test_module: TestClass = getattr(test_module, parts[1], None) try: if issubclass(TestClass, (unittest.TestCase, real_unittest.TestCase)): if len(parts) == 2: # label is app.TestClass try: return unittest.TestLoader().loadTestsFromTestCase(TestClass) except TypeError: raise ValueError("Test label '%s' does not refer to a test class" % label) else: # label is app.TestClass.test_method return TestClass(parts[2]) except TypeError: # TestClass isn't a TestClass - it must be a method or normal class pass # # If there isn't a TestCase, look for a doctest that matches # tests = [] for module in app_module, test_module: try: doctests = doctest.DocTestSuite(module, checker=doctestOutputChecker, runner=DocTestRunner) # Now iterate over the suite, looking for doctests whose name # matches the pattern that was given for test in doctests: if test._dt_test.name in ( '%s.%s' % (module.__name__, '.'.join(parts[1:])), '%s.__test__.%s' % (module.__name__, '.'.join(parts[1:]))): tests.append(test) except ValueError: # No doctests found. pass # If no tests were found, then we were given a bad test label. if not tests: raise ValueError("Test label '%s' does not refer to a test" % label) # Construct a suite out of the tests that matched. return unittest.TestSuite(tests) def partition_suite(suite, classes, bins): """ Partitions a test suite by test type. classes is a sequence of types bins is a sequence of TestSuites, one more than classes Tests of type classes[i] are added to bins[i], tests with no match found in classes are place in bins[-1] """ for test in suite: if isinstance(test, unittest.TestSuite): partition_suite(test, classes, bins) else: for i in range(len(classes)): if isinstance(test, classes[i]): bins[i].addTest(test) break else: bins[-1].addTest(test) def reorder_suite(suite, classes): """ Reorders a test suite by test type. classes is a sequence of types All tests of type clases[0] are placed first, then tests of type classes[1], etc. Tests with no match in classes are placed last. """ class_count = len(classes) bins = [unittest.TestSuite() for i in range(class_count+1)] partition_suite(suite, classes, bins) for i in range(class_count): bins[0].addTests(bins[i+1]) return bins[0] def dependency_ordered(test_databases, dependencies): """Reorder test_databases into an order that honors the dependencies described in TEST_DEPENDENCIES. """ ordered_test_databases = [] resolved_databases = set() while test_databases: changed = False deferred = [] while test_databases: signature, (db_name, aliases) = test_databases.pop() dependencies_satisfied = True for alias in aliases: if alias in dependencies: if all(a in resolved_databases for a in dependencies[alias]): # all dependencies for this alias are satisfied dependencies.pop(alias) resolved_databases.add(alias) else: dependencies_satisfied = False else: resolved_databases.add(alias) if dependencies_satisfied: ordered_test_databases.append((signature, (db_name, aliases))) changed = True else: deferred.append((signature, (db_name, aliases))) if not changed: raise ImproperlyConfigured("Circular dependency in TEST_DEPENDENCIES") test_databases = deferred return ordered_test_databases class DjangoTestSuiteRunner(object): def __init__(self, verbosity=1, interactive=True, failfast=True, **kwargs): self.verbosity = verbosity self.interactive = interactive self.failfast = failfast def setup_test_environment(self, **kwargs): setup_test_environment() settings.DEBUG = False unittest.installHandler() def build_suite(self, test_labels, extra_tests=None, **kwargs): suite = unittest.TestSuite() if test_labels: for label in test_labels: if '.' in label: suite.addTest(build_test(label)) else: app = get_app(label) suite.addTest(build_suite(app)) else: for app in get_apps(): suite.addTest(build_suite(app)) if extra_tests: for test in extra_tests: suite.addTest(test) return reorder_suite(suite, (TestCase,)) def setup_databases(self, **kwargs): from django.db import connections, DEFAULT_DB_ALIAS # First pass -- work out which databases actually need to be created, # and which ones are test mirrors or duplicate entries in DATABASES mirrored_aliases = {} test_databases = {} dependencies = {} for alias in connections: connection = connections[alias] if connection.settings_dict['TEST_MIRROR']: # If the database is marked as a test mirror, save # the alias. mirrored_aliases[alias] = connection.settings_dict['TEST_MIRROR'] else: # Store a tuple with DB parameters that uniquely identify it. # If we have two aliases with the same values for that tuple, # we only need to create the test database once. item = test_databases.setdefault( connection.creation.test_db_signature(), (connection.settings_dict['NAME'], []) ) item[1].append(alias) if 'TEST_DEPENDENCIES' in connection.settings_dict: dependencies[alias] = connection.settings_dict['TEST_DEPENDENCIES'] else: if alias != DEFAULT_DB_ALIAS: dependencies[alias] = connection.settings_dict.get('TEST_DEPENDENCIES', [DEFAULT_DB_ALIAS]) # Second pass -- actually create the databases. old_names = [] mirrors = [] for signature, (db_name, aliases) in dependency_ordered(test_databases.items(), dependencies): # Actually create the database for the first connection connection = connections[aliases[0]] old_names.append((connection, db_name, True)) test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive) for alias in aliases[1:]: connection = connections[alias] if db_name: old_names.append((connection, db_name, False)) connection.settings_dict['NAME'] = test_db_name else: # If settings_dict['NAME'] isn't defined, we have a backend where # the name isn't important -- e.g., SQLite, which uses :memory:. # Force create the database instead of assuming it's a duplicate. old_names.append((connection, db_name, True)) connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive) for alias, mirror_alias in mirrored_aliases.items(): mirrors.append((alias, connections[alias].settings_dict['NAME'])) connections[alias].settings_dict['NAME'] = connections[mirror_alias].settings_dict['NAME'] return old_names, mirrors def run_suite(self, suite, **kwargs): return unittest.TextTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite) def teardown_databases(self, old_config, **kwargs): from django.db import connections old_names, mirrors = old_config # Point all the mirrors back to the originals for alias, old_name in mirrors: connections[alias].settings_dict['NAME'] = old_name # Destroy all the non-mirror databases for connection, old_name, destroy in old_names: if destroy: connection.creation.destroy_test_db(old_name, self.verbosity) else: connection.settings_dict['NAME'] = old_name def teardown_test_environment(self, **kwargs): unittest.removeHandler() teardown_test_environment() def suite_result(self, suite, result, **kwargs): return len(result.failures) + len(result.errors) def run_tests(self, test_labels, extra_tests=None, **kwargs): """ Run the unit tests for all the test labels in the provided list. Labels must be of the form: - app.TestClass.test_method Run a single specific test method - app.TestClass Run all the test methods in a given class - app Search for doctests and unittests in the named application. When looking for tests, the test runner will look in the models and tests modules for the application. A list of 'extra' tests may also be provided; these tests will be added to the test suite. Returns the number of tests that failed. """ self.setup_test_environment() suite = self.build_suite(test_labels, extra_tests) old_config = self.setup_databases() result = self.run_suite(suite) self.teardown_databases(old_config) self.teardown_test_environment() return self.suite_result(suite, result) def run_tests(test_labels, verbosity=1, interactive=True, failfast=False, extra_tests=None): import warnings warnings.warn( 'The run_tests() test runner has been deprecated in favor of DjangoTestSuiteRunner.', DeprecationWarning ) test_runner = DjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast) return test_runner.run_tests(test_labels, extra_tests=extra_tests)
bsd-3-clause
[ 646, 2882, 465, 3363, 63, 2796, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 992, 492, 664, 63, 571, 12, 664, 63, 5181, 199, 504, 1639, 14, 396, 492, 485, 11390, 465, 8868, 199, 504, 1639, 14, 396, 14, 1208, 492, 3272, 63, 396, 63, 5418, 12, 17558, 63, 396, 63, 5418, 199, 504, 1639, 14, 396, 14, 396, 9403, 492, 7242, 3048, 12, 5454, 13649, 12, 7640, 199, 504, 1639, 14, 1208, 492, 2882, 199, 199, 893, 26, 272, 1006, 199, 2590, 12746, 26, 272, 687, 1639, 14, 1208, 14, 1661, 5819, 492, 1006, 421, 199, 363, 452, 363, 275, 661, 9323, 13649, 297, 283, 9323, 10591, 7446, 297, 283, 1065, 63, 2219, 358, 199, 199, 3, 710, 859, 536, 367, 2295, 9682, 1709, 14, 647, 199, 2864, 63, 10001, 275, 283, 2219, 7, 199, 199, 11390, 2959, 3048, 275, 7242, 3048, 342, 199, 199, 533, 5634, 13649, 8, 2796, 14, 24285, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 492, 3598, 267, 3598, 14, 4050, 8, 288, 298, 9323, 13649, 365, 5906, 27, 652, 1159, 9330, 365, 2539, 270, 17603, 461, 687, 4516, 13649, 401, 288, 29216, 15561, 267, 776, 267, 1613, 8, 9323, 13649, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 318, 664, 63, 2219, 8, 571, 63, 578, 304, 272, 862, 26, 267, 1145, 63, 515, 275, 1145, 63, 578, 855, 354, 4343, 1294, 7563, 4439, 17, 61, 267, 511, 63, 578, 275, 636, 646, 363, 5175, 1370, 904, 8, 571, 63, 515, 435, 359, 2864, 63, 10001, 2522, 5479, 5479, 7393, 63, 10001, 9, 272, 871, 3545, 12, 325, 26, 267, 327, 18615, 78, 1133, 492, 2295, 14, 647, 14, 644, 305, 652, 7037, 370, 282, 4124, 570, 12, 503, 267, 327, 7037, 370, 376, 492, 1125, 315, 282, 2295, 14, 647, 626, 5965, 3495, 31, 267, 492, 747, 14, 515, 267, 687, 1742, 492, 2342, 63, 578, 267, 862, 26, 288, 3413, 275, 2342, 63, 578, 8, 2864, 63, 10001, 12, 359, 736, 14, 515, 14, 3475, 8, 571, 63, 578, 855, 493, 3368, 566, 267, 871, 3545, 26, 288, 327, 283, 2219, 7, 859, 3181, 1133, 2187, 14, 14171, 641, 14, 288, 511, 63, 578, 275, 488, 267, 587, 26, 288, 327, 710, 859, 3495, 12, 880, 2337, 1471, 506, 376, 492, 1125, 315, 314, 288, 327, 511, 859, 6337, 14, 2136, 2793, 1133, 1929, 314, 859, 27, 880, 340, 314, 288, 327, 859, 1990, 282, 2849, 570, 859, 334, 73, 14, 69, 2020, 2295, 14, 647, 395, 4002, 314, 570, 288, 327, 2429, 2138, 701, 2342, 63, 578, 14, 6630, 12, 314, 511, 859, 288, 327, 365, 282, 2082, 12, 436, 2337, 365, 6548, 370, 4002, 14, 288, 340, 3413, 59, 16, 2189, 355, 3413, 59, 16, 1055, 1600, 342, 288, 746, 272, 372, 511, 63, 578, 199, 199, 318, 1900, 63, 5768, 8, 571, 63, 578, 304, 272, 298, 2499, 282, 4890, 5634, 511, 5241, 367, 314, 2741, 4223, 859, 2, 272, 5241, 275, 2882, 14, 10591, 342, 339, 327, 7190, 4137, 436, 26721, 315, 314, 1709, 14, 647, 859, 14, 982, 859, 965, 272, 327, 282, 5241, 342, 1083, 12, 675, 652, 14, 6630, 1900, 314, 511, 5241, 26495, 14, 272, 340, 2688, 8, 571, 63, 578, 12, 283, 5768, 735, 267, 5241, 14, 15714, 8, 571, 63, 578, 14, 5768, 1012, 272, 587, 26, 267, 5241, 14, 15714, 8, 2796, 14, 885, 15824, 14, 12861, 2377, 8, 571, 63, 578, 430, 267, 862, 26, 288, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 571, 63, 578, 12, 6901, 7739, 29, 11390, 2959, 3048, 12, 6901, 7876, 29, 3768, 13649, 430, 267, 871, 1722, 26, 288, 327, 3091, 1382, 2295, 315, 1709, 14, 647, 288, 986, 339, 327, 2670, 370, 1937, 340, 282, 7396, 283, 2219, 7, 859, 3495, 9861, 370, 314, 272, 327, 1709, 859, 272, 511, 63, 578, 275, 664, 63, 2219, 8, 571, 63, 578, 9, 272, 340, 511, 63, 578, 26, 267, 327, 7190, 4137, 436, 26721, 315, 314, 2295, 14, 647, 859, 14, 982, 859, 965, 267, 327, 282, 5241, 342, 1083, 12, 675, 652, 14, 6630, 1900, 314, 511, 5241, 26495, 14, 267, 340, 2688, 8, 396, 63, 578, 12, 283, 5768, 735, 288, 5241, 14, 15714, 8, 396, 63, 578, 14, 5768, 1012, 267, 587, 26, 288, 5241, 14, 15714, 8, 2796, 14, 885, 15824, 14, 12861, 2377, 8, 396, 63, 578, 430, 288, 862, 26, 355, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 396, 63, 578, 12, 8962, 7739, 29, 11390, 2959, 3048, 12, 8962, 7876, 29, 3768, 13649, 430, 288, 871, 1722, 26, 355, 327, 3091, 1382, 2295, 315, 2295, 14, 647, 355, 986, 272, 372, 5241, 199, 199, 318, 1900, 63, 396, 8, 1302, 304, 272, 408, 11493, 282, 511, 1930, 543, 314, 2013, 1768, 14, 10354, 1077, 506, 402, 314, 272, 1824, 1402, 14, 22009, 503, 1402, 14, 22009, 14, 396, 63, 765, 14, 1803, 376, 272, 17544, 511, 503, 511, 5241, 5226, 370, 314, 1768, 2741, 14, 339, 408, 272, 4184, 275, 1768, 14, 1294, 7563, 272, 340, 822, 8, 4181, 9, 665, 499, 503, 822, 8, 4181, 9, 690, 650, 26, 267, 746, 1722, 480, 774, 1768, 1543, 83, 7, 1077, 506, 402, 314, 1824, 1145, 14, 1746, 503, 1145, 14, 1746, 14, 396, 63, 765, 2, 450, 1768, 9, 339, 327, 272, 327, 7758, 12, 3648, 367, 7640, 4454, 543, 282, 536, 626, 4450, 272, 327, 272, 1145, 63, 578, 275, 664, 63, 571, 8, 4181, 59, 16, 566, 272, 511, 63, 578, 275, 664, 63, 2219, 8, 571, 63, 578, 9, 272, 1379, 2543, 275, 2519, 8, 571, 63, 578, 12, 4184, 59, 17, 467, 488, 9, 339, 327, 18615, 78, 1133, 2342, 314, 511, 1021, 315, 1709, 14, 647, 27, 3648, 315, 2295, 14, 647, 272, 340, 1379, 2543, 365, 488, 26, 267, 340, 511, 63, 578, 26, 288, 1379, 2543, 275, 2519, 8, 396, 63, 578, 12, 4184, 59, 17, 467, 488, 9, 339, 862, 26, 267, 340 ]
[ 2882, 465, 3363, 63, 2796, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 992, 492, 664, 63, 571, 12, 664, 63, 5181, 199, 504, 1639, 14, 396, 492, 485, 11390, 465, 8868, 199, 504, 1639, 14, 396, 14, 1208, 492, 3272, 63, 396, 63, 5418, 12, 17558, 63, 396, 63, 5418, 199, 504, 1639, 14, 396, 14, 396, 9403, 492, 7242, 3048, 12, 5454, 13649, 12, 7640, 199, 504, 1639, 14, 1208, 492, 2882, 199, 199, 893, 26, 272, 1006, 199, 2590, 12746, 26, 272, 687, 1639, 14, 1208, 14, 1661, 5819, 492, 1006, 421, 199, 363, 452, 363, 275, 661, 9323, 13649, 297, 283, 9323, 10591, 7446, 297, 283, 1065, 63, 2219, 358, 199, 199, 3, 710, 859, 536, 367, 2295, 9682, 1709, 14, 647, 199, 2864, 63, 10001, 275, 283, 2219, 7, 199, 199, 11390, 2959, 3048, 275, 7242, 3048, 342, 199, 199, 533, 5634, 13649, 8, 2796, 14, 24285, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 492, 3598, 267, 3598, 14, 4050, 8, 288, 298, 9323, 13649, 365, 5906, 27, 652, 1159, 9330, 365, 2539, 270, 17603, 461, 687, 4516, 13649, 401, 288, 29216, 15561, 267, 776, 267, 1613, 8, 9323, 13649, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 318, 664, 63, 2219, 8, 571, 63, 578, 304, 272, 862, 26, 267, 1145, 63, 515, 275, 1145, 63, 578, 855, 354, 4343, 1294, 7563, 4439, 17, 61, 267, 511, 63, 578, 275, 636, 646, 363, 5175, 1370, 904, 8, 571, 63, 515, 435, 359, 2864, 63, 10001, 2522, 5479, 5479, 7393, 63, 10001, 9, 272, 871, 3545, 12, 325, 26, 267, 327, 18615, 78, 1133, 492, 2295, 14, 647, 14, 644, 305, 652, 7037, 370, 282, 4124, 570, 12, 503, 267, 327, 7037, 370, 376, 492, 1125, 315, 282, 2295, 14, 647, 626, 5965, 3495, 31, 267, 492, 747, 14, 515, 267, 687, 1742, 492, 2342, 63, 578, 267, 862, 26, 288, 3413, 275, 2342, 63, 578, 8, 2864, 63, 10001, 12, 359, 736, 14, 515, 14, 3475, 8, 571, 63, 578, 855, 493, 3368, 566, 267, 871, 3545, 26, 288, 327, 283, 2219, 7, 859, 3181, 1133, 2187, 14, 14171, 641, 14, 288, 511, 63, 578, 275, 488, 267, 587, 26, 288, 327, 710, 859, 3495, 12, 880, 2337, 1471, 506, 376, 492, 1125, 315, 314, 288, 327, 511, 859, 6337, 14, 2136, 2793, 1133, 1929, 314, 859, 27, 880, 340, 314, 288, 327, 859, 1990, 282, 2849, 570, 859, 334, 73, 14, 69, 2020, 2295, 14, 647, 395, 4002, 314, 570, 288, 327, 2429, 2138, 701, 2342, 63, 578, 14, 6630, 12, 314, 511, 859, 288, 327, 365, 282, 2082, 12, 436, 2337, 365, 6548, 370, 4002, 14, 288, 340, 3413, 59, 16, 2189, 355, 3413, 59, 16, 1055, 1600, 342, 288, 746, 272, 372, 511, 63, 578, 199, 199, 318, 1900, 63, 5768, 8, 571, 63, 578, 304, 272, 298, 2499, 282, 4890, 5634, 511, 5241, 367, 314, 2741, 4223, 859, 2, 272, 5241, 275, 2882, 14, 10591, 342, 339, 327, 7190, 4137, 436, 26721, 315, 314, 1709, 14, 647, 859, 14, 982, 859, 965, 272, 327, 282, 5241, 342, 1083, 12, 675, 652, 14, 6630, 1900, 314, 511, 5241, 26495, 14, 272, 340, 2688, 8, 571, 63, 578, 12, 283, 5768, 735, 267, 5241, 14, 15714, 8, 571, 63, 578, 14, 5768, 1012, 272, 587, 26, 267, 5241, 14, 15714, 8, 2796, 14, 885, 15824, 14, 12861, 2377, 8, 571, 63, 578, 430, 267, 862, 26, 288, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 571, 63, 578, 12, 6901, 7739, 29, 11390, 2959, 3048, 12, 6901, 7876, 29, 3768, 13649, 430, 267, 871, 1722, 26, 288, 327, 3091, 1382, 2295, 315, 1709, 14, 647, 288, 986, 339, 327, 2670, 370, 1937, 340, 282, 7396, 283, 2219, 7, 859, 3495, 9861, 370, 314, 272, 327, 1709, 859, 272, 511, 63, 578, 275, 664, 63, 2219, 8, 571, 63, 578, 9, 272, 340, 511, 63, 578, 26, 267, 327, 7190, 4137, 436, 26721, 315, 314, 2295, 14, 647, 859, 14, 982, 859, 965, 267, 327, 282, 5241, 342, 1083, 12, 675, 652, 14, 6630, 1900, 314, 511, 5241, 26495, 14, 267, 340, 2688, 8, 396, 63, 578, 12, 283, 5768, 735, 288, 5241, 14, 15714, 8, 396, 63, 578, 14, 5768, 1012, 267, 587, 26, 288, 5241, 14, 15714, 8, 2796, 14, 885, 15824, 14, 12861, 2377, 8, 396, 63, 578, 430, 288, 862, 26, 355, 5241, 14, 15714, 8, 11390, 14, 3768, 10591, 8, 396, 63, 578, 12, 8962, 7739, 29, 11390, 2959, 3048, 12, 8962, 7876, 29, 3768, 13649, 430, 288, 871, 1722, 26, 355, 327, 3091, 1382, 2295, 315, 2295, 14, 647, 355, 986, 272, 372, 5241, 199, 199, 318, 1900, 63, 396, 8, 1302, 304, 272, 408, 11493, 282, 511, 1930, 543, 314, 2013, 1768, 14, 10354, 1077, 506, 402, 314, 272, 1824, 1402, 14, 22009, 503, 1402, 14, 22009, 14, 396, 63, 765, 14, 1803, 376, 272, 17544, 511, 503, 511, 5241, 5226, 370, 314, 1768, 2741, 14, 339, 408, 272, 4184, 275, 1768, 14, 1294, 7563, 272, 340, 822, 8, 4181, 9, 665, 499, 503, 822, 8, 4181, 9, 690, 650, 26, 267, 746, 1722, 480, 774, 1768, 1543, 83, 7, 1077, 506, 402, 314, 1824, 1145, 14, 1746, 503, 1145, 14, 1746, 14, 396, 63, 765, 2, 450, 1768, 9, 339, 327, 272, 327, 7758, 12, 3648, 367, 7640, 4454, 543, 282, 536, 626, 4450, 272, 327, 272, 1145, 63, 578, 275, 664, 63, 571, 8, 4181, 59, 16, 566, 272, 511, 63, 578, 275, 664, 63, 2219, 8, 571, 63, 578, 9, 272, 1379, 2543, 275, 2519, 8, 571, 63, 578, 12, 4184, 59, 17, 467, 488, 9, 339, 327, 18615, 78, 1133, 2342, 314, 511, 1021, 315, 1709, 14, 647, 27, 3648, 315, 2295, 14, 647, 272, 340, 1379, 2543, 365, 488, 26, 267, 340, 511, 63, 578, 26, 288, 1379, 2543, 275, 2519, 8, 396, 63, 578, 12, 4184, 59, 17, 467, 488, 9, 339, 862, 26, 267, 340, 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, 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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 ]
151706061/ITK
Examples/DataRepresentation/Image/ImageToArray.py
32
1257
#========================================================================== # # Copyright Insight Software Consortium # # 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.txt # # 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 InsightToolkit import * from numarray import * from sys import argv reader = itkImageFileReaderUC2_New() connector = itkPyBufferUC2_New() reader.SetFileName( argv[1] ) reader.Update() print "ready to convert image into array" buffer = connector.GetArrayFromImage( reader.GetOutput() ) writer = itkImageFileWriterUC2_New() writer.SetFileName( argv[2] ) print "ready to convert array into image" writer.SetInput( connector.GetImageFromArray( buffer ) ) writer.Update()
apache-2.0
[ 14813, 17575, 199, 3, 199, 3, 257, 1898, 1010, 22727, 2290, 1448, 1509, 280, 453, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 3515, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 14, 2424, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 14813, 17575, 15870, 199, 199, 504, 1010, 22727, 5157, 6065, 492, 627, 199, 504, 1967, 1144, 492, 627, 199, 504, 984, 492, 9238, 199, 199, 5503, 275, 652, 75, 30636, 5929, 13371, 18, 63, 4665, 342, 199, 199, 11815, 275, 652, 75, 2713, 3299, 13371, 18, 63, 4665, 342, 199, 199, 5503, 14, 1084, 7733, 8, 9238, 59, 17, 61, 776, 199, 199, 5503, 14, 4152, 342, 199, 199, 1361, 298, 2179, 370, 3957, 1834, 1901, 1625, 2, 199, 199, 2738, 275, 13252, 14, 1002, 3836, 2532, 3491, 8, 7002, 14, 18614, 342, 776, 199, 199, 5491, 275, 652, 75, 3491, 28199, 13371, 18, 63, 4665, 342, 199, 199, 5491, 14, 1084, 7733, 8, 9238, 59, 18, 61, 776, 199, 199, 1361, 298, 2179, 370, 3957, 1625, 1901, 1834, 2, 199, 199, 5491, 14, 24029, 8, 13252, 14, 1002, 3491, 2532, 3836, 8, 3335, 776, 776, 199, 199, 5491, 14, 4152, 342, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17575, 199, 3, 199, 3, 257, 1898, 1010, 22727, 2290, 1448, 1509, 280, 453, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 3515, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 14, 2424, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 14813, 17575, 15870, 199, 199, 504, 1010, 22727, 5157, 6065, 492, 627, 199, 504, 1967, 1144, 492, 627, 199, 504, 984, 492, 9238, 199, 199, 5503, 275, 652, 75, 30636, 5929, 13371, 18, 63, 4665, 342, 199, 199, 11815, 275, 652, 75, 2713, 3299, 13371, 18, 63, 4665, 342, 199, 199, 5503, 14, 1084, 7733, 8, 9238, 59, 17, 61, 776, 199, 199, 5503, 14, 4152, 342, 199, 199, 1361, 298, 2179, 370, 3957, 1834, 1901, 1625, 2, 199, 199, 2738, 275, 13252, 14, 1002, 3836, 2532, 3491, 8, 7002, 14, 18614, 342, 776, 199, 199, 5491, 275, 652, 75, 3491, 28199, 13371, 18, 63, 4665, 342, 199, 199, 5491, 14, 1084, 7733, 8, 9238, 59, 18, 61, 776, 199, 199, 1361, 298, 2179, 370, 3957, 1625, 1901, 1834, 2, 199, 199, 5491, 14, 24029, 8, 13252, 14, 1002, 3491, 2532, 3836, 8, 3335, 776, 776, 199, 199, 5491, 14, 4152, 342, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
AlphaX2/FotoShareN9
0.9.7/fotoshare_deb/opt/FotoShareN9/simplejson/tests/test_namedtuple.py
69
3956
import unittest import simplejson as json from StringIO import StringIO try: from collections import namedtuple except ImportError: class Value(tuple): def __new__(cls, *args): return tuple.__new__(cls, args) def _asdict(self): return {'value': self[0]} class Point(tuple): def __new__(cls, *args): return tuple.__new__(cls, args) def _asdict(self): return {'x': self[0], 'y': self[1]} else: Value = namedtuple('Value', ['value']) Point = namedtuple('Point', ['x', 'y']) class DuckValue(object): def __init__(self, *args): self.value = Value(*args) def _asdict(self): return self.value._asdict() class DuckPoint(object): def __init__(self, *args): self.point = Point(*args) def _asdict(self): return self.point._asdict() class DeadDuck(object): _asdict = None class DeadDict(dict): _asdict = None CONSTRUCTORS = [ lambda v: v, lambda v: [v], lambda v: [{'key': v}], ] class TestNamedTuple(unittest.TestCase): def test_namedtuple_dumps(self): for v in [Value(1), Point(1, 2), DuckValue(1), DuckPoint(1, 2)]: d = v._asdict() self.assertEqual(d, json.loads(json.dumps(v))) self.assertEqual( d, json.loads(json.dumps(v, namedtuple_as_object=True))) self.assertEqual(d, json.loads(json.dumps(v, tuple_as_array=False))) self.assertEqual( d, json.loads(json.dumps(v, namedtuple_as_object=True, tuple_as_array=False))) def test_namedtuple_dumps_false(self): for v in [Value(1), Point(1, 2)]: l = list(v) self.assertEqual( l, json.loads(json.dumps(v, namedtuple_as_object=False))) self.assertRaises(TypeError, json.dumps, v, tuple_as_array=False, namedtuple_as_object=False) def test_namedtuple_dump(self): for v in [Value(1), Point(1, 2), DuckValue(1), DuckPoint(1, 2)]: d = v._asdict() sio = StringIO() json.dump(v, sio) self.assertEqual(d, json.loads(sio.getvalue())) sio = StringIO() json.dump(v, sio, namedtuple_as_object=True) self.assertEqual( d, json.loads(sio.getvalue())) sio = StringIO() json.dump(v, sio, tuple_as_array=False) self.assertEqual(d, json.loads(sio.getvalue())) sio = StringIO() json.dump(v, sio, namedtuple_as_object=True, tuple_as_array=False) self.assertEqual( d, json.loads(sio.getvalue())) def test_namedtuple_dump_false(self): for v in [Value(1), Point(1, 2)]: l = list(v) sio = StringIO() json.dump(v, sio, namedtuple_as_object=False) self.assertEqual( l, json.loads(sio.getvalue())) self.assertRaises(TypeError, json.dump, v, StringIO(), tuple_as_array=False, namedtuple_as_object=False) def test_asdict_not_callable_dump(self): for f in CONSTRUCTORS: self.assertRaises(TypeError, json.dump, f(DeadDuck()), StringIO(), namedtuple_as_object=True) sio = StringIO() json.dump(f(DeadDict()), sio, namedtuple_as_object=True) self.assertEqual( json.dumps(f({})), sio.getvalue()) def test_asdict_not_callable_dumps(self): for f in CONSTRUCTORS: self.assertRaises(TypeError, json.dumps, f(DeadDuck()), namedtuple_as_object=True) self.assertEqual( json.dumps(f({})), json.dumps(f(DeadDict()), namedtuple_as_object=True))
gpl-3.0
[ 646, 2882, 199, 646, 13804, 465, 2022, 199, 504, 5228, 492, 5228, 199, 199, 893, 26, 272, 687, 5055, 492, 12863, 199, 2590, 3545, 26, 272, 1021, 1594, 8, 2960, 304, 267, 347, 636, 1222, 721, 1886, 12, 627, 589, 304, 288, 372, 2008, 855, 1222, 721, 1886, 12, 1249, 9, 398, 347, 485, 305, 807, 8, 277, 304, 288, 372, 791, 585, 356, 291, 59, 16, 9420, 272, 1021, 7584, 8, 2960, 304, 267, 347, 636, 1222, 721, 1886, 12, 627, 589, 304, 288, 372, 2008, 855, 1222, 721, 1886, 12, 1249, 9, 398, 347, 485, 305, 807, 8, 277, 304, 288, 372, 791, 88, 356, 291, 59, 16, 467, 283, 89, 356, 291, 59, 17, 9420, 199, 2836, 26, 272, 1594, 275, 12863, 360, 1110, 297, 788, 585, 1105, 272, 7584, 275, 12863, 360, 3428, 297, 788, 88, 297, 283, 89, 1105, 199, 199, 533, 577, 10112, 1110, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 291, 14, 585, 275, 1594, 2031, 589, 9, 339, 347, 485, 305, 807, 8, 277, 304, 267, 372, 291, 14, 585, 423, 305, 807, 342, 199, 199, 533, 577, 10112, 3428, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 291, 14, 1403, 275, 7584, 2031, 589, 9, 339, 347, 485, 305, 807, 8, 277, 304, 267, 372, 291, 14, 1403, 423, 305, 807, 342, 199, 199, 533, 1487, 350, 36, 10112, 8, 785, 304, 272, 485, 305, 807, 275, 488, 199, 199, 533, 1487, 350, 2141, 8, 807, 304, 272, 485, 305, 807, 275, 488, 199, 199, 1864, 8893, 4149, 275, 359, 272, 2400, 373, 26, 373, 12, 272, 2400, 373, 26, 359, 86, 467, 272, 2400, 373, 26, 9016, 498, 356, 373, 22140, 199, 61, 199, 199, 533, 1379, 7989, 7075, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 18921, 63, 4180, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 395, 577, 10112, 1110, 8, 17, 395, 577, 10112, 3428, 8, 17, 12, 499, 19532, 288, 366, 275, 373, 423, 305, 807, 342, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 1724, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 549, 1724, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 2008, 63, 305, 63, 1144, 29, 797, 1724, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 549, 12, 4228, 2008, 63, 305, 63, 1144, 29, 797, 1724, 339, 347, 511, 63, 18921, 63, 4180, 63, 3910, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 19532, 288, 634, 275, 769, 8, 86, 9, 288, 291, 14, 629, 8, 355, 634, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 797, 1724, 288, 291, 14, 1855, 8, 4333, 12, 2022, 14, 4180, 12, 373, 12, 355, 2008, 63, 305, 63, 1144, 29, 797, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 339, 347, 511, 63, 18921, 63, 2724, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 395, 577, 10112, 1110, 8, 17, 395, 577, 10112, 3428, 8, 17, 12, 499, 19532, 288, 366, 275, 373, 423, 305, 807, 342, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 9, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 2008, 63, 305, 63, 1144, 29, 797, 9, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 12, 1993, 2008, 63, 305, 63, 1144, 29, 797, 9, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 339, 347, 511, 63, 18921, 63, 2724, 63, 3910, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 19532, 288, 634, 275, 769, 8, 86, 9, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 288, 291, 14, 629, 8, 355, 634, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 291, 14, 1855, 8, 4333, 12, 2022, 14, 2724, 12, 373, 12, 5228, 1062, 355, 2008, 63, 305, 63, 1144, 29, 797, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 339, 347, 511, 63, 305, 807, 63, 1397, 63, 8296, 63, 2724, 8, 277, 304, 267, 367, 289, 315, 1868, 8893, 4149, 26, 288, 291, 14, 1855, 8, 4333, 12, 355, 2022, 14, 2724, 12, 289, 8, 22147, 36, 10112, 4000, 5228, 1062, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 70, 8, 22147, 2141, 4000, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 2022, 14, 4180, 8, 70, 14079, 395, 355, 29129, 14, 7150, 1012, 339, 347, 511, 63, 305, 807, 63, 1397, 63, 8296, 63, 4180, 8, 277, 304, 267, 367, 289, 315, 1868, 8893, 4149, 26, 288, 291, 14, 1855, 8, 4333, 12, 355, 2022, 14, 4180, 12, 289, 8, 22147, 36, 10112, 4000, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 2022, 14, 4180, 8, 70, 14079, 395, 355, 2022, 14, 4180, 8, 70, 8, 22147, 2141, 4000, 12863, 63, 305 ]
[ 2882, 199, 646, 13804, 465, 2022, 199, 504, 5228, 492, 5228, 199, 199, 893, 26, 272, 687, 5055, 492, 12863, 199, 2590, 3545, 26, 272, 1021, 1594, 8, 2960, 304, 267, 347, 636, 1222, 721, 1886, 12, 627, 589, 304, 288, 372, 2008, 855, 1222, 721, 1886, 12, 1249, 9, 398, 347, 485, 305, 807, 8, 277, 304, 288, 372, 791, 585, 356, 291, 59, 16, 9420, 272, 1021, 7584, 8, 2960, 304, 267, 347, 636, 1222, 721, 1886, 12, 627, 589, 304, 288, 372, 2008, 855, 1222, 721, 1886, 12, 1249, 9, 398, 347, 485, 305, 807, 8, 277, 304, 288, 372, 791, 88, 356, 291, 59, 16, 467, 283, 89, 356, 291, 59, 17, 9420, 199, 2836, 26, 272, 1594, 275, 12863, 360, 1110, 297, 788, 585, 1105, 272, 7584, 275, 12863, 360, 3428, 297, 788, 88, 297, 283, 89, 1105, 199, 199, 533, 577, 10112, 1110, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 291, 14, 585, 275, 1594, 2031, 589, 9, 339, 347, 485, 305, 807, 8, 277, 304, 267, 372, 291, 14, 585, 423, 305, 807, 342, 199, 199, 533, 577, 10112, 3428, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 291, 14, 1403, 275, 7584, 2031, 589, 9, 339, 347, 485, 305, 807, 8, 277, 304, 267, 372, 291, 14, 1403, 423, 305, 807, 342, 199, 199, 533, 1487, 350, 36, 10112, 8, 785, 304, 272, 485, 305, 807, 275, 488, 199, 199, 533, 1487, 350, 2141, 8, 807, 304, 272, 485, 305, 807, 275, 488, 199, 199, 1864, 8893, 4149, 275, 359, 272, 2400, 373, 26, 373, 12, 272, 2400, 373, 26, 359, 86, 467, 272, 2400, 373, 26, 9016, 498, 356, 373, 22140, 199, 61, 199, 199, 533, 1379, 7989, 7075, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 18921, 63, 4180, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 395, 577, 10112, 1110, 8, 17, 395, 577, 10112, 3428, 8, 17, 12, 499, 19532, 288, 366, 275, 373, 423, 305, 807, 342, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 1724, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 549, 1724, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 2008, 63, 305, 63, 1144, 29, 797, 1724, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 549, 12, 4228, 2008, 63, 305, 63, 1144, 29, 797, 1724, 339, 347, 511, 63, 18921, 63, 4180, 63, 3910, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 19532, 288, 634, 275, 769, 8, 86, 9, 288, 291, 14, 629, 8, 355, 634, 12, 355, 2022, 14, 3640, 8, 1001, 14, 4180, 8, 86, 12, 12863, 63, 305, 63, 785, 29, 797, 1724, 288, 291, 14, 1855, 8, 4333, 12, 2022, 14, 4180, 12, 373, 12, 355, 2008, 63, 305, 63, 1144, 29, 797, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 339, 347, 511, 63, 18921, 63, 2724, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 395, 577, 10112, 1110, 8, 17, 395, 577, 10112, 3428, 8, 17, 12, 499, 19532, 288, 366, 275, 373, 423, 305, 807, 342, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 9, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 2008, 63, 305, 63, 1144, 29, 797, 9, 288, 291, 14, 629, 8, 68, 12, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 12, 1993, 2008, 63, 305, 63, 1144, 29, 797, 9, 288, 291, 14, 629, 8, 355, 366, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 339, 347, 511, 63, 18921, 63, 2724, 63, 3910, 8, 277, 304, 267, 367, 373, 315, 359, 1110, 8, 17, 395, 7584, 8, 17, 12, 499, 19532, 288, 634, 275, 769, 8, 86, 9, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 86, 12, 29129, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 288, 291, 14, 629, 8, 355, 634, 12, 355, 2022, 14, 3640, 8, 22961, 14, 7150, 4059, 288, 291, 14, 1855, 8, 4333, 12, 2022, 14, 2724, 12, 373, 12, 5228, 1062, 355, 2008, 63, 305, 63, 1144, 29, 797, 12, 12863, 63, 305, 63, 785, 29, 797, 9, 339, 347, 511, 63, 305, 807, 63, 1397, 63, 8296, 63, 2724, 8, 277, 304, 267, 367, 289, 315, 1868, 8893, 4149, 26, 288, 291, 14, 1855, 8, 4333, 12, 355, 2022, 14, 2724, 12, 289, 8, 22147, 36, 10112, 4000, 5228, 1062, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 29129, 275, 5228, 342, 288, 2022, 14, 2724, 8, 70, 8, 22147, 2141, 4000, 29129, 12, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 2022, 14, 4180, 8, 70, 14079, 395, 355, 29129, 14, 7150, 1012, 339, 347, 511, 63, 305, 807, 63, 1397, 63, 8296, 63, 4180, 8, 277, 304, 267, 367, 289, 315, 1868, 8893, 4149, 26, 288, 291, 14, 1855, 8, 4333, 12, 355, 2022, 14, 4180, 12, 289, 8, 22147, 36, 10112, 4000, 12863, 63, 305, 63, 785, 29, 549, 9, 288, 291, 14, 629, 8, 355, 2022, 14, 4180, 8, 70, 14079, 395, 355, 2022, 14, 4180, 8, 70, 8, 22147, 2141, 4000, 12863, 63, 305, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pablocastro/elasticsearch
dev-tools/smoke_test_rc.py
49
12477
# Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright # ownership. Elasticsearch 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. # Smoke-tests a release candidate # # 1. Downloads the tar.gz, deb, RPM and zip file from the staging URL # 2. Verifies it's sha1 hashes and GPG signatures against the release key # 3. Installs all official plugins # 4. Starts one node for tar.gz and zip packages and checks: # -- if it runs with Java 1.7 # -- if the build hash given is the one that is returned by the status response # -- if the build is a release version and not a snapshot version # -- if all plugins are loaded # -- if the status response returns the correct version # # USAGE: # # python3 -B ./dev-tools/smoke_test_rc.py --version 2.0.0-beta1 --hash bfa3e47 # # to also test other plugins try run # # python3 -B ./dev-tools/smoke_test_rc.py --version 2.0.0-beta1 --hash bfa3e47 --plugins license,shield,watcher # # Note: Ensure the script is run from the elasticsearch top level directory # # For testing a release from sonatype try this: # # python3 -B dev-tools/smoke_test_rc.py --version 2.0.0-beta1 --hash bfa3e47 --fetch_url https://oss.sonatype.org/content/repositories/releases/ # import argparse import tempfile import os import signal import shutil import urllib import urllib.request import hashlib import time import socket import json import base64 from prepare_release_candidate import run from http.client import HTTPConnection DEFAULT_PLUGINS = ["analysis-icu", "analysis-kuromoji", "analysis-phonetic", "analysis-smartcn", "analysis-stempel", "cloud-aws", "cloud-azure", "cloud-gce", "delete-by-query", "discovery-multicast", "lang-javascript", "lang-python", "mapper-murmur3", "mapper-size"] try: JAVA_HOME = os.environ['JAVA_HOME'] except KeyError: raise RuntimeError(""" Please set JAVA_HOME in the env before running release tool On OSX use: export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`""") def java_exe(): path = JAVA_HOME return 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % (path, path, path) def verify_java_version(version): s = os.popen('%s; java -version 2>&1' % java_exe()).read() if ' version "%s.' % version not in s: raise RuntimeError('got wrong version for java %s:\n%s' % (version, s)) def sha1(file): with open(file, 'rb') as f: return hashlib.sha1(f.read()).hexdigest() def read_fully(file): with open(file, encoding='utf-8') as f: return f.read() def wait_for_node_startup(host='127.0.0.1', port=9200, timeout=60, header={}): print(' Waiting until node becomes available for at most %s seconds' % timeout) for _ in range(timeout): conn = HTTPConnection(host=host, port=port, timeout=timeout) try: time.sleep(1) conn.request('GET', '', headers=header) res = conn.getresponse() if res.status == 200: return True except socket.error as e: pass #that is ok it might not be there yet finally: conn.close() return False def download_and_verify(version, hash, files, base_url, plugins=DEFAULT_PLUGINS, verbose=False): print('Downloading and verifying release %s from %s' % (version, base_url)) tmp_dir = tempfile.mkdtemp() try: downloaded_files = [] print(' ' + '*' * 80) for file in files: name = os.path.basename(file) print(' Smoketest file: %s' % name) url = '%s/%s' % (base_url, file) print(' Downloading %s' % (url)) artifact_path = os.path.join(tmp_dir, file) downloaded_files.append(artifact_path) current_artifact_dir = os.path.dirname(artifact_path) os.makedirs(current_artifact_dir) urllib.request.urlretrieve(url, os.path.join(tmp_dir, file)) sha1_url = ''.join([url, '.sha1']) checksum_file = artifact_path + ".sha1" print(' Downloading %s' % (sha1_url)) urllib.request.urlretrieve(sha1_url, checksum_file) print(' Verifying checksum %s' % (checksum_file)) expected = read_fully(checksum_file) actual = sha1(artifact_path) if expected != actual : raise RuntimeError('sha1 hash for %s doesn\'t match %s != %s' % (name, expected, actual)) gpg_url = ''.join([url, '.asc']) gpg_file = artifact_path + ".asc" print(' Downloading %s' % (gpg_url)) urllib.request.urlretrieve(gpg_url, gpg_file) print(' Verifying gpg signature %s' % (gpg_file)) # here we create a temp gpg home where we download the release key as the only key into # when we verify the signature it will fail if the signed key is not in the keystore and that # way we keep the executing host unmodified since we don't have to import the key into the default keystore gpg_home_dir = os.path.join(current_artifact_dir, "gpg_home_dir") os.makedirs(gpg_home_dir, 0o700) run('gpg --homedir %s --keyserver pgp.mit.edu --recv-key D88E42B4' % gpg_home_dir, verbose=verbose) run('cd %s && gpg --homedir %s --verify %s' % (current_artifact_dir, gpg_home_dir, os.path.basename(gpg_file)), verbose=verbose) print(' ' + '*' * 80) print() smoke_test_release(version, downloaded_files, hash, plugins, verbose=verbose) print(' SUCCESS') finally: shutil.rmtree(tmp_dir) def smoke_test_release(release, files, expected_hash, plugins, verbose=False): for release_file in files: if not os.path.isfile(release_file): raise RuntimeError('Smoketest failed missing file %s' % (release_file)) tmp_dir = tempfile.mkdtemp() if release_file.endswith('tar.gz'): run('tar -xzf %s -C %s' % (release_file, tmp_dir), verbose=verbose) elif release_file.endswith('zip'): run('unzip %s -d %s' % (release_file, tmp_dir), verbose=verbose) else: print(' Skip SmokeTest for [%s]' % release_file) continue # nothing to do here es_run_path = os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'bin/elasticsearch') print(' Smoke testing package [%s]' % release_file) es_plugin_path = os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'bin/plugin') plugin_names = {} for plugin in plugins: print(' Install plugin [%s]' % (plugin)) run('%s; %s -Des.plugins.staging=true %s %s' % (java_exe(), es_plugin_path, 'install', plugin), verbose=verbose) plugin_names[plugin] = True if 'shield' in plugin_names: headers = { 'Authorization' : 'Basic %s' % base64.b64encode(b"es_admin:foobar").decode("UTF-8") } es_shield_path = os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'bin/shield/esusers') print(" Install dummy shield user") run('%s; %s useradd es_admin -r admin -p foobar' % (java_exe(), es_shield_path), verbose=verbose) else: headers = {} print(' Starting elasticsearch deamon from [%s]' % os.path.join(tmp_dir, 'elasticsearch-%s' % release)) try: run('%s; %s -Des.node.name=smoke_tester -Des.cluster.name=prepare_release -Des.script.inline=on -Des.script.indexed=on -Des.repositories.url.allowed_urls=http://snapshot.test* %s -Des.pidfile=%s' % (java_exe(), es_run_path, '-d', os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'es-smoke.pid')), verbose=verbose) conn = HTTPConnection(host='127.0.0.1', port=9200, timeout=20) if not wait_for_node_startup(header=headers): print("elasticsearch logs:") print('*' * 80) logs = read_fully(os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'logs/prepare_release.log')) print(logs) print('*' * 80) raise RuntimeError('server didn\'t start up') try: # we now get / and /_nodes to fetch basic infos like hashes etc and the installed plugins conn.request('GET', '', headers=headers) res = conn.getresponse() if res.status == 200: version = json.loads(res.read().decode("utf-8"))['version'] if release != version['number']: raise RuntimeError('Expected version [%s] but was [%s]' % (release, version['number'])) if version['build_snapshot']: raise RuntimeError('Expected non snapshot version') if expected_hash.startswith(version['build_hash'].strip()): raise RuntimeError('HEAD hash does not match expected [%s] but got [%s]' % (expected_hash, version['build_hash'])) print(' Verify if plugins are listed in _nodes') conn.request('GET', '/_nodes?plugin=true&pretty=true', headers=headers) res = conn.getresponse() if res.status == 200: nodes = json.loads(res.read().decode("utf-8"))['nodes'] for _, node in nodes.items(): node_plugins = node['plugins'] for node_plugin in node_plugins: if not plugin_names.get(node_plugin['name'].strip(), False): raise RuntimeError('Unexpeced plugin %s' % node_plugin['name']) del plugin_names[node_plugin['name']] if plugin_names: raise RuntimeError('Plugins not loaded %s' % list(plugin_names.keys())) else: raise RuntimeError('Expected HTTP 200 but got %s' % res.status) else: raise RuntimeError('Expected HTTP 200 but got %s' % res.status) finally: conn.close() finally: pid_path = os.path.join(tmp_dir, 'elasticsearch-%s' % (release), 'es-smoke.pid') if os.path.exists(pid_path): # try reading the pid and kill the node pid = int(read_fully(pid_path)) os.kill(pid, signal.SIGKILL) shutil.rmtree(tmp_dir) print(' ' + '*' * 80) print() def parse_list(string): return [x.strip() for x in string.split(',')] if __name__ == "__main__": parser = argparse.ArgumentParser(description='SmokeTests a Release Candidate from S3 staging repo') parser.add_argument('--version', '-v', dest='version', default=None, help='The Elasticsearch Version to smoke-tests', required=True) parser.add_argument('--hash', '-s', dest='hash', default=None, required=True, help='The sha1 short hash of the git commit to smoketest') parser.add_argument('--plugins', '-p', dest='plugins', default=[], required=False, type=parse_list, help='A list of additional plugins to smoketest') parser.add_argument('--verbose', '-b', dest='verbose', help='Runs the script in verbose mode') parser.add_argument('--fetch_url', '-u', dest='url', default=None, help='Runs the script in verbose mode') parser.set_defaults(hash=None) parser.set_defaults(plugins=[]) parser.set_defaults(version=None) parser.set_defaults(verbose=False) parser.set_defaults(url=None) args = parser.parse_args() plugins = args.plugins version = args.version hash = args.hash verbose = args.verbose url = args.url files = [ x % {'version': version} for x in [ 'org/elasticsearch/distribution/tar/elasticsearch/%(version)s/elasticsearch-%(version)s.tar.gz', 'org/elasticsearch/distribution/zip/elasticsearch/%(version)s/elasticsearch-%(version)s.zip', 'org/elasticsearch/distribution/deb/elasticsearch/%(version)s/elasticsearch-%(version)s.deb', 'org/elasticsearch/distribution/rpm/elasticsearch/%(version)s/elasticsearch-%(version)s.rpm' ]] verify_java_version('1.7') if url: download_url = url else: download_url = '%s/%s-%s' % ('http://download.elasticsearch.org/elasticsearch/staging', version, hash) download_and_verify(version, hash, files, download_url, plugins=DEFAULT_PLUGINS + plugins, verbose=verbose)
apache-2.0
[ 3, 3909, 370, 19509, 1733, 1334, 1373, 503, 1655, 11615, 199, 3, 4190, 14024, 14, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 199, 3, 12715, 14, 19509, 1733, 12378, 642, 570, 370, 1265, 1334, 199, 3, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 221, 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, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 199, 3, 376, 283, 1179, 2281, 7, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 3, 428, 17767, 13, 2219, 282, 4683, 7627, 199, 3, 199, 3, 413, 14, 13392, 3640, 314, 5330, 14, 6838, 12, 32610, 12, 820, 10793, 436, 3482, 570, 687, 314, 28512, 2851, 199, 3, 499, 14, 26114, 652, 1159, 7793, 17, 14647, 436, 598, 11115, 17597, 6169, 314, 4683, 790, 199, 3, 650, 14, 13276, 83, 1006, 25410, 8963, 199, 3, 841, 14, 7707, 83, 1373, 1031, 367, 5330, 14, 6838, 436, 3482, 6117, 436, 5920, 26, 199, 3, 259, 1553, 340, 652, 7858, 543, 9586, 413, 14, 23, 199, 3, 259, 1553, 340, 314, 1900, 2631, 1627, 365, 314, 1373, 626, 365, 2138, 701, 314, 2004, 1177, 199, 3, 259, 1553, 340, 314, 1900, 365, 282, 4683, 1015, 436, 440, 282, 5740, 1015, 199, 3, 259, 1553, 340, 1006, 8963, 787, 6511, 199, 3, 259, 1553, 340, 314, 2004, 1177, 2529, 314, 3211, 1015, 199, 3, 199, 3, 19635, 2962, 26, 199, 3, 199, 3, 2366, 19, 446, 34, 16605, 2374, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 199, 3, 199, 3, 370, 2597, 511, 1163, 8963, 862, 1255, 199, 3, 199, 3, 2366, 19, 446, 34, 16605, 2374, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 1553, 5265, 4190, 12, 29880, 12, 22226, 199, 3, 199, 3, 3390, 26, 7523, 314, 2884, 365, 1255, 687, 314, 24380, 1733, 2746, 2166, 2082, 199, 3, 199, 3, 2104, 5343, 282, 4683, 687, 27970, 8588, 862, 642, 26, 199, 3, 199, 3, 2366, 19, 446, 34, 4866, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 1553, 3535, 63, 633, 4178, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1317, 15, 23949, 15, 11840, 15, 199, 3, 199, 199, 646, 7534, 199, 646, 5549, 199, 646, 747, 199, 646, 4673, 199, 646, 5145, 199, 646, 4011, 199, 646, 4011, 14, 1069, 199, 646, 8337, 199, 646, 900, 199, 646, 2838, 199, 646, 2022, 199, 646, 1300, 772, 199, 199, 504, 9275, 63, 3221, 63, 9007, 492, 1255, 199, 504, 1455, 14, 1258, 492, 3101, 3225, 199, 199, 3472, 63, 16483, 10789, 275, 2097, 10466, 13, 530, 85, 401, 673, 298, 10466, 13, 20661, 417, 79, 8047, 401, 673, 298, 10466, 13, 9339, 764, 401, 673, 298, 10466, 13, 7853, 6413, 401, 673, 298, 10466, 13, 83, 808, 352, 401, 673, 298, 4091, 13, 7231, 401, 673, 298, 4091, 13, 9078, 401, 673, 298, 4091, 13, 22833, 401, 673, 298, 1807, 13, 991, 13, 1131, 401, 673, 298, 14859, 13, 23797, 401, 673, 298, 4159, 13, 9554, 401, 673, 298, 4159, 13, 1548, 401, 673, 298, 7153, 13, 31006, 19, 401, 673, 298, 7153, 13, 890, 937, 199, 199, 893, 26, 523, 1603, 28520, 63, 9524, 275, 747, 14, 2314, 459, 42, 28520, 63, 9524, 418, 199, 2590, 4067, 26, 523, 746, 6064, 4852, 523, 7754, 663, 1603, 28520, 63, 9524, 315, 314, 2589, 2544, 3879, 4683, 4744, 523, 4068, 32144, 675, 26, 4843, 1603, 28520, 63, 9524, 29, 64, 15, 2647, 15, 773, 1628, 15, 6138, 63, 4219, 446, 86, 283, 17, 14, 23, 10223, 64, 6141, 199, 199, 318, 12120, 63, 5803, 837, 523, 931, 275, 1603, 28520, 63, 9524, 523, 372, 283, 3790, 1603, 28520, 63, 9524, 5961, 83, 2, 15097, 5961, 83, 15, 1393, 26, 4, 3243, 2, 1603, 6087, 1348, 5127, 5961, 83, 15, 1393, 15, 6138, 4507, 450, 334, 515, 12, 931, 12, 931, 9, 199, 199, 318, 4911, 63, 6138, 63, 1023, 8, 1023, 304, 523, 308, 275, 747, 14, 12207, 3508, 83, 27, 12120, 446, 1023, 499, 18181, 17, 7, 450, 12120, 63, 5803, 8801, 739, 342, 523, 340, 283, 1015, 2071, 83, 3530, 450, 1015, 440, 315, 308, 26, 272, 746, 6064, 360, 7808, 6835, 1015, 367, 12120, 450, 83, 3427, 78, 5, 83, 7, 450, 334, 1023, 12, 308, 430, 421, 199, 318, 7793, 17, 8, 493, 304, 523, 543, 1551, 8, 493, 12, 283, 4848, 358, 465, 289, 26, 272, 372, 8337, 14, 4835, 17, 8, 70, 14, 739, 8801, 11453, 342, 199, 199, 318, 1586, 63, 5836, 8, 493, 304, 523, 543, 1551, 8, 493, 12, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 1362, 372, 289, 14, 739, 342, 421, 199, 318, 3618, 63, 509, 63, 932, 63, 16480, 8, 1102, 534, 4195, 14, 16, 14, 16, 14, 17, 297, 1844, 29, 25, 1840, 12, 2653, 29, 2259, 12, 1406, 16420, 523, 870, 360, 258, 13144, 316, 5133, 1031, 15410, 2808, 367, 737, 4750, 450, 83, 4696, 7, 450, 2653, 9, 523, 367, 485, 315, 1425, 8, 2593, 304, 272, 2557, 275, 3101, 3225, 8, 1102, 29, 1102, 12, 1844, 29, 719, 12, 2653, 29, 2593, 9, 272, 862, 26, 489, 900, 14, 4532, 8, 17, 9, 489, 2557, 14, 1069, 360, 2970, 297, 3260, 2323, 29, 1291, 9, 489, 522, 275, 2557 ]
[ 3909, 370, 19509, 1733, 1334, 1373, 503, 1655, 11615, 199, 3, 4190, 14024, 14, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 199, 3, 12715, 14, 19509, 1733, 12378, 642, 570, 370, 1265, 1334, 199, 3, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 221, 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, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 199, 3, 376, 283, 1179, 2281, 7, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 3, 428, 17767, 13, 2219, 282, 4683, 7627, 199, 3, 199, 3, 413, 14, 13392, 3640, 314, 5330, 14, 6838, 12, 32610, 12, 820, 10793, 436, 3482, 570, 687, 314, 28512, 2851, 199, 3, 499, 14, 26114, 652, 1159, 7793, 17, 14647, 436, 598, 11115, 17597, 6169, 314, 4683, 790, 199, 3, 650, 14, 13276, 83, 1006, 25410, 8963, 199, 3, 841, 14, 7707, 83, 1373, 1031, 367, 5330, 14, 6838, 436, 3482, 6117, 436, 5920, 26, 199, 3, 259, 1553, 340, 652, 7858, 543, 9586, 413, 14, 23, 199, 3, 259, 1553, 340, 314, 1900, 2631, 1627, 365, 314, 1373, 626, 365, 2138, 701, 314, 2004, 1177, 199, 3, 259, 1553, 340, 314, 1900, 365, 282, 4683, 1015, 436, 440, 282, 5740, 1015, 199, 3, 259, 1553, 340, 1006, 8963, 787, 6511, 199, 3, 259, 1553, 340, 314, 2004, 1177, 2529, 314, 3211, 1015, 199, 3, 199, 3, 19635, 2962, 26, 199, 3, 199, 3, 2366, 19, 446, 34, 16605, 2374, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 199, 3, 199, 3, 370, 2597, 511, 1163, 8963, 862, 1255, 199, 3, 199, 3, 2366, 19, 446, 34, 16605, 2374, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 1553, 5265, 4190, 12, 29880, 12, 22226, 199, 3, 199, 3, 3390, 26, 7523, 314, 2884, 365, 1255, 687, 314, 24380, 1733, 2746, 2166, 2082, 199, 3, 199, 3, 2104, 5343, 282, 4683, 687, 27970, 8588, 862, 642, 26, 199, 3, 199, 3, 2366, 19, 446, 34, 4866, 13, 2537, 15, 30697, 63, 396, 63, 1195, 14, 647, 1553, 1023, 499, 14, 16, 14, 16, 13, 5683, 17, 1553, 2227, 330, 667, 19, 69, 2417, 1553, 3535, 63, 633, 4178, 921, 26890, 14, 834, 8588, 14, 1308, 15, 1317, 15, 23949, 15, 11840, 15, 199, 3, 199, 199, 646, 7534, 199, 646, 5549, 199, 646, 747, 199, 646, 4673, 199, 646, 5145, 199, 646, 4011, 199, 646, 4011, 14, 1069, 199, 646, 8337, 199, 646, 900, 199, 646, 2838, 199, 646, 2022, 199, 646, 1300, 772, 199, 199, 504, 9275, 63, 3221, 63, 9007, 492, 1255, 199, 504, 1455, 14, 1258, 492, 3101, 3225, 199, 199, 3472, 63, 16483, 10789, 275, 2097, 10466, 13, 530, 85, 401, 673, 298, 10466, 13, 20661, 417, 79, 8047, 401, 673, 298, 10466, 13, 9339, 764, 401, 673, 298, 10466, 13, 7853, 6413, 401, 673, 298, 10466, 13, 83, 808, 352, 401, 673, 298, 4091, 13, 7231, 401, 673, 298, 4091, 13, 9078, 401, 673, 298, 4091, 13, 22833, 401, 673, 298, 1807, 13, 991, 13, 1131, 401, 673, 298, 14859, 13, 23797, 401, 673, 298, 4159, 13, 9554, 401, 673, 298, 4159, 13, 1548, 401, 673, 298, 7153, 13, 31006, 19, 401, 673, 298, 7153, 13, 890, 937, 199, 199, 893, 26, 523, 1603, 28520, 63, 9524, 275, 747, 14, 2314, 459, 42, 28520, 63, 9524, 418, 199, 2590, 4067, 26, 523, 746, 6064, 4852, 523, 7754, 663, 1603, 28520, 63, 9524, 315, 314, 2589, 2544, 3879, 4683, 4744, 523, 4068, 32144, 675, 26, 4843, 1603, 28520, 63, 9524, 29, 64, 15, 2647, 15, 773, 1628, 15, 6138, 63, 4219, 446, 86, 283, 17, 14, 23, 10223, 64, 6141, 199, 199, 318, 12120, 63, 5803, 837, 523, 931, 275, 1603, 28520, 63, 9524, 523, 372, 283, 3790, 1603, 28520, 63, 9524, 5961, 83, 2, 15097, 5961, 83, 15, 1393, 26, 4, 3243, 2, 1603, 6087, 1348, 5127, 5961, 83, 15, 1393, 15, 6138, 4507, 450, 334, 515, 12, 931, 12, 931, 9, 199, 199, 318, 4911, 63, 6138, 63, 1023, 8, 1023, 304, 523, 308, 275, 747, 14, 12207, 3508, 83, 27, 12120, 446, 1023, 499, 18181, 17, 7, 450, 12120, 63, 5803, 8801, 739, 342, 523, 340, 283, 1015, 2071, 83, 3530, 450, 1015, 440, 315, 308, 26, 272, 746, 6064, 360, 7808, 6835, 1015, 367, 12120, 450, 83, 3427, 78, 5, 83, 7, 450, 334, 1023, 12, 308, 430, 421, 199, 318, 7793, 17, 8, 493, 304, 523, 543, 1551, 8, 493, 12, 283, 4848, 358, 465, 289, 26, 272, 372, 8337, 14, 4835, 17, 8, 70, 14, 739, 8801, 11453, 342, 199, 199, 318, 1586, 63, 5836, 8, 493, 304, 523, 543, 1551, 8, 493, 12, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 1362, 372, 289, 14, 739, 342, 421, 199, 318, 3618, 63, 509, 63, 932, 63, 16480, 8, 1102, 534, 4195, 14, 16, 14, 16, 14, 17, 297, 1844, 29, 25, 1840, 12, 2653, 29, 2259, 12, 1406, 16420, 523, 870, 360, 258, 13144, 316, 5133, 1031, 15410, 2808, 367, 737, 4750, 450, 83, 4696, 7, 450, 2653, 9, 523, 367, 485, 315, 1425, 8, 2593, 304, 272, 2557, 275, 3101, 3225, 8, 1102, 29, 1102, 12, 1844, 29, 719, 12, 2653, 29, 2593, 9, 272, 862, 26, 489, 900, 14, 4532, 8, 17, 9, 489, 2557, 14, 1069, 360, 2970, 297, 3260, 2323, 29, 1291, 9, 489, 522, 275, 2557, 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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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 ]
benjello/openfisca-france-indirect-taxation
openfisca_france_indirect_taxation/tests/test_legislations.py
4
4237
# -*- coding: utf-8 -*- # OpenFisca -- A versatile microsimulation software # By: OpenFisca Team <contact@openfisca.fr> # # Copyright (C) 2011, 2012, 2013, 2014, 2015 OpenFisca Team # https://github.com/openfisca # # This file is part of OpenFisca. # # OpenFisca 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. # # OpenFisca 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 datetime import json import xml.etree.ElementTree from openfisca_core import conv, legislations, legislationsxml from openfisca_france_indirect_taxation import init_country TaxBenefitSystem = init_country() def check_legislation_xml_file(year): legislation_tree = xml.etree.ElementTree.parse(TaxBenefitSystem.legislation_xml_file_path) legislation_xml_json = conv.check(legislationsxml.xml_legislation_to_json)(legislation_tree.getroot(), state = conv.default_state) legislation_xml_json, errors = legislationsxml.validate_legislation_xml_json(legislation_xml_json, state = conv.default_state) if errors is not None: errors = conv.embed_error(legislation_xml_json, 'errors', errors) if errors is None: raise ValueError(unicode(json.dumps(legislation_xml_json, ensure_ascii = False, indent = 2)).encode('utf-8')) raise ValueError(u'{0} for: {1}'.format( unicode(json.dumps(errors, ensure_ascii = False, indent = 2, sort_keys = True)), unicode(json.dumps(legislation_xml_json, ensure_ascii = False, indent = 2)), ).encode('utf-8')) _, legislation_json = legislationsxml.transform_node_xml_json_to_json(legislation_xml_json) legislation_json, errors = legislations.validate_legislation_json(legislation_json, state = conv.default_state) if errors is not None: errors = conv.embed_error(legislation_json, 'errors', errors) if errors is None: raise ValueError(unicode(json.dumps(legislation_json, ensure_ascii = False, indent = 2)).encode('utf-8')) raise ValueError(u'{0} for: {1}'.format( unicode(json.dumps(errors, ensure_ascii = False, indent = 2, sort_keys = True)), unicode(json.dumps(legislation_json, ensure_ascii = False, indent = 2)), ).encode('utf-8')) # Create tax_benefit system only now, to be able to debug XML validation errors in above code. tax_benefit_system = TaxBenefitSystem() if tax_benefit_system.preprocess_legislation is not None: tax_benefit_system.preprocess_legislation(legislation_json) legislation_json = legislations.generate_dated_legislation_json(legislation_json, year) legislation_json, errors = legislations.validate_dated_legislation_json(legislation_json, state = conv.default_state) if errors is not None: errors = conv.embed_error(legislation_json, 'errors', errors) if errors is None: raise ValueError(unicode(json.dumps(legislation_json, ensure_ascii = False, indent = 2)).encode( 'utf-8')) raise ValueError(u'{0} for: {1}'.format( unicode(json.dumps(errors, ensure_ascii = False, indent = 2, sort_keys = True)), unicode(json.dumps(legislation_json, ensure_ascii = False, indent = 2)), ).encode('utf-8')) compact_legislation = legislations.compact_dated_node_json(legislation_json) assert compact_legislation is not None def test_legislation_xml_file(): for year in range(1995, datetime.date.today().year + 1): yield check_legislation_xml_file, year if __name__ == '__main__': test_legislation_xml_file() import nose nose.core.runmodule(argv = [__file__, '-v', 'test_legislations:test_legislation_xml_file'])
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 421, 199, 3, 3232, 38, 374, 696, 1553, 437, 809, 83, 23590, 9967, 22930, 2032, 199, 3, 4885, 26, 3232, 38, 374, 696, 11682, 665, 7811, 32, 1490, 329, 7101, 14, 4391, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 12, 6029, 12, 6171, 12, 6927, 12, 6900, 3232, 38, 374, 696, 11682, 199, 3, 4178, 921, 5031, 14, 957, 15, 1490, 329, 7101, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3232, 38, 374, 696, 14, 199, 3, 199, 3, 3232, 38, 374, 696, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 3232, 38, 374, 696, 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, 421, 199, 646, 2197, 199, 646, 2022, 199, 646, 2748, 14, 9464, 14, 15325, 199, 199, 504, 1551, 329, 7101, 63, 1018, 492, 8260, 12, 1026, 5668, 6011, 12, 1026, 5668, 6011, 1652, 199, 199, 504, 1551, 329, 7101, 63, 4391, 554, 63, 29306, 63, 5530, 425, 492, 4205, 63, 6063, 421, 199, 26019, 34, 6349, 3269, 3989, 275, 4205, 63, 6063, 342, 421, 199, 318, 1104, 63, 4170, 374, 2212, 63, 1652, 63, 493, 8, 3403, 304, 272, 1026, 5668, 2212, 63, 2350, 275, 2748, 14, 9464, 14, 15325, 14, 1122, 8, 26019, 34, 6349, 3269, 3989, 14, 4170, 374, 2212, 63, 1652, 63, 493, 63, 515, 9, 272, 1026, 5668, 2212, 63, 1652, 63, 1001, 275, 8260, 14, 1074, 8, 4170, 374, 6011, 1652, 14, 1652, 63, 4170, 374, 2212, 63, 475, 63, 1001, 5130, 4170, 374, 2212, 63, 2350, 14, 24544, 1062, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 339, 1026, 5668, 2212, 63, 1652, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 1652, 14, 3502, 63, 4170, 374, 2212, 63, 1652, 63, 1001, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 355, 4363, 275, 499, 4992, 2143, 360, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180, 8, 2550, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 12, 4069, 63, 1612, 275, 715, 1826, 288, 2649, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 1826, 288, 7092, 2143, 360, 1624, 13, 24, 1333, 339, 5501, 1026, 5668, 2212, 63, 1001, 275, 1026, 5668, 6011, 1652, 14, 4711, 63, 932, 63, 1652, 63, 1001, 63, 475, 63, 1001, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 9, 339, 1026, 5668, 2212, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 14, 3502, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 4992, 2143, 360, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180, 8, 2550, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 12, 4069, 63, 1612, 275, 715, 1826, 288, 2649, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 1826, 288, 7092, 2143, 360, 1624, 13, 24, 1333, 339, 327, 2790, 9067, 63, 66, 6349, 3269, 2656, 1454, 3063, 12, 370, 506, 7688, 370, 3105, 4692, 6411, 2552, 315, 3432, 1233, 14, 272, 9067, 63, 66, 6349, 3269, 63, 2253, 275, 30174, 34, 6349, 3269, 3989, 342, 272, 340, 9067, 63, 66, 6349, 3269, 63, 2253, 14, 17677, 63, 4170, 374, 2212, 365, 440, 488, 26, 267, 9067, 63, 66, 6349, 3269, 63, 2253, 14, 17677, 63, 4170, 374, 2212, 8, 4170, 374, 2212, 63, 1001, 9, 339, 1026, 5668, 2212, 63, 1001, 275, 1026, 5668, 6011, 14, 4208, 63, 19074, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 5361, 9, 272, 1026, 5668, 2212, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 14, 3502, 63, 19074, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 4992, 2143, 8, 355, 283, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 421, 199, 3, 3232, 38, 374, 696, 1553, 437, 809, 83, 23590, 9967, 22930, 2032, 199, 3, 4885, 26, 3232, 38, 374, 696, 11682, 665, 7811, 32, 1490, 329, 7101, 14, 4391, 30, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 12, 6029, 12, 6171, 12, 6927, 12, 6900, 3232, 38, 374, 696, 11682, 199, 3, 4178, 921, 5031, 14, 957, 15, 1490, 329, 7101, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3232, 38, 374, 696, 14, 199, 3, 199, 3, 3232, 38, 374, 696, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 3232, 38, 374, 696, 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, 421, 199, 646, 2197, 199, 646, 2022, 199, 646, 2748, 14, 9464, 14, 15325, 199, 199, 504, 1551, 329, 7101, 63, 1018, 492, 8260, 12, 1026, 5668, 6011, 12, 1026, 5668, 6011, 1652, 199, 199, 504, 1551, 329, 7101, 63, 4391, 554, 63, 29306, 63, 5530, 425, 492, 4205, 63, 6063, 421, 199, 26019, 34, 6349, 3269, 3989, 275, 4205, 63, 6063, 342, 421, 199, 318, 1104, 63, 4170, 374, 2212, 63, 1652, 63, 493, 8, 3403, 304, 272, 1026, 5668, 2212, 63, 2350, 275, 2748, 14, 9464, 14, 15325, 14, 1122, 8, 26019, 34, 6349, 3269, 3989, 14, 4170, 374, 2212, 63, 1652, 63, 493, 63, 515, 9, 272, 1026, 5668, 2212, 63, 1652, 63, 1001, 275, 8260, 14, 1074, 8, 4170, 374, 6011, 1652, 14, 1652, 63, 4170, 374, 2212, 63, 475, 63, 1001, 5130, 4170, 374, 2212, 63, 2350, 14, 24544, 1062, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 339, 1026, 5668, 2212, 63, 1652, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 1652, 14, 3502, 63, 4170, 374, 2212, 63, 1652, 63, 1001, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 355, 4363, 275, 499, 4992, 2143, 360, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180, 8, 2550, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 12, 4069, 63, 1612, 275, 715, 1826, 288, 2649, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 1826, 288, 7092, 2143, 360, 1624, 13, 24, 1333, 339, 5501, 1026, 5668, 2212, 63, 1001, 275, 1026, 5668, 6011, 1652, 14, 4711, 63, 932, 63, 1652, 63, 1001, 63, 475, 63, 1001, 8, 4170, 374, 2212, 63, 1652, 63, 1001, 9, 339, 1026, 5668, 2212, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 14, 3502, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 4992, 2143, 360, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180, 8, 2550, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 12, 4069, 63, 1612, 275, 715, 1826, 288, 2649, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 1826, 288, 7092, 2143, 360, 1624, 13, 24, 1333, 339, 327, 2790, 9067, 63, 66, 6349, 3269, 2656, 1454, 3063, 12, 370, 506, 7688, 370, 3105, 4692, 6411, 2552, 315, 3432, 1233, 14, 272, 9067, 63, 66, 6349, 3269, 63, 2253, 275, 30174, 34, 6349, 3269, 3989, 342, 272, 340, 9067, 63, 66, 6349, 3269, 63, 2253, 14, 17677, 63, 4170, 374, 2212, 365, 440, 488, 26, 267, 9067, 63, 66, 6349, 3269, 63, 2253, 14, 17677, 63, 4170, 374, 2212, 8, 4170, 374, 2212, 63, 1001, 9, 339, 1026, 5668, 2212, 63, 1001, 275, 1026, 5668, 6011, 14, 4208, 63, 19074, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 5361, 9, 272, 1026, 5668, 2212, 63, 1001, 12, 2552, 275, 1026, 5668, 6011, 14, 3502, 63, 19074, 63, 4170, 374, 2212, 63, 1001, 8, 4170, 374, 2212, 63, 1001, 12, 267, 1174, 275, 8260, 14, 885, 63, 929, 9, 272, 340, 2552, 365, 440, 488, 26, 267, 2552, 275, 8260, 14, 6427, 63, 705, 8, 4170, 374, 2212, 63, 1001, 12, 283, 2550, 297, 2552, 9, 267, 340, 2552, 365, 488, 26, 288, 746, 1722, 8, 2975, 8, 1001, 14, 4180, 8, 4170, 374, 2212, 63, 1001, 12, 4868, 63, 4371, 275, 756, 12, 4363, 275, 499, 4992, 2143, 8, 355, 283, 1624, 13, 24, 1333, 267, 746, 1722, 8, 85, 16019, 16, 93, 367, 26, 469, 17, 5285, 908, 8, 288, 2649, 8, 1001, 14, 4180, 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 ]
fchu/hadoop-0.20.205
share/hadoop/contrib/hod/hodlib/Common/logger.py
182
28370
#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. """hodLogger provides a customized interface to Python's core logging package. """ import sys, os, re, logging, logging.handlers, inspect, pprint, types from tcp import get_address_tuple fileFormatString = '[%(asctime)s] %(levelname)s/%(levelno)s \ %(module)s:%(lineno)s - %(message)s' streamFormatString = '%(levelname)s - %(message)s' debugStreamFormatString = '[%(asctime)s] %(levelname)s/%(levelno)s \ %(module)s:%(lineno)s - %(message)s' syslogFormatString = '(%(process)d) %(levelname)s/%(levelno)s \ %(module)s:%(lineno)s - %(message)s' smtpFormatString = '[%(asctime)s] %(levelname)s/%(levelno)s \ %(module)s:%(lineno)s\n\n%(message)s' fileFormater = logging.Formatter(fileFormatString) streamFormater = logging.Formatter(streamFormatString) debugStreamFormater = logging.Formatter(debugStreamFormatString) syslogFormater = logging.Formatter(syslogFormatString) smtpFormater = logging.Formatter(smtpFormatString) defaultFileLevel = 3 defaultStreamLevel = 4 defaultSyslogLevel = 3 defaultSmtpLevel = 0 hodLogLevelMap = { 0 : logging.CRITICAL, 1 : logging.ERROR, 2 : logging.WARNING, 3 : logging.INFO, 4 : logging.DEBUG } hodStreamFormatMap = { 0 : streamFormater, 1 : streamFormater, 2 : streamFormater, 3 : streamFormater, 4 : debugStreamFormater } rehodLogLevelMap = {} for key in hodLogLevelMap.keys(): rehodLogLevelMap[hodLogLevelMap[key]] = key reModule = re.compile("^(.*)\..*$") hodLogs = {} class hodRotatingFileHandler(logging.handlers.RotatingFileHandler): """ This class needs to be used in place of RotatingFileHandler when the 2.4.0 Python interpreter is used.""" def emit(self, record): """ Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline [N.B. this may be removed depending on feedback]. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. ***** THIS IS A HACK, when instances of hodLogger get passed to the child of a child thread for some reason self.stream gets closed. This version of emit re-opens self.stream if it is closed. After testing it appears that self.stream is only closed once after the second thread is initialized so there is not performance penalty to this hack. This problem only exists in python 2.4. ***** """ try: if self.shouldRollover(record): self.doRollover() try: msg = self.format(record) fs = "%s\n" if not hasattr(types, "UnicodeType"): #if no unicode support... self.stream.write(fs % msg) else: try: self.stream.write(fs % msg) except UnicodeError: self.stream.write(fs % msg.encode("UTF-8")) except ValueError: self.stream = open(self.baseFilename, self.mode) self.stream.write(fs % msg) self.flush() except: self.handleError(record) except: self.handleError(record) def shouldRollover(self, record): """ Determine if rollover should occur. Basically, see if the supplied record would cause the file to exceed the size limit we have. ***** THIS IS A HACK, when instances of hodLogger get passed to the child of a child thread for some reason self.stream gets closed. This version of emit re-opens self.stream if it is closed. After testing it appears that self.stream is only closed once after the second thread is initialized so there is not performance penalty to this hack. This problem only exists in python 2.4. ***** """ if self.maxBytes > 0: # are we rolling over? msg = "%s\n" % self.format(record) try: #due to non-posix-compliant Windows feature self.stream.seek(0, 2) except ValueError: self.stream = open(self.baseFilename, self.mode) self.stream.seek(0, 2) if self.stream.tell() + len(msg) >= self.maxBytes: return 1 return 0 class hodCustomLoggingLogger(logging.Logger): """ Slight extension of the logging.Logger class used by the hodLog class. """ def findCaller(self): """ findCaller() is supposed to return the callers file name and line number of the caller. This was broken when the logging package was wrapped by hodLog. We should return much more relevant info now. """ callerModule = '' callerLine = 0 currentModule = os.path.basename(__file__) currentModule = reModule.sub("\g<1>", currentModule) frames = inspect.stack() for i in range(len(frames)): frameModule = os.path.basename(frames[i][1]) frameModule = reModule.sub("\g<1>", frameModule) if frameModule == currentModule: previousFrameModule = os.path.basename(frames[i+1][1]) previousFrameModule = reModule.sub("\g<1>", previousFrameModule) callerFile = frames[i+1][1] callerLine = frames[i+1][2] continue returnValues = (callerFile, callerLine) if sys.version.startswith('2.4.4') or sys.version.startswith('2.5'): returnValues = (callerFile, callerLine, None) return returnValues class hodLog: """ Cluster management logging class. logging levels: 0 - log only critical messages 1 - log critical and error messages 2 - log critical, error, and warning messages 3 - log critical, error, warning, and info messages 4 - log critical, error, warning, info, and debug messages""" def __init__(self, appName): """Constructs a hodLogger object. appName - name of logging application, log filenames will be prepended with this name""" self.__appName = appName # initialize a dictionary to hold loggerNames self.__loggerNames = {} # initialize a dictionary to track log handlers and handler classes self.__logObjs = { 'file' : {}, 'smtp' : {}, 'syslog' : {}, 'strm' : {} } # use a custom logging.Logger class logging.setLoggerClass(hodCustomLoggingLogger) # get the root app logger self.__logger = logging.getLogger(appName) self.__logger.setLevel(logging.DEBUG) hodLogs[self.__appName] = self def __attr__(self, attrname): """loggerNames - list of defined logger names""" if attrname == "loggerNames": return self.__loggerNames.keys() else: raise AttributeError, attrname def __repr__(self): """Returns a string representation of a hodLog object of the form: LOG_NAME file: FILENAME (level LEVEL) smtp: SMTP_SERVER from FROM_ADDRESS (level LEVEL) strm: STRM_OBJECT (level LEVEL) ... """ hodLogString = "hodLog: %s\n\n" % self.__appName for loggerName in self.__loggerNames.keys(): hodLogString = "%s logger: %s\n" % (hodLogString, loggerName) handlerClasses = self.__logObjs.keys() handlerClasses.sort() for handlerClass in handlerClasses: try: loggerLevelName = logging.getLevelName( self.__logObjs[handlerClass][loggerName]['level']) hodLogString = "%s %s: %s (level %s)\n" % ( hodLogString, handlerClass, self.__logObjs[handlerClass][loggerName]['data'], loggerLevelName) except: hodLogString = "%s %s: none\n" % ( hodLogString, handlerClass) hodLogString = "%s\n" % hodLogString return hodLogString # 'private' method which adds handlers to self.__logObjs def __add_to_handlers(self, handlerClass, loggerName, handler, data, level): self.__logObjs[handlerClass][loggerName] = {} self.__logObjs[handlerClass][loggerName]['handler'] = handler self.__logObjs[handlerClass][loggerName]['data'] = data self.__logObjs[handlerClass][loggerName]['level'] = level # 'private' method which determines whether a hod log level is valid and # returns a valid logging.Logger level def __get_logging_level(self, level, defaultLevel): loggingLevel = '' try: loggingLevel = hodLogLevelMap[int(level)] except: loggingLevel = hodLogLevelMap[defaultLevel] return loggingLevel # make a logging.logger name rootLogger.childLogger in our case the # appName.componentName def __get_logging_logger_name(self, loggerName): return "%s.%s" % (self.__appName, loggerName) def add_logger(self, loggerName): """Adds a logger of name loggerName. loggerName - name of component of a given application doing the logging Returns a hodLogger object for the just added logger.""" try: self.__loggerNames[loggerName] except: loggingLoggerName = self.__get_logging_logger_name(loggerName) logging.getLogger(loggingLoggerName) self.__loggerNames[loggerName] = 1 return hodLogger(self.__appName, loggingLoggerName) def add_file(self, logDirectory, maxBytes=0, backupCount=0, level=defaultFileLevel, addToLoggerNames=None): """Adds a file handler to all defined loggers or a specified set of loggers. Each log file will be located in logDirectory and have a name of the form appName-loggerName.log. logDirectory - logging directory maxBytes - maximum log size to write in bytes before rotate backupCount - number of rotated logs to keep level - cluster management log level addToLoggerNames - list of logger names to which stream handling will be added""" def add_file_handler(loggerName): if not self.__logObjs['file'].has_key(loggerName): loggingLevel = self.__get_logging_level(level, defaultFileLevel) logFile = os.path.join(logDirectory, "%s-%s.log" % ( self.__appName, loggerName)) logFilePresent = False if(os.path.exists(logFile)): logFilePresent = True if sys.version.startswith('2.4'): fileHandler = hodRotatingFileHandler(logFile, maxBytes=maxBytes, backupCount=backupCount) else: fileHandler = logging.handlers.RotatingFileHandler(logFile, maxBytes=maxBytes, backupCount=backupCount) if logFilePresent and backupCount: fileHandler.doRollover() fileHandler.setLevel(loggingLevel) fileHandler.setFormatter(fileFormater) loggingLoggerName = self.__get_logging_logger_name(loggerName) aLogger = logging.getLogger(loggingLoggerName) aLogger.addHandler(fileHandler) fileData = "%s" % logFile self.__add_to_handlers('file', loggerName, fileHandler, fileData, loggingLevel) if addToLoggerNames: for loggerName in addToLoggerNames: add_file_handler(loggerName) else: for loggerName in self.__loggerNames: add_file_handler(loggerName) def add_stream(self, stream=sys.stderr, level=defaultStreamLevel, addToLoggerNames=None): """Adds a stream handler to all defined loggers or a specified set of loggers. stream - a stream such as sys.stderr or sys.stdout level - cluster management log level addToLoggerNames - tupple of logger names to which stream handling will be added""" def add_stream_handler(loggerName): if not self.__logObjs['strm'].has_key(loggerName): loggingLevel = self.__get_logging_level(level, defaultStreamLevel) streamHandler = logging.StreamHandler(stream) streamHandler.setLevel(loggingLevel) streamHandler.setFormatter(hodStreamFormatMap[int(level)]) loggingLoggerName = self.__get_logging_logger_name(loggerName) aLogger = logging.getLogger(loggingLoggerName) aLogger.addHandler(streamHandler) streamData = "%s" % stream self.__add_to_handlers('strm', loggerName, streamHandler, streamData, loggingLevel) if addToLoggerNames: for loggerName in addToLoggerNames: add_stream_handler(loggerName) else: for loggerName in self.__loggerNames: add_stream_handler(loggerName) def add_syslog(self, address, level=defaultSyslogLevel, addToLoggerNames=None): def add_syslog_handler(loggerName): if not self.__logObjs['syslog'].has_key(loggerName): loggingLevel = self.__get_logging_level(level, defaultSyslogLevel) address[1] = int(address[1]) syslogHandler = logging.handlers.SysLogHandler(tuple(address), 9) syslogHandler.setLevel(loggingLevel) syslogHandler.setFormatter(syslogFormater) loggingLoggerName = self.__get_logging_logger_name(loggerName) aLogger = logging.getLogger(loggingLoggerName) aLogger.addHandler(syslogHandler) syslogData = "%s:%s" % (address[0], address[1]) self.__add_to_handlers('syslog', loggerName, syslogHandler, syslogData, loggingLevel) if addToLoggerNames: for loggerName in addToLoggerNames: add_syslog_handler(loggerName) else: for loggerName in self.__loggerNames: add_syslog_handler(loggerName) def add_smtp(self, mailHost, fromAddress, toAddresses, level=defaultSmtpLevel, addToLoggerNames=None): """Adds an SMTP handler to all defined loggers or a specified set of loggers. mailHost - SMTP server to used when sending mail fromAddress - email address to use as the from address when sending mail toAdresses - comma seperated list of email address to which mail will be sent level - cluster management log level addToLoggerNames - tupple of logger names to which smtp handling will be added""" def add_email_handler(loggerName): if not self.__logObjs['smtp'].has_key(loggerName): loggingLevel = self.__get_logging_level(level, defaultSmtpLevel) subject = loggerName if loggingLevel == 50: subject = "%s - a critical error has occured." % subject elif loggingLevel == 40: subject = "%s - an error has occured." % subject elif loggingLevel == 30: subject = "%s - warning message." % subject elif loggingLevel == 20: subject = "%s - information message." % subject elif loggingLevel == 10: subject = "%s - debugging message." % subject mailHostTuple = get_address_tuple(mailHost) emailHandler = logging.handlers.SMTPHandler(mailHostTuple, fromAddress, toAddresses, subject) emailHandler.setFormatter(smtpFormater) emailHandler.setLevel(loggingLevel) loggingLoggerName = self.__get_logging_logger_name(loggerName) aLogger = logging.getLogger(loggingLoggerName) aLogger.addHandler(emailHandler) emailData = "%s from %s" % (mailHost, fromAddress) self.__add_to_handlers('smtp', loggerName, emailHandler, emailData, loggingLevel) if addToLoggerNames: for loggerName in addToLoggerNames: add_email_handler(loggerName) else: for loggerName in self.__loggerNames: add_email_handler(loggerName) def status(self): statusStruct = {} for loggerName in self.__loggerNames.keys(): statusStruct[loggerName] = [] for handlerClass in self.__logObjs.keys(): loggerDict = {} try: level = self.__logObjs[handlerClass][loggerName]['level'] level = rehodLogLevelMap[level] loggerDict['handler'] = handlerClass loggerDict['level'] = level loggerDict['data'] = \ self.__logObjs[handlerClass][loggerName]['data'] except: pass else: statusStruct[loggerName].append(loggerDict) return statusStruct def lock_handlers(self): for handlerClass in self.__logObjs.keys(): for loggerName in self.__logObjs[handlerClass].keys(): self.__logObjs[handlerClass][loggerName]['handler'].acquire() def release_handlers(self): for handlerClass in self.__logObjs.keys(): for loggerName in self.__logObjs[handlerClass].keys(): self.__logObjs[handlerClass][loggerName]['handler'].release() def get_level(self, handler, loggerName): return rehodLogLevelMap[self.__logObjs[handler][loggerName]['level']] def set_level(self, handler, loggerName, level): """Sets the logging level of a particular logger and logger handler. handler - handler (smtp, file, or stream) loggerName - logger to set level on level - level to set logger """ level = self.__get_logging_level(level, defaultFileLevel) self.__logObjs[handler][loggerName]['handler'].setLevel(level) self.__logObjs[handler][loggerName]['level'] = level if handler == 'stream': self.__logObjs[handler][loggerName]['handler'].setFormatter( hodStreamFormatMap[int(level)]) def set_logger_level(self, loggerName, level): status = 0 for handlerClass in self.__logObjs.keys(): if self.__logObjs[handlerClass].has_key(loggerName): self.set_level(handlerClass, loggerName, level) else: status = 1 return status def rollover(self, loggerName): status = 0 if self.__logObjs['file'].has_key(loggerName): if self.__logObjs['file'][loggerName]['handler'].shouldRollover(): self.__logObjs['file'][loggerName]['handler'].doRollover() else: status = 1 return status def set_max_bytes(self, maxBytes): status = 0 if self.__logObjs.has_key('file'): for loggerName in self.__logObjs['file'].keys(): self.__logObjs['file'][loggerName]['handler'].maxBytes = 0 else: status = 1 return status def get_logger(self, loggerName): """ Returns a hodLogger object for a logger by name. """ loggingLoggerName = self.__get_logging_logger_name(loggerName) return hodLogger(self.__appName, loggingLoggerName) def critical(self, loggerName, msg): """Logs a critical message and flushes log buffers. This method really should only be called upon a catastrophic failure. loggerName - logger to use msg - message to be logged""" loggingLoggerName = self.__get_logging_logger_name(loggerName) logger = logging.getLogger(loggingLoggerName) logger.critical(msg) self.flush() def error(self, loggerName, msg): """Logs an error message and flushes log buffers. loggerName - logger to use msg - message to be logged""" loggingLoggerName = self.__get_logging_logger_name(loggerName) logger = logging.getLogger(loggingLoggerName) logger.error(msg) self.flush() def warn(self, loggerName, msg): """Logs a warning message. loggerName - logger to use msg - message to be logged""" loggingLoggerName = self.__get_logging_logger_name(loggerName) logger = logging.getLogger(loggingLoggerName) logger.warn(msg) def info(self, loggerName, msg): """Logs an information message. loggerName - logger to use msg - message to be logged""" loggingLoggerName = self.__get_logging_logger_name(loggerName) logger = logging.getLogger(loggingLoggerName) logger.info(msg) def debug(self, loggerName, msg): """Logs a debugging message. loggerName - logger to use msg - message to be logged""" loggingLoggerName = self.__get_logging_logger_name(loggerName) logger = logging.getLogger(loggingLoggerName) logger.debug(msg) def flush(self): """Flush all log handlers.""" for handlerClass in self.__logObjs.keys(): for loggerName in self.__logObjs[handlerClass].keys(): self.__logObjs[handlerClass][loggerName]['handler'].flush() def shutdown(self): """Shutdown all logging, flushing all buffers.""" for handlerClass in self.__logObjs.keys(): for loggerName in self.__logObjs[handlerClass].keys(): self.__logObjs[handlerClass][loggerName]['handler'].flush() # Causes famous 'ValueError: I/O operation on closed file' # self.__logObjs[handlerClass][loggerName]['handler'].close() class hodLogger: """ Encapsulates a particular logger from a hodLog object. """ def __init__(self, appName, loggingLoggerName): """Constructs a hodLogger object (a particular logger in a hodLog object). loggingLoggerName - name of a logger in hodLog object""" self.__appName = appName self.__loggerName = loggingLoggerName self.__logger = logging.getLogger(self.__loggerName) def __repr__(self): """Returns a string representation of a hodComponentLog object.""" return "%s hodLog" % self.__loggerName def __call__(self): pass def set_logger_level(self, loggerName, level): return hodLogs[self.__appName].set_logger_level(loggerName, level) def set_max_bytes(self, maxBytes): return hodLogs[self.__appName].set_max_bytes(maxBytes) def rollover(self): return hodLogs[self.__appName].rollover(self.__loggerName) def get_level(self, handler, loggerName): return hodLogs[self.__appName].get_level(handler, loggerName) def critical(self, msg): """Logs a critical message and calls sys.exit(1). msg - message to be logged""" self.__logger.critical(msg) def error(self, msg): """Logs an error message. msg - message to be logged""" self.__logger.error(msg) def warn(self, msg): """Logs a warning message. msg - message to be logged""" self.__logger.warn(msg) def info(self, msg): """Logs an information message. msg - message to be logged""" self.__logger.info(msg) def debug(self, msg): """Logs a debugging message. msg - message to be logged""" self.__logger.debug(msg) class hodDummyLogger: """ Dummy hodLogger class. Other hod classes requiring a hodLogger default to this hodLogger if no logger is passed.""" def __init__(self): """pass""" pass def __repr__(self): return "dummy hodLogger" def __call__(self): """pass""" pass def set_logger_level(self, loggerName, level): return 0 def set_max_bytes(self, loggerName, maxBytes): return 0 def get_level(self, handler, loggerName): return 4 def rollover(self): return 0 def critical(self, msg): """pass""" pass def error(self, msg): """pass""" pass def warn(self, msg): """pass""" pass def info(self, msg): """pass""" pass def debug(self, msg): """pass""" pass def ensureLogDir(logDir): """Verify that the passed in log directory exists, and if it doesn't create it.""" if not os.path.exists(logDir): try: old_mask = os.umask(0) os.makedirs(logDir, 01777) os.umask(old_mask) except Exception, e: print >>sys.stderr, "Could not create log directories %s. Exception: %s. Stack Trace: %s" % (logDir, get_exception_error_string(), get_exception_string()) raise e def getLogger(cfg, logName): if cfg['debug'] > 0: user = cfg['userid'] baseLogger = hodLog(logName) log = baseLogger.add_logger('main') if cfg.has_key('log-dir'): serviceId = os.getenv('PBS_JOBID') if serviceId: logDir = os.path.join(cfg['log-dir'], "%s.%s" % (user, serviceId)) else: logDir = os.path.join(cfg['log-dir'], user) if not os.path.exists(logDir): os.mkdir(logDir) baseLogger.add_file(logDirectory=logDir, level=cfg['debug'], addToLoggerNames=('main',)) try: if cfg.has_key('stream') and cfg['stream']: baseLogger.add_stream(level=cfg['debug'], addToLoggerNames=('main',)) if cfg.has_key('syslog-address'): baseLogger.add_syslog(cfg['syslog-address'], level=cfg['debug'], addToLoggerNames=('main',)) except Exception,e: # Caught an exception while initialising logger log.critical("%s Logger failed to initialise. Reason : %s" % (logName, e)) pass return log
apache-2.0
[ 3, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 3, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 23662, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 3, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 3097, 1298, 1334, 314, 844, 14, 199, 624, 72, 364, 4455, 6571, 282, 26707, 3217, 370, 2018, 1159, 6170, 2050, 2559, 14, 199, 624, 199, 199, 646, 984, 12, 747, 12, 295, 12, 2050, 12, 2050, 14, 5586, 12, 6485, 12, 10933, 12, 2943, 199, 504, 14719, 492, 664, 63, 1562, 63, 2960, 199, 199, 493, 3484, 1558, 259, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 1745, 3484, 1558, 221, 275, 9487, 20056, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 1757, 3296, 3484, 1558, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 16878, 3484, 1558, 275, 8189, 2840, 1412, 9, 68, 9, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 15592, 3484, 1558, 259, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 60, 78, 60, 78, 2840, 1188, 9, 83, 7, 199, 199, 493, 2821, 6618, 275, 2050, 14, 7772, 8, 493, 3484, 1558, 9, 199, 1745, 2821, 6618, 275, 2050, 14, 7772, 8, 1745, 3484, 1558, 9, 199, 1757, 3296, 2821, 6618, 275, 2050, 14, 7772, 8, 1757, 3296, 3484, 1558, 9, 199, 16878, 2821, 6618, 275, 2050, 14, 7772, 8, 16878, 3484, 1558, 9, 199, 15592, 2821, 6618, 275, 2050, 14, 7772, 8, 15592, 3484, 1558, 9, 199, 199, 885, 1173, 4670, 275, 650, 199, 885, 3296, 4670, 275, 841, 199, 885, 11319, 793, 4670, 275, 650, 199, 885, 16782, 683, 4670, 275, 378, 199, 199, 72, 364, 2445, 4670, 2956, 275, 469, 378, 520, 2050, 14, 21539, 12, 673, 413, 520, 2050, 14, 3170, 12, 673, 499, 520, 2050, 14, 9171, 12, 673, 650, 520, 2050, 14, 4531, 12, 673, 841, 520, 2050, 14, 5287, 259, 789, 199, 199, 72, 364, 3296, 3484, 2956, 275, 469, 378, 520, 2547, 2821, 6618, 12, 2432, 413, 520, 2547, 2821, 6618, 12, 2432, 499, 520, 2547, 2821, 6618, 12, 2432, 650, 520, 2547, 2821, 6618, 12, 2432, 841, 520, 3105, 3296, 2821, 6618, 789, 199, 199, 264, 72, 364, 2445, 4670, 2956, 275, 1052, 199, 509, 790, 315, 394, 364, 2445, 4670, 2956, 14, 1612, 837, 272, 295, 72, 364, 2445, 4670, 2956, 59, 72, 364, 2445, 4670, 2956, 59, 498, 2677, 275, 790, 421, 199, 264, 2377, 275, 295, 14, 2014, 18523, 19276, 2862, 703, 10, 22550, 199, 199, 72, 364, 16333, 275, 1052, 199, 199, 533, 394, 364, 14728, 1958, 21982, 8, 4806, 14, 5586, 14, 14728, 1958, 21982, 304, 272, 408, 961, 1021, 4839, 370, 506, 1202, 315, 4192, 402, 20423, 1958, 21982, 1380, 267, 314, 499, 14, 20, 14, 16, 2018, 12693, 365, 1202, 1041, 339, 347, 8689, 8, 277, 12, 2777, 304, 267, 408, 267, 662, 1147, 282, 2777, 14, 398, 982, 282, 9698, 365, 2013, 12, 652, 365, 1202, 370, 1475, 314, 2777, 14, 267, 710, 2777, 365, 2066, 5313, 370, 314, 2547, 543, 282, 8520, 8057, 267, 359, 46, 14, 34, 14, 642, 1443, 506, 4829, 10298, 641, 17145, 1055, 982, 1919, 267, 2556, 365, 3451, 12, 652, 365, 7871, 1808, 267, 5190, 14, 1361, 63, 1971, 436, 11544, 370, 314, 2547, 14, 398, 1011, 9153, 398, 5749, 2281, 437, 31697, 12, 1380, 4454, 402, 394, 364, 4455, 664, 3032, 370, 314, 1982, 402, 267, 282, 1982, 2462, 367, 2005, 4499, 291, 14, 1745, 7545, 6876, 14, 221, 961, 1015, 267, 402, 8689, 295, 13, 1490, 83, 291, 14, 1745, 340, 652, 365, 6876, 14, 221, 12836, 5343, 652, 11337, 267, 626, 291, 14, 1745, 365, 1454, 6876, 5403, 2410, 314, 3499, 2462, 365, 267, 10038, 880, 2337, 365, 440, 10238, 21251, 370, 642, 11176, 14, 221, 961, 267, 5160, 1454, 3495, 315, 2366, 499, 14, 20, 14, 398, 1011, 9153, 267, 408, 267, 862, 26, 288, 340, 291, 14, 5626, 50, 393, 21960, 8, 3059, 304, 355, 291, 14, 1117, 50, 393, 21960, 342, 288, 862, 26, 355, 1499, 275, 291, 14, 908, 8, 3059, 9, 355, 7449, 275, 2071, 83, 60, 78, 2, 355, 340, 440, 2688, 8, 1313, 12, 298, 7087, 804, 2349, 327, 692, 949, 2649, 2291, 1396, 490, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 355, 587, 26, 490, 862, 26, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 490, 871, 20872, 26, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 14, 2143, 480, 6610, 13, 24, 2237, 490, 871, 1722, 26, 717, 291, 14, 1745, 275, 1551, 8, 277, 14, 1095, 8117, 12, 291, 14, 632, 9, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 2234, 291, 14, 4939, 342, 288, 871, 26, 355, 291, 14, 2479, 547, 8, 3059, 9, 267, 871, 26, 288, 291 ]
[ 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 3, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 23662, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 3, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 3097, 1298, 1334, 314, 844, 14, 199, 624, 72, 364, 4455, 6571, 282, 26707, 3217, 370, 2018, 1159, 6170, 2050, 2559, 14, 199, 624, 199, 199, 646, 984, 12, 747, 12, 295, 12, 2050, 12, 2050, 14, 5586, 12, 6485, 12, 10933, 12, 2943, 199, 504, 14719, 492, 664, 63, 1562, 63, 2960, 199, 199, 493, 3484, 1558, 259, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 1745, 3484, 1558, 221, 275, 9487, 20056, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 1757, 3296, 3484, 1558, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 16878, 3484, 1558, 275, 8189, 2840, 1412, 9, 68, 9, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 446, 2818, 1188, 9, 83, 7, 199, 199, 15592, 3484, 1558, 259, 275, 6730, 2840, 18331, 9, 83, 61, 2818, 20056, 9, 83, 21275, 1896, 889, 9, 83, 971, 199, 2840, 578, 9, 83, 19648, 3469, 9, 83, 60, 78, 60, 78, 2840, 1188, 9, 83, 7, 199, 199, 493, 2821, 6618, 275, 2050, 14, 7772, 8, 493, 3484, 1558, 9, 199, 1745, 2821, 6618, 275, 2050, 14, 7772, 8, 1745, 3484, 1558, 9, 199, 1757, 3296, 2821, 6618, 275, 2050, 14, 7772, 8, 1757, 3296, 3484, 1558, 9, 199, 16878, 2821, 6618, 275, 2050, 14, 7772, 8, 16878, 3484, 1558, 9, 199, 15592, 2821, 6618, 275, 2050, 14, 7772, 8, 15592, 3484, 1558, 9, 199, 199, 885, 1173, 4670, 275, 650, 199, 885, 3296, 4670, 275, 841, 199, 885, 11319, 793, 4670, 275, 650, 199, 885, 16782, 683, 4670, 275, 378, 199, 199, 72, 364, 2445, 4670, 2956, 275, 469, 378, 520, 2050, 14, 21539, 12, 673, 413, 520, 2050, 14, 3170, 12, 673, 499, 520, 2050, 14, 9171, 12, 673, 650, 520, 2050, 14, 4531, 12, 673, 841, 520, 2050, 14, 5287, 259, 789, 199, 199, 72, 364, 3296, 3484, 2956, 275, 469, 378, 520, 2547, 2821, 6618, 12, 2432, 413, 520, 2547, 2821, 6618, 12, 2432, 499, 520, 2547, 2821, 6618, 12, 2432, 650, 520, 2547, 2821, 6618, 12, 2432, 841, 520, 3105, 3296, 2821, 6618, 789, 199, 199, 264, 72, 364, 2445, 4670, 2956, 275, 1052, 199, 509, 790, 315, 394, 364, 2445, 4670, 2956, 14, 1612, 837, 272, 295, 72, 364, 2445, 4670, 2956, 59, 72, 364, 2445, 4670, 2956, 59, 498, 2677, 275, 790, 421, 199, 264, 2377, 275, 295, 14, 2014, 18523, 19276, 2862, 703, 10, 22550, 199, 199, 72, 364, 16333, 275, 1052, 199, 199, 533, 394, 364, 14728, 1958, 21982, 8, 4806, 14, 5586, 14, 14728, 1958, 21982, 304, 272, 408, 961, 1021, 4839, 370, 506, 1202, 315, 4192, 402, 20423, 1958, 21982, 1380, 267, 314, 499, 14, 20, 14, 16, 2018, 12693, 365, 1202, 1041, 339, 347, 8689, 8, 277, 12, 2777, 304, 267, 408, 267, 662, 1147, 282, 2777, 14, 398, 982, 282, 9698, 365, 2013, 12, 652, 365, 1202, 370, 1475, 314, 2777, 14, 267, 710, 2777, 365, 2066, 5313, 370, 314, 2547, 543, 282, 8520, 8057, 267, 359, 46, 14, 34, 14, 642, 1443, 506, 4829, 10298, 641, 17145, 1055, 982, 1919, 267, 2556, 365, 3451, 12, 652, 365, 7871, 1808, 267, 5190, 14, 1361, 63, 1971, 436, 11544, 370, 314, 2547, 14, 398, 1011, 9153, 398, 5749, 2281, 437, 31697, 12, 1380, 4454, 402, 394, 364, 4455, 664, 3032, 370, 314, 1982, 402, 267, 282, 1982, 2462, 367, 2005, 4499, 291, 14, 1745, 7545, 6876, 14, 221, 961, 1015, 267, 402, 8689, 295, 13, 1490, 83, 291, 14, 1745, 340, 652, 365, 6876, 14, 221, 12836, 5343, 652, 11337, 267, 626, 291, 14, 1745, 365, 1454, 6876, 5403, 2410, 314, 3499, 2462, 365, 267, 10038, 880, 2337, 365, 440, 10238, 21251, 370, 642, 11176, 14, 221, 961, 267, 5160, 1454, 3495, 315, 2366, 499, 14, 20, 14, 398, 1011, 9153, 267, 408, 267, 862, 26, 288, 340, 291, 14, 5626, 50, 393, 21960, 8, 3059, 304, 355, 291, 14, 1117, 50, 393, 21960, 342, 288, 862, 26, 355, 1499, 275, 291, 14, 908, 8, 3059, 9, 355, 7449, 275, 2071, 83, 60, 78, 2, 355, 340, 440, 2688, 8, 1313, 12, 298, 7087, 804, 2349, 327, 692, 949, 2649, 2291, 1396, 490, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 355, 587, 26, 490, 862, 26, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 490, 871, 20872, 26, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 14, 2143, 480, 6610, 13, 24, 2237, 490, 871, 1722, 26, 717, 291, 14, 1745, 275, 1551, 8, 277, 14, 1095, 8117, 12, 291, 14, 632, 9, 717, 291, 14, 1745, 14, 952, 8, 2319, 450, 1499, 9, 2234, 291, 14, 4939, 342, 288, 871, 26, 355, 291, 14, 2479, 547, 8, 3059, 9, 267, 871, 26, 288, 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, 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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 ]
redmanatee/field-promotion
py/rest_handler.py
2
8273
import webapp2 from models import Game from models import User from google.appengine.ext import ndb import logging import json from datetime import datetime from google.appengine.api import users from google.appengine.api import namespace_manager from collections import defaultdict import math import datetime class StatsHandler(webapp2.RequestHandler): def how_many_months_ago(self, date1, date2): delta = abs(date1 - date2) months = int(math.ceil(delta.days / 30)) return months def initialize_stats(self): return { 'count': 0, 'nt_count': 0, 'wins': 0, 'win_per': 0.0, 'history':[0,0,0,0,0,0,0,0,0,0,0,0] } def get(self): today = datetime.date.today() statMap = {} game_list = [] namespace_manager.set_namespace(users.get_current_user().user_id()) query = Game.query() games = query.fetch(1000) for game in games: faction = game.player_faction if not faction in statMap: statMap[faction] = self.initialize_stats() statMap[game.player_faction]['count'] += 1 if game.won: statMap[game.player_faction]['wins'] += 1 if not game.teaching and not game.draw: statMap[game.player_faction]['nt_count'] += 1 months_ago = self.how_many_months_ago(game.date, today) if months_ago < 12: statMap[game.player_faction]['history'][months_ago] +=1 self.response.out.write(json.dumps(statMap)) class GameHandler(webapp2.RequestHandler): def record_usage(self): cu = users.get_current_user() current_user = User.query().filter(User.user_id == cu.user_id()).get() if not current_user: user = User(user_id = cu.user_id(), name = cu.nickname(), email=cu.email()) user.put() else: current_user.put() def get(self): """ GET ALL games - and filters if there are search criteria """ self.record_usage() game_list = [] namespace_manager.set_namespace(users.get_current_user().user_id()) query = Game.query() if self.request.get('player_faction'): query = query.filter(Game.player_faction == self.request.get('player_faction')) if self.request.get('player_warcaster'): query = query.filter(Game.player_warcaster == self.request.get('player_warcaster')) if self.request.get('opponent_name'): query = query.filter(Game.opponent_name == self.request.get('opponent_name')) if self.request.get('opponent_faction'): query = query.filter(Game.opponent_faction == self.request.get('opponent_faction')) if self.request.get('opponent_warcaster'): query = query.filter(Game.opponent_warcaster == self.request.get('opponent_warcaster')) if self.request.get('size'): query = query.filter(Game.size == self.request.get('size')) if self.request.get('result'): query = query.filter(Game.result == self.request.get('result')) if self.request.get('location'): query = query.filter(Game.location == self.request.get('location')) if self.request.get('game_type'): query = query.filter(Game.game_type == self.request.get('game_type')) win_count = 0 non_teaching_count = 0 games = query.fetch(1000) for game in games: if game.won: win_count = win_count + 1 if not game.teaching and not game.draw: non_teaching_count = non_teaching_count + 1 game_map = {} for attr in ['player_faction', 'player_warcaster', 'opponent_name', 'opponent_faction', 'opponent_warcaster', 'result', 'size', 'won', 'draw', 'teaching', 'location', 'game_type']: game_map[attr] = getattr(game, attr) game_map['date'] = game.date.isoformat() if game.created_at is not None: game_map['created_at'] = game.created_at.isoformat() game_map['key'] = game.key.urlsafe() game_list.append(game_map) game_list.sort(key=lambda game: game['date'], reverse=True) results = { 'games': game_list, 'win_count': win_count, 'non_teaching_count': non_teaching_count } self.response.out.write(json.dumps(results)) def post(self): """ CREATE a new Game entity """ self.record_usage() namespace_manager.set_namespace(users.get_current_user().user_id()) param_map = {} param_map['player_faction'] = self.request.get('player_faction') param_map['player_warcaster'] = self.request.get('player_warcaster') param_map['opponent_name'] = self.request.get('opponent_name', '') param_map['opponent_faction'] = self.request.get('opponent_faction') param_map['opponent_warcaster'] = self.request.get('opponent_warcaster') param_map['result'] = self.request.get('result') param_map['size'] = int(self.request.get('size', 0)) param_map['won'] = self.request.get('won') == 'true' param_map['draw'] = self.request.get('draw') == 'true' param_map['teaching'] = self.request.get('teaching') == 'true' param_map['location'] = self.request.get('location', '') param_map['game_type'] = self.request.get('game_type', '') date = self.request.get('date') try: real_date = datetime.datetime.strptime(date,'%m/%d/%Y') except (ValueError): real_date = datetime.datetime.strptime(date,'%Y-%m-%d') param_map['date'] = real_date param_map['created_at'] = datetime.datetime.now() logging.error(param_map) game = Game(**param_map) game.put() self.response.out.write(game.key.urlsafe()) def put(self): """ UPDATE an existing Game entity """ self.record_usage() namespace_manager.set_namespace(users.get_current_user().user_id()) key_str = self.request.get('key') key = ndb.Key(urlsafe=key_str) game = key.get() if not game: self.response.set_code(500) return if self.request.get('player_faction'): game.player_faction = self.request.get('player_faction') if self.request.get('player_warcaster'): game.player_warcaster = self.request.get('player_warcaster') if self.request.get('opponent_name'): game.opponent_name = self.request.get('opponent_name') if self.request.get('opponent_faction'): game.opponent_faction = self.request.get('opponent_faction') if self.request.get('opponent_warcaster'): game.opponent_warcaster = self.request.get('opponent_warcaster') if self.request.get('result'): game.result = self.request.get('result') if self.request.get('size'): game.size = int(self.request.get('size', 0)) if self.request.get('won'): game.won = bool(self.request.get('won')) if self.request.get('draw'): game.draw = bool(self.request.get('draw')) if self.request.get('teaching'): game.teaching = bool(self.request.get('teaching')) if self.request.get('date'): date = self.request.get('date') try: real_date = datetime.datetime.strptime(date,'%m/%d/%Y') except (ValueError): real_date = datetime.datetime.strptime(date,'%Y-%m-%d') game.date = real_date game.put() def delete(self): """ DELETE an existing Game entity """ self.record_usage() namespace_manager.set_namespace(users.get_current_user().user_id()) key_str = self.request.url key_str = self.request.url[self.request.url.rfind('/')+1:] key = ndb.Key(urlsafe=key_str) key.delete() app = webapp2.WSGIApplication([ ('/game.*', GameHandler), ('/stat.*', StatsHandler) ], debug=True)
mit
[ 646, 24812, 18, 199, 504, 1709, 492, 25132, 199, 504, 1709, 492, 2876, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 646, 2050, 199, 646, 2022, 199, 504, 2197, 492, 2197, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 504, 6233, 14, 15358, 14, 1246, 492, 3231, 63, 2609, 199, 504, 5055, 492, 10018, 199, 646, 3473, 199, 646, 2197, 199, 199, 533, 29062, 2461, 8, 22632, 18, 14, 11149, 304, 272, 347, 4212, 63, 3479, 63, 16745, 63, 14315, 8, 277, 12, 1434, 17, 12, 1434, 18, 304, 267, 5762, 275, 2853, 8, 602, 17, 446, 1434, 18, 9, 267, 20096, 275, 1109, 8, 3442, 14, 14085, 8, 3136, 14, 4899, 1182, 4233, 430, 267, 372, 20096, 339, 347, 8265, 63, 3200, 8, 277, 304, 267, 372, 469, 288, 283, 835, 356, 378, 12, 288, 283, 343, 63, 835, 356, 378, 12, 288, 283, 2676, 83, 356, 378, 12, 288, 283, 2676, 63, 529, 356, 378, 14, 16, 12, 288, 283, 5570, 15211, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 61, 267, 789, 339, 347, 664, 8, 277, 304, 267, 11168, 275, 2197, 14, 602, 14, 8136, 342, 267, 5672, 2956, 275, 1052, 267, 9219, 63, 513, 275, 942, 267, 3231, 63, 2609, 14, 409, 63, 3251, 8, 3707, 14, 362, 63, 1818, 63, 751, 1252, 751, 63, 344, 1012, 267, 1827, 275, 25132, 14, 1131, 342, 267, 9219, 83, 275, 1827, 14, 3535, 8, 5279, 9, 267, 367, 9219, 315, 9219, 83, 26, 288, 289, 1287, 275, 9219, 14, 6147, 63, 17287, 288, 340, 440, 289, 1287, 315, 5672, 2956, 26, 355, 5672, 2956, 59, 17287, 61, 275, 291, 14, 8489, 63, 3200, 342, 288, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 835, 418, 847, 413, 288, 340, 9219, 14, 87, 265, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 2676, 83, 418, 847, 413, 288, 340, 440, 9219, 14, 266, 23302, 436, 440, 9219, 14, 5485, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 343, 63, 835, 418, 847, 413, 953, 20096, 63, 14315, 275, 291, 14, 1917, 63, 3479, 63, 16745, 63, 14315, 8, 5097, 14, 602, 12, 11168, 9, 288, 340, 20096, 63, 14315, 665, 3144, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 5570, 3488, 16745, 63, 14315, 61, 847, 17, 7318, 291, 14, 1310, 14, 548, 14, 952, 8, 1001, 14, 4180, 8, 3736, 2956, 430, 421, 199, 533, 25132, 2461, 8, 22632, 18, 14, 11149, 304, 339, 347, 2777, 63, 3807, 8, 277, 304, 267, 30353, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 267, 1453, 63, 751, 275, 2876, 14, 1131, 1252, 1541, 8, 1899, 14, 751, 63, 344, 508, 30353, 14, 751, 63, 344, 8801, 362, 342, 267, 340, 440, 1453, 63, 751, 26, 288, 922, 275, 2876, 8, 751, 63, 344, 275, 30353, 14, 751, 63, 344, 1062, 536, 275, 30353, 14, 18544, 1062, 3031, 29, 15140, 14, 2123, 1012, 288, 922, 14, 524, 342, 267, 587, 26, 288, 1453, 63, 751, 14, 524, 342, 339, 347, 664, 8, 277, 304, 267, 408, 267, 9576, 11727, 9219, 83, 446, 436, 4766, 340, 2337, 787, 2754, 15647, 267, 408, 267, 291, 14, 3059, 63, 3807, 342, 267, 9219, 63, 513, 275, 942, 267, 3231, 63, 2609, 14, 409, 63, 3251, 8, 3707, 14, 362, 63, 1818, 63, 751, 1252, 751, 63, 344, 1012, 267, 1827, 275, 25132, 14, 1131, 342, 398, 340, 291, 14, 1069, 14, 362, 360, 6147, 63, 17287, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 6147, 63, 17287, 508, 291, 14, 1069, 14, 362, 360, 6147, 63, 17287, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 6147, 63, 3281, 67, 2311, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 6147, 63, 3281, 67, 2311, 508, 291, 14, 1069, 14, 362, 360, 6147, 63, 3281, 67, 2311, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 354, 735, 1779, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 354, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 354, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 17287, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 17287, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 17287, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 3281, 67, 2311, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 3281, 67, 2311, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 3281, 67, 2311, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 890, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 890, 508, 291, 14, 1069, 14, 362, 360, 890, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 1099, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 1099, 508, 291, 14, 1069, 14, 362, 360, 1099, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 1985, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 1985, 508, 291, 14, 1069, 14, 362, 360, 1985, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 5097, 63, 466, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 5097, 63, 466, 508, 291, 14, 1069, 14, 362, 360, 5097, 63, 466, 1333, 398, 4747, 63, 835, 275, 378, 267, 2222, 63, 266, 23302, 63, 835, 275, 378, 398, 9219, 83, 275, 1827, 14, 3535, 8, 5279, 9, 398, 367, 9219, 315, 9219, 83, 26, 288, 340, 9219, 14, 87, 265, 26, 355, 4747, 63, 835, 275, 4747, 63, 835, 435, 413, 288, 340, 440, 9219, 14, 266, 23302, 436, 440, 9219, 14, 5485, 26, 355, 2222, 63, 266, 23302, 63, 835, 275, 2222, 63, 266, 23302, 63, 835, 435, 413, 288, 9219, 63, 1130, 275, 1052, 288, 367, 1921, 315, 788, 6147, 63, 17287, 297, 283, 6147, 63, 3281, 67, 2311, 297, 283, 411, 10339, 63, 354, 297, 283, 411, 10339, 63, 17287, 297, 586, 283 ]
[ 24812, 18, 199, 504, 1709, 492, 25132, 199, 504, 1709, 492, 2876, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 646, 2050, 199, 646, 2022, 199, 504, 2197, 492, 2197, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 504, 6233, 14, 15358, 14, 1246, 492, 3231, 63, 2609, 199, 504, 5055, 492, 10018, 199, 646, 3473, 199, 646, 2197, 199, 199, 533, 29062, 2461, 8, 22632, 18, 14, 11149, 304, 272, 347, 4212, 63, 3479, 63, 16745, 63, 14315, 8, 277, 12, 1434, 17, 12, 1434, 18, 304, 267, 5762, 275, 2853, 8, 602, 17, 446, 1434, 18, 9, 267, 20096, 275, 1109, 8, 3442, 14, 14085, 8, 3136, 14, 4899, 1182, 4233, 430, 267, 372, 20096, 339, 347, 8265, 63, 3200, 8, 277, 304, 267, 372, 469, 288, 283, 835, 356, 378, 12, 288, 283, 343, 63, 835, 356, 378, 12, 288, 283, 2676, 83, 356, 378, 12, 288, 283, 2676, 63, 529, 356, 378, 14, 16, 12, 288, 283, 5570, 15211, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 61, 267, 789, 339, 347, 664, 8, 277, 304, 267, 11168, 275, 2197, 14, 602, 14, 8136, 342, 267, 5672, 2956, 275, 1052, 267, 9219, 63, 513, 275, 942, 267, 3231, 63, 2609, 14, 409, 63, 3251, 8, 3707, 14, 362, 63, 1818, 63, 751, 1252, 751, 63, 344, 1012, 267, 1827, 275, 25132, 14, 1131, 342, 267, 9219, 83, 275, 1827, 14, 3535, 8, 5279, 9, 267, 367, 9219, 315, 9219, 83, 26, 288, 289, 1287, 275, 9219, 14, 6147, 63, 17287, 288, 340, 440, 289, 1287, 315, 5672, 2956, 26, 355, 5672, 2956, 59, 17287, 61, 275, 291, 14, 8489, 63, 3200, 342, 288, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 835, 418, 847, 413, 288, 340, 9219, 14, 87, 265, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 2676, 83, 418, 847, 413, 288, 340, 440, 9219, 14, 266, 23302, 436, 440, 9219, 14, 5485, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 343, 63, 835, 418, 847, 413, 953, 20096, 63, 14315, 275, 291, 14, 1917, 63, 3479, 63, 16745, 63, 14315, 8, 5097, 14, 602, 12, 11168, 9, 288, 340, 20096, 63, 14315, 665, 3144, 26, 355, 5672, 2956, 59, 5097, 14, 6147, 63, 17287, 2733, 5570, 3488, 16745, 63, 14315, 61, 847, 17, 7318, 291, 14, 1310, 14, 548, 14, 952, 8, 1001, 14, 4180, 8, 3736, 2956, 430, 421, 199, 533, 25132, 2461, 8, 22632, 18, 14, 11149, 304, 339, 347, 2777, 63, 3807, 8, 277, 304, 267, 30353, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 267, 1453, 63, 751, 275, 2876, 14, 1131, 1252, 1541, 8, 1899, 14, 751, 63, 344, 508, 30353, 14, 751, 63, 344, 8801, 362, 342, 267, 340, 440, 1453, 63, 751, 26, 288, 922, 275, 2876, 8, 751, 63, 344, 275, 30353, 14, 751, 63, 344, 1062, 536, 275, 30353, 14, 18544, 1062, 3031, 29, 15140, 14, 2123, 1012, 288, 922, 14, 524, 342, 267, 587, 26, 288, 1453, 63, 751, 14, 524, 342, 339, 347, 664, 8, 277, 304, 267, 408, 267, 9576, 11727, 9219, 83, 446, 436, 4766, 340, 2337, 787, 2754, 15647, 267, 408, 267, 291, 14, 3059, 63, 3807, 342, 267, 9219, 63, 513, 275, 942, 267, 3231, 63, 2609, 14, 409, 63, 3251, 8, 3707, 14, 362, 63, 1818, 63, 751, 1252, 751, 63, 344, 1012, 267, 1827, 275, 25132, 14, 1131, 342, 398, 340, 291, 14, 1069, 14, 362, 360, 6147, 63, 17287, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 6147, 63, 17287, 508, 291, 14, 1069, 14, 362, 360, 6147, 63, 17287, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 6147, 63, 3281, 67, 2311, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 6147, 63, 3281, 67, 2311, 508, 291, 14, 1069, 14, 362, 360, 6147, 63, 3281, 67, 2311, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 354, 735, 1779, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 354, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 354, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 17287, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 17287, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 17287, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 3281, 67, 2311, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 411, 10339, 63, 3281, 67, 2311, 508, 291, 14, 1069, 14, 362, 360, 411, 10339, 63, 3281, 67, 2311, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 890, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 890, 508, 291, 14, 1069, 14, 362, 360, 890, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 1099, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 1099, 508, 291, 14, 1069, 14, 362, 360, 1099, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 1985, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 1985, 508, 291, 14, 1069, 14, 362, 360, 1985, 1333, 267, 340, 291, 14, 1069, 14, 362, 360, 5097, 63, 466, 735, 288, 1827, 275, 1827, 14, 1541, 8, 11454, 14, 5097, 63, 466, 508, 291, 14, 1069, 14, 362, 360, 5097, 63, 466, 1333, 398, 4747, 63, 835, 275, 378, 267, 2222, 63, 266, 23302, 63, 835, 275, 378, 398, 9219, 83, 275, 1827, 14, 3535, 8, 5279, 9, 398, 367, 9219, 315, 9219, 83, 26, 288, 340, 9219, 14, 87, 265, 26, 355, 4747, 63, 835, 275, 4747, 63, 835, 435, 413, 288, 340, 440, 9219, 14, 266, 23302, 436, 440, 9219, 14, 5485, 26, 355, 2222, 63, 266, 23302, 63, 835, 275, 2222, 63, 266, 23302, 63, 835, 435, 413, 288, 9219, 63, 1130, 275, 1052, 288, 367, 1921, 315, 788, 6147, 63, 17287, 297, 283, 6147, 63, 3281, 67, 2311, 297, 283, 411, 10339, 63, 354, 297, 283, 411, 10339, 63, 17287, 297, 586, 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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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, 1 ]
mt2d2/servo
tests/wpt/css-tests/tools/html5lib/html5lib/tests/test_tokenizer.py
420
6544
from __future__ import absolute_import, division, unicode_literals import json import warnings import re from .support import get_data_files from html5lib.tokenizer import HTMLTokenizer from html5lib import constants class TokenizerTestParser(object): def __init__(self, initialState, lastStartTag=None): self.tokenizer = HTMLTokenizer self._state = initialState self._lastStartTag = lastStartTag def parse(self, stream, encoding=None, innerHTML=False): tokenizer = self.tokenizer(stream, encoding) self.outputTokens = [] tokenizer.state = getattr(tokenizer, self._state) if self._lastStartTag is not None: tokenizer.currentToken = {"type": "startTag", "name": self._lastStartTag} types = dict((v, k) for k, v in constants.tokenTypes.items()) for token in tokenizer: getattr(self, 'process%s' % types[token["type"]])(token) return self.outputTokens def processDoctype(self, token): self.outputTokens.append(["DOCTYPE", token["name"], token["publicId"], token["systemId"], token["correct"]]) def processStartTag(self, token): self.outputTokens.append(["StartTag", token["name"], dict(token["data"][::-1]), token["selfClosing"]]) def processEmptyTag(self, token): if token["name"] not in constants.voidElements: self.outputTokens.append("ParseError") self.outputTokens.append(["StartTag", token["name"], dict(token["data"][::-1])]) def processEndTag(self, token): self.outputTokens.append(["EndTag", token["name"], token["selfClosing"]]) def processComment(self, token): self.outputTokens.append(["Comment", token["data"]]) def processSpaceCharacters(self, token): self.outputTokens.append(["Character", token["data"]]) self.processSpaceCharacters = self.processCharacters def processCharacters(self, token): self.outputTokens.append(["Character", token["data"]]) def processEOF(self, token): pass def processParseError(self, token): self.outputTokens.append(["ParseError", token["data"]]) def concatenateCharacterTokens(tokens): outputTokens = [] for token in tokens: if "ParseError" not in token and token[0] == "Character": if (outputTokens and "ParseError" not in outputTokens[-1] and outputTokens[-1][0] == "Character"): outputTokens[-1][1] += token[1] else: outputTokens.append(token) else: outputTokens.append(token) return outputTokens def normalizeTokens(tokens): # TODO: convert tests to reflect arrays for i, token in enumerate(tokens): if token[0] == 'ParseError': tokens[i] = token[0] return tokens def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder, ignoreErrors=False): """Test whether the test has passed or failed If the ignoreErrorOrder flag is set to true we don't test the relative positions of parse errors and non parse errors """ checkSelfClosing = False for token in expectedTokens: if (token[0] == "StartTag" and len(token) == 4 or token[0] == "EndTag" and len(token) == 3): checkSelfClosing = True break if not checkSelfClosing: for token in receivedTokens: if token[0] == "StartTag" or token[0] == "EndTag": token.pop() if not ignoreErrorOrder and not ignoreErrors: return expectedTokens == receivedTokens else: # Sort the tokens into two groups; non-parse errors and parse errors tokens = {"expected": [[], []], "received": [[], []]} for tokenType, tokenList in zip(list(tokens.keys()), (expectedTokens, receivedTokens)): for token in tokenList: if token != "ParseError": tokens[tokenType][0].append(token) else: if not ignoreErrors: tokens[tokenType][1].append(token) return tokens["expected"] == tokens["received"] def unescape(test): def decode(inp): return inp.encode("utf-8").decode("unicode-escape") test["input"] = decode(test["input"]) for token in test["output"]: if token == "ParseError": continue else: token[1] = decode(token[1]) if len(token) > 2: for key, value in token[2]: del token[2][key] token[2][decode(key)] = decode(value) return test def runTokenizerTest(test): warnings.resetwarnings() warnings.simplefilter("error") expected = concatenateCharacterTokens(test['output']) if 'lastStartTag' not in test: test['lastStartTag'] = None parser = TokenizerTestParser(test['initialState'], test['lastStartTag']) tokens = parser.parse(test['input']) tokens = concatenateCharacterTokens(tokens) received = normalizeTokens(tokens) errorMsg = "\n".join(["\n\nInitial state:", test['initialState'], "\nInput:", test['input'], "\nExpected:", repr(expected), "\nreceived:", repr(tokens)]) errorMsg = errorMsg ignoreErrorOrder = test.get('ignoreErrorOrder', False) assert tokensMatch(expected, received, ignoreErrorOrder, True), errorMsg def _doCapitalize(match): return match.group(1).upper() _capitalizeRe = re.compile(r"\W+(\w)").sub def capitalize(s): s = s.lower() s = _capitalizeRe(_doCapitalize, s) return s def testTokenizer(): for filename in get_data_files('tokenizer', '*.test'): with open(filename) as fp: tests = json.load(fp) if 'tests' in tests: for index, test in enumerate(tests['tests']): if 'initialStates' not in test: test["initialStates"] = ["Data state"] if 'doubleEscaped' in test: test = unescape(test) for initialState in test["initialStates"]: test["initialState"] = capitalize(initialState) yield runTokenizerTest, test
mpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 3598, 199, 646, 295, 199, 199, 504, 1275, 4058, 492, 664, 63, 576, 63, 1725, 199, 199, 504, 3517, 21, 773, 14, 13771, 492, 4163, 21782, 199, 504, 3517, 21, 773, 492, 5262, 421, 199, 533, 8767, 1793, 774, 2842, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2536, 2223, 12, 2061, 17697, 29, 403, 304, 267, 291, 14, 13771, 275, 4163, 21782, 267, 291, 423, 929, 275, 2536, 2223, 267, 291, 423, 2019, 17697, 275, 2061, 17697, 339, 347, 2198, 8, 277, 12, 2547, 12, 2644, 29, 403, 12, 6506, 4943, 29, 797, 304, 267, 14803, 275, 291, 14, 13771, 8, 1745, 12, 2644, 9, 267, 291, 14, 1199, 16419, 275, 942, 398, 14803, 14, 929, 275, 2519, 8, 13771, 12, 291, 423, 929, 9, 267, 340, 291, 423, 2019, 17697, 365, 440, 488, 26, 288, 14803, 14, 11631, 275, 2420, 466, 582, 298, 16252, 401, 4228, 298, 354, 582, 291, 423, 2019, 17697, 93, 398, 2943, 275, 1211, 1332, 86, 12, 1022, 9, 367, 1022, 12, 373, 315, 5262, 14, 1418, 4100, 14, 1744, 1012, 267, 367, 1526, 315, 14803, 26, 288, 2519, 8, 277, 12, 283, 1412, 5, 83, 7, 450, 2943, 59, 1418, 905, 466, 937, 566, 8, 1418, 9, 398, 372, 291, 14, 1199, 16419, 339, 347, 2112, 21629, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 16556, 401, 1526, 905, 354, 2255, 1526, 905, 25311, 2255, 3303, 1526, 905, 20150, 2255, 1526, 905, 4525, 937, 566, 339, 347, 2112, 17697, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 17697, 401, 1526, 905, 354, 2255, 3303, 1211, 8, 1418, 905, 576, 9210, 21123, 17, 2522, 1526, 905, 26770, 937, 566, 339, 347, 2112, 4699, 1931, 8, 277, 12, 1526, 304, 267, 340, 1526, 905, 354, 937, 440, 315, 5262, 14, 1647, 6255, 26, 288, 291, 14, 1199, 16419, 14, 740, 480, 9123, 531, 267, 291, 14, 1199, 16419, 14, 740, 5234, 17697, 401, 1526, 905, 354, 2255, 1211, 8, 1418, 905, 576, 9210, 21123, 17, 24310, 339, 347, 2112, 16906, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 16906, 401, 1526, 905, 354, 2255, 3303, 1526, 905, 26770, 937, 566, 339, 347, 2112, 7488, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 7488, 401, 1526, 905, 576, 937, 566, 339, 347, 2112, 28501, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 14852, 401, 1526, 905, 576, 937, 566, 267, 291, 14, 1412, 28501, 275, 291, 14, 1412, 9272, 339, 347, 2112, 9272, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 14852, 401, 1526, 905, 576, 937, 566, 339, 347, 2112, 13178, 8, 277, 12, 1526, 304, 267, 986, 339, 347, 2112, 9123, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 9123, 401, 1526, 905, 576, 937, 566, 421, 199, 318, 24788, 14852, 16419, 8, 4504, 304, 272, 1072, 16419, 275, 942, 272, 367, 1526, 315, 4645, 26, 267, 340, 298, 9123, 2, 440, 315, 1526, 436, 1526, 59, 16, 61, 508, 298, 14852, 582, 288, 340, 334, 1199, 16419, 436, 298, 9123, 2, 440, 315, 1072, 16419, 1988, 17, 61, 436, 490, 1072, 16419, 1988, 17, 1527, 16, 61, 508, 298, 14852, 2349, 355, 1072, 16419, 1988, 17, 1527, 17, 61, 847, 1526, 59, 17, 61, 288, 587, 26, 355, 1072, 16419, 14, 740, 8, 1418, 9, 267, 587, 26, 288, 1072, 16419, 14, 740, 8, 1418, 9, 272, 372, 1072, 16419, 421, 199, 318, 7666, 16419, 8, 4504, 304, 272, 327, 3254, 26, 3957, 2295, 370, 16806, 6572, 272, 367, 284, 12, 1526, 315, 3874, 8, 4504, 304, 267, 340, 1526, 59, 16, 61, 508, 283, 9123, 356, 288, 4645, 59, 73, 61, 275, 1526, 59, 16, 61, 272, 372, 4645, 421, 199, 318, 4645, 4486, 8, 2062, 16419, 12, 3086, 16419, 12, 3686, 547, 4738, 12, 355, 3686, 9298, 29, 797, 304, 272, 408, 774, 3775, 314, 511, 965, 3032, 503, 3405, 339, 982, 314, 3686, 547, 4738, 3305, 365, 663, 370, 2549, 781, 2793, 1133, 511, 314, 3847, 272, 12266, 402, 2198, 2552, 436, 2222, 2198, 2552, 272, 408, 272, 1104, 12887, 18433, 275, 756, 272, 367, 1526, 315, 1420, 16419, 26, 267, 340, 334, 1418, 59, 16, 61, 508, 298, 17697, 2, 436, 822, 8, 1418, 9, 508, 841, 355, 503, 1526, 59, 16, 61, 508, 298, 16906, 2, 436, 822, 8, 1418, 9, 508, 650, 304, 288, 1104, 12887, 18433, 275, 715, 288, 2059, 339, 340, 440, 1104, 12887, 18433, 26, 267, 367, 1526, 315, 3086, 16419, 26, 288, 340, 1526, 59, 16, 61, 508, 298, 17697, 2, 503, 1526, 59, 16, 61, 508, 298, 16906, 582, 355, 1526, 14, 1935, 342, 339, 340, 440, 3686, 547, 4738, 436, 440, 3686, 9298, 26, 267, 372, 1420, 16419, 508, 3086, 16419, 272, 587, 26, 267, 327, 16722, 314, 4645, 1901, 2877, 4652, 27, 2222, 13, 1122, 2552, 436, 2198, 2552, 267, 4645, 275, 2420, 2062, 582, 3474, 467, 942, 467, 298, 9226, 582, 3474, 467, 942, 9420, 267, 367, 1526, 804, 12, 1526, 1296, 315, 3482, 8, 513, 8, 4504, 14, 1612, 4000, 3147, 334, 2062, 16419, 12, 3086, 16419, 2298, 288, 367, 1526, 315, 1526, 1296, 26, 355, 340, 1526, 1137, 298, 9123, 582, 490, 4645, 59, 1418, 804, 1527, 16, 1055, 740, 8, 1418, 9, 355, 587, 26, 490, 340, 440, 3686, 9298, 26, 717, 4645, 59, 1418, 804, 1527, 17, 1055, 740, 8, 1418, 9, 267, 372, 4645, 905, 2062, 937, 508, 4645, 905, 9226, 937, 421, 199, 318, 22221, 8, 396, 304, 272, 347, 4849, 8, 11416, 304, 267, 372, 10702, 14, 2143, 480, 1624, 13, 24, 3471, 2708, 480, 2975, 13, 3765, 531, 339, 511, 905, 1210, 937, 275, 4849, 8, 396, 905, 1210, 3135, 272, 367, 1526, 315, 511, 905, 1199, 6229, 267, 340, 1526, 508, 298, 9123, 582, 288, 1980, 267, 587, 26, 288, 1526, 59, 17, 61, 275, 4849, 8 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 3598, 199, 646, 295, 199, 199, 504, 1275, 4058, 492, 664, 63, 576, 63, 1725, 199, 199, 504, 3517, 21, 773, 14, 13771, 492, 4163, 21782, 199, 504, 3517, 21, 773, 492, 5262, 421, 199, 533, 8767, 1793, 774, 2842, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 2536, 2223, 12, 2061, 17697, 29, 403, 304, 267, 291, 14, 13771, 275, 4163, 21782, 267, 291, 423, 929, 275, 2536, 2223, 267, 291, 423, 2019, 17697, 275, 2061, 17697, 339, 347, 2198, 8, 277, 12, 2547, 12, 2644, 29, 403, 12, 6506, 4943, 29, 797, 304, 267, 14803, 275, 291, 14, 13771, 8, 1745, 12, 2644, 9, 267, 291, 14, 1199, 16419, 275, 942, 398, 14803, 14, 929, 275, 2519, 8, 13771, 12, 291, 423, 929, 9, 267, 340, 291, 423, 2019, 17697, 365, 440, 488, 26, 288, 14803, 14, 11631, 275, 2420, 466, 582, 298, 16252, 401, 4228, 298, 354, 582, 291, 423, 2019, 17697, 93, 398, 2943, 275, 1211, 1332, 86, 12, 1022, 9, 367, 1022, 12, 373, 315, 5262, 14, 1418, 4100, 14, 1744, 1012, 267, 367, 1526, 315, 14803, 26, 288, 2519, 8, 277, 12, 283, 1412, 5, 83, 7, 450, 2943, 59, 1418, 905, 466, 937, 566, 8, 1418, 9, 398, 372, 291, 14, 1199, 16419, 339, 347, 2112, 21629, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 16556, 401, 1526, 905, 354, 2255, 1526, 905, 25311, 2255, 3303, 1526, 905, 20150, 2255, 1526, 905, 4525, 937, 566, 339, 347, 2112, 17697, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 17697, 401, 1526, 905, 354, 2255, 3303, 1211, 8, 1418, 905, 576, 9210, 21123, 17, 2522, 1526, 905, 26770, 937, 566, 339, 347, 2112, 4699, 1931, 8, 277, 12, 1526, 304, 267, 340, 1526, 905, 354, 937, 440, 315, 5262, 14, 1647, 6255, 26, 288, 291, 14, 1199, 16419, 14, 740, 480, 9123, 531, 267, 291, 14, 1199, 16419, 14, 740, 5234, 17697, 401, 1526, 905, 354, 2255, 1211, 8, 1418, 905, 576, 9210, 21123, 17, 24310, 339, 347, 2112, 16906, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 16906, 401, 1526, 905, 354, 2255, 3303, 1526, 905, 26770, 937, 566, 339, 347, 2112, 7488, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 7488, 401, 1526, 905, 576, 937, 566, 339, 347, 2112, 28501, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 14852, 401, 1526, 905, 576, 937, 566, 267, 291, 14, 1412, 28501, 275, 291, 14, 1412, 9272, 339, 347, 2112, 9272, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 14852, 401, 1526, 905, 576, 937, 566, 339, 347, 2112, 13178, 8, 277, 12, 1526, 304, 267, 986, 339, 347, 2112, 9123, 8, 277, 12, 1526, 304, 267, 291, 14, 1199, 16419, 14, 740, 5234, 9123, 401, 1526, 905, 576, 937, 566, 421, 199, 318, 24788, 14852, 16419, 8, 4504, 304, 272, 1072, 16419, 275, 942, 272, 367, 1526, 315, 4645, 26, 267, 340, 298, 9123, 2, 440, 315, 1526, 436, 1526, 59, 16, 61, 508, 298, 14852, 582, 288, 340, 334, 1199, 16419, 436, 298, 9123, 2, 440, 315, 1072, 16419, 1988, 17, 61, 436, 490, 1072, 16419, 1988, 17, 1527, 16, 61, 508, 298, 14852, 2349, 355, 1072, 16419, 1988, 17, 1527, 17, 61, 847, 1526, 59, 17, 61, 288, 587, 26, 355, 1072, 16419, 14, 740, 8, 1418, 9, 267, 587, 26, 288, 1072, 16419, 14, 740, 8, 1418, 9, 272, 372, 1072, 16419, 421, 199, 318, 7666, 16419, 8, 4504, 304, 272, 327, 3254, 26, 3957, 2295, 370, 16806, 6572, 272, 367, 284, 12, 1526, 315, 3874, 8, 4504, 304, 267, 340, 1526, 59, 16, 61, 508, 283, 9123, 356, 288, 4645, 59, 73, 61, 275, 1526, 59, 16, 61, 272, 372, 4645, 421, 199, 318, 4645, 4486, 8, 2062, 16419, 12, 3086, 16419, 12, 3686, 547, 4738, 12, 355, 3686, 9298, 29, 797, 304, 272, 408, 774, 3775, 314, 511, 965, 3032, 503, 3405, 339, 982, 314, 3686, 547, 4738, 3305, 365, 663, 370, 2549, 781, 2793, 1133, 511, 314, 3847, 272, 12266, 402, 2198, 2552, 436, 2222, 2198, 2552, 272, 408, 272, 1104, 12887, 18433, 275, 756, 272, 367, 1526, 315, 1420, 16419, 26, 267, 340, 334, 1418, 59, 16, 61, 508, 298, 17697, 2, 436, 822, 8, 1418, 9, 508, 841, 355, 503, 1526, 59, 16, 61, 508, 298, 16906, 2, 436, 822, 8, 1418, 9, 508, 650, 304, 288, 1104, 12887, 18433, 275, 715, 288, 2059, 339, 340, 440, 1104, 12887, 18433, 26, 267, 367, 1526, 315, 3086, 16419, 26, 288, 340, 1526, 59, 16, 61, 508, 298, 17697, 2, 503, 1526, 59, 16, 61, 508, 298, 16906, 582, 355, 1526, 14, 1935, 342, 339, 340, 440, 3686, 547, 4738, 436, 440, 3686, 9298, 26, 267, 372, 1420, 16419, 508, 3086, 16419, 272, 587, 26, 267, 327, 16722, 314, 4645, 1901, 2877, 4652, 27, 2222, 13, 1122, 2552, 436, 2198, 2552, 267, 4645, 275, 2420, 2062, 582, 3474, 467, 942, 467, 298, 9226, 582, 3474, 467, 942, 9420, 267, 367, 1526, 804, 12, 1526, 1296, 315, 3482, 8, 513, 8, 4504, 14, 1612, 4000, 3147, 334, 2062, 16419, 12, 3086, 16419, 2298, 288, 367, 1526, 315, 1526, 1296, 26, 355, 340, 1526, 1137, 298, 9123, 582, 490, 4645, 59, 1418, 804, 1527, 16, 1055, 740, 8, 1418, 9, 355, 587, 26, 490, 340, 440, 3686, 9298, 26, 717, 4645, 59, 1418, 804, 1527, 17, 1055, 740, 8, 1418, 9, 267, 372, 4645, 905, 2062, 937, 508, 4645, 905, 9226, 937, 421, 199, 318, 22221, 8, 396, 304, 272, 347, 4849, 8, 11416, 304, 267, 372, 10702, 14, 2143, 480, 1624, 13, 24, 3471, 2708, 480, 2975, 13, 3765, 531, 339, 511, 905, 1210, 937, 275, 4849, 8, 396, 905, 1210, 3135, 272, 367, 1526, 315, 511, 905, 1199, 6229, 267, 340, 1526, 508, 298, 9123, 582, 288, 1980, 267, 587, 26, 288, 1526, 59, 17, 61, 275, 4849, 8, 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 ]
yavalvas/yav_com
build/matplotlib/lib/mpl_examples/widgets/slider_demo.py
13
1179
import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Slider, Button, RadioButtons fig, ax = plt.subplots() plt.subplots_adjust(left=0.25, bottom=0.25) t = np.arange(0.0, 1.0, 0.001) a0 = 5 f0 = 3 s = a0*np.sin(2*np.pi*f0*t) l, = plt.plot(t,s, lw=2, color='red') plt.axis([0, 1, -10, 10]) axcolor = 'lightgoldenrodyellow' axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor) axamp = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor) sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0) samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0) def update(val): amp = samp.val freq = sfreq.val l.set_ydata(amp*np.sin(2*np.pi*freq*t)) fig.canvas.draw_idle() sfreq.on_changed(update) samp.on_changed(update) resetax = plt.axes([0.8, 0.025, 0.1, 0.04]) button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975') def reset(event): sfreq.reset() samp.reset() button.on_clicked(reset) rax = plt.axes([0.025, 0.5, 0.15, 0.15], axisbg=axcolor) radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0) def colorfunc(label): l.set_color(label) fig.canvas.draw_idle() radio.on_clicked(colorfunc) plt.show()
mit
[ 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 14, 8583, 492, 428, 11306, 12, 16005, 12, 13514, 24021, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 342, 199, 6003, 14, 21430, 63, 10917, 8, 3039, 29, 16, 14, 821, 12, 9048, 29, 16, 14, 821, 9, 199, 84, 275, 980, 14, 5605, 8, 16, 14, 16, 12, 413, 14, 16, 12, 378, 14, 4587, 9, 199, 65, 16, 275, 959, 199, 70, 16, 275, 650, 199, 83, 275, 282, 16, 10, 1590, 14, 5911, 8, 18, 10, 1590, 14, 1038, 10, 70, 16, 10, 84, 9, 199, 76, 12, 275, 4488, 14, 2798, 8, 84, 12, 83, 12, 20482, 29, 18, 12, 3164, 534, 581, 358, 199, 6003, 14, 3127, 779, 16, 12, 413, 12, 446, 709, 12, 1616, 566, 199, 199, 1219, 2326, 275, 283, 4040, 19440, 293, 8161, 10723, 7, 199, 1219, 5646, 275, 4488, 14, 6402, 779, 16, 14, 821, 12, 378, 14, 17, 12, 378, 14, 2182, 12, 378, 14, 1644, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 1219, 5282, 221, 275, 4488, 14, 6402, 779, 16, 14, 821, 12, 378, 14, 1046, 12, 378, 14, 2182, 12, 378, 14, 1644, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 199, 83, 5646, 275, 428, 11306, 8, 1219, 5646, 12, 283, 13875, 297, 378, 14, 17, 12, 4233, 14, 16, 12, 1139, 826, 29, 70, 16, 9, 199, 16557, 275, 428, 11306, 8, 1219, 5282, 12, 283, 28189, 297, 378, 14, 17, 12, 1616, 14, 16, 12, 1139, 826, 29, 65, 16, 9, 199, 199, 318, 1678, 8, 637, 304, 272, 15204, 275, 2937, 311, 14, 637, 272, 9220, 275, 308, 5646, 14, 637, 272, 634, 14, 409, 63, 89, 576, 8, 5282, 10, 1590, 14, 5911, 8, 18, 10, 1590, 14, 1038, 10, 5646, 10, 84, 430, 272, 6085, 14, 7682, 14, 5485, 63, 12000, 342, 199, 83, 5646, 14, 265, 63, 2489, 8, 873, 9, 199, 16557, 14, 265, 63, 2489, 8, 873, 9, 199, 199, 3958, 1219, 275, 4488, 14, 6402, 779, 16, 14, 24, 12, 378, 14, 18823, 12, 378, 14, 17, 12, 378, 14, 966, 566, 199, 3887, 275, 16005, 8, 3958, 1219, 12, 283, 9637, 297, 3164, 29, 1219, 2326, 12, 394, 1883, 2326, 534, 16, 14, 28947, 358, 199, 318, 5305, 8, 1430, 304, 272, 308, 5646, 14, 3958, 342, 272, 2937, 311, 14, 3958, 342, 199, 3887, 14, 265, 63, 11276, 8, 3958, 9, 199, 199, 14495, 275, 4488, 14, 6402, 779, 16, 14, 18823, 12, 378, 14, 21, 12, 378, 14, 1046, 12, 378, 14, 1046, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 11905, 275, 13514, 24021, 8, 14495, 12, 661, 581, 297, 283, 6304, 297, 283, 7731, 659, 4702, 29, 16, 9, 199, 318, 3164, 1532, 8, 1302, 304, 272, 634, 14, 409, 63, 2326, 8, 1302, 9, 272, 6085, 14, 7682, 14, 5485, 63, 12000, 342, 199, 11905, 14, 265, 63, 11276, 8, 2326, 1532, 9, 199, 199, 6003, 14, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 8027, 14, 8583, 492, 428, 11306, 12, 16005, 12, 13514, 24021, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 342, 199, 6003, 14, 21430, 63, 10917, 8, 3039, 29, 16, 14, 821, 12, 9048, 29, 16, 14, 821, 9, 199, 84, 275, 980, 14, 5605, 8, 16, 14, 16, 12, 413, 14, 16, 12, 378, 14, 4587, 9, 199, 65, 16, 275, 959, 199, 70, 16, 275, 650, 199, 83, 275, 282, 16, 10, 1590, 14, 5911, 8, 18, 10, 1590, 14, 1038, 10, 70, 16, 10, 84, 9, 199, 76, 12, 275, 4488, 14, 2798, 8, 84, 12, 83, 12, 20482, 29, 18, 12, 3164, 534, 581, 358, 199, 6003, 14, 3127, 779, 16, 12, 413, 12, 446, 709, 12, 1616, 566, 199, 199, 1219, 2326, 275, 283, 4040, 19440, 293, 8161, 10723, 7, 199, 1219, 5646, 275, 4488, 14, 6402, 779, 16, 14, 821, 12, 378, 14, 17, 12, 378, 14, 2182, 12, 378, 14, 1644, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 1219, 5282, 221, 275, 4488, 14, 6402, 779, 16, 14, 821, 12, 378, 14, 1046, 12, 378, 14, 2182, 12, 378, 14, 1644, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 199, 83, 5646, 275, 428, 11306, 8, 1219, 5646, 12, 283, 13875, 297, 378, 14, 17, 12, 4233, 14, 16, 12, 1139, 826, 29, 70, 16, 9, 199, 16557, 275, 428, 11306, 8, 1219, 5282, 12, 283, 28189, 297, 378, 14, 17, 12, 1616, 14, 16, 12, 1139, 826, 29, 65, 16, 9, 199, 199, 318, 1678, 8, 637, 304, 272, 15204, 275, 2937, 311, 14, 637, 272, 9220, 275, 308, 5646, 14, 637, 272, 634, 14, 409, 63, 89, 576, 8, 5282, 10, 1590, 14, 5911, 8, 18, 10, 1590, 14, 1038, 10, 5646, 10, 84, 430, 272, 6085, 14, 7682, 14, 5485, 63, 12000, 342, 199, 83, 5646, 14, 265, 63, 2489, 8, 873, 9, 199, 16557, 14, 265, 63, 2489, 8, 873, 9, 199, 199, 3958, 1219, 275, 4488, 14, 6402, 779, 16, 14, 24, 12, 378, 14, 18823, 12, 378, 14, 17, 12, 378, 14, 966, 566, 199, 3887, 275, 16005, 8, 3958, 1219, 12, 283, 9637, 297, 3164, 29, 1219, 2326, 12, 394, 1883, 2326, 534, 16, 14, 28947, 358, 199, 318, 5305, 8, 1430, 304, 272, 308, 5646, 14, 3958, 342, 272, 2937, 311, 14, 3958, 342, 199, 3887, 14, 265, 63, 11276, 8, 3958, 9, 199, 199, 14495, 275, 4488, 14, 6402, 779, 16, 14, 18823, 12, 378, 14, 21, 12, 378, 14, 1046, 12, 378, 14, 1046, 467, 3114, 6856, 29, 1219, 2326, 9, 199, 11905, 275, 13514, 24021, 8, 14495, 12, 661, 581, 297, 283, 6304, 297, 283, 7731, 659, 4702, 29, 16, 9, 199, 318, 3164, 1532, 8, 1302, 304, 272, 634, 14, 409, 63, 2326, 8, 1302, 9, 272, 6085, 14, 7682, 14, 5485, 63, 12000, 342, 199, 11905, 14, 265, 63, 11276, 8, 2326, 1532, 9, 199, 199, 6003, 14, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
jeremiah-c-leary/vhdl-style-guide
vsg/tests/generate/test_rule_001.py
1
1243
import os import unittest from vsg.rules import generate from vsg import vhdlFile from vsg.tests import utils sTestDir = os.path.dirname(__file__) lFile, eError =vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd')) dIndentMap = utils.read_indent_file() lExpected = [] lExpected.append('') utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected) class test_generate_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) self.oFile.set_indent_map(dIndentMap) def test_rule_001(self): oRule = generate.rule_001() self.assertTrue(oRule) self.assertEqual(oRule.name, 'generate') self.assertEqual(oRule.identifier, '001') lExpected = [20, 24, 28] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) def test_fix_rule_001(self): oRule = generate.rule_001() oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
gpl-3.0
[ 199, 646, 747, 199, 646, 2882, 199, 199, 504, 373, 1226, 14, 4423, 492, 3550, 199, 504, 373, 1226, 492, 373, 28738, 1173, 199, 504, 373, 1226, 14, 2219, 492, 3778, 199, 199, 26935, 3567, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 76, 1173, 12, 19424, 275, 20369, 5030, 1173, 14, 1208, 14, 739, 63, 20961, 12059, 8, 736, 14, 515, 14, 904, 8, 26935, 3567, 2584, 2200, 63, 4587, 63, 396, 63, 1210, 14, 20961, 1333, 199, 199, 68, 7583, 2956, 275, 3778, 14, 739, 63, 3724, 63, 493, 342, 199, 199, 76, 6964, 275, 942, 199, 76, 6964, 14, 740, 8355, 199, 1208, 14, 739, 63, 493, 8, 736, 14, 515, 14, 904, 8, 26935, 3567, 12, 283, 2200, 63, 4587, 63, 396, 63, 1210, 14, 5964, 14, 20961, 659, 634, 6964, 9, 421, 199, 533, 511, 63, 4208, 63, 2200, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 79, 1173, 275, 373, 28738, 1173, 14, 20369, 5030, 1173, 8, 76, 1173, 9, 267, 291, 14, 7702, 8, 6259, 9, 267, 291, 14, 79, 1173, 14, 409, 63, 3724, 63, 1130, 8, 68, 7583, 2956, 9, 339, 347, 511, 63, 2200, 63, 4587, 8, 277, 304, 267, 312, 5065, 275, 3550, 14, 2200, 63, 4587, 342, 267, 291, 14, 1815, 8, 79, 5065, 9, 267, 291, 14, 629, 8, 79, 5065, 14, 354, 12, 283, 4208, 358, 267, 291, 14, 629, 8, 79, 5065, 14, 5364, 12, 283, 4587, 358, 398, 634, 6964, 275, 359, 1165, 12, 5504, 12, 7294, 61, 398, 312, 5065, 14, 21184, 8, 277, 14, 79, 1173, 9, 267, 291, 14, 629, 8, 76, 6964, 12, 3778, 14, 5005, 63, 433, 10410, 63, 1278, 63, 504, 63, 433, 10410, 63, 785, 8, 79, 5065, 14, 433, 22938, 430, 339, 347, 511, 63, 970, 63, 2200, 63, 4587, 8, 277, 304, 267, 312, 5065, 275, 3550, 14, 2200, 63, 4587, 342, 398, 312, 5065, 14, 970, 8, 277, 14, 79, 1173, 9, 398, 634, 30141, 275, 291, 14, 79, 1173, 14, 362, 63, 1278, 342, 398, 291, 14, 629, 8, 76, 6964, 12, 634, 30141, 9, 398, 312, 5065, 14, 21184, 8, 277, 14, 79, 1173, 9, 267, 291, 14, 629, 8, 79, 5065, 14, 433, 22938, 12, 3073, 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 ]
[ 646, 747, 199, 646, 2882, 199, 199, 504, 373, 1226, 14, 4423, 492, 3550, 199, 504, 373, 1226, 492, 373, 28738, 1173, 199, 504, 373, 1226, 14, 2219, 492, 3778, 199, 199, 26935, 3567, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 76, 1173, 12, 19424, 275, 20369, 5030, 1173, 14, 1208, 14, 739, 63, 20961, 12059, 8, 736, 14, 515, 14, 904, 8, 26935, 3567, 2584, 2200, 63, 4587, 63, 396, 63, 1210, 14, 20961, 1333, 199, 199, 68, 7583, 2956, 275, 3778, 14, 739, 63, 3724, 63, 493, 342, 199, 199, 76, 6964, 275, 942, 199, 76, 6964, 14, 740, 8355, 199, 1208, 14, 739, 63, 493, 8, 736, 14, 515, 14, 904, 8, 26935, 3567, 12, 283, 2200, 63, 4587, 63, 396, 63, 1210, 14, 5964, 14, 20961, 659, 634, 6964, 9, 421, 199, 533, 511, 63, 4208, 63, 2200, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 79, 1173, 275, 373, 28738, 1173, 14, 20369, 5030, 1173, 8, 76, 1173, 9, 267, 291, 14, 7702, 8, 6259, 9, 267, 291, 14, 79, 1173, 14, 409, 63, 3724, 63, 1130, 8, 68, 7583, 2956, 9, 339, 347, 511, 63, 2200, 63, 4587, 8, 277, 304, 267, 312, 5065, 275, 3550, 14, 2200, 63, 4587, 342, 267, 291, 14, 1815, 8, 79, 5065, 9, 267, 291, 14, 629, 8, 79, 5065, 14, 354, 12, 283, 4208, 358, 267, 291, 14, 629, 8, 79, 5065, 14, 5364, 12, 283, 4587, 358, 398, 634, 6964, 275, 359, 1165, 12, 5504, 12, 7294, 61, 398, 312, 5065, 14, 21184, 8, 277, 14, 79, 1173, 9, 267, 291, 14, 629, 8, 76, 6964, 12, 3778, 14, 5005, 63, 433, 10410, 63, 1278, 63, 504, 63, 433, 10410, 63, 785, 8, 79, 5065, 14, 433, 22938, 430, 339, 347, 511, 63, 970, 63, 2200, 63, 4587, 8, 277, 304, 267, 312, 5065, 275, 3550, 14, 2200, 63, 4587, 342, 398, 312, 5065, 14, 970, 8, 277, 14, 79, 1173, 9, 398, 634, 30141, 275, 291, 14, 79, 1173, 14, 362, 63, 1278, 342, 398, 291, 14, 629, 8, 76, 6964, 12, 634, 30141, 9, 398, 312, 5065, 14, 21184, 8, 277, 14, 79, 1173, 9, 267, 291, 14, 629, 8, 79, 5065, 14, 433, 22938, 12, 3073, 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, 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,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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 ]
Ayub-Khan/edx-platform
common/lib/capa/capa/capa_problem.py
54
36321
# # File: capa/capa_problem.py # # Nomenclature: # # A capa Problem is a collection of text and capa Response questions. # Each Response may have one or more Input entry fields. # The capa problem may include a solution. # """ Main module which shows problems (of "capa" type). This is used by capa_module. """ from copy import deepcopy from datetime import datetime import logging import os.path import re from lxml import etree from pytz import UTC from xml.sax.saxutils import unescape from capa.correctmap import CorrectMap import capa.inputtypes as inputtypes import capa.customrender as customrender import capa.responsetypes as responsetypes from capa.util import contextualize_text, convert_files_to_filenames import capa.xqueue_interface as xqueue_interface from capa.safe_exec import safe_exec # extra things displayed after "show answers" is pressed solution_tags = ['solution'] # these get captured as student responses response_properties = ["codeparam", "responseparam", "answer", "openendedparam"] # special problem tags which should be turned into innocuous HTML html_transforms = { 'problem': {'tag': 'div'}, 'text': {'tag': 'span'}, 'math': {'tag': 'span'}, } # These should be removed from HTML output, including all subelements html_problem_semantics = [ "codeparam", "responseparam", "answer", "script", "hintgroup", "openendedparam", "openendedrubric", ] log = logging.getLogger(__name__) #----------------------------------------------------------------------------- # main class for this module class LoncapaSystem(object): """ An encapsulation of resources needed from the outside. These interfaces are collected here so that a caller of LoncapaProblem can provide these resources however make sense for their environment, and this code can remain independent. Attributes: i18n: an object implementing the `gettext.Translations` interface so that we can use `.ugettext` to localize strings. See :class:`ModuleSystem` for documentation of other attributes. """ def __init__( # pylint: disable=invalid-name self, ajax_url, anonymous_student_id, cache, can_execute_unsafe_code, get_python_lib_zip, DEBUG, # pylint: disable=invalid-name filestore, i18n, node_path, render_template, seed, # Why do we do this if we have self.seed? STATIC_URL, # pylint: disable=invalid-name xqueue, matlab_api_key=None ): self.ajax_url = ajax_url self.anonymous_student_id = anonymous_student_id self.cache = cache self.can_execute_unsafe_code = can_execute_unsafe_code self.get_python_lib_zip = get_python_lib_zip self.DEBUG = DEBUG # pylint: disable=invalid-name self.filestore = filestore self.i18n = i18n self.node_path = node_path self.render_template = render_template self.seed = seed # Why do we do this if we have self.seed? self.STATIC_URL = STATIC_URL # pylint: disable=invalid-name self.xqueue = xqueue self.matlab_api_key = matlab_api_key class LoncapaProblem(object): """ Main class for capa Problems. """ def __init__(self, problem_text, id, capa_system, capa_module, # pylint: disable=redefined-builtin state=None, seed=None): """ Initializes capa Problem. Arguments: problem_text (string): xml defining the problem. id (string): identifier for this problem, often a filename (no spaces). capa_system (LoncapaSystem): LoncapaSystem instance which provides OS, rendering, user context, and other resources. capa_module: instance needed to access runtime/logging state (dict): containing the following keys: - `seed` (int) random number generator seed - `student_answers` (dict) maps input id to the stored answer for that input - `correct_map` (CorrectMap) a map of each input to their 'correctness' - `done` (bool) indicates whether or not this problem is considered done - `input_state` (dict) maps input_id to a dictionary that holds the state for that input seed (int): random number generator seed. """ ## Initialize class variables from state self.do_reset() self.problem_id = id self.capa_system = capa_system self.capa_module = capa_module state = state or {} # Set seed according to the following priority: # 1. Contained in problem's state # 2. Passed into capa_problem via constructor self.seed = state.get('seed', seed) assert self.seed is not None, "Seed must be provided for LoncapaProblem." self.student_answers = state.get('student_answers', {}) if 'correct_map' in state: self.correct_map.set_dict(state['correct_map']) self.done = state.get('done', False) self.input_state = state.get('input_state', {}) # Convert startouttext and endouttext to proper <text></text> problem_text = re.sub(r"startouttext\s*/", "text", problem_text) problem_text = re.sub(r"endouttext\s*/", "/text", problem_text) self.problem_text = problem_text # parse problem XML file into an element tree self.tree = etree.XML(problem_text) self.make_xml_compatible(self.tree) # handle any <include file="foo"> tags self._process_includes() # construct script processor context (eg for customresponse problems) self.context = self._extract_context(self.tree) # Pre-parse the XML tree: modifies it to add ID's and perform some in-place # transformations. This also creates the dict (self.responders) of Response # instances for each question in the problem. The dict has keys = xml subtree of # Response, values = Response instance self._preprocess_problem(self.tree) if not self.student_answers: # True when student_answers is an empty dict self.set_initial_display() # dictionary of InputType objects associated with this problem # input_id string -> InputType object self.inputs = {} # Run response late_transforms last (see MultipleChoiceResponse) # Sort the responses to be in *_1 *_2 ... order. responses = self.responders.values() responses = sorted(responses, key=lambda resp: int(resp.id[resp.id.rindex('_') + 1:])) for response in responses: if hasattr(response, 'late_transforms'): response.late_transforms(self) self.extracted_tree = self._extract_html(self.tree) def make_xml_compatible(self, tree): """ Adjust tree xml in-place for compatibility before creating a problem from it. The idea here is to provide a central point for XML translation, for example, supporting an old XML format. At present, there just two translations. 1. <additional_answer> compatibility translation: old: <additional_answer>ANSWER</additional_answer> convert to new: <additional_answer answer="ANSWER">OPTIONAL-HINT</addional_answer> 2. <optioninput> compatibility translation: optioninput works like this internally: <optioninput options="('yellow','blue','green')" correct="blue" /> With extended hints there is a new <option> tag, like this <option correct="True">blue <optionhint>sky color</optionhint> </option> This translation takes in the new format and synthesizes the old option= attribute so all downstream logic works unchanged with the new <option> tag format. """ additionals = tree.xpath('//stringresponse/additional_answer') for additional in additionals: answer = additional.get('answer') text = additional.text if not answer and text: # trigger of old->new conversion additional.set('answer', text) additional.text = '' for optioninput in tree.xpath('//optioninput'): correct_option = None child_options = [] for option_element in optioninput.findall('./option'): option_name = option_element.text.strip() if option_element.get('correct').upper() == 'TRUE': correct_option = option_name child_options.append("'" + option_name + "'") if len(child_options) > 0: options_string = '(' + ','.join(child_options) + ')' optioninput.attrib.update({'options': options_string}) if correct_option: optioninput.attrib.update({'correct': correct_option}) def do_reset(self): """ Reset internal state to unfinished, with no answers """ self.student_answers = dict() self.correct_map = CorrectMap() self.done = False def set_initial_display(self): """ Set the student's answers to the responders' initial displays, if specified. """ initial_answers = dict() for responder in self.responders.values(): if hasattr(responder, 'get_initial_display'): initial_answers.update(responder.get_initial_display()) self.student_answers = initial_answers def __unicode__(self): return u"LoncapaProblem ({0})".format(self.problem_id) def get_state(self): """ Stored per-user session data neeeded to: 1) Recreate the problem 2) Populate any student answers. """ return {'seed': self.seed, 'student_answers': self.student_answers, 'correct_map': self.correct_map.get_dict(), 'input_state': self.input_state, 'done': self.done} def get_max_score(self): """ Return the maximum score for this problem. """ maxscore = 0 for responder in self.responders.values(): maxscore += responder.get_max_score() return maxscore def get_score(self): """ Compute score for this problem. The score is the number of points awarded. Returns a dictionary {'score': integer, from 0 to get_max_score(), 'total': get_max_score()}. """ correct = 0 for key in self.correct_map: try: correct += self.correct_map.get_npoints(key) except Exception: log.error('key=%s, correct_map = %s', key, self.correct_map) raise if (not self.student_answers) or len(self.student_answers) == 0: return {'score': 0, 'total': self.get_max_score()} else: return {'score': correct, 'total': self.get_max_score()} def update_score(self, score_msg, queuekey): """ Deliver grading response (e.g. from async code checking) to the specific ResponseType that requested grading Returns an updated CorrectMap """ cmap = CorrectMap() cmap.update(self.correct_map) for responder in self.responders.values(): if hasattr(responder, 'update_score'): # Each LoncapaResponse will update its specific entries in cmap # cmap is passed by reference responder.update_score(score_msg, cmap, queuekey) self.correct_map.set_dict(cmap.get_dict()) return cmap def ungraded_response(self, xqueue_msg, queuekey): """ Handle any responses from the xqueue that do not contain grades Will try to pass the queue message to all inputtypes that can handle ungraded responses Does not return any value """ # check against each inputtype for the_input in self.inputs.values(): # if the input type has an ungraded function, pass in the values if hasattr(the_input, 'ungraded_response'): the_input.ungraded_response(xqueue_msg, queuekey) def is_queued(self): """ Returns True if any part of the problem has been submitted to an external queue (e.g. for grading.) """ return any(self.correct_map.is_queued(answer_id) for answer_id in self.correct_map) def get_recentmost_queuetime(self): """ Returns a DateTime object that represents the timestamp of the most recent queueing request, or None if not queued """ if not self.is_queued(): return None # Get a list of timestamps of all queueing requests, then convert it to a DateTime object queuetime_strs = [ self.correct_map.get_queuetime_str(answer_id) for answer_id in self.correct_map if self.correct_map.is_queued(answer_id) ] queuetimes = [ datetime.strptime(qt_str, xqueue_interface.dateformat).replace(tzinfo=UTC) for qt_str in queuetime_strs ] return max(queuetimes) def grade_answers(self, answers): """ Grade student responses. Called by capa_module.check_problem. `answers` is a dict of all the entries from request.POST, but with the first part of each key removed (the string before the first "_"). Thus, for example, input_ID123 -> ID123, and input_fromjs_ID123 -> fromjs_ID123 Calls the Response for each question in this problem, to do the actual grading. """ # if answers include File objects, convert them to filenames. self.student_answers = convert_files_to_filenames(answers) return self._grade_answers(answers) def supports_rescoring(self): """ Checks that the current problem definition permits rescoring. More precisely, it checks that there are no response types in the current problem that are not fully supported (yet) for rescoring. This includes responsetypes for which the student's answer is not properly stored in state, i.e. file submissions. At present, we have no way to know if an existing response was actually a real answer or merely the filename of a file submitted as an answer. It turns out that because rescoring is a background task, limiting it to responsetypes that don't support file submissions also means that the responsetypes are synchronous. This is convenient as it permits rescoring to be complete when the rescoring call returns. """ return all('filesubmission' not in responder.allowed_inputfields for responder in self.responders.values()) def rescore_existing_answers(self): """ Rescore student responses. Called by capa_module.rescore_problem. """ return self._grade_answers(None) def _grade_answers(self, student_answers): """ Internal grading call used for checking new 'student_answers' and also rescoring existing student_answers. For new student_answers being graded, `student_answers` is a dict of all the entries from request.POST, but with the first part of each key removed (the string before the first "_"). Thus, for example, input_ID123 -> ID123, and input_fromjs_ID123 -> fromjs_ID123. For rescoring, `student_answers` is None. Calls the Response for each question in this problem, to do the actual grading. """ # old CorrectMap oldcmap = self.correct_map # start new with empty CorrectMap newcmap = CorrectMap() # Call each responsetype instance to do actual grading for responder in self.responders.values(): # File objects are passed only if responsetype explicitly allows # for file submissions. But we have no way of knowing if # student_answers contains a proper answer or the filename of # an earlier submission, so for now skip these entirely. # TODO: figure out where to get file submissions when rescoring. if 'filesubmission' in responder.allowed_inputfields and student_answers is None: _ = self.capa_system.i18n.ugettext raise Exception(_(u"Cannot rescore problems with possible file submissions")) # use 'student_answers' only if it is provided, and if it might contain a file # submission that would not exist in the persisted "student_answers". if 'filesubmission' in responder.allowed_inputfields and student_answers is not None: results = responder.evaluate_answers(student_answers, oldcmap) else: results = responder.evaluate_answers(self.student_answers, oldcmap) newcmap.update(results) self.correct_map = newcmap return newcmap def get_question_answers(self): """ Returns a dict of answer_ids to answer values. If we cannot generate an answer (this sometimes happens in customresponses), that answer_id is not included. Called by "show answers" button JSON request (see capa_module) """ # dict of (id, correct_answer) answer_map = dict() for response in self.responders.keys(): results = self.responder_answers[response] answer_map.update(results) # include solutions from <solution>...</solution> stanzas for entry in self.tree.xpath("//" + "|//".join(solution_tags)): answer = etree.tostring(entry) if answer: answer_map[entry.get('id')] = contextualize_text(answer, self.context) log.debug('answer_map = %s', answer_map) return answer_map def get_answer_ids(self): """ Return the IDs of all the responses -- these are the keys used for the dicts returned by grade_answers and get_question_answers. (Though get_question_answers may only return a subset of these. """ answer_ids = [] for response in self.responders.keys(): results = self.responder_answers[response] answer_ids.append(results.keys()) return answer_ids def do_targeted_feedback(self, tree): """ Implements targeted-feedback in-place on <multiplechoiceresponse> -- choice-level explanations shown to a student after submission. Does nothing if there is no targeted-feedback attribute. """ # Note that the modifications has been done, avoiding problems if called twice. if hasattr(self, 'has_targeted'): return self.has_targeted = True # pylint: disable=attribute-defined-outside-init for mult_choice_response in tree.xpath('//multiplechoiceresponse[@targeted-feedback]'): show_explanation = mult_choice_response.get('targeted-feedback') == 'alwaysShowCorrectChoiceExplanation' # Grab the first choicegroup (there should only be one within each <multiplechoiceresponse> tag) choicegroup = mult_choice_response.xpath('./choicegroup[@type="MultipleChoice"]')[0] choices_list = list(choicegroup.iter('choice')) # Find the student answer key that matches our <choicegroup> id student_answer = self.student_answers.get(choicegroup.get('id')) expl_id_for_student_answer = None # Keep track of the explanation-id that corresponds to the student's answer # Also, keep track of the solution-id solution_id = None for choice in choices_list: if choice.get('name') == student_answer: expl_id_for_student_answer = choice.get('explanation-id') if choice.get('correct') == 'true': solution_id = choice.get('explanation-id') # Filter out targetedfeedback that doesn't correspond to the answer the student selected # Note: following-sibling will grab all following siblings, so we just want the first in the list targetedfeedbackset = mult_choice_response.xpath('./following-sibling::targetedfeedbackset') if len(targetedfeedbackset) != 0: targetedfeedbackset = targetedfeedbackset[0] targetedfeedbacks = targetedfeedbackset.xpath('./targetedfeedback') for targetedfeedback in targetedfeedbacks: # Don't show targeted feedback if the student hasn't answer the problem # or if the target feedback doesn't match the student's (incorrect) answer if not self.done or targetedfeedback.get('explanation-id') != expl_id_for_student_answer: targetedfeedbackset.remove(targetedfeedback) # Do not displace the solution under these circumstances if not show_explanation or not self.done: continue # The next element should either be <solution> or <solutionset> next_element = targetedfeedbackset.getnext() parent_element = tree solution_element = None if next_element is not None and next_element.tag == 'solution': solution_element = next_element elif next_element is not None and next_element.tag == 'solutionset': solutions = next_element.xpath('./solution') for solution in solutions: if solution.get('explanation-id') == solution_id: parent_element = next_element solution_element = solution # If could not find the solution element, then skip the remaining steps below if solution_element is None: continue # Change our correct-choice explanation from a "solution explanation" to within # the set of targeted feedback, which means the explanation will render on the page # without the student clicking "Show Answer" or seeing a checkmark next to the correct choice parent_element.remove(solution_element) # Add our solution instead to the targetedfeedbackset and change its tag name solution_element.tag = 'targetedfeedback' targetedfeedbackset.append(solution_element) def get_html(self): """ Main method called externally to get the HTML to be rendered for this capa Problem. """ self.do_targeted_feedback(self.tree) html = contextualize_text(etree.tostring(self._extract_html(self.tree)), self.context) return html def handle_input_ajax(self, data): """ InputTypes can support specialized AJAX calls. Find the correct input and pass along the correct data Also, parse out the dispatch from the get so that it can be passed onto the input type nicely """ # pull out the id input_id = data['input_id'] if self.inputs[input_id]: dispatch = data['dispatch'] return self.inputs[input_id].handle_ajax(dispatch, data) else: log.warning("Could not find matching input for id: %s", input_id) return {} # ======= Private Methods Below ======== def _process_includes(self): """ Handle any <include file="foo"> tags by reading in the specified file and inserting it into our XML tree. Fail gracefully if debugging. """ includes = self.tree.findall('.//include') for inc in includes: filename = inc.get('file') if filename is not None: try: # open using LoncapaSystem OSFS filestore ifp = self.capa_system.filestore.open(filename) except Exception as err: log.warning( 'Error %s in problem xml include: %s', err, etree.tostring(inc, pretty_print=True) ) log.warning( 'Cannot find file %s in %s', filename, self.capa_system.filestore ) # if debugging, don't fail - just log error # TODO (vshnayder): need real error handling, display to users if not self.capa_system.DEBUG: raise else: continue try: # read in and convert to XML incxml = etree.XML(ifp.read()) except Exception as err: log.warning( 'Error %s in problem xml include: %s', err, etree.tostring(inc, pretty_print=True) ) log.warning('Cannot parse XML in %s', (filename)) # if debugging, don't fail - just log error # TODO (vshnayder): same as above if not self.capa_system.DEBUG: raise else: continue # insert new XML into tree in place of include parent = inc.getparent() parent.insert(parent.index(inc), incxml) parent.remove(inc) log.debug('Included %s into %s', filename, self.problem_id) def _extract_system_path(self, script): """ Extracts and normalizes additional paths for code execution. For now, there's a default path of data/course/code; this may be removed at some point. script : ?? (TODO) """ DEFAULT_PATH = ['code'] # Separate paths by :, like the system path. raw_path = script.get('system_path', '').split(":") + DEFAULT_PATH # find additional comma-separated modules search path path = [] for dir in raw_path: if not dir: continue # path is an absolute path or a path relative to the data dir dir = os.path.join(self.capa_system.filestore.root_path, dir) # Check that we are within the filestore tree. reldir = os.path.relpath(dir, self.capa_system.filestore.root_path) if ".." in reldir: log.warning("Ignoring Python directory outside of course: %r", dir) continue abs_dir = os.path.normpath(dir) path.append(abs_dir) return path def _extract_context(self, tree): """ Extract content of <script>...</script> from the problem.xml file, and exec it in the context of this problem. Provides ability to randomize problems, and also set variables for problem answer checking. Problem XML goes to Python execution context. Runs everything in script tags. """ context = {} context['seed'] = self.seed context['anonymous_student_id'] = self.capa_system.anonymous_student_id all_code = '' python_path = [] for script in tree.findall('.//script'): stype = script.get('type') if stype: if 'javascript' in stype: continue # skip javascript if 'perl' in stype: continue # skip perl # TODO: evaluate only python for d in self._extract_system_path(script): if d not in python_path and os.path.exists(d): python_path.append(d) XMLESC = {"&apos;": "'", "&quot;": '"'} code = unescape(script.text, XMLESC) all_code += code extra_files = [] if all_code: # An asset named python_lib.zip can be imported by Python code. zip_lib = self.capa_system.get_python_lib_zip() if zip_lib is not None: extra_files.append(("python_lib.zip", zip_lib)) python_path.append("python_lib.zip") try: safe_exec( all_code, context, random_seed=self.seed, python_path=python_path, extra_files=extra_files, cache=self.capa_system.cache, slug=self.problem_id, unsafely=self.capa_system.can_execute_unsafe_code(), ) except Exception as err: log.exception("Error while execing script code: " + all_code) msg = "Error while executing script code: %s" % str(err).replace('<', '&lt;') raise responsetypes.LoncapaProblemError(msg) # Store code source in context, along with the Python path needed to run it correctly. context['script_code'] = all_code context['python_path'] = python_path context['extra_files'] = extra_files or None return context def _extract_html(self, problemtree): # private """ Main (private) function which converts Problem XML tree to HTML. Calls itself recursively. Returns Element tree of XHTML representation of problemtree. Calls render_html of Response instances to render responses into XHTML. Used by get_html. """ if not isinstance(problemtree.tag, basestring): # Comment and ProcessingInstruction nodes are not Elements, # and we're ok leaving those behind. # BTW: etree gives us no good way to distinguish these things # other than to examine .tag to see if it's a string. :( return if (problemtree.tag == 'script' and problemtree.get('type') and 'javascript' in problemtree.get('type')): # leave javascript intact. return deepcopy(problemtree) if problemtree.tag in html_problem_semantics: return problemid = problemtree.get('id') # my ID if problemtree.tag in inputtypes.registry.registered_tags(): # If this is an inputtype subtree, let it render itself. status = "unsubmitted" msg = '' hint = '' hintmode = None input_id = problemtree.get('id') answervariable = None if problemid in self.correct_map: pid = input_id status = self.correct_map.get_correctness(pid) msg = self.correct_map.get_msg(pid) hint = self.correct_map.get_hint(pid) hintmode = self.correct_map.get_hintmode(pid) answervariable = self.correct_map.get_property(pid, 'answervariable') value = "" if self.student_answers and problemid in self.student_answers: value = self.student_answers[problemid] if input_id not in self.input_state: self.input_state[input_id] = {} # do the rendering state = { 'value': value, 'status': status, 'id': input_id, 'input_state': self.input_state[input_id], 'answervariable': answervariable, 'feedback': { 'message': msg, 'hint': hint, 'hintmode': hintmode, } } input_type_cls = inputtypes.registry.get_class_for_tag(problemtree.tag) # save the input type so that we can make ajax calls on it if we need to self.inputs[input_id] = input_type_cls(self.capa_system, problemtree, state) return self.inputs[input_id].get_html() # let each Response render itself if problemtree in self.responders: overall_msg = self.correct_map.get_overall_message() return self.responders[problemtree].render_html( self._extract_html, response_msg=overall_msg ) # let each custom renderer render itself: if problemtree.tag in customrender.registry.registered_tags(): renderer_class = customrender.registry.get_class_for_tag(problemtree.tag) renderer = renderer_class(self.capa_system, problemtree) return renderer.get_html() # otherwise, render children recursively, and copy over attributes tree = etree.Element(problemtree.tag) for item in problemtree: item_xhtml = self._extract_html(item) if item_xhtml is not None: tree.append(item_xhtml) if tree.tag in html_transforms: tree.tag = html_transforms[problemtree.tag]['tag'] else: # copy attributes over if not innocufying for (key, value) in problemtree.items(): tree.set(key, value) tree.text = problemtree.text tree.tail = problemtree.tail return tree def _preprocess_problem(self, tree): # private """ Assign IDs to all the responses Assign sub-IDs to all entries (textline, schematic, etc.) Annoted correctness and value In-place transformation Also create capa Response instances for each responsetype and save as self.responders Obtain all responder answers and save as self.responder_answers dict (key = response) """ response_id = 1 self.responders = {} for response in tree.xpath('//' + "|//".join(responsetypes.registry.registered_tags())): response_id_str = self.problem_id + "_" + str(response_id) # create and save ID for this response response.set('id', response_id_str) response_id += 1 answer_id = 1 input_tags = inputtypes.registry.registered_tags() inputfields = tree.xpath( "|".join(['//' + response.tag + '[@id=$id]//' + x for x in input_tags + solution_tags]), id=response_id_str ) # assign one answer_id for each input type or solution type for entry in inputfields: entry.attrib['response_id'] = str(response_id) entry.attrib['answer_id'] = str(answer_id) entry.attrib['id'] = "%s_%i_%i" % (self.problem_id, response_id, answer_id) answer_id = answer_id + 1 # instantiate capa Response responsetype_cls = responsetypes.registry.get_class_for_tag(response.tag) responder = responsetype_cls(response, inputfields, self.context, self.capa_system, self.capa_module) # save in list in self self.responders[response] = responder # get responder answers (do this only once, since there may be a performance cost, # eg with externalresponse) self.responder_answers = {} for response in self.responders.keys(): try: self.responder_answers[response] = self.responders[response].get_answers() except: log.debug('responder %s failed to properly return get_answers()', self.responders[response]) # FIXME raise # <solution>...</solution> may not be associated with any specific response; give # IDs for those separately # TODO: We should make the namespaces consistent and unique (e.g. %s_problem_%i). solution_id = 1 for solution in tree.findall('.//solution'): solution.attrib['id'] = "%s_solution_%i" % (self.problem_id, solution_id) solution_id += 1
agpl-3.0
[ 3, 199, 3, 3814, 26, 257, 28068, 15, 18182, 63, 6462, 14, 647, 199, 3, 199, 3, 653, 1377, 78, 429, 1463, 26, 199, 3, 199, 3, 437, 28068, 20980, 365, 282, 3245, 402, 1318, 436, 28068, 7232, 23071, 14, 199, 3, 7048, 7232, 1443, 1172, 1373, 503, 1655, 6924, 2397, 1504, 14, 199, 3, 710, 28068, 5160, 1443, 2387, 282, 8744, 14, 199, 3, 199, 624, 199, 6756, 859, 1314, 13703, 8826, 334, 1618, 298, 18182, 2, 730, 680, 199, 199, 2765, 365, 1202, 701, 28068, 63, 578, 14, 199, 624, 199, 199, 504, 1331, 492, 14800, 199, 504, 2197, 492, 2197, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 504, 14490, 492, 7559, 199, 504, 15444, 492, 12174, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 22221, 199, 199, 504, 28068, 14, 4525, 1130, 492, 31057, 2956, 199, 646, 28068, 14, 1210, 1313, 465, 1324, 1313, 199, 646, 28068, 14, 4229, 3352, 465, 3537, 3352, 199, 646, 28068, 14, 1310, 1313, 465, 1177, 1313, 199, 504, 28068, 14, 1974, 492, 1067, 1061, 794, 63, 505, 12, 3957, 63, 1725, 63, 475, 63, 10309, 199, 646, 28068, 14, 88, 1825, 63, 3266, 465, 671, 1825, 63, 3266, 199, 504, 28068, 14, 3489, 63, 1628, 492, 5048, 63, 1628, 421, 199, 3, 2402, 7645, 9080, 2410, 298, 2384, 17133, 2, 365, 25167, 199, 14458, 63, 2969, 275, 788, 14458, 418, 199, 199, 3, 3520, 664, 17487, 465, 6474, 9320, 199, 1310, 63, 3282, 275, 2097, 600, 635, 401, 298, 1310, 635, 401, 298, 5934, 401, 298, 1490, 8960, 635, 937, 199, 199, 3, 4539, 5160, 3762, 1314, 1077, 506, 19136, 1901, 315, 23507, 7514, 4163, 199, 1360, 63, 15133, 275, 469, 272, 283, 6462, 356, 791, 1450, 356, 283, 3015, 2267, 272, 283, 505, 356, 791, 1450, 356, 283, 3751, 2267, 272, 283, 3442, 356, 791, 1450, 356, 283, 3751, 2267, 199, 93, 199, 199, 3, 5723, 1077, 506, 4829, 687, 4163, 1072, 12, 5893, 1006, 1007, 5527, 199, 1360, 63, 6462, 63, 261, 1237, 7769, 275, 359, 272, 298, 600, 635, 401, 272, 298, 1310, 635, 401, 272, 298, 5934, 401, 272, 298, 1579, 401, 272, 298, 6479, 923, 401, 272, 298, 1490, 8960, 635, 401, 272, 298, 1490, 8960, 21586, 401, 199, 61, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18045, 199, 3, 2446, 1021, 367, 642, 859, 421, 199, 533, 491, 265, 18182, 3989, 8, 785, 304, 272, 408, 272, 1626, 22667, 5332, 402, 5944, 4346, 687, 314, 9682, 14, 339, 5723, 8386, 787, 13736, 2348, 880, 626, 282, 8025, 402, 491, 265, 18182, 16467, 272, 883, 5647, 3520, 5944, 13432, 1852, 12249, 367, 3932, 3734, 12, 436, 272, 642, 1233, 883, 5706, 12717, 14, 339, 9382, 26, 267, 284, 1085, 78, 26, 376, 909, 18234, 314, 658, 5152, 14, 3188, 6011, 64, 3217, 880, 288, 626, 781, 883, 675, 19853, 23499, 64, 370, 2257, 794, 3326, 14, 339, 1666, 520, 533, 1705, 2377, 3989, 64, 367, 3794, 402, 1163, 3004, 14, 339, 408, 272, 347, 636, 826, 721, 2476, 755, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 12, 267, 25930, 63, 633, 12, 267, 16535, 63, 5500, 63, 344, 12, 267, 2581, 12, 267, 883, 63, 2526, 63, 14242, 63, 600, 12, 267, 664, 63, 1548, 63, 773, 63, 3065, 12, 267, 10990, 12, 2476, 3515, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 570, 1617, 12, 267, 284, 1085, 78, 12, 267, 1031, 63, 515, 12, 267, 3795, 63, 1160, 12, 267, 6347, 12, 420, 327, 6827, 886, 781, 886, 642, 340, 781, 1172, 291, 14, 5176, 31, 267, 27815, 63, 2632, 12, 32542, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 671, 1825, 12, 267, 2530, 5561, 63, 1246, 63, 498, 29, 403, 272, 3461, 267, 291, 14, 12774, 63, 633, 275, 25930, 63, 633, 267, 291, 14, 12628, 63, 5500, 63, 344, 275, 16535, 63, 5500, 63, 344, 267, 291, 14, 1637, 275, 2581, 267, 291, 14, 2425, 63, 2526, 63, 14242, 63, 600, 275, 883, 63, 2526, 63, 14242, 63, 600, 267, 291, 14, 362, 63, 1548, 63, 773, 63, 3065, 275, 664, 63, 1548, 63, 773, 63, 3065, 267, 291, 14, 5287, 275, 10990, 19242, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 14, 493, 1617, 275, 570, 1617, 267, 291, 14, 73, 1085, 78, 275, 284, 1085, 78, 267, 291, 14, 932, 63, 515, 275, 1031, 63, 515, 267, 291, 14, 3352, 63, 1160, 275, 3795, 63, 1160, 267, 291, 14, 5176, 275, 6347, 9326, 327, 6827, 886, 781, 886, 642, 340, 781, 1172, 291, 14, 5176, 31, 267, 291, 14, 10449, 63, 2632, 275, 27815, 63, 2632, 8540, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 14, 88, 1825, 275, 671, 1825, 267, 291, 14, 569, 5561, 63, 1246, 63, 498, 275, 2530, 5561, 63, 1246, 63, 498, 421, 199, 533, 491, 265, 18182, 16467, 8, 785, 304, 272, 408, 272, 11298, 1021, 367, 28068, 2165, 7561, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5160, 63, 505, 12, 1305, 12, 28068, 63, 2253, 12, 28068, 63, 578, 12, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 326, 1174, 29, 403, 12, 6347, 29, 403, 304, 267, 408, 267, 6026, 6491, 28068, 20980, 14, 398, 7628, 26, 953, 5160, 63, 505, 334, 875, 304, 2748, 12669, 314, 5160, 14, 288, 1305, 334, 875, 304, 5148, 367, 642, 5160, 12, 14115, 282, 1788, 334, 889, 7883, 680, 288, 28068, 63, 2253, 334, 31253, 18182, 3989, 304, 491, 265, 18182, 3989, 1256, 1314, 6571, 4403, 12, 355, 14066, 12, 922, 1067, 12, 436, 1163, 5944, 14, 288, 28068, 63, 578, 26, 1256, 4346, 370, 2879, 8836, 15, 4806, 288, 1174, 334, 807, 304, 3035, 314, 2569, 2883, 26, 355, 446, 658, 5176, 64, 334, 442, 9, 2196, 1329, 4306, 6347, 355, 446, 658, 5500, 63, 13379, 64, 334, 807, 9, 9033, 1324, 1305, 370, 314, 5489, 6385, 367, 626, 1324, 355, 446, 658, 4525, 63, 1130, 64, 334, 19993, 2956, 9, 282, 2341, 402, 1924, 1324, 370, 3932, 283, 4525, 4171, 7 ]
[ 199, 3, 3814, 26, 257, 28068, 15, 18182, 63, 6462, 14, 647, 199, 3, 199, 3, 653, 1377, 78, 429, 1463, 26, 199, 3, 199, 3, 437, 28068, 20980, 365, 282, 3245, 402, 1318, 436, 28068, 7232, 23071, 14, 199, 3, 7048, 7232, 1443, 1172, 1373, 503, 1655, 6924, 2397, 1504, 14, 199, 3, 710, 28068, 5160, 1443, 2387, 282, 8744, 14, 199, 3, 199, 624, 199, 6756, 859, 1314, 13703, 8826, 334, 1618, 298, 18182, 2, 730, 680, 199, 199, 2765, 365, 1202, 701, 28068, 63, 578, 14, 199, 624, 199, 199, 504, 1331, 492, 14800, 199, 504, 2197, 492, 2197, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 646, 295, 199, 199, 504, 14490, 492, 7559, 199, 504, 15444, 492, 12174, 199, 504, 2748, 14, 14338, 14, 14338, 1208, 492, 22221, 199, 199, 504, 28068, 14, 4525, 1130, 492, 31057, 2956, 199, 646, 28068, 14, 1210, 1313, 465, 1324, 1313, 199, 646, 28068, 14, 4229, 3352, 465, 3537, 3352, 199, 646, 28068, 14, 1310, 1313, 465, 1177, 1313, 199, 504, 28068, 14, 1974, 492, 1067, 1061, 794, 63, 505, 12, 3957, 63, 1725, 63, 475, 63, 10309, 199, 646, 28068, 14, 88, 1825, 63, 3266, 465, 671, 1825, 63, 3266, 199, 504, 28068, 14, 3489, 63, 1628, 492, 5048, 63, 1628, 421, 199, 3, 2402, 7645, 9080, 2410, 298, 2384, 17133, 2, 365, 25167, 199, 14458, 63, 2969, 275, 788, 14458, 418, 199, 199, 3, 3520, 664, 17487, 465, 6474, 9320, 199, 1310, 63, 3282, 275, 2097, 600, 635, 401, 298, 1310, 635, 401, 298, 5934, 401, 298, 1490, 8960, 635, 937, 199, 199, 3, 4539, 5160, 3762, 1314, 1077, 506, 19136, 1901, 315, 23507, 7514, 4163, 199, 1360, 63, 15133, 275, 469, 272, 283, 6462, 356, 791, 1450, 356, 283, 3015, 2267, 272, 283, 505, 356, 791, 1450, 356, 283, 3751, 2267, 272, 283, 3442, 356, 791, 1450, 356, 283, 3751, 2267, 199, 93, 199, 199, 3, 5723, 1077, 506, 4829, 687, 4163, 1072, 12, 5893, 1006, 1007, 5527, 199, 1360, 63, 6462, 63, 261, 1237, 7769, 275, 359, 272, 298, 600, 635, 401, 272, 298, 1310, 635, 401, 272, 298, 5934, 401, 272, 298, 1579, 401, 272, 298, 6479, 923, 401, 272, 298, 1490, 8960, 635, 401, 272, 298, 1490, 8960, 21586, 401, 199, 61, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18045, 199, 3, 2446, 1021, 367, 642, 859, 421, 199, 533, 491, 265, 18182, 3989, 8, 785, 304, 272, 408, 272, 1626, 22667, 5332, 402, 5944, 4346, 687, 314, 9682, 14, 339, 5723, 8386, 787, 13736, 2348, 880, 626, 282, 8025, 402, 491, 265, 18182, 16467, 272, 883, 5647, 3520, 5944, 13432, 1852, 12249, 367, 3932, 3734, 12, 436, 272, 642, 1233, 883, 5706, 12717, 14, 339, 9382, 26, 267, 284, 1085, 78, 26, 376, 909, 18234, 314, 658, 5152, 14, 3188, 6011, 64, 3217, 880, 288, 626, 781, 883, 675, 19853, 23499, 64, 370, 2257, 794, 3326, 14, 339, 1666, 520, 533, 1705, 2377, 3989, 64, 367, 3794, 402, 1163, 3004, 14, 339, 408, 272, 347, 636, 826, 721, 2476, 755, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 12, 267, 25930, 63, 633, 12, 267, 16535, 63, 5500, 63, 344, 12, 267, 2581, 12, 267, 883, 63, 2526, 63, 14242, 63, 600, 12, 267, 664, 63, 1548, 63, 773, 63, 3065, 12, 267, 10990, 12, 2476, 3515, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 570, 1617, 12, 267, 284, 1085, 78, 12, 267, 1031, 63, 515, 12, 267, 3795, 63, 1160, 12, 267, 6347, 12, 420, 327, 6827, 886, 781, 886, 642, 340, 781, 1172, 291, 14, 5176, 31, 267, 27815, 63, 2632, 12, 32542, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 671, 1825, 12, 267, 2530, 5561, 63, 1246, 63, 498, 29, 403, 272, 3461, 267, 291, 14, 12774, 63, 633, 275, 25930, 63, 633, 267, 291, 14, 12628, 63, 5500, 63, 344, 275, 16535, 63, 5500, 63, 344, 267, 291, 14, 1637, 275, 2581, 267, 291, 14, 2425, 63, 2526, 63, 14242, 63, 600, 275, 883, 63, 2526, 63, 14242, 63, 600, 267, 291, 14, 362, 63, 1548, 63, 773, 63, 3065, 275, 664, 63, 1548, 63, 773, 63, 3065, 267, 291, 14, 5287, 275, 10990, 19242, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 14, 493, 1617, 275, 570, 1617, 267, 291, 14, 73, 1085, 78, 275, 284, 1085, 78, 267, 291, 14, 932, 63, 515, 275, 1031, 63, 515, 267, 291, 14, 3352, 63, 1160, 275, 3795, 63, 1160, 267, 291, 14, 5176, 275, 6347, 9326, 327, 6827, 886, 781, 886, 642, 340, 781, 1172, 291, 14, 5176, 31, 267, 291, 14, 10449, 63, 2632, 275, 27815, 63, 2632, 8540, 327, 4287, 26, 3507, 29, 3197, 13, 354, 267, 291, 14, 88, 1825, 275, 671, 1825, 267, 291, 14, 569, 5561, 63, 1246, 63, 498, 275, 2530, 5561, 63, 1246, 63, 498, 421, 199, 533, 491, 265, 18182, 16467, 8, 785, 304, 272, 408, 272, 11298, 1021, 367, 28068, 2165, 7561, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5160, 63, 505, 12, 1305, 12, 28068, 63, 2253, 12, 28068, 63, 578, 12, 221, 327, 4287, 26, 3507, 29, 27913, 13, 5351, 326, 1174, 29, 403, 12, 6347, 29, 403, 304, 267, 408, 267, 6026, 6491, 28068, 20980, 14, 398, 7628, 26, 953, 5160, 63, 505, 334, 875, 304, 2748, 12669, 314, 5160, 14, 288, 1305, 334, 875, 304, 5148, 367, 642, 5160, 12, 14115, 282, 1788, 334, 889, 7883, 680, 288, 28068, 63, 2253, 334, 31253, 18182, 3989, 304, 491, 265, 18182, 3989, 1256, 1314, 6571, 4403, 12, 355, 14066, 12, 922, 1067, 12, 436, 1163, 5944, 14, 288, 28068, 63, 578, 26, 1256, 4346, 370, 2879, 8836, 15, 4806, 288, 1174, 334, 807, 304, 3035, 314, 2569, 2883, 26, 355, 446, 658, 5176, 64, 334, 442, 9, 2196, 1329, 4306, 6347, 355, 446, 658, 5500, 63, 13379, 64, 334, 807, 9, 9033, 1324, 1305, 370, 314, 5489, 6385, 367, 626, 1324, 355, 446, 658, 4525, 63, 1130, 64, 334, 19993, 2956, 9, 282, 2341, 402, 1924, 1324, 370, 3932, 283, 4525, 4171, 7, 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,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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 ]
SimonSapin/servo
tests/wpt/web-platform-tests/tools/third_party/pytest/src/_pytest/pastebin.py
34
3631
""" submit failure or test session information to a pastebin service. """ from __future__ import absolute_import, division, print_function import pytest import six import sys import tempfile def pytest_addoption(parser): group = parser.getgroup("terminal reporting") group._addoption( "--pastebin", metavar="mode", action="store", dest="pastebin", default=None, choices=["failed", "all"], help="send failed|all info to bpaste.net pastebin service.", ) @pytest.hookimpl(trylast=True) def pytest_configure(config): if config.option.pastebin == "all": tr = config.pluginmanager.getplugin("terminalreporter") # if no terminal reporter plugin is present, nothing we can do here; # this can happen when this function executes in a slave node # when using pytest-xdist, for example if tr is not None: # pastebin file will be utf-8 encoded binary file config._pastebinfile = tempfile.TemporaryFile("w+b") oldwrite = tr._tw.write def tee_write(s, **kwargs): oldwrite(s, **kwargs) if isinstance(s, six.text_type): s = s.encode("utf-8") config._pastebinfile.write(s) tr._tw.write = tee_write def pytest_unconfigure(config): if hasattr(config, "_pastebinfile"): # get terminal contents and delete file config._pastebinfile.seek(0) sessionlog = config._pastebinfile.read() config._pastebinfile.close() del config._pastebinfile # undo our patching in the terminal reporter tr = config.pluginmanager.getplugin("terminalreporter") del tr._tw.__dict__["write"] # write summary tr.write_sep("=", "Sending information to Paste Service") pastebinurl = create_new_paste(sessionlog) tr.write_line("pastebin session-log: %s\n" % pastebinurl) def create_new_paste(contents): """ Creates a new paste using bpaste.net service. :contents: paste contents as utf-8 encoded bytes :returns: url to the pasted contents """ import re if sys.version_info < (3, 0): from urllib import urlopen, urlencode else: from urllib.request import urlopen from urllib.parse import urlencode params = { "code": contents, "lexer": "python3" if sys.version_info[0] == 3 else "python", "expiry": "1week", } url = "https://bpaste.net" response = urlopen(url, data=urlencode(params).encode("ascii")).read() m = re.search(r'href="/raw/(\w+)"', response.decode("utf-8")) if m: return "%s/show/%s" % (url, m.group(1)) else: return "bad response: " + response def pytest_terminal_summary(terminalreporter): import _pytest.config if terminalreporter.config.option.pastebin != "failed": return tr = terminalreporter if "failed" in tr.stats: terminalreporter.write_sep("=", "Sending information to Paste Service") for rep in terminalreporter.stats.get("failed"): try: msg = rep.longrepr.reprtraceback.reprentries[-1].reprfileloc except AttributeError: msg = tr._getfailureheadline(rep) tw = _pytest.config.create_terminal_writer( terminalreporter.config, stringio=True ) rep.toterminal(tw) s = tw.stringio.getvalue() assert len(s) pastebinurl = create_new_paste(s) tr.write_line("%s --> %s" % (msg, pastebinurl))
mpl-2.0
[ 624, 11482, 5988, 503, 511, 2351, 2556, 370, 282, 20901, 1393, 2435, 14, 408, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 646, 3816, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1572, 275, 1798, 14, 362, 923, 480, 12010, 17290, 531, 272, 1572, 423, 525, 1422, 8, 267, 4320, 16586, 1393, 401, 267, 8214, 628, 632, 401, 267, 1595, 628, 1617, 401, 267, 2053, 628, 16586, 1393, 401, 267, 849, 29, 403, 12, 267, 3415, 6270, 4892, 401, 298, 452, 2255, 267, 1720, 628, 2254, 3405, 92, 452, 2256, 370, 13292, 9209, 14, 846, 20901, 1393, 2435, 4765, 272, 776, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2019, 29, 549, 9, 199, 318, 4613, 63, 6472, 8, 888, 304, 272, 340, 1101, 14, 1422, 14, 16586, 1393, 508, 298, 452, 582, 267, 5651, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12010, 12222, 531, 267, 327, 340, 949, 11167, 17663, 3589, 365, 3451, 12, 6548, 781, 883, 886, 2348, 27, 267, 327, 642, 883, 5992, 1380, 642, 805, 24956, 315, 282, 15494, 1031, 267, 327, 1380, 1808, 4613, 13, 88, 2686, 12, 367, 2893, 267, 340, 5651, 365, 440, 488, 26, 288, 327, 20901, 1393, 570, 911, 506, 2774, 13, 24, 5737, 3366, 570, 288, 1101, 423, 16586, 1393, 493, 275, 5549, 14, 13271, 480, 87, 11, 66, 531, 288, 2269, 952, 275, 5651, 423, 8122, 14, 952, 953, 347, 1565, 69, 63, 952, 8, 83, 12, 1011, 958, 304, 355, 2269, 952, 8, 83, 12, 1011, 958, 9, 355, 340, 1228, 8, 83, 12, 3816, 14, 505, 63, 466, 304, 490, 308, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 355, 1101, 423, 16586, 1393, 493, 14, 952, 8, 83, 9, 953, 5651, 423, 8122, 14, 952, 275, 1565, 69, 63, 952, 421, 199, 318, 4613, 63, 324, 6472, 8, 888, 304, 272, 340, 2688, 8, 888, 12, 2668, 16586, 1393, 493, 2349, 267, 327, 664, 11167, 4072, 436, 3145, 570, 267, 1101, 423, 16586, 1393, 493, 14, 5507, 8, 16, 9, 267, 2351, 793, 275, 1101, 423, 16586, 1393, 493, 14, 739, 342, 267, 1101, 423, 16586, 1393, 493, 14, 1600, 342, 267, 2150, 1101, 423, 16586, 1393, 493, 267, 327, 18172, 4154, 3371, 316, 315, 314, 11167, 17663, 267, 5651, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12010, 12222, 531, 267, 2150, 5651, 423, 8122, 855, 807, 363, 905, 952, 937, 267, 327, 2218, 6212, 267, 5651, 14, 952, 63, 4127, 480, 11107, 298, 27219, 2556, 370, 510, 9209, 7591, 531, 267, 20901, 1393, 633, 275, 1218, 63, 1222, 63, 16586, 8, 1730, 793, 9, 267, 5651, 14, 952, 63, 604, 480, 16586, 1393, 2351, 13, 793, 26, 450, 83, 60, 78, 2, 450, 20901, 1393, 633, 9, 421, 199, 318, 1218, 63, 1222, 63, 16586, 8, 4407, 304, 272, 408, 272, 10560, 282, 892, 20901, 1808, 13292, 9209, 14, 846, 2435, 14, 339, 520, 4407, 26, 20901, 4072, 465, 2774, 13, 24, 5737, 2783, 272, 520, 5808, 26, 1166, 370, 314, 19099, 471, 4072, 272, 408, 272, 492, 295, 339, 340, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 378, 304, 267, 687, 4011, 492, 18279, 12, 16511, 272, 587, 26, 267, 687, 4011, 14, 1069, 492, 18279, 267, 687, 4011, 14, 1122, 492, 16511, 339, 1862, 275, 469, 267, 298, 600, 582, 4072, 12, 267, 298, 11729, 582, 298, 1548, 19, 2, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 587, 298, 1548, 401, 267, 298, 16844, 582, 298, 17, 6419, 401, 272, 789, 272, 1166, 275, 298, 2859, 921, 10913, 9209, 14, 846, 2, 272, 1177, 275, 18279, 8, 633, 12, 666, 29, 10738, 8, 1162, 680, 2143, 480, 4371, 21688, 739, 342, 272, 333, 275, 295, 14, 1733, 8, 82, 7, 6399, 9555, 1773, 15, 2961, 87, 20415, 297, 1177, 14, 2708, 480, 1624, 13, 24, 2237, 272, 340, 333, 26, 267, 372, 2071, 83, 15, 2384, 3149, 83, 2, 450, 334, 633, 12, 333, 14, 923, 8, 17, 430, 272, 587, 26, 267, 372, 298, 4087, 1177, 26, 298, 435, 1177, 421, 199, 318, 4613, 63, 12010, 63, 4705, 8, 12010, 12222, 304, 272, 492, 485, 4462, 14, 888, 339, 340, 11167, 12222, 14, 888, 14, 1422, 14, 16586, 1393, 1137, 298, 4892, 582, 267, 372, 272, 5651, 275, 11167, 12222, 272, 340, 298, 4892, 2, 315, 5651, 14, 3200, 26, 267, 11167, 12222, 14, 952, 63, 4127, 480, 11107, 298, 27219, 2556, 370, 510, 9209, 7591, 531, 267, 367, 1833, 315, 11167, 12222, 14, 3200, 14, 362, 480, 4892, 2349, 288, 862, 26, 355, 1499, 275, 1833, 14, 2809, 2722, 14, 2722, 6894, 14, 1155, 640, 1996, 1988, 17, 1055, 2722, 493, 2102, 288, 871, 4281, 26, 355, 1499, 275, 5651, 423, 362, 5328, 11268, 8, 1155, 9, 288, 8900, 275, 485, 4462, 14, 888, 14, 981, 63, 12010, 63, 5491, 8, 355, 11167, 12222, 14, 888, 12, 1059, 2308, 29, 549, 288, 776, 288, 1833, 14, 475, 12010, 8, 8122, 9, 288, 308, 275, 8900, 14, 875, 2308, 14, 7150, 342, 288, 702, 822, 8, 83, 9, 288, 20901, 1393, 633, 275, 1218, 63, 1222, 63, 16586, 8, 83, 9, 288, 5651, 14, 952, 63, 604, 3647, 83, 10541, 450, 83, 2, 450, 334, 1328, 12, 20901, 1393, 633, 430, 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 ]
[ 11482, 5988, 503, 511, 2351, 2556, 370, 282, 20901, 1393, 2435, 14, 408, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 646, 3816, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1572, 275, 1798, 14, 362, 923, 480, 12010, 17290, 531, 272, 1572, 423, 525, 1422, 8, 267, 4320, 16586, 1393, 401, 267, 8214, 628, 632, 401, 267, 1595, 628, 1617, 401, 267, 2053, 628, 16586, 1393, 401, 267, 849, 29, 403, 12, 267, 3415, 6270, 4892, 401, 298, 452, 2255, 267, 1720, 628, 2254, 3405, 92, 452, 2256, 370, 13292, 9209, 14, 846, 20901, 1393, 2435, 4765, 272, 776, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2019, 29, 549, 9, 199, 318, 4613, 63, 6472, 8, 888, 304, 272, 340, 1101, 14, 1422, 14, 16586, 1393, 508, 298, 452, 582, 267, 5651, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12010, 12222, 531, 267, 327, 340, 949, 11167, 17663, 3589, 365, 3451, 12, 6548, 781, 883, 886, 2348, 27, 267, 327, 642, 883, 5992, 1380, 642, 805, 24956, 315, 282, 15494, 1031, 267, 327, 1380, 1808, 4613, 13, 88, 2686, 12, 367, 2893, 267, 340, 5651, 365, 440, 488, 26, 288, 327, 20901, 1393, 570, 911, 506, 2774, 13, 24, 5737, 3366, 570, 288, 1101, 423, 16586, 1393, 493, 275, 5549, 14, 13271, 480, 87, 11, 66, 531, 288, 2269, 952, 275, 5651, 423, 8122, 14, 952, 953, 347, 1565, 69, 63, 952, 8, 83, 12, 1011, 958, 304, 355, 2269, 952, 8, 83, 12, 1011, 958, 9, 355, 340, 1228, 8, 83, 12, 3816, 14, 505, 63, 466, 304, 490, 308, 275, 308, 14, 2143, 480, 1624, 13, 24, 531, 355, 1101, 423, 16586, 1393, 493, 14, 952, 8, 83, 9, 953, 5651, 423, 8122, 14, 952, 275, 1565, 69, 63, 952, 421, 199, 318, 4613, 63, 324, 6472, 8, 888, 304, 272, 340, 2688, 8, 888, 12, 2668, 16586, 1393, 493, 2349, 267, 327, 664, 11167, 4072, 436, 3145, 570, 267, 1101, 423, 16586, 1393, 493, 14, 5507, 8, 16, 9, 267, 2351, 793, 275, 1101, 423, 16586, 1393, 493, 14, 739, 342, 267, 1101, 423, 16586, 1393, 493, 14, 1600, 342, 267, 2150, 1101, 423, 16586, 1393, 493, 267, 327, 18172, 4154, 3371, 316, 315, 314, 11167, 17663, 267, 5651, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12010, 12222, 531, 267, 2150, 5651, 423, 8122, 855, 807, 363, 905, 952, 937, 267, 327, 2218, 6212, 267, 5651, 14, 952, 63, 4127, 480, 11107, 298, 27219, 2556, 370, 510, 9209, 7591, 531, 267, 20901, 1393, 633, 275, 1218, 63, 1222, 63, 16586, 8, 1730, 793, 9, 267, 5651, 14, 952, 63, 604, 480, 16586, 1393, 2351, 13, 793, 26, 450, 83, 60, 78, 2, 450, 20901, 1393, 633, 9, 421, 199, 318, 1218, 63, 1222, 63, 16586, 8, 4407, 304, 272, 408, 272, 10560, 282, 892, 20901, 1808, 13292, 9209, 14, 846, 2435, 14, 339, 520, 4407, 26, 20901, 4072, 465, 2774, 13, 24, 5737, 2783, 272, 520, 5808, 26, 1166, 370, 314, 19099, 471, 4072, 272, 408, 272, 492, 295, 339, 340, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 378, 304, 267, 687, 4011, 492, 18279, 12, 16511, 272, 587, 26, 267, 687, 4011, 14, 1069, 492, 18279, 267, 687, 4011, 14, 1122, 492, 16511, 339, 1862, 275, 469, 267, 298, 600, 582, 4072, 12, 267, 298, 11729, 582, 298, 1548, 19, 2, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 587, 298, 1548, 401, 267, 298, 16844, 582, 298, 17, 6419, 401, 272, 789, 272, 1166, 275, 298, 2859, 921, 10913, 9209, 14, 846, 2, 272, 1177, 275, 18279, 8, 633, 12, 666, 29, 10738, 8, 1162, 680, 2143, 480, 4371, 21688, 739, 342, 272, 333, 275, 295, 14, 1733, 8, 82, 7, 6399, 9555, 1773, 15, 2961, 87, 20415, 297, 1177, 14, 2708, 480, 1624, 13, 24, 2237, 272, 340, 333, 26, 267, 372, 2071, 83, 15, 2384, 3149, 83, 2, 450, 334, 633, 12, 333, 14, 923, 8, 17, 430, 272, 587, 26, 267, 372, 298, 4087, 1177, 26, 298, 435, 1177, 421, 199, 318, 4613, 63, 12010, 63, 4705, 8, 12010, 12222, 304, 272, 492, 485, 4462, 14, 888, 339, 340, 11167, 12222, 14, 888, 14, 1422, 14, 16586, 1393, 1137, 298, 4892, 582, 267, 372, 272, 5651, 275, 11167, 12222, 272, 340, 298, 4892, 2, 315, 5651, 14, 3200, 26, 267, 11167, 12222, 14, 952, 63, 4127, 480, 11107, 298, 27219, 2556, 370, 510, 9209, 7591, 531, 267, 367, 1833, 315, 11167, 12222, 14, 3200, 14, 362, 480, 4892, 2349, 288, 862, 26, 355, 1499, 275, 1833, 14, 2809, 2722, 14, 2722, 6894, 14, 1155, 640, 1996, 1988, 17, 1055, 2722, 493, 2102, 288, 871, 4281, 26, 355, 1499, 275, 5651, 423, 362, 5328, 11268, 8, 1155, 9, 288, 8900, 275, 485, 4462, 14, 888, 14, 981, 63, 12010, 63, 5491, 8, 355, 11167, 12222, 14, 888, 12, 1059, 2308, 29, 549, 288, 776, 288, 1833, 14, 475, 12010, 8, 8122, 9, 288, 308, 275, 8900, 14, 875, 2308, 14, 7150, 342, 288, 702, 822, 8, 83, 9, 288, 20901, 1393, 633, 275, 1218, 63, 1222, 63, 16586, 8, 83, 9, 288, 5651, 14, 952, 63, 604, 3647, 83, 10541, 450, 83, 2, 450, 334, 1328, 12, 20901, 1393, 633, 430, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GoSecure/gophish-cli
modules/report.py
1
25755
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Reporting class to gather information from the campaign @author: Martin Dubé @organization: Gosecure inc. @license: MIT License @contact: mdube@gosecure.ca Copyright (c) 2018, Gosecure All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import os import re import ssl import time import json import config import pytz import logging import datetime import dateutil.parser import paramiko import sendgrid import urllib.request import apache_log_parser from prettytable import PrettyTable BROWSER_MSG = ['Email Opened', 'Clicked Link', 'Submitted Data'] logger = logging.getLogger('gophish-cli') class GophishReporter(): timeline = None results = None empire_agents = None excluded_ip = [] stats = {} out_folder = config.WORKING_DIR + 'report_%s/' % time.strftime("%Y%m%d-%H%M%S") apache_folder = out_folder + 'apache_logs/' # Flags to easily enable/disable features. enable_apache = True enable_sendgrid = True enable_empire = False enable_msf = False enable_cobalt = False def __init__(self, timeline, results): self.timeline = timeline self.results = results self.excluded_ip = config.EXCLUDED_IP self.timezone = pytz.timezone(config.GOPHISH_TIMEZONE) def _setup_out_folder(self): if not os.path.exists(self.out_folder): logger.debug("Creating folder: %s" % self.out_folder) os.makedirs(self.out_folder) if not os.path.exists(self.apache_folder): logger.debug("Creating folder: %s" % self.apache_folder) os.makedirs(self.apache_folder) def _ssh_agent_auth(self, transport, username): """ Attempt to authenticate to the given transport using any of the private keys available from an SSH agent """ logger.debug('[SSH] Attempting to authenticate') agent = paramiko.Agent() agent_keys = agent.get_keys() if len(agent_keys) == 0: return for key in agent_keys: logger.debug('[SSH] Trying ssh-agent key %s' % key.get_fingerprint().hex()) try: transport.auth_publickey(username, key) logger.debug('[SSH]... success!') return except paramiko.SSHException as e: logger.debug('[SSH]... failed!', e) # Extract specific keys and return a list of their values. # Useful to extract empire unique users, workstations or operating systems def _json_get_unique_key(self, json_obj, key): return list(set([obj[key] for obj in json_obj])) def _json_get_count_key(self, json_obj, key): d = dict() for obj in json_obj: key_value = obj[key] d[key_value] = d.get(key_value, 0) + 1 return d def _get_timeline_unique_key(self, key): return list(set([getattr(obj,key) for obj in self.timeline])) def _get_timeline_key_count(self, key): d = dict() for obj in self.timeline: key_value = getattr(obj,key) d[key_value] = d.get(key_value, 0) + 1 return d def _get_results_unique_key(self, key): return list(set([getattr(obj,key) for obj in self.results])) def _get_results_key_count(self, key): d = dict() for obj in self.results: key_value = getattr(obj,key) d[key_value] = d.get(key_value, 0) + 1 return d def _get_apache_key_count(self, key): d = dict() line_parser = apache_log_parser.make_parser(config.APACHE_LOGS_FORMAT) for log_line in self.apache_malware_dl: log_line_data = line_parser(log_line) key_value = log_line_data[key] d[key_value] = d.get(key_value, 0) + 1 return d def _grep_files(self, path, search): res = [] for root, dirs, fnames in os.walk(path): for fname in fnames: filepath = os.path.join(root, fname) with open(filepath, 'r', encoding = "ISO-8859-1") as f: for line in f: if search in line: res.append(line) return res def get_apache_logs(self): ssh = paramiko.Transport((config.APACHE_HOST, config.APACHE_SSH_PORT)) ssh.start_client() self._ssh_agent_auth(ssh, config.APACHE_SSH_USER) if not ssh.is_authenticated(): logger.error("[SSH] Authentication failed. Make sure that your key is added to SSH agent. If not, use ssh-add.") sys.exit(1) else: logger.debug("[SSH] Authentication successful") #ssh.set_missing_host_key_policy(AllowAnythingPolicy()) sftp = ssh.open_session() sftp = paramiko.SFTPClient.from_transport(ssh) logger.debug('[SSH] Changing directory: %s' % config.APACHE_LOGS_FOLDER) sftp.chdir(config.APACHE_LOGS_FOLDER) for filename in sorted(sftp.listdir()): if filename.startswith(config.APACHE_LOGS_PREFIX): logger.debug('[SSH] Downloading: %s' % filename) sftp.get(filename, self.apache_folder + filename) sftp.close() ssh.close() # TODO: Unzip *.gz self.apache_malware_dl = self._grep_files(self.apache_folder, config.APACHE_MALWARE_NAME) logger.debug(' Got %s malware download' % len(self.apache_malware_dl)) def get_empire_agents(self): header={'Content-Type': 'application/json'} url = '%s/api/agents?token=%s' % (config.EMPIRE_API_URL, config.EMPIRE_API_KEY) ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url=url, headers=header, method='GET') res = urllib.request.urlopen(req, timeout=5, context=ctx) res_body = res.read() self.empire_agents = json.loads(res_body.decode('utf-8'))['agents'] logger.debug(' Got %s agents' % len(self.empire_agents)) def get_sendgrid_stats(self): sg = sendgrid.SendGridAPIClient(apikey=config.SENDGRID_API_KEY) start_date = self.get_first_event_ts().strftime('%Y-%m-%d') params = {'aggregated_by': 'day', 'limit': 1, 'start_date': start_date, 'end_date': start_date, 'offset': 1} response = sg.client.stats.get(query_params=params) if response.status_code == 200: self.sendgrid_stats = json.loads(response.body.decode('utf-8'))[0]['stats'][0]['metrics'] else: self.sendgrid_stats = [] def get_msf_shells(self): pass def get_cobaltstrike_shells(self): pass def get_first_event_ts(self): return dateutil.parser.parse(self.timeline[0].time).astimezone(self.timezone) def get_last_event_ts(self): return dateutil.parser.parse(self.timeline[-1].time).astimezone(self.timezone) def extract_gophish_stats(self): self.stats['first_event_ts'] = self.get_first_event_ts().strftime("%Y-%m-%d %H:%M:%S") self.stats['last_event_ts'] = self.get_last_event_ts().strftime("%Y-%m-%d %H:%M:%S") self.stats['email_sent_ct'] = len([x.email for x in self.timeline if x.message == 'Email Sent']) self.stats['email_opened_ct'] = len([x.email for x in self.timeline if x.message == 'Email Opened']) self.stats['clicked_link_ct'] = len([x.email for x in self.timeline if x.message == 'Clicked Link']) self.stats['submitted_data_ct'] = len([x.email for x in self.timeline if x.message == 'Submitted Data']) self.stats['unique_email_sent_ct'] = len(list(set([x.email for x in self.timeline if x.message == 'Email Sent']))) self.stats['unique_email_opened_ct'] = len(list(set([x.email for x in self.timeline if x.message == 'Email Opened']))) self.stats['unique_clicked_link_ct'] = len(list(set([x.email for x in self.timeline if x.message == 'Clicked Link']))) self.stats['unique_submitted_data_ct'] = len(list(set([x.email for x in self.timeline if x.message == 'Submitted Data']))) # source IP for i in range(0, len(self.timeline)): if self.timeline[i].message in BROWSER_MSG and type(self.timeline[i].details) is dict: self.timeline[i].source_ip = self.timeline[i].details['browser']['address'] else: self.timeline[i].source_ip = None self.stats['source_ip'] = self._get_timeline_key_count('source_ip') def extract_apache_stats(self): self.stats['apache_malware_dl_ct'] = len(self.apache_malware_dl) self.stats['apache_source_ip'] = self._get_apache_key_count('remote_host') def extract_empire_stats(self): self.stats['empire_agents_ct'] = len(self.empire_agents) self.stats['empire_agents_highpriv_ct'] = len([x for x in self.empire_agents if x['high_integrity'] == 1]) self.stats['empire_agents_unique_usernames_ct'] = len(self._json_get_unique_key(self.empire_agents, 'username')) self.stats['empire_agents_unique_hostnames_ct'] = len(self._json_get_unique_key(self.empire_agents, 'hostname')) self.stats['empire_os'] = self._json_get_count_key(self.empire_agents, 'os_details') self.stats['empire_source_ip'] = self._json_get_count_key(self.empire_agents, 'external_ip') def extract_msf_stats(self): self.stats['msf_agents_ct'] = 0 self.stats['msf_agents_highpriv_ct'] = 0 self.stats['msf_agents_unique_usernames_ct'] = 0 self.stats['msf_agents_unique_hostnames_ct'] = 0 self.stats['msf_os'] = [] self.stats['msf_source_ip'] = [] def extract_cobaltstrike_stats(self): self.stats['cs_agents_ct'] = 0 self.stats['cs_agents_highpriv_ct'] = 0 self.stats['cs_agents_unique_usernames_ct'] = 0 self.stats['cs_agents_unique_hostnames_ct'] = 0 self.stats['cs_os'] = [] self.stats['cs_source_ip'] = [] def extract_delivered_emails(self): pass def extract_conversion_stats(self): try: self.stats['conversion_receive_to_open'] = None self.stats['conversion_email_to_click'] = None self.stats['conversion_page_to_creds'] = None self.stats['conversion_receive_to_open'] = round(self.stats['unique_email_opened_ct'] / self.stats['unique_email_sent_ct'] * 100, 2) self.stats['conversion_email_to_click'] = round(self.stats['unique_clicked_link_ct'] / self.stats['unique_email_opened_ct'] * 100, 2) self.stats['conversion_page_to_creds'] = round(self.stats['unique_submitted_data_ct'] / self.stats['unique_clicked_link_ct'] * 100, 2) except ZeroDivisionError: pass if self.enable_apache and self.enable_empire: self.stats['conversion_dl_to_empire_exec'] = round(self.stats['empire_agents_unique_usernames_ct'] / \ self.stats['apache_malware_dl_ct'] * 100, 2) else: self.stats['conversion_dl_to_empire_exec'] = None if self.enable_apache and self.enable_msf: self.stats['conversion_dl_to_msf_exec'] = round(self.stats['msf_agents_unique_usernames_ct'] / \ self.stats['apache_malware_dl_ct'] * 100, 2) else: self.stats['conversion_dl_to_msf_exec'] = None if self.enable_apache and self.enable_cobalt: self.stats['conversion_dl_to_cs_exec'] = round(self.stats['cs_agents_unique_usernames_ct'] / \ self.stats['apache_malware_dl_ct'] * 100, 2) else: self.stats['conversion_dl_to_cs_exec'] = None # Extract statistics of each position (often used as a department) # The objective is to extract stats based on departments. def extract_position_stats(self): self.stats['position'] = {} position_list = self._get_results_unique_key('position') for pos in position_list: position_results = [obj for obj in self.results if obj.position == pos] pos_total = len(position_results) pos_scheduled = len([obj for obj in position_results if obj.status == 'Scheduled']) pos_email_sent = len([obj for obj in position_results if obj.status == 'Email Sent']) pos_email_open = len([obj for obj in position_results if obj.status == 'Email Opened']) pos_link_clicked = len([obj for obj in position_results if obj.status == 'Clicked Link']) pos_submitted_data = len([obj for obj in position_results if obj.status == 'Submitted Data']) self.stats['position'][pos] = {'total': pos_total, \ 'scheduled': pos_scheduled, \ 'email_sent': pos_email_sent, \ 'email_open': pos_email_open, \ 'link_clicked': pos_link_clicked, \ 'submitted_data': pos_submitted_data} def extract_stats_percentage(self): self.stats['stats_email_opened'] = round(self.stats['unique_email_opened_ct'] / \ self.sendgrid_stats['delivered'] * 100, 2) self.stats['stats_clicked_link'] = round(self.stats['unique_clicked_link_ct'] / \ self.sendgrid_stats['delivered'] * 100, 2) self.stats['stats_submitted_data'] = round(self.stats['unique_submitted_data_ct'] / \ self.sendgrid_stats['delivered'] * 100, 2) def print_position_stats(self): title = ['Position', 'Scheduled', 'Email Sent', 'Email Open', \ 'Link Clicked', 'Submitted Data', 'Total'] x = PrettyTable(title) x.align['Position'] = 'l' x.align['Scheduled'] = 'c' x.align['Email Sent'] = 'c' x.align['Email Open'] = 'c' x.align['Link Clicked'] = 'c' x.align['Submitted Data'] = 'c' x.align['Total'] = 'c' x.padding_width = 1 x.max_width = 40 position_list = self._get_results_unique_key('position') for pos in position_list: row = self.stats['position'][pos] x.add_row([ pos, row['scheduled'], row['email_sent'], \ row['email_open'], row['link_clicked'], \ row['submitted_data'], row['total'] ]) print(x.get_string()) def generate(self): logger.info("Generating report.") logger.info("Setting up folders") self._setup_out_folder() if self.enable_apache: logger.info("Downloading apache logs") self.get_apache_logs() if self.enable_sendgrid: logger.info("Getting Sendgrid Stats") self.get_sendgrid_stats() if self.enable_empire: logger.info("Getting Empire Agents") self.get_empire_agents() logger.info("Extracting stats") self.extract_gophish_stats() if self.enable_apache: self.extract_apache_stats() if self.enable_empire: self.extract_empire_stats() if self.enable_msf: self.extract_msf_stats() if self.enable_cobalt: self.extract_cobaltstrike_stats() self.extract_conversion_stats() self.extract_position_stats() if self.enable_sendgrid: self.extract_stats_percentage() logger.info("Printing Report") print("Raw Data: ") print("") print(" Timeline: ") print(" First Event: %s" % self.stats['first_event_ts']) print(" Last Event: %s" % self.stats['last_event_ts']) print(" Email sent: %s" % self.stats['email_sent_ct']) print(" Email opened: %s" % self.stats['email_opened_ct']) print(" Clicked Link: %s" % self.stats['clicked_link_ct']) print(" Submitted Data: %s" % self.stats['submitted_data_ct']) print(" Unique Email sent: %s" % self.stats['unique_email_sent_ct']) print(" Unique Email opened: %s" % self.stats['unique_email_opened_ct']) print(" Unique Clicked Link: %s" % self.stats['unique_clicked_link_ct']) print(" Unique Submitted Data: %s" % self.stats['unique_submitted_data_ct']) print(" Source IPs: ") for key, count in self.stats['source_ip'].items(): print(" %s (%s)" % (key,count)) print("") print(" Position stats:") self.print_position_stats() print("") if self.enable_sendgrid: print(" Sendgrid stats:") print(" Blocks: %s" % self.sendgrid_stats['blocks']) print(" Bounce Drops: %s" % self.sendgrid_stats['bounce_drops']) print(" Bounces: %s" % self.sendgrid_stats['bounces']) print(" Clicks: %s" % self.sendgrid_stats['clicks']) print(" Deffered: %s" % self.sendgrid_stats['deferred']) print(" Delivered: %s" % self.sendgrid_stats['delivered']) print(" Invalid Emails: %s" % self.sendgrid_stats['invalid_emails']) print(" Open: %s" % self.sendgrid_stats['opens']) print(" Processed: %s" % self.sendgrid_stats['processed']) print(" Requests: %s" % self.sendgrid_stats['requests']) print(" Spam Report Drops: %s" % self.sendgrid_stats['spam_report_drops']) print(" Spam Reports: %s" % self.sendgrid_stats['spam_reports']) print(" Unique Clicks: %s" % self.sendgrid_stats['unique_clicks']) print(" Unique Opens: %s" % self.sendgrid_stats['unique_opens']) print(" Subscribe Drops: %s" % self.sendgrid_stats['unsubscribe_drops']) print(" Unsubscribes: %s" % self.sendgrid_stats['unsubscribes']) print("") if self.enable_apache: print(" Apache: ") print(" Malware Download: %s" % self.stats['apache_malware_dl_ct']) print(" Source IPs: ") for key, count in self.stats['apache_source_ip'].items(): print(" %s (%s)" % (key,count)) print("") if self.enable_empire and self.stats['empire_agents_ct'] > 0: print(" Empire: ") print(" Agents count: %s" % self.stats['empire_agents_ct']) print(" Agents HighPriv count: %s" % self.stats['empire_agents_highpriv_ct']) print(" Unique Agents username count: %s" % self.stats['empire_agents_unique_usernames_ct']) print(" Unique Agents Hostnames count: %s" % self.stats['empire_agents_unique_hostnames_ct']) print(" OS Details: ") for key, count in self.stats['empire_os'].items(): print(" %s (%s)" % (key,count)) print(" Source IPs: ") for key, count in self.stats['empire_source_ip'].items(): print(" %s (%s)" % (key,count)) print("") if self.enable_msf and self.stats['msf_agents_ct'] > 0: print(" Metasploit: ") print(" Agents count: %s" % self.stats['msf_agents_ct']) print(" Agents HighPriv count: %s" % self.stats['msf_agents_highpriv_ct']) print(" Unique Agents username count: %s" % self.stats['msf_agents_unique_usernames_ct']) print(" Unique Agents Hostnames count: %s" % self.stats['msf_agents_unique_hostnames_ct']) print(" OS Details: ") for key, count in self.stats['msf_os'].items(): print(" %s (%s)" % (key,count)) print(" Source IPs: ") for key, count in self.stats['msf_source_ip'].items(): print(" %s (%s)" % (key,count)) print("") if self.enable_cobalt and self.stats['cs_agents_ct'] > 0: print(" Cobalt Strike: ") print(" Agents count: %s" % self.stats['cs_agents_ct']) print(" Agents HighPriv count: %s" % self.stats['cs_agents_highpriv_ct']) print(" Unique Agents username count: %s" % self.stats['cs_agents_unique_usernames_ct']) print(" Unique Agents Hostnames count: %s" % self.stats['cs_agents_unique_hostnames_ct']) print(" OS Details: ") for key, count in self.stats['cs_os'].items(): print(" %s (%s)" % (key,count)) print(" Source IPs: ") for key, count in self.stats['cs_source_ip'].items(): print(" %s (%s)" % (key,count)) print("") print("Analyzed Data: ") print("") print(" Conversion Percentage:") print(" Email Received (%s) -> Email Opened (%s): %s" % (self.stats['unique_email_sent_ct'], self.stats['unique_email_opened_ct'], self.stats['conversion_receive_to_open'])) print(" Email Open (%s) -> Link Clicked (%s): %s" % (self.stats['unique_email_opened_ct'], self.stats['unique_clicked_link_ct'], self.stats['conversion_email_to_click'])) print(" Page Visit (%s) -> Send Credentials (%s): %s" % (self.stats['unique_clicked_link_ct'], self.stats['unique_submitted_data_ct'], self.stats['conversion_page_to_creds'])) print(" Malware Download (%s) -> Malware Execution (%s) (Empire): %s" % (self.stats.get('apache_malware_dl_ct', None), self.stats.get('empire_agents_unique_usernames_ct', None), self.stats.get('conversion_dl_to_empire_exec', None))) print(" Malware Download (%s) -> Malware Execution (%s) (Msf): %s" % (self.stats.get('apache_malware_dl_ct', None), self.stats.get('msf_agents_unique_usernames_ct', None), self.stats.get('conversion_dl_to_msf_exec', None))) print(" Malware Download (%s) -> Malware Execution (%s) (Cobalt): %s" % (self.stats.get('apache_malware_dl_ct', None), self.stats.get('cs_agents_unique_usernames_ct', None), self.stats.get('conversion_dl_to_cs_exec', None))) print("") if self.enable_sendgrid: print(" Events statistics (based on the number of delivered email from Sendgrid): ") print(" Unique Email Opened (gophish unique opened (%s) / sendgrid delivered (%s) * 100): %s" % (self.stats.get('unique_email_opened_ct'), self.sendgrid_stats['delivered'], self.stats.get('stats_email_opened', None))) print(" Unique Clicked Link (gophish unique clicked link (%s) / sendgrid delivered (%s) * 100): %s" % (self.stats.get('unique_clicked_link_ct', None), self.sendgrid_stats['delivered'], self.stats.get('stats_clicked_link', None))) print(" Unique Submitted Data (gophish unique submitted data (%s) / sendgrid delivered (%s) * 100): %s" % (self.stats.get('unique_submitted_data_ct', None), self.sendgrid_stats['delivered'], self.stats.get('stats_submitted_data', None))) print("")
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 28457, 1021, 370, 13082, 2556, 687, 314, 22166, 199, 199, 32, 2502, 26, 603, 26788, 577, 456, 5741, 199, 32, 9071, 26, 3971, 7817, 12864, 14, 199, 32, 1682, 26, 10697, 844, 199, 32, 7811, 26, 6128, 3375, 32, 1939, 7817, 14, 696, 199, 199, 7384, 334, 67, 9, 14894, 12, 3971, 7817, 199, 2422, 4481, 4644, 14, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 6149, 199, 646, 900, 199, 646, 2022, 199, 646, 1101, 199, 646, 15444, 199, 646, 2050, 199, 646, 2197, 199, 646, 22208, 14, 2087, 199, 646, 26162, 199, 646, 3222, 3825, 199, 646, 4011, 14, 1069, 199, 646, 17098, 63, 793, 63, 2087, 199, 504, 7268, 1224, 492, 31651, 3186, 199, 199, 31956, 3279, 63, 9740, 275, 788, 7035, 3232, 379, 297, 283, 31483, 10967, 297, 283, 2610, 4485, 3918, 418, 199, 199, 2921, 275, 2050, 14, 5572, 360, 71, 411, 866, 72, 13, 2764, 358, 199, 199, 533, 598, 411, 866, 72, 15891, 837, 272, 20780, 275, 488, 272, 2058, 275, 488, 272, 9052, 3621, 63, 14250, 275, 488, 272, 8789, 63, 711, 275, 942, 272, 5020, 275, 1052, 339, 734, 63, 3741, 275, 1101, 14, 8406, 1206, 63, 3022, 435, 283, 3070, 4970, 83, 4805, 450, 900, 14, 6205, 3647, 57, 5, 77, 5, 68, 3295, 40, 5, 45, 5, 51, 531, 272, 17098, 63, 3741, 275, 734, 63, 3741, 435, 283, 3796, 63, 7270, 4805, 339, 327, 24870, 370, 16174, 4756, 15, 5993, 4534, 14, 272, 4756, 63, 3796, 275, 715, 272, 4756, 63, 2254, 3825, 275, 715, 272, 4756, 63, 2109, 3621, 275, 756, 272, 4756, 63, 706, 70, 275, 756, 272, 4756, 63, 331, 66, 4478, 275, 756, 339, 347, 636, 826, 721, 277, 12, 20780, 12, 2058, 304, 267, 291, 14, 19369, 275, 20780, 267, 291, 14, 2604, 275, 2058, 267, 291, 14, 12144, 63, 711, 275, 1101, 14, 29647, 53, 8280, 63, 1772, 267, 291, 14, 7145, 275, 15444, 14, 7145, 8, 888, 14, 39, 1938, 40, 13898, 63, 4961, 15353, 9, 339, 347, 485, 2758, 63, 548, 63, 3741, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 548, 63, 3741, 304, 288, 2512, 14, 1757, 480, 14380, 4922, 26, 450, 83, 2, 450, 291, 14, 548, 63, 3741, 9, 288, 747, 14, 8347, 8, 277, 14, 548, 63, 3741, 9, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 3796, 63, 3741, 304, 288, 2512, 14, 1757, 480, 14380, 4922, 26, 450, 83, 2, 450, 291, 14, 3796, 63, 3741, 9, 288, 747, 14, 8347, 8, 277, 14, 3796, 63, 3741, 9, 339, 347, 485, 5510, 63, 4054, 63, 1178, 8, 277, 12, 7773, 12, 3434, 304, 267, 408, 267, 23115, 370, 12895, 370, 314, 1627, 7773, 1808, 1263, 402, 314, 5726, 267, 2883, 2808, 687, 376, 12027, 6631, 267, 408, 272, 267, 2512, 14, 1757, 11894, 13716, 61, 17413, 1337, 370, 12895, 358, 267, 6631, 275, 26162, 14, 7788, 342, 267, 6631, 63, 1612, 275, 6631, 14, 362, 63, 1612, 342, 267, 340, 822, 8, 4054, 63, 1612, 9, 508, 378, 26, 288, 372, 13857, 367, 790, 315, 6631, 63, 1612, 26, 288, 2512, 14, 1757, 11894, 13716, 61, 7649, 316, 8635, 13, 4054, 790, 450, 83, 7, 450, 790, 14, 362, 63, 15077, 1252, 4097, 1012, 288, 862, 26, 355, 7773, 14, 1178, 63, 5645, 8442, 14655, 8, 2473, 12, 790, 9, 355, 2512, 14, 1757, 11894, 13716, 61, 1396, 3182, 10916, 355, 372, 288, 871, 26162, 14, 13716, 1726, 465, 325, 26, 355, 2512, 14, 1757, 11894, 13716, 61, 1396, 3405, 12389, 325, 9, 339, 327, 12892, 2488, 2883, 436, 372, 282, 769, 402, 3932, 1338, 14, 272, 327, 18491, 370, 5536, 9052, 3621, 3747, 4390, 12, 1736, 270, 1298, 503, 17406, 10460, 272, 347, 485, 1001, 63, 362, 63, 3235, 63, 498, 8, 277, 12, 2022, 63, 1113, 12, 790, 304, 267, 372, 769, 8, 409, 779, 1113, 59, 498, 61, 367, 1559, 315, 2022, 63, 1113, 2459, 339, 347, 485, 1001, 63, 362, 63, 835, 63, 498, 8, 277, 12, 2022, 63, 1113, 12, 790, 304, 267, 366, 275, 1211, 342, 267, 367, 1559, 315, 2022, 63, 1113, 26, 288, 790, 63, 585, 275, 1559, 59, 498, 61, 288, 366, 59, 498, 63, 585, 61, 275, 366, 14, 362, 8, 498, 63, 585, 12, 378, 9, 435, 413, 267, 372, 366, 339, 347, 485, 362, 63, 19369, 63, 3235, 63, 498, 8, 277, 12, 790, 304, 267, 372, 769, 8, 409, 779, 5675, 8, 1113, 12, 498, 9, 367, 1559, 315, 291, 14, 19369, 2459, 339, 347, 485, 362, 63, 19369, 63, 498, 63, 835, 8, 277, 12, 790, 304, 267, 366, 275, 1211, 342, 267, 367 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 28457, 1021, 370, 13082, 2556, 687, 314, 22166, 199, 199, 32, 2502, 26, 603, 26788, 577, 456, 5741, 199, 32, 9071, 26, 3971, 7817, 12864, 14, 199, 32, 1682, 26, 10697, 844, 199, 32, 7811, 26, 6128, 3375, 32, 1939, 7817, 14, 696, 199, 199, 7384, 334, 67, 9, 14894, 12, 3971, 7817, 199, 2422, 4481, 4644, 14, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 6149, 199, 646, 900, 199, 646, 2022, 199, 646, 1101, 199, 646, 15444, 199, 646, 2050, 199, 646, 2197, 199, 646, 22208, 14, 2087, 199, 646, 26162, 199, 646, 3222, 3825, 199, 646, 4011, 14, 1069, 199, 646, 17098, 63, 793, 63, 2087, 199, 504, 7268, 1224, 492, 31651, 3186, 199, 199, 31956, 3279, 63, 9740, 275, 788, 7035, 3232, 379, 297, 283, 31483, 10967, 297, 283, 2610, 4485, 3918, 418, 199, 199, 2921, 275, 2050, 14, 5572, 360, 71, 411, 866, 72, 13, 2764, 358, 199, 199, 533, 598, 411, 866, 72, 15891, 837, 272, 20780, 275, 488, 272, 2058, 275, 488, 272, 9052, 3621, 63, 14250, 275, 488, 272, 8789, 63, 711, 275, 942, 272, 5020, 275, 1052, 339, 734, 63, 3741, 275, 1101, 14, 8406, 1206, 63, 3022, 435, 283, 3070, 4970, 83, 4805, 450, 900, 14, 6205, 3647, 57, 5, 77, 5, 68, 3295, 40, 5, 45, 5, 51, 531, 272, 17098, 63, 3741, 275, 734, 63, 3741, 435, 283, 3796, 63, 7270, 4805, 339, 327, 24870, 370, 16174, 4756, 15, 5993, 4534, 14, 272, 4756, 63, 3796, 275, 715, 272, 4756, 63, 2254, 3825, 275, 715, 272, 4756, 63, 2109, 3621, 275, 756, 272, 4756, 63, 706, 70, 275, 756, 272, 4756, 63, 331, 66, 4478, 275, 756, 339, 347, 636, 826, 721, 277, 12, 20780, 12, 2058, 304, 267, 291, 14, 19369, 275, 20780, 267, 291, 14, 2604, 275, 2058, 267, 291, 14, 12144, 63, 711, 275, 1101, 14, 29647, 53, 8280, 63, 1772, 267, 291, 14, 7145, 275, 15444, 14, 7145, 8, 888, 14, 39, 1938, 40, 13898, 63, 4961, 15353, 9, 339, 347, 485, 2758, 63, 548, 63, 3741, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 548, 63, 3741, 304, 288, 2512, 14, 1757, 480, 14380, 4922, 26, 450, 83, 2, 450, 291, 14, 548, 63, 3741, 9, 288, 747, 14, 8347, 8, 277, 14, 548, 63, 3741, 9, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 277, 14, 3796, 63, 3741, 304, 288, 2512, 14, 1757, 480, 14380, 4922, 26, 450, 83, 2, 450, 291, 14, 3796, 63, 3741, 9, 288, 747, 14, 8347, 8, 277, 14, 3796, 63, 3741, 9, 339, 347, 485, 5510, 63, 4054, 63, 1178, 8, 277, 12, 7773, 12, 3434, 304, 267, 408, 267, 23115, 370, 12895, 370, 314, 1627, 7773, 1808, 1263, 402, 314, 5726, 267, 2883, 2808, 687, 376, 12027, 6631, 267, 408, 272, 267, 2512, 14, 1757, 11894, 13716, 61, 17413, 1337, 370, 12895, 358, 267, 6631, 275, 26162, 14, 7788, 342, 267, 6631, 63, 1612, 275, 6631, 14, 362, 63, 1612, 342, 267, 340, 822, 8, 4054, 63, 1612, 9, 508, 378, 26, 288, 372, 13857, 367, 790, 315, 6631, 63, 1612, 26, 288, 2512, 14, 1757, 11894, 13716, 61, 7649, 316, 8635, 13, 4054, 790, 450, 83, 7, 450, 790, 14, 362, 63, 15077, 1252, 4097, 1012, 288, 862, 26, 355, 7773, 14, 1178, 63, 5645, 8442, 14655, 8, 2473, 12, 790, 9, 355, 2512, 14, 1757, 11894, 13716, 61, 1396, 3182, 10916, 355, 372, 288, 871, 26162, 14, 13716, 1726, 465, 325, 26, 355, 2512, 14, 1757, 11894, 13716, 61, 1396, 3405, 12389, 325, 9, 339, 327, 12892, 2488, 2883, 436, 372, 282, 769, 402, 3932, 1338, 14, 272, 327, 18491, 370, 5536, 9052, 3621, 3747, 4390, 12, 1736, 270, 1298, 503, 17406, 10460, 272, 347, 485, 1001, 63, 362, 63, 3235, 63, 498, 8, 277, 12, 2022, 63, 1113, 12, 790, 304, 267, 372, 769, 8, 409, 779, 1113, 59, 498, 61, 367, 1559, 315, 2022, 63, 1113, 2459, 339, 347, 485, 1001, 63, 362, 63, 835, 63, 498, 8, 277, 12, 2022, 63, 1113, 12, 790, 304, 267, 366, 275, 1211, 342, 267, 367, 1559, 315, 2022, 63, 1113, 26, 288, 790, 63, 585, 275, 1559, 59, 498, 61, 288, 366, 59, 498, 63, 585, 61, 275, 366, 14, 362, 8, 498, 63, 585, 12, 378, 9, 435, 413, 267, 372, 366, 339, 347, 485, 362, 63, 19369, 63, 3235, 63, 498, 8, 277, 12, 790, 304, 267, 372, 769, 8, 409, 779, 5675, 8, 1113, 12, 498, 9, 367, 1559, 315, 291, 14, 19369, 2459, 339, 347, 485, 362, 63, 19369, 63, 498, 63, 835, 8, 277, 12, 790, 304, 267, 366, 275, 1211, 342, 267, 367, 0 ]
[ 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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documentation build configuration file, created by # sphinx-quickstart # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. """ import os import sys import unittest.mock as mock import matplotlib import heliopy matplotlib.use('agg') sys.path.insert(0, os.path.abspath('../../')) html_favicon = '../../artwork/favicon.ico' html_sidebars = {'**': ['docsidebar.html']} # Pretend these modules exits so readthedocs builds MOCK_MODULES = [] for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock.Mock() # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', 'sphinx.ext.intersphinx', 'sphinx_gallery.gen_gallery', 'sphinx_automodapi.automodapi', 'sphinx_issues' ] intersphinx_mapping = { 'matplotlib': ('https://matplotlib.org', None), 'python': ('https://docs.python.org/3', None), 'numpy': ('https://numpy.org/doc/stable', None), 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), 'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None), 'astropy': ('https://docs.astropy.org/en/stable', None), 'sunpy': ('https://docs.sunpy.org/en/stable', None)} sphinx_gallery_conf = { 'default_thumb_file': os.path.abspath(os.path.join('..', '..', 'artwork', 'logo_circle.png')), 'examples_dirs': '../../examples', 'gallery_dirs': 'auto_examples', 'backreferences_dir': 'gen_modules/backreferences', 'doc_module': ('sphinx_gallery', 'heliopy'), 'min_reported_time': 0, 'abort_on_example_error': False, } issues_github_path = 'heliopython/heliopy' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The encoding of source files. # # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'HelioPy' author = 'David Stansby' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = heliopy.__version__ # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # # today = '' # # Else, today_fmt is used as the format for a strftime call. # # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = 'py:obj' # If true, '()' will be appended to :func: etc. cross-reference text. # # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'heliopy_theme' html_theme_path = ['../'] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {'canonical_url': 'http://docs.heliopy.org/en/stable/', # 'analytics_id': 'UA-112461508-1', # 'prev_next_buttons_location': 'None'} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. # "<project> v<release> documentation" by default. # # html_title = 'heliopy v0.1' # A shorter title for the navigation bar. Default is the same as html_title. # # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # # html_logo = None # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or # 32x32 pixels large. # # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # # html_extra_path = [] # If not None, a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. # The empty string is equivalent to '%b %d, %Y'. # # html_last_updated_fmt = None # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # # html_additional_pages = {} # If false, no module index is generated. # # html_domain_indices = True # If false, no index is generated. # # html_use_index = True # If true, the index is split into individual pages for each letter. # # html_split_index = False # If true, links to the reST sources are added to the pages. # # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = False # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' # # html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # 'ja' uses this config value. # 'zh' user can custom change `jieba` dictionary path. # # html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. # # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'heliopydoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'heliopy.tex', 'HelioPy Documentation', 'David Stansby', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # # latex_use_parts = False # If true, show page references after internal links. # # latex_show_pagerefs = False # If true, show URL addresses after external links. # # latex_show_urls = False # Documents to append as an appendix to all manuals. # # latex_appendices = [] # It false, will not define \strong, \code, itleref, \crossref ... but only # \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added # packages. # # latex_keep_old_macro_names = True # If false, no module index is generated. # # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'HelioPy', 'HelioPy Documentation', [author], 1) ] # If true, show URL addresses after external links. # # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) '''texinfo_documents = [ (master_doc, 'HelioPy', 'HelioPy Documentation', author, 'HelioPy team', 'Python for space physics.', 'Miscellaneous'), ] html_theme_options = { "about_links": [ ("About", "http://docs.heliopy.org/en/stable/guide/about.html", 1), ( "Acknowledge HelioPy", "http://docs.heliopy.org/en/stable/guide/citing.html", 1, ), ("Code of Conduct", "http://docs.heliopy.org/en/stable/guide/code-of-conduct.html", 1), ], "navbar_links": [ ("Documentation", "http://docs.heliopy.org/en/stable/index.html", 1), ("Get Help", "http://docs.heliopy.org/en/stable/index.html", 1), ], }'''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 3, 946, 317, 927, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 14, 1805, 465, 1683, 199, 199, 646, 8027, 199, 199, 646, 946, 317, 927, 199, 199, 16440, 14, 1180, 360, 13452, 358, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 360, 9707, 1333, 199, 199, 1360, 63, 22229, 275, 283, 9707, 580, 800, 15, 22229, 14, 12802, 7, 199, 1360, 63, 29627, 275, 791, 538, 356, 788, 1301, 27372, 14, 1360, 12074, 199, 199, 3, 5543, 7169, 3520, 4621, 20100, 880, 1586, 22618, 14723, 199, 17749, 63, 21194, 275, 942, 199, 509, 3413, 63, 354, 315, 10362, 2504, 63, 21194, 26, 272, 984, 14, 3112, 59, 1494, 63, 354, 61, 275, 1683, 14, 3346, 342, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 199, 3, 4839, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 28056, 297, 272, 283, 8008, 14, 832, 14, 11390, 297, 272, 283, 8008, 14, 832, 14, 10828, 297, 272, 283, 8008, 14, 832, 14, 3442, 15863, 297, 272, 283, 8008, 14, 832, 14, 2542, 16721, 265, 297, 272, 283, 8008, 14, 832, 14, 1058, 8008, 297, 272, 283, 8008, 63, 25372, 14, 2268, 63, 25372, 297, 272, 283, 8008, 63, 6898, 676, 364, 1246, 14, 6898, 676, 364, 1246, 297, 272, 283, 8008, 63, 10115, 7, 199, 61, 199, 199, 1058, 8008, 63, 4745, 275, 469, 272, 283, 16440, 356, 661, 2859, 921, 16440, 14, 1308, 297, 488, 395, 272, 283, 1548, 356, 661, 2859, 921, 4757, 14, 1548, 14, 1308, 15, 19, 297, 488, 395, 272, 283, 4714, 356, 661, 2859, 921, 4714, 14, 1308, 15, 1301, 15, 11989, 297, 488, 395, 272, 283, 14248, 356, 661, 2859, 921, 4757, 14, 14248, 14, 1308, 15, 1301, 15, 14248, 15, 4443, 297, 488, 395, 272, 283, 15718, 356, 661, 2859, 921, 15718, 14, 647, 576, 14, 1308, 15, 15718, 13, 4757, 15, 11989, 297, 488, 395, 272, 283, 1810, 7537, 356, 661, 2859, 921, 4757, 14, 1810, 7537, 14, 1308, 15, 287, 15, 11989, 297, 488, 395, 272, 283, 11846, 647, 356, 661, 2859, 921, 4757, 14, 11846, 647, 14, 1308, 15, 287, 15, 11989, 297, 488, 6769, 421, 199, 8008, 63, 25372, 63, 2190, 275, 469, 272, 283, 885, 63, 16534, 63, 493, 356, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 19155, 283, 580, 800, 297, 283, 9733, 63, 11001, 14, 4524, 3855, 272, 283, 8589, 63, 3220, 356, 283, 9707, 8589, 297, 272, 283, 25372, 63, 3220, 356, 283, 2495, 63, 8589, 297, 272, 283, 894, 12635, 63, 694, 356, 283, 2268, 63, 3112, 15, 894, 12635, 297, 272, 283, 1301, 63, 578, 356, 661, 8008, 63, 25372, 297, 283, 426, 317, 927, 659, 272, 283, 827, 63, 1155, 1376, 63, 521, 356, 378, 12, 272, 283, 13845, 63, 265, 63, 2694, 63, 705, 356, 756, 12, 199, 93, 199, 199, 10115, 63, 5031, 63, 515, 275, 283, 426, 317, 927, 898, 15, 426, 317, 927, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 8, 397, 9, 402, 1350, 6203, 14, 199, 3, 2047, 883, 4165, 3663, 4739, 465, 282, 769, 402, 1059, 26, 199, 3, 199, 3, 1350, 63, 4511, 275, 18953, 8332, 297, 1987, 1064, 418, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 199, 3, 1350, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 283, 1966, 14437, 2713, 7, 199, 2502, 275, 283, 36, 17204, 1933, 796, 991, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 946, 317, 927, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1015, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 199, 3, 961, 365, 2597, 1202, 340, 1265, 886, 1564, 7761, 4799, 9796, 6230, 18238, 14, 199, 3, 24612, 1265, 663, 298, 3671, 2, 687, 314, 1414, 1004, 367, 3520, 5560, 14, 199, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 3, 946, 317, 927, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 14, 1805, 465, 1683, 199, 199, 646, 8027, 199, 199, 646, 946, 317, 927, 199, 199, 16440, 14, 1180, 360, 13452, 358, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 360, 9707, 1333, 199, 199, 1360, 63, 22229, 275, 283, 9707, 580, 800, 15, 22229, 14, 12802, 7, 199, 1360, 63, 29627, 275, 791, 538, 356, 788, 1301, 27372, 14, 1360, 12074, 199, 199, 3, 5543, 7169, 3520, 4621, 20100, 880, 1586, 22618, 14723, 199, 17749, 63, 21194, 275, 942, 199, 509, 3413, 63, 354, 315, 10362, 2504, 63, 21194, 26, 272, 984, 14, 3112, 59, 1494, 63, 354, 61, 275, 1683, 14, 3346, 342, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 199, 3, 4839, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 28056, 297, 272, 283, 8008, 14, 832, 14, 11390, 297, 272, 283, 8008, 14, 832, 14, 10828, 297, 272, 283, 8008, 14, 832, 14, 3442, 15863, 297, 272, 283, 8008, 14, 832, 14, 2542, 16721, 265, 297, 272, 283, 8008, 14, 832, 14, 1058, 8008, 297, 272, 283, 8008, 63, 25372, 14, 2268, 63, 25372, 297, 272, 283, 8008, 63, 6898, 676, 364, 1246, 14, 6898, 676, 364, 1246, 297, 272, 283, 8008, 63, 10115, 7, 199, 61, 199, 199, 1058, 8008, 63, 4745, 275, 469, 272, 283, 16440, 356, 661, 2859, 921, 16440, 14, 1308, 297, 488, 395, 272, 283, 1548, 356, 661, 2859, 921, 4757, 14, 1548, 14, 1308, 15, 19, 297, 488, 395, 272, 283, 4714, 356, 661, 2859, 921, 4714, 14, 1308, 15, 1301, 15, 11989, 297, 488, 395, 272, 283, 14248, 356, 661, 2859, 921, 4757, 14, 14248, 14, 1308, 15, 1301, 15, 14248, 15, 4443, 297, 488, 395, 272, 283, 15718, 356, 661, 2859, 921, 15718, 14, 647, 576, 14, 1308, 15, 15718, 13, 4757, 15, 11989, 297, 488, 395, 272, 283, 1810, 7537, 356, 661, 2859, 921, 4757, 14, 1810, 7537, 14, 1308, 15, 287, 15, 11989, 297, 488, 395, 272, 283, 11846, 647, 356, 661, 2859, 921, 4757, 14, 11846, 647, 14, 1308, 15, 287, 15, 11989, 297, 488, 6769, 421, 199, 8008, 63, 25372, 63, 2190, 275, 469, 272, 283, 885, 63, 16534, 63, 493, 356, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 19155, 283, 580, 800, 297, 283, 9733, 63, 11001, 14, 4524, 3855, 272, 283, 8589, 63, 3220, 356, 283, 9707, 8589, 297, 272, 283, 25372, 63, 3220, 356, 283, 2495, 63, 8589, 297, 272, 283, 894, 12635, 63, 694, 356, 283, 2268, 63, 3112, 15, 894, 12635, 297, 272, 283, 1301, 63, 578, 356, 661, 8008, 63, 25372, 297, 283, 426, 317, 927, 659, 272, 283, 827, 63, 1155, 1376, 63, 521, 356, 378, 12, 272, 283, 13845, 63, 265, 63, 2694, 63, 705, 356, 756, 12, 199, 93, 199, 199, 10115, 63, 5031, 63, 515, 275, 283, 426, 317, 927, 898, 15, 426, 317, 927, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 8, 397, 9, 402, 1350, 6203, 14, 199, 3, 2047, 883, 4165, 3663, 4739, 465, 282, 769, 402, 1059, 26, 199, 3, 199, 3, 1350, 63, 4511, 275, 18953, 8332, 297, 1987, 1064, 418, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 199, 3, 1350, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 283, 1966, 14437, 2713, 7, 199, 2502, 275, 283, 36, 17204, 1933, 796, 991, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 946, 317, 927, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1015, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 199, 3, 961, 365, 2597, 1202, 340, 1265, 886, 1564, 7761, 4799, 9796, 6230, 18238, 14, 199, 3, 24612, 1265, 663, 298, 3671, 2, 687, 314, 1414, 1004, 367, 3520, 5560, 14, 199, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 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, 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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 ]
BackupGGCode/python-for-android
python3-alpha/python3-src/Lib/idlelib/HyperParser.py
89
10310
""" HyperParser =========== This module defines the HyperParser class, which provides advanced parsing abilities for the ParenMatch and other extensions. The HyperParser uses PyParser. PyParser is intended mostly to give information on the proper indentation of code. HyperParser gives some information on the structure of code, used by extensions to help the user. """ import string import keyword from idlelib import PyParse class HyperParser: def __init__(self, editwin, index): """Initialize the HyperParser to analyze the surroundings of the given index. """ self.editwin = editwin self.text = text = editwin.text parser = PyParse.Parser(editwin.indentwidth, editwin.tabwidth) def index2line(index): return int(float(index)) lno = index2line(text.index(index)) if not editwin.context_use_ps1: for context in editwin.num_context_lines: startat = max(lno - context, 1) startatindex = repr(startat) + ".0" stopatindex = "%d.end" % lno # We add the newline because PyParse requires a newline at end. # We add a space so that index won't be at end of line, so that # its status will be the same as the char before it, if should. parser.set_str(text.get(startatindex, stopatindex)+' \n') bod = parser.find_good_parse_start( editwin._build_char_in_string_func(startatindex)) if bod is not None or startat == 1: break parser.set_lo(bod or 0) else: r = text.tag_prevrange("console", index) if r: startatindex = r[1] else: startatindex = "1.0" stopatindex = "%d.end" % lno # We add the newline because PyParse requires a newline at end. # We add a space so that index won't be at end of line, so that # its status will be the same as the char before it, if should. parser.set_str(text.get(startatindex, stopatindex)+' \n') parser.set_lo(0) # We want what the parser has, except for the last newline and space. self.rawtext = parser.str[:-2] # As far as I can see, parser.str preserves the statement we are in, # so that stopatindex can be used to synchronize the string with the # text box indices. self.stopatindex = stopatindex self.bracketing = parser.get_last_stmt_bracketing() # find which pairs of bracketing are openers. These always correspond # to a character of rawtext. self.isopener = [i>0 and self.bracketing[i][1] > self.bracketing[i-1][1] for i in range(len(self.bracketing))] self.set_index(index) def set_index(self, index): """Set the index to which the functions relate. Note that it must be in the same statement. """ indexinrawtext = \ len(self.rawtext) - len(self.text.get(index, self.stopatindex)) if indexinrawtext < 0: raise ValueError("The index given is before the analyzed statement") self.indexinrawtext = indexinrawtext # find the rightmost bracket to which index belongs self.indexbracket = 0 while self.indexbracket < len(self.bracketing)-1 and \ self.bracketing[self.indexbracket+1][0] < self.indexinrawtext: self.indexbracket += 1 if self.indexbracket < len(self.bracketing)-1 and \ self.bracketing[self.indexbracket+1][0] == self.indexinrawtext and \ not self.isopener[self.indexbracket+1]: self.indexbracket += 1 def is_in_string(self): """Is the index given to the HyperParser is in a string?""" # The bracket to which we belong should be an opener. # If it's an opener, it has to have a character. return self.isopener[self.indexbracket] and \ self.rawtext[self.bracketing[self.indexbracket][0]] in ('"', "'") def is_in_code(self): """Is the index given to the HyperParser is in a normal code?""" return not self.isopener[self.indexbracket] or \ self.rawtext[self.bracketing[self.indexbracket][0]] not in \ ('#', '"', "'") def get_surrounding_brackets(self, openers='([{', mustclose=False): """If the index given to the HyperParser is surrounded by a bracket defined in openers (or at least has one before it), return the indices of the opening bracket and the closing bracket (or the end of line, whichever comes first). If it is not surrounded by brackets, or the end of line comes before the closing bracket and mustclose is True, returns None. """ bracketinglevel = self.bracketing[self.indexbracket][1] before = self.indexbracket while not self.isopener[before] or \ self.rawtext[self.bracketing[before][0]] not in openers or \ self.bracketing[before][1] > bracketinglevel: before -= 1 if before < 0: return None bracketinglevel = min(bracketinglevel, self.bracketing[before][1]) after = self.indexbracket + 1 while after < len(self.bracketing) and \ self.bracketing[after][1] >= bracketinglevel: after += 1 beforeindex = self.text.index("%s-%dc" % (self.stopatindex, len(self.rawtext)-self.bracketing[before][0])) if after >= len(self.bracketing) or \ self.bracketing[after][0] > len(self.rawtext): if mustclose: return None afterindex = self.stopatindex else: # We are after a real char, so it is a ')' and we give the index # before it. afterindex = self.text.index("%s-%dc" % (self.stopatindex, len(self.rawtext)-(self.bracketing[after][0]-1))) return beforeindex, afterindex # This string includes all chars that may be in a white space _whitespace_chars = " \t\n\\" # This string includes all chars that may be in an identifier _id_chars = string.ascii_letters + string.digits + "_" # This string includes all chars that may be the first char of an identifier _id_first_chars = string.ascii_letters + "_" # Given a string and pos, return the number of chars in the identifier # which ends at pos, or 0 if there is no such one. Saved words are not # identifiers. def _eat_identifier(self, str, limit, pos): i = pos while i > limit and str[i-1] in self._id_chars: i -= 1 if i < pos and (str[i] not in self._id_first_chars or \ keyword.iskeyword(str[i:pos])): i = pos return pos - i def get_expression(self): """Return a string with the Python expression which ends at the given index, which is empty if there is no real one. """ if not self.is_in_code(): raise ValueError("get_expression should only be called if index "\ "is inside a code.") rawtext = self.rawtext bracketing = self.bracketing brck_index = self.indexbracket brck_limit = bracketing[brck_index][0] pos = self.indexinrawtext last_identifier_pos = pos postdot_phase = True while 1: # Eat whitespaces, comments, and if postdot_phase is False - one dot while 1: if pos>brck_limit and rawtext[pos-1] in self._whitespace_chars: # Eat a whitespace pos -= 1 elif not postdot_phase and \ pos > brck_limit and rawtext[pos-1] == '.': # Eat a dot pos -= 1 postdot_phase = True # The next line will fail if we are *inside* a comment, but we # shouldn't be. elif pos == brck_limit and brck_index > 0 and \ rawtext[bracketing[brck_index-1][0]] == '#': # Eat a comment brck_index -= 2 brck_limit = bracketing[brck_index][0] pos = bracketing[brck_index+1][0] else: # If we didn't eat anything, quit. break if not postdot_phase: # We didn't find a dot, so the expression end at the last # identifier pos. break ret = self._eat_identifier(rawtext, brck_limit, pos) if ret: # There is an identifier to eat pos = pos - ret last_identifier_pos = pos # Now, in order to continue the search, we must find a dot. postdot_phase = False # (the loop continues now) elif pos == brck_limit: # We are at a bracketing limit. If it is a closing bracket, # eat the bracket, otherwise, stop the search. level = bracketing[brck_index][1] while brck_index > 0 and bracketing[brck_index-1][1] > level: brck_index -= 1 if bracketing[brck_index][0] == brck_limit: # We were not at the end of a closing bracket break pos = bracketing[brck_index][0] brck_index -= 1 brck_limit = bracketing[brck_index][0] last_identifier_pos = pos if rawtext[pos] in "([": # [] and () may be used after an identifier, so we # continue. postdot_phase is True, so we don't allow a dot. pass else: # We can't continue after other types of brackets break else: # We've found an operator or something. break return rawtext[last_identifier_pos:self.indexinrawtext]
apache-2.0
[ 624, 199, 18727, 2842, 199, 21326, 199, 2765, 859, 7890, 314, 21344, 2842, 1021, 12, 1314, 6571, 19472, 6057, 199, 5807, 367, 314, 10164, 828, 4486, 436, 1163, 5478, 14, 199, 1918, 21344, 2842, 4440, 1611, 2842, 14, 1611, 2842, 365, 11619, 19762, 370, 8120, 2556, 199, 265, 314, 5576, 14311, 402, 1233, 14, 21344, 2842, 10557, 2005, 2556, 641, 314, 199, 6976, 402, 1233, 12, 1202, 701, 5478, 370, 1720, 314, 922, 14, 199, 624, 199, 199, 646, 1059, 199, 646, 4252, 199, 504, 15072, 773, 492, 1611, 4003, 199, 199, 533, 21344, 2842, 26, 339, 347, 636, 826, 721, 277, 12, 5283, 2676, 12, 1478, 304, 267, 408, 9345, 314, 21344, 2842, 370, 19897, 314, 6296, 2363, 780, 402, 314, 1627, 267, 1478, 14, 267, 408, 398, 291, 14, 3773, 2676, 275, 5283, 2676, 267, 291, 14, 505, 275, 1318, 275, 5283, 2676, 14, 505, 398, 1798, 275, 1611, 4003, 14, 2842, 8, 3773, 2676, 14, 3724, 2063, 12, 5283, 2676, 14, 2902, 2063, 9, 398, 347, 1478, 18, 604, 8, 1080, 304, 288, 372, 1109, 8, 1609, 8, 1080, 430, 267, 634, 889, 275, 1478, 18, 604, 8, 505, 14, 1080, 8, 1080, 430, 398, 340, 440, 5283, 2676, 14, 1100, 63, 1180, 63, 1190, 17, 26, 288, 367, 1067, 315, 5283, 2676, 14, 1507, 63, 1100, 63, 1278, 26, 355, 1343, 292, 275, 1390, 8, 76, 889, 446, 1067, 12, 413, 9, 355, 1343, 292, 1080, 275, 4700, 8, 928, 292, 9, 435, 3680, 16, 2, 355, 3631, 292, 1080, 275, 2071, 68, 14, 500, 2, 450, 634, 889, 355, 327, 2136, 1050, 314, 8057, 2952, 1611, 4003, 5074, 282, 8057, 737, 1284, 14, 355, 327, 2136, 1050, 282, 4601, 880, 626, 1478, 7859, 1133, 506, 737, 1284, 402, 1004, 12, 880, 626, 355, 327, 2399, 2004, 911, 506, 314, 2011, 465, 314, 1495, 2544, 652, 12, 340, 1077, 14, 355, 1798, 14, 409, 63, 495, 8, 505, 14, 362, 8, 928, 292, 1080, 12, 3631, 292, 1080, 20731, 971, 78, 358, 355, 330, 364, 275, 1798, 14, 1623, 63, 8302, 63, 1122, 63, 928, 8, 2079, 5283, 2676, 423, 1506, 63, 1560, 63, 262, 63, 875, 63, 1532, 8, 928, 292, 1080, 430, 355, 340, 330, 364, 365, 440, 488, 503, 1343, 292, 508, 413, 26, 490, 2059, 288, 1798, 14, 409, 63, 320, 8, 66, 364, 503, 378, 9, 267, 587, 26, 288, 519, 275, 1318, 14, 1450, 63, 5701, 1842, 480, 6614, 401, 1478, 9, 288, 340, 519, 26, 355, 1343, 292, 1080, 275, 519, 59, 17, 61, 288, 587, 26, 355, 1343, 292, 1080, 275, 298, 17, 14, 16, 2, 288, 3631, 292, 1080, 275, 2071, 68, 14, 500, 2, 450, 634, 889, 288, 327, 2136, 1050, 314, 8057, 2952, 1611, 4003, 5074, 282, 8057, 737, 1284, 14, 288, 327, 2136, 1050, 282, 4601, 880, 626, 1478, 7859, 1133, 506, 737, 1284, 402, 1004, 12, 880, 626, 288, 327, 2399, 2004, 911, 506, 314, 2011, 465, 314, 1495, 2544, 652, 12, 340, 1077, 14, 288, 1798, 14, 409, 63, 495, 8, 505, 14, 362, 8, 928, 292, 1080, 12, 3631, 292, 1080, 20731, 971, 78, 358, 288, 1798, 14, 409, 63, 320, 8, 16, 9, 398, 327, 2136, 2934, 4052, 314, 1798, 965, 12, 871, 367, 314, 2061, 8057, 436, 4601, 14, 267, 291, 14, 1773, 505, 275, 1798, 14, 495, 4439, 18, 61, 267, 327, 3709, 12474, 465, 473, 883, 1937, 12, 1798, 14, 495, 876, 20603, 314, 5164, 781, 787, 315, 12, 267, 327, 880, 626, 3631, 292, 1080, 883, 506, 1202, 370, 31021, 314, 1059, 543, 314, 267, 327, 1318, 5689, 4918, 14, 267, 291, 14, 2379, 292, 1080, 275, 3631, 292, 1080, 267, 291, 14, 14594, 316, 275, 1798, 14, 362, 63, 2019, 63, 9649, 63, 14594, 316, 342, 267, 327, 2342, 1314, 6342, 402, 14540, 316, 787, 16088, 83, 14, 5723, 3544, 17118, 267, 327, 370, 282, 4528, 402, 3066, 505, 14, 267, 291, 14, 374, 11637, 275, 359, 73, 30, 16, 436, 291, 14, 14594, 316, 59, 73, 1527, 17, 61, 690, 291, 14, 14594, 316, 59, 73, 13, 17, 1527, 17, 61, 586, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 14594, 316, 10524, 398, 291, 14, 409, 63, 1080, 8, 1080, 9, 339, 347, 663, 63, 1080, 8, 277, 12, 1478, 304, 267, 408, 1084, 314, 1478, 370, 1314, 314, 3423, 295, 750, 14, 3390, 626, 652, 1471, 506, 267, 315, 314, 2011, 5164, 14, 267, 408, 267, 1478, 262, 1773, 505, 275, 971, 288, 822, 8, 277, 14, 1773, 505, 9, 446, 822, 8, 277, 14, 505, 14, 362, 8, 1080, 12, 291, 14, 2379, 292, 1080, 430, 267, 340, 1478, 262, 1773, 505, 665, 378, 26, 288, 746, 1722, 480, 1918, 1478, 1627, 365, 2544, 314, 5909, 7068, 5164, 531, 267, 291, 14, 1080, 262, 1773, 505, 275, 1478, 262, 1773, 505, 267, 327, 2342, 314, 2451, 2786, 14540, 370, 1314, 1478, 15006, 267, 291, 14, 1080, 14594, 275, 378, 267, 1830, 291, 14, 1080, 14594, 665, 822, 8, 277, 14, 14594, 316, 7216, 17, 436, 971, 1598, 291, 14, 14594, 316, 59, 277, 14, 1080, 14594, 11, 17, 1527, 16, 61, 665, 291, 14, 1080, 262, 1773, 505, 26, 288, 291, 14, 1080, 14594, 847, 413, 267, 340, 291, 14, 1080, 14594, 665, 822, 8, 277, 14, 14594, 316, 7216, 17, 436, 971, 1779, 291, 14, 14594, 316, 59, 277, 14, 1080, 14594, 11, 17, 1527, 16, 61, 508, 291, 14, 1080, 262, 1773, 505, 436, 971, 1779, 440, 291, 14, 374, 11637, 59, 277, 14, 1080, 14594, 11, 17, 2189, 288, 291, 14, 1080, 14594, 847, 413, 339, 347, 365, 63, 262, 63, 875, 8, 277, 304, 267, 408, 1831, 314, 1478, 1627, 370, 314, 21344, 2842, 365, 315, 282, 1059, 30196, 267, 327, 710, 14540, 370, 1314, 781, 13511, 1077, 506, 376, 16088, 14, 267, 327, 982, 652, 1159, 376, 16088, 12, 652, 965, 370, 1172, 282, 4528, 14, 267, 372, 291, 14, 374, 11637, 59, 277, 14, 1080, 14594, 61, 436, 971, 2049, 291, 14, 1773, 505, 59, 277, 14, 14594, 316, 59, 277, 14, 1080, 14594, 1527, 16, 2677, 315 ]
[ 199, 18727, 2842, 199, 21326, 199, 2765, 859, 7890, 314, 21344, 2842, 1021, 12, 1314, 6571, 19472, 6057, 199, 5807, 367, 314, 10164, 828, 4486, 436, 1163, 5478, 14, 199, 1918, 21344, 2842, 4440, 1611, 2842, 14, 1611, 2842, 365, 11619, 19762, 370, 8120, 2556, 199, 265, 314, 5576, 14311, 402, 1233, 14, 21344, 2842, 10557, 2005, 2556, 641, 314, 199, 6976, 402, 1233, 12, 1202, 701, 5478, 370, 1720, 314, 922, 14, 199, 624, 199, 199, 646, 1059, 199, 646, 4252, 199, 504, 15072, 773, 492, 1611, 4003, 199, 199, 533, 21344, 2842, 26, 339, 347, 636, 826, 721, 277, 12, 5283, 2676, 12, 1478, 304, 267, 408, 9345, 314, 21344, 2842, 370, 19897, 314, 6296, 2363, 780, 402, 314, 1627, 267, 1478, 14, 267, 408, 398, 291, 14, 3773, 2676, 275, 5283, 2676, 267, 291, 14, 505, 275, 1318, 275, 5283, 2676, 14, 505, 398, 1798, 275, 1611, 4003, 14, 2842, 8, 3773, 2676, 14, 3724, 2063, 12, 5283, 2676, 14, 2902, 2063, 9, 398, 347, 1478, 18, 604, 8, 1080, 304, 288, 372, 1109, 8, 1609, 8, 1080, 430, 267, 634, 889, 275, 1478, 18, 604, 8, 505, 14, 1080, 8, 1080, 430, 398, 340, 440, 5283, 2676, 14, 1100, 63, 1180, 63, 1190, 17, 26, 288, 367, 1067, 315, 5283, 2676, 14, 1507, 63, 1100, 63, 1278, 26, 355, 1343, 292, 275, 1390, 8, 76, 889, 446, 1067, 12, 413, 9, 355, 1343, 292, 1080, 275, 4700, 8, 928, 292, 9, 435, 3680, 16, 2, 355, 3631, 292, 1080, 275, 2071, 68, 14, 500, 2, 450, 634, 889, 355, 327, 2136, 1050, 314, 8057, 2952, 1611, 4003, 5074, 282, 8057, 737, 1284, 14, 355, 327, 2136, 1050, 282, 4601, 880, 626, 1478, 7859, 1133, 506, 737, 1284, 402, 1004, 12, 880, 626, 355, 327, 2399, 2004, 911, 506, 314, 2011, 465, 314, 1495, 2544, 652, 12, 340, 1077, 14, 355, 1798, 14, 409, 63, 495, 8, 505, 14, 362, 8, 928, 292, 1080, 12, 3631, 292, 1080, 20731, 971, 78, 358, 355, 330, 364, 275, 1798, 14, 1623, 63, 8302, 63, 1122, 63, 928, 8, 2079, 5283, 2676, 423, 1506, 63, 1560, 63, 262, 63, 875, 63, 1532, 8, 928, 292, 1080, 430, 355, 340, 330, 364, 365, 440, 488, 503, 1343, 292, 508, 413, 26, 490, 2059, 288, 1798, 14, 409, 63, 320, 8, 66, 364, 503, 378, 9, 267, 587, 26, 288, 519, 275, 1318, 14, 1450, 63, 5701, 1842, 480, 6614, 401, 1478, 9, 288, 340, 519, 26, 355, 1343, 292, 1080, 275, 519, 59, 17, 61, 288, 587, 26, 355, 1343, 292, 1080, 275, 298, 17, 14, 16, 2, 288, 3631, 292, 1080, 275, 2071, 68, 14, 500, 2, 450, 634, 889, 288, 327, 2136, 1050, 314, 8057, 2952, 1611, 4003, 5074, 282, 8057, 737, 1284, 14, 288, 327, 2136, 1050, 282, 4601, 880, 626, 1478, 7859, 1133, 506, 737, 1284, 402, 1004, 12, 880, 626, 288, 327, 2399, 2004, 911, 506, 314, 2011, 465, 314, 1495, 2544, 652, 12, 340, 1077, 14, 288, 1798, 14, 409, 63, 495, 8, 505, 14, 362, 8, 928, 292, 1080, 12, 3631, 292, 1080, 20731, 971, 78, 358, 288, 1798, 14, 409, 63, 320, 8, 16, 9, 398, 327, 2136, 2934, 4052, 314, 1798, 965, 12, 871, 367, 314, 2061, 8057, 436, 4601, 14, 267, 291, 14, 1773, 505, 275, 1798, 14, 495, 4439, 18, 61, 267, 327, 3709, 12474, 465, 473, 883, 1937, 12, 1798, 14, 495, 876, 20603, 314, 5164, 781, 787, 315, 12, 267, 327, 880, 626, 3631, 292, 1080, 883, 506, 1202, 370, 31021, 314, 1059, 543, 314, 267, 327, 1318, 5689, 4918, 14, 267, 291, 14, 2379, 292, 1080, 275, 3631, 292, 1080, 267, 291, 14, 14594, 316, 275, 1798, 14, 362, 63, 2019, 63, 9649, 63, 14594, 316, 342, 267, 327, 2342, 1314, 6342, 402, 14540, 316, 787, 16088, 83, 14, 5723, 3544, 17118, 267, 327, 370, 282, 4528, 402, 3066, 505, 14, 267, 291, 14, 374, 11637, 275, 359, 73, 30, 16, 436, 291, 14, 14594, 316, 59, 73, 1527, 17, 61, 690, 291, 14, 14594, 316, 59, 73, 13, 17, 1527, 17, 61, 586, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 14594, 316, 10524, 398, 291, 14, 409, 63, 1080, 8, 1080, 9, 339, 347, 663, 63, 1080, 8, 277, 12, 1478, 304, 267, 408, 1084, 314, 1478, 370, 1314, 314, 3423, 295, 750, 14, 3390, 626, 652, 1471, 506, 267, 315, 314, 2011, 5164, 14, 267, 408, 267, 1478, 262, 1773, 505, 275, 971, 288, 822, 8, 277, 14, 1773, 505, 9, 446, 822, 8, 277, 14, 505, 14, 362, 8, 1080, 12, 291, 14, 2379, 292, 1080, 430, 267, 340, 1478, 262, 1773, 505, 665, 378, 26, 288, 746, 1722, 480, 1918, 1478, 1627, 365, 2544, 314, 5909, 7068, 5164, 531, 267, 291, 14, 1080, 262, 1773, 505, 275, 1478, 262, 1773, 505, 267, 327, 2342, 314, 2451, 2786, 14540, 370, 1314, 1478, 15006, 267, 291, 14, 1080, 14594, 275, 378, 267, 1830, 291, 14, 1080, 14594, 665, 822, 8, 277, 14, 14594, 316, 7216, 17, 436, 971, 1598, 291, 14, 14594, 316, 59, 277, 14, 1080, 14594, 11, 17, 1527, 16, 61, 665, 291, 14, 1080, 262, 1773, 505, 26, 288, 291, 14, 1080, 14594, 847, 413, 267, 340, 291, 14, 1080, 14594, 665, 822, 8, 277, 14, 14594, 316, 7216, 17, 436, 971, 1779, 291, 14, 14594, 316, 59, 277, 14, 1080, 14594, 11, 17, 1527, 16, 61, 508, 291, 14, 1080, 262, 1773, 505, 436, 971, 1779, 440, 291, 14, 374, 11637, 59, 277, 14, 1080, 14594, 11, 17, 2189, 288, 291, 14, 1080, 14594, 847, 413, 339, 347, 365, 63, 262, 63, 875, 8, 277, 304, 267, 408, 1831, 314, 1478, 1627, 370, 314, 21344, 2842, 365, 315, 282, 1059, 30196, 267, 327, 710, 14540, 370, 1314, 781, 13511, 1077, 506, 376, 16088, 14, 267, 327, 982, 652, 1159, 376, 16088, 12, 652, 965, 370, 1172, 282, 4528, 14, 267, 372, 291, 14, 374, 11637, 59, 277, 14, 1080, 14594, 61, 436, 971, 2049, 291, 14, 1773, 505, 59, 277, 14, 14594, 316, 59, 277, 14, 1080, 14594, 1527, 16, 2677, 315, 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, 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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 ]
rcosnita/fantastico
fantastico/mvc/tests/itest_model_facade.py
1
10388
''' Copyright 2013 Cosnita Radu Viorel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .. codeauthor:: Radu Viorel Cosnita <radu.cosnita@gmail.com> .. py:module:: fantastico.mvc.tests.itest_model_facade ''' from fantastico import mvc from fantastico.exceptions import FantasticoDbError, FantasticoDbNotFoundError from fantastico.mvc import BASEMODEL from fantastico.mvc.model_facade import ModelFacade from fantastico.mvc.models.model_filter import ModelFilter from fantastico.mvc.models.model_filter_compound import ModelFilterAnd, ModelFilterOr from fantastico.mvc.models.model_sort import ModelSort from fantastico.settings import SettingsFacade from fantastico.tests.base_case import FantasticoIntegrationTestCase from mock import Mock from sqlalchemy.schema import Column from sqlalchemy.types import Integer, Text import uuid class ModelFacadeMessage(BASEMODEL): '''This class is a simple mapping over mvc_model_facade_messages table.''' __tablename__ = "mvc_model_facade_messages" id = Column("id", Integer, primary_key=True, autoincrement=True) message = Column("message", Text) def __init__(self, message): self.message = message class ModelFacadeIntegration(FantasticoIntegrationTestCase): '''This class provides test cases required to guarantee model facade is working as expected.''' MESSAGES = ["Hello world 1", "Hello world 2", "Hello world 3", "Hello world 4"] settings_facade = None model_facade = None last_generated_pk = None entities_created = [] request_id = uuid.uuid4() @classmethod def setup_once(cls): '''This method is invoked once before executing any test case. For model facade we create a series of messages.''' cls.settings_facade = SettingsFacade() mvc.CONN_MANAGER = mvc.init_dm_db_engine(cls.settings_facade.get("database_config"), echo=True) cls.model_facade = ModelFacade(ModelFacadeMessage, mvc.CONN_MANAGER.get_connection(ModelFacadeIntegration.request_id)) @classmethod def cleanup_once(cls): '''This method is invoked once for cleaning up all resources from test suite.''' mvc.CONN_MANAGER.close_connection(ModelFacadeIntegration.request_id) def init(self): '''This method creates a number of messages before each test case.''' for message in ModelFacadeIntegration.MESSAGES: message_entity = self.model_facade.new_model(message=message) message_id = self.model_facade.create(message_entity) assert message_id[0] == message_entity.id assert message_id[0] > 0 self.last_generated_pk = message_id[0] self.entities_created.append(message_entity) records_count = self.model_facade.count_records(ModelFilter(ModelFacadeMessage.id, 0, ModelFilter.GT)) self.assertEqual(len(self.MESSAGES), records_count) def cleanup(self): '''This method is invoked after each test case in order to remove all added messages.''' for entity in self.entities_created: self.model_facade.delete(entity) self.assertEqual(0, self.model_facade.count_records()) def test_retrieve_message_bypk(self): '''This test case ensures filtering message by primary key works.''' message = self.model_facade.find_by_pk({ModelFacadeMessage.id: self.last_generated_pk}) self.assertIsNotNone(message) self.assertEqual(self.MESSAGES[-1], message.message) def test_retrieve_message_bypk_notfound(self): '''This test case ensures an exception is raised if a record is not found.''' with self.assertRaises(FantasticoDbNotFoundError): self.model_facade.find_by_pk({ModelFacadeMessage.id: -1}) def test_retrieve_message_byfilter_and(self): '''This test case ensures filtering message using compound **and** works as expected.''' model_filter_gt = ModelFilter(ModelFacadeMessage.id, 1, ModelFilter.GT) model_filter_like = ModelFilter(ModelFacadeMessage.message, "%%world 4%%", ModelFilter.LIKE) model_filter_and = ModelFilterAnd(model_filter_gt, model_filter_like) records = self.model_facade.get_records_paged(0, 100, filter_expr=model_filter_and) self.assertEqual(1, len(records)) self.assertEqual(self.last_generated_pk, records[0].id) self.assertEqual(self.MESSAGES[-1], records[0].message) def test_retrieve_message_byfilter_or(self): '''This test case ensures filtering message using compound **or** works as expected.''' model_filter_gt = ModelFilter(ModelFacadeMessage.id, self.last_generated_pk, ModelFilter.GT) model_filter_ge = ModelFilter(ModelFacadeMessage.id, self.last_generated_pk + 1, ModelFilter.GT) model_filter_eq = ModelFilter(ModelFacadeMessage.id, 1, ModelFilter.EQ) model_filter_lt = ModelFilter(ModelFacadeMessage.id, -1, ModelFilter.LT) model_filter_le = ModelFilter(ModelFacadeMessage.id, -1, ModelFilter.LE) model_filter_like = ModelFilter(ModelFacadeMessage.message, "%%world 4%%", ModelFilter.LIKE) model_filter_or = ModelFilterOr(model_filter_gt, model_filter_ge, model_filter_eq, model_filter_like, model_filter_lt, model_filter_le) records = self.model_facade.get_records_paged(0, 100, filter_expr=model_filter_or) self.assertEqual(1, len(records)) self.assertEqual(self.last_generated_pk, records[0].id) self.assertEqual(self.MESSAGES[-1], records[0].message) def test_retrieve_subset_ordered_desc(self): '''This test case ensures subset records retrieval work as expected for desc order.''' model_filter_like = ModelFilter(ModelFacadeMessage.message, "%%world%%", ModelFilter.LIKE) model_sort = ModelSort(ModelFacadeMessage.message, ModelSort.DESC) records = self.model_facade.get_records_paged(1, 3, filter_expr=model_filter_like, sort_expr=model_sort) self.assertIsNotNone(records) self.assertEqual(2, len(records)) self.assertEqual(self.MESSAGES[-2], records[0].message) self.assertEqual(self.MESSAGES[-3], records[1].message) self.assertLess(records[1].id, records[0].id) def test_retrieve_subset_ordered_asc(self): '''This test case ensures subset records retrieval work as expected for asc order.''' model_filter_like = ModelFilter(ModelFacadeMessage.message, "%%world%%", ModelFilter.LIKE) model_sort = ModelSort(ModelFacadeMessage.message, ModelSort.ASC) records = self.model_facade.get_records_paged(1, 3, filter_expr=model_filter_like, sort_expr=model_sort) self.assertIsNotNone(records) self.assertEqual(2, len(records)) self.assertEqual(self.MESSAGES[1], records[0].message) self.assertEqual(self.MESSAGES[2], records[1].message) self.assertLess(records[0].id, records[1].id) def test_retrieve_subset_ordered_asc_in(self): '''This test case ensures a subset of records is retrieved correctly when order expression and in filter are specified.''' model_filter_in = ModelFilter(ModelFacadeMessage.message, ["Hello world 2", "Hello world 3"], ModelFilter.IN) model_sort = ModelSort(ModelFacadeMessage.message, ModelSort.ASC) records = self.model_facade.get_records_paged(1, 2, filter_expr=model_filter_in, sort_expr=model_sort) self.assertIsNotNone(records) self.assertEqual(1, len(records)) self.assertEqual(self.MESSAGES[-2], records[0].message) def test_create_duplicate(self): '''This test case ensure duplicate records insert attempt result in an exception.''' model = self.model_facade.new_model(message="duplicate entry") model.id = self.last_generated_pk with self.assertRaises(FantasticoDbError): self.model_facade.create(model) def test_update_entry(self): '''This test case ensures updating a record work as expected.''' model = self.model_facade.new_model(message="update sequence") try: self.model_facade.create(model) self.assertGreater(model.id, self.last_generated_pk) model.message = "simple message" self.model_facade.update(model) model = self.model_facade.find_by_pk({ModelFacadeMessage.id: model.id}) self.assertIsNotNone(model) self.assertEqual("simple message", model.message) finally: self.model_facade.delete(model) def test_count_records_exception_unhandled(self): '''This integration test make sure an unhandled exception is converted into a db error.''' filter = Mock() filter.build = Mock(side_effect=Exception("Unhandled exception")) with self.assertRaises(FantasticoDbError): self.model_facade.count_records(filter)
mit
[ 2344, 199, 7384, 6171, 445, 736, 78, 21492, 820, 350, 85, 6561, 720, 76, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 221, 199, 9970, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 221, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 221, 199, 460, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 221, 199, 55, 2007, 2563, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 221, 199, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 221, 199, 689, 6978, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 703, 1233, 2502, 447, 820, 350, 85, 6561, 720, 76, 445, 736, 78, 21492, 665, 345, 2033, 14, 331, 5167, 21492, 32, 6799, 14, 957, 30, 199, 703, 1134, 26, 578, 447, 13758, 502, 270, 12802, 14, 77, 6737, 14, 2219, 14, 73, 396, 63, 1238, 63, 12668, 9587, 199, 2344, 199, 504, 13758, 502, 270, 12802, 492, 333, 6737, 199, 504, 13758, 502, 270, 12802, 14, 3924, 492, 481, 290, 502, 270, 12802, 8882, 547, 12, 481, 290, 502, 270, 12802, 8882, 10870, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 492, 19721, 11429, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 1238, 63, 12668, 9587, 492, 5822, 38, 645, 9587, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 1541, 492, 5822, 4131, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 1541, 63, 15278, 492, 5822, 4131, 3325, 12, 5822, 4131, 2844, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 3191, 492, 5822, 14376, 199, 504, 13758, 502, 270, 12802, 14, 1751, 492, 13303, 38, 645, 9587, 199, 504, 13758, 502, 270, 12802, 14, 2219, 14, 1095, 63, 2546, 492, 481, 290, 502, 270, 12802, 20405, 1746, 199, 504, 1683, 492, 4420, 199, 504, 8335, 14, 3629, 492, 4996, 199, 504, 8335, 14, 1313, 492, 7225, 12, 4516, 199, 646, 5377, 199, 199, 533, 5822, 38, 645, 9587, 2209, 8, 5825, 11429, 304, 272, 1449, 2765, 1021, 365, 282, 3486, 4412, 1806, 333, 6737, 63, 1238, 63, 12668, 9587, 63, 3431, 1817, 10595, 2286, 636, 10983, 363, 275, 298, 77, 6737, 63, 1238, 63, 12668, 9587, 63, 3431, 2, 2286, 1305, 275, 4996, 480, 344, 401, 7225, 12, 5062, 63, 498, 29, 549, 12, 32497, 29, 549, 9, 272, 1245, 275, 4996, 480, 1188, 401, 4516, 9, 2286, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 291, 14, 1188, 275, 1245, 199, 199, 533, 5822, 38, 645, 9587, 20405, 8, 29745, 502, 270, 12802, 20405, 1746, 304, 272, 1449, 2765, 1021, 6571, 511, 5560, 1415, 370, 24197, 1402, 21625, 9587, 365, 6449, 465, 1420, 10595, 2286, 603, 1608, 5383, 275, 2097, 6257, 6701, 413, 401, 298, 6257, 6701, 499, 401, 298, 6257, 6701, 650, 401, 298, 6257, 6701, 841, 937, 2286, 2202, 63, 12668, 9587, 275, 488, 272, 1402, 63, 12668, 9587, 275, 488, 272, 2061, 63, 10176, 63, 2051, 275, 488, 272, 9045, 63, 3966, 275, 942, 272, 1056, 63, 344, 275, 5377, 14, 2580, 20, 342, 2286, 768, 3744, 272, 347, 3272, 63, 5089, 8, 1886, 304, 267, 1449, 2765, 1083, 365, 10302, 5403, 2544, 14043, 1263, 511, 1930, 14, 2104, 1402, 21625, 9587, 781, 1218, 282, 6779, 402, 3788, 10595, 2728, 843, 14, 1751, 63, 12668, 9587, 275, 13303, 38, 645, 9587, 342, 267, 333, 6737, 14, 17489, 63, 28541, 275, 333, 6737, 14, 826, 63, 6428, 63, 697, 63, 3908, 8, 1886, 14, 1751, 63, 12668, 9587, 14, 362, 480, 4659, 63, 888, 1288, 11343, 29, 549, 9, 2728, 843, 14, 1238, 63, 12668, 9587, 275, 5822, 38, 645, 9587, 8, 1685, 38, 645, 9587, 2209, 12, 221, 4318, 333, 6737, 14, 17489, 63, 28541, 14, 362, 63, 2105, 8, 1685, 38, 645, 9587, 20405, 14, 1069, 63, 344, 430, 2286, 768, 3744, 272, 347, 9058, 63, 5089, 8, 1886, 304, 267, 1449, 2765, 1083, 365, 10302, 5403, 367, 29579, 1536, 1006, 5944, 687, 511, 5241, 10595, 2728, 333, 6737, 14, 17489, 63, 28541, 14, 1600, 63, 2105, 8, 1685, 38, 645, 9587, 20405, 14, 1069, 63, 344, 9, 2286, 347, 4205, 8, 277, 304, 267, 1449, 2765, 1083, 8491, 282, 1329, 402, 3788, 2544, 1924, 511, 1930, 10595, 2728, 367, 1245, 315, 5822, 38, 645, 9587, 20405, 14, 23229, 26, 288, 1245, 63, 4502, 275, 291, 14, 1238, 63, 12668, 9587, 14, 1222, 63, 1238, 8, 1188, 29, 1188, 9, 288, 1245, 63, 344, 275, 291, 14, 1238, 63, 12668, 9587, 14, 981, 8, 1188, 63, 4502, 9, 7846, 702, 1245, 63, 344, 59, 16, 61, 508, 1245, 63, 4502, 14, 344, 288, 702, 1245, 63, 344, 59, 16, 61, 690, 378, 7846, 291, 14, 2019, 63, 10176, 63, 2051, 275, 1245, 63, 344, 59, 16, 61, 288, 291, 14, 8327, 63, 3966, 14, 740, 8, 1188, 63, 4502, 9, 2728, 5767, 63, 835, 275, 291, 14, 1238, 63, 12668, 9587, 14, 835, 63, 6502, 8, 1685, 4131, 8, 1685, 38, 645, 9587, 2209, 14, 344, 12, 378, 12, 5822, 4131, 14, 8391, 430, 267, 291, 14, 629, 8, 552, 8, 277, 14, 23229, 395, 5767, 63, 835, 9, 15567, 347, 9058, 8, 277, 304, 267, 1449, 2765, 1083, 365, 10302, 2410, 1924, 511, 1930, 315, 1865, 370, 2813, 1006, 3483, 3788, 10595, 2728, 367 ]
[ 199, 7384, 6171, 445, 736, 78, 21492, 820, 350, 85, 6561, 720, 76, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 221, 199, 9970, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 221, 199, 1589, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 221, 199, 460, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 221, 199, 55, 2007, 2563, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 221, 199, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 221, 199, 689, 6978, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 703, 1233, 2502, 447, 820, 350, 85, 6561, 720, 76, 445, 736, 78, 21492, 665, 345, 2033, 14, 331, 5167, 21492, 32, 6799, 14, 957, 30, 199, 703, 1134, 26, 578, 447, 13758, 502, 270, 12802, 14, 77, 6737, 14, 2219, 14, 73, 396, 63, 1238, 63, 12668, 9587, 199, 2344, 199, 504, 13758, 502, 270, 12802, 492, 333, 6737, 199, 504, 13758, 502, 270, 12802, 14, 3924, 492, 481, 290, 502, 270, 12802, 8882, 547, 12, 481, 290, 502, 270, 12802, 8882, 10870, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 492, 19721, 11429, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 1238, 63, 12668, 9587, 492, 5822, 38, 645, 9587, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 1541, 492, 5822, 4131, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 1541, 63, 15278, 492, 5822, 4131, 3325, 12, 5822, 4131, 2844, 199, 504, 13758, 502, 270, 12802, 14, 77, 6737, 14, 992, 14, 1238, 63, 3191, 492, 5822, 14376, 199, 504, 13758, 502, 270, 12802, 14, 1751, 492, 13303, 38, 645, 9587, 199, 504, 13758, 502, 270, 12802, 14, 2219, 14, 1095, 63, 2546, 492, 481, 290, 502, 270, 12802, 20405, 1746, 199, 504, 1683, 492, 4420, 199, 504, 8335, 14, 3629, 492, 4996, 199, 504, 8335, 14, 1313, 492, 7225, 12, 4516, 199, 646, 5377, 199, 199, 533, 5822, 38, 645, 9587, 2209, 8, 5825, 11429, 304, 272, 1449, 2765, 1021, 365, 282, 3486, 4412, 1806, 333, 6737, 63, 1238, 63, 12668, 9587, 63, 3431, 1817, 10595, 2286, 636, 10983, 363, 275, 298, 77, 6737, 63, 1238, 63, 12668, 9587, 63, 3431, 2, 2286, 1305, 275, 4996, 480, 344, 401, 7225, 12, 5062, 63, 498, 29, 549, 12, 32497, 29, 549, 9, 272, 1245, 275, 4996, 480, 1188, 401, 4516, 9, 2286, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 291, 14, 1188, 275, 1245, 199, 199, 533, 5822, 38, 645, 9587, 20405, 8, 29745, 502, 270, 12802, 20405, 1746, 304, 272, 1449, 2765, 1021, 6571, 511, 5560, 1415, 370, 24197, 1402, 21625, 9587, 365, 6449, 465, 1420, 10595, 2286, 603, 1608, 5383, 275, 2097, 6257, 6701, 413, 401, 298, 6257, 6701, 499, 401, 298, 6257, 6701, 650, 401, 298, 6257, 6701, 841, 937, 2286, 2202, 63, 12668, 9587, 275, 488, 272, 1402, 63, 12668, 9587, 275, 488, 272, 2061, 63, 10176, 63, 2051, 275, 488, 272, 9045, 63, 3966, 275, 942, 272, 1056, 63, 344, 275, 5377, 14, 2580, 20, 342, 2286, 768, 3744, 272, 347, 3272, 63, 5089, 8, 1886, 304, 267, 1449, 2765, 1083, 365, 10302, 5403, 2544, 14043, 1263, 511, 1930, 14, 2104, 1402, 21625, 9587, 781, 1218, 282, 6779, 402, 3788, 10595, 2728, 843, 14, 1751, 63, 12668, 9587, 275, 13303, 38, 645, 9587, 342, 267, 333, 6737, 14, 17489, 63, 28541, 275, 333, 6737, 14, 826, 63, 6428, 63, 697, 63, 3908, 8, 1886, 14, 1751, 63, 12668, 9587, 14, 362, 480, 4659, 63, 888, 1288, 11343, 29, 549, 9, 2728, 843, 14, 1238, 63, 12668, 9587, 275, 5822, 38, 645, 9587, 8, 1685, 38, 645, 9587, 2209, 12, 221, 4318, 333, 6737, 14, 17489, 63, 28541, 14, 362, 63, 2105, 8, 1685, 38, 645, 9587, 20405, 14, 1069, 63, 344, 430, 2286, 768, 3744, 272, 347, 9058, 63, 5089, 8, 1886, 304, 267, 1449, 2765, 1083, 365, 10302, 5403, 367, 29579, 1536, 1006, 5944, 687, 511, 5241, 10595, 2728, 333, 6737, 14, 17489, 63, 28541, 14, 1600, 63, 2105, 8, 1685, 38, 645, 9587, 20405, 14, 1069, 63, 344, 9, 2286, 347, 4205, 8, 277, 304, 267, 1449, 2765, 1083, 8491, 282, 1329, 402, 3788, 2544, 1924, 511, 1930, 10595, 2728, 367, 1245, 315, 5822, 38, 645, 9587, 20405, 14, 23229, 26, 288, 1245, 63, 4502, 275, 291, 14, 1238, 63, 12668, 9587, 14, 1222, 63, 1238, 8, 1188, 29, 1188, 9, 288, 1245, 63, 344, 275, 291, 14, 1238, 63, 12668, 9587, 14, 981, 8, 1188, 63, 4502, 9, 7846, 702, 1245, 63, 344, 59, 16, 61, 508, 1245, 63, 4502, 14, 344, 288, 702, 1245, 63, 344, 59, 16, 61, 690, 378, 7846, 291, 14, 2019, 63, 10176, 63, 2051, 275, 1245, 63, 344, 59, 16, 61, 288, 291, 14, 8327, 63, 3966, 14, 740, 8, 1188, 63, 4502, 9, 2728, 5767, 63, 835, 275, 291, 14, 1238, 63, 12668, 9587, 14, 835, 63, 6502, 8, 1685, 4131, 8, 1685, 38, 645, 9587, 2209, 14, 344, 12, 378, 12, 5822, 4131, 14, 8391, 430, 267, 291, 14, 629, 8, 552, 8, 277, 14, 23229, 395, 5767, 63, 835, 9, 15567, 347, 9058, 8, 277, 304, 267, 1449, 2765, 1083, 365, 10302, 2410, 1924, 511, 1930, 315, 1865, 370, 2813, 1006, 3483, 3788, 10595, 2728, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ode_literals from django.contrib.gis.db.models import fields from django.core.exceptions import ImproperlyConfigured from django.db import connection, migrations, models from django.db.migrations.migration import Migration from django.db.migrations.state import ProjectState from django.test import ( TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from ..utils import mysql if connection.features.gis_enabled: try: GeometryColumns = connection.ops.geometry_columns() HAS_GEOMETRY_COLUMNS = True except NotImplementedError: HAS_GEOMETRY_COLUMNS = False @skipUnlessDBFeature('gis_enabled') class OperationTests(TransactionTestCase): available_apps = ['gis_tests.gis_migrations'] def tearDown(self): # Delete table after testing if hasattr(self, 'current_state'): self.apply_operations('gis', self.current_state, [migrations.DeleteModel('Neighborhood')]) super(OperationTests, self).tearDown() def get_table_description(self, table): with connection.cursor() as cursor: return connection.introspection.get_table_description(cursor, table) def assertColumnExists(self, table, column): self.assertIn(column, [c.name for c in self.get_table_description(table)]) def assertColumnNotExists(self, table, column): self.assertNotIn(column, [c.name for c in self.get_table_description(table)]) def apply_operations(self, app_label, project_state, operations): migration = Migration('name', app_label) migration.operations = operations with connection.schema_editor() as editor: return migration.apply(project_state, editor) def set_up_test_model(self, force_raster_creation=False): test_fields = [ ('id', models.AutoField(primary_key=True)), ('name', models.CharField(max_length=100, unique=True)), ('geom', fields.MultiPolygonField(srid=4326)) ] if connection.features.supports_raster or force_raster_creation: test_fields += [('rast', fields.RasterField(srid=4326))] operations = [migrations.CreateModel('Neighborhood', test_fields)] return self.apply_operations('gis', ProjectState(), operations) def assertGeometryColumnsCount(self, expected_count): table_name = 'gis_neighborhood' if connection.features.uppercases_column_names: table_name = table_name.upper() self.assertEqual( GeometryColumns.objects.filter(**{ GeometryColumns.table_name_col(): table_name, }).count(), expected_count ) def assertSpatialIndexExists(self, table, column): with connection.cursor() as cursor: indexes = connection.introspection.get_indexes(cursor, table) self.assertIn(column, indexes) def alter_gis_model(self, migration_class, model_name, field_name, blank=False, field_class=None): project_state = self.set_up_test_model() self.current_state = project_state args = [model_name, field_name] if field_class: args.append(field_class(srid=4326, blank=blank)) operation = migration_class(*args) new_state = project_state.clone() operation.state_forwards('gis', new_state) with connection.schema_editor() as editor: operation.database_forwards('gis', editor, project_state, new_state) self.current_state = new_state def test_add_geom_field(self): """ Test the AddField operation with a geometry-enabled column. """ self.alter_gis_model(migrations.AddField, 'Neighborhood', 'path', False, fields.LineStringField) self.assertColumnExists('gis_neighborhood', 'path') # Test GeometryColumns when available if HAS_GEOMETRY_COLUMNS: self.assertGeometryColumnsCount(2) # Test spatial indices when available if self.has_spatial_indexes: self.assertSpatialIndexExists('gis_neighborhood', 'path') @skipUnlessDBFeature('supports_raster') def test_add_raster_field(self): """ Test the AddField operation with a raster-enabled column. """ self.alter_gis_model(migrations.AddField, 'Neighborhood', 'heatmap', False, fields.RasterField) self.assertColumnExists('gis_neighborhood', 'heatmap') # Test spatial indices when available if self.has_spatial_indexes: self.assertSpatialIndexExists('gis_neighborhood', 'heatmap') @skipIfDBFeature('supports_raster') def test_create_raster_model_on_db_without_raster_support(self): """ Test creating a model with a raster field on a db without raster support. """ msg = 'Raster fields require backends with raster support.' with self.assertRaisesMessage(ImproperlyConfigured, msg): self.set_up_test_model(True) @skipIfDBFeature('supports_raster') def test_add_raster_field_on_db_without_raster_support(self): """ Test adding a raster field on a db without raster support. """ msg = 'Raster fields require backends with raster support.' with self.assertRaisesMessage(ImproperlyConfigured, msg): self.alter_gis_model( migrations.AddField, 'Neighborhood', 'heatmap', False, fields.RasterField ) def test_add_blank_geom_field(self): """ Should be able to add a GeometryField with blank=True. """ self.alter_gis_model(migrations.AddField, 'Neighborhood', 'path', True, fields.LineStringField) self.assertColumnExists('gis_neighborhood', 'path') # Test GeometryColumns when available if HAS_GEOMETRY_COLUMNS: self.assertGeometryColumnsCount(2) # Test spatial indices when available if self.has_spatial_indexes: self.assertSpatialIndexExists('gis_neighborhood', 'path') @skipUnlessDBFeature('supports_raster') def test_add_blank_raster_field(self): """ Should be able to add a RasterField with blank=True. """ self.alter_gis_model(migrations.AddField, 'Neighborhood', 'heatmap', True, fields.RasterField) self.assertColumnExists('gis_neighborhood', 'heatmap') # Test spatial indices when available if self.has_spatial_indexes: self.assertSpatialIndexExists('gis_neighborhood', 'heatmap') def test_remove_geom_field(self): """ Test the RemoveField operation with a geometry-enabled column. """ self.alter_gis_model(migrations.RemoveField, 'Neighborhood', 'geom') self.assertColumnNotExists('gis_neighborhood', 'geom') # Test GeometryColumns when available if HAS_GEOMETRY_COLUMNS: self.assertGeometryColumnsCount(0) @skipUnlessDBFeature('supports_raster') def test_remove_raster_field(self): """ Test the RemoveField operation with a raster-enabled column. """ self.alter_gis_model(migrations.RemoveField, 'Neighborhood', 'rast') self.assertColumnNotExists('gis_neighborhood', 'rast') def test_create_model_spatial_index(self): self.current_state = self.set_up_test_model() if not self.has_spatial_indexes: self.skipTest('No support for Spatial indexes') self.assertSpatialIndexExists('gis_neighborhood', 'geom') if connection.features.supports_raster: self.assertSpatialIndexExists('gis_neighborhood', 'rast') @property def has_spatial_indexes(self): if mysql: with connection.cursor() as cursor: return connection.introspection.supports_spatial_index(cursor, 'gis_neighborhood') return True
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 1504, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 8998, 492, 12090, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 12, 199, 9, 199, 199, 504, 2508, 1208, 492, 12896, 199, 199, 692, 1950, 14, 3179, 14, 5668, 63, 3827, 26, 272, 862, 26, 267, 10579, 15086, 275, 1950, 14, 1483, 14, 7660, 63, 3406, 342, 267, 7509, 63, 28472, 63, 28427, 275, 715, 272, 871, 4279, 26, 267, 7509, 63, 28472, 63, 28427, 275, 756, 421, 199, 32, 22424, 360, 5668, 63, 3827, 358, 199, 533, 17954, 2925, 8, 10161, 1746, 304, 272, 2808, 63, 5181, 275, 788, 5668, 63, 2219, 14, 5668, 63, 7685, 418, 339, 347, 6766, 8, 277, 304, 267, 327, 8496, 1817, 2410, 5343, 267, 340, 2688, 8, 277, 12, 283, 1818, 63, 929, 735, 288, 291, 14, 4998, 63, 8170, 360, 5668, 297, 291, 14, 1818, 63, 929, 12, 359, 7685, 14, 5392, 1685, 360, 13779, 10422, 2023, 267, 1613, 8, 6044, 2925, 12, 291, 680, 12336, 342, 339, 347, 664, 63, 1224, 63, 1802, 8, 277, 12, 1817, 304, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 372, 1950, 14, 21627, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 9, 339, 347, 702, 4547, 7965, 8, 277, 12, 1817, 12, 2763, 304, 267, 291, 14, 4080, 8, 2301, 12, 359, 67, 14, 354, 367, 286, 315, 291, 14, 362, 63, 1224, 63, 1802, 8, 1224, 3948, 339, 347, 702, 4547, 25095, 8, 277, 12, 1817, 12, 2763, 304, 267, 291, 14, 8795, 8, 2301, 12, 359, 67, 14, 354, 367, 286, 315, 291, 14, 362, 63, 1224, 63, 1802, 8, 1224, 3948, 339, 347, 4838, 63, 8170, 8, 277, 12, 1145, 63, 1302, 12, 2199, 63, 929, 12, 5331, 304, 267, 8367, 275, 12090, 360, 354, 297, 1145, 63, 1302, 9, 267, 8367, 14, 8170, 275, 5331, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 372, 8367, 14, 4998, 8, 1715, 63, 929, 12, 8823, 9, 339, 347, 663, 63, 384, 63, 396, 63, 1238, 8, 277, 12, 3542, 63, 20876, 63, 8782, 29, 797, 304, 267, 511, 63, 955, 275, 359, 288, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 3747, 29, 549, 1826, 288, 661, 6481, 297, 1504, 14, 3947, 12367, 792, 8, 10498, 29, 17948, 430, 267, 1622, 267, 340, 1950, 14, 3179, 14, 9823, 63, 20876, 503, 3542, 63, 20876, 63, 8782, 26, 288, 511, 63, 955, 847, 4274, 345, 270, 297, 1504, 14, 13284, 792, 8, 10498, 29, 17948, 10524, 267, 5331, 275, 359, 7685, 14, 14907, 360, 13779, 10422, 297, 511, 63, 955, 1874, 267, 372, 291, 14, 4998, 63, 8170, 360, 5668, 297, 7290, 2223, 1062, 5331, 9, 339, 347, 702, 6831, 15086, 2353, 8, 277, 12, 1420, 63, 835, 304, 267, 1817, 63, 354, 275, 283, 5668, 63, 13881, 10422, 7, 267, 340, 1950, 14, 3179, 14, 4142, 9403, 63, 2301, 63, 1247, 26, 288, 1817, 63, 354, 275, 1817, 63, 354, 14, 4142, 342, 267, 291, 14, 629, 8, 288, 10579, 15086, 14, 1462, 14, 1541, 25679, 355, 10579, 15086, 14, 1224, 63, 354, 63, 761, 837, 1817, 63, 354, 12, 288, 789, 680, 835, 1062, 288, 1420, 63, 835, 267, 776, 339, 347, 702, 18075, 2681, 7965, 8, 277, 12, 1817, 12, 2763, 304, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 10507, 275, 1950, 14, 21627, 14, 362, 63, 10116, 8, 3937, 12, 1817, 9, 267, 291, 14, 4080, 8, 2301, 12, 10507, 9, 339, 347, 17355, 63, 5668, 63, 1238, 8, 277, 12, 8367, 63, 533, 12, 1402, 63, 354, 12, 901, 63, 354, 12, 288, 4596, 29, 797, 12, 901, 63, 533, 29, 403, 304, 267, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 342, 267, 291, 14, 1818, 63, 929, 275, 2199, 63, 929, 267, 1249, 275, 359, 1238, 63, 354, 12, 901, 63, 354, 61, 267, 340, 901, 63, 533, 26, 288, 1249, 14, 740, 8, 698, 63, 533, 8, 10498, 29, 17948, 12, 4596, 29, 2500, 430, 267, 3439, 275, 8367, 63, 533, 2031, 589, 9, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 360, 5668, 297, 892, 63, 929, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 360, 5668, 297, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 291, 14, 1818, 63, 929, 275, 892, 63, 929, 339, 347, 511, 63, 525, 63, 6481, 63, 698, 8, 277, 304, 267, 408, 267, 1379, 314, 2654, 792, 3439, 543, 282, 3400, 13, 3827, 2763, 14, 267, 408, 267, 291, 14, 11858, 63, 5668, 63, 1238, 8, 7685, 14, 18381, 12, 283, 13779, 10422, 297, 288, 283, 515, 297, 756, 12, 1504, 14, 3049, 14912, 9, 267, 291, 14, 479, 4547, 7965, 360, 5668, 63, 13881, 10422, 297, 283, 515, 358, 398, 327, 1379, 10579, 15086, 1380, 2808, 267, 340, 7509, 63, 28472, 63, 28427, 26, 288, 291, 14, 479, 6831, 15086, 2353, 8, 18, 9, 398, 327, 1379, 11469, 4918, 1380, 2808, 267, 340, 291, 14, 1989, 63, 11679, 63, 10116, 26, 288, 291, 14, 479, 18075, 2681, 7965, 360, 5668, 63, 13881, 10422, 297, 283, 515, 358, 339, 768, 22424, 360, 9823, 63, 20876, 358, 272, 347, 511, 63, 525, 63, 20876, 63, 698, 8, 277, 304, 267, 408, 267, 1379, 314, 2654, 792, 3439, 543, 282, 19775, 13, 3827, 2763, 14, 267, 408, 267, 291, 14, 11858, 63, 5668, 63, 1238, 8, 7685, 14, 18381, 12, 283, 13779, 10422, 297, 288, 283, 16614, 1130, 297, 756, 12, 1504, 14, 13284 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 1504, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 8998, 492, 12090, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 12, 199, 9, 199, 199, 504, 2508, 1208, 492, 12896, 199, 199, 692, 1950, 14, 3179, 14, 5668, 63, 3827, 26, 272, 862, 26, 267, 10579, 15086, 275, 1950, 14, 1483, 14, 7660, 63, 3406, 342, 267, 7509, 63, 28472, 63, 28427, 275, 715, 272, 871, 4279, 26, 267, 7509, 63, 28472, 63, 28427, 275, 756, 421, 199, 32, 22424, 360, 5668, 63, 3827, 358, 199, 533, 17954, 2925, 8, 10161, 1746, 304, 272, 2808, 63, 5181, 275, 788, 5668, 63, 2219, 14, 5668, 63, 7685, 418, 339, 347, 6766, 8, 277, 304, 267, 327, 8496, 1817, 2410, 5343, 267, 340, 2688, 8, 277, 12, 283, 1818, 63, 929, 735, 288, 291, 14, 4998, 63, 8170, 360, 5668, 297, 291, 14, 1818, 63, 929, 12, 359, 7685, 14, 5392, 1685, 360, 13779, 10422, 2023, 267, 1613, 8, 6044, 2925, 12, 291, 680, 12336, 342, 339, 347, 664, 63, 1224, 63, 1802, 8, 277, 12, 1817, 304, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 372, 1950, 14, 21627, 14, 362, 63, 1224, 63, 1802, 8, 3937, 12, 1817, 9, 339, 347, 702, 4547, 7965, 8, 277, 12, 1817, 12, 2763, 304, 267, 291, 14, 4080, 8, 2301, 12, 359, 67, 14, 354, 367, 286, 315, 291, 14, 362, 63, 1224, 63, 1802, 8, 1224, 3948, 339, 347, 702, 4547, 25095, 8, 277, 12, 1817, 12, 2763, 304, 267, 291, 14, 8795, 8, 2301, 12, 359, 67, 14, 354, 367, 286, 315, 291, 14, 362, 63, 1224, 63, 1802, 8, 1224, 3948, 339, 347, 4838, 63, 8170, 8, 277, 12, 1145, 63, 1302, 12, 2199, 63, 929, 12, 5331, 304, 267, 8367, 275, 12090, 360, 354, 297, 1145, 63, 1302, 9, 267, 8367, 14, 8170, 275, 5331, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 372, 8367, 14, 4998, 8, 1715, 63, 929, 12, 8823, 9, 339, 347, 663, 63, 384, 63, 396, 63, 1238, 8, 277, 12, 3542, 63, 20876, 63, 8782, 29, 797, 304, 267, 511, 63, 955, 275, 359, 288, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 3747, 29, 549, 1826, 288, 661, 6481, 297, 1504, 14, 3947, 12367, 792, 8, 10498, 29, 17948, 430, 267, 1622, 267, 340, 1950, 14, 3179, 14, 9823, 63, 20876, 503, 3542, 63, 20876, 63, 8782, 26, 288, 511, 63, 955, 847, 4274, 345, 270, 297, 1504, 14, 13284, 792, 8, 10498, 29, 17948, 10524, 267, 5331, 275, 359, 7685, 14, 14907, 360, 13779, 10422, 297, 511, 63, 955, 1874, 267, 372, 291, 14, 4998, 63, 8170, 360, 5668, 297, 7290, 2223, 1062, 5331, 9, 339, 347, 702, 6831, 15086, 2353, 8, 277, 12, 1420, 63, 835, 304, 267, 1817, 63, 354, 275, 283, 5668, 63, 13881, 10422, 7, 267, 340, 1950, 14, 3179, 14, 4142, 9403, 63, 2301, 63, 1247, 26, 288, 1817, 63, 354, 275, 1817, 63, 354, 14, 4142, 342, 267, 291, 14, 629, 8, 288, 10579, 15086, 14, 1462, 14, 1541, 25679, 355, 10579, 15086, 14, 1224, 63, 354, 63, 761, 837, 1817, 63, 354, 12, 288, 789, 680, 835, 1062, 288, 1420, 63, 835, 267, 776, 339, 347, 702, 18075, 2681, 7965, 8, 277, 12, 1817, 12, 2763, 304, 267, 543, 1950, 14, 3937, 342, 465, 3920, 26, 288, 10507, 275, 1950, 14, 21627, 14, 362, 63, 10116, 8, 3937, 12, 1817, 9, 267, 291, 14, 4080, 8, 2301, 12, 10507, 9, 339, 347, 17355, 63, 5668, 63, 1238, 8, 277, 12, 8367, 63, 533, 12, 1402, 63, 354, 12, 901, 63, 354, 12, 288, 4596, 29, 797, 12, 901, 63, 533, 29, 403, 304, 267, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 342, 267, 291, 14, 1818, 63, 929, 275, 2199, 63, 929, 267, 1249, 275, 359, 1238, 63, 354, 12, 901, 63, 354, 61, 267, 340, 901, 63, 533, 26, 288, 1249, 14, 740, 8, 698, 63, 533, 8, 10498, 29, 17948, 12, 4596, 29, 2500, 430, 267, 3439, 275, 8367, 63, 533, 2031, 589, 9, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 360, 5668, 297, 892, 63, 929, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 360, 5668, 297, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 291, 14, 1818, 63, 929, 275, 892, 63, 929, 339, 347, 511, 63, 525, 63, 6481, 63, 698, 8, 277, 304, 267, 408, 267, 1379, 314, 2654, 792, 3439, 543, 282, 3400, 13, 3827, 2763, 14, 267, 408, 267, 291, 14, 11858, 63, 5668, 63, 1238, 8, 7685, 14, 18381, 12, 283, 13779, 10422, 297, 288, 283, 515, 297, 756, 12, 1504, 14, 3049, 14912, 9, 267, 291, 14, 479, 4547, 7965, 360, 5668, 63, 13881, 10422, 297, 283, 515, 358, 398, 327, 1379, 10579, 15086, 1380, 2808, 267, 340, 7509, 63, 28472, 63, 28427, 26, 288, 291, 14, 479, 6831, 15086, 2353, 8, 18, 9, 398, 327, 1379, 11469, 4918, 1380, 2808, 267, 340, 291, 14, 1989, 63, 11679, 63, 10116, 26, 288, 291, 14, 479, 18075, 2681, 7965, 360, 5668, 63, 13881, 10422, 297, 283, 515, 358, 339, 768, 22424, 360, 9823, 63, 20876, 358, 272, 347, 511, 63, 525, 63, 20876, 63, 698, 8, 277, 304, 267, 408, 267, 1379, 314, 2654, 792, 3439, 543, 282, 19775, 13, 3827, 2763, 14, 267, 408, 267, 291, 14, 11858, 63, 5668, 63, 1238, 8, 7685, 14, 18381, 12, 283, 13779, 10422, 297, 288, 283, 16614, 1130, 297, 756, 12, 1504, 14, 13284, 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, 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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 ]
bastibl/gnuradio
gr-digital/python/digital/constellation_map_generator.py
7
2083
#!/usr/bin/env python # # Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, or (at your option) # any later version. # # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from __future__ import unicode_literals def constellation_map_generator(basis_cpoints, basis_symbols, k, pi): ''' Uses the a basis constellation provided (e.g., from psk_constellation.psk_4()) and the the k and permutation index (pi) to generate a new Gray-coded symbol map to the constellation points provided in the basis. The basis_cpoints are the constellation points of the basis constellation, and basis_symbols are the symbols that correspond to the constellation points. The selection of k and pi will provide an automorphism the hyperoctahedral group of the basis constellation. This function returns a tuple of (constellation_points, symbol_map). The constellation_points is a list of the constellation points in complex space and the symbol_map is a list of the log2(M)-bit symbols for the constellation points (i.e., symbol_map[i] are the bits associated with constellation_points[i]). ''' #const_points, s = basis() const_points = basis_cpoints s = basis_symbols symbols = list() for s_i in s: tmp = 0 for i,p in enumerate(pi): bit = (s_i >> i) & 0x1 tmp |= bit << p symbols.append(tmp ^ k) return (const_points, symbols)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 318, 406, 30721, 2212, 63, 1130, 63, 4679, 8, 19220, 63, 67, 3438, 12, 5597, 63, 7450, 12, 1022, 12, 6682, 304, 272, 1449, 272, 14911, 314, 282, 5597, 406, 30721, 2212, 2741, 334, 69, 14, 71, 2020, 687, 272, 299, 1339, 63, 388, 30721, 2212, 14, 30333, 63, 20, 1012, 436, 314, 314, 1022, 436, 22966, 1478, 272, 334, 1038, 9, 370, 3550, 282, 892, 598, 803, 13, 15282, 5272, 2341, 370, 314, 406, 30721, 2212, 272, 4501, 2741, 315, 314, 5597, 14, 339, 710, 5597, 63, 67, 3438, 787, 314, 406, 30721, 2212, 4501, 402, 314, 5597, 272, 406, 30721, 2212, 12, 436, 5597, 63, 7450, 787, 314, 6698, 626, 17118, 272, 370, 314, 406, 30721, 2212, 4501, 14, 339, 710, 7267, 402, 1022, 436, 6682, 911, 5647, 376, 6384, 25456, 19185, 314, 272, 10342, 15560, 11326, 379, 13984, 1572, 402, 314, 5597, 406, 30721, 2212, 14, 339, 961, 805, 2529, 282, 2008, 402, 334, 388, 30721, 2212, 63, 3438, 12, 272, 5272, 63, 1130, 680, 710, 406, 30721, 2212, 63, 3438, 365, 282, 769, 402, 314, 272, 406, 30721, 2212, 4501, 315, 6114, 4601, 436, 314, 5272, 63, 1130, 365, 282, 769, 272, 402, 314, 943, 18, 8, 45, 7216, 2075, 6698, 367, 314, 406, 30721, 2212, 4501, 334, 73, 14, 69, 2020, 272, 5272, 63, 1130, 59, 73, 61, 787, 314, 5821, 4568, 543, 272, 406, 30721, 2212, 63, 3438, 59, 73, 6575, 272, 1449, 272, 327, 1297, 63, 3438, 12, 308, 275, 5597, 342, 272, 950, 63, 3438, 275, 5597, 63, 67, 3438, 272, 308, 275, 5597, 63, 7450, 272, 6698, 275, 769, 342, 272, 367, 308, 63, 73, 315, 308, 26, 267, 3529, 275, 378, 267, 367, 284, 12, 80, 315, 3874, 8, 1038, 304, 288, 4546, 275, 334, 83, 63, 73, 4331, 284, 9, 1253, 378, 88, 17, 288, 3529, 8901, 4546, 5213, 299, 267, 6698, 14, 740, 8, 2791, 7167, 1022, 9, 272, 372, 334, 1297, 63, 3438, 12, 6698, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 318, 406, 30721, 2212, 63, 1130, 63, 4679, 8, 19220, 63, 67, 3438, 12, 5597, 63, 7450, 12, 1022, 12, 6682, 304, 272, 1449, 272, 14911, 314, 282, 5597, 406, 30721, 2212, 2741, 334, 69, 14, 71, 2020, 687, 272, 299, 1339, 63, 388, 30721, 2212, 14, 30333, 63, 20, 1012, 436, 314, 314, 1022, 436, 22966, 1478, 272, 334, 1038, 9, 370, 3550, 282, 892, 598, 803, 13, 15282, 5272, 2341, 370, 314, 406, 30721, 2212, 272, 4501, 2741, 315, 314, 5597, 14, 339, 710, 5597, 63, 67, 3438, 787, 314, 406, 30721, 2212, 4501, 402, 314, 5597, 272, 406, 30721, 2212, 12, 436, 5597, 63, 7450, 787, 314, 6698, 626, 17118, 272, 370, 314, 406, 30721, 2212, 4501, 14, 339, 710, 7267, 402, 1022, 436, 6682, 911, 5647, 376, 6384, 25456, 19185, 314, 272, 10342, 15560, 11326, 379, 13984, 1572, 402, 314, 5597, 406, 30721, 2212, 14, 339, 961, 805, 2529, 282, 2008, 402, 334, 388, 30721, 2212, 63, 3438, 12, 272, 5272, 63, 1130, 680, 710, 406, 30721, 2212, 63, 3438, 365, 282, 769, 402, 314, 272, 406, 30721, 2212, 4501, 315, 6114, 4601, 436, 314, 5272, 63, 1130, 365, 282, 769, 272, 402, 314, 943, 18, 8, 45, 7216, 2075, 6698, 367, 314, 406, 30721, 2212, 4501, 334, 73, 14, 69, 2020, 272, 5272, 63, 1130, 59, 73, 61, 787, 314, 5821, 4568, 543, 272, 406, 30721, 2212, 63, 3438, 59, 73, 6575, 272, 1449, 272, 327, 1297, 63, 3438, 12, 308, 275, 5597, 342, 272, 950, 63, 3438, 275, 5597, 63, 67, 3438, 272, 308, 275, 5597, 63, 7450, 272, 6698, 275, 769, 342, 272, 367, 308, 63, 73, 315, 308, 26, 267, 3529, 275, 378, 267, 367, 284, 12, 80, 315, 3874, 8, 1038, 304, 288, 4546, 275, 334, 83, 63, 73, 4331, 284, 9, 1253, 378, 88, 17, 288, 3529, 8901, 4546, 5213, 299, 267, 6698, 14, 740, 8, 2791, 7167, 1022, 9, 272, 372, 334, 1297, 63, 3438, 12, 6698, 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, 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,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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 ]
AmeriCanAndroid/kernel-android-msm-2.6.35
tools/perf/scripts/python/syscall-counts-by-pid.py
944
1744
# system call counts, by pid # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * usage = "perf trace -s syscall-counts-by-pid.py [comm]\n"; for_comm = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): pass def trace_end(): print_syscall_totals() 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[common_comm][common_pid][id] += 1 except TypeError: syscalls[common_comm][common_pid][id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events by comm/pid:\n\n", print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): print " %-38d %10d\n" % (id, val),
gpl-2.0
[ 3, 2656, 1240, 8242, 12, 701, 4422, 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, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 3807, 275, 298, 9452, 3307, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 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, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 68, 221, 450, 709, 68, 60, 78, 2, 450, 334, 344, 12, 1139, 395, 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 ]
[ 2656, 1240, 8242, 12, 701, 4422, 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, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 3807, 275, 298, 9452, 3307, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 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, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 68, 221, 450, 709, 68, 60, 78, 2, 450, 334, 344, 12, 1139, 395, 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, 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 ]
t3dev/odoo
addons/mrp/__manifest__.py
5
1731
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { 'name': 'Manufacturing', 'version': '2.0', 'website': 'https://www.odoo.com/page/manufacturing', 'category': 'Manufacturing/Manufacturing', 'sequence': 16, 'summary': 'Manufacturing Orders & BOMs', 'depends': ['product', 'stock', 'resource'], 'description': "", 'data': [ 'security/mrp_security.xml', 'security/ir.model.access.csv', 'data/mrp_data.xml', 'wizard/mrp_product_produce_views.xml', 'wizard/change_production_qty_views.xml', 'wizard/mrp_workcenter_block_view.xml', 'wizard/stock_warn_insufficient_qty_views.xml', 'views/mrp_views_menus.xml', 'views/stock_move_views.xml', 'views/mrp_workorder_views.xml', 'views/mrp_workcenter_views.xml', 'views/mrp_production_views.xml', 'views/mrp_routing_views.xml', 'views/mrp_bom_views.xml', 'views/product_views.xml', 'views/stock_warehouse_views.xml', 'views/stock_picking_views.xml', 'views/mrp_unbuild_views.xml', 'views/ir_attachment_view.xml', 'views/res_config_settings_views.xml', 'views/mrp_templates.xml', 'views/stock_scrap_views.xml', 'report/mrp_report_views_main.xml', 'report/mrp_report_bom_structure.xml', 'report/mrp_production_templates.xml', 'report/report_stock_rule.xml', 'report/mrp_zebra_production_templates.xml', ], 'qweb': ['static/src/xml/mrp.xml'], 'demo': [ 'data/mrp_demo.xml', ], 'test': [], 'application': True, 'post_init_hook': '_create_warehouse_data', }
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 421, 199, 91, 272, 283, 354, 356, 283, 2395, 7415, 319, 4039, 297, 272, 283, 1023, 356, 283, 18, 14, 16, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1237, 7415, 319, 4039, 297, 272, 283, 3710, 356, 283, 2395, 7415, 319, 4039, 15, 2395, 7415, 319, 4039, 297, 272, 283, 4041, 356, 3193, 12, 272, 283, 4705, 356, 283, 2395, 7415, 319, 4039, 4236, 7735, 1253, 4367, 13586, 297, 272, 283, 8912, 356, 788, 2558, 297, 283, 6088, 297, 283, 1927, 995, 272, 283, 1802, 356, 4873, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 17058, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 576, 15, 17058, 63, 576, 14, 1652, 297, 267, 283, 9819, 15, 17058, 63, 2558, 63, 7832, 63, 4196, 14, 1652, 297, 267, 283, 9819, 15, 1461, 63, 10777, 63, 5643, 63, 4196, 14, 1652, 297, 267, 283, 9819, 15, 17058, 63, 23963, 63, 1457, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6088, 63, 4050, 63, 3617, 12983, 63, 5643, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 4196, 63, 30969, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 1185, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 800, 1648, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 23963, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 10777, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 9492, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 16302, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 2558, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 12806, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 11463, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 324, 1506, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 723, 63, 8905, 63, 1345, 14, 1652, 297, 267, 283, 4196, 15, 470, 63, 888, 63, 1751, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 5876, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 551, 1330, 63, 4196, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 3070, 63, 4196, 63, 973, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 3070, 63, 16302, 63, 6976, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 10777, 63, 5876, 14, 1652, 297, 267, 283, 3070, 15, 3070, 63, 6088, 63, 2200, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 806, 7828, 63, 10777, 63, 5876, 14, 1652, 297, 272, 2156, 272, 283, 22600, 356, 788, 1986, 15, 2164, 15, 1652, 15, 17058, 14, 1652, 995, 272, 283, 8768, 356, 359, 267, 283, 576, 15, 17058, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 990, 272, 283, 3578, 356, 715, 12, 272, 283, 1932, 63, 826, 63, 3664, 356, 2513, 981, 63, 12806, 63, 576, 297, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 421, 199, 91, 272, 283, 354, 356, 283, 2395, 7415, 319, 4039, 297, 272, 283, 1023, 356, 283, 18, 14, 16, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1237, 7415, 319, 4039, 297, 272, 283, 3710, 356, 283, 2395, 7415, 319, 4039, 15, 2395, 7415, 319, 4039, 297, 272, 283, 4041, 356, 3193, 12, 272, 283, 4705, 356, 283, 2395, 7415, 319, 4039, 4236, 7735, 1253, 4367, 13586, 297, 272, 283, 8912, 356, 788, 2558, 297, 283, 6088, 297, 283, 1927, 995, 272, 283, 1802, 356, 4873, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 17058, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 576, 15, 17058, 63, 576, 14, 1652, 297, 267, 283, 9819, 15, 17058, 63, 2558, 63, 7832, 63, 4196, 14, 1652, 297, 267, 283, 9819, 15, 1461, 63, 10777, 63, 5643, 63, 4196, 14, 1652, 297, 267, 283, 9819, 15, 17058, 63, 23963, 63, 1457, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6088, 63, 4050, 63, 3617, 12983, 63, 5643, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 4196, 63, 30969, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 1185, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 800, 1648, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 23963, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 10777, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 9492, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 16302, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 2558, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 12806, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 11463, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 324, 1506, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 723, 63, 8905, 63, 1345, 14, 1652, 297, 267, 283, 4196, 15, 470, 63, 888, 63, 1751, 63, 4196, 14, 1652, 297, 267, 283, 4196, 15, 17058, 63, 5876, 14, 1652, 297, 267, 283, 4196, 15, 6088, 63, 551, 1330, 63, 4196, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 3070, 63, 4196, 63, 973, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 3070, 63, 16302, 63, 6976, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 10777, 63, 5876, 14, 1652, 297, 267, 283, 3070, 15, 3070, 63, 6088, 63, 2200, 14, 1652, 297, 267, 283, 3070, 15, 17058, 63, 806, 7828, 63, 10777, 63, 5876, 14, 1652, 297, 272, 2156, 272, 283, 22600, 356, 788, 1986, 15, 2164, 15, 1652, 15, 17058, 14, 1652, 995, 272, 283, 8768, 356, 359, 267, 283, 576, 15, 17058, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 990, 272, 283, 3578, 356, 715, 12, 272, 283, 1932, 63, 826, 63, 3664, 356, 2513, 981, 63, 12806, 63, 576, 297, 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, 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, 0 ]
idea4bsd/idea4bsd
python/helpers/pycharm/_jb_utils.py
15
1220
__author__ = 'Ilya.Kazakevich' import sys class VersionAgnosticUtils(object): """ "six" emulator: this class fabrics appropriate tool to use regardless python version. Use it to write code that works both on py2 and py3. # TODO: Use Six instead """ @staticmethod def __new__(cls, *more): """ Fabrics Py2 or Py3 instance based on py version """ real_class = _Py3KUtils if sys.version_info >= (3, 0) else _Py2Utils return super(cls, real_class).__new__(real_class, *more) def to_unicode(self, obj): """ :param obj: string to convert to unicode :return: unicode string """ raise NotImplementedError() class _Py2Utils(VersionAgnosticUtils): """ Util for Py2 """ def to_unicode(self, obj): if isinstance(obj, unicode): return obj try: return unicode(obj) # Obj may have its own __unicode__ except (UnicodeDecodeError, AttributeError): return unicode(str(obj).decode("utf-8")) # or it may have __str__ class _Py3KUtils(VersionAgnosticUtils): """ Util for Py3 """ def to_unicode(self, obj): return str(obj)
apache-2.0
[ 363, 2502, 363, 275, 283, 41, 590, 65, 14, 43, 4651, 1728, 433, 335, 7, 199, 646, 984, 421, 199, 533, 3394, 33, 784, 941, 530, 7535, 8, 785, 304, 272, 408, 272, 298, 4174, 2, 17423, 707, 26, 642, 1021, 31507, 11818, 5827, 4744, 370, 675, 15270, 2366, 1015, 14, 272, 3645, 652, 370, 2218, 1233, 626, 5419, 3865, 641, 1134, 18, 436, 1134, 19, 14, 327, 3254, 26, 3645, 428, 1148, 3140, 272, 408, 339, 768, 4639, 272, 347, 636, 1222, 721, 1886, 12, 627, 6878, 304, 267, 408, 267, 481, 371, 11818, 1611, 18, 503, 1611, 19, 1256, 4079, 641, 1134, 1015, 267, 408, 267, 3363, 63, 533, 275, 485, 2713, 19, 43, 7535, 340, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 587, 485, 2713, 18, 7535, 267, 372, 1613, 8, 1886, 12, 3363, 63, 533, 2843, 1222, 721, 3093, 63, 533, 12, 627, 6878, 9, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 408, 398, 520, 635, 1559, 26, 1059, 370, 3957, 370, 2649, 267, 520, 1107, 26, 2649, 1059, 267, 408, 398, 746, 4279, 342, 421, 199, 533, 485, 2713, 18, 7535, 8, 3353, 33, 784, 941, 530, 7535, 304, 272, 408, 272, 21248, 367, 1611, 18, 272, 408, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2649, 304, 288, 372, 1559, 267, 862, 26, 288, 372, 2649, 8, 1113, 9, 327, 24921, 1443, 1172, 2399, 5705, 636, 2975, 363, 267, 871, 334, 7087, 12620, 12, 4281, 304, 288, 372, 2649, 8, 495, 8, 1113, 680, 2708, 480, 1624, 13, 24, 2237, 327, 503, 652, 1443, 1172, 636, 495, 363, 421, 199, 533, 485, 2713, 19, 43, 7535, 8, 3353, 33, 784, 941, 530, 7535, 304, 272, 408, 272, 21248, 367, 1611, 19, 272, 408, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 372, 620, 8, 1113, 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 ]
[ 2502, 363, 275, 283, 41, 590, 65, 14, 43, 4651, 1728, 433, 335, 7, 199, 646, 984, 421, 199, 533, 3394, 33, 784, 941, 530, 7535, 8, 785, 304, 272, 408, 272, 298, 4174, 2, 17423, 707, 26, 642, 1021, 31507, 11818, 5827, 4744, 370, 675, 15270, 2366, 1015, 14, 272, 3645, 652, 370, 2218, 1233, 626, 5419, 3865, 641, 1134, 18, 436, 1134, 19, 14, 327, 3254, 26, 3645, 428, 1148, 3140, 272, 408, 339, 768, 4639, 272, 347, 636, 1222, 721, 1886, 12, 627, 6878, 304, 267, 408, 267, 481, 371, 11818, 1611, 18, 503, 1611, 19, 1256, 4079, 641, 1134, 1015, 267, 408, 267, 3363, 63, 533, 275, 485, 2713, 19, 43, 7535, 340, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 378, 9, 587, 485, 2713, 18, 7535, 267, 372, 1613, 8, 1886, 12, 3363, 63, 533, 2843, 1222, 721, 3093, 63, 533, 12, 627, 6878, 9, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 408, 398, 520, 635, 1559, 26, 1059, 370, 3957, 370, 2649, 267, 520, 1107, 26, 2649, 1059, 267, 408, 398, 746, 4279, 342, 421, 199, 533, 485, 2713, 18, 7535, 8, 3353, 33, 784, 941, 530, 7535, 304, 272, 408, 272, 21248, 367, 1611, 18, 272, 408, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 2649, 304, 288, 372, 1559, 267, 862, 26, 288, 372, 2649, 8, 1113, 9, 327, 24921, 1443, 1172, 2399, 5705, 636, 2975, 363, 267, 871, 334, 7087, 12620, 12, 4281, 304, 288, 372, 2649, 8, 495, 8, 1113, 680, 2708, 480, 1624, 13, 24, 2237, 327, 503, 652, 1443, 1172, 636, 495, 363, 421, 199, 533, 485, 2713, 19, 43, 7535, 8, 3353, 33, 784, 941, 530, 7535, 304, 272, 408, 272, 21248, 367, 1611, 19, 272, 408, 339, 347, 370, 63, 2975, 8, 277, 12, 1559, 304, 267, 372, 620, 8, 1113, 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, 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, 0 ]
tfwillems/STRValidator
pedigree_analysis.py
1
23183
import matplotlib as mpl mpl.use('Agg') import collections import sys import numpy import matplotlib.pyplot as plt import vcf from matplotlib.backends.backend_pdf import PdfPages from fractions import Fraction class TRIO: def __init__(self, child, mother, father): self.child = child self.mother = mother self.father = father def __str__(self): return "%s\t%s\t%s"%(self.child, self.mother, self.father) class FATHER_SON_PAIR: def __init__(self, son, father): self.son = son self.father = father def __str__(self): return "%s\t%s"%(self.son, self.father) def read_1kg_pedigree_file(input_file, header=True): data = open(input_file, "r") if header: data.readline() trios, father_son_pairs = [], [] for line in data: tokens = line.strip().split() if tokens[2] != "0" and tokens[3] != "0": child, dad, mom = tokens[1:4] trios.append(TRIO(child, dad, mom)) if tokens[2] != "0" and tokens[4] == "1": father_son_pairs.append(FATHER_SON_PAIR(tokens[1], tokens[2])) data.close() print("There are %d trios and %d father-son-pairs in the pedigree file"%(len(trios), len(father_son_pairs))) return trios, father_son_pairs # Find the index for the highest bin which is less than # or equal to the provided value def find_index(bins, value): low = 0 high = len(bins)-1 while high > low + 1: midval = bins[(low+high)/2] if value > midval: low = (low+high)/2 elif value < midval: high = (low+high)/2 - 1 else: return (low+high)/2 if value < bins[low]: exit("Unable to find index. Exiting...") if value >= bins[high]: return high else: return low def is_discordant(a11, a12, a21, a22): if (a11 == a21 and a12 == a22) or (a11 == a22 and a12 == a21): return False else: return True def is_mendelian(a11, a12, a21, a22, a31, a32): if (a31 == a11 or a31 == a12) and (a32 == a21 or a32 == a22): return True elif (a31 == a21 or a31 == a22) and (a32 == a11 or a32 == a12): return True else: return False def draw_bp_histogram(discordant_counts, pdfpage): # Create histogram of father-son differences bp_diff_counts = [collections.defaultdict(int) for _ in xrange(6)] repeat_diff_counts = [collections.defaultdict(int) for _ in xrange(6)] out_frame_count = 0 in_frame_count = 0 for key,val in discordant_counts.items(): bp_diff_counts[key[2]-1][key[1]-key[0]] += val repeat_diff_counts[key[2]-1][Fraction(key[1]-key[0], key[2])] += val for xlabel,diff_counts,in_frame in zip(["bps", "repeats"], [bp_diff_counts, repeat_diff_counts], [lambda bp,period: bp%period == 0, lambda rep,period: int(rep)==float(rep) ]): fig = plt.figure() ax = fig.add_subplot(111) diffs = sorted(list(set(reduce(lambda x,y:x+y, map(lambda z: z.keys(), diff_counts))))) colors = ['c', 'r', 'g', 'y', 'b', 'm'] heights = numpy.zeros(len(diffs)) for i in xrange(6): vals = [diff_counts[i][x] for x in diffs] if sum(vals) == 0: continue in_frame_trips = filter(lambda x: in_frame(x[0], i+1), zip(diffs, vals, heights)) out_frame_trips = filter(lambda x: not in_frame(x[0], i+1), zip(diffs, vals, heights)) if len(in_frame_trips) != 0: x,y,h = zip(*in_frame_trips) in_frame_count += sum(y) ax.bar(x, y, bottom=h, align='center', color=colors[i], width=0.25, label=str(i+1)) if len(out_frame_trips) != 0: x,y,h = zip(*out_frame_trips) out_frame_count += sum(y) ax.bar(x, y, bottom=h, align='center', color=colors[i], width=0.25, label=str(i+1), hatch='//') heights += vals ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') ax.set_xlabel(r"$father-son ("+xlabel+")$") ax.set_ylabel(r"$n_{calls}$") ax.legend() pdfpage.savefig(fig) print("IN FRAME=%d, OUT FRAME=%d"%(in_frame_count/2, out_frame_count/2)) class CHRY_STATS: def __init__(self, father_son_pairs, call_output): self.pairs = father_son_pairs self.output_calls = open(call_output, "w") def initialize(self, vcf_reader): sample_indices = dict(zip(vcf_reader.samples, range(len(vcf_reader.samples)))) self.pair_indices = [] for i in xrange(len(self.pairs)): if self.pairs[i].son not in sample_indices: exit("Unable to assess chrY inheritance because no data was found for " + self.pairs[i].son) if self.pairs[i].father not in sample_indices: exit("Unable to assess chrY inheritance because no data was found for " + self.pairs[i].father) self.pair_indices.append([sample_indices[self.pairs[i].father], sample_indices[self.pairs[i].son]]) self.missing_data_skip_counts = numpy.zeros(len(self.pair_indices)) self.het_gt_skip_counts = numpy.zeros(len(self.pair_indices)) self.num_concordant = 0 self.num_discordant = 0 self.pair_info = {} self.discordant_counts = collections.defaultdict(int) self.call_count = 0 def process_record(self, record): motif_len = len(record.INFO['MOTIF']) for i in xrange(len(self.pair_indices)): if any(map(lambda x: record.samples[x]['GT'] is None, self.pair_indices[i])): self.missing_data_skip_counts[i] += 1 continue self.call_count += 1 father = record.samples[self.pair_indices[i][0]] son = record.samples[self.pair_indices[i][1]] gb_1a, gb_1b = map(int, father['GB'].split("/")) gb_2a, gb_2b = map(int, son['GB'].split("/")) self.output_calls.write("%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\n"%(self.call_count, record.CHROM, record.POS, record.INFO['END'], gb_1a + gb_1b, gb_2a + gb_2b, gb_1a, gb_1b, gb_2a, gb_2b, father.sample, son.sample)) if gb_1a != gb_1b or gb_2a != gb_2b: self.het_gt_skip_counts[i] += 1 if gb_1a != gb_1b: print("chrY\t%d\t%d\t%s\t%s\t%s"%(record.POS, record.INFO["END"], father.sample, str(gb_1a) + "|" + str(gb_1b), "HET")) if gb_2a != gb_2b: print("chrY\t%d\t%d\t%s\t%s\t%s"%(record.POS, record.INFO["END"], father.sample, str(gb_2a) + "|" + str(gb_2b), "HET")) continue if gb_1a != gb_2a: self.num_discordant += 1 self.discordant_counts[(gb_1a, gb_2a, motif_len)] +=1 print("chrY\t%d\t%d\t%s\t%s\t%s"%(record.POS, record.INFO["END"], father.sample + "," + son.sample, str(gb_1a) + "," + str(gb_2b), "DISCORDANT")) else: self.num_concordant += 1 if (gb_1a, gb_2a) not in self.pair_info: self.pair_info[(gb_1a, gb_2a)] = [] self.pair_info[(gb_1a, gb_2a)].append((record.CHROM, record.POS, record.INFO['END'], father.sample+"-"+son.sample)) def finish(self, pdfpage, output_prefix): print("WARNING: Skipped " + str(self.missing_data_skip_counts) + " comparisons due to missing data for one or more individuals") print("WARNING: Skipped " + str(self.het_gt_skip_counts) + " comparisons due to heterozygous genotypes for one or more individuals") if self.num_discordant + self.num_concordant != 0: print("%d vs. %d = %f Percent"%(self.num_discordant, self.num_concordant, 100.0*self.num_discordant/(self.num_discordant+self.num_concordant))) else: print("WARNING: No chrY calls were applicable for comparison") # Create bubble plot using all data fig = plt.figure() ax = fig.add_subplot(111) x, y = zip(*self.pair_info.keys()) s = numpy.array(map(len, self.pair_info.values()))*10 ax.scatter(x, y, s=s, alpha=0.7) ax.set_xlabel("Father's genotype (bp)") ax.set_ylabel("Son's genotype (bp)") ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') ax.plot(numpy.arange(min(x)-5, max(x)+5, 1.0), numpy.arange(min(y)-5, max(y)+5, 1.0), linestyle='--', color='k') pdfpage.savefig(fig) # Create histogram of father-son differences draw_bp_histogram(self.discordant_counts, pdfpage) viz_output = open(output_prefix+"_chrY.csv", "w") viz_output.write(",".join(["X","Y", "CHROMS", "STARTS", "STOPS", "SAMPLES"]) + "\n") for key,val in self.pair_info.items(): chroms, positions, ends, samples = map(list, zip(*val)) viz_output.write(",".join([str(key[0]), str(key[1]), "_".join(chroms), "_".join(map(str, positions)), "_".join(map(str, ends)), "_".join(map(str, samples))]) + "\n") viz_output.close() self.output_calls.close() class MENDELIAN_STATS: def __init__(self, trios, coverage_bins, quality_bins, max_coverage, quality_thresholds): self.trios = trios self.coverage_bins = coverage_bins self.quality_bins = quality_bins self.max_coverage = max_coverage self.qual_thresh = quality_thresholds def initialize(self, vcf_reader): sample_indices = dict(zip(vcf_reader.samples, range(len(vcf_reader.samples)))) self.trio_indices = [] for i in xrange(len(self.trios)): if self.trios[i].child not in sample_indices: exit("Unable to calculate Mendelian inheritance because no data was found for " + self.trios[i].child) if self.trios[i].father not in sample_indices: exit("Unable to calculate Mendelian inheritance because no data was found for " + self.trios[i].father) if self.trios[i].mother not in sample_indices: exit("Unable to calculate Mendelian inheritance because no data was found for " + self.trios[i].mother) # Father, Mother, Child self.trio_indices.append(map(lambda x: sample_indices[x], [self.trios[i].father, self.trios[i].mother, self.trios[i].child])) self.coverage_bins = numpy.concatenate(([-100000], self.coverage_bins)) self.quality_bins = numpy.concatenate(([-100000], self.quality_bins)) # Quality/Coverage x Trios x Period x Thresholds self.all_loci_nstrs = [numpy.zeros((len(self.trios), 5, len(self.coverage_bins))), numpy.zeros((len(self.trios), 5, len(self.quality_bins)))] self.all_loci_nmend = [numpy.zeros((len(self.trios), 5, len(self.coverage_bins))), numpy.zeros((len(self.trios), 5, len(self.quality_bins)))] self.disc_loci_nstrs = [numpy.zeros((len(self.trios), 5, len(self.coverage_bins))), numpy.zeros((len(self.trios), 5, len(self.quality_bins)))] self.disc_loci_nmend = [numpy.zeros((len(self.trios), 5, len(self.coverage_bins))), numpy.zeros((len(self.trios), 5, len(self.quality_bins)))] self.missing_data_skip_counts = numpy.zeros(len(self.trios)) self.coverage_skip_counts = numpy.zeros(len(self.trios)) # Trios x Period x Thresholds self.all_loci_nstrs_min_q = numpy.zeros((len(self.trios), 5, len(self.coverage_bins))) self.all_loci_nmend_min_q = numpy.zeros((len(self.trios), 5, len(self.coverage_bins))) self.disc_loci_nstrs_min_q = numpy.zeros((len(self.trios), 5, len(self.coverage_bins))) self.disc_loci_nmend_min_q = numpy.zeros((len(self.trios), 5, len(self.coverage_bins))) def process_record(self, record): for i in xrange(len(self.trios)): if any(map(lambda x: record.samples[x]['GT'] is None, self.trio_indices[i])): self.missing_data_skip_counts[i] += 1 continue if 'X' in record.CHROM or 'x' in record.CHROM or 'Y' in record.CHROM or 'y' in record.CHROM: continue q1, q2, q3 = map(lambda x: record.samples[x]["Q"], self.trio_indices[i]) c1, c2, c3 = map(lambda x: record.samples[x]["DP"], self.trio_indices[i]) a11, a21 = record.samples[self.trio_indices[i][0]]["GT"].split("/") a21, a22 = record.samples[self.trio_indices[i][1]]["GT"].split("/") a31, a32 = record.samples[self.trio_indices[i][2]]["GT"].split("/") discordant = is_discordant(a11, a12, a21, a22) mendelian = is_mendelian(a11, a12, a21, a22, a31, a32) # Filter out loci with too high of coverage if max(c1, c2, c3) > self.max_coverage: self.coverage_skip_counts[i] += 1 continue coverage = min(c1, c2, c3) bin_idx = find_index(self.coverage_bins, coverage) motif_len = len(record.INFO["MOTIF"])-2 self.all_loci_nstrs [0][i][motif_len][bin_idx] += 1 self.all_loci_nmend [0][i][motif_len][bin_idx] += mendelian*1 self.disc_loci_nstrs[0][i][motif_len][bin_idx] += discordant*1 self.disc_loci_nmend[0][i][motif_len][bin_idx] += discordant*mendelian*1 quality = min(q1, q2, q3) bin_idx = find_index(self.quality_bins, quality) self.all_loci_nstrs [1][i][motif_len][bin_idx] += 1 self.all_loci_nmend [1][i][motif_len][bin_idx] += mendelian*1 self.disc_loci_nstrs[1][i][motif_len][bin_idx] += discordant*1 self.disc_loci_nmend[1][i][motif_len][bin_idx] += discordant*mendelian*1 coverage = min(c1, c2, c3) bin_idx = find_index(self.coverage_bins, coverage) if quality > self.qual_thresh[motif_len]: self.all_loci_nstrs_min_q [i][motif_len][bin_idx] += 1 self.all_loci_nmend_min_q [i][motif_len][bin_idx] += mendelian*1 self.disc_loci_nstrs_min_q [i][motif_len][bin_idx] += discordant*1 self.disc_loci_nmend_min_q [i][motif_len][bin_idx] += discordant*mendelian*1 def finish(self, pdfpage): print("WARNING: Skipped " + str(self.missing_data_skip_counts) + " loci due to missing data for one or more individual") print("WARNING: Skipped " + str(self.coverage_skip_counts) + " loci due to too high coverage") # Iterate over coverage and quality stats types = ['Coverage', 'Quality', 'Coverage'] bins = [self.coverage_bins, self.quality_bins, self.coverage_bins] for n in xrange(3): # Sum across all trios if n == 0 or n == 1: all_loci_nstrs = numpy.sum(self.all_loci_nstrs [n], axis=0) all_loci_nmend = numpy.sum(self.all_loci_nmend [n], axis=0) disc_loci_nstrs = numpy.sum(self.disc_loci_nstrs[n], axis=0) disc_loci_nmend = numpy.sum(self.disc_loci_nmend[n], axis=0) else: all_loci_nstrs = numpy.sum(self.all_loci_nstrs_min_q, axis=0) all_loci_nmend = numpy.sum(self.all_loci_nmend_min_q, axis=0) disc_loci_nstrs = numpy.sum(self.disc_loci_nstrs_min_q, axis=0) disc_loci_nmend = numpy.sum(self.disc_loci_nmend_min_q, axis=0) # Create plots for individual periods fig = plt.figure() ax1 = fig.add_subplot(221) ax1.set_ylabel("Fraction Mendelian") ax1.set_title("All sites") ax2 = fig.add_subplot(222, sharey=ax1) ax2.set_title("Discordant parental sites") ax3 = fig.add_subplot(223, sharex=ax1) ax3.set_xlabel(types[n] + " threshold") ax3.set_ylabel("# genotypes") ax3.set_yscale('log') ax4 = fig.add_subplot(224, sharex=ax2, sharey=ax3) ax4.set_xlabel(types[n] + " threshold") ax4.set_yscale('log') box1 = ax1.get_position() ax1.set_position([box1.x0, box1.y0, box1.width*0.9, box1.height]) ax2.set_position([box1.x0 + box1.width*1.15, box1.y0, box1.width*0.9, box1.height]) box3 = ax3.get_position() ax3.set_position([box3.x0, box3.y0, box3.width*0.9, box3.height]) ax4.set_position([box3.x0 + box3.width*1.15, box3.y0, box3.width*0.9, box3.height]) font_size = 9 for i in xrange(5): nstrs_all = numpy.cumsum(all_loci_nstrs [i][::-1])[::-1] nmend_all = numpy.cumsum(all_loci_nmend [i][::-1])[::-1] nstrs_disc = numpy.cumsum(disc_loci_nstrs[i][::-1])[::-1] nmend_disc = numpy.cumsum(disc_loci_nmend[i][::-1])[::-1] all_fracs = (1.0*nmend_all/nstrs_all)[1:] disc_fracs = (1.0*nmend_disc/nstrs_disc)[1:] ax1.plot(bins[n][1:], all_fracs, '-o', label=str(i+1)) ax2.plot(bins[n][1:], disc_fracs, '-o', label=str(i+1)) ax3.plot(bins[n][1:], nstrs_all[1:], '-o', label=str(i+1)) ax4.plot(bins[n][1:], nstrs_disc[1:], '-o', label=str(i+1)) ax4.legend(bbox_to_anchor=(1.05, 0.9, 0.25, 0.2), loc='center left') for ax in [ax1, ax2, ax3, ax4]: for tick in ax.xaxis.get_major_ticks(): tick.label.set_fontsize(font_size) for tick in ax.yaxis.get_major_ticks(): tick.label.set_fontsize(font_size) pdfpage.savefig(fig) # Create plots using all periods # Sum across all periods all_loci_nstrs = numpy.sum(all_loci_nstrs, axis=0) all_loci_nmend = numpy.sum(all_loci_nmend, axis=0) disc_loci_nstrs = numpy.sum(disc_loci_nstrs, axis=0) disc_loci_nmend = numpy.sum(disc_loci_nmend, axis=0) # Transform into running sums all_loci_nstrs = numpy.cumsum(all_loci_nstrs[::-1])[::-1] all_loci_nmend = numpy.cumsum(all_loci_nmend[::-1])[::-1] disc_loci_nstrs = numpy.cumsum(disc_loci_nstrs[::-1])[::-1] disc_loci_nmend = numpy.cumsum(disc_loci_nmend[::-1])[::-1] # Calculate the fraction of Mendelian inheritance for all loci and discordant loci all_loci_fracs = (1.0*all_loci_nmend/all_loci_nstrs)[1:] disc_loci_fracs = (1.0*disc_loci_nmend/disc_loci_nstrs)[1:] fig = plt.figure() ax1 = fig.add_subplot(221) ax1.set_ylabel("Fraction Mendelian") ax1.set_title("All sites") ax1.plot(bins[n][1:], all_loci_fracs, '-o') ax2 = fig.add_subplot(222, sharey=ax1) ax2.plot(bins[n][1:], disc_loci_fracs, '-o') ax2.set_title("Discordant parental sites") ax3 = fig.add_subplot(223, sharex=ax1) ax3.set_xlabel(types[n] + " threshold") ax3.set_ylabel("# genotypes") ax3.set_yscale('log') ax3.plot(bins[n][1:], all_loci_nstrs[1:], '-o') ax4 = fig.add_subplot(224, sharex=ax2, sharey=ax3) ax4.set_xlabel(types[n] + " threshold") ax4.set_yscale('log') ax4.plot(bins[n][1:], disc_loci_nstrs[1:], '-o') for ax in [ax1, ax2, ax3, ax4]: for tick in ax.xaxis.get_major_ticks(): tick.label.set_fontsize(font_size) for tick in ax.yaxis.get_major_ticks(): tick.label.set_fontsize(font_size) pdfpage.savefig(fig) mpl.rcParams['xtick.labelsize'] = 10 mpl.rcParams['ytick.labelsize'] = 10 fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(bins[n][1:], all_loci_fracs, '-o', color='b') ax1.set_ylabel("Fraction Mendelian") ax1.set_xlabel(types[n] + " threshold") ax2 = ax1.twinx() ax2.set_yscale('log') ax2.plot(bins[n][1:], all_loci_nstrs[1:], '-o', color='g') pdfpage.savefig(fig) ax1.axis('equal') pdfpage.savefig(fig) fig = plt.figure() ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(212) ax1.plot(bins[n][1:], all_loci_fracs, '-o', color='b') ax1.set_ylabel("Fraction Mendelian") ax1.xaxis.set_ticks_position('bottom') ax1.yaxis.set_ticks_position('left') ax2.set_xlabel(types[n] + " threshold") ax2.plot(bins[n][1:], all_loci_nstrs[1:], '-o', color='g') ax2.set_yscale('log') ax2.set_ylabel("# Called loci across trios") ax2.xaxis.set_ticks_position('bottom') ax2.yaxis.set_ticks_position('left') pdfpage.savefig(fig) def main(): print("Invocation syntax: python pedigree_analysis.py 1kg_pedigree_file.txt vcf_file.vcf output_file.pdf") trios, father_son_pairs = read_1kg_pedigree_file(sys.argv[1], header=True) vcf_reader = vcf.Reader(filename=sys.argv[2]) call_stats = sys.argv[3] samples = vcf_reader.samples trios_with_data = [] pairs_with_data = [] for trio in trios: if trio.child in samples and trio.mother in samples and trio.father in samples: trios_with_data.append(trio) print("There are %d trios with data"%len(trios_with_data)) for pair in father_son_pairs: if pair.father in samples and pair.son in samples: pairs_with_data.append(pair) print("There are %d father-son pairs with data"%(len(pairs_with_data))) coverage_bins = numpy.append(numpy.arange(1.001, 5.0011, 1.0), numpy.arange(6.001, 18.0011, 2.0)) quality_bins = numpy.arange(0.0, 1.0, 0.1) quality_thresh = [0.9, 0.5, 0.5, 0.5, 0.5, 0.5] max_coverage = 100 processors = [CHRY_STATS(pairs_with_data, call_stats)] #mend_stats = MENDELIAN_STATS(trios_with_data, coverage_bins, quality_bins, max_coverage, quality_thresh) for proc in processors: proc.initialize(vcf_reader) for record in vcf_reader: for proc in processors: proc.process_record(record) pp = PdfPages(sys.argv[3]+".pdf") for proc in processors: proc.finish(pp, sys.argv[3]) pp.close() return 0 if __name__ == "__main__": main()
gpl-3.0
[ 646, 8027, 465, 22513, 199, 2421, 14, 1180, 360, 7248, 358, 199, 199, 646, 5055, 199, 646, 984, 199, 646, 2680, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 373, 2177, 199, 504, 8027, 14, 7765, 14, 4620, 63, 5607, 492, 510, 1587, 17773, 199, 504, 28213, 2452, 492, 17980, 199, 199, 533, 9074, 2090, 26, 272, 347, 636, 826, 721, 277, 12, 1982, 12, 1303, 728, 12, 1433, 728, 304, 267, 291, 14, 1739, 221, 275, 1982, 267, 291, 14, 573, 728, 275, 1303, 728, 267, 291, 14, 667, 728, 275, 1433, 728, 272, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 60, 84, 5, 83, 60, 84, 5, 83, 14007, 277, 14, 1739, 12, 291, 14, 573, 728, 12, 291, 14, 667, 728, 9, 199, 199, 533, 481, 619, 3452, 63, 3377, 63, 28263, 26, 272, 347, 636, 826, 721, 277, 12, 27970, 12, 1433, 728, 304, 267, 291, 14, 834, 259, 275, 27970, 267, 291, 14, 667, 728, 275, 1433, 728, 272, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 60, 84, 5, 83, 14007, 277, 14, 834, 12, 291, 14, 667, 728, 9, 199, 199, 318, 1586, 63, 17, 9761, 63, 321, 18367, 850, 63, 493, 8, 1210, 63, 493, 12, 1406, 29, 549, 304, 272, 666, 275, 1551, 8, 1210, 63, 493, 12, 298, 82, 531, 272, 340, 1406, 26, 267, 666, 14, 6407, 342, 339, 3229, 736, 12, 1433, 728, 63, 834, 63, 7322, 275, 990, 942, 272, 367, 1004, 315, 666, 26, 267, 4645, 275, 1004, 14, 1913, 1252, 1294, 342, 267, 340, 4645, 59, 18, 61, 1137, 298, 16, 2, 436, 4645, 59, 19, 61, 1137, 298, 16, 582, 288, 1982, 12, 366, 350, 12, 30202, 275, 4645, 59, 17, 26, 20, 61, 288, 3229, 736, 14, 740, 8, 1766, 2090, 8, 1739, 12, 221, 366, 350, 12, 30202, 430, 267, 340, 4645, 59, 18, 61, 1137, 298, 16, 2, 436, 4645, 59, 20, 61, 508, 298, 17, 582, 288, 1433, 728, 63, 834, 63, 7322, 14, 740, 8, 21331, 3452, 63, 3377, 63, 28263, 8, 4504, 59, 17, 467, 4645, 59, 18, 2459, 272, 666, 14, 1600, 342, 272, 870, 480, 10924, 787, 450, 68, 3229, 736, 436, 450, 68, 1433, 728, 13, 834, 13, 7322, 315, 314, 4837, 18367, 850, 570, 14007, 552, 8, 599, 736, 395, 822, 8, 667, 728, 63, 834, 63, 7322, 1724, 272, 372, 3229, 736, 12, 1433, 728, 63, 834, 63, 7322, 199, 199, 3, 6668, 314, 1478, 367, 314, 15356, 2517, 1314, 365, 6656, 2419, 199, 3, 503, 4472, 370, 314, 2741, 574, 199, 318, 2342, 63, 1080, 8, 11329, 12, 574, 304, 272, 6465, 221, 275, 378, 272, 4721, 275, 822, 8, 11329, 7216, 17, 272, 1830, 4721, 690, 6465, 435, 413, 26, 267, 10887, 637, 275, 13341, 7528, 674, 11, 6260, 2447, 18, 61, 27144, 340, 574, 690, 10887, 637, 26, 288, 6465, 221, 275, 334, 674, 11, 6260, 2447, 18, 4960, 916, 574, 665, 10887, 637, 26, 288, 4721, 275, 334, 674, 11, 6260, 2447, 18, 446, 413, 267, 587, 26, 288, 372, 334, 674, 11, 6260, 2447, 18, 272, 340, 574, 665, 13341, 59, 674, 2189, 267, 4458, 480, 6005, 370, 2342, 1478, 14, 18704, 316, 12594, 272, 340, 574, 2356, 13341, 59, 6260, 2189, 267, 372, 4721, 272, 587, 26, 267, 372, 6465, 199, 199, 318, 365, 63, 6409, 2181, 867, 8, 65, 845, 12, 282, 713, 12, 282, 2025, 12, 282, 1081, 304, 272, 340, 334, 65, 845, 508, 282, 2025, 436, 282, 713, 508, 282, 1081, 9, 503, 334, 65, 845, 508, 282, 1081, 436, 282, 713, 508, 282, 2025, 304, 267, 372, 756, 272, 587, 26, 267, 372, 715, 523, 199, 318, 365, 63, 1410, 6933, 290, 8, 65, 845, 12, 282, 713, 12, 282, 2025, 12, 282, 1081, 12, 282, 2192, 12, 282, 708, 304, 272, 340, 334, 65, 2192, 508, 282, 845, 503, 282, 2192, 508, 282, 713, 9, 436, 334, 65, 708, 508, 282, 2025, 503, 282, 708, 508, 282, 1081, 304, 267, 372, 715, 272, 916, 334, 65, 2192, 508, 282, 2025, 503, 282, 2192, 508, 282, 1081, 9, 436, 334, 65, 708, 508, 282, 845, 503, 282, 708, 508, 282, 713, 304, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 199, 318, 5954, 63, 10913, 63, 14805, 8, 6409, 2181, 867, 63, 6851, 12, 11249, 1606, 304, 272, 327, 2790, 15379, 402, 1433, 728, 13, 834, 15109, 14924, 5591, 13292, 63, 3028, 63, 6851, 258, 275, 359, 7882, 14, 21501, 8, 442, 9, 367, 485, 315, 4945, 8, 22, 1874, 272, 11982, 63, 3028, 63, 6851, 275, 359, 7882, 14, 21501, 8, 442, 9, 367, 485, 315, 4945, 8, 22, 1874, 272, 734, 63, 1943, 63, 835, 259, 275, 378, 272, 315, 63, 1943, 63, 835, 258, 275, 378, 272, 367, 790, 12, 637, 315, 4339, 2181, 867, 63, 6851, 14, 1744, 837, 267, 13292, 63, 3028, 63, 6851, 59, 498, 59, 18, 11285, 17, 1527, 498, 59, 17, 11285, 498, 59, 16, 2677, 847, 1139, 267, 11982, 63, 3028, 63, 6851, 59, 498, 59, 18, 11285, 17, 1527, 27217, 8, 498, 59, 17, 11285, 498, 59, 16, 467, 790, 59, 18, 12457, 847, 1139, 272, 367, 671, 1302, 12, 3028, 63, 6851, 12, 262, 63, 1943, 315, 3482, 5234, 66, 1190, 401, 298, 32547, 2255, 5644, 359, 10913, 63, 3028, 63, 6851, 12, 11982, 63, 3028, 63, 6851, 467, 5644, 359, 2734, 13292, 12, 5191, 26, 13292, 5, 5191, 508, 378, 12, 2400, 1833, 12, 5191, 26, 1109, 8, 1155, 12694, 1609, 8, 1155, 9, 1622, 304, 267, 6085, 275, 4488, 14, 8941, 342, 267, 2185, 221, 275, 6085, 14, 525, 63, 13334, 8, 6673, 9, 267, 14981, 275, 3355, 8, 513, 8, 409, 8, 5270, 8, 2734, 671, 12, 89, 26, 88, 11, 89, 12, 2341, 8, 2734, 1315, 26, 1315, 14, 1612, 1062, 3915, 63, 6851, 430, 1724, 267, 9229, 275, 788, 67, 297, 283, 82, 297, 283, 71, 297, 283, 89, 297, 283, 66, 297, 283, 77, 418, 267, 946, 2492, 275, 2680, 14, 4250, 8, 552, 8, 17418, 430, 267, 367, 284, 315 ]
[ 8027, 465, 22513, 199, 2421, 14, 1180, 360, 7248, 358, 199, 199, 646, 5055, 199, 646, 984, 199, 646, 2680, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 373, 2177, 199, 504, 8027, 14, 7765, 14, 4620, 63, 5607, 492, 510, 1587, 17773, 199, 504, 28213, 2452, 492, 17980, 199, 199, 533, 9074, 2090, 26, 272, 347, 636, 826, 721, 277, 12, 1982, 12, 1303, 728, 12, 1433, 728, 304, 267, 291, 14, 1739, 221, 275, 1982, 267, 291, 14, 573, 728, 275, 1303, 728, 267, 291, 14, 667, 728, 275, 1433, 728, 272, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 60, 84, 5, 83, 60, 84, 5, 83, 14007, 277, 14, 1739, 12, 291, 14, 573, 728, 12, 291, 14, 667, 728, 9, 199, 199, 533, 481, 619, 3452, 63, 3377, 63, 28263, 26, 272, 347, 636, 826, 721, 277, 12, 27970, 12, 1433, 728, 304, 267, 291, 14, 834, 259, 275, 27970, 267, 291, 14, 667, 728, 275, 1433, 728, 272, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 60, 84, 5, 83, 14007, 277, 14, 834, 12, 291, 14, 667, 728, 9, 199, 199, 318, 1586, 63, 17, 9761, 63, 321, 18367, 850, 63, 493, 8, 1210, 63, 493, 12, 1406, 29, 549, 304, 272, 666, 275, 1551, 8, 1210, 63, 493, 12, 298, 82, 531, 272, 340, 1406, 26, 267, 666, 14, 6407, 342, 339, 3229, 736, 12, 1433, 728, 63, 834, 63, 7322, 275, 990, 942, 272, 367, 1004, 315, 666, 26, 267, 4645, 275, 1004, 14, 1913, 1252, 1294, 342, 267, 340, 4645, 59, 18, 61, 1137, 298, 16, 2, 436, 4645, 59, 19, 61, 1137, 298, 16, 582, 288, 1982, 12, 366, 350, 12, 30202, 275, 4645, 59, 17, 26, 20, 61, 288, 3229, 736, 14, 740, 8, 1766, 2090, 8, 1739, 12, 221, 366, 350, 12, 30202, 430, 267, 340, 4645, 59, 18, 61, 1137, 298, 16, 2, 436, 4645, 59, 20, 61, 508, 298, 17, 582, 288, 1433, 728, 63, 834, 63, 7322, 14, 740, 8, 21331, 3452, 63, 3377, 63, 28263, 8, 4504, 59, 17, 467, 4645, 59, 18, 2459, 272, 666, 14, 1600, 342, 272, 870, 480, 10924, 787, 450, 68, 3229, 736, 436, 450, 68, 1433, 728, 13, 834, 13, 7322, 315, 314, 4837, 18367, 850, 570, 14007, 552, 8, 599, 736, 395, 822, 8, 667, 728, 63, 834, 63, 7322, 1724, 272, 372, 3229, 736, 12, 1433, 728, 63, 834, 63, 7322, 199, 199, 3, 6668, 314, 1478, 367, 314, 15356, 2517, 1314, 365, 6656, 2419, 199, 3, 503, 4472, 370, 314, 2741, 574, 199, 318, 2342, 63, 1080, 8, 11329, 12, 574, 304, 272, 6465, 221, 275, 378, 272, 4721, 275, 822, 8, 11329, 7216, 17, 272, 1830, 4721, 690, 6465, 435, 413, 26, 267, 10887, 637, 275, 13341, 7528, 674, 11, 6260, 2447, 18, 61, 27144, 340, 574, 690, 10887, 637, 26, 288, 6465, 221, 275, 334, 674, 11, 6260, 2447, 18, 4960, 916, 574, 665, 10887, 637, 26, 288, 4721, 275, 334, 674, 11, 6260, 2447, 18, 446, 413, 267, 587, 26, 288, 372, 334, 674, 11, 6260, 2447, 18, 272, 340, 574, 665, 13341, 59, 674, 2189, 267, 4458, 480, 6005, 370, 2342, 1478, 14, 18704, 316, 12594, 272, 340, 574, 2356, 13341, 59, 6260, 2189, 267, 372, 4721, 272, 587, 26, 267, 372, 6465, 199, 199, 318, 365, 63, 6409, 2181, 867, 8, 65, 845, 12, 282, 713, 12, 282, 2025, 12, 282, 1081, 304, 272, 340, 334, 65, 845, 508, 282, 2025, 436, 282, 713, 508, 282, 1081, 9, 503, 334, 65, 845, 508, 282, 1081, 436, 282, 713, 508, 282, 2025, 304, 267, 372, 756, 272, 587, 26, 267, 372, 715, 523, 199, 318, 365, 63, 1410, 6933, 290, 8, 65, 845, 12, 282, 713, 12, 282, 2025, 12, 282, 1081, 12, 282, 2192, 12, 282, 708, 304, 272, 340, 334, 65, 2192, 508, 282, 845, 503, 282, 2192, 508, 282, 713, 9, 436, 334, 65, 708, 508, 282, 2025, 503, 282, 708, 508, 282, 1081, 304, 267, 372, 715, 272, 916, 334, 65, 2192, 508, 282, 2025, 503, 282, 2192, 508, 282, 1081, 9, 436, 334, 65, 708, 508, 282, 845, 503, 282, 708, 508, 282, 713, 304, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 199, 318, 5954, 63, 10913, 63, 14805, 8, 6409, 2181, 867, 63, 6851, 12, 11249, 1606, 304, 272, 327, 2790, 15379, 402, 1433, 728, 13, 834, 15109, 14924, 5591, 13292, 63, 3028, 63, 6851, 258, 275, 359, 7882, 14, 21501, 8, 442, 9, 367, 485, 315, 4945, 8, 22, 1874, 272, 11982, 63, 3028, 63, 6851, 275, 359, 7882, 14, 21501, 8, 442, 9, 367, 485, 315, 4945, 8, 22, 1874, 272, 734, 63, 1943, 63, 835, 259, 275, 378, 272, 315, 63, 1943, 63, 835, 258, 275, 378, 272, 367, 790, 12, 637, 315, 4339, 2181, 867, 63, 6851, 14, 1744, 837, 267, 13292, 63, 3028, 63, 6851, 59, 498, 59, 18, 11285, 17, 1527, 498, 59, 17, 11285, 498, 59, 16, 2677, 847, 1139, 267, 11982, 63, 3028, 63, 6851, 59, 498, 59, 18, 11285, 17, 1527, 27217, 8, 498, 59, 17, 11285, 498, 59, 16, 467, 790, 59, 18, 12457, 847, 1139, 272, 367, 671, 1302, 12, 3028, 63, 6851, 12, 262, 63, 1943, 315, 3482, 5234, 66, 1190, 401, 298, 32547, 2255, 5644, 359, 10913, 63, 3028, 63, 6851, 12, 11982, 63, 3028, 63, 6851, 467, 5644, 359, 2734, 13292, 12, 5191, 26, 13292, 5, 5191, 508, 378, 12, 2400, 1833, 12, 5191, 26, 1109, 8, 1155, 12694, 1609, 8, 1155, 9, 1622, 304, 267, 6085, 275, 4488, 14, 8941, 342, 267, 2185, 221, 275, 6085, 14, 525, 63, 13334, 8, 6673, 9, 267, 14981, 275, 3355, 8, 513, 8, 409, 8, 5270, 8, 2734, 671, 12, 89, 26, 88, 11, 89, 12, 2341, 8, 2734, 1315, 26, 1315, 14, 1612, 1062, 3915, 63, 6851, 430, 1724, 267, 9229, 275, 788, 67, 297, 283, 82, 297, 283, 71, 297, 283, 89, 297, 283, 66, 297, 283, 77, 418, 267, 946, 2492, 275, 2680, 14, 4250, 8,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
camptocamp/ngo-addons-backport
addons/base_import/test_models.py
97
2366
from openerp.osv import orm, fields def name(n): return 'base_import.tests.models.%s' % n class char(orm.Model): _name = name('char') _columns = { 'value': fields.char('unknown', size=None) } class char_required(orm.Model): _name = name('char.required') _columns = { 'value': fields.char('unknown', size=None, required=True) } class char_readonly(orm.Model): _name = name('char.readonly') _columns = { 'value': fields.char('unknown', size=None, readonly=True) } class char_states(orm.Model): _name = name('char.states') _columns = { 'value': fields.char('unknown', size=None, readonly=True, states={'draft': [('readonly', False)]}) } class char_noreadonly(orm.Model): _name = name('char.noreadonly') _columns = { 'value': fields.char('unknown', size=None, readonly=True, states={'draft': [('invisible', True)]}) } class char_stillreadonly(orm.Model): _name = name('char.stillreadonly') _columns = { 'value': fields.char('unknown', size=None, readonly=True, states={'draft': [('readonly', True)]}) } # TODO: complex field (m2m, o2m, m2o) class m2o(orm.Model): _name = name('m2o') _columns = { 'value': fields.many2one(name('m2o.related')) } class m2o_related(orm.Model): _name = name('m2o.related') _columns = { 'value': fields.integer() } _defaults = { 'value': 42 } class m2o_required(orm.Model): _name = name('m2o.required') _columns = { 'value': fields.many2one(name('m2o.required.related'), required=True) } class m2o_required_related(orm.Model): _name = name('m2o.required.related') _columns = { 'value': fields.integer() } _defaults = { 'value': 42 } class o2m(orm.Model): _name = name('o2m') _columns = { 'value': fields.one2many(name('o2m.child'), 'parent_id') } class o2m_child(orm.Model): _name = name('o2m.child') _columns = { 'parent_id': fields.many2one(name('o2m')), 'value': fields.integer() } class preview_model(orm.Model): _name = name('preview') _columns = { 'name': fields.char('Name', size=None), 'somevalue': fields.integer('Some Value', required=True), 'othervalue': fields.integer('Other Variable'), }
agpl-3.0
[ 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 199, 318, 536, 8, 78, 304, 372, 283, 1095, 63, 646, 14, 2219, 14, 992, 4111, 83, 7, 450, 302, 199, 199, 533, 1495, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 9, 272, 789, 199, 199, 533, 1495, 63, 2427, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 2427, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 1415, 29, 549, 9, 272, 789, 199, 199, 533, 1495, 63, 6753, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 6753, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 9, 272, 789, 199, 199, 533, 1495, 63, 4981, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 4981, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 6753, 297, 756, 1874, 1552, 272, 789, 199, 199, 533, 1495, 63, 27400, 350, 2118, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 27400, 350, 2118, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 262, 6604, 297, 715, 1874, 1552, 272, 789, 199, 199, 533, 1495, 63, 32310, 6753, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 32310, 6753, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 6753, 297, 715, 1874, 1552, 272, 789, 199, 199, 3, 3254, 26, 6114, 901, 334, 77, 18, 77, 12, 312, 18, 77, 12, 333, 18, 79, 9, 199, 533, 333, 18, 79, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 77, 18, 79, 14, 2407, 1333, 272, 789, 199, 533, 333, 18, 79, 63, 2407, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2407, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 585, 356, 5685, 272, 789, 199, 199, 533, 333, 18, 79, 63, 2427, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2427, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 77, 18, 79, 14, 2427, 14, 2407, 659, 1415, 29, 549, 9, 272, 789, 199, 533, 333, 18, 79, 63, 2427, 63, 2407, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2427, 14, 2407, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 585, 356, 5685, 272, 789, 199, 199, 533, 312, 18, 77, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 79, 18, 77, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 368, 18, 3479, 8, 354, 360, 79, 18, 77, 14, 1739, 659, 283, 1708, 63, 344, 358, 272, 789, 199, 533, 312, 18, 77, 63, 1739, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 79, 18, 77, 14, 1739, 358, 339, 485, 3406, 275, 469, 267, 283, 1708, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 79, 18, 77, 3855, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 199, 199, 533, 19653, 63, 1238, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 7780, 358, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 1568, 29, 403, 395, 267, 283, 3972, 585, 356, 1504, 14, 4115, 360, 7700, 1594, 297, 1415, 29, 549, 395, 267, 283, 1848, 585, 356, 1504, 14, 4115, 360, 8632, 4905, 659, 272, 789, 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 ]
[ 5166, 14, 4795, 492, 9813, 12, 1504, 199, 199, 318, 536, 8, 78, 304, 372, 283, 1095, 63, 646, 14, 2219, 14, 992, 4111, 83, 7, 450, 302, 199, 199, 533, 1495, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 9, 272, 789, 199, 199, 533, 1495, 63, 2427, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 2427, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 1415, 29, 549, 9, 272, 789, 199, 199, 533, 1495, 63, 6753, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 6753, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 9, 272, 789, 199, 199, 533, 1495, 63, 4981, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 4981, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 6753, 297, 756, 1874, 1552, 272, 789, 199, 199, 533, 1495, 63, 27400, 350, 2118, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 27400, 350, 2118, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 262, 6604, 297, 715, 1874, 1552, 272, 789, 199, 199, 533, 1495, 63, 32310, 6753, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 1560, 14, 32310, 6753, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 1560, 360, 5187, 297, 1568, 29, 403, 12, 6863, 29, 549, 12, 6363, 3713, 7185, 356, 4274, 6753, 297, 715, 1874, 1552, 272, 789, 199, 199, 3, 3254, 26, 6114, 901, 334, 77, 18, 77, 12, 312, 18, 77, 12, 333, 18, 79, 9, 199, 533, 333, 18, 79, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 77, 18, 79, 14, 2407, 1333, 272, 789, 199, 533, 333, 18, 79, 63, 2407, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2407, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 585, 356, 5685, 272, 789, 199, 199, 533, 333, 18, 79, 63, 2427, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2427, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 77, 18, 79, 14, 2427, 14, 2407, 659, 1415, 29, 549, 9, 272, 789, 199, 533, 333, 18, 79, 63, 2427, 63, 2407, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 77, 18, 79, 14, 2427, 14, 2407, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 585, 356, 5685, 272, 789, 199, 199, 533, 312, 18, 77, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 79, 18, 77, 358, 339, 485, 3406, 275, 469, 267, 283, 585, 356, 1504, 14, 368, 18, 3479, 8, 354, 360, 79, 18, 77, 14, 1739, 659, 283, 1708, 63, 344, 358, 272, 789, 199, 533, 312, 18, 77, 63, 1739, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 79, 18, 77, 14, 1739, 358, 339, 485, 3406, 275, 469, 267, 283, 1708, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 354, 360, 79, 18, 77, 3855, 267, 283, 585, 356, 1504, 14, 4115, 342, 272, 789, 199, 199, 533, 19653, 63, 1238, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 536, 360, 7780, 358, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 1568, 29, 403, 395, 267, 283, 3972, 585, 356, 1504, 14, 4115, 360, 7700, 1594, 297, 1415, 29, 549, 395, 267, 283, 1848, 585, 356, 1504, 14, 4115, 360, 8632, 4905, 659, 272, 789, 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, 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, 0 ]
j-griffith/cinder
cinder/tests/unit/volume/drivers/dell_emc/vnx/test_replication.py
4
4014
# Copyright (c) 2017 Dell Inc. or its subsidiaries. # 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. import mock from cinder import context from cinder.objects import fields from cinder import test from cinder.tests.unit.volume.drivers.dell_emc.vnx import res_mock from cinder.tests.unit.volume.drivers.dell_emc.vnx import utils from cinder.volume import configuration as conf from cinder.volume.drivers.dell_emc.vnx import utils as vnx_utils class TestReplicationAdapter(test.TestCase): def setUp(self): super(TestReplicationAdapter, self).setUp() self.configuration = conf.Configuration(None) vnx_utils.init_ops(self.configuration) self.configuration.san_ip = '192.168.1.1' self.configuration.storage_vnx_authentication_type = 'global' self.ctxt = context.get_admin_context() @utils.patch_group_specs({ 'consistent_group_replication_enabled': '<is> True'}) @res_mock.mock_driver_input @res_mock.patch_common_adapter def test_enable_replication(self, common_adapter, mocked_res, mocked_input): group = mocked_input['group'] volumes = [mocked_input['volume1'], mocked_input['volume2']] volumes[0].group = group volumes[1].group = group common_adapter.enable_replication(self.ctxt, group, volumes) @utils.patch_group_specs({ 'consistent_group_replication_enabled': '<is> True'}) @res_mock.mock_driver_input @res_mock.patch_common_adapter def test_disable_replication(self, common_adapter, mocked_res, mocked_input): group = mocked_input['group'] volumes = [mocked_input['volume1'], mocked_input['volume2']] volumes[0].group = group volumes[1].group = group common_adapter.disable_replication(self.ctxt, group, volumes) @utils.patch_group_specs({ 'consistent_group_replication_enabled': '<is> True'}) @res_mock.mock_driver_input @res_mock.patch_common_adapter def test_failover_replication(self, common_adapter, mocked_res, mocked_input): device = utils.get_replication_device() common_adapter.config.replication_device = [device] group = mocked_input['group'] volumes = [mocked_input['volume1'], mocked_input['volume2']] lun1 = mocked_res['lun1'] volumes[0].group = group volumes[1].group = group secondary_backend_id = 'fake_serial' with mock.patch.object(common_adapter, 'build_mirror_view') as fake: fake_mirror = utils.build_fake_mirror_view() fake_mirror.secondary_client.get_lun.return_value = lun1 fake_mirror.secondary_client.get_serial.return_value = ( device['backend_id']) fake.return_value = fake_mirror model_update, volume_updates = common_adapter.failover_replication( self.ctxt, group, volumes, secondary_backend_id) fake_mirror.promote_mirror_group.assert_called_with( group.id.replace('-', '')) self.assertEqual(fields.ReplicationStatus.FAILED_OVER, model_update['replication_status']) for update in volume_updates: self.assertEqual(fields.ReplicationStatus.FAILED_OVER, update['replication_status'])
apache-2.0
[ 3, 1898, 334, 67, 9, 9708, 577, 1697, 3277, 14, 503, 2399, 1007, 338, 328, 3433, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 13069, 492, 1067, 199, 504, 13069, 14, 1462, 492, 1504, 199, 504, 13069, 492, 511, 199, 504, 13069, 14, 2219, 14, 3248, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 522, 63, 1805, 199, 504, 13069, 14, 2219, 14, 3248, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 3778, 199, 504, 13069, 14, 2405, 492, 2897, 465, 3743, 199, 504, 13069, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 3778, 465, 373, 7343, 63, 1208, 421, 199, 533, 1379, 31320, 10200, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 31320, 10200, 12, 291, 680, 5996, 342, 267, 291, 14, 4758, 275, 3743, 14, 5688, 8, 403, 9, 267, 373, 7343, 63, 1208, 14, 826, 63, 1483, 8, 277, 14, 4758, 9, 267, 291, 14, 4758, 14, 18904, 63, 711, 275, 283, 5756, 14, 6568, 14, 17, 14, 17, 7, 267, 291, 14, 4758, 14, 3494, 63, 6002, 88, 63, 11725, 63, 466, 275, 283, 2966, 7, 267, 291, 14, 6725, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 4296, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 1816, 16991, 63, 1210, 304, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 673, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 2863, 63, 10394, 14, 4296, 63, 17144, 8, 277, 14, 6725, 12, 1572, 12, 12158, 9, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 5993, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 639, 16991, 63, 1210, 304, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 673, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 2863, 63, 10394, 14, 5993, 63, 17144, 8, 277, 14, 6725, 12, 1572, 12, 12158, 9, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 667, 23165, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 3303, 16991, 63, 1210, 304, 267, 2243, 275, 3778, 14, 362, 63, 17144, 63, 1782, 342, 267, 2863, 63, 10394, 14, 888, 14, 17144, 63, 1782, 275, 359, 1782, 61, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 19465, 17, 275, 16991, 63, 470, 459, 13542, 17, 418, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 13851, 63, 4620, 63, 344, 275, 283, 3183, 63, 2171, 7, 267, 543, 1683, 14, 2068, 14, 785, 8, 2330, 63, 10394, 12, 3044, 283, 1506, 63, 12324, 63, 1345, 358, 465, 4026, 26, 288, 4026, 63, 12324, 275, 3778, 14, 1506, 63, 3183, 63, 12324, 63, 1345, 342, 288, 4026, 63, 12324, 14, 12371, 63, 1258, 14, 362, 63, 13542, 14, 1107, 63, 585, 275, 19465, 17, 288, 4026, 63, 12324, 14, 12371, 63, 1258, 14, 362, 63, 2171, 14, 1107, 63, 585, 275, 334, 355, 2243, 459, 4620, 63, 344, 1105, 288, 4026, 14, 1107, 63, 585, 275, 4026, 63, 12324, 288, 1402, 63, 873, 12, 3301, 63, 7618, 275, 2863, 63, 10394, 14, 667, 23165, 63, 17144, 8, 355, 291, 14, 6725, 12, 1572, 12, 12158, 12, 13851, 63, 4620, 63, 344, 9, 953, 4026, 63, 12324, 14, 20422, 63, 12324, 63, 923, 14, 479, 63, 3527, 63, 1045, 8, 355, 1572, 14, 344, 14, 1814, 13858, 12381, 288, 291, 14, 629, 8, 955, 14, 31320, 3694, 14, 12299, 63, 14336, 12, 2490, 1402, 63, 873, 459, 17144, 63, 1205, 1105, 288, 367, 1678, 315, 3301, 63, 7618, 26, 355, 291, 14, 629, 8, 955, 14, 31320, 3694, 14, 12299, 63, 14336, 12, 639, 1678, 459, 17144, 63, 1205, 1105, 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 ]
[ 1898, 334, 67, 9, 9708, 577, 1697, 3277, 14, 503, 2399, 1007, 338, 328, 3433, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 13069, 492, 1067, 199, 504, 13069, 14, 1462, 492, 1504, 199, 504, 13069, 492, 511, 199, 504, 13069, 14, 2219, 14, 3248, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 522, 63, 1805, 199, 504, 13069, 14, 2219, 14, 3248, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 3778, 199, 504, 13069, 14, 2405, 492, 2897, 465, 3743, 199, 504, 13069, 14, 2405, 14, 13337, 14, 271, 914, 63, 69, 5466, 14, 6002, 88, 492, 3778, 465, 373, 7343, 63, 1208, 421, 199, 533, 1379, 31320, 10200, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 31320, 10200, 12, 291, 680, 5996, 342, 267, 291, 14, 4758, 275, 3743, 14, 5688, 8, 403, 9, 267, 373, 7343, 63, 1208, 14, 826, 63, 1483, 8, 277, 14, 4758, 9, 267, 291, 14, 4758, 14, 18904, 63, 711, 275, 283, 5756, 14, 6568, 14, 17, 14, 17, 7, 267, 291, 14, 4758, 14, 3494, 63, 6002, 88, 63, 11725, 63, 466, 275, 283, 2966, 7, 267, 291, 14, 6725, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 4296, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 1816, 16991, 63, 1210, 304, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 673, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 2863, 63, 10394, 14, 4296, 63, 17144, 8, 277, 14, 6725, 12, 1572, 12, 12158, 9, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 5993, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 639, 16991, 63, 1210, 304, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 673, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 2863, 63, 10394, 14, 5993, 63, 17144, 8, 277, 14, 6725, 12, 1572, 12, 12158, 9, 339, 768, 1208, 14, 2068, 63, 923, 63, 7273, 2561, 267, 283, 15478, 63, 923, 63, 17144, 63, 3827, 356, 2650, 374, 30, 715, 3071, 272, 768, 470, 63, 1805, 14, 1805, 63, 3090, 63, 1210, 272, 768, 470, 63, 1805, 14, 2068, 63, 2330, 63, 10394, 272, 347, 511, 63, 667, 23165, 63, 17144, 8, 277, 12, 2863, 63, 10394, 12, 16991, 63, 470, 12, 3303, 16991, 63, 1210, 304, 267, 2243, 275, 3778, 14, 362, 63, 17144, 63, 1782, 342, 267, 2863, 63, 10394, 14, 888, 14, 17144, 63, 1782, 275, 359, 1782, 61, 267, 1572, 275, 16991, 63, 1210, 459, 923, 418, 267, 12158, 275, 359, 27740, 63, 1210, 459, 2405, 17, 995, 16991, 63, 1210, 459, 2405, 18, 6538, 267, 19465, 17, 275, 16991, 63, 470, 459, 13542, 17, 418, 267, 12158, 59, 16, 1055, 923, 275, 1572, 267, 12158, 59, 17, 1055, 923, 275, 1572, 267, 13851, 63, 4620, 63, 344, 275, 283, 3183, 63, 2171, 7, 267, 543, 1683, 14, 2068, 14, 785, 8, 2330, 63, 10394, 12, 3044, 283, 1506, 63, 12324, 63, 1345, 358, 465, 4026, 26, 288, 4026, 63, 12324, 275, 3778, 14, 1506, 63, 3183, 63, 12324, 63, 1345, 342, 288, 4026, 63, 12324, 14, 12371, 63, 1258, 14, 362, 63, 13542, 14, 1107, 63, 585, 275, 19465, 17, 288, 4026, 63, 12324, 14, 12371, 63, 1258, 14, 362, 63, 2171, 14, 1107, 63, 585, 275, 334, 355, 2243, 459, 4620, 63, 344, 1105, 288, 4026, 14, 1107, 63, 585, 275, 4026, 63, 12324, 288, 1402, 63, 873, 12, 3301, 63, 7618, 275, 2863, 63, 10394, 14, 667, 23165, 63, 17144, 8, 355, 291, 14, 6725, 12, 1572, 12, 12158, 12, 13851, 63, 4620, 63, 344, 9, 953, 4026, 63, 12324, 14, 20422, 63, 12324, 63, 923, 14, 479, 63, 3527, 63, 1045, 8, 355, 1572, 14, 344, 14, 1814, 13858, 12381, 288, 291, 14, 629, 8, 955, 14, 31320, 3694, 14, 12299, 63, 14336, 12, 2490, 1402, 63, 873, 459, 17144, 63, 1205, 1105, 288, 367, 1678, 315, 3301, 63, 7618, 26, 355, 291, 14, 629, 8, 955, 14, 31320, 3694, 14, 12299, 63, 14336, 12, 639, 1678, 459, 17144, 63, 1205, 1105, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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py
254
12206
# -*- coding: utf-8 -*- r""" werkzeug.contrib.securecookie ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module implements a cookie that is not alterable from the client because it adds a checksum the server checks for. You can use it as session replacement if all you have is a user id or something to mark a logged in user. Keep in mind that the data is still readable from the client as a normal cookie is. However you don't have to store and flush the sessions you have at the server. Example usage: >>> from werkzeug.contrib.securecookie import SecureCookie >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef") Dumping into a string so that one can store it in a cookie: >>> value = x.serialize() Loading from that string again: >>> x = SecureCookie.unserialize(value, "deadbeef") >>> x["baz"] (1, 2, 3) If someone modifies the cookie and the checksum is wrong the unserialize method will fail silently and return a new empty `SecureCookie` object. Keep in mind that the values will be visible in the cookie so do not store data in a cookie you don't want the user to see. Application Integration ======================= If you are using the werkzeug request objects you could integrate the secure cookie into your application like this:: from werkzeug.utils import cached_property from werkzeug.wrappers import BaseRequest from werkzeug.contrib.securecookie import SecureCookie # don't use this key but a different one; you could just use # os.urandom(20) to get something random SECRET_KEY = '\xfa\xdd\xb8z\xae\xe0}4\x8b\xea' class Request(BaseRequest): @cached_property def client_session(self): data = self.cookies.get('session_data') if not data: return SecureCookie(secret_key=SECRET_KEY) return SecureCookie.unserialize(data, SECRET_KEY) def application(environ, start_response): request = Request(environ, start_response) # get a response object here response = ... if request.client_session.should_save: session_data = request.client_session.serialize() response.set_cookie('session_data', session_data, httponly=True) return response(environ, start_response) A less verbose integration can be achieved by using shorthand methods:: class Request(BaseRequest): @cached_property def client_session(self): return SecureCookie.load_cookie(self, secret_key=COOKIE_SECRET) def application(environ, start_response): request = Request(environ, start_response) # get a response object here response = ... request.client_session.save_cookie(response) return response(environ, start_response) :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import pickle import base64 from hmac import new as hmac from time import time from hashlib import sha1 as _default_hash from werkzeug._compat import iteritems, text_type from werkzeug.urls import url_quote_plus, url_unquote_plus from werkzeug._internal import _date_to_unix from werkzeug.contrib.sessions import ModificationTrackingDict from werkzeug.security import safe_str_cmp from werkzeug._compat import to_native class UnquoteError(Exception): """Internal exception used to signal failures on quoting.""" class SecureCookie(ModificationTrackingDict): """Represents a secure cookie. You can subclass this class and provide an alternative mac method. The import thing is that the mac method is a function with a similar interface to the hashlib. Required methods are update() and digest(). Example usage: >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef") >>> x["foo"] 42 >>> x["baz"] (1, 2, 3) >>> x["blafasel"] = 23 >>> x.should_save True :param data: the initial data. Either a dict, list of tuples or `None`. :param secret_key: the secret key. If not set `None` or not specified it has to be set before :meth:`serialize` is called. :param new: The initial value of the `new` flag. """ #: The hash method to use. This has to be a module with a new function #: or a function that creates a hashlib object. Such as `hashlib.md5` #: Subclasses can override this attribute. The default hash is sha1. #: Make sure to wrap this in staticmethod() if you store an arbitrary #: function there such as hashlib.sha1 which might be implemented #: as a function. hash_method = staticmethod(_default_hash) #: the module used for serialization. Unless overriden by subclasses #: the standard pickle module is used. serialization_method = pickle #: if the contents should be base64 quoted. This can be disabled if the #: serialization process returns cookie safe strings only. quote_base64 = True def __init__(self, data=None, secret_key=None, new=True): ModificationTrackingDict.__init__(self, data or ()) # explicitly convert it into a bytestring because python 2.6 # no longer performs an implicit string conversion on hmac if secret_key is not None: secret_key = bytes(secret_key) self.secret_key = secret_key self.new = new def __repr__(self): return '<%s %s%s>' % ( self.__class__.__name__, dict.__repr__(self), self.should_save and '*' or '' ) @property def should_save(self): """True if the session should be saved. By default this is only true for :attr:`modified` cookies, not :attr:`new`. """ return self.modified @classmethod def quote(cls, value): """Quote the value for the cookie. This can be any object supported by :attr:`serialization_method`. :param value: the value to quote. """ if cls.serialization_method is not None: value = cls.serialization_method.dumps(value) if cls.quote_base64: value = b''.join(base64.b64encode(value).splitlines()).strip() return value @classmethod def unquote(cls, value): """Unquote the value for the cookie. If unquoting does not work a :exc:`UnquoteError` is raised. :param value: the value to unquote. """ try: if cls.quote_base64: value = base64.b64decode(value) if cls.serialization_method is not None: value = cls.serialization_method.loads(value) return value except Exception: # unfortunately pickle and other serialization modules can # cause pretty every error here. if we get one we catch it # and convert it into an UnquoteError raise UnquoteError() def serialize(self, expires=None): """Serialize the secure cookie into a string. If expires is provided, the session will be automatically invalidated after expiration when you unseralize it. This provides better protection against session cookie theft. :param expires: an optional expiration date for the cookie (a :class:`datetime.datetime` object) """ if self.secret_key is None: raise RuntimeError('no secret key defined') if expires: self['_expires'] = _date_to_unix(expires) result = [] mac = hmac(self.secret_key, None, self.hash_method) for key, value in sorted(self.items()): result.append(('%s=%s' % ( url_quote_plus(key), self.quote(value).decode('ascii') )).encode('ascii')) mac.update(b'|' + result[-1]) return b'?'.join([ base64.b64encode(mac.digest()).strip(), b'&'.join(result) ]) @classmethod def unserialize(cls, string, secret_key): """Load the secure cookie from a serialized string. :param string: the cookie value to unserialize. :param secret_key: the secret key used to serialize the cookie. :return: a new :class:`SecureCookie`. """ if isinstance(string, text_type): string = string.encode('utf-8', 'replace') if isinstance(secret_key, text_type): secret_key = secret_key.encode('utf-8', 'replace') try: base64_hash, data = string.split(b'?', 1) except (ValueError, IndexError): items = () else: items = {} mac = hmac(secret_key, None, cls.hash_method) for item in data.split(b'&'): mac.update(b'|' + item) if b'=' not in item: items = None break key, value = item.split(b'=', 1) # try to make the key a string key = url_unquote_plus(key.decode('ascii')) try: key = to_native(key) except UnicodeError: pass items[key] = value # no parsing error and the mac looks okay, we can now # sercurely unpickle our cookie. try: client_hash = base64.b64decode(base64_hash) except TypeError: items = client_hash = None if items is not None and safe_str_cmp(client_hash, mac.digest()): try: for key, value in iteritems(items): items[key] = cls.unquote(value) except UnquoteError: items = () else: if '_expires' in items: if time() > items['_expires']: items = () else: del items['_expires'] else: items = () return cls(items, secret_key, False) @classmethod def load_cookie(cls, request, key='session', secret_key=None): """Loads a :class:`SecureCookie` from a cookie in request. If the cookie is not set, a new :class:`SecureCookie` instanced is returned. :param request: a request object that has a `cookies` attribute which is a dict of all cookie values. :param key: the name of the cookie. :param secret_key: the secret key used to unquote the cookie. Always provide the value even though it has no default! """ data = request.cookies.get(key) if not data: return cls(secret_key=secret_key) return cls.unserialize(data, secret_key) def save_cookie(self, response, key='session', expires=None, session_expires=None, max_age=None, path='/', domain=None, secure=None, httponly=False, force=False): """Saves the SecureCookie in a cookie on response object. All parameters that are not described here are forwarded directly to :meth:`~BaseResponse.set_cookie`. :param response: a response object that has a :meth:`~BaseResponse.set_cookie` method. :param key: the name of the cookie. :param session_expires: the expiration date of the secure cookie stored information. If this is not provided the cookie `expires` date is used instead. """ if force or self.should_save: data = self.serialize(session_expires or expires) response.set_cookie(key, data, expires=expires, max_age=max_age, path=path, domain=domain, secure=secure, httponly=httponly)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10380, 14, 2828, 14, 7817, 5306, 272, 18294, 22935, 94, 339, 961, 859, 9031, 282, 5494, 626, 365, 440, 741, 13048, 687, 314, 1890, 272, 2952, 652, 9584, 282, 9040, 314, 1654, 5920, 367, 14, 221, 2047, 883, 675, 652, 465, 272, 2351, 8343, 340, 1006, 1265, 1172, 365, 282, 922, 1305, 503, 6020, 370, 2216, 272, 282, 10367, 315, 922, 14, 339, 14797, 315, 25169, 626, 314, 666, 365, 5139, 12701, 687, 314, 1890, 465, 282, 272, 3293, 5494, 365, 14, 221, 9738, 1265, 2793, 1133, 1172, 370, 3877, 436, 8976, 314, 272, 12184, 1265, 1172, 737, 314, 1654, 14, 339, 5679, 4503, 26, 339, 1306, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 272, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 339, 19460, 316, 1901, 282, 1059, 880, 626, 1373, 883, 3877, 652, 315, 282, 5494, 26, 339, 1306, 574, 275, 671, 14, 3549, 342, 339, 3835, 5384, 687, 626, 1059, 4020, 26, 339, 1306, 671, 275, 30894, 7810, 14, 324, 3549, 8, 585, 12, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 339, 982, 17122, 26473, 314, 5494, 436, 314, 9040, 365, 6835, 314, 625, 3549, 272, 1083, 911, 2449, 18030, 436, 372, 282, 892, 2701, 658, 24117, 7810, 64, 909, 14, 339, 14797, 315, 25169, 626, 314, 1338, 911, 506, 8917, 315, 314, 5494, 880, 886, 440, 272, 3877, 666, 315, 282, 5494, 1265, 2793, 1133, 2934, 314, 922, 370, 1937, 14, 339, 13515, 27561, 272, 16248, 23476, 339, 982, 1265, 787, 1808, 314, 10380, 1056, 2251, 1265, 4293, 21494, 314, 272, 11153, 5494, 1901, 2195, 4223, 2839, 642, 447, 398, 687, 10380, 14, 1208, 492, 6328, 63, 1829, 267, 687, 10380, 14, 21148, 492, 3523, 2017, 267, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 398, 327, 2793, 1133, 675, 642, 790, 1325, 282, 3365, 1373, 27, 1265, 4293, 2951, 675, 267, 327, 747, 14, 22776, 8, 1165, 9, 370, 664, 6020, 2196, 267, 5795, 11771, 63, 3078, 275, 1557, 10500, 60, 11110, 60, 1774, 24, 90, 60, 10183, 60, 1845, 16, 93, 20, 60, 88, 24, 66, 60, 10656, 7, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 666, 275, 291, 14, 7792, 14, 362, 360, 1730, 63, 576, 358, 355, 340, 440, 666, 26, 490, 372, 30894, 7810, 8, 4731, 63, 498, 29, 12961, 63, 3078, 9, 355, 372, 30894, 7810, 14, 324, 3549, 8, 576, 12, 5795, 11771, 63, 3078, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 340, 1056, 14, 1258, 63, 1730, 14, 5626, 63, 2117, 26, 355, 2351, 63, 576, 275, 1056, 14, 1258, 63, 1730, 14, 3549, 342, 355, 1177, 14, 409, 63, 5306, 360, 1730, 63, 576, 297, 2351, 63, 576, 12, 2511, 22768, 26960, 29, 549, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 437, 6656, 3376, 13150, 883, 506, 22175, 1354, 701, 1808, 1033, 23999, 3102, 447, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 372, 30894, 7810, 14, 912, 63, 5306, 8, 277, 12, 7565, 63, 498, 29, 13665, 63, 12961, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 1056, 14, 1258, 63, 1730, 14, 2117, 63, 5306, 8, 1310, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 520, 7307, 26, 334, 67, 9, 6927, 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, 5927, 199, 646, 1300, 772, 199, 504, 20330, 492, 892, 465, 20330, 199, 504, 900, 492, 900, 199, 504, 8337, 492, 7793, 17, 465, 485, 885, 63, 2227, 199, 199, 504, 10380, 423, 5819, 492, 10849, 12, 1318, 63, 466, 199, 504, 10380, 14, 3603, 492, 1166, 63, 3513, 63, 6666, 12, 1166, 63, 12240, 63, 6666, 199, 504, 10380, 423, 4672, 492, 485, 602, 63, 475, 63, 11864, 199, 504, 10380, 14, 2828, 14, 11676, 492, 12972, 3477, 23785, 2141, 199, 504, 10380, 14, 4416, 492, 5048, 63, 495, 63, 5730, 199, 504, 10380, 423, 5819, 492, 370, 63, 6106, 421, 199, 533, 1910, 3513, 547, 8, 1726, 304, 339, 408, 8405, 1919, 1202, 370, 4673, 9081, 641, 18593, 1041, 421, 199, 533, 30894, 7810, 8, 29188, 23785, 2141, 304, 339, 408, 18089, 282, 11153, 5494, 14, 221, 2047, 883, 5516, 642, 1021, 436, 5647, 272, 376, 13943, 4497, 1083, 14, 221, 710, 492, 8377, 365, 626, 314, 4497, 1083, 272, 365, 282, 805, 543, 282, 8545, 3217, 370, 314, 8337, 14, 221, 11105, 272, 3102, 787, 1678, 342, 436, 10017, 1252, 339, 5679, 4503, 26, 339, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 1421, 937, 272, 5685, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 272, 1306, 671, 905, 21244, 70, 482, 76, 937, 275, 6546, 272, 1306, 671, 14, 5626, 63, 2117, 272, 715, 339, 520, 635, 666, 26, 314, 2536, 666, 14, 221, 13083, 282, 1211, 12, 769, 402, 6346, 503, 658, 403, 2313, 272, 520, 635, 7565, 63, 498, 26, 314, 7565, 790, 14, 221, 982, 440, 663, 658, 403, 64, 503, 440, 2013, 2432, 652, 965, 370, 506, 663, 2544, 520, 5247, 1705, 3549, 64, 365, 2797, 14, 272, 520, 635, 892, 26, 710, 2536, 574, 402, 314, 658, 1222, 64, 3305, 14, 272, 408, 339, 6079, 710, 2631, 1083, 370 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10380, 14, 2828, 14, 7817, 5306, 272, 18294, 22935, 94, 339, 961, 859, 9031, 282, 5494, 626, 365, 440, 741, 13048, 687, 314, 1890, 272, 2952, 652, 9584, 282, 9040, 314, 1654, 5920, 367, 14, 221, 2047, 883, 675, 652, 465, 272, 2351, 8343, 340, 1006, 1265, 1172, 365, 282, 922, 1305, 503, 6020, 370, 2216, 272, 282, 10367, 315, 922, 14, 339, 14797, 315, 25169, 626, 314, 666, 365, 5139, 12701, 687, 314, 1890, 465, 282, 272, 3293, 5494, 365, 14, 221, 9738, 1265, 2793, 1133, 1172, 370, 3877, 436, 8976, 314, 272, 12184, 1265, 1172, 737, 314, 1654, 14, 339, 5679, 4503, 26, 339, 1306, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 272, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 339, 19460, 316, 1901, 282, 1059, 880, 626, 1373, 883, 3877, 652, 315, 282, 5494, 26, 339, 1306, 574, 275, 671, 14, 3549, 342, 339, 3835, 5384, 687, 626, 1059, 4020, 26, 339, 1306, 671, 275, 30894, 7810, 14, 324, 3549, 8, 585, 12, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 339, 982, 17122, 26473, 314, 5494, 436, 314, 9040, 365, 6835, 314, 625, 3549, 272, 1083, 911, 2449, 18030, 436, 372, 282, 892, 2701, 658, 24117, 7810, 64, 909, 14, 339, 14797, 315, 25169, 626, 314, 1338, 911, 506, 8917, 315, 314, 5494, 880, 886, 440, 272, 3877, 666, 315, 282, 5494, 1265, 2793, 1133, 2934, 314, 922, 370, 1937, 14, 339, 13515, 27561, 272, 16248, 23476, 339, 982, 1265, 787, 1808, 314, 10380, 1056, 2251, 1265, 4293, 21494, 314, 272, 11153, 5494, 1901, 2195, 4223, 2839, 642, 447, 398, 687, 10380, 14, 1208, 492, 6328, 63, 1829, 267, 687, 10380, 14, 21148, 492, 3523, 2017, 267, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 398, 327, 2793, 1133, 675, 642, 790, 1325, 282, 3365, 1373, 27, 1265, 4293, 2951, 675, 267, 327, 747, 14, 22776, 8, 1165, 9, 370, 664, 6020, 2196, 267, 5795, 11771, 63, 3078, 275, 1557, 10500, 60, 11110, 60, 1774, 24, 90, 60, 10183, 60, 1845, 16, 93, 20, 60, 88, 24, 66, 60, 10656, 7, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 666, 275, 291, 14, 7792, 14, 362, 360, 1730, 63, 576, 358, 355, 340, 440, 666, 26, 490, 372, 30894, 7810, 8, 4731, 63, 498, 29, 12961, 63, 3078, 9, 355, 372, 30894, 7810, 14, 324, 3549, 8, 576, 12, 5795, 11771, 63, 3078, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 340, 1056, 14, 1258, 63, 1730, 14, 5626, 63, 2117, 26, 355, 2351, 63, 576, 275, 1056, 14, 1258, 63, 1730, 14, 3549, 342, 355, 1177, 14, 409, 63, 5306, 360, 1730, 63, 576, 297, 2351, 63, 576, 12, 2511, 22768, 26960, 29, 549, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 437, 6656, 3376, 13150, 883, 506, 22175, 1354, 701, 1808, 1033, 23999, 3102, 447, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 372, 30894, 7810, 14, 912, 63, 5306, 8, 277, 12, 7565, 63, 498, 29, 13665, 63, 12961, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 1056, 14, 1258, 63, 1730, 14, 2117, 63, 5306, 8, 1310, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 520, 7307, 26, 334, 67, 9, 6927, 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, 5927, 199, 646, 1300, 772, 199, 504, 20330, 492, 892, 465, 20330, 199, 504, 900, 492, 900, 199, 504, 8337, 492, 7793, 17, 465, 485, 885, 63, 2227, 199, 199, 504, 10380, 423, 5819, 492, 10849, 12, 1318, 63, 466, 199, 504, 10380, 14, 3603, 492, 1166, 63, 3513, 63, 6666, 12, 1166, 63, 12240, 63, 6666, 199, 504, 10380, 423, 4672, 492, 485, 602, 63, 475, 63, 11864, 199, 504, 10380, 14, 2828, 14, 11676, 492, 12972, 3477, 23785, 2141, 199, 504, 10380, 14, 4416, 492, 5048, 63, 495, 63, 5730, 199, 504, 10380, 423, 5819, 492, 370, 63, 6106, 421, 199, 533, 1910, 3513, 547, 8, 1726, 304, 339, 408, 8405, 1919, 1202, 370, 4673, 9081, 641, 18593, 1041, 421, 199, 533, 30894, 7810, 8, 29188, 23785, 2141, 304, 339, 408, 18089, 282, 11153, 5494, 14, 221, 2047, 883, 5516, 642, 1021, 436, 5647, 272, 376, 13943, 4497, 1083, 14, 221, 710, 492, 8377, 365, 626, 314, 4497, 1083, 272, 365, 282, 805, 543, 282, 8545, 3217, 370, 314, 8337, 14, 221, 11105, 272, 3102, 787, 1678, 342, 436, 10017, 1252, 339, 5679, 4503, 26, 339, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 1421, 937, 272, 5685, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 272, 1306, 671, 905, 21244, 70, 482, 76, 937, 275, 6546, 272, 1306, 671, 14, 5626, 63, 2117, 272, 715, 339, 520, 635, 666, 26, 314, 2536, 666, 14, 221, 13083, 282, 1211, 12, 769, 402, 6346, 503, 658, 403, 2313, 272, 520, 635, 7565, 63, 498, 26, 314, 7565, 790, 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, 1, 1, 1, 1, 1, 1, 1 ]
pathompongoo/ThGovJobApp
env/lib/python2.7/site-packages/pip/commands/install.py
187
14659
from __future__ import absolute_import import logging import operator import os import tempfile import shutil import warnings try: import wheel except ImportError: wheel = None from pip.req import RequirementSet from pip.basecommand import RequirementCommand from pip.locations import virtualenv_no_global, distutils_scheme from pip.index import PackageFinder from pip.exceptions import ( InstallationError, CommandError, PreviousBuildDirError, ) from pip import cmdoptions from pip.utils import ensure_dir from pip.utils.build import BuildDirectory from pip.utils.deprecation import RemovedInPip8Warning from pip.utils.filesystem import check_path_owner from pip.wheel import WheelCache, WheelBuilder logger = logging.getLogger(__name__) class InstallCommand(RequirementCommand): """ Install packages from: - PyPI (and other indexes) using requirement specifiers. - VCS project urls. - Local project directories. - Local or remote source archives. pip also supports installing from "requirements files", which provide an easy way to specify a whole environment to be installed. """ name = 'install' usage = """ %prog [options] <requirement specifier> [package-index-options] ... %prog [options] -r <requirements file> [package-index-options] ... %prog [options] [-e] <vcs project url> ... %prog [options] [-e] <local project path> ... %prog [options] <archive url/path> ...""" summary = 'Install packages.' def __init__(self, *args, **kw): super(InstallCommand, self).__init__(*args, **kw) cmd_opts = self.cmd_opts cmd_opts.add_option(cmdoptions.constraints()) cmd_opts.add_option(cmdoptions.editable()) cmd_opts.add_option(cmdoptions.requirements()) cmd_opts.add_option(cmdoptions.build_dir()) cmd_opts.add_option( '-t', '--target', dest='target_dir', metavar='dir', default=None, help='Install packages into <dir>. ' 'By default this will not replace existing files/folders in ' '<dir>. Use --upgrade to replace existing packages in <dir> ' 'with new versions.' ) cmd_opts.add_option( '-d', '--download', '--download-dir', '--download-directory', dest='download_dir', metavar='dir', default=None, help=("Download packages into <dir> instead of installing them, " "regardless of what's already installed."), ) cmd_opts.add_option(cmdoptions.download_cache()) cmd_opts.add_option(cmdoptions.src()) cmd_opts.add_option( '-U', '--upgrade', dest='upgrade', action='store_true', help='Upgrade all specified packages to the newest available ' 'version. This process is recursive regardless of whether ' 'a dependency is already satisfied.' ) cmd_opts.add_option( '--force-reinstall', dest='force_reinstall', action='store_true', help='When upgrading, reinstall all packages even if they are ' 'already up-to-date.') cmd_opts.add_option( '-I', '--ignore-installed', dest='ignore_installed', action='store_true', help='Ignore the installed packages (reinstalling instead).') cmd_opts.add_option(cmdoptions.no_deps()) cmd_opts.add_option(cmdoptions.install_options()) cmd_opts.add_option(cmdoptions.global_options()) cmd_opts.add_option( '--user', dest='use_user_site', action='store_true', help="Install to the Python user install directory for your " "platform. Typically ~/.local/, or %APPDATA%\Python on " "Windows. (See the Python documentation for site.USER_BASE " "for full details.)") cmd_opts.add_option( '--egg', dest='as_egg', action='store_true', help="Install packages as eggs, not 'flat', like pip normally " "does. This option is not about installing *from* eggs. " "(WARNING: Because this option overrides pip's normal install" " logic, requirements files may not behave as expected.)") cmd_opts.add_option( '--root', dest='root_path', metavar='dir', default=None, help="Install everything relative to this alternate root " "directory.") cmd_opts.add_option( "--compile", action="store_true", dest="compile", default=True, help="Compile py files to pyc", ) cmd_opts.add_option( "--no-compile", action="store_false", dest="compile", help="Do not compile py files to pyc", ) cmd_opts.add_option(cmdoptions.use_wheel()) cmd_opts.add_option(cmdoptions.no_use_wheel()) cmd_opts.add_option(cmdoptions.no_binary()) cmd_opts.add_option(cmdoptions.only_binary()) cmd_opts.add_option( '--pre', action='store_true', default=False, help="Include pre-release and development versions. By default, " "pip only finds stable versions.") cmd_opts.add_option(cmdoptions.no_clean()) index_opts = cmdoptions.make_option_group( cmdoptions.index_group, self.parser, ) self.parser.insert_option_group(0, index_opts) self.parser.insert_option_group(0, cmd_opts) def _build_package_finder(self, options, index_urls, session): """ Create a package finder appropriate to this install command. This method is meant to be overridden by subclasses, not called directly. """ return PackageFinder( find_links=options.find_links, format_control=options.format_control, index_urls=index_urls, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, trusted_hosts=options.trusted_hosts, allow_all_prereleases=options.pre, process_dependency_links=options.process_dependency_links, session=session, ) def run(self, options, args): cmdoptions.resolve_wheel_no_use_binary(options) cmdoptions.check_install_build_global(options) if options.download_dir: options.ignore_installed = True if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) options.src_dir = os.path.abspath(options.src_dir) install_options = options.install_options or [] if options.use_user_site: if virtualenv_no_global(): raise InstallationError( "Can not perform a '--user' install. User site-packages " "are not visible in this virtualenv." ) install_options.append('--user') install_options.append('--prefix=') temp_target_dir = None if options.target_dir: options.ignore_installed = True temp_target_dir = tempfile.mkdtemp() options.target_dir = os.path.abspath(options.target_dir) if (os.path.exists(options.target_dir) and not os.path.isdir(options.target_dir)): raise CommandError( "Target path exists but is not a directory, will not " "continue." ) install_options.append('--home=' + temp_target_dir) global_options = options.global_options or [] index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.info('Ignoring indexes: %s', ','.join(index_urls)) index_urls = [] if options.download_cache: warnings.warn( "--download-cache has been deprecated and will be removed in " "the future. Pip now automatically uses and configures its " "cache.", RemovedInPip8Warning, ) with self._build_session(options) as session: finder = self._build_package_finder(options, index_urls, session) build_delete = (not (options.no_clean or options.build_dir)) wheel_cache = WheelCache(options.cache_dir, options.format_control) if options.cache_dir and not check_path_owner(options.cache_dir): logger.warning( "The directory '%s' or its parent directory is not owned " "by the current user and caching wheels has been " "disabled. check the permissions and owner of that " "directory. If executing pip with sudo, you may want " "sudo's -H flag.", options.cache_dir, ) options.cache_dir = None with BuildDirectory(options.build_dir, delete=build_delete) as build_dir: requirement_set = RequirementSet( build_dir=build_dir, src_dir=options.src_dir, download_dir=options.download_dir, upgrade=options.upgrade, as_egg=options.as_egg, ignore_installed=options.ignore_installed, ignore_dependencies=options.ignore_dependencies, force_reinstall=options.force_reinstall, use_user_site=options.use_user_site, target_dir=temp_target_dir, session=session, pycompile=options.compile, isolated=options.isolated_mode, wheel_cache=wheel_cache, ) self.populate_requirement_set( requirement_set, args, options, finder, session, self.name, wheel_cache ) if not requirement_set.has_requirements: return try: if (options.download_dir or not wheel or not options.cache_dir): # on -d don't do complex things like building # wheels, and don't try to build wheels when wheel is # not installed. requirement_set.prepare_files(finder) else: # build wheels before install. wb = WheelBuilder( requirement_set, finder, build_options=[], global_options=[], ) # Ignore the result: a failed wheel will be # installed from the sdist/vcs whatever. wb.build(autobuilding=True) if not options.download_dir: requirement_set.install( install_options, global_options, root=options.root_path, ) reqs = sorted( requirement_set.successfully_installed, key=operator.attrgetter('name')) items = [] for req in reqs: item = req.name try: if hasattr(req, 'installed_version'): if req.installed_version: item += '-' + req.installed_version except Exception: pass items.append(item) installed = ' '.join(items) if installed: logger.info('Successfully installed %s', installed) else: downloaded = ' '.join([ req.name for req in requirement_set.successfully_downloaded ]) if downloaded: logger.info( 'Successfully downloaded %s', downloaded ) except PreviousBuildDirError: options.no_clean = True raise finally: # Clean up if not options.no_clean: requirement_set.cleanup_files() if options.target_dir: ensure_dir(options.target_dir) lib_dir = distutils_scheme('', home=temp_target_dir)['purelib'] for item in os.listdir(lib_dir): target_item_dir = os.path.join(options.target_dir, item) if os.path.exists(target_item_dir): if not options.upgrade: logger.warning( 'Target directory %s already exists. Specify ' '--upgrade to force replacement.', target_item_dir ) continue if os.path.islink(target_item_dir): logger.warning( 'Target directory %s already exists and is ' 'a link. Pip will not automatically replace ' 'links, please remove if replacement is ' 'desired.', target_item_dir ) continue if os.path.isdir(target_item_dir): shutil.rmtree(target_item_dir) else: os.remove(target_item_dir) shutil.move( os.path.join(lib_dir, item), target_item_dir ) shutil.rmtree(temp_target_dir) return requirement_set
gpl-3.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 4182, 199, 646, 747, 199, 646, 5549, 199, 646, 5145, 199, 646, 3598, 199, 893, 26, 272, 492, 9989, 199, 2590, 3545, 26, 272, 9989, 275, 488, 199, 199, 504, 7305, 14, 2103, 492, 25013, 1084, 199, 504, 7305, 14, 1095, 1531, 492, 25013, 3110, 199, 504, 7305, 14, 8022, 492, 19128, 63, 889, 63, 2966, 12, 7065, 63, 5512, 199, 504, 7305, 14, 1080, 492, 15665, 11791, 199, 504, 7305, 14, 3924, 492, 334, 272, 26866, 547, 12, 14393, 12, 26902, 3425, 3567, 547, 12, 199, 9, 199, 504, 7305, 492, 2088, 1419, 199, 504, 7305, 14, 1208, 492, 4868, 63, 694, 199, 504, 7305, 14, 1208, 14, 1506, 492, 6516, 6231, 199, 504, 7305, 14, 1208, 14, 15383, 492, 799, 17920, 32457, 24, 3849, 199, 504, 7305, 14, 1208, 14, 11381, 492, 1104, 63, 515, 63, 4597, 199, 504, 7305, 14, 11798, 492, 26161, 4437, 12, 26161, 6437, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 13276, 3110, 8, 17947, 3110, 304, 272, 408, 272, 13276, 6117, 687, 26, 339, 446, 24330, 334, 460, 1163, 10507, 9, 1808, 10685, 29558, 14, 272, 446, 23563, 2199, 8187, 14, 272, 446, 10111, 2199, 6602, 14, 272, 446, 10111, 503, 3982, 1350, 25993, 14, 339, 7305, 2597, 5171, 22200, 687, 298, 7538, 1584, 401, 1314, 5647, 272, 376, 8837, 4340, 370, 4165, 282, 8852, 3734, 370, 506, 4903, 14, 272, 408, 272, 536, 275, 283, 3174, 7, 339, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 12434, 16628, 30, 359, 2491, 13, 1080, 13, 1419, 61, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 359, 2491, 13, 1080, 13, 1419, 61, 2263, 489, 450, 6595, 359, 1419, 61, 5243, 69, 61, 665, 15525, 2199, 1166, 30, 2263, 489, 450, 6595, 359, 1419, 61, 5243, 69, 61, 665, 1832, 2199, 931, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 6404, 1166, 15, 515, 30, 2508, 1041, 339, 6212, 275, 283, 8154, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 8154, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 398, 2088, 63, 3291, 275, 291, 14, 1760, 63, 3291, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 9882, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 10820, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 7538, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1506, 63, 694, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 84, 297, 2850, 1375, 297, 288, 2053, 534, 1375, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 403, 12, 288, 1720, 534, 8154, 6117, 1901, 665, 694, 10827, 283, 326, 283, 2175, 849, 642, 911, 440, 3350, 3411, 1584, 15, 15171, 315, 283, 326, 2650, 694, 10827, 3645, 1553, 9375, 370, 3350, 3411, 6117, 315, 665, 694, 30, 283, 326, 283, 1045, 892, 5459, 3530, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 68, 297, 2850, 4249, 297, 2850, 4249, 13, 694, 297, 2850, 4249, 13, 3619, 297, 288, 2053, 534, 4249, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 403, 12, 288, 1720, 15387, 11950, 6117, 1901, 665, 694, 30, 3140, 402, 22200, 3062, 12, 298, 2116, 298, 1135, 1005, 2003, 402, 4052, 1159, 2575, 4903, 7651, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 4249, 63, 1637, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 2164, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 53, 297, 2850, 9375, 297, 288, 2053, 534, 9375, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 19217, 1006, 2013, 6117, 370, 314, 29608, 2808, 283, 326, 283, 1023, 14, 961, 2112, 365, 9133, 15270, 402, 3775, 283, 326, 283, 65, 5936, 365, 2575, 23233, 3530, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 3990, 13, 264, 3174, 297, 288, 2053, 534, 3990, 63, 264, 3174, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 11423, 1536, 16050, 12, 295, 3174, 1006, 6117, 2755, 340, 2985, 787, 283, 326, 283, 14039, 1536, 13, 475, 13, 602, 2659, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 41, 297, 2850, 4247, 13, 7657, 297, 288, 2053, 534, 4247, 63, 7657, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 9495, 314, 4903, 6117, 334, 264, 3174, 316, 3140, 28583, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 5846, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 3174, 63, 1419, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 2966, 63, 1419, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 751, 297, 288, 2053, 534, 1180, 63, 751, 63, 2124, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 8154, 370, 314, 2018, 922, 3907, 2082, 367, 2195, 298, 326, 298, 3246, 14, 26914, 25975, 1832, 15, 12, 503, 450, 28057, 27744, 4718, 641, 298, 326, 298, 8647, 14, 334, 9295, 314, 2018, 3794, 367, 4770, 14, 3791, 63, 5825, 298, 326, 298, 509, 2615, 2436, 4959, 531, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 5799, 297, 288, 2053, 534, 305, 63, 5799, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 8154, 6117, 465, 22151, 12, 440, 283, 7088, 297, 2839, 7305, 12252, 298, 326, 298, 9105, 14, 961, 945, 365, 440, 3595, 22200, 627, 504, 10, 22151, 14, 298, 326, 7340, 9171, 26, 13821, 642, 945, 10580, 7305, 1159, 3293, 3907, 2, 326, 298, 9661, 12, 9760, 1584, 1443, 440, 24062, 465, 1420, 4959, 531, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 1231, 297, 288, 2053, 534, 1231, 63, 515, 297, 288 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 4182, 199, 646, 747, 199, 646, 5549, 199, 646, 5145, 199, 646, 3598, 199, 893, 26, 272, 492, 9989, 199, 2590, 3545, 26, 272, 9989, 275, 488, 199, 199, 504, 7305, 14, 2103, 492, 25013, 1084, 199, 504, 7305, 14, 1095, 1531, 492, 25013, 3110, 199, 504, 7305, 14, 8022, 492, 19128, 63, 889, 63, 2966, 12, 7065, 63, 5512, 199, 504, 7305, 14, 1080, 492, 15665, 11791, 199, 504, 7305, 14, 3924, 492, 334, 272, 26866, 547, 12, 14393, 12, 26902, 3425, 3567, 547, 12, 199, 9, 199, 504, 7305, 492, 2088, 1419, 199, 504, 7305, 14, 1208, 492, 4868, 63, 694, 199, 504, 7305, 14, 1208, 14, 1506, 492, 6516, 6231, 199, 504, 7305, 14, 1208, 14, 15383, 492, 799, 17920, 32457, 24, 3849, 199, 504, 7305, 14, 1208, 14, 11381, 492, 1104, 63, 515, 63, 4597, 199, 504, 7305, 14, 11798, 492, 26161, 4437, 12, 26161, 6437, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 13276, 3110, 8, 17947, 3110, 304, 272, 408, 272, 13276, 6117, 687, 26, 339, 446, 24330, 334, 460, 1163, 10507, 9, 1808, 10685, 29558, 14, 272, 446, 23563, 2199, 8187, 14, 272, 446, 10111, 2199, 6602, 14, 272, 446, 10111, 503, 3982, 1350, 25993, 14, 339, 7305, 2597, 5171, 22200, 687, 298, 7538, 1584, 401, 1314, 5647, 272, 376, 8837, 4340, 370, 4165, 282, 8852, 3734, 370, 506, 4903, 14, 272, 408, 272, 536, 275, 283, 3174, 7, 339, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 12434, 16628, 30, 359, 2491, 13, 1080, 13, 1419, 61, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 359, 2491, 13, 1080, 13, 1419, 61, 2263, 489, 450, 6595, 359, 1419, 61, 5243, 69, 61, 665, 15525, 2199, 1166, 30, 2263, 489, 450, 6595, 359, 1419, 61, 5243, 69, 61, 665, 1832, 2199, 931, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 6404, 1166, 15, 515, 30, 2508, 1041, 339, 6212, 275, 283, 8154, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 8154, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 398, 2088, 63, 3291, 275, 291, 14, 1760, 63, 3291, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 9882, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 10820, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 7538, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1506, 63, 694, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 84, 297, 2850, 1375, 297, 288, 2053, 534, 1375, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 403, 12, 288, 1720, 534, 8154, 6117, 1901, 665, 694, 10827, 283, 326, 283, 2175, 849, 642, 911, 440, 3350, 3411, 1584, 15, 15171, 315, 283, 326, 2650, 694, 10827, 3645, 1553, 9375, 370, 3350, 3411, 6117, 315, 665, 694, 30, 283, 326, 283, 1045, 892, 5459, 3530, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 68, 297, 2850, 4249, 297, 2850, 4249, 13, 694, 297, 2850, 4249, 13, 3619, 297, 288, 2053, 534, 4249, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 403, 12, 288, 1720, 15387, 11950, 6117, 1901, 665, 694, 30, 3140, 402, 22200, 3062, 12, 298, 2116, 298, 1135, 1005, 2003, 402, 4052, 1159, 2575, 4903, 7651, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 4249, 63, 1637, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 2164, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 53, 297, 2850, 9375, 297, 288, 2053, 534, 9375, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 19217, 1006, 2013, 6117, 370, 314, 29608, 2808, 283, 326, 283, 1023, 14, 961, 2112, 365, 9133, 15270, 402, 3775, 283, 326, 283, 65, 5936, 365, 2575, 23233, 3530, 267, 776, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 3990, 13, 264, 3174, 297, 288, 2053, 534, 3990, 63, 264, 3174, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 11423, 1536, 16050, 12, 295, 3174, 1006, 6117, 2755, 340, 2985, 787, 283, 326, 283, 14039, 1536, 13, 475, 13, 602, 2659, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 41, 297, 2850, 4247, 13, 7657, 297, 288, 2053, 534, 4247, 63, 7657, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 9495, 314, 4903, 6117, 334, 264, 3174, 316, 3140, 28583, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 5846, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 3174, 63, 1419, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 2966, 63, 1419, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 751, 297, 288, 2053, 534, 1180, 63, 751, 63, 2124, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 8154, 370, 314, 2018, 922, 3907, 2082, 367, 2195, 298, 326, 298, 3246, 14, 26914, 25975, 1832, 15, 12, 503, 450, 28057, 27744, 4718, 641, 298, 326, 298, 8647, 14, 334, 9295, 314, 2018, 3794, 367, 4770, 14, 3791, 63, 5825, 298, 326, 298, 509, 2615, 2436, 4959, 531, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 5799, 297, 288, 2053, 534, 305, 63, 5799, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 8154, 6117, 465, 22151, 12, 440, 283, 7088, 297, 2839, 7305, 12252, 298, 326, 298, 9105, 14, 961, 945, 365, 440, 3595, 22200, 627, 504, 10, 22151, 14, 298, 326, 7340, 9171, 26, 13821, 642, 945, 10580, 7305, 1159, 3293, 3907, 2, 326, 298, 9661, 12, 9760, 1584, 1443, 440, 24062, 465, 1420, 4959, 531, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 1231, 297, 288, 2053, 534, 1231, 63, 515, 297, 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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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 ]
DTOcean/dtocean-core
tests/test_data_definitions_xgrid2d.py
1
4013
import pytest import numpy as np import matplotlib.pyplot as plt from aneris.control.factory import InterfaceFactory from dtocean_core.core import (AutoFileInput, AutoFileOutput, AutoPlot, Core) from dtocean_core.data import CoreMetaData from dtocean_core.data.definitions import XGrid2D def test_XGrid2D_available(): new_core = Core() all_objs = new_core.control._store._structures assert "XGrid2D" in all_objs.keys() def test_XGrid2D(): raw = {"values": np.random.randn(2, 3), "coords": [['a', 'b'], [-2, 0, 2]]} meta = CoreMetaData({"identifier": "test", "structure": "test", "title": "test", "labels": ['x', 'y'], "units": [None, 'm', 'POWER!']}) test = XGrid2D() a = test.get_data(raw, meta) b = test.get_value(a) assert b.values.shape == (2,3) assert b.units == 'POWER!' assert b.y.units == 'm' def test_get_None(): test = XGrid2D() result = test.get_value(None) assert result is None @pytest.mark.parametrize("fext", [".nc"]) def test_XGrid2D_auto_file(tmpdir, fext): test_path = tmpdir.mkdir("sub").join("test{}".format(fext)) test_path_str = str(test_path) raw = {"values": np.random.randn(2, 3), "coords": [['a', 'b'], [-2, 0, 2]]} meta = CoreMetaData({"identifier": "test", "structure": "test", "title": "test", "labels": ['x', 'y'], "units": [None, 'm', 'POWER!']}) test = XGrid2D() fout_factory = InterfaceFactory(AutoFileOutput) FOutCls = fout_factory(meta, test) fout = FOutCls() fout._path = test_path_str fout.data.result = test.get_data(raw, meta) fout.connect() assert len(tmpdir.listdir()) == 1 fin_factory = InterfaceFactory(AutoFileInput) FInCls = fin_factory(meta, test) fin = FInCls() fin.meta.result = meta fin._path = test_path_str fin.connect() result = test.get_data(fin.data.result, meta) assert result.values.shape == (2,3) assert result.units == 'POWER!' assert result.y.units == 'm' def test_XGrid2D_auto_plot(tmpdir): raw = {"values": np.random.randn(2, 3), "coords": [['a', 'b'], [-2, 0, 2]]} meta = CoreMetaData({"identifier": "test", "structure": "test", "title": "test", "labels": ['x', 'y'], "units": ['\sum_{n=1}^{\infty} 2^{-n} = 1', 'm', 'POWER!']}) test = XGrid2D() fout_factory = InterfaceFactory(AutoPlot) PlotCls = fout_factory(meta, test) plot = PlotCls() plot.data.result = test.get_data(raw, meta) plot.meta.result = meta plot.connect() assert len(plt.get_fignums()) == 1 plt.close("all") def test_XGrid2D_auto_plot_reverse(tmpdir): raw = {"values": np.random.randn(3, 2), "coords": [[-2, 0, 2], ['a', 'b']]} meta = CoreMetaData({"identifier": "test", "structure": "test", "title": "test", "labels": ['x', 'y'], "units": ['\sum_{n=1}^{\infty} 2^{-n} = 1', 'm', 'POWER!']}) test = XGrid2D() fout_factory = InterfaceFactory(AutoPlot) PlotCls = fout_factory(meta, test) plot = PlotCls() plot.data.result = test.get_data(raw, meta) plot.meta.result = meta plot.connect() assert len(plt.get_fignums()) == 1 plt.close("all")
gpl-3.0
[ 646, 4613, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 504, 376, 281, 374, 14, 2785, 14, 3702, 492, 14816, 2927, 199, 504, 366, 475, 20867, 63, 1018, 14, 1018, 492, 334, 3358, 1173, 3205, 12, 3044, 9195, 1173, 2959, 12, 3044, 9195, 10711, 12, 3044, 11672, 9, 199, 504, 366, 475, 20867, 63, 1018, 14, 576, 492, 11672, 25285, 199, 504, 366, 475, 20867, 63, 1018, 14, 576, 14, 15388, 492, 1323, 7900, 18, 36, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 4561, 837, 2286, 892, 63, 1018, 275, 11672, 342, 272, 1006, 63, 8718, 275, 892, 63, 1018, 14, 2785, 423, 1617, 423, 13547, 339, 702, 298, 56, 7900, 18, 36, 2, 315, 1006, 63, 8718, 14, 1612, 342, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 837, 339, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 359, 403, 12, 283, 77, 297, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 272, 282, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 272, 330, 275, 511, 14, 362, 63, 585, 8, 65, 9, 2286, 702, 330, 14, 1459, 14, 1392, 508, 334, 18, 12, 19, 9, 272, 702, 330, 14, 5260, 508, 283, 16064, 11213, 272, 702, 330, 14, 89, 14, 5260, 508, 283, 77, 7, 16872, 199, 318, 511, 63, 362, 63, 403, 837, 2286, 511, 275, 1323, 7900, 18, 36, 342, 272, 754, 275, 511, 14, 362, 63, 585, 8, 403, 9, 2286, 702, 754, 365, 488, 421, 199, 32, 4462, 14, 1657, 14, 10396, 480, 771, 400, 401, 359, 1674, 7966, 3135, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 493, 8, 8616, 12, 289, 832, 304, 339, 511, 63, 515, 275, 12885, 14, 8215, 480, 954, 3471, 904, 480, 396, 13536, 908, 8, 771, 400, 430, 272, 511, 63, 515, 63, 495, 275, 620, 8, 396, 63, 515, 9, 288, 272, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 359, 403, 12, 283, 77, 297, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 1173, 2959, 9, 272, 481, 2204, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 9, 2286, 17863, 275, 481, 2204, 24342, 342, 272, 17863, 423, 515, 275, 511, 63, 515, 63, 495, 272, 17863, 14, 576, 14, 1099, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 339, 17863, 14, 2242, 342, 2286, 702, 822, 8, 8616, 14, 7374, 1012, 508, 413, 2049, 272, 2583, 63, 3702, 275, 14816, 2927, 8, 3358, 1173, 3205, 9, 272, 481, 607, 24342, 275, 2583, 63, 3702, 8, 2024, 12, 511, 9, 2049, 272, 2583, 275, 481, 607, 24342, 342, 272, 2583, 14, 2024, 14, 1099, 275, 3404, 272, 2583, 423, 515, 275, 511, 63, 515, 63, 495, 2286, 2583, 14, 2242, 342, 272, 754, 275, 511, 14, 362, 63, 576, 8, 2408, 14, 576, 14, 1099, 12, 3404, 9, 2286, 702, 754, 14, 1459, 14, 1392, 508, 334, 18, 12, 19, 9, 272, 702, 754, 14, 5260, 508, 283, 16064, 11213, 272, 702, 754, 14, 89, 14, 5260, 508, 283, 77, 7, 27844, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 2798, 8, 8616, 304, 5493, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 788, 60, 1838, 7348, 78, 29, 17, 93, 11683, 60, 4904, 369, 93, 499, 25997, 78, 93, 275, 413, 297, 3521, 283, 77, 297, 221, 3521, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 10711, 9, 272, 14794, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 9, 2286, 5137, 275, 14794, 24342, 342, 272, 5137, 14, 576, 14, 1099, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 272, 5137, 14, 2024, 14, 1099, 275, 3404, 339, 5137, 14, 2242, 342, 2286, 702, 822, 8, 6003, 14, 362, 63, 592, 16084, 1012, 508, 413, 272, 4488, 14, 1600, 480, 452, 531, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 2798, 63, 4471, 8, 8616, 304, 5493, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 19, 12, 499, 395, 1779, 298, 8032, 582, 27291, 18, 12, 378, 12, 499, 467, 788, 65, 297, 283, 66, 6538, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 788, 60, 1838, 7348, 78, 29, 17, 93, 11683, 60, 4904, 369, 93, 499, 25997, 78, 93, 275, 413, 297, 3521, 283, 77, 297, 221, 3521, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 10711, 9, 272, 14794, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 9 ]
[ 4613, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 504, 376, 281, 374, 14, 2785, 14, 3702, 492, 14816, 2927, 199, 504, 366, 475, 20867, 63, 1018, 14, 1018, 492, 334, 3358, 1173, 3205, 12, 3044, 9195, 1173, 2959, 12, 3044, 9195, 10711, 12, 3044, 11672, 9, 199, 504, 366, 475, 20867, 63, 1018, 14, 576, 492, 11672, 25285, 199, 504, 366, 475, 20867, 63, 1018, 14, 576, 14, 15388, 492, 1323, 7900, 18, 36, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 4561, 837, 2286, 892, 63, 1018, 275, 11672, 342, 272, 1006, 63, 8718, 275, 892, 63, 1018, 14, 2785, 423, 1617, 423, 13547, 339, 702, 298, 56, 7900, 18, 36, 2, 315, 1006, 63, 8718, 14, 1612, 342, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 837, 339, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 359, 403, 12, 283, 77, 297, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 272, 282, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 272, 330, 275, 511, 14, 362, 63, 585, 8, 65, 9, 2286, 702, 330, 14, 1459, 14, 1392, 508, 334, 18, 12, 19, 9, 272, 702, 330, 14, 5260, 508, 283, 16064, 11213, 272, 702, 330, 14, 89, 14, 5260, 508, 283, 77, 7, 16872, 199, 318, 511, 63, 362, 63, 403, 837, 2286, 511, 275, 1323, 7900, 18, 36, 342, 272, 754, 275, 511, 14, 362, 63, 585, 8, 403, 9, 2286, 702, 754, 365, 488, 421, 199, 32, 4462, 14, 1657, 14, 10396, 480, 771, 400, 401, 359, 1674, 7966, 3135, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 493, 8, 8616, 12, 289, 832, 304, 339, 511, 63, 515, 275, 12885, 14, 8215, 480, 954, 3471, 904, 480, 396, 13536, 908, 8, 771, 400, 430, 272, 511, 63, 515, 63, 495, 275, 620, 8, 396, 63, 515, 9, 288, 272, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 359, 403, 12, 283, 77, 297, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 1173, 2959, 9, 272, 481, 2204, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 9, 2286, 17863, 275, 481, 2204, 24342, 342, 272, 17863, 423, 515, 275, 511, 63, 515, 63, 495, 272, 17863, 14, 576, 14, 1099, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 339, 17863, 14, 2242, 342, 2286, 702, 822, 8, 8616, 14, 7374, 1012, 508, 413, 2049, 272, 2583, 63, 3702, 275, 14816, 2927, 8, 3358, 1173, 3205, 9, 272, 481, 607, 24342, 275, 2583, 63, 3702, 8, 2024, 12, 511, 9, 2049, 272, 2583, 275, 481, 607, 24342, 342, 272, 2583, 14, 2024, 14, 1099, 275, 3404, 272, 2583, 423, 515, 275, 511, 63, 515, 63, 495, 2286, 2583, 14, 2242, 342, 272, 754, 275, 511, 14, 362, 63, 576, 8, 2408, 14, 576, 14, 1099, 12, 3404, 9, 2286, 702, 754, 14, 1459, 14, 1392, 508, 334, 18, 12, 19, 9, 272, 702, 754, 14, 5260, 508, 283, 16064, 11213, 272, 702, 754, 14, 89, 14, 5260, 508, 283, 77, 7, 27844, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 2798, 8, 8616, 304, 5493, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 18, 12, 650, 395, 1779, 298, 8032, 582, 11194, 65, 297, 283, 66, 995, 5243, 18, 12, 378, 12, 499, 2677, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 788, 60, 1838, 7348, 78, 29, 17, 93, 11683, 60, 4904, 369, 93, 499, 25997, 78, 93, 275, 413, 297, 3521, 283, 77, 297, 221, 3521, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 10711, 9, 272, 14794, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 9, 2286, 5137, 275, 14794, 24342, 342, 272, 5137, 14, 576, 14, 1099, 275, 511, 14, 362, 63, 576, 8, 1773, 12, 3404, 9, 272, 5137, 14, 2024, 14, 1099, 275, 3404, 339, 5137, 14, 2242, 342, 2286, 702, 822, 8, 6003, 14, 362, 63, 592, 16084, 1012, 508, 413, 272, 4488, 14, 1600, 480, 452, 531, 421, 199, 318, 511, 63, 56, 7900, 18, 36, 63, 2495, 63, 2798, 63, 4471, 8, 8616, 304, 5493, 3066, 275, 2420, 1459, 582, 980, 14, 2355, 14, 10843, 8, 19, 12, 499, 395, 1779, 298, 8032, 582, 27291, 18, 12, 378, 12, 499, 467, 788, 65, 297, 283, 66, 6538, 93, 288, 272, 3404, 275, 11672, 25285, 6333, 5364, 582, 298, 396, 401, 586, 298, 6976, 582, 298, 396, 401, 586, 298, 1213, 582, 298, 396, 401, 586, 298, 3512, 582, 788, 88, 297, 283, 89, 995, 586, 298, 5260, 582, 788, 60, 1838, 7348, 78, 29, 17, 93, 11683, 60, 4904, 369, 93, 499, 25997, 78, 93, 275, 413, 297, 3521, 283, 77, 297, 221, 3521, 283, 16064, 1, 13678, 2286, 511, 275, 1323, 7900, 18, 36, 342, 2286, 17863, 63, 3702, 275, 14816, 2927, 8, 3358, 10711, 9, 272, 14794, 24342, 275, 17863, 63, 3702, 8, 2024, 12, 511, 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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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 ]
saurabh6790/medsynaptic-app
patches/june_2013/p05_remove_unused_doctypes.py
30
1916
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt import webnotes def execute(): doctypes = [ "Announcement", "Authorization Rules", "Blog Subscriber", "Books", "Call Log", "Call Log Details", "Campaign Expense", "Communication Log", "Compaint Note", "Company Control", "Competitor", "Complaint Detail", "Desktop Item", "DocType Label", "Employee Training", "Featured Item", "GL Control", "GL Mapper", "GL Mapper Detail", "Holiday Block List", "Holiday Block List Allow", "Holiday Block List Date", "Home Control", "Home Settings", "Item Parameter", "Item Parameter Value", "Lead Email CC Detail", "Manage Account", "Market Segment", "Multi Ledger Report Detail", "Naming Series Options", "Navigation Control", "Online Contact", "Order Reconciliation", "Order Reconciliation Detail", "Other Income Detail", "Partner Target Detail", "Permission Control", "Permission Rules", "Print Style", "Product Catalogue Control", "Product Group", "Product Settings", "Products Settings", "Profile Control", "Project Activity", "Project Activity Update", "Project Control", "Project Cost Breakup", "Related Page", "RV Detail", "Sales Browser Control", "Sandbox", "Search Criteria", "Series Detail", "Shipping Address", "SMS Receiver", "State", "TC Detail", "Territory Target Detail", "Timesheet", "Timesheet Detail", "Top Bar Settings", "Training Session", "Training Session Details", "Transfer Ownership", "Trash Control", "Trend Analyzer Control", "Update Delivery Date", "User Setting-Profile", "User Setting-Role Permission", "User Setting-Role User", "User Settings", "Valuation Control", "Website Product Category", "Workflow Action Detail", "Workflow Engine", "Workflow Rule", "Workflow Rule Detail" ] for d in doctypes: webnotes.delete_doc("DocType", d)
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 646, 23154, 199, 199, 318, 5341, 837, 199, 198, 6356, 83, 275, 359, 199, 198, 2, 2493, 13348, 434, 401, 199, 198, 2, 11626, 24259, 401, 199, 198, 2, 26081, 4804, 10979, 401, 199, 198, 2, 8696, 83, 401, 199, 198, 2, 2176, 5297, 401, 199, 198, 2, 2176, 5297, 15621, 401, 199, 198, 2, 3630, 11721, 7910, 677, 401, 199, 198, 2, 27258, 425, 5297, 401, 199, 198, 2, 2404, 65, 442, 3390, 401, 199, 198, 2, 16063, 8612, 401, 199, 198, 2, 2404, 69, 6403, 269, 401, 199, 198, 2, 2404, 416, 442, 13302, 401, 199, 198, 2, 20436, 7020, 401, 199, 198, 2, 3768, 804, 10354, 401, 199, 198, 2, 22635, 22859, 401, 199, 198, 2, 24927, 3297, 7020, 401, 199, 198, 2, 2226, 8612, 401, 199, 198, 2, 2226, 9672, 529, 401, 199, 198, 2, 2226, 9672, 529, 13302, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 9812, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 6148, 401, 199, 198, 2, 12054, 8612, 401, 199, 198, 2, 12054, 13303, 401, 199, 198, 2, 2081, 12009, 401, 199, 198, 2, 2081, 12009, 1594, 401, 199, 198, 2, 29006, 11426, 17586, 13302, 401, 199, 198, 2, 20588, 9973, 401, 199, 198, 2, 21667, 29858, 401, 199, 198, 2, 3947, 491, 379, 836, 11774, 13302, 401, 199, 198, 2, 46, 9568, 12403, 8394, 401, 199, 198, 2, 19617, 5360, 8612, 401, 199, 198, 2, 28587, 18684, 401, 199, 198, 2, 4738, 799, 388, 29685, 401, 199, 198, 2, 4738, 799, 388, 29685, 13302, 401, 199, 198, 2, 8632, 1010, 4352, 13302, 401, 199, 198, 2, 24120, 10256, 13302, 401, 199, 198, 2, 7980, 8612, 401, 199, 198, 2, 7980, 24259, 401, 199, 198, 2, 5375, 19442, 401, 199, 198, 2, 5884, 22881, 310, 8612, 401, 199, 198, 2, 5884, 5611, 401, 199, 198, 2, 5884, 13303, 401, 199, 198, 2, 29631, 13303, 401, 199, 198, 2, 5736, 8612, 401, 199, 198, 2, 4761, 21885, 401, 199, 198, 2, 4761, 21885, 6162, 401, 199, 198, 2, 4761, 8612, 401, 199, 198, 2, 4761, 24681, 22535, 384, 401, 199, 198, 2, 13885, 10331, 401, 199, 198, 2, 28841, 13302, 401, 199, 198, 2, 18220, 27620, 8612, 401, 199, 198, 2, 29155, 401, 199, 198, 2, 5278, 445, 7527, 65, 401, 199, 198, 2, 9641, 13302, 401, 199, 198, 2, 30707, 4073, 9906, 401, 199, 198, 2, 51, 3053, 799, 6594, 401, 199, 198, 2, 2223, 401, 199, 198, 2, 5708, 13302, 401, 199, 198, 2, 8600, 26425, 10256, 13302, 401, 199, 198, 2, 1366, 5069, 401, 199, 198, 2, 1366, 5069, 13302, 401, 199, 198, 2, 6105, 12377, 13303, 401, 199, 198, 2, 20463, 8596, 401, 199, 198, 2, 20463, 8596, 15621, 401, 199, 198, 2, 11761, 593, 4977, 3319, 401, 199, 198, 2, 14064, 1119, 8612, 401, 199, 198, 2, 52, 16479, 14279, 2282, 8612, 401, 199, 198, 2, 4152, 1487, 317, 2588, 6148, 401, 199, 198, 2, 1899, 13510, 13, 5736, 401, 199, 198, 2, 1899, 13510, 13, 7422, 8779, 401, 199, 198, 2, 1899, 13510, 13, 7422, 2876, 401, 199, 198, 2, 1899, 13303, 401, 199, 198, 2, 7562, 4086, 8612, 401, 199, 198, 2, 26354, 12705, 13573, 401, 199, 198, 2, 17527, 10033, 13302, 401, 199, 198, 2, 17527, 12580, 401, 199, 198, 2, 17527, 11949, 401, 199, 198, 2, 17527, 11949, 13302, 2, 199, 198, 61, 8299, 198, 509, 366, 315, 886, 9798, 26, 507, 198, 30307, 14, 1807, 63, 1301, 480, 3768, 804, 401, 366, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 646, 23154, 199, 199, 318, 5341, 837, 199, 198, 6356, 83, 275, 359, 199, 198, 2, 2493, 13348, 434, 401, 199, 198, 2, 11626, 24259, 401, 199, 198, 2, 26081, 4804, 10979, 401, 199, 198, 2, 8696, 83, 401, 199, 198, 2, 2176, 5297, 401, 199, 198, 2, 2176, 5297, 15621, 401, 199, 198, 2, 3630, 11721, 7910, 677, 401, 199, 198, 2, 27258, 425, 5297, 401, 199, 198, 2, 2404, 65, 442, 3390, 401, 199, 198, 2, 16063, 8612, 401, 199, 198, 2, 2404, 69, 6403, 269, 401, 199, 198, 2, 2404, 416, 442, 13302, 401, 199, 198, 2, 20436, 7020, 401, 199, 198, 2, 3768, 804, 10354, 401, 199, 198, 2, 22635, 22859, 401, 199, 198, 2, 24927, 3297, 7020, 401, 199, 198, 2, 2226, 8612, 401, 199, 198, 2, 2226, 9672, 529, 401, 199, 198, 2, 2226, 9672, 529, 13302, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 9812, 401, 199, 198, 2, 17810, 317, 2977, 8651, 3820, 6148, 401, 199, 198, 2, 12054, 8612, 401, 199, 198, 2, 12054, 13303, 401, 199, 198, 2, 2081, 12009, 401, 199, 198, 2, 2081, 12009, 1594, 401, 199, 198, 2, 29006, 11426, 17586, 13302, 401, 199, 198, 2, 20588, 9973, 401, 199, 198, 2, 21667, 29858, 401, 199, 198, 2, 3947, 491, 379, 836, 11774, 13302, 401, 199, 198, 2, 46, 9568, 12403, 8394, 401, 199, 198, 2, 19617, 5360, 8612, 401, 199, 198, 2, 28587, 18684, 401, 199, 198, 2, 4738, 799, 388, 29685, 401, 199, 198, 2, 4738, 799, 388, 29685, 13302, 401, 199, 198, 2, 8632, 1010, 4352, 13302, 401, 199, 198, 2, 24120, 10256, 13302, 401, 199, 198, 2, 7980, 8612, 401, 199, 198, 2, 7980, 24259, 401, 199, 198, 2, 5375, 19442, 401, 199, 198, 2, 5884, 22881, 310, 8612, 401, 199, 198, 2, 5884, 5611, 401, 199, 198, 2, 5884, 13303, 401, 199, 198, 2, 29631, 13303, 401, 199, 198, 2, 5736, 8612, 401, 199, 198, 2, 4761, 21885, 401, 199, 198, 2, 4761, 21885, 6162, 401, 199, 198, 2, 4761, 8612, 401, 199, 198, 2, 4761, 24681, 22535, 384, 401, 199, 198, 2, 13885, 10331, 401, 199, 198, 2, 28841, 13302, 401, 199, 198, 2, 18220, 27620, 8612, 401, 199, 198, 2, 29155, 401, 199, 198, 2, 5278, 445, 7527, 65, 401, 199, 198, 2, 9641, 13302, 401, 199, 198, 2, 30707, 4073, 9906, 401, 199, 198, 2, 51, 3053, 799, 6594, 401, 199, 198, 2, 2223, 401, 199, 198, 2, 5708, 13302, 401, 199, 198, 2, 8600, 26425, 10256, 13302, 401, 199, 198, 2, 1366, 5069, 401, 199, 198, 2, 1366, 5069, 13302, 401, 199, 198, 2, 6105, 12377, 13303, 401, 199, 198, 2, 20463, 8596, 401, 199, 198, 2, 20463, 8596, 15621, 401, 199, 198, 2, 11761, 593, 4977, 3319, 401, 199, 198, 2, 14064, 1119, 8612, 401, 199, 198, 2, 52, 16479, 14279, 2282, 8612, 401, 199, 198, 2, 4152, 1487, 317, 2588, 6148, 401, 199, 198, 2, 1899, 13510, 13, 5736, 401, 199, 198, 2, 1899, 13510, 13, 7422, 8779, 401, 199, 198, 2, 1899, 13510, 13, 7422, 2876, 401, 199, 198, 2, 1899, 13303, 401, 199, 198, 2, 7562, 4086, 8612, 401, 199, 198, 2, 26354, 12705, 13573, 401, 199, 198, 2, 17527, 10033, 13302, 401, 199, 198, 2, 17527, 12580, 401, 199, 198, 2, 17527, 11949, 401, 199, 198, 2, 17527, 11949, 13302, 2, 199, 198, 61, 8299, 198, 509, 366, 315, 886, 9798, 26, 507, 198, 30307, 14, 1807, 63, 1301, 480, 3768, 804, 401, 366, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
nicocardiel/pyemir
emirdrp/processing/wavecal/get_islitlet.py
3
1590
# # Copyright 2019 Universidad Complutense de Madrid # # This file is part of PyEmir # # PyEmir 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. # # PyEmir 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 PyEmir. If not, see <http://www.gnu.org/licenses/>. # """Return islitlet from Y-pixel coordinate in the rectified image""" from emirdrp.core import EMIR_NBARS from emirdrp.core import EMIR_NPIXPERSLIT_RECTIFIED def get_islitlet(ipixel): """Return islilet (from 1 to EMIR_NBARS) from Y-pixel coordinate Parameters ---------- ipixel : int Y-pixel coordinate in the rectified image. Returns ------- islitlet : int Slitlet number (from 1 to EMIR_NBARS). """ if ipixel < 1: raise ValueError('ipixel={} cannot be < 1'.format(ipixel)) if ipixel > EMIR_NPIXPERSLIT_RECTIFIED * EMIR_NBARS: raise ValueError('ipixel={} cannot be > {}'.format( ipixel, EMIR_NPIXPERSLIT_RECTIFIED * EMIR_NBARS )) islitlet = int(ipixel / EMIR_NPIXPERSLIT_RECTIFIED) + 1 if ipixel % EMIR_NPIXPERSLIT_RECTIFIED == 0: islitlet -= 1 return islitlet
gpl-3.0
[ 3, 199, 3, 1898, 20312, 1910, 4380, 4148, 350, 1849, 2421, 85, 724, 261, 477, 603, 350, 1677, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1611, 37, 77, 723, 199, 3, 199, 3, 1611, 37, 77, 723, 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, 1611, 37, 77, 723, 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, 1611, 37, 77, 723, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 1767, 365, 1051, 2723, 687, 1488, 13, 8435, 10021, 315, 314, 6488, 8981, 1834, 624, 199, 199, 504, 18564, 5428, 4599, 14, 1018, 492, 26512, 3927, 63, 46, 13895, 51, 199, 504, 18564, 5428, 4599, 14, 1018, 492, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 421, 199, 318, 664, 63, 374, 1051, 2723, 8, 711, 5887, 304, 272, 408, 1767, 365, 317, 2723, 334, 504, 413, 370, 26512, 3927, 63, 46, 13895, 51, 9, 687, 1488, 13, 8435, 10021, 339, 3897, 272, 4143, 272, 284, 8435, 520, 1109, 267, 1488, 13, 8435, 10021, 315, 314, 6488, 8981, 1834, 14, 339, 1803, 272, 5514, 272, 365, 1051, 2723, 520, 1109, 267, 428, 1051, 2723, 1329, 334, 504, 413, 370, 26512, 3927, 63, 46, 13895, 51, 680, 339, 408, 339, 340, 284, 8435, 665, 413, 26, 267, 746, 1722, 360, 711, 5887, 7622, 3913, 506, 665, 413, 1370, 908, 8, 711, 5887, 430, 339, 340, 284, 8435, 690, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 627, 26512, 3927, 63, 46, 13895, 51, 26, 267, 746, 1722, 360, 711, 5887, 7622, 3913, 506, 690, 9499, 908, 8, 288, 284, 8435, 12, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 627, 26512, 3927, 63, 46, 13895, 51, 267, 5082, 339, 365, 1051, 2723, 275, 1109, 8, 711, 5887, 1182, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 9, 435, 413, 339, 340, 284, 8435, 450, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 508, 378, 26, 267, 365, 1051, 2723, 4862, 413, 339, 372, 365, 1051, 2723, 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 ]
[ 199, 3, 1898, 20312, 1910, 4380, 4148, 350, 1849, 2421, 85, 724, 261, 477, 603, 350, 1677, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1611, 37, 77, 723, 199, 3, 199, 3, 1611, 37, 77, 723, 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, 1611, 37, 77, 723, 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, 1611, 37, 77, 723, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 1767, 365, 1051, 2723, 687, 1488, 13, 8435, 10021, 315, 314, 6488, 8981, 1834, 624, 199, 199, 504, 18564, 5428, 4599, 14, 1018, 492, 26512, 3927, 63, 46, 13895, 51, 199, 504, 18564, 5428, 4599, 14, 1018, 492, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 421, 199, 318, 664, 63, 374, 1051, 2723, 8, 711, 5887, 304, 272, 408, 1767, 365, 317, 2723, 334, 504, 413, 370, 26512, 3927, 63, 46, 13895, 51, 9, 687, 1488, 13, 8435, 10021, 339, 3897, 272, 4143, 272, 284, 8435, 520, 1109, 267, 1488, 13, 8435, 10021, 315, 314, 6488, 8981, 1834, 14, 339, 1803, 272, 5514, 272, 365, 1051, 2723, 520, 1109, 267, 428, 1051, 2723, 1329, 334, 504, 413, 370, 26512, 3927, 63, 46, 13895, 51, 680, 339, 408, 339, 340, 284, 8435, 665, 413, 26, 267, 746, 1722, 360, 711, 5887, 7622, 3913, 506, 665, 413, 1370, 908, 8, 711, 5887, 430, 339, 340, 284, 8435, 690, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 627, 26512, 3927, 63, 46, 13895, 51, 26, 267, 746, 1722, 360, 711, 5887, 7622, 3913, 506, 690, 9499, 908, 8, 288, 284, 8435, 12, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 627, 26512, 3927, 63, 46, 13895, 51, 267, 5082, 339, 365, 1051, 2723, 275, 1109, 8, 711, 5887, 1182, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 9, 435, 413, 339, 340, 284, 8435, 450, 26512, 3927, 63, 46, 18545, 48, 3960, 44, 649, 63, 4168, 31223, 508, 378, 26, 267, 365, 1051, 2723, 4862, 413, 339, 372, 365, 1051, 2723, 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, 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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utf-8 -*- # # Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz> # Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html """ This module contains basic interfaces used throughout the whole gensim package. The interfaces are realized as abstract base classes (ie., some optional functionality is provided in the interface itself, so that the interfaces can be subclassed). """ from __future__ import with_statement import logging import itertools from gensim import utils, matutils from six.moves import xrange logger = logging.getLogger('gensim.interfaces') class CorpusABC(utils.SaveLoad): """ Interface (abstract base class) for corpora. A *corpus* is simply an iterable, where each iteration step yields one document: >>> for doc in corpus: >>> # do something with the doc... A document is a sequence of `(fieldId, fieldValue)` 2-tuples: >>> for attr_id, attr_value in doc: >>> # do something with the attribute Note that although a default :func:`len` method is provided, it is very inefficient (performs a linear scan through the corpus to determine its length). Wherever the corpus size is needed and known in advance (or at least doesn't change so that it can be cached), the :func:`len` method should be overridden. See the :mod:`gensim.corpora.svmlightcorpus` module for an example of a corpus. Saving the corpus with the `save` method (inherited from `utils.SaveLoad`) will only store the *in-memory* (binary, pickled) object representation=the stream state, and **not** the documents themselves. See the `save_corpus` static method for serializing the actual stream content. """ def __iter__(self): """ Iterate over the corpus, yielding one document at a time. """ raise NotImplementedError('cannot instantiate abstract base class') def save(self, *args, **kwargs): import warnings warnings.warn("corpus.save() stores only the (tiny) iteration object; " "to serialize the actual corpus content, use e.g. MmCorpus.serialize(corpus)") super(CorpusABC, self).save(*args, **kwargs) def __len__(self): """ Return the number of documents in the corpus. This method is just the least common denominator and should really be overridden when possible. """ raise NotImplementedError("must override __len__() before calling len(corpus)") # logger.warning("performing full corpus scan to determine its length; was this intended?") # return sum(1 for doc in self) # sum(empty generator) == 0, so this works even for an empty corpus @staticmethod def save_corpus(fname, corpus, id2word=None, metadata=False): """ Save an existing `corpus` to disk. Some formats also support saving the dictionary (`feature_id->word` mapping), which can in this case be provided by the optional `id2word` parameter. >>> MmCorpus.save_corpus('file.mm', corpus) Some corpora also support an index of where each document begins, so that the documents on disk can be accessed in O(1) time (see the `corpora.IndexedCorpus` base class). In this case, `save_corpus` is automatically called internally by `serialize`, which does `save_corpus` plus saves the index at the same time, so you want to store the corpus with:: >>> MmCorpus.serialize('file.mm', corpus) # stores index as well, allowing random access to individual documents Calling `serialize()` is preferred to calling `save_corpus()`. """ raise NotImplementedError('cannot instantiate abstract base class') # example code: logger.info("converting corpus to ??? format: %s" % fname) with utils.smart_open(fname, 'wb') as fout: for doc in corpus: # iterate over the document stream fmt = str(doc) # format the document appropriately... fout.write(utils.to_utf8("%s\n" % fmt)) # serialize the formatted document to disk #endclass CorpusABC class TransformedCorpus(CorpusABC): def __init__(self, obj, corpus, chunksize=None): self.obj, self.corpus, self.chunksize = obj, corpus, chunksize self.metadata = False def __len__(self): return len(self.corpus) def __iter__(self): if self.chunksize: for chunk in utils.grouper(self.corpus, self.chunksize): for transformed in self.obj.__getitem__(chunk, chunksize=None): yield transformed else: for doc in self.corpus: yield self.obj[doc] #endclass TransformedCorpus class TransformationABC(utils.SaveLoad): """ Interface for transformations. A 'transformation' is any object which accepts a sparse document via the dictionary notation `[]` and returns another sparse document in its stead:: >>> transformed_doc = transformation[doc] or also:: >>> transformed_corpus = transformation[corpus] See the :mod:`gensim.models.tfidfmodel` module for an example of a transformation. """ def __getitem__(self, vec): """ Transform vector from one vector space into another **or** Transform a whole corpus into another. """ raise NotImplementedError('cannot instantiate abstract base class') def _apply(self, corpus, chunksize=None): """ Apply the transformation to a whole corpus (as opposed to a single document) and return the result as another corpus. """ return TransformedCorpus(self, corpus, chunksize) #endclass TransformationABC class SimilarityABC(utils.SaveLoad): """ Abstract interface for similarity searches over a corpus. In all instances, there is a corpus against which we want to perform the similarity search. For each similarity search, the input is a document and the output are its similarities to individual corpus documents. Similarity queries are realized by calling ``self[query_document]``. There is also a convenience wrapper, where iterating over `self` yields similarities of each document in the corpus against the whole corpus (ie., the query is each corpus document in turn). """ def __init__(self, corpus): raise NotImplementedError("cannot instantiate Abstract Base Class") def get_similarities(self, doc): # (Sparse)MatrixSimilarity override this method so that they both use the # same __getitem__ method, defined below raise NotImplementedError("cannot instantiate Abstract Base Class") def __getitem__(self, query): """Get similarities of document `query` to all documents in the corpus. **or** If `query` is a corpus (iterable of documents), return a matrix of similarities of all query documents vs. all corpus document. Using this type of batch query is more efficient than computing the similarities one document after another. """ is_corpus, query = utils.is_corpus(query) if self.normalize: # self.normalize only works if the input is a plain gensim vector/corpus (as # advertised in the doc). in fact, input can be a numpy or scipy.sparse matrix # as well, but in that case assume tricks are happening and don't normalize # anything (self.normalize has no effect). if matutils.ismatrix(query): import warnings # warnings.warn("non-gensim input must already come normalized") else: if is_corpus: query = [matutils.unitvec(v) for v in query] else: query = matutils.unitvec(query) result = self.get_similarities(query) if self.num_best is None: return result # if the input query was a corpus (=more documents), compute the top-n # most similar for each document in turn if matutils.ismatrix(result): return [matutils.full2sparse_clipped(v, self.num_best) for v in result] else: # otherwise, return top-n of the single input document return matutils.full2sparse_clipped(result, self.num_best) def __iter__(self): """ For each index document, compute cosine similarity against all other documents in the index and yield the result. """ # turn off query normalization (vectors in the index are assumed to be already normalized) norm = self.normalize self.normalize = False # Try to compute similarities in bigger chunks of documents (not # one query = a single document after another). The point is, a # bigger query of N documents is faster than N small queries of one # document. # # After computing similarities of the bigger query in `self[chunk]`, # yield the resulting similarities one after another, so that it looks # exactly the same as if they had been computed with many small queries. try: chunking = self.chunksize > 1 except AttributeError: # chunking not supported; fall back to the (slower) mode of 1 query=1 document chunking = False if chunking: # assumes `self.corpus` holds the index as a 2-d numpy array. # this is true for MatrixSimilarity and SparseMatrixSimilarity, but # may not be true for other (future) classes..? for chunk_start in xrange(0, self.index.shape[0], self.chunksize): # scipy.sparse doesn't allow slicing beyond real size of the matrix # (unlike numpy). so, clip the end of the chunk explicitly to make # scipy.sparse happy chunk_end = min(self.index.shape[0], chunk_start + self.chunksize) chunk = self.index[chunk_start : chunk_end] if chunk.shape[0] > 1: for sim in self[chunk]: yield sim else: yield self[chunk] else: for doc in self.index: yield self[doc] # restore old normalization value self.normalize = norm #endclass SimilarityABC
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 199, 624, 199, 2765, 859, 3509, 5678, 8386, 1202, 23088, 314, 8852, 3805, 5206, 2559, 14, 199, 199, 1918, 8386, 787, 3363, 1759, 465, 9006, 1300, 3992, 334, 1873, 2020, 2005, 2716, 9330, 199, 374, 2741, 315, 314, 3217, 6337, 12, 880, 626, 314, 8386, 883, 506, 1007, 28271, 680, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 2050, 199, 646, 7975, 199, 199, 504, 3805, 5206, 492, 3778, 12, 2530, 1208, 199, 504, 3816, 14, 4912, 492, 4945, 421, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 7436, 358, 421, 199, 533, 7499, 8843, 8390, 8, 1208, 14, 8229, 6200, 304, 272, 408, 272, 14816, 334, 6198, 1300, 1021, 9, 367, 1970, 7314, 65, 14, 437, 627, 16780, 10, 365, 9329, 376, 6076, 12, 272, 2382, 1924, 8494, 3650, 14801, 1373, 2213, 26, 339, 1306, 367, 1382, 315, 16831, 26, 272, 1306, 258, 327, 886, 6020, 543, 314, 1382, 1396, 339, 437, 2213, 365, 282, 3414, 402, 16918, 698, 1304, 12, 901, 1110, 12544, 499, 13, 11760, 26, 339, 1306, 367, 1921, 63, 344, 12, 1921, 63, 585, 315, 1382, 26, 272, 1306, 258, 327, 886, 6020, 543, 314, 2225, 339, 3390, 626, 22160, 282, 849, 520, 1532, 1705, 552, 64, 1083, 365, 2741, 12, 652, 365, 7437, 315, 21069, 272, 334, 529, 3351, 282, 7798, 8000, 4012, 314, 16831, 370, 6705, 2399, 2582, 680, 17685, 422, 272, 314, 16831, 1568, 365, 4346, 436, 6040, 315, 18695, 334, 269, 737, 5210, 3181, 1133, 1570, 880, 272, 626, 652, 883, 506, 6328, 395, 314, 520, 1532, 1705, 552, 64, 1083, 1077, 506, 10087, 14, 339, 1666, 314, 520, 1494, 1705, 2268, 5206, 14, 20504, 65, 14, 16820, 4040, 16780, 64, 859, 367, 376, 2893, 402, 282, 16831, 14, 339, 428, 5519, 314, 16831, 543, 314, 658, 2117, 64, 1083, 334, 17571, 687, 658, 1208, 14, 8229, 6200, 10522, 911, 272, 1454, 3877, 314, 627, 262, 13, 4844, 10, 334, 3008, 12, 18731, 9, 909, 6025, 29, 1589, 2547, 272, 1174, 12, 436, 1011, 1397, 538, 314, 8247, 17279, 14, 1666, 314, 658, 2117, 63, 16780, 64, 2955, 1083, 272, 367, 3012, 9147, 314, 3503, 2547, 1564, 14, 272, 408, 272, 347, 636, 1661, 721, 277, 304, 267, 408, 267, 23989, 1806, 314, 16831, 12, 32035, 1373, 2213, 737, 282, 900, 14, 267, 408, 267, 746, 4279, 360, 11250, 17321, 9006, 1300, 1021, 358, 2378, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 492, 3598, 267, 3598, 14, 4050, 480, 16780, 14, 2117, 342, 14086, 1454, 314, 334, 9864, 9, 8494, 909, 27, 298, 288, 298, 475, 8437, 314, 3503, 16831, 1564, 12, 675, 325, 14, 71, 14, 603, 77, 26424, 14, 3549, 8, 16780, 6320, 267, 1613, 8, 26424, 8390, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 552, 721, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 8247, 315, 314, 16831, 14, 398, 961, 1083, 365, 2951, 314, 5210, 2863, 21859, 436, 1077, 7710, 506, 267, 10087, 1380, 3962, 14, 267, 408, 267, 746, 4279, 480, 7790, 4278, 636, 552, 4533, 2544, 6358, 822, 8, 16780, 6320, 199, 3, 263, 2512, 14, 3764, 480, 15795, 316, 2615, 16831, 8000, 370, 6705, 2399, 2582, 27, 1990, 642, 11619, 18582, 199, 3, 263, 372, 3089, 8, 17, 367, 1382, 315, 291, 9, 327, 3089, 8, 1667, 4306, 9, 508, 378, 12, 880, 642, 5419, 2755, 367, 376, 2701, 16831, 339, 768, 4639, 272, 347, 3354, 63, 16780, 8, 5252, 12, 16831, 12, 1305, 18, 1027, 29, 403, 12, 3341, 29, 797, 304, 267, 408, 267, 11063, 376, 3411, 658, 16780, 64, 370, 4543, 14, 398, 6601, 6752, 2597, 2291, 13369, 314, 2600, 13493, 4445, 63, 344, 5118, 1027, 64, 4412, 395, 267, 1314, 883, 315, 642, 1930, 506, 2741, 701, 314, 2716, 658, 344, 18, 1027, 64, 2725, 14, 398, 1306, 603, 77, 26424, 14, 2117, 63, 16780, 360, 493, 14, 596, 297, 16831, 9, 398, 6601, 1970, 7314, 65, 2597, 2291, 376, 1478, 402, 2382, 1924, 2213, 22241, 12, 880, 267, 626, 314, 8247, 641, 4543, 883, 506, 13810, 315, 593, 8, 17, 9, 900, 334, 3239, 314, 267, 658, 20504, 65, 14, 19067, 26424, 64, 1300, 1021, 680, 1010, 642, 1930, 12, 658, 2117, 63, 16780, 64, 365, 5847, 267, 2797, 14448, 701, 658, 3549, 3559, 1314, 1630, 658, 2117, 63, 16780, 64, 12254, 23050, 314, 1478, 267, 737, 314, 2011, 900, 12, 880, 1265, 2934, 370, 3877, 314, 16831, 543, 447, 398, 1306, 603, 77, 26424, 14, 3549, 360, 493, 14, 596, 297, 16831, 9, 327, 14086, 1478, 465, 5521, 12, 17266, 2196, 2879, 370, 8212, 8247, 398, 23892, 658, 3549, 11995, 365, 14388, 370, 6358, 658, 2117, 63, 16780, 25593, 398, 408, 267, 746, 4279, 360, 11250, 17321, 9006, 1300, 1021, 358, 398, 327, 2893, 1233, 26, 267, 2512, 14, 815, 480, 6435, 1337, 16831, 370, 5805, 10674, 1475, 26, 450, 83, 2, 450, 6748, 9, 267, 543, 3778, 14, 7853, 63, 1490, 8, 5252, 12, 283, 6603, 358, 465, 17863, 26, 288, 367, 1382, 315, 16831, 26, 327, 13974, 1806, 314, 2213, 2547, 355, 7104, 275, 620, 8, 1301, 9, 327, 1475, 314, 2213, 22497, 1396, 355, 17863, 14, 952, 8, 1208, 14, 475, 63, 1624, 24, 3647, 83, 60, 78, 2, 450, 7104, 430, 327, 8437, 314, 7871, 2213, 370, 4543, 199, 3, 500, 533, 7499, 8843, 8390, 421, 199, 533, 6266, 6194, 26424, 8, 26424, 8390, 304, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 16831, 12, 22064, 29, 403, 304, 267, 291, 14, 1113, 12, 291, 14, 16780, 12, 291, 14, 30617, 275, 1559, 12, 16831, 12, 22064, 267, 291, 14, 2343, 275, 756, 339 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 199, 624, 199, 2765, 859, 3509, 5678, 8386, 1202, 23088, 314, 8852, 3805, 5206, 2559, 14, 199, 199, 1918, 8386, 787, 3363, 1759, 465, 9006, 1300, 3992, 334, 1873, 2020, 2005, 2716, 9330, 199, 374, 2741, 315, 314, 3217, 6337, 12, 880, 626, 314, 8386, 883, 506, 1007, 28271, 680, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 2050, 199, 646, 7975, 199, 199, 504, 3805, 5206, 492, 3778, 12, 2530, 1208, 199, 504, 3816, 14, 4912, 492, 4945, 421, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 7436, 358, 421, 199, 533, 7499, 8843, 8390, 8, 1208, 14, 8229, 6200, 304, 272, 408, 272, 14816, 334, 6198, 1300, 1021, 9, 367, 1970, 7314, 65, 14, 437, 627, 16780, 10, 365, 9329, 376, 6076, 12, 272, 2382, 1924, 8494, 3650, 14801, 1373, 2213, 26, 339, 1306, 367, 1382, 315, 16831, 26, 272, 1306, 258, 327, 886, 6020, 543, 314, 1382, 1396, 339, 437, 2213, 365, 282, 3414, 402, 16918, 698, 1304, 12, 901, 1110, 12544, 499, 13, 11760, 26, 339, 1306, 367, 1921, 63, 344, 12, 1921, 63, 585, 315, 1382, 26, 272, 1306, 258, 327, 886, 6020, 543, 314, 2225, 339, 3390, 626, 22160, 282, 849, 520, 1532, 1705, 552, 64, 1083, 365, 2741, 12, 652, 365, 7437, 315, 21069, 272, 334, 529, 3351, 282, 7798, 8000, 4012, 314, 16831, 370, 6705, 2399, 2582, 680, 17685, 422, 272, 314, 16831, 1568, 365, 4346, 436, 6040, 315, 18695, 334, 269, 737, 5210, 3181, 1133, 1570, 880, 272, 626, 652, 883, 506, 6328, 395, 314, 520, 1532, 1705, 552, 64, 1083, 1077, 506, 10087, 14, 339, 1666, 314, 520, 1494, 1705, 2268, 5206, 14, 20504, 65, 14, 16820, 4040, 16780, 64, 859, 367, 376, 2893, 402, 282, 16831, 14, 339, 428, 5519, 314, 16831, 543, 314, 658, 2117, 64, 1083, 334, 17571, 687, 658, 1208, 14, 8229, 6200, 10522, 911, 272, 1454, 3877, 314, 627, 262, 13, 4844, 10, 334, 3008, 12, 18731, 9, 909, 6025, 29, 1589, 2547, 272, 1174, 12, 436, 1011, 1397, 538, 314, 8247, 17279, 14, 1666, 314, 658, 2117, 63, 16780, 64, 2955, 1083, 272, 367, 3012, 9147, 314, 3503, 2547, 1564, 14, 272, 408, 272, 347, 636, 1661, 721, 277, 304, 267, 408, 267, 23989, 1806, 314, 16831, 12, 32035, 1373, 2213, 737, 282, 900, 14, 267, 408, 267, 746, 4279, 360, 11250, 17321, 9006, 1300, 1021, 358, 2378, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 492, 3598, 267, 3598, 14, 4050, 480, 16780, 14, 2117, 342, 14086, 1454, 314, 334, 9864, 9, 8494, 909, 27, 298, 288, 298, 475, 8437, 314, 3503, 16831, 1564, 12, 675, 325, 14, 71, 14, 603, 77, 26424, 14, 3549, 8, 16780, 6320, 267, 1613, 8, 26424, 8390, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 552, 721, 277, 304, 267, 408, 267, 1432, 314, 1329, 402, 8247, 315, 314, 16831, 14, 398, 961, 1083, 365, 2951, 314, 5210, 2863, 21859, 436, 1077, 7710, 506, 267, 10087, 1380, 3962, 14, 267, 408, 267, 746, 4279, 480, 7790, 4278, 636, 552, 4533, 2544, 6358, 822, 8, 16780, 6320, 199, 3, 263, 2512, 14, 3764, 480, 15795, 316, 2615, 16831, 8000, 370, 6705, 2399, 2582, 27, 1990, 642, 11619, 18582, 199, 3, 263, 372, 3089, 8, 17, 367, 1382, 315, 291, 9, 327, 3089, 8, 1667, 4306, 9, 508, 378, 12, 880, 642, 5419, 2755, 367, 376, 2701, 16831, 339, 768, 4639, 272, 347, 3354, 63, 16780, 8, 5252, 12, 16831, 12, 1305, 18, 1027, 29, 403, 12, 3341, 29, 797, 304, 267, 408, 267, 11063, 376, 3411, 658, 16780, 64, 370, 4543, 14, 398, 6601, 6752, 2597, 2291, 13369, 314, 2600, 13493, 4445, 63, 344, 5118, 1027, 64, 4412, 395, 267, 1314, 883, 315, 642, 1930, 506, 2741, 701, 314, 2716, 658, 344, 18, 1027, 64, 2725, 14, 398, 1306, 603, 77, 26424, 14, 2117, 63, 16780, 360, 493, 14, 596, 297, 16831, 9, 398, 6601, 1970, 7314, 65, 2597, 2291, 376, 1478, 402, 2382, 1924, 2213, 22241, 12, 880, 267, 626, 314, 8247, 641, 4543, 883, 506, 13810, 315, 593, 8, 17, 9, 900, 334, 3239, 314, 267, 658, 20504, 65, 14, 19067, 26424, 64, 1300, 1021, 680, 1010, 642, 1930, 12, 658, 2117, 63, 16780, 64, 365, 5847, 267, 2797, 14448, 701, 658, 3549, 3559, 1314, 1630, 658, 2117, 63, 16780, 64, 12254, 23050, 314, 1478, 267, 737, 314, 2011, 900, 12, 880, 1265, 2934, 370, 3877, 314, 16831, 543, 447, 398, 1306, 603, 77, 26424, 14, 3549, 360, 493, 14, 596, 297, 16831, 9, 327, 14086, 1478, 465, 5521, 12, 17266, 2196, 2879, 370, 8212, 8247, 398, 23892, 658, 3549, 11995, 365, 14388, 370, 6358, 658, 2117, 63, 16780, 25593, 398, 408, 267, 746, 4279, 360, 11250, 17321, 9006, 1300, 1021, 358, 398, 327, 2893, 1233, 26, 267, 2512, 14, 815, 480, 6435, 1337, 16831, 370, 5805, 10674, 1475, 26, 450, 83, 2, 450, 6748, 9, 267, 543, 3778, 14, 7853, 63, 1490, 8, 5252, 12, 283, 6603, 358, 465, 17863, 26, 288, 367, 1382, 315, 16831, 26, 327, 13974, 1806, 314, 2213, 2547, 355, 7104, 275, 620, 8, 1301, 9, 327, 1475, 314, 2213, 22497, 1396, 355, 17863, 14, 952, 8, 1208, 14, 475, 63, 1624, 24, 3647, 83, 60, 78, 2, 450, 7104, 430, 327, 8437, 314, 7871, 2213, 370, 4543, 199, 3, 500, 533, 7499, 8843, 8390, 421, 199, 533, 6266, 6194, 26424, 8, 26424, 8390, 304, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 16831, 12, 22064, 29, 403, 304, 267, 291, 14, 1113, 12, 291, 14, 16780, 12, 291, 14, 30617, 275, 1559, 12, 16831, 12, 22064, 267, 291, 14, 2343, 275, 756, 339, 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 ]
shengwangXX/deeplearning
pytorch/mnist_dist.py
1
4858
from __future__ import print_function import argparse import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.autograd import Variable import torch.nn.parallel import torch.distributed as dist import torch.utils.data.distributed #import torch.utils.data.distributed # Training settings parser = argparse.ArgumentParser(description='PyTorch MNIST Example') parser.add_argument('--batch-size', type=int, default=64, metavar='N', help='input batch size for training (default: 64)') parser.add_argument('--test-batch-size', type=int, default=1000, metavar='N', help='input batch size for testing (default: 1000)') parser.add_argument('--epochs', type=int, default=10, metavar='N', help='number of epochs to train (default: 10)') parser.add_argument('--lr', type=float, default=0.01, metavar='LR', help='learning rate (default: 0.01)') parser.add_argument('--momentum', type=float, default=0.5, metavar='M', help='SGD momentum (default: 0.5)') parser.add_argument('--no-cuda', action='store_true', default=False, help='disables CUDA training') parser.add_argument('--seed', type=int, default=1, metavar='S', help='random seed (default: 1)') parser.add_argument('--log-interval', type=int, default=10, metavar='N', help='how many batches to wait before logging training status') args = parser.parse_args() args.cuda = not args.no_cuda and torch.cuda.is_available() torch.manual_seed(args.seed) if args.cuda: torch.cuda.manual_seed(args.seed) dist.init_process_group(backend='gloo', init_method='tcp://192.168.1.4:7777',rank = 0, world_size=2) train_datasets= datasets.MNIST('../data', train=True, download=True,transform=transforms.Compose([transforms.ToTensor(),transforms.Normalize((0.1307,), (0.3081,))])) train_sampler = torch.utils.data.distributed.DistributedSampler(train_datasets) kwargs = {'num_workers': 1, 'pin_memory': True} if args.cuda else {} train_loader = torch.utils.data.DataLoader(train_datasets, num_workers=2, sampler=train_sampler,batch_size=args.batch_size, shuffle=False, **kwargs) test_loader = torch.utils.data.DataLoader( datasets.MNIST('../data', train=False, transform=transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,)) ])), batch_size=args.test_batch_size, shuffle=True, **kwargs) class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) self.fc2 = nn.Linear(50, 10) def forward(self, x): x = F.relu(F.max_pool2d(self.conv1(x), 2)) x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2)) x = x.view(-1, 320) x = F.relu(self.fc1(x)) x = F.dropout(x, training=self.training) x = self.fc2(x) return F.log_softmax(x) model = Net() #model = torch.nn.parallel.DistributedDataParallel(model) if args.cuda: model.cuda() optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=args.momentum) def train(epoch): model.train() for batch_idx, (data, target) in enumerate(train_loader): if args.cuda: data, target = data.cuda(), target.cuda() data, target = Variable(data), Variable(target) optimizer.zero_grad() output = model(data) loss = F.nll_loss(output, target) loss.backward() optimizer.step() if batch_idx % args.log_interval == 0: print('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format( epoch, batch_idx * len(data), len(train_loader.dataset), 100. * batch_idx / len(train_loader), loss.data[0])) def test(): model.eval() test_loss = 0 correct = 0 for data, target in test_loader: if args.cuda: data, target = data.cuda(), target.cuda() data, target = Variable(data, volatile=True), Variable(target) output = model(data) test_loss += F.nll_loss(output, target, size_average=False).data[0] # sum up batch loss pred = output.data.max(1, keepdim=True)[1] # get the index of the max log-probability correct += pred.eq(target.data.view_as(pred)).cpu().sum() test_loss /= len(test_loader.dataset) print('\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n'.format( test_loss, correct, len(test_loader.dataset), 100. * correct / len(test_loader.dataset))) for epoch in range(1, args.epochs + 1): train(epoch) #test()
apache-2.0
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 21416, 199, 646, 21416, 14, 4411, 465, 11542, 199, 646, 21416, 14, 4411, 14, 15481, 465, 481, 199, 646, 21416, 14, 6433, 465, 5323, 199, 504, 21416, 2317, 492, 13148, 12, 18501, 199, 504, 21416, 14, 2495, 6017, 492, 4905, 199, 646, 21416, 14, 4411, 14, 11887, 199, 646, 21416, 14, 16832, 465, 2917, 199, 646, 21416, 14, 1208, 14, 576, 14, 16832, 199, 3, 646, 21416, 14, 1208, 14, 576, 14, 16832, 199, 3, 22859, 2202, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 534, 2713, 20994, 335, 603, 25392, 5679, 358, 199, 2087, 14, 525, 63, 2094, 4517, 2912, 13, 890, 297, 730, 29, 442, 12, 849, 29, 772, 12, 8214, 534, 46, 297, 490, 1720, 534, 1210, 3522, 1568, 367, 6093, 334, 885, 26, 5049, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 396, 13, 2912, 13, 890, 297, 730, 29, 442, 12, 849, 29, 5279, 12, 8214, 534, 46, 297, 490, 1720, 534, 1210, 3522, 1568, 367, 5343, 334, 885, 26, 5198, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 13161, 297, 730, 29, 442, 12, 849, 29, 709, 12, 8214, 534, 46, 297, 490, 1720, 534, 1955, 402, 18463, 370, 3560, 334, 885, 26, 1616, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 7493, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 614, 12, 8214, 534, 17665, 297, 490, 1720, 534, 10546, 6634, 334, 885, 26, 378, 14, 614, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 25710, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 8214, 534, 45, 297, 490, 1720, 534, 4254, 36, 23887, 334, 885, 26, 378, 14, 21, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 889, 13, 16309, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 490, 1720, 534, 2297, 5921, 445, 3383, 33, 6093, 358, 199, 2087, 14, 525, 63, 2094, 4517, 5176, 297, 730, 29, 442, 12, 849, 29, 17, 12, 8214, 534, 51, 297, 490, 1720, 534, 2355, 6347, 334, 885, 26, 413, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 793, 13, 4284, 297, 730, 29, 442, 12, 849, 29, 709, 12, 8214, 534, 46, 297, 490, 1720, 534, 1917, 5002, 19593, 370, 3618, 2544, 2050, 6093, 2004, 358, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 589, 14, 16309, 275, 440, 1249, 14, 889, 63, 16309, 436, 21416, 14, 16309, 14, 374, 63, 4561, 342, 199, 199, 29676, 14, 9285, 63, 5176, 8, 589, 14, 5176, 9, 199, 692, 1249, 14, 16309, 26, 272, 21416, 14, 16309, 14, 9285, 63, 5176, 8, 589, 14, 5176, 9, 199, 2686, 14, 826, 63, 1412, 63, 923, 8, 4620, 534, 30737, 79, 297, 4205, 63, 765, 534, 8815, 921, 5756, 14, 6568, 14, 17, 14, 20, 26, 16713, 297, 4648, 275, 378, 12, 6701, 63, 890, 29, 18, 9, 421, 199, 2834, 63, 12281, 29, 13148, 14, 16237, 6225, 24592, 576, 297, 3560, 29, 549, 12, 5235, 29, 549, 12, 4711, 29, 15133, 14, 2404, 3362, 779, 15133, 14, 1378, 3861, 1062, 15133, 14, 22580, 1332, 16, 14, 13421, 4706, 334, 16, 14, 1216, 2835, 4641, 2459, 199, 199, 2834, 63, 22934, 275, 21416, 14, 1208, 14, 576, 14, 16832, 14, 27398, 27434, 8, 2834, 63, 12281, 9, 199, 199, 958, 275, 791, 1507, 63, 11009, 356, 413, 12, 283, 7751, 63, 4844, 356, 715, 93, 340, 1249, 14, 16309, 587, 1052, 199, 2834, 63, 3422, 275, 21416, 14, 1208, 14, 576, 14, 1451, 5455, 8, 2834, 63, 12281, 12, 1967, 63, 11009, 29, 18, 12, 25906, 29, 2834, 63, 22934, 12, 2912, 63, 890, 29, 589, 14, 2912, 63, 890, 12, 13031, 29, 797, 12, 1011, 958, 9, 199, 396, 63, 3422, 275, 21416, 14, 1208, 14, 576, 14, 1451, 5455, 8, 272, 13148, 14, 16237, 6225, 24592, 576, 297, 3560, 29, 797, 12, 5793, 29, 15133, 14, 2404, 3362, 779, 2432, 18501, 14, 1378, 3861, 1062, 2432, 18501, 14, 22580, 1332, 16, 14, 13421, 4706, 334, 16, 14, 1216, 2835, 4641, 673, 4794, 395, 272, 3522, 63, 890, 29, 589, 14, 396, 63, 2912, 63, 890, 12, 13031, 29, 549, 12, 1011, 958, 9, 421, 199, 533, 5365, 8, 4411, 14, 2377, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 2480, 12, 291, 2843, 826, 4533, 267, 291, 14, 5598, 17, 275, 11542, 14, 11596, 18, 68, 8, 17, 12, 1616, 12, 5114, 63, 890, 29, 21, 9, 267, 291, 14, 5598, 18, 275, 11542, 14, 11596, 18, 68, 8, 709, 12, 3388, 12, 5114, 63, 890, 29, 21, 9, 267, 291, 14, 5598, 18, 63, 4824, 275, 11542, 14, 30662, 18, 68, 342, 267, 291, 14, 3003, 17, 275, 11542, 14, 10608, 8, 12122, 12, 5238, 9, 267, 291, 14, 3003, 18, 275, 11542, 14, 10608, 8, 1400, 12, 1616, 9, 339, 347, 7568, 8, 277, 12, 671, 304, 267, 671, 275, 481, 14, 12833, 8, 38, 14, 988, 63, 2293, 18, 68, 8, 277, 14, 5598, 17, 8, 88, 395, 499, 430, 267, 671, 275, 481, 14, 12833, 8, 38, 14, 988, 63, 2293, 18, 68, 8, 277, 14, 5598, 18, 63, 4824, 8, 277, 14, 5598, 18, 8, 88, 1826, 499, 430, 267, 671, 275, 671, 14, 1345, 2801, 17, 12, 25611, 9, 267, 671, 275, 481, 14, 12833, 8, 277, 14, 3003, 17, 8, 88, 430, 267, 671, 275, 481, 14, 17953, 8, 88, 12, 6093, 29, 277, 14, 7588, 9, 267, 671, 275, 291, 14, 3003, 18, 8, 88, 9, 267, 372, 481, 14, 793, 63, 16395, 8, 88, 9, 199, 199, 1238, 275, 5365, 342, 199, 3, 1238, 275, 21416, 14, 4411, 14, 11887, 14, 27398, 1451, 25721, 8, 1238, 9, 199, 692, 1249, 14, 16309, 26, 272, 1402, 14, 16309, 342, 199, 199, 12290, 275, 5323, 14, 4254, 36, 8, 1238, 14, 3214, 1062, 13645, 29, 589, 14, 7493, 12, 23887, 29, 589, 14, 25710, 9, 199, 199, 318, 3560, 8, 7367, 304, 272, 1402, 14, 2834, 342, 272, 367, 3522, 63, 2996, 12, 334, 576, 12, 1347, 9, 315, 3874, 8, 2834, 63, 3422, 304, 267, 340 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 21416, 199, 646, 21416, 14, 4411, 465, 11542, 199, 646, 21416, 14, 4411, 14, 15481, 465, 481, 199, 646, 21416, 14, 6433, 465, 5323, 199, 504, 21416, 2317, 492, 13148, 12, 18501, 199, 504, 21416, 14, 2495, 6017, 492, 4905, 199, 646, 21416, 14, 4411, 14, 11887, 199, 646, 21416, 14, 16832, 465, 2917, 199, 646, 21416, 14, 1208, 14, 576, 14, 16832, 199, 3, 646, 21416, 14, 1208, 14, 576, 14, 16832, 199, 3, 22859, 2202, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 534, 2713, 20994, 335, 603, 25392, 5679, 358, 199, 2087, 14, 525, 63, 2094, 4517, 2912, 13, 890, 297, 730, 29, 442, 12, 849, 29, 772, 12, 8214, 534, 46, 297, 490, 1720, 534, 1210, 3522, 1568, 367, 6093, 334, 885, 26, 5049, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 396, 13, 2912, 13, 890, 297, 730, 29, 442, 12, 849, 29, 5279, 12, 8214, 534, 46, 297, 490, 1720, 534, 1210, 3522, 1568, 367, 5343, 334, 885, 26, 5198, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 13161, 297, 730, 29, 442, 12, 849, 29, 709, 12, 8214, 534, 46, 297, 490, 1720, 534, 1955, 402, 18463, 370, 3560, 334, 885, 26, 1616, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 7493, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 614, 12, 8214, 534, 17665, 297, 490, 1720, 534, 10546, 6634, 334, 885, 26, 378, 14, 614, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 25710, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 8214, 534, 45, 297, 490, 1720, 534, 4254, 36, 23887, 334, 885, 26, 378, 14, 21, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 889, 13, 16309, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 490, 1720, 534, 2297, 5921, 445, 3383, 33, 6093, 358, 199, 2087, 14, 525, 63, 2094, 4517, 5176, 297, 730, 29, 442, 12, 849, 29, 17, 12, 8214, 534, 51, 297, 490, 1720, 534, 2355, 6347, 334, 885, 26, 413, 5942, 199, 2087, 14, 525, 63, 2094, 4517, 793, 13, 4284, 297, 730, 29, 442, 12, 849, 29, 709, 12, 8214, 534, 46, 297, 490, 1720, 534, 1917, 5002, 19593, 370, 3618, 2544, 2050, 6093, 2004, 358, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 589, 14, 16309, 275, 440, 1249, 14, 889, 63, 16309, 436, 21416, 14, 16309, 14, 374, 63, 4561, 342, 199, 199, 29676, 14, 9285, 63, 5176, 8, 589, 14, 5176, 9, 199, 692, 1249, 14, 16309, 26, 272, 21416, 14, 16309, 14, 9285, 63, 5176, 8, 589, 14, 5176, 9, 199, 2686, 14, 826, 63, 1412, 63, 923, 8, 4620, 534, 30737, 79, 297, 4205, 63, 765, 534, 8815, 921, 5756, 14, 6568, 14, 17, 14, 20, 26, 16713, 297, 4648, 275, 378, 12, 6701, 63, 890, 29, 18, 9, 421, 199, 2834, 63, 12281, 29, 13148, 14, 16237, 6225, 24592, 576, 297, 3560, 29, 549, 12, 5235, 29, 549, 12, 4711, 29, 15133, 14, 2404, 3362, 779, 15133, 14, 1378, 3861, 1062, 15133, 14, 22580, 1332, 16, 14, 13421, 4706, 334, 16, 14, 1216, 2835, 4641, 2459, 199, 199, 2834, 63, 22934, 275, 21416, 14, 1208, 14, 576, 14, 16832, 14, 27398, 27434, 8, 2834, 63, 12281, 9, 199, 199, 958, 275, 791, 1507, 63, 11009, 356, 413, 12, 283, 7751, 63, 4844, 356, 715, 93, 340, 1249, 14, 16309, 587, 1052, 199, 2834, 63, 3422, 275, 21416, 14, 1208, 14, 576, 14, 1451, 5455, 8, 2834, 63, 12281, 12, 1967, 63, 11009, 29, 18, 12, 25906, 29, 2834, 63, 22934, 12, 2912, 63, 890, 29, 589, 14, 2912, 63, 890, 12, 13031, 29, 797, 12, 1011, 958, 9, 199, 396, 63, 3422, 275, 21416, 14, 1208, 14, 576, 14, 1451, 5455, 8, 272, 13148, 14, 16237, 6225, 24592, 576, 297, 3560, 29, 797, 12, 5793, 29, 15133, 14, 2404, 3362, 779, 2432, 18501, 14, 1378, 3861, 1062, 2432, 18501, 14, 22580, 1332, 16, 14, 13421, 4706, 334, 16, 14, 1216, 2835, 4641, 673, 4794, 395, 272, 3522, 63, 890, 29, 589, 14, 396, 63, 2912, 63, 890, 12, 13031, 29, 549, 12, 1011, 958, 9, 421, 199, 533, 5365, 8, 4411, 14, 2377, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 2480, 12, 291, 2843, 826, 4533, 267, 291, 14, 5598, 17, 275, 11542, 14, 11596, 18, 68, 8, 17, 12, 1616, 12, 5114, 63, 890, 29, 21, 9, 267, 291, 14, 5598, 18, 275, 11542, 14, 11596, 18, 68, 8, 709, 12, 3388, 12, 5114, 63, 890, 29, 21, 9, 267, 291, 14, 5598, 18, 63, 4824, 275, 11542, 14, 30662, 18, 68, 342, 267, 291, 14, 3003, 17, 275, 11542, 14, 10608, 8, 12122, 12, 5238, 9, 267, 291, 14, 3003, 18, 275, 11542, 14, 10608, 8, 1400, 12, 1616, 9, 339, 347, 7568, 8, 277, 12, 671, 304, 267, 671, 275, 481, 14, 12833, 8, 38, 14, 988, 63, 2293, 18, 68, 8, 277, 14, 5598, 17, 8, 88, 395, 499, 430, 267, 671, 275, 481, 14, 12833, 8, 38, 14, 988, 63, 2293, 18, 68, 8, 277, 14, 5598, 18, 63, 4824, 8, 277, 14, 5598, 18, 8, 88, 1826, 499, 430, 267, 671, 275, 671, 14, 1345, 2801, 17, 12, 25611, 9, 267, 671, 275, 481, 14, 12833, 8, 277, 14, 3003, 17, 8, 88, 430, 267, 671, 275, 481, 14, 17953, 8, 88, 12, 6093, 29, 277, 14, 7588, 9, 267, 671, 275, 291, 14, 3003, 18, 8, 88, 9, 267, 372, 481, 14, 793, 63, 16395, 8, 88, 9, 199, 199, 1238, 275, 5365, 342, 199, 3, 1238, 275, 21416, 14, 4411, 14, 11887, 14, 27398, 1451, 25721, 8, 1238, 9, 199, 692, 1249, 14, 16309, 26, 272, 1402, 14, 16309, 342, 199, 199, 12290, 275, 5323, 14, 4254, 36, 8, 1238, 14, 3214, 1062, 13645, 29, 589, 14, 7493, 12, 23887, 29, 589, 14, 25710, 9, 199, 199, 318, 3560, 8, 7367, 304, 272, 1402, 14, 2834, 342, 272, 367, 3522, 63, 2996, 12, 334, 576, 12, 1347, 9, 315, 3874, 8, 2834, 63, 3422, 304, 267, 340, 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, 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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 ]
Baumelbi/IntroPython2016
students/alextruo/session2/series.py
3
1664
#define the function here with n as the value print("Give me a number:") n = int(input()) def fibonacci(n): """(must be indented) this is an example doc string compute the nth Fibonacci number""" if n < 0: return None elif n == 0: return 0 if n == 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2) #this calls the function with the number that I enter. print("This is the number:", fibonacci(n)) def lucas(n): """this is the lucas series, which is similar but it starts with 1 and 1 instead""" if n < 0: return None elif n == 2: return 2 if n == 1: return 1 else: return lucas(n - 1) + lucas(n - 2) #call the function and print out this number from the lucas series print("This the lucas number: ", lucas(n)) #define the sum series with 3 parameters, required, 2 optional def sum_series(n, param1=0, param2=1): """ for param1 = 0 , return the zero position for param2 = 1, return the first element in the series if the first and second numbers are 0 and 1, it's Fibonnaci if the first and second numbers are 2 and 1, it's Lucas """ if n < 0: return None if n == 0: return param1 elif n == 1: return param2 else: return sum_series(n - 1, param1, param2) + sum_series(n - 2, param1, param2) print("Prints the nth number in the sequence: ", sum_series(n)) #testing with assert statements assert fibonacci(0) == 0 assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(5) == 5 assert lucas(-1) == None assert lucas(-2) == None assert lucas(5) == 8
unlicense
[ 3, 4640, 314, 805, 2348, 543, 302, 465, 314, 574, 199, 1361, 480, 39, 1912, 562, 282, 1329, 9107, 199, 78, 275, 1109, 8, 1210, 1012, 199, 199, 318, 289, 1892, 265, 645, 559, 8, 78, 304, 272, 408, 8, 7790, 506, 19197, 9, 642, 365, 376, 2893, 1382, 1059, 4526, 314, 30564, 481, 1892, 265, 645, 559, 1329, 624, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 916, 302, 508, 378, 26, 267, 372, 378, 272, 340, 302, 508, 413, 26, 267, 372, 413, 272, 372, 289, 1892, 265, 645, 559, 8, 78, 446, 413, 9, 435, 289, 1892, 265, 645, 559, 8, 78, 446, 499, 9, 199, 199, 3, 3749, 4882, 314, 805, 543, 314, 1329, 626, 473, 9509, 14, 199, 1361, 480, 2765, 365, 314, 1329, 6783, 289, 1892, 265, 645, 559, 8, 78, 430, 199, 199, 318, 634, 947, 305, 8, 78, 304, 272, 408, 3749, 365, 314, 634, 947, 305, 6779, 12, 1314, 365, 8545, 1325, 652, 9174, 543, 413, 436, 413, 3140, 624, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 916, 302, 508, 499, 26, 267, 372, 499, 272, 340, 302, 508, 413, 26, 267, 372, 413, 272, 587, 26, 267, 372, 634, 947, 305, 8, 78, 446, 413, 9, 435, 634, 947, 305, 8, 78, 446, 499, 9, 199, 3, 1250, 314, 805, 436, 870, 734, 642, 1329, 687, 314, 634, 947, 305, 6779, 199, 1361, 480, 2765, 314, 634, 947, 305, 1329, 26, 3872, 634, 947, 305, 8, 78, 430, 199, 199, 3, 4640, 314, 3089, 6779, 543, 650, 2633, 12, 1415, 12, 499, 2716, 199, 318, 3089, 63, 5602, 8, 78, 12, 1215, 17, 29, 16, 12, 1215, 18, 29, 17, 304, 272, 408, 272, 367, 1215, 17, 275, 378, 2360, 372, 314, 4697, 3421, 272, 367, 1215, 18, 275, 413, 12, 372, 314, 1642, 1819, 315, 314, 6779, 272, 340, 314, 1642, 436, 3499, 5579, 787, 378, 436, 413, 12, 652, 1159, 481, 1892, 265, 3540, 559, 272, 340, 314, 1642, 436, 3499, 5579, 787, 499, 436, 413, 12, 652, 1159, 491, 947, 305, 272, 408, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 340, 302, 508, 378, 26, 267, 372, 1215, 17, 272, 916, 302, 508, 413, 26, 267, 372, 1215, 18, 272, 587, 26, 267, 372, 3089, 63, 5602, 8, 78, 446, 413, 12, 1215, 17, 12, 1215, 18, 9, 435, 3089, 63, 5602, 8, 78, 446, 499, 12, 1215, 17, 12, 1215, 18, 9, 199, 199, 1361, 480, 26113, 314, 30564, 1329, 315, 314, 3414, 26, 3872, 3089, 63, 5602, 8, 78, 430, 199, 199, 3, 4776, 543, 702, 9834, 199, 479, 289, 1892, 265, 645, 559, 8, 16, 9, 508, 378, 199, 479, 289, 1892, 265, 645, 559, 8, 17, 9, 508, 413, 199, 479, 289, 1892, 265, 645, 559, 8, 18, 9, 508, 413, 199, 479, 289, 1892, 265, 645, 559, 8, 19, 9, 508, 499, 199, 479, 289, 1892, 265, 645, 559, 8, 21, 9, 508, 959, 199, 199, 479, 634, 947, 305, 2801, 17, 9, 508, 221, 488, 199, 479, 634, 947, 305, 2801, 18, 9, 508, 221, 488, 199, 479, 634, 947, 305, 8, 21, 9, 508, 221, 1695, 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 ]
[ 4640, 314, 805, 2348, 543, 302, 465, 314, 574, 199, 1361, 480, 39, 1912, 562, 282, 1329, 9107, 199, 78, 275, 1109, 8, 1210, 1012, 199, 199, 318, 289, 1892, 265, 645, 559, 8, 78, 304, 272, 408, 8, 7790, 506, 19197, 9, 642, 365, 376, 2893, 1382, 1059, 4526, 314, 30564, 481, 1892, 265, 645, 559, 1329, 624, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 916, 302, 508, 378, 26, 267, 372, 378, 272, 340, 302, 508, 413, 26, 267, 372, 413, 272, 372, 289, 1892, 265, 645, 559, 8, 78, 446, 413, 9, 435, 289, 1892, 265, 645, 559, 8, 78, 446, 499, 9, 199, 199, 3, 3749, 4882, 314, 805, 543, 314, 1329, 626, 473, 9509, 14, 199, 1361, 480, 2765, 365, 314, 1329, 6783, 289, 1892, 265, 645, 559, 8, 78, 430, 199, 199, 318, 634, 947, 305, 8, 78, 304, 272, 408, 3749, 365, 314, 634, 947, 305, 6779, 12, 1314, 365, 8545, 1325, 652, 9174, 543, 413, 436, 413, 3140, 624, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 916, 302, 508, 499, 26, 267, 372, 499, 272, 340, 302, 508, 413, 26, 267, 372, 413, 272, 587, 26, 267, 372, 634, 947, 305, 8, 78, 446, 413, 9, 435, 634, 947, 305, 8, 78, 446, 499, 9, 199, 3, 1250, 314, 805, 436, 870, 734, 642, 1329, 687, 314, 634, 947, 305, 6779, 199, 1361, 480, 2765, 314, 634, 947, 305, 1329, 26, 3872, 634, 947, 305, 8, 78, 430, 199, 199, 3, 4640, 314, 3089, 6779, 543, 650, 2633, 12, 1415, 12, 499, 2716, 199, 318, 3089, 63, 5602, 8, 78, 12, 1215, 17, 29, 16, 12, 1215, 18, 29, 17, 304, 272, 408, 272, 367, 1215, 17, 275, 378, 2360, 372, 314, 4697, 3421, 272, 367, 1215, 18, 275, 413, 12, 372, 314, 1642, 1819, 315, 314, 6779, 272, 340, 314, 1642, 436, 3499, 5579, 787, 378, 436, 413, 12, 652, 1159, 481, 1892, 265, 3540, 559, 272, 340, 314, 1642, 436, 3499, 5579, 787, 499, 436, 413, 12, 652, 1159, 491, 947, 305, 272, 408, 272, 340, 302, 665, 378, 26, 267, 372, 488, 272, 340, 302, 508, 378, 26, 267, 372, 1215, 17, 272, 916, 302, 508, 413, 26, 267, 372, 1215, 18, 272, 587, 26, 267, 372, 3089, 63, 5602, 8, 78, 446, 413, 12, 1215, 17, 12, 1215, 18, 9, 435, 3089, 63, 5602, 8, 78, 446, 499, 12, 1215, 17, 12, 1215, 18, 9, 199, 199, 1361, 480, 26113, 314, 30564, 1329, 315, 314, 3414, 26, 3872, 3089, 63, 5602, 8, 78, 430, 199, 199, 3, 4776, 543, 702, 9834, 199, 479, 289, 1892, 265, 645, 559, 8, 16, 9, 508, 378, 199, 479, 289, 1892, 265, 645, 559, 8, 17, 9, 508, 413, 199, 479, 289, 1892, 265, 645, 559, 8, 18, 9, 508, 413, 199, 479, 289, 1892, 265, 645, 559, 8, 19, 9, 508, 499, 199, 479, 289, 1892, 265, 645, 559, 8, 21, 9, 508, 959, 199, 199, 479, 634, 947, 305, 2801, 17, 9, 508, 221, 488, 199, 479, 634, 947, 305, 2801, 18, 9, 508, 221, 488, 199, 479, 634, 947, 305, 8, 21, 9, 508, 221, 1695, 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, 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 ]
inverthermit/pacman_ai
reinforcement/graphicsCrawlerDisplay.py
6
11027
# graphicsCrawlerDisplay.py # ------------------------- # Licensing Information: You are free to use or extend these projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to UC Berkeley, including a link to http://ai.berkeley.edu. # # Attribution Information: The Pacman AI projects were developed at UC Berkeley. # The core projects and autograders were primarily created by John DeNero # (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). # Student side autograding was added by Brad Miller, Nick Hay, and # Pieter Abbeel (pabbeel@cs.berkeley.edu). # graphicsCrawlerDisplay.py # ------------------------- # Licensing Information: Please do not distribute or publish solutions to this # project. You are free to use and extend these projects for educational # purposes. The Pacman AI projects were developed at UC Berkeley, primarily by # John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). # Student side autograding was added by Brad Miller, Nick Hay, and Pieter # Abbeel in Spring 2013. # For more info, see http://inst.eecs.berkeley.edu/~cs188/pacman/pacman.html import Tkinter import qlearningAgents import time import threading import sys import crawler #import pendulum import math from math import pi as PI robotType = 'crawler' class Application: def sigmoid(self, x): return 1.0 / (1.0 + 2.0 ** (-x)) def incrementSpeed(self, inc): self.tickTime *= inc # self.epsilon = min(1.0, self.epsilon) # self.epsilon = max(0.0,self.epsilon) # self.learner.setSpeed(self.epsilon) self.speed_label['text'] = 'Step Delay: %.5f' % (self.tickTime) def incrementEpsilon(self, inc): self.ep += inc self.epsilon = self.sigmoid(self.ep) self.learner.setEpsilon(self.epsilon) self.epsilon_label['text'] = 'Epsilon: %.3f' % (self.epsilon) def incrementGamma(self, inc): self.ga += inc self.gamma = self.sigmoid(self.ga) self.learner.setDiscount(self.gamma) self.gamma_label['text'] = 'Discount: %.3f' % (self.gamma) def incrementAlpha(self, inc): self.al += inc self.alpha = self.sigmoid(self.al) self.learner.setLearningRate(self.alpha) self.alpha_label['text'] = 'Learning Rate: %.3f' % (self.alpha) def __initGUI(self, win): ## Window ## self.win = win ## Initialize Frame ## win.grid() self.dec = -.5 self.inc = .5 self.tickTime = 0.1 ## Epsilon Button + Label ## self.setupSpeedButtonAndLabel(win) self.setupEpsilonButtonAndLabel(win) ## Gamma Button + Label ## self.setUpGammaButtonAndLabel(win) ## Alpha Button + Label ## self.setupAlphaButtonAndLabel(win) ## Exit Button ## #self.exit_button = Tkinter.Button(win,text='Quit', command=self.exit) #self.exit_button.grid(row=0, column=9) ## Simulation Buttons ## # self.setupSimulationButtons(win) ## Canvas ## self.canvas = Tkinter.Canvas(root, height=200, width=1000) self.canvas.grid(row=2,columnspan=10) def setupAlphaButtonAndLabel(self, win): self.alpha_minus = Tkinter.Button(win, text="-",command=(lambda: self.incrementAlpha(self.dec))) self.alpha_minus.grid(row=1, column=3, padx=10) self.alpha = self.sigmoid(self.al) self.alpha_label = Tkinter.Label(win, text='Learning Rate: %.3f' % (self.alpha)) self.alpha_label.grid(row=1, column=4) self.alpha_plus = Tkinter.Button(win, text="+",command=(lambda: self.incrementAlpha(self.inc))) self.alpha_plus.grid(row=1, column=5, padx=10) def setUpGammaButtonAndLabel(self, win): self.gamma_minus = Tkinter.Button(win, text="-",command=(lambda: self.incrementGamma(self.dec))) self.gamma_minus.grid(row=1, column=0, padx=10) self.gamma = self.sigmoid(self.ga) self.gamma_label = Tkinter.Label(win, text='Discount: %.3f' % (self.gamma)) self.gamma_label.grid(row=1, column=1) self.gamma_plus = Tkinter.Button(win, text="+",command=(lambda: self.incrementGamma(self.inc))) self.gamma_plus.grid(row=1, column=2, padx=10) def setupEpsilonButtonAndLabel(self, win): self.epsilon_minus = Tkinter.Button(win, text="-",command=(lambda: self.incrementEpsilon(self.dec))) self.epsilon_minus.grid(row=0, column=3) self.epsilon = self.sigmoid(self.ep) self.epsilon_label = Tkinter.Label(win, text='Epsilon: %.3f' % (self.epsilon)) self.epsilon_label.grid(row=0, column=4) self.epsilon_plus = Tkinter.Button(win, text="+",command=(lambda: self.incrementEpsilon(self.inc))) self.epsilon_plus.grid(row=0, column=5) def setupSpeedButtonAndLabel(self, win): self.speed_minus = Tkinter.Button(win, text="-",command=(lambda: self.incrementSpeed(.5))) self.speed_minus.grid(row=0, column=0) self.speed_label = Tkinter.Label(win, text='Step Delay: %.5f' % (self.tickTime)) self.speed_label.grid(row=0, column=1) self.speed_plus = Tkinter.Button(win, text="+",command=(lambda: self.incrementSpeed(2))) self.speed_plus.grid(row=0, column=2) def skip5kSteps(self): self.stepsToSkip = 5000 def __init__(self, win): self.ep = 0 self.ga = 2 self.al = 2 self.stepCount = 0 ## Init Gui self.__initGUI(win) # Init environment if robotType == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robotEnvironment = crawler.CrawlingRobotEnvironment(self.robot) elif robotType == 'pendulum': self.robot = pendulum.PendulumRobot(self.canvas) self.robotEnvironment = \ pendulum.PendulumRobotEnvironment(self.robot) else: raise "Unknown RobotType" # Init Agent simulationFn = lambda agent: \ simulation.SimulationEnvironment(self.robotEnvironment,agent) actionFn = lambda state: \ self.robotEnvironment.getPossibleActions(state) self.learner = qlearningAgents.QLearningAgent(actionFn=actionFn) self.learner.setEpsilon(self.epsilon) self.learner.setLearningRate(self.alpha) self.learner.setDiscount(self.gamma) # Start GUI self.running = True self.stopped = False self.stepsToSkip = 0 self.thread = threading.Thread(target=self.run) self.thread.start() def exit(self): self.running = False for i in range(5): if not self.stopped: time.sleep(0.1) try: self.win.destroy() except: pass sys.exit(0) def step(self): self.stepCount += 1 state = self.robotEnvironment.getCurrentState() actions = self.robotEnvironment.getPossibleActions(state) if len(actions) == 0.0: self.robotEnvironment.reset() state = self.robotEnvironment.getCurrentState() actions = self.robotEnvironment.getPossibleActions(state) print 'Reset!' action = self.learner.getAction(state) if action == None: raise 'None action returned: Code Not Complete' nextState, reward = self.robotEnvironment.doAction(action) self.learner.observeTransition(state, action, nextState, reward) def animatePolicy(self): if robotType != 'pendulum': raise 'Only pendulum can animatePolicy' totWidth = self.canvas.winfo_reqwidth() totHeight = self.canvas.winfo_reqheight() length = 0.48 * min(totWidth, totHeight) x,y = totWidth-length-30, length+10 angleMin, angleMax = self.robot.getMinAndMaxAngle() velMin, velMax = self.robot.getMinAndMaxAngleVelocity() if not 'animatePolicyBox' in dir(self): self.canvas.create_line(x,y,x+length,y) self.canvas.create_line(x+length,y,x+length,y-length) self.canvas.create_line(x+length,y-length,x,y-length) self.canvas.create_line(x,y-length,x,y) self.animatePolicyBox = 1 self.canvas.create_text(x+length/2,y+10,text='angle') self.canvas.create_text(x-30,y-length/2,text='velocity') self.canvas.create_text(x-60,y-length/4,text='Blue = kickLeft') self.canvas.create_text(x-60,y-length/4+20,text='Red = kickRight') self.canvas.create_text(x-60,y-length/4+40,text='White = doNothing') angleDelta = (angleMax-angleMin) / 100 velDelta = (velMax-velMin) / 100 for i in range(100): angle = angleMin + i * angleDelta for j in range(100): vel = velMin + j * velDelta state = self.robotEnvironment.getState(angle,vel) max, argMax = None, None if not self.learner.seenState(state): argMax = 'unseen' else: for action in ('kickLeft','kickRight','doNothing'): qVal = self.learner.getQValue(state, action) if max == None or qVal > max: max, argMax = qVal, action if argMax != 'unseen': if argMax == 'kickLeft': color = 'blue' elif argMax == 'kickRight': color = 'red' elif argMax == 'doNothing': color = 'white' dx = length / 100.0 dy = length / 100.0 x0, y0 = x+i*dx, y-j*dy self.canvas.create_rectangle(x0,y0,x0+dx,y0+dy,fill=color) def run(self): self.stepCount = 0 self.learner.startEpisode() while True: minSleep = .01 tm = max(minSleep, self.tickTime) time.sleep(tm) self.stepsToSkip = int(tm / self.tickTime) - 1 if not self.running: self.stopped = True return for i in range(self.stepsToSkip): self.step() self.stepsToSkip = 0 self.step() # self.robot.draw() self.learner.stopEpisode() def start(self): self.win.mainloop() def run(): global root root = Tkinter.Tk() root.title( 'Crawler GUI' ) root.resizable( 0, 0 ) # root.mainloop() app = Application(root) def update_gui(): app.robot.draw(app.stepCount, app.tickTime) root.after(10, update_gui) update_gui() root.protocol( 'WM_DELETE_WINDOW', app.exit) try: app.start() except: app.exit()
mit
[ 3, 24348, 35, 16057, 7687, 14, 647, 199, 3, 10652, 9960, 199, 3, 491, 530, 25843, 17064, 26, 221, 2047, 787, 2867, 370, 675, 503, 12247, 3520, 11336, 367, 199, 3, 3988, 947, 6279, 12901, 2741, 626, 334, 17, 9, 1265, 886, 440, 11207, 503, 2780, 199, 3, 24886, 12, 334, 18, 9, 1265, 8074, 642, 4245, 12, 436, 334, 19, 9, 1265, 5647, 5436, 199, 3, 737, 15980, 370, 738, 35, 23207, 415, 15515, 12, 5893, 282, 2142, 370, 1455, 921, 5789, 14, 605, 415, 15515, 14, 8654, 14, 199, 3, 221, 199, 3, 2854, 15980, 17064, 26, 710, 510, 645, 1237, 437, 41, 11336, 4898, 477, 27813, 737, 738, 35, 23207, 415, 15515, 14, 199, 3, 710, 6170, 11336, 436, 2599, 926, 7735, 4898, 1979, 30468, 2737, 701, 17815, 1487, 46, 3478, 199, 3, 334, 848, 3478, 32, 1259, 14, 605, 415, 15515, 14, 8654, 9, 436, 24747, 1804, 274, 262, 334, 23572, 262, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 199, 3, 17246, 5366, 2599, 16050, 1990, 3483, 701, 699, 9525, 603, 19576, 12, 653, 2000, 869, 1187, 12, 436, 199, 3, 510, 1873, 351, 8351, 1235, 352, 334, 80, 371, 1235, 352, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 421, 199, 3, 24348, 35, 16057, 7687, 14, 647, 199, 3, 10652, 9960, 199, 3, 491, 530, 25843, 17064, 26, 7754, 886, 440, 11207, 503, 2780, 24886, 370, 642, 199, 3, 2199, 14, 2047, 787, 2867, 370, 675, 436, 12247, 3520, 11336, 367, 3988, 947, 6279, 199, 3, 12901, 14, 710, 510, 645, 1237, 437, 41, 11336, 4898, 477, 27813, 737, 738, 35, 23207, 415, 15515, 12, 1979, 30468, 701, 199, 3, 17815, 1487, 46, 3478, 334, 848, 3478, 32, 1259, 14, 605, 415, 15515, 14, 8654, 9, 436, 24747, 1804, 274, 262, 334, 23572, 262, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 199, 3, 17246, 5366, 2599, 16050, 1990, 3483, 701, 699, 9525, 603, 19576, 12, 653, 2000, 869, 1187, 12, 436, 510, 1873, 351, 199, 3, 8351, 1235, 352, 315, 428, 2700, 316, 6171, 14, 199, 3, 2104, 1655, 2256, 12, 1937, 1455, 921, 3615, 14, 69, 23075, 14, 605, 415, 15515, 14, 8654, 22500, 1259, 11501, 15, 28582, 1237, 15, 28582, 1237, 14, 1360, 199, 199, 646, 16826, 199, 646, 1894, 10546, 7788, 83, 199, 646, 900, 199, 646, 5796, 199, 646, 984, 199, 646, 29550, 199, 3, 646, 299, 500, 348, 453, 199, 646, 3473, 199, 504, 3473, 492, 6682, 465, 16678, 199, 199, 9751, 804, 275, 283, 23972, 7, 199, 199, 533, 13515, 26, 339, 347, 28886, 8, 277, 12, 671, 304, 267, 372, 413, 14, 16, 1182, 334, 17, 14, 16, 435, 499, 14, 16, 1011, 5868, 88, 430, 339, 347, 11609, 15146, 8, 277, 12, 12864, 304, 267, 291, 14, 8284, 1366, 9000, 12864, 199, 3, 263, 291, 14, 15761, 275, 1748, 8, 17, 14, 16, 12, 291, 14, 15761, 9, 199, 3, 263, 291, 14, 15761, 275, 1390, 8, 16, 14, 16, 12, 277, 14, 15761, 9, 199, 3, 263, 291, 14, 29144, 14, 409, 15146, 8, 277, 14, 15761, 9, 267, 291, 14, 7625, 63, 1302, 459, 505, 418, 275, 283, 7801, 18464, 1187, 26, 10536, 21, 70, 7, 450, 334, 277, 14, 8284, 1366, 9, 339, 347, 11609, 14057, 8746, 8, 277, 12, 12864, 304, 267, 291, 14, 1545, 847, 12864, 267, 291, 14, 15761, 275, 291, 14, 20035, 8, 277, 14, 1545, 9, 267, 291, 14, 29144, 14, 409, 14057, 8746, 8, 277, 14, 15761, 9, 267, 291, 14, 15761, 63, 1302, 459, 505, 418, 275, 283, 14057, 8746, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 15761, 9, 339, 347, 11609, 15091, 8, 277, 12, 12864, 304, 267, 291, 14, 5294, 847, 12864, 267, 291, 14, 7325, 275, 291, 14, 20035, 8, 277, 14, 5294, 9, 267, 291, 14, 29144, 14, 409, 2825, 835, 8, 277, 14, 7325, 9, 267, 291, 14, 7325, 63, 1302, 459, 505, 418, 275, 283, 2825, 835, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 7325, 9, 339, 347, 11609, 16192, 8, 277, 12, 12864, 304, 267, 291, 14, 279, 847, 12864, 267, 291, 14, 4468, 275, 291, 14, 20035, 8, 277, 14, 279, 9, 267, 291, 14, 29144, 14, 409, 25519, 6621, 8, 277, 14, 4468, 9, 267, 291, 14, 4468, 63, 1302, 459, 505, 418, 275, 283, 25519, 26311, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 4468, 9, 339, 347, 636, 826, 14438, 8, 277, 12, 4747, 304, 267, 925, 15689, 925, 267, 291, 14, 2676, 275, 4747, 398, 925, 11578, 11726, 925, 267, 4747, 14, 3825, 342, 267, 291, 14, 7778, 275, 3568, 21, 267, 291, 14, 6559, 275, 1275, 21, 267, 291, 14, 8284, 1366, 275, 378, 14, 17, 398, 925, 27255, 8746, 16005, 435, 10354, 925, 267, 291, 14, 2758, 15146, 4259, 3325, 4314, 8, 2676, 9, 398, 291, 14, 2758, 14057, 8746, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 598, 4746, 16005, 435, 10354, 925, 267, 291, 14, 5996, 15091, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 32657, 16005, 435, 10354, 925, 267, 291, 14, 2758, 16192, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 18704, 16005, 925, 267, 327, 277, 14, 2224, 63, 3887, 275, 16826, 14, 4259, 8, 2676, 12, 505, 534, 24145, 297, 1414, 29, 277, 14, 2224, 9, 267, 327, 277, 14, 2224, 63, 3887, 14, 3825, 8, 1143, 29, 16, 12, 2763, 29, 25, 9, 398, 925, 10751, 5332, 16005, 83, 925, 199, 3, 263, 291, 14, 2758, 31728, 24021, 8, 2676, 9, 13359, 925, 29349, 925, 267, 291, 14, 7682, 275, 16826, 14, 15174, 8, 1231, 12, 4569, 29, 1840, 12, 3462, 29, 5279, 9, 267, 291, 14, 7682, 14, 3825, 8, 1143, 29, 18, 12, 3406, 10384, 29, 709, 9, 339, 347, 3272, 16192, 4259, 3325, 4314, 8, 277, 12, 4747, 304, 267, 291, 14, 4468, 63, 13084, 275, 16826, 14, 4259, 8, 2676, 12, 267, 1318, 27295, 401, 1531, 2687, 2734, 26, 291, 14, 9728, 16192, 8, 277, 14, 7778, 1724, 267, 291, 14, 4468, 63, 13084, 14, 3825, 8, 1143, 29, 17, 12, 2763, 29, 19, 12 ]
[ 24348, 35, 16057, 7687, 14, 647, 199, 3, 10652, 9960, 199, 3, 491, 530, 25843, 17064, 26, 221, 2047, 787, 2867, 370, 675, 503, 12247, 3520, 11336, 367, 199, 3, 3988, 947, 6279, 12901, 2741, 626, 334, 17, 9, 1265, 886, 440, 11207, 503, 2780, 199, 3, 24886, 12, 334, 18, 9, 1265, 8074, 642, 4245, 12, 436, 334, 19, 9, 1265, 5647, 5436, 199, 3, 737, 15980, 370, 738, 35, 23207, 415, 15515, 12, 5893, 282, 2142, 370, 1455, 921, 5789, 14, 605, 415, 15515, 14, 8654, 14, 199, 3, 221, 199, 3, 2854, 15980, 17064, 26, 710, 510, 645, 1237, 437, 41, 11336, 4898, 477, 27813, 737, 738, 35, 23207, 415, 15515, 14, 199, 3, 710, 6170, 11336, 436, 2599, 926, 7735, 4898, 1979, 30468, 2737, 701, 17815, 1487, 46, 3478, 199, 3, 334, 848, 3478, 32, 1259, 14, 605, 415, 15515, 14, 8654, 9, 436, 24747, 1804, 274, 262, 334, 23572, 262, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 199, 3, 17246, 5366, 2599, 16050, 1990, 3483, 701, 699, 9525, 603, 19576, 12, 653, 2000, 869, 1187, 12, 436, 199, 3, 510, 1873, 351, 8351, 1235, 352, 334, 80, 371, 1235, 352, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 421, 199, 3, 24348, 35, 16057, 7687, 14, 647, 199, 3, 10652, 9960, 199, 3, 491, 530, 25843, 17064, 26, 7754, 886, 440, 11207, 503, 2780, 24886, 370, 642, 199, 3, 2199, 14, 2047, 787, 2867, 370, 675, 436, 12247, 3520, 11336, 367, 3988, 947, 6279, 199, 3, 12901, 14, 710, 510, 645, 1237, 437, 41, 11336, 4898, 477, 27813, 737, 738, 35, 23207, 415, 15515, 12, 1979, 30468, 701, 199, 3, 17815, 1487, 46, 3478, 334, 848, 3478, 32, 1259, 14, 605, 415, 15515, 14, 8654, 9, 436, 24747, 1804, 274, 262, 334, 23572, 262, 32, 1259, 14, 605, 415, 15515, 14, 8654, 680, 199, 3, 17246, 5366, 2599, 16050, 1990, 3483, 701, 699, 9525, 603, 19576, 12, 653, 2000, 869, 1187, 12, 436, 510, 1873, 351, 199, 3, 8351, 1235, 352, 315, 428, 2700, 316, 6171, 14, 199, 3, 2104, 1655, 2256, 12, 1937, 1455, 921, 3615, 14, 69, 23075, 14, 605, 415, 15515, 14, 8654, 22500, 1259, 11501, 15, 28582, 1237, 15, 28582, 1237, 14, 1360, 199, 199, 646, 16826, 199, 646, 1894, 10546, 7788, 83, 199, 646, 900, 199, 646, 5796, 199, 646, 984, 199, 646, 29550, 199, 3, 646, 299, 500, 348, 453, 199, 646, 3473, 199, 504, 3473, 492, 6682, 465, 16678, 199, 199, 9751, 804, 275, 283, 23972, 7, 199, 199, 533, 13515, 26, 339, 347, 28886, 8, 277, 12, 671, 304, 267, 372, 413, 14, 16, 1182, 334, 17, 14, 16, 435, 499, 14, 16, 1011, 5868, 88, 430, 339, 347, 11609, 15146, 8, 277, 12, 12864, 304, 267, 291, 14, 8284, 1366, 9000, 12864, 199, 3, 263, 291, 14, 15761, 275, 1748, 8, 17, 14, 16, 12, 291, 14, 15761, 9, 199, 3, 263, 291, 14, 15761, 275, 1390, 8, 16, 14, 16, 12, 277, 14, 15761, 9, 199, 3, 263, 291, 14, 29144, 14, 409, 15146, 8, 277, 14, 15761, 9, 267, 291, 14, 7625, 63, 1302, 459, 505, 418, 275, 283, 7801, 18464, 1187, 26, 10536, 21, 70, 7, 450, 334, 277, 14, 8284, 1366, 9, 339, 347, 11609, 14057, 8746, 8, 277, 12, 12864, 304, 267, 291, 14, 1545, 847, 12864, 267, 291, 14, 15761, 275, 291, 14, 20035, 8, 277, 14, 1545, 9, 267, 291, 14, 29144, 14, 409, 14057, 8746, 8, 277, 14, 15761, 9, 267, 291, 14, 15761, 63, 1302, 459, 505, 418, 275, 283, 14057, 8746, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 15761, 9, 339, 347, 11609, 15091, 8, 277, 12, 12864, 304, 267, 291, 14, 5294, 847, 12864, 267, 291, 14, 7325, 275, 291, 14, 20035, 8, 277, 14, 5294, 9, 267, 291, 14, 29144, 14, 409, 2825, 835, 8, 277, 14, 7325, 9, 267, 291, 14, 7325, 63, 1302, 459, 505, 418, 275, 283, 2825, 835, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 7325, 9, 339, 347, 11609, 16192, 8, 277, 12, 12864, 304, 267, 291, 14, 279, 847, 12864, 267, 291, 14, 4468, 275, 291, 14, 20035, 8, 277, 14, 279, 9, 267, 291, 14, 29144, 14, 409, 25519, 6621, 8, 277, 14, 4468, 9, 267, 291, 14, 4468, 63, 1302, 459, 505, 418, 275, 283, 25519, 26311, 26, 10536, 19, 70, 7, 450, 334, 277, 14, 4468, 9, 339, 347, 636, 826, 14438, 8, 277, 12, 4747, 304, 267, 925, 15689, 925, 267, 291, 14, 2676, 275, 4747, 398, 925, 11578, 11726, 925, 267, 4747, 14, 3825, 342, 267, 291, 14, 7778, 275, 3568, 21, 267, 291, 14, 6559, 275, 1275, 21, 267, 291, 14, 8284, 1366, 275, 378, 14, 17, 398, 925, 27255, 8746, 16005, 435, 10354, 925, 267, 291, 14, 2758, 15146, 4259, 3325, 4314, 8, 2676, 9, 398, 291, 14, 2758, 14057, 8746, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 598, 4746, 16005, 435, 10354, 925, 267, 291, 14, 5996, 15091, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 32657, 16005, 435, 10354, 925, 267, 291, 14, 2758, 16192, 4259, 3325, 4314, 8, 2676, 9, 398, 925, 18704, 16005, 925, 267, 327, 277, 14, 2224, 63, 3887, 275, 16826, 14, 4259, 8, 2676, 12, 505, 534, 24145, 297, 1414, 29, 277, 14, 2224, 9, 267, 327, 277, 14, 2224, 63, 3887, 14, 3825, 8, 1143, 29, 16, 12, 2763, 29, 25, 9, 398, 925, 10751, 5332, 16005, 83, 925, 199, 3, 263, 291, 14, 2758, 31728, 24021, 8, 2676, 9, 13359, 925, 29349, 925, 267, 291, 14, 7682, 275, 16826, 14, 15174, 8, 1231, 12, 4569, 29, 1840, 12, 3462, 29, 5279, 9, 267, 291, 14, 7682, 14, 3825, 8, 1143, 29, 18, 12, 3406, 10384, 29, 709, 9, 339, 347, 3272, 16192, 4259, 3325, 4314, 8, 277, 12, 4747, 304, 267, 291, 14, 4468, 63, 13084, 275, 16826, 14, 4259, 8, 2676, 12, 267, 1318, 27295, 401, 1531, 2687, 2734, 26, 291, 14, 9728, 16192, 8, 277, 14, 7778, 1724, 267, 291, 14, 4468, 63, 13084, 14, 3825, 8, 1143, 29, 17, 12, 2763, 29, 19, 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, 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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 ]
MyAOSP/external_chromium_org
ppapi/generators/idl_log.py
137
1271
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Error and information logging for IDL """ import sys class IDLLog(object): """Captures and routes logging output. Caputres logging output and/or sends out via a file handle, typically stdout or stderr. """ def __init__(self, name, out): if name: self._name = '%s : ' % name else: self._name = '' self._out = out self._capture = False self._console = True self._log = [] def Log(self, msg): if self._console: line = "%s\n" % (msg) self._out.write(line) if self._capture: self._log.append(msg) def LogLine(self, filename, lineno, pos, msg): if self._console: line = "%s(%d) : %s%s\n" % (filename, lineno, self._name, msg) self._out.write(line) if self._capture: self._log.append(msg) def SetConsole(self, enable): self._console = enable def SetCapture(self, enable): self._capture = enable def DrainLog(self): out = self._log self._log = [] return out ErrOut = IDLLog('Error', sys.stderr) WarnOut = IDLLog('Warning', sys.stdout) InfoOut = IDLLog('', sys.stdout)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 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, 4520, 436, 2556, 2050, 367, 14575, 408, 199, 199, 646, 984, 421, 199, 533, 14575, 2445, 8, 785, 304, 523, 408, 13519, 1482, 436, 15777, 2050, 1072, 14, 819, 22516, 337, 470, 2050, 1072, 436, 15, 269, 16178, 734, 4799, 282, 570, 2429, 12, 13609, 523, 3839, 503, 4635, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 536, 12, 734, 304, 272, 340, 536, 26, 489, 291, 423, 354, 275, 1543, 83, 520, 283, 450, 536, 272, 587, 26, 489, 291, 423, 354, 275, 2125, 339, 291, 423, 548, 275, 734, 272, 291, 423, 12685, 275, 756, 272, 291, 423, 6614, 275, 715, 272, 291, 423, 793, 275, 942, 819, 347, 5297, 8, 277, 12, 1499, 304, 272, 340, 291, 423, 6614, 26, 489, 1004, 275, 2071, 83, 60, 78, 2, 450, 334, 1328, 9, 489, 291, 423, 548, 14, 952, 8, 604, 9, 272, 340, 291, 423, 12685, 26, 489, 291, 423, 793, 14, 740, 8, 1328, 9, 819, 347, 5297, 3049, 8, 277, 12, 1788, 12, 5874, 12, 2086, 12, 1499, 304, 272, 340, 291, 423, 6614, 26, 489, 1004, 275, 2071, 83, 4042, 68, 9, 520, 450, 83, 5, 83, 60, 78, 2, 450, 334, 1501, 12, 5874, 12, 291, 423, 354, 12, 1499, 9, 489, 291, 423, 548, 14, 952, 8, 604, 9, 272, 340, 291, 423, 12685, 26, 489, 291, 423, 793, 14, 740, 8, 1328, 9, 819, 347, 2494, 9270, 8, 277, 12, 4756, 304, 272, 291, 423, 6614, 275, 4756, 819, 347, 2494, 16640, 8, 277, 12, 4756, 304, 272, 291, 423, 12685, 275, 4756, 819, 347, 577, 6322, 2445, 8, 277, 304, 272, 734, 275, 291, 423, 793, 272, 291, 423, 793, 275, 942, 272, 372, 734, 199, 199, 5432, 2204, 221, 275, 14575, 2445, 360, 547, 297, 984, 14, 3083, 9, 199, 22673, 2204, 275, 14575, 2445, 360, 3849, 297, 984, 14, 2703, 9, 199, 2354, 2204, 275, 14575, 2445, 8594, 984, 14, 2703, 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 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 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, 4520, 436, 2556, 2050, 367, 14575, 408, 199, 199, 646, 984, 421, 199, 533, 14575, 2445, 8, 785, 304, 523, 408, 13519, 1482, 436, 15777, 2050, 1072, 14, 819, 22516, 337, 470, 2050, 1072, 436, 15, 269, 16178, 734, 4799, 282, 570, 2429, 12, 13609, 523, 3839, 503, 4635, 14, 523, 408, 523, 347, 636, 826, 721, 277, 12, 536, 12, 734, 304, 272, 340, 536, 26, 489, 291, 423, 354, 275, 1543, 83, 520, 283, 450, 536, 272, 587, 26, 489, 291, 423, 354, 275, 2125, 339, 291, 423, 548, 275, 734, 272, 291, 423, 12685, 275, 756, 272, 291, 423, 6614, 275, 715, 272, 291, 423, 793, 275, 942, 819, 347, 5297, 8, 277, 12, 1499, 304, 272, 340, 291, 423, 6614, 26, 489, 1004, 275, 2071, 83, 60, 78, 2, 450, 334, 1328, 9, 489, 291, 423, 548, 14, 952, 8, 604, 9, 272, 340, 291, 423, 12685, 26, 489, 291, 423, 793, 14, 740, 8, 1328, 9, 819, 347, 5297, 3049, 8, 277, 12, 1788, 12, 5874, 12, 2086, 12, 1499, 304, 272, 340, 291, 423, 6614, 26, 489, 1004, 275, 2071, 83, 4042, 68, 9, 520, 450, 83, 5, 83, 60, 78, 2, 450, 334, 1501, 12, 5874, 12, 291, 423, 354, 12, 1499, 9, 489, 291, 423, 548, 14, 952, 8, 604, 9, 272, 340, 291, 423, 12685, 26, 489, 291, 423, 793, 14, 740, 8, 1328, 9, 819, 347, 2494, 9270, 8, 277, 12, 4756, 304, 272, 291, 423, 6614, 275, 4756, 819, 347, 2494, 16640, 8, 277, 12, 4756, 304, 272, 291, 423, 12685, 275, 4756, 819, 347, 577, 6322, 2445, 8, 277, 304, 272, 734, 275, 291, 423, 793, 272, 291, 423, 793, 275, 942, 272, 372, 734, 199, 199, 5432, 2204, 221, 275, 14575, 2445, 360, 547, 297, 984, 14, 3083, 9, 199, 22673, 2204, 275, 14575, 2445, 360, 3849, 297, 984, 14, 2703, 9, 199, 2354, 2204, 275, 14575, 2445, 8594, 984, 14, 2703, 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, 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,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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 ]
0x0mar/king-phisher
king_phisher/client/client_rpc.py
1
5357
#!/usr/bin/env python # -*- coding: utf-8 -*- # # king_phisher/client/client_rpc.py # # 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 the project 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 code import getpass import json import logging import os import sys from king_phisher import find from king_phisher.third_party import AdvancedHTTPServer try: import msgpack has_msgpack = True """Whether the :py:mod:`msgpack` module is available or not.""" except ImportError: has_msgpack = False class KingPhisherRPCClient(AdvancedHTTPServer.AdvancedHTTPServerRPCClientCached): """ The main RPC object for communicating with the King Phisher Server over RPC. """ def __init__(self, *args, **kwargs): self.logger = logging.getLogger('KingPhisher.Client.RPC') super(KingPhisherRPCClient, self).__init__(*args, **kwargs) if has_msgpack: serializer = 'binary/message-pack' else: serializer = 'binary/json' self.set_serializer(serializer) def remote_table(self, table, *args): """ Get a remote table from the server by calling the correct RPC method. :param str table: The table name to retrieve. :return: A generator which yields rows in dictionaries. """ table_method = table + '/view' page = 0 args = list(args) args.append(page) results = self.call(table_method, *args) results_length = len(results or '') while results: columns = results['columns'] for row in results['rows']: yield dict(zip(columns, row)) if len(results) < results_length: break args[-1] += 1 results = self.call(table_method, *args) def remote_table_row(self, table, row_id, cache=False, refresh=False): """ Get a specific row by it's id, optionally cacheing it. :param str table: The table in which the row exists. :param row_id: The value of the row's id column. :param bool cache: Whether to use the cache for this row. :param bool refresh: If *cache* is True, get the current row value and store it. :return: The remote row. """ table_method = table + '/get' if cache and refresh: result = self.cache_call_refresh(table_method, row_id) elif cache and not refresh: result = self.cache_call(table_method, row_id) else: result = self.call(table_method, row_id) return result def vte_child_routine(config): """ This is the method which is executed within the child process spawned by VTE. It expects additional values to be set in the *config* object so it can initialize a new :py:class:`.KingPhisherRPCClient` instance. It will then drop into an interpreter where the user may directly interact with the rpc object. :param str config: A JSON encoded client configuration. """ config = json.loads(config) try: import readline import rlcompleter except ImportError: pass else: readline.parse_and_bind('tab: complete') plugins_directory = find.find_data_directory('plugins') if plugins_directory: sys.path.append(plugins_directory) rpc = KingPhisherRPCClient(**config['rpc_data']) logged_in = False for _ in range(0, 3): rpc.password = getpass.getpass("{0}@{1}'s password: ".format(rpc.username, rpc.host)) try: logged_in = rpc('ping') except AdvancedHTTPServer.AdvancedHTTPServerRPCError: print('Permission denied, please try again.') continue else: break if not logged_in: return banner = "Python {0} on {1}".format(sys.version, sys.platform) print(banner) information = "Campaign Name: '{0}' ID: {1}".format(config['campaign_name'], config['campaign_id']) print(information) console_vars = { 'CAMPAIGN_NAME': config['campaign_name'], 'CAMPAIGN_ID': config['campaign_id'], 'os': os, 'rpc': rpc, 'sys': sys } export_to_builtins = ['CAMPAIGN_NAME', 'CAMPAIGN_ID', 'rpc'] console = code.InteractiveConsole(console_vars) for var in export_to_builtins: console.push("__builtins__['{0}'] = {0}".format(var)) console.interact('The \'rpc\' object holds the connected KingPhisherRPCClient instance') return
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1022, 316, 63, 838, 2453, 281, 15, 1258, 15, 1258, 63, 4354, 14, 647, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 259, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 259, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 314, 2199, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 259, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 221, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 221, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 221, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 221, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 221, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 221, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 221, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 221, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 221, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 221, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 199, 646, 1233, 199, 646, 18354, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1022, 316, 63, 838, 2453, 281, 492, 2342, 199, 504, 1022, 316, 63, 838, 2453, 281, 14, 11470, 63, 7522, 492, 32445, 14938, 199, 893, 26, 199, 198, 646, 26635, 199, 198, 1989, 63, 1328, 1389, 275, 715, 199, 198, 624, 26625, 314, 520, 647, 26, 1494, 1705, 1328, 1389, 64, 859, 365, 2808, 503, 440, 1041, 199, 2590, 3545, 26, 199, 198, 1989, 63, 1328, 1389, 275, 756, 199, 199, 533, 1804, 316, 48, 866, 2523, 18612, 2571, 864, 8, 23613, 14938, 14, 23613, 14938, 18612, 2571, 864, 16138, 304, 199, 198, 624, 199, 198, 1918, 2446, 11785, 909, 367, 13882, 1958, 543, 314, 1804, 316, 510, 866, 2523, 7146, 199, 198, 1883, 11785, 14, 199, 198, 624, 199, 198, 318, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 507, 198, 277, 14, 2921, 275, 2050, 14, 5572, 360, 43, 316, 48, 866, 2523, 14, 3041, 14, 8171, 358, 507, 198, 4792, 8, 43, 316, 48, 866, 2523, 18612, 2571, 864, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 507, 198, 692, 965, 63, 1328, 1389, 26, 686, 198, 8349, 275, 283, 3008, 15, 1188, 13, 1389, 7, 507, 198, 2836, 26, 686, 198, 8349, 275, 283, 3008, 15, 1001, 7, 507, 198, 277, 14, 409, 63, 8349, 8, 8349, 9, 421, 198, 318, 3982, 63, 1224, 8, 277, 12, 1817, 12, 627, 589, 304, 507, 198, 624, 507, 198, 1002, 282, 3982, 1817, 687, 314, 1654, 701, 6358, 314, 3211, 11785, 507, 198, 765, 14, 2742, 198, 26, 635, 620, 1817, 26, 710, 1817, 536, 370, 8044, 14, 507, 198, 26, 1107, 26, 437, 4306, 1314, 14801, 4730, 315, 11196, 14, 507, 198, 624, 507, 198, 1224, 63, 765, 275, 1817, 435, 1994, 1345, 7, 507, 198, 1606, 275, 378, 507, 198, 589, 275, 769, 8, 589, 9, 507, 198, 589, 14, 740, 8, 1606, 9, 507, 198, 2604, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 627, 589, 9, 507, 198, 2604, 63, 1267, 275, 822, 8, 2604, 503, 4074, 507, 198, 6710, 2058, 26, 686, 198, 3406, 275, 2058, 459, 3406, 418, 686, 198, 509, 1962, 315, 2058, 459, 3838, 2565, 1585, 198, 11481, 1211, 8, 3065, 8, 3406, 12, 1962, 430, 686, 198, 692, 822, 8, 2604, 9, 665, 2058, 63, 1267, 26, 1585, 198, 4785, 686, 198, 589, 1988, 17, 61, 847, 413, 686, 198, 2604, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 627, 589, 9, 421, 198, 318, 3982, 63, 1224, 63, 1143, 8, 277, 12, 1817, 12, 1962, 63, 344, 12, 2581, 29, 797, 12, 9236, 29, 797, 304, 507, 198, 624, 507, 198, 1002, 282, 2488, 1962, 701, 652, 1159, 1305, 12, 14190, 2581, 316, 652, 14, 2742, 198, 26, 635, 620, 1817, 26, 710, 1817, 315, 1314, 314, 1962, 3495, 14, 507, 198, 26, 635, 1962, 63, 344, 26, 710, 574, 402, 314, 1962, 1159, 1305, 2763, 14, 507, 198, 26, 635, 2155, 2581, 26, 7480, 370, 675, 314, 2581, 367, 642, 1962, 14, 507, 198, 26, 635, 2155, 9236, 26, 982, 627, 1637, 10, 365, 715, 12, 664, 314, 1453, 1962, 574, 436, 3877, 652, 14, 507, 198, 26, 1107, 26, 710, 3982, 1962, 14, 507, 198, 624, 507, 198, 1224, 63, 765, 275, 1817, 435, 1994, 362, 7, 507, 198, 692, 2581, 436, 9236, 26, 686, 198, 1099, 275, 291, 14, 1637, 63, 1250, 63, 6635, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 4164, 2581, 436, 440, 9236, 26, 686, 198, 1099, 275, 291, 14, 1637, 63, 1250, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 2836, 26, 686, 198, 1099, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 1107, 754, 199, 199, 318, 373, 266, 63, 1739, 63, 17765, 8, 888, 304, 199, 198 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1022, 316, 63, 838, 2453, 281, 15, 1258, 15, 1258, 63, 4354, 14, 647, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 259, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 259, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 314, 2199, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 259, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 221, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 221, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 221, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 221, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 221, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 221, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 221, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 221, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 221, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 221, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 199, 646, 1233, 199, 646, 18354, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1022, 316, 63, 838, 2453, 281, 492, 2342, 199, 504, 1022, 316, 63, 838, 2453, 281, 14, 11470, 63, 7522, 492, 32445, 14938, 199, 893, 26, 199, 198, 646, 26635, 199, 198, 1989, 63, 1328, 1389, 275, 715, 199, 198, 624, 26625, 314, 520, 647, 26, 1494, 1705, 1328, 1389, 64, 859, 365, 2808, 503, 440, 1041, 199, 2590, 3545, 26, 199, 198, 1989, 63, 1328, 1389, 275, 756, 199, 199, 533, 1804, 316, 48, 866, 2523, 18612, 2571, 864, 8, 23613, 14938, 14, 23613, 14938, 18612, 2571, 864, 16138, 304, 199, 198, 624, 199, 198, 1918, 2446, 11785, 909, 367, 13882, 1958, 543, 314, 1804, 316, 510, 866, 2523, 7146, 199, 198, 1883, 11785, 14, 199, 198, 624, 199, 198, 318, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 507, 198, 277, 14, 2921, 275, 2050, 14, 5572, 360, 43, 316, 48, 866, 2523, 14, 3041, 14, 8171, 358, 507, 198, 4792, 8, 43, 316, 48, 866, 2523, 18612, 2571, 864, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 507, 198, 692, 965, 63, 1328, 1389, 26, 686, 198, 8349, 275, 283, 3008, 15, 1188, 13, 1389, 7, 507, 198, 2836, 26, 686, 198, 8349, 275, 283, 3008, 15, 1001, 7, 507, 198, 277, 14, 409, 63, 8349, 8, 8349, 9, 421, 198, 318, 3982, 63, 1224, 8, 277, 12, 1817, 12, 627, 589, 304, 507, 198, 624, 507, 198, 1002, 282, 3982, 1817, 687, 314, 1654, 701, 6358, 314, 3211, 11785, 507, 198, 765, 14, 2742, 198, 26, 635, 620, 1817, 26, 710, 1817, 536, 370, 8044, 14, 507, 198, 26, 1107, 26, 437, 4306, 1314, 14801, 4730, 315, 11196, 14, 507, 198, 624, 507, 198, 1224, 63, 765, 275, 1817, 435, 1994, 1345, 7, 507, 198, 1606, 275, 378, 507, 198, 589, 275, 769, 8, 589, 9, 507, 198, 589, 14, 740, 8, 1606, 9, 507, 198, 2604, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 627, 589, 9, 507, 198, 2604, 63, 1267, 275, 822, 8, 2604, 503, 4074, 507, 198, 6710, 2058, 26, 686, 198, 3406, 275, 2058, 459, 3406, 418, 686, 198, 509, 1962, 315, 2058, 459, 3838, 2565, 1585, 198, 11481, 1211, 8, 3065, 8, 3406, 12, 1962, 430, 686, 198, 692, 822, 8, 2604, 9, 665, 2058, 63, 1267, 26, 1585, 198, 4785, 686, 198, 589, 1988, 17, 61, 847, 413, 686, 198, 2604, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 627, 589, 9, 421, 198, 318, 3982, 63, 1224, 63, 1143, 8, 277, 12, 1817, 12, 1962, 63, 344, 12, 2581, 29, 797, 12, 9236, 29, 797, 304, 507, 198, 624, 507, 198, 1002, 282, 2488, 1962, 701, 652, 1159, 1305, 12, 14190, 2581, 316, 652, 14, 2742, 198, 26, 635, 620, 1817, 26, 710, 1817, 315, 1314, 314, 1962, 3495, 14, 507, 198, 26, 635, 1962, 63, 344, 26, 710, 574, 402, 314, 1962, 1159, 1305, 2763, 14, 507, 198, 26, 635, 2155, 2581, 26, 7480, 370, 675, 314, 2581, 367, 642, 1962, 14, 507, 198, 26, 635, 2155, 9236, 26, 982, 627, 1637, 10, 365, 715, 12, 664, 314, 1453, 1962, 574, 436, 3877, 652, 14, 507, 198, 26, 1107, 26, 710, 3982, 1962, 14, 507, 198, 624, 507, 198, 1224, 63, 765, 275, 1817, 435, 1994, 362, 7, 507, 198, 692, 2581, 436, 9236, 26, 686, 198, 1099, 275, 291, 14, 1637, 63, 1250, 63, 6635, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 4164, 2581, 436, 440, 9236, 26, 686, 198, 1099, 275, 291, 14, 1637, 63, 1250, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 2836, 26, 686, 198, 1099, 275, 291, 14, 1250, 8, 1224, 63, 765, 12, 1962, 63, 344, 9, 507, 198, 1107, 754, 199, 199, 318, 373, 266, 63, 1739, 63, 17765, 8, 888, 304, 199, 198, 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,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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 ]
sxjscience/tvm
rust/tvm-graph-rt/tests/test_tvm_basic/src/build_test_lib.py
5
1356
#!/usr/bin/env python3 # 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. """Prepares a simple TVM library for testing.""" from os import path as osp import sys import tvm from tvm import te def main(): n = te.var("n") A = te.placeholder((n,), name="A") B = te.placeholder((n,), name="B") C = te.compute(A.shape, lambda *i: A(*i) + B(*i), name="C") s = tvm.te.create_schedule(C.op) s[C].parallel(s[C].op.axis[0]) print(tvm.lower(s, [A, B, C], simple_mode=True)) tvm.build(s, [A, B, C], "llvm --system-lib").save(osp.join(sys.argv[1], "test.o")) if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 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, 199, 624, 2398, 27749, 282, 3486, 377, 6849, 3555, 367, 5343, 1041, 199, 199, 504, 747, 492, 931, 465, 312, 681, 199, 646, 984, 199, 199, 646, 31385, 199, 504, 31385, 492, 1565, 421, 199, 318, 2446, 837, 272, 302, 275, 1565, 14, 1391, 480, 78, 531, 272, 437, 275, 1565, 14, 6199, 1332, 78, 4706, 536, 628, 33, 531, 272, 699, 275, 1565, 14, 6199, 1332, 78, 4706, 536, 628, 34, 531, 272, 445, 275, 1565, 14, 3357, 8, 33, 14, 1392, 12, 2400, 627, 73, 26, 437, 2031, 73, 9, 435, 699, 2031, 73, 395, 536, 628, 35, 531, 272, 308, 275, 31385, 14, 266, 14, 981, 63, 7211, 8, 35, 14, 411, 9, 272, 308, 59, 35, 1055, 11887, 8, 83, 59, 35, 1055, 411, 14, 3127, 59, 16, 566, 272, 870, 8, 84, 2611, 14, 2325, 8, 83, 12, 359, 33, 12, 699, 12, 445, 467, 3486, 63, 632, 29, 549, 430, 272, 31385, 14, 1506, 8, 83, 12, 359, 33, 12, 699, 12, 445, 467, 298, 29257, 1553, 2253, 13, 773, 3471, 2117, 8, 79, 681, 14, 904, 8, 1274, 14, 3020, 59, 17, 467, 298, 396, 14, 79, 2237, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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, 199, 624, 2398, 27749, 282, 3486, 377, 6849, 3555, 367, 5343, 1041, 199, 199, 504, 747, 492, 931, 465, 312, 681, 199, 646, 984, 199, 199, 646, 31385, 199, 504, 31385, 492, 1565, 421, 199, 318, 2446, 837, 272, 302, 275, 1565, 14, 1391, 480, 78, 531, 272, 437, 275, 1565, 14, 6199, 1332, 78, 4706, 536, 628, 33, 531, 272, 699, 275, 1565, 14, 6199, 1332, 78, 4706, 536, 628, 34, 531, 272, 445, 275, 1565, 14, 3357, 8, 33, 14, 1392, 12, 2400, 627, 73, 26, 437, 2031, 73, 9, 435, 699, 2031, 73, 395, 536, 628, 35, 531, 272, 308, 275, 31385, 14, 266, 14, 981, 63, 7211, 8, 35, 14, 411, 9, 272, 308, 59, 35, 1055, 11887, 8, 83, 59, 35, 1055, 411, 14, 3127, 59, 16, 566, 272, 870, 8, 84, 2611, 14, 2325, 8, 83, 12, 359, 33, 12, 699, 12, 445, 467, 3486, 63, 632, 29, 549, 430, 272, 31385, 14, 1506, 8, 83, 12, 359, 33, 12, 699, 12, 445, 467, 298, 29257, 1553, 2253, 13, 773, 3471, 2117, 8, 79, 681, 14, 904, 8, 1274, 14, 3020, 59, 17, 467, 298, 396, 14, 79, 2237, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
Pluto-tv/chromium-crosswalk
chromecast/tools/build/chromecast_repack_locales.py
24
4485
#!/usr/bin/env python # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Helper script to repack paks for a list of locales. Gyp doesn't have any built-in looping capability, so this just provides a way to loop over a list of locales when repacking pak files, thus avoiding a proliferation of mostly duplicate, cut-n-paste gyp actions. """ import optparse import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'tools', 'grit')) from grit.format import data_pack # Some build paths defined by gyp. GRIT_DIR = None INT_DIR = None CHROMECAST_BRANDING = None class Usage(Exception): def __init__(self, msg): self.msg = msg def calc_output(locale): """Determine the file that will be generated for the given locale.""" #e.g. '<(INTERMEDIATE_DIR)/repack/da.pak', # For Fake Bidi, generate it at a fixed path so that tests can safely # reference it. if locale == 'fake-bidi': return '%s/%s.pak' % (INT_DIR, locale) return os.path.join(INT_DIR, locale + '.pak') def calc_inputs(locale): """Determine the files that need processing for the given locale.""" inputs = [] if CHROMECAST_BRANDING != 'public': inputs.append(os.path.join(GRIT_DIR, 'app_strings_%s.pak' % locale)) inputs.append(os.path.join(GRIT_DIR, 'chromecast_settings_%s.pak' % locale)) return inputs def list_outputs(locales): """Returns the names of files that will be generated for the given locales. This is to provide gyp the list of output files, so build targets can properly track what needs to be built. """ outputs = [] for locale in locales: outputs.append(calc_output(locale)) # Quote each element so filename spaces don't mess up gyp's attempt to parse # it into a list. return " ".join(['"%s"' % x for x in outputs]) def list_inputs(locales): """Returns the names of files that will be processed for the given locales. This is to provide gyp the list of input files, so build targets can properly track their prerequisites. """ inputs = [] for locale in locales: inputs += calc_inputs(locale) # Quote each element so filename spaces don't mess up gyp's attempt to parse # it into a list. return " ".join(['"%s"' % x for x in inputs]) def repack_locales(locales): """ Loop over and repack the given locales.""" for locale in locales: inputs = [] inputs += calc_inputs(locale) output = calc_output(locale) data_pack.DataPack.RePack(output, inputs) def DoMain(argv): global CHROMECAST_BRANDING global GRIT_DIR global INT_DIR parser = optparse.OptionParser("usage: %prog [options] locales") parser.add_option("-i", action="store_true", dest="inputs", default=False, help="Print the expected input file list, then exit.") parser.add_option("-o", action="store_true", dest="outputs", default=False, help="Print the expected output file list, then exit.") parser.add_option("-g", action="store", dest="grit_dir", help="GRIT build files output directory.") parser.add_option("-x", action="store", dest="int_dir", help="Intermediate build files output directory.") parser.add_option("-b", action="store", dest="chromecast_branding", help="Chromecast branding " + "('public', 'internal' or 'google').") options, locales = parser.parse_args(argv) if not locales: parser.error('Please specificy at least one locale to process.\n') print_inputs = options.inputs print_outputs = options.outputs GRIT_DIR = options.grit_dir INT_DIR = options.int_dir CHROMECAST_BRANDING = options.chromecast_branding if (CHROMECAST_BRANDING != 'public' and CHROMECAST_BRANDING != 'internal' and CHROMECAST_BRANDING != 'google'): parser.error('Chromecast branding (-b) must be ' + '"public", "internal" or "google".\n') if not (GRIT_DIR and INT_DIR): parser.error('Please specify all of "-g" and "-x".\n') if print_inputs and print_outputs: parser.error('Please specify only one of "-i" or "-o".\n') if print_inputs: return list_inputs(locales) if print_outputs: return list_outputs(locales) return repack_locales(locales) if __name__ == '__main__': results = DoMain(sys.argv[1:]) if results: print results
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6927, 710, 12051, 6642, 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, 4433, 2884, 370, 295, 1389, 691, 6080, 367, 282, 769, 402, 24847, 14, 199, 199, 13899, 3181, 1133, 1172, 1263, 6137, 13, 262, 4438, 316, 19854, 12, 880, 642, 2951, 6571, 282, 4340, 370, 199, 3813, 1806, 282, 769, 402, 24847, 1380, 295, 1389, 316, 691, 75, 1584, 12, 12850, 5126, 316, 282, 199, 496, 853, 281, 425, 402, 19762, 9250, 12, 10415, 13, 78, 13, 16586, 4902, 5445, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 2490, 283, 2537, 297, 283, 7928, 84, 1333, 199, 504, 486, 11133, 14, 908, 492, 666, 63, 1389, 199, 199, 3, 6601, 1900, 3792, 3247, 701, 4902, 14, 199, 3975, 649, 63, 3022, 275, 488, 199, 2919, 63, 3022, 275, 488, 199, 1244, 31364, 18898, 63, 7184, 3649, 1206, 275, 488, 199, 199, 533, 11028, 8, 1726, 304, 523, 347, 636, 826, 721, 277, 12, 1499, 304, 272, 291, 14, 1328, 275, 1499, 421, 199, 318, 12831, 63, 1199, 8, 5508, 304, 523, 408, 21767, 314, 570, 626, 911, 506, 4046, 367, 314, 1627, 5867, 1041, 523, 327, 69, 14, 71, 14, 2650, 8, 23227, 63, 3022, 2447, 264, 1389, 15, 983, 14, 22460, 297, 523, 327, 2104, 7777, 699, 9897, 12, 3550, 652, 737, 282, 6317, 931, 880, 626, 2295, 883, 19353, 523, 327, 3659, 652, 14, 523, 340, 5867, 508, 283, 3183, 13, 21555, 356, 272, 372, 1543, 83, 3149, 83, 14, 22460, 7, 450, 334, 2919, 63, 3022, 12, 5867, 9, 523, 372, 747, 14, 515, 14, 904, 8, 2919, 63, 3022, 12, 5867, 435, 1987, 22460, 358, 421, 199, 318, 12831, 63, 3711, 8, 5508, 304, 523, 408, 21767, 314, 1584, 626, 1929, 6661, 367, 314, 1627, 5867, 1041, 523, 4153, 275, 942, 523, 340, 6624, 31364, 18898, 63, 7184, 3649, 1206, 1137, 283, 3455, 356, 272, 4153, 14, 740, 8, 736, 14, 515, 14, 904, 8, 3975, 649, 63, 3022, 12, 283, 571, 63, 5465, 4970, 83, 14, 22460, 7, 450, 5867, 430, 523, 4153, 14, 740, 8, 736, 14, 515, 14, 904, 8, 3975, 649, 63, 3022, 12, 283, 9887, 2931, 63, 1751, 4970, 83, 14, 22460, 7, 450, 5867, 430, 523, 372, 4153, 421, 199, 318, 769, 63, 4467, 8, 24763, 304, 523, 408, 3407, 314, 1561, 402, 1584, 626, 911, 506, 4046, 367, 314, 1627, 24847, 14, 819, 961, 365, 370, 5647, 4902, 314, 769, 402, 1072, 1584, 12, 880, 1900, 4545, 883, 523, 7684, 4426, 4052, 4839, 370, 506, 6137, 14, 523, 408, 523, 4704, 275, 942, 523, 367, 5867, 315, 24847, 26, 272, 4704, 14, 740, 8, 8104, 63, 1199, 8, 5508, 430, 523, 327, 29335, 1924, 1819, 880, 1788, 7883, 2793, 1133, 15634, 1536, 4902, 1159, 7427, 370, 2198, 523, 327, 652, 1901, 282, 769, 14, 523, 372, 298, 3680, 904, 2941, 6808, 83, 4507, 450, 671, 367, 671, 315, 4704, 566, 421, 199, 318, 769, 63, 3711, 8, 24763, 304, 523, 408, 3407, 314, 1561, 402, 1584, 626, 911, 506, 7686, 367, 314, 1627, 24847, 14, 819, 961, 365, 370, 5647, 4902, 314, 769, 402, 1324, 1584, 12, 880, 1900, 4545, 883, 7684, 523, 4426, 3932, 876, 30140, 14, 523, 408, 523, 4153, 275, 942, 523, 367, 5867, 315, 24847, 26, 272, 4153, 847, 12831, 63, 3711, 8, 5508, 9, 523, 327, 29335, 1924, 1819, 880, 1788, 7883, 2793, 1133, 15634, 1536, 4902, 1159, 7427, 370, 2198, 523, 327, 652, 1901, 282, 769, 14, 523, 372, 298, 3680, 904, 2941, 6808, 83, 4507, 450, 671, 367, 671, 315, 4153, 566, 421, 199, 318, 295, 1389, 63, 24763, 8, 24763, 304, 523, 408, 18175, 1806, 436, 295, 1389, 314, 1627, 24847, 1041, 523, 367, 5867, 315, 24847, 26, 272, 4153, 275, 942, 272, 4153, 847, 12831, 63, 3711, 8, 5508, 9, 272, 1072, 275, 12831, 63, 1199, 8, 5508, 9, 272, 666, 63, 1389, 14, 1451, 2305, 14, 497, 2305, 8, 1199, 12, 4153, 9, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 2288, 6624, 31364, 18898, 63, 7184, 3649, 1206, 523, 2288, 21772, 649, 63, 3022, 523, 2288, 16429, 63, 3022, 819, 1798, 275, 8691, 14, 14553, 480, 3807, 26, 450, 6595, 359, 1419, 61, 24847, 531, 523, 1798, 14, 525, 63, 1422, 6096, 73, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 3711, 401, 849, 29, 797, 12, 490, 1720, 628, 5375, 314, 1420, 1324, 570, 769, 12, 2066, 4458, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 79, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 4467, 401, 849, 29, 797, 12, 490, 1720, 628, 5375, 314, 1420, 1072, 570, 769, 12, 2066, 4458, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 71, 401, 1595, 628, 1617, 401, 2053, 628, 7928, 84, 63, 694, 401, 490, 1720, 628, 3975, 649, 1900, 1584, 1072, 2082, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 88, 401, 1595, 628, 1617, 401, 2053, 628, 442, 63, 694, 401, 490, 1720, 628, 2620, 5050, 1900, 1584, 1072, 2082, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 66, 401, 1595, 628, 1617, 401, 2053, 628, 9887, 2931, 63, 19026, 316, 401, 490, 1720, 628, 18083, 2931, 32159, 316, 298, 435, 586, 16111, 3455, 297, 283, 4672, 7, 503, 283, 3098, 1959, 531, 523, 1511, 12, 24847, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 24847, 26, 272, 1798, 14, 705, 360, 8254, 1106, 329, 1480, 737, 5210, 1373, 5867, 370, 2112, 3134, 78, 358, 819, 870, 63, 3711, 275, 1511, 14, 3711, 523, 870, 63, 4467, 275, 1511, 14, 4467, 523, 21772, 649, 63, 3022, 275, 1511, 14, 7928, 84, 63, 694, 523, 16429, 63, 3022, 275, 1511, 14, 442, 63, 694, 523, 6624, 31364, 18898, 63, 7184, 3649, 1206, 275, 1511, 14, 9887 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6927, 710, 12051, 6642, 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, 4433, 2884, 370, 295, 1389, 691, 6080, 367, 282, 769, 402, 24847, 14, 199, 199, 13899, 3181, 1133, 1172, 1263, 6137, 13, 262, 4438, 316, 19854, 12, 880, 642, 2951, 6571, 282, 4340, 370, 199, 3813, 1806, 282, 769, 402, 24847, 1380, 295, 1389, 316, 691, 75, 1584, 12, 12850, 5126, 316, 282, 199, 496, 853, 281, 425, 402, 19762, 9250, 12, 10415, 13, 78, 13, 16586, 4902, 5445, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 19155, 19155, 19155, 2490, 283, 2537, 297, 283, 7928, 84, 1333, 199, 504, 486, 11133, 14, 908, 492, 666, 63, 1389, 199, 199, 3, 6601, 1900, 3792, 3247, 701, 4902, 14, 199, 3975, 649, 63, 3022, 275, 488, 199, 2919, 63, 3022, 275, 488, 199, 1244, 31364, 18898, 63, 7184, 3649, 1206, 275, 488, 199, 199, 533, 11028, 8, 1726, 304, 523, 347, 636, 826, 721, 277, 12, 1499, 304, 272, 291, 14, 1328, 275, 1499, 421, 199, 318, 12831, 63, 1199, 8, 5508, 304, 523, 408, 21767, 314, 570, 626, 911, 506, 4046, 367, 314, 1627, 5867, 1041, 523, 327, 69, 14, 71, 14, 2650, 8, 23227, 63, 3022, 2447, 264, 1389, 15, 983, 14, 22460, 297, 523, 327, 2104, 7777, 699, 9897, 12, 3550, 652, 737, 282, 6317, 931, 880, 626, 2295, 883, 19353, 523, 327, 3659, 652, 14, 523, 340, 5867, 508, 283, 3183, 13, 21555, 356, 272, 372, 1543, 83, 3149, 83, 14, 22460, 7, 450, 334, 2919, 63, 3022, 12, 5867, 9, 523, 372, 747, 14, 515, 14, 904, 8, 2919, 63, 3022, 12, 5867, 435, 1987, 22460, 358, 421, 199, 318, 12831, 63, 3711, 8, 5508, 304, 523, 408, 21767, 314, 1584, 626, 1929, 6661, 367, 314, 1627, 5867, 1041, 523, 4153, 275, 942, 523, 340, 6624, 31364, 18898, 63, 7184, 3649, 1206, 1137, 283, 3455, 356, 272, 4153, 14, 740, 8, 736, 14, 515, 14, 904, 8, 3975, 649, 63, 3022, 12, 283, 571, 63, 5465, 4970, 83, 14, 22460, 7, 450, 5867, 430, 523, 4153, 14, 740, 8, 736, 14, 515, 14, 904, 8, 3975, 649, 63, 3022, 12, 283, 9887, 2931, 63, 1751, 4970, 83, 14, 22460, 7, 450, 5867, 430, 523, 372, 4153, 421, 199, 318, 769, 63, 4467, 8, 24763, 304, 523, 408, 3407, 314, 1561, 402, 1584, 626, 911, 506, 4046, 367, 314, 1627, 24847, 14, 819, 961, 365, 370, 5647, 4902, 314, 769, 402, 1072, 1584, 12, 880, 1900, 4545, 883, 523, 7684, 4426, 4052, 4839, 370, 506, 6137, 14, 523, 408, 523, 4704, 275, 942, 523, 367, 5867, 315, 24847, 26, 272, 4704, 14, 740, 8, 8104, 63, 1199, 8, 5508, 430, 523, 327, 29335, 1924, 1819, 880, 1788, 7883, 2793, 1133, 15634, 1536, 4902, 1159, 7427, 370, 2198, 523, 327, 652, 1901, 282, 769, 14, 523, 372, 298, 3680, 904, 2941, 6808, 83, 4507, 450, 671, 367, 671, 315, 4704, 566, 421, 199, 318, 769, 63, 3711, 8, 24763, 304, 523, 408, 3407, 314, 1561, 402, 1584, 626, 911, 506, 7686, 367, 314, 1627, 24847, 14, 819, 961, 365, 370, 5647, 4902, 314, 769, 402, 1324, 1584, 12, 880, 1900, 4545, 883, 7684, 523, 4426, 3932, 876, 30140, 14, 523, 408, 523, 4153, 275, 942, 523, 367, 5867, 315, 24847, 26, 272, 4153, 847, 12831, 63, 3711, 8, 5508, 9, 523, 327, 29335, 1924, 1819, 880, 1788, 7883, 2793, 1133, 15634, 1536, 4902, 1159, 7427, 370, 2198, 523, 327, 652, 1901, 282, 769, 14, 523, 372, 298, 3680, 904, 2941, 6808, 83, 4507, 450, 671, 367, 671, 315, 4153, 566, 421, 199, 318, 295, 1389, 63, 24763, 8, 24763, 304, 523, 408, 18175, 1806, 436, 295, 1389, 314, 1627, 24847, 1041, 523, 367, 5867, 315, 24847, 26, 272, 4153, 275, 942, 272, 4153, 847, 12831, 63, 3711, 8, 5508, 9, 272, 1072, 275, 12831, 63, 1199, 8, 5508, 9, 272, 666, 63, 1389, 14, 1451, 2305, 14, 497, 2305, 8, 1199, 12, 4153, 9, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 2288, 6624, 31364, 18898, 63, 7184, 3649, 1206, 523, 2288, 21772, 649, 63, 3022, 523, 2288, 16429, 63, 3022, 819, 1798, 275, 8691, 14, 14553, 480, 3807, 26, 450, 6595, 359, 1419, 61, 24847, 531, 523, 1798, 14, 525, 63, 1422, 6096, 73, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 3711, 401, 849, 29, 797, 12, 490, 1720, 628, 5375, 314, 1420, 1324, 570, 769, 12, 2066, 4458, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 79, 401, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 4467, 401, 849, 29, 797, 12, 490, 1720, 628, 5375, 314, 1420, 1072, 570, 769, 12, 2066, 4458, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 71, 401, 1595, 628, 1617, 401, 2053, 628, 7928, 84, 63, 694, 401, 490, 1720, 628, 3975, 649, 1900, 1584, 1072, 2082, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 88, 401, 1595, 628, 1617, 401, 2053, 628, 442, 63, 694, 401, 490, 1720, 628, 2620, 5050, 1900, 1584, 1072, 2082, 2685, 523, 1798, 14, 525, 63, 1422, 6096, 66, 401, 1595, 628, 1617, 401, 2053, 628, 9887, 2931, 63, 19026, 316, 401, 490, 1720, 628, 18083, 2931, 32159, 316, 298, 435, 586, 16111, 3455, 297, 283, 4672, 7, 503, 283, 3098, 1959, 531, 523, 1511, 12, 24847, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 24847, 26, 272, 1798, 14, 705, 360, 8254, 1106, 329, 1480, 737, 5210, 1373, 5867, 370, 2112, 3134, 78, 358, 819, 870, 63, 3711, 275, 1511, 14, 3711, 523, 870, 63, 4467, 275,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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 ]
crepererum/analysis-preservation.cern.ch
invenio_data/base/bundles.py
1
1116
# -*- coding: utf-8 -*- # # This file is part of CERN Analysis Preservation Framework. # Copyright (C) 2014, 2015 CERN. # # CERN Analysis Preservation Framework 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. # # CERN Analysis Preservation Framework 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 software; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02D111-1307, USA. """Data-demo bundles.""" from invenio.ext.assets import Bundle from invenio.base.bundles import styles as _styles css = Bundle( "css/style.css", output="datademo.css", weight=1, bower = { "open-sans-fontface": "latest", } )
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 24354, 21916, 5543, 8213, 22545, 14, 199, 3, 1898, 334, 35, 9, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 24354, 21916, 5543, 8213, 22545, 365, 2867, 2032, 27, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24354, 21916, 5543, 8213, 22545, 365, 1854, 315, 314, 3661, 626, 199, 3, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 199, 3, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 199, 3, 3104, 14, 221, 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, 2032, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 199, 3, 12497, 36, 6673, 13, 13421, 12, 8217, 14, 199, 199, 624, 1451, 13, 8768, 27206, 1041, 199, 199, 504, 13640, 14, 832, 14, 12186, 492, 29311, 199, 199, 504, 13640, 14, 1095, 14, 66, 18793, 492, 15725, 465, 485, 12955, 199, 199, 3919, 275, 29311, 8, 523, 298, 3919, 15, 2487, 14, 3919, 401, 523, 1072, 628, 576, 8768, 14, 3919, 401, 523, 5401, 29, 17, 12, 523, 330, 3891, 275, 469, 272, 298, 1490, 13, 26052, 13, 4246, 1409, 582, 298, 7410, 401, 523, 789, 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, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 24354, 21916, 5543, 8213, 22545, 14, 199, 3, 1898, 334, 35, 9, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 24354, 21916, 5543, 8213, 22545, 365, 2867, 2032, 27, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24354, 21916, 5543, 8213, 22545, 365, 1854, 315, 314, 3661, 626, 199, 3, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 199, 3, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 199, 3, 3104, 14, 221, 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, 2032, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 199, 3, 12497, 36, 6673, 13, 13421, 12, 8217, 14, 199, 199, 624, 1451, 13, 8768, 27206, 1041, 199, 199, 504, 13640, 14, 832, 14, 12186, 492, 29311, 199, 199, 504, 13640, 14, 1095, 14, 66, 18793, 492, 15725, 465, 485, 12955, 199, 199, 3919, 275, 29311, 8, 523, 298, 3919, 15, 2487, 14, 3919, 401, 523, 1072, 628, 576, 8768, 14, 3919, 401, 523, 5401, 29, 17, 12, 523, 330, 3891, 275, 469, 272, 298, 1490, 13, 26052, 13, 4246, 1409, 582, 298, 7410, 401, 523, 789, 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, 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,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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 ]
ctb/pygr
pygr/nlmsa_utils.py
1
17639
import classutil, logger import os, types class NLMSASeqList(list): def __init__(self, nlmsaSeqDict): list.__init__(self) self.nlmsaSeqDict = nlmsaSeqDict def __getitem__(self, nlmsaID): 'return NLMSASequence for a given nlmsa_id' try: return list.__getitem__(self,nlmsaID) except IndexError: seqID,nsID = self.nlmsaSeqDict.IDdict[str(nlmsaID)] return list.__getitem__(self,nsID) def getSeq(self, nlmsaID): 'return seq for a given nlmsa_id' seqID,nsID = self.nlmsaSeqDict.IDdict[str(nlmsaID)] return self.nlmsaSeqDict.nlmsa.seqDict[seqID] def getSeqID(self, nlmsaID): 'return seqID for a given nlmsa_id' seqID,nsID=self.nlmsaSeqDict.IDdict[str(nlmsaID)] return seqID def is_lpo(self, id): if id >= len(self): return False ns = self[id] if ns.is_lpo: return True else: return False def nextID(self): return len(self) class EmptySliceError(KeyError): pass class EmptyAlignmentError(ValueError): pass class EmptySlice: 'Empty slice for use by NLMSASlice' def __init__(self, seq): self.seq = seq def edges(self, *args, **kwargs): return [] def items(self, **kwargs): return [] def iteritems(self, **kwargs): return iter([]) def keys(self, **kwargs): return [] def __iter__(self): return iter([]) def __getitem__(self, k): raise KeyError def __len__(self): return 0 def matchIntervals(self, seq=None): return [] def findSeqEnds(self, seq): raise KeyError('seq not aligned in this interval') def generateSeqEnds(self): return [] def groupByIntervals(self, **kwargs): return {} def groupBySequences(self, **kwargs): return [] def split(self, **kwargs): return [] def regions(self, **kwargs): return [] def __cmp__(self, other): return cmp(self.seq, other.seq) def rawIvals(self): return [] class NLMSASeqDict(dict): 'index sequences by pathForward, and use list to keep reverse mapping' def __init__(self, nlmsa, filename, mode, maxID=1000000, idDictClass=None): dict.__init__(self) self.seqlist = NLMSASeqList(self) self.maxID = maxID self.nlmsa = nlmsa self.filename = filename if mode == 'memory': # just use python dictionary idDictClass = dict elif mode == 'w': # new database mode = 'n' if idDictClass is None: # use persistent id dictionary storage self.seqIDdict = classutil.open_shelve(filename + '.seqIDdict', mode) self.IDdict = classutil.open_shelve(filename + '.idDict', mode) else: # user supplied class for id dictionary storage self.seqIDdict = idDictClass() self.IDdict = idDictClass() def saveSeq(self, seq, nsID= -1, offset=0, nlmsaID=None): 'save mapping of seq to specified (nlmsaID,ns,offset)' if nsID < 0: # let the union figure it out self.nlmsa.currentUnion.__iadd__(seq) return # the union added it for us, no need to do anything if isinstance(seq, types.StringType): id = seq # treat this as fully qualified identifier else: # get the identfier from the seq / database id = self.getSeqID(seq) if nlmsaID is None: # allocate a new unique id nlmsaID = self.nlmsa.nextID() self.seqIDdict[id] = nlmsaID, nsID, offset self.IDdict[str(nlmsaID)] = id,nsID def getIDcoords(self, seq): 'return nlmsaID,start,stop for a given seq ival.' nlmsaID = self.getID(seq) return nlmsaID, seq.start, seq.stop # standard coords def getID(self, seq): 'return nlmsa_id for a given seq' return self[seq][0] def __getitem__(self, seq): 'return nlmsaID,NLMSASequence,offset for a given seq' if not hasattr(seq, 'annotationType'): # don't cache annotations try: # look in our sequence cache return dict.__getitem__(self,seq.pathForward) except AttributeError: raise KeyError('key must be a sequence interval!') except KeyError: pass seqID = self.getSeqID(seq) # use seq id to look up... try: nlmsaID, nsID, offset = self.seqIDdict[seqID] except KeyError: raise KeyError('seq not found in this alignment') v = nlmsaID, self.seqlist[nsID], offset if not hasattr(seq,'annotationType'): # don't cache annotations dict.__setitem__(self, seq.pathForward, v) # cache this result return v def __iter__(self): 'iterate over sequences in this alignment' for seqID in self.seqIDdict: yield self.nlmsa.seqDict[seqID] def getSeqID(self, seq): 'return fully qualified sequence ID for this seq' return (~(self.nlmsa.seqDict))[seq] def __setitem__(self, k, ns): 'save mapping of seq to the specified NLMSASequence' self.seqlist.append(ns) if isinstance(k, types.StringType): dict.__setitem__(self,k,(ns.id,ns,0)) # allow build with a string object elif k is not None: dict.__setitem__(self,k.pathForward,(ns.id,ns,0)) def __iadd__(self, ns): 'add coord system ns to the alignment' self[None] = ns return self # iadd must return self!!! def close(self): 'finalize and close shelve indexes' try: do_close = self.seqIDdict.close except AttributeError: return # our storage doesn't support close(), so nothing to do do_close() # close both shelve objects self.IDdict.close() def reopenReadOnly(self, mode='r'): 'save existing data and reopen in read-only mode' self.close() self.seqIDdict = classutil.open_shelve(self.filename + '.seqIDdict', mode) self.IDdict = classutil.open_shelve(self.filename + '.idDict', mode) def getUnionSlice(self, seq): 'get union coords for this seq interval, adding seq to index if needed' try: id, ns, offset = self[seq] # look up in index except KeyError: self.saveSeq(seq) # add this new sequence to our current union id, ns, offset = self[seq] # look up in index i, start, stop = self.getIDcoords(seq) # make sure to handle annots right if start < 0: # reverse orientation return ns, slice(start - offset, stop - offset) # use union coords else: # forward orientation return ns, slice(start + offset, stop + offset) # use union coords def splitLPOintervals(lpoList, ival, targetIval=None): 'return list of intervals split to different LPOs' if ival.start < 0: # reverse orientation: force into forward ori start= -(ival.stop) stop= -(ival.start) else: # forward orientation start=ival.start stop=ival.stop l = [] i = len(lpoList) - 1 while i >= 0: offset = lpoList[i].offset if offset < stop: # appears to be in this if offset <= start: # fits completely in this LPO if ival.start < 0: # reverse ori myslice = slice(offset - stop, offset - start) else: # forward ori myslice = slice(start - offset, stop - offset) if targetIval is not None: l.append((lpoList[i], myslice, targetIval)) else: l.append((lpoList[i], myslice)) return l # done else: # continues past start of this LPO if ival.start < 0: # reverse ori myslice = slice(offset - stop, 0) else: # forward ori myslice = slice(0, stop - offset) if targetIval is not None: l.append((lpoList[i], myslice, targetIval[offset - start:])) targetIval = targetIval[:offset - start] #remove part already appended else: l.append((lpoList[i], myslice)) stop = offset i -= 1 # continue to previous LPO raise ValueError('empty lpoList or offset not starting at 0? Debug!') class BuildMSASlice(object): def __init__(self,ns,start,stop,id,offset,is_lpo=0,seq=None): self.ns=ns self.start=start self.stop=stop self.id=id self.offset=offset self.is_lpo=is_lpo self.seq=seq def offsetSlice(self,ival): if ival.orientation<0: return slice(ival.start-self.offset,ival.stop-self.offset) else: return slice(ival.start+self.offset,ival.stop+self.offset) def __iadd__(self,targetIval): 'save an alignment edge between self and targetIval' if self.is_lpo: # assign to correct LPO(s) if isinstance(targetIval,types.SliceType): raise ValueError('you attempted to map LPO --> LPO?!?') self.ns.nlmsaLetters.__iadd__(targetIval) splitList=splitLPOintervals(self.ns.nlmsaLetters.lpoList, slice(self.start,self.stop),targetIval) for ns,src,target in splitList: # save intervals to respective LPOs ns[src]=self.ns.nlmsaLetters.seqs.getIDcoords(target) #LPO-->target if self.ns.nlmsaLetters.is_bidirectional: nsu,myslice=self.ns.nlmsaLetters.seqs.getUnionSlice(target) nsu[myslice]=(ns.id,src.start,src.stop) # save target --> LPO else: if isinstance(targetIval,types.SliceType): # target is LPO splitList=splitLPOintervals(self.ns.nlmsaLetters.lpoList, targetIval,self.seq) for ns,target,src in splitList: self.ns[self.offsetSlice(src)]=(ns.id,target.start,target.stop) if self.ns.nlmsaLetters.is_bidirectional: ns[target]=(self.id,src.start,src.stop) # save LPO --> SRC else: # both src and target are normal seqs. use_virtual_lpo!! self.ns.nlmsaLetters.__iadd__(targetIval) self.ns.nlmsaLetters.init_pairwise_mode() ns_lpo=self.ns.nlmsaLetters.seqlist[self.ns.id -1] # our virtual LPO ns_lpo[self.offsetSlice(self.seq)]=self.ns.nlmsaLetters.seqs \ .getIDcoords(targetIval) # save src --> target if self.ns.nlmsaLetters.is_bidirectional: nsu,myslice=self.ns.nlmsaLetters.seqs.getUnionSlice(targetIval) ns_lpo=self.ns.nlmsaLetters.seqlist[nsu.id -1] # our virtual LPO ns_lpo[myslice]=(self.id,self.start,self.stop) # save target --> src return self # iadd must always return self def __setitem__(self,k,v): if v is not None: raise ValueError('NLMSA cannot save edge-info. Only nlmsa[s1][s2]=None allowed') self+=k def read_seq_dict(pathstem,trypath=None): 'read seqDict for NLMSA' if os.access(pathstem+'.seqDictP',os.R_OK): from pygr import worldbase ifile = file(pathstem+'.seqDictP', 'rb') # pickle is binary file! try: # load from worldbase-aware pickle file seqDict = worldbase._mdb.loads(ifile.read()) finally: ifile.close() elif os.access(pathstem+'.seqDict',os.R_OK): # old-style union header import seqdb seqDict = seqdb.PrefixUnionDict(filename=pathstem+'.seqDict', trypath=trypath) else: raise ValueError('''Unable to find seqDict file %s.seqDictP or %s.seqDict and no seqDict provided as an argument''' % (pathstem,pathstem)) return seqDict def save_seq_dict(pathstem,seqDict): 'save seqDict to a worldbase-aware pickle file' from metabase import dumps ofile = file(pathstem+'.seqDictP','wb') # pickle is binary file! try: ofile.write(dumps(seqDict)) finally: ofile.close() def prune_self_mappings(src_prefix,dest_prefix,is_bidirectional): '''return is_bidirectional flag according to whether source and target are the same genome. This handles axtNet reading, in which mappings between genomes are given in only one direction, whereas mappings between the same genome are given in both directions.''' if src_prefix == dest_prefix: return 0 else: return 1 def nlmsa_textdump_unpickler(filepath,kwargs): from cnestedlist import textfile_to_binaries,NLMSA logger.info('Saving NLMSA indexes from textdump: %s' % filepath) try: buildpath = os.environ['WORLDBASEBUILDDIR'] except KeyError: buildpath = classutil.get_env_or_cwd('PYGRDATABUILDDIR') path = textfile_to_binaries(filepath, buildpath=buildpath, **kwargs) o = NLMSA(path) # now open in read mode from the saved index fileset o._saveLocalBuild = True # mark this for saving in local metabase return o nlmsa_textdump_unpickler.__safe_for_unpickling__ = 1 class NLMSABuilder(object): 'when unpickled triggers construction of NLMSA from textdump' _worldbase_no_cache = True # force worldbase to reload this fresh def __init__(self,filepath,**kwargs): self.filepath = filepath self.kwargs = kwargs def __reduce__(self): return (nlmsa_textdump_unpickler,(self.filepath,self.kwargs)) class SeqCacheOwner(object): 'weak referenceable object: workaround for pyrex extension classes' def __init__(self): self.cachedSeqs = {} def cache_reference(self, seq): 'keep a ref to seqs cached on our behalf' self.cachedSeqs[seq.id] = seq def generate_nlmsa_edges(self, *args, **kwargs): """iterate over all edges for all sequences in the alignment. Very slow for a big alignment!""" for seq in self.seqs: myslice = self[seq] for results in myslice.edges(*args, **kwargs): yield results def get_interval(seq,start,end,ori): "trivial function to get the interval seq[start:end] with requested ori" if ori < 0: return seq.absolute_slice(-end, -start) else: return seq.absolute_slice(start, end) _default_ivals_attrs = dict(idDest='id', startDest='start', stopDest='stop', oriDest='ori') class CoordsToIntervals(object): '''Transforms coord objects to (ival1,ival2) aligned interval pairs. The intervals can come in in two forms: First, as a list, with [src, dest1, dest2, dest3] information; or second, as an object, with attributes specifying src/dest info. ''' def __init__(self, srcDB, destDB=None, alignedIvalsAttrs=_default_ivals_attrs): self.srcDB = srcDB if destDB: self.destDB = destDB else: self.destDB = srcDB self.getAttr = classutil.make_attribute_interface(alignedIvalsAttrs) def __call__(self, alignedCoords): '''Read interval info from alignedCoords and generate actual intervals. Information read is id, start, stop, and orientation (ori). ''' for c in alignedCoords: if isinstance(c, (CoordsGroupStart,CoordsGroupEnd)): yield c # just pass grouping-info through continue try: srcData = c[0] # align everything to the first interval destSet = c[1:] except TypeError: srcData = c # extract both src and dest from ivals object destSet = [c] id = self.getAttr(srcData, 'id') start = self.getAttr(srcData, 'start') stop = self.getAttr(srcData, 'stop') ori = self.getAttr(srcData, 'ori', 1) # default orientation: + srcIval = get_interval(self.srcDB[id], start, stop, ori) # get the dest interval(s) and yield w/src. for destData in destSet: idDest = self.getAttr(destData, 'idDest') startDest = self.getAttr(destData, 'startDest') stopDest = self.getAttr(destData, 'stopDest') oriDest = self.getAttr(destData, 'oriDest', 1) # default ori: + destIval = get_interval(self.destDB[idDest], startDest, stopDest, oriDest) yield srcIval, destIval # generate aligned intervals def add_aligned_intervals(al, alignedIvals): '''Save a set of aligned intervals to alignment. ''' # for each pair of aligned intervals, save them into the alignment. for t in alignedIvals: # is 't' a marker object for start or end of a group of coordinates? if isinstance(t, (CoordsGroupStart, CoordsGroupEnd)): continue # ignore grouping markers (src, dest) = t al += src al[src][dest] = None # save their alignment class CoordsGroupStart(object): '''Marker object indicating start of a coordinates group. See BlastHitParser for an example.''' pass class CoordsGroupEnd(object): '''Marker object indicating end of a group of coordinates. See BlastHitParser for an example.''' pass
bsd-3-clause
[ 646, 1021, 1974, 12, 2512, 199, 646, 747, 12, 2943, 199, 199, 533, 24719, 3053, 1179, 4077, 1296, 8, 513, 304, 272, 347, 636, 826, 721, 277, 12, 12992, 706, 65, 11205, 2141, 304, 267, 769, 855, 826, 721, 277, 9, 267, 291, 14, 7530, 706, 65, 11205, 2141, 275, 12992, 706, 65, 11205, 2141, 339, 347, 636, 6095, 721, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 24719, 3053, 1179, 69, 1954, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 862, 26, 288, 372, 769, 855, 6095, 721, 277, 12, 7530, 706, 65, 998, 9, 267, 871, 7888, 26, 288, 5412, 998, 12, 561, 998, 275, 291, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 288, 372, 769, 855, 6095, 721, 277, 12, 561, 998, 9, 339, 347, 664, 11205, 8, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 5412, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 5412, 998, 12, 561, 998, 275, 291, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 267, 372, 291, 14, 7530, 706, 65, 11205, 2141, 14, 7530, 706, 65, 14, 3610, 2141, 59, 3610, 998, 61, 2286, 347, 664, 11205, 998, 8, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 5412, 998, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 5412, 998, 12, 561, 998, 29, 277, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 267, 372, 5412, 998, 2286, 347, 365, 63, 76, 555, 8, 277, 12, 1305, 304, 267, 340, 1305, 2356, 822, 8, 277, 304, 288, 372, 756, 267, 700, 275, 291, 59, 344, 61, 267, 340, 700, 14, 374, 63, 76, 555, 26, 288, 372, 715, 267, 587, 26, 288, 372, 756, 5493, 347, 2163, 998, 8, 277, 304, 267, 372, 822, 8, 277, 9, 199, 199, 533, 9630, 14034, 547, 8, 10230, 304, 272, 986, 199, 199, 533, 9630, 16613, 547, 8, 3393, 304, 272, 986, 199, 199, 533, 9630, 14034, 26, 272, 283, 4699, 6014, 367, 675, 701, 24719, 3053, 1179, 3037, 7, 272, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 5412, 272, 347, 8207, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 2974, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 10849, 8, 277, 12, 1011, 958, 304, 267, 372, 2740, 4157, 272, 347, 2883, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 4157, 272, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 746, 4067, 272, 347, 636, 552, 721, 277, 304, 267, 372, 378, 272, 347, 1336, 2620, 3643, 8, 277, 12, 5412, 29, 403, 304, 267, 372, 942, 272, 347, 2342, 11205, 1327, 795, 8, 277, 12, 5412, 304, 267, 746, 4067, 360, 3610, 440, 22569, 315, 642, 6252, 358, 272, 347, 3550, 11205, 1327, 795, 8, 277, 304, 267, 372, 942, 272, 347, 1572, 2175, 2620, 3643, 8, 277, 12, 1011, 958, 304, 267, 372, 1052, 272, 347, 1572, 2175, 1513, 6227, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 3715, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 16150, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 372, 10467, 8, 277, 14, 3610, 12, 1163, 14, 3610, 9, 272, 347, 3066, 41, 3643, 8, 277, 304, 267, 372, 942, 1362, 199, 533, 24719, 3053, 1179, 4077, 2141, 8, 807, 304, 272, 283, 1080, 8013, 701, 931, 12984, 12, 436, 675, 769, 370, 4215, 3837, 4412, 7, 272, 347, 636, 826, 721, 277, 12, 12992, 706, 65, 12, 1788, 12, 818, 12, 1390, 998, 29, 22589, 12, 1305, 2141, 2543, 29, 403, 304, 267, 1211, 855, 826, 721, 277, 9, 267, 291, 14, 3610, 513, 275, 24719, 3053, 1179, 4077, 1296, 8, 277, 9, 267, 291, 14, 988, 998, 275, 1390, 998, 267, 291, 14, 7530, 706, 65, 275, 12992, 706, 65, 267, 291, 14, 1501, 275, 1788, 267, 340, 818, 508, 283, 4844, 356, 327, 2951, 675, 2366, 2600, 288, 1305, 2141, 2543, 275, 1211, 267, 916, 818, 508, 283, 87, 356, 327, 892, 3050, 288, 818, 275, 283, 78, 7, 267, 340, 1305, 2141, 2543, 365, 488, 26, 327, 675, 16149, 1305, 2600, 4887, 288, 291, 14, 3610, 998, 807, 275, 1021, 1974, 14, 1490, 63, 609, 15320, 8, 1501, 435, 1987, 3610, 998, 807, 297, 818, 9, 288, 291, 14, 998, 807, 275, 1021, 1974, 14, 1490, 63, 609, 15320, 8, 1501, 435, 1987, 344, 2141, 297, 818, 9, 267, 587, 26, 327, 922, 6841, 1021, 367, 1305, 2600, 4887, 288, 291, 14, 3610, 998, 807, 275, 1305, 2141, 2543, 342, 288, 291, 14, 998, 807, 275, 1305, 2141, 2543, 342, 339, 347, 3354, 11205, 8, 277, 12, 5412, 12, 700, 998, 29, 446, 17, 12, 3268, 29, 16, 12, 12992, 706, 65, 998, 29, 403, 304, 267, 283, 2117, 4412, 402, 5412, 370, 2013, 334, 7530, 706, 65, 998, 12, 561, 12, 2743, 3171, 267, 340, 700, 998, 665, 378, 26, 327, 4691, 314, 13629, 9658, 652, 734, 288, 291, 14, 7530, 706, 65, 14, 1818, 15540, 855, 28788, 721, 3610, 9, 288, 372, 327, 314, 13629, 3483, 652, 367, 2739, 12, 949, 1929, 370, 886, 7003, 267, 340, 1228, 8, 3610, 12, 2943, 14, 22463, 304, 288, 1305, 275, 5412, 327, 14312, 642, 465, 9999, 12313, 5148, 267, 587, 26, 327, 664, 314, 12893, 3895, 687, 314, 5412, 1182, 3050, 288, 1305, 275, 291, 14, 362, 11205, 998, 8, 3610, 9, 267, 340, 12992, 706, 65, 998, 365, 488, 26, 327, 18310, 282, 892, 3747, 1305, 288, 12992, 706, 65, 998, 275, 291, 14, 7530, 706, 65, 14, 2184, 998, 342, 267, 291, 14, 3610, 998, 807, 59, 344, 61, 275, 12992, 706, 65, 998, 12, 700, 998, 12, 3268, 267, 291, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 275, 1305, 12, 561, 998 ]
[ 1021, 1974, 12, 2512, 199, 646, 747, 12, 2943, 199, 199, 533, 24719, 3053, 1179, 4077, 1296, 8, 513, 304, 272, 347, 636, 826, 721, 277, 12, 12992, 706, 65, 11205, 2141, 304, 267, 769, 855, 826, 721, 277, 9, 267, 291, 14, 7530, 706, 65, 11205, 2141, 275, 12992, 706, 65, 11205, 2141, 339, 347, 636, 6095, 721, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 24719, 3053, 1179, 69, 1954, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 862, 26, 288, 372, 769, 855, 6095, 721, 277, 12, 7530, 706, 65, 998, 9, 267, 871, 7888, 26, 288, 5412, 998, 12, 561, 998, 275, 291, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 288, 372, 769, 855, 6095, 721, 277, 12, 561, 998, 9, 339, 347, 664, 11205, 8, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 5412, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 5412, 998, 12, 561, 998, 275, 291, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 267, 372, 291, 14, 7530, 706, 65, 11205, 2141, 14, 7530, 706, 65, 14, 3610, 2141, 59, 3610, 998, 61, 2286, 347, 664, 11205, 998, 8, 277, 12, 12992, 706, 65, 998, 304, 267, 283, 1107, 5412, 998, 367, 282, 1627, 12992, 706, 65, 63, 344, 7, 267, 5412, 998, 12, 561, 998, 29, 277, 14, 7530, 706, 65, 11205, 2141, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 267, 372, 5412, 998, 2286, 347, 365, 63, 76, 555, 8, 277, 12, 1305, 304, 267, 340, 1305, 2356, 822, 8, 277, 304, 288, 372, 756, 267, 700, 275, 291, 59, 344, 61, 267, 340, 700, 14, 374, 63, 76, 555, 26, 288, 372, 715, 267, 587, 26, 288, 372, 756, 5493, 347, 2163, 998, 8, 277, 304, 267, 372, 822, 8, 277, 9, 199, 199, 533, 9630, 14034, 547, 8, 10230, 304, 272, 986, 199, 199, 533, 9630, 16613, 547, 8, 3393, 304, 272, 986, 199, 199, 533, 9630, 14034, 26, 272, 283, 4699, 6014, 367, 675, 701, 24719, 3053, 1179, 3037, 7, 272, 347, 636, 826, 721, 277, 12, 5412, 304, 267, 291, 14, 3610, 275, 5412, 272, 347, 8207, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 2974, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 10849, 8, 277, 12, 1011, 958, 304, 267, 372, 2740, 4157, 272, 347, 2883, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 4157, 272, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 746, 4067, 272, 347, 636, 552, 721, 277, 304, 267, 372, 378, 272, 347, 1336, 2620, 3643, 8, 277, 12, 5412, 29, 403, 304, 267, 372, 942, 272, 347, 2342, 11205, 1327, 795, 8, 277, 12, 5412, 304, 267, 746, 4067, 360, 3610, 440, 22569, 315, 642, 6252, 358, 272, 347, 3550, 11205, 1327, 795, 8, 277, 304, 267, 372, 942, 272, 347, 1572, 2175, 2620, 3643, 8, 277, 12, 1011, 958, 304, 267, 372, 1052, 272, 347, 1572, 2175, 1513, 6227, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 3715, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 16150, 8, 277, 12, 1011, 958, 304, 267, 372, 942, 272, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 372, 10467, 8, 277, 14, 3610, 12, 1163, 14, 3610, 9, 272, 347, 3066, 41, 3643, 8, 277, 304, 267, 372, 942, 1362, 199, 533, 24719, 3053, 1179, 4077, 2141, 8, 807, 304, 272, 283, 1080, 8013, 701, 931, 12984, 12, 436, 675, 769, 370, 4215, 3837, 4412, 7, 272, 347, 636, 826, 721, 277, 12, 12992, 706, 65, 12, 1788, 12, 818, 12, 1390, 998, 29, 22589, 12, 1305, 2141, 2543, 29, 403, 304, 267, 1211, 855, 826, 721, 277, 9, 267, 291, 14, 3610, 513, 275, 24719, 3053, 1179, 4077, 1296, 8, 277, 9, 267, 291, 14, 988, 998, 275, 1390, 998, 267, 291, 14, 7530, 706, 65, 275, 12992, 706, 65, 267, 291, 14, 1501, 275, 1788, 267, 340, 818, 508, 283, 4844, 356, 327, 2951, 675, 2366, 2600, 288, 1305, 2141, 2543, 275, 1211, 267, 916, 818, 508, 283, 87, 356, 327, 892, 3050, 288, 818, 275, 283, 78, 7, 267, 340, 1305, 2141, 2543, 365, 488, 26, 327, 675, 16149, 1305, 2600, 4887, 288, 291, 14, 3610, 998, 807, 275, 1021, 1974, 14, 1490, 63, 609, 15320, 8, 1501, 435, 1987, 3610, 998, 807, 297, 818, 9, 288, 291, 14, 998, 807, 275, 1021, 1974, 14, 1490, 63, 609, 15320, 8, 1501, 435, 1987, 344, 2141, 297, 818, 9, 267, 587, 26, 327, 922, 6841, 1021, 367, 1305, 2600, 4887, 288, 291, 14, 3610, 998, 807, 275, 1305, 2141, 2543, 342, 288, 291, 14, 998, 807, 275, 1305, 2141, 2543, 342, 339, 347, 3354, 11205, 8, 277, 12, 5412, 12, 700, 998, 29, 446, 17, 12, 3268, 29, 16, 12, 12992, 706, 65, 998, 29, 403, 304, 267, 283, 2117, 4412, 402, 5412, 370, 2013, 334, 7530, 706, 65, 998, 12, 561, 12, 2743, 3171, 267, 340, 700, 998, 665, 378, 26, 327, 4691, 314, 13629, 9658, 652, 734, 288, 291, 14, 7530, 706, 65, 14, 1818, 15540, 855, 28788, 721, 3610, 9, 288, 372, 327, 314, 13629, 3483, 652, 367, 2739, 12, 949, 1929, 370, 886, 7003, 267, 340, 1228, 8, 3610, 12, 2943, 14, 22463, 304, 288, 1305, 275, 5412, 327, 14312, 642, 465, 9999, 12313, 5148, 267, 587, 26, 327, 664, 314, 12893, 3895, 687, 314, 5412, 1182, 3050, 288, 1305, 275, 291, 14, 362, 11205, 998, 8, 3610, 9, 267, 340, 12992, 706, 65, 998, 365, 488, 26, 327, 18310, 282, 892, 3747, 1305, 288, 12992, 706, 65, 998, 275, 291, 14, 7530, 706, 65, 14, 2184, 998, 342, 267, 291, 14, 3610, 998, 807, 59, 344, 61, 275, 12992, 706, 65, 998, 12, 700, 998, 12, 3268, 267, 291, 14, 998, 807, 59, 495, 8, 7530, 706, 65, 998, 1874, 275, 1305, 12, 561, 998, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ebber/noteCreationServer
flask/lib/python3.5/site-packages/pip/wheel.py
187
30186
""" Support for installing and building the "wheel" binary package format. """ from __future__ import absolute_import import compileall import csv import errno import functools import hashlib import logging import os import os.path import re import shutil import stat import sys import tempfile import warnings from base64 import urlsafe_b64encode from email.parser import Parser from pip._vendor.six import StringIO import pip from pip.download import path_to_url, unpack_url from pip.exceptions import InvalidWheelFilename, UnsupportedWheel from pip.locations import distutils_scheme, PIP_DELETE_MARKER_FILENAME from pip import pep425tags from pip.utils import ( call_subprocess, ensure_dir, make_path_relative, captured_stdout, rmtree) from pip.utils.logging import indent_log from pip._vendor.distlib.scripts import ScriptMaker from pip._vendor import pkg_resources from pip._vendor.six.moves import configparser wheel_ext = '.whl' VERSION_COMPATIBLE = (1, 0) logger = logging.getLogger(__name__) class WheelCache(object): """A cache of wheels for future installs.""" def __init__(self, cache_dir, format_control): """Create a wheel cache. :param cache_dir: The root of the cache. :param format_control: A pip.index.FormatControl object to limit binaries being read from the cache. """ self._cache_dir = os.path.expanduser(cache_dir) if cache_dir else None self._format_control = format_control def cached_wheel(self, link, package_name): return cached_wheel( self._cache_dir, link, self._format_control, package_name) def _cache_for_link(cache_dir, link): """ Return a directory to store cached wheels in for link. Because there are M wheels for any one sdist, we provide a directory to cache them in, and then consult that directory when looking up cache hits. We only insert things into the cache if they have plausible version numbers, so that we don't contaminate the cache with things that were not unique. E.g. ./package might have dozens of installs done for it and build a version of 0.0...and if we built and cached a wheel, we'd end up using the same wheel even if the source has been edited. :param cache_dir: The cache_dir being used by pip. :param link: The link of the sdist for which this will cache wheels. """ # We want to generate an url to use as our cache key, we don't want to just # re-use the URL because it might have other items in the fragment and we # don't care about those. key_parts = [link.url_without_fragment] if link.hash_name is not None and link.hash is not None: key_parts.append("=".join([link.hash_name, link.hash])) key_url = "#".join(key_parts) # Encode our key url with sha224, we'll use this because it has similar # security properties to sha256, but with a shorter total output (and thus # less secure). However the differences don't make a lot of difference for # our use case here. hashed = hashlib.sha224(key_url.encode()).hexdigest() # We want to nest the directories some to prevent having a ton of top level # directories where we might run out of sub directories on some FS. parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]] # Inside of the base location for cached wheels, expand our parts and join # them all together. return os.path.join(cache_dir, "wheels", *parts) def cached_wheel(cache_dir, link, format_control, package_name): if not cache_dir: return link if not link: return link if link.is_wheel: return link if not link.is_artifact: return link if not package_name: return link canonical_name = pkg_resources.safe_name(package_name).lower() formats = pip.index.fmt_ctl_formats(format_control, canonical_name) if "binary" not in formats: return link root = _cache_for_link(cache_dir, link) try: wheel_names = os.listdir(root) except OSError as e: if e.errno in (errno.ENOENT, errno.ENOTDIR): return link raise candidates = [] for wheel_name in wheel_names: try: wheel = Wheel(wheel_name) except InvalidWheelFilename: continue if not wheel.supported(): # Built for a different python/arch/etc continue candidates.append((wheel.support_index_min(), wheel_name)) if not candidates: return link candidates.sort() path = os.path.join(root, candidates[0][1]) return pip.index.Link(path_to_url(path), trusted=True) def rehash(path, algo='sha256', blocksize=1 << 20): """Return (hash, length) for path using hashlib.new(algo)""" h = hashlib.new(algo) length = 0 with open(path, 'rb') as f: block = f.read(blocksize) while block: length += len(block) h.update(block) block = f.read(blocksize) digest = 'sha256=' + urlsafe_b64encode( h.digest() ).decode('latin1').rstrip('=') return (digest, length) def open_for_csv(name, mode): if sys.version_info[0] < 3: nl = {} bin = 'b' else: nl = {'newline': ''} bin = '' return open(name, mode + bin, **nl) def fix_script(path): """Replace #!python with #!/path/to/python Return True if file was changed.""" # XXX RECORD hashes will need to be updated if os.path.isfile(path): with open(path, 'rb') as script: firstline = script.readline() if not firstline.startswith(b'#!python'): return False exename = sys.executable.encode(sys.getfilesystemencoding()) firstline = b'#!' + exename + os.linesep.encode("ascii") rest = script.read() with open(path, 'wb') as script: script.write(firstline) script.write(rest) return True dist_info_re = re.compile(r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?) \.dist-info$""", re.VERBOSE) def root_is_purelib(name, wheeldir): """ Return True if the extracted wheel in wheeldir should go into purelib. """ name_folded = name.replace("-", "_") for item in os.listdir(wheeldir): match = dist_info_re.match(item) if match and match.group('name') == name_folded: with open(os.path.join(wheeldir, item, 'WHEEL')) as wheel: for line in wheel: line = line.lower().rstrip() if line == "root-is-purelib: true": return True return False def get_entrypoints(filename): if not os.path.exists(filename): return {}, {} # This is done because you can pass a string to entry_points wrappers which # means that they may or may not be valid INI files. The attempt here is to # strip leading and trailing whitespace in order to make them valid INI # files. with open(filename) as fp: data = StringIO() for line in fp: data.write(line.strip()) data.write("\n") data.seek(0) cp = configparser.RawConfigParser() cp.readfp(data) console = {} gui = {} if cp.has_section('console_scripts'): console = dict(cp.items('console_scripts')) if cp.has_section('gui_scripts'): gui = dict(cp.items('gui_scripts')) return console, gui def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None, pycompile=True, scheme=None, isolated=False): """Install a wheel""" if not scheme: scheme = distutils_scheme( name, user=user, home=home, root=root, isolated=isolated ) if root_is_purelib(name, wheeldir): lib_dir = scheme['purelib'] else: lib_dir = scheme['platlib'] info_dir = [] data_dirs = [] source = wheeldir.rstrip(os.path.sep) + os.path.sep # Record details of the files moved # installed = files copied from the wheel to the destination # changed = files changed while installing (scripts #! line typically) # generated = files newly generated during the install (script wrappers) installed = {} changed = set() generated = [] # Compile all of the pyc files that we're going to be installing if pycompile: with captured_stdout() as stdout: with warnings.catch_warnings(): warnings.filterwarnings('ignore') compileall.compile_dir(source, force=True, quiet=True) logger.debug(stdout.getvalue()) def normpath(src, p): return make_path_relative(src, p).replace(os.path.sep, '/') def record_installed(srcfile, destfile, modified=False): """Map archive RECORD paths to installation RECORD paths.""" oldpath = normpath(srcfile, wheeldir) newpath = normpath(destfile, lib_dir) installed[oldpath] = newpath if modified: changed.add(destfile) def clobber(source, dest, is_base, fixer=None, filter=None): ensure_dir(dest) # common for the 'include' path for dir, subdirs, files in os.walk(source): basedir = dir[len(source):].lstrip(os.path.sep) destdir = os.path.join(dest, basedir) if is_base and basedir.split(os.path.sep, 1)[0].endswith('.data'): continue for s in subdirs: destsubdir = os.path.join(dest, basedir, s) if is_base and basedir == '' and destsubdir.endswith('.data'): data_dirs.append(s) continue elif (is_base and s.endswith('.dist-info') and # is self.req.project_name case preserving? s.lower().startswith( req.project_name.replace('-', '_').lower())): assert not info_dir, 'Multiple .dist-info directories' info_dir.append(destsubdir) for f in files: # Skip unwanted files if filter and filter(f): continue srcfile = os.path.join(dir, f) destfile = os.path.join(dest, basedir, f) # directory creation is lazy and after the file filtering above # to ensure we don't install empty dirs; empty dirs can't be # uninstalled. ensure_dir(destdir) # We use copyfile (not move, copy, or copy2) to be extra sure # that we are not moving directories over (copyfile fails for # directories) as well as to ensure that we are not copying # over any metadata because we want more control over what # metadata we actually copy over. shutil.copyfile(srcfile, destfile) # Copy over the metadata for the file, currently this only # includes the atime and mtime. st = os.stat(srcfile) if hasattr(os, "utime"): os.utime(destfile, (st.st_atime, st.st_mtime)) # If our file is executable, then make our destination file # executable. if os.access(srcfile, os.X_OK): st = os.stat(srcfile) permissions = ( st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH ) os.chmod(destfile, permissions) changed = False if fixer: changed = fixer(destfile) record_installed(srcfile, destfile, changed) clobber(source, lib_dir, True) assert info_dir, "%s .dist-info directory not found" % req # Get the defined entry points ep_file = os.path.join(info_dir[0], 'entry_points.txt') console, gui = get_entrypoints(ep_file) def is_entrypoint_wrapper(name): # EP, EP.exe and EP-script.py are scripts generated for # entry point EP by setuptools if name.lower().endswith('.exe'): matchname = name[:-4] elif name.lower().endswith('-script.py'): matchname = name[:-10] elif name.lower().endswith(".pya"): matchname = name[:-4] else: matchname = name # Ignore setuptools-generated scripts return (matchname in console or matchname in gui) for datadir in data_dirs: fixer = None filter = None for subdir in os.listdir(os.path.join(wheeldir, datadir)): fixer = None if subdir == 'scripts': fixer = fix_script filter = is_entrypoint_wrapper source = os.path.join(wheeldir, datadir, subdir) dest = scheme[subdir] clobber(source, dest, False, fixer=fixer, filter=filter) maker = ScriptMaker(None, scheme['scripts']) # Ensure old scripts are overwritten. # See https://github.com/pypa/pip/issues/1800 maker.clobber = True # Ensure we don't generate any variants for scripts because this is almost # never what somebody wants. # See https://bitbucket.org/pypa/distlib/issue/35/ maker.variants = set(('', )) # This is required because otherwise distlib creates scripts that are not # executable. # See https://bitbucket.org/pypa/distlib/issue/32/ maker.set_mode = True # Simplify the script and fix the fact that the default script swallows # every single stack trace. # See https://bitbucket.org/pypa/distlib/issue/34/ # See https://bitbucket.org/pypa/distlib/issue/33/ def _get_script_text(entry): return maker.script_template % { "module": entry.prefix, "import_name": entry.suffix.split(".")[0], "func": entry.suffix, } maker._get_script_text = _get_script_text maker.script_template = """# -*- coding: utf-8 -*- import re import sys from %(module)s import %(import_name)s if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(%(func)s()) """ # Special case pip and setuptools to generate versioned wrappers # # The issue is that some projects (specifically, pip and setuptools) use # code in setup.py to create "versioned" entry points - pip2.7 on Python # 2.7, pip3.3 on Python 3.3, etc. But these entry points are baked into # the wheel metadata at build time, and so if the wheel is installed with # a *different* version of Python the entry points will be wrong. The # correct fix for this is to enhance the metadata to be able to describe # such versioned entry points, but that won't happen till Metadata 2.0 is # available. # In the meantime, projects using versioned entry points will either have # incorrect versioned entry points, or they will not be able to distribute # "universal" wheels (i.e., they will need a wheel per Python version). # # Because setuptools and pip are bundled with _ensurepip and virtualenv, # we need to use universal wheels. So, as a stopgap until Metadata 2.0, we # override the versioned entry points in the wheel and generate the # correct ones. This code is purely a short-term measure until Metadat 2.0 # is available. # # To add the level of hack in this section of code, in order to support # ensurepip this code will look for an ``ENSUREPIP_OPTIONS`` environment # variable which will control which version scripts get installed. # # ENSUREPIP_OPTIONS=altinstall # - Only pipX.Y and easy_install-X.Y will be generated and installed # ENSUREPIP_OPTIONS=install # - pipX.Y, pipX, easy_install-X.Y will be generated and installed. Note # that this option is technically if ENSUREPIP_OPTIONS is set and is # not altinstall # DEFAULT # - The default behavior is to install pip, pipX, pipX.Y, easy_install # and easy_install-X.Y. pip_script = console.pop('pip', None) if pip_script: if "ENSUREPIP_OPTIONS" not in os.environ: spec = 'pip = ' + pip_script generated.extend(maker.make(spec)) if os.environ.get("ENSUREPIP_OPTIONS", "") != "altinstall": spec = 'pip%s = %s' % (sys.version[:1], pip_script) generated.extend(maker.make(spec)) spec = 'pip%s = %s' % (sys.version[:3], pip_script) generated.extend(maker.make(spec)) # Delete any other versioned pip entry points pip_ep = [k for k in console if re.match(r'pip(\d(\.\d)?)?$', k)] for k in pip_ep: del console[k] easy_install_script = console.pop('easy_install', None) if easy_install_script: if "ENSUREPIP_OPTIONS" not in os.environ: spec = 'easy_install = ' + easy_install_script generated.extend(maker.make(spec)) spec = 'easy_install-%s = %s' % (sys.version[:3], easy_install_script) generated.extend(maker.make(spec)) # Delete any other versioned easy_install entry points easy_install_ep = [ k for k in console if re.match(r'easy_install(-\d\.\d)?$', k) ] for k in easy_install_ep: del console[k] # Generate the console and GUI entry points specified in the wheel if len(console) > 0: generated.extend( maker.make_multiple(['%s = %s' % kv for kv in console.items()]) ) if len(gui) > 0: generated.extend( maker.make_multiple( ['%s = %s' % kv for kv in gui.items()], {'gui': True} ) ) record = os.path.join(info_dir[0], 'RECORD') temp_record = os.path.join(info_dir[0], 'RECORD.pip') with open_for_csv(record, 'r') as record_in: with open_for_csv(temp_record, 'w+') as record_out: reader = csv.reader(record_in) writer = csv.writer(record_out) for row in reader: row[0] = installed.pop(row[0], row[0]) if row[0] in changed: row[1], row[2] = rehash(row[0]) writer.writerow(row) for f in generated: h, l = rehash(f) writer.writerow((f, h, l)) for f in installed: writer.writerow((installed[f], '', '')) shutil.move(temp_record, record) def _unique(fn): @functools.wraps(fn) def unique(*args, **kw): seen = set() for item in fn(*args, **kw): if item not in seen: seen.add(item) yield item return unique # TODO: this goes somewhere besides the wheel module @_unique def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path def wheel_version(source_dir): """ Return the Wheel-Version of an extracted wheel, if possible. Otherwise, return False if we couldn't parse / extract it. """ try: dist = [d for d in pkg_resources.find_on_path(None, source_dir)][0] wheel_data = dist.get_metadata('WHEEL') wheel_data = Parser().parsestr(wheel_data) version = wheel_data['Wheel-Version'].strip() version = tuple(map(int, version.split('.'))) return version except: return False def check_compatibility(version, name): """ Raises errors or warns if called with an incompatible Wheel-Version. Pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a version only minor version ahead (e.g 1.2 > 1.1). version: a 2-tuple representing a Wheel-Version (Major, Minor) name: name of wheel or package to raise exception about :raises UnsupportedWheel: when an incompatible Wheel-Version is given """ if not version: raise UnsupportedWheel( "%s is in an unsupported or invalid wheel" % name ) if version[0] > VERSION_COMPATIBLE[0]: raise UnsupportedWheel( "%s's Wheel-Version (%s) is not compatible with this version " "of pip" % (name, '.'.join(map(str, version))) ) elif version > VERSION_COMPATIBLE: logger.warning( 'Installing from a newer Wheel-Version (%s)', '.'.join(map(str, version)), ) class Wheel(object): """A wheel file""" # TODO: maybe move the install code into this class wheel_file_re = re.compile( r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?)) ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?) \.whl|\.dist-info)$""", re.VERBOSE ) def __init__(self, filename): """ :raises InvalidWheelFilename: when the filename is invalid for a wheel """ wheel_info = self.wheel_file_re.match(filename) if not wheel_info: raise InvalidWheelFilename( "%s is not a valid wheel filename." % filename ) self.filename = filename self.name = wheel_info.group('name').replace('_', '-') # we'll assume "_" means "-" due to wheel naming scheme # (https://github.com/pypa/pip/issues/1150) self.version = wheel_info.group('ver').replace('_', '-') self.pyversions = wheel_info.group('pyver').split('.') self.abis = wheel_info.group('abi').split('.') self.plats = wheel_info.group('plat').split('.') # All the tag combinations from this file self.file_tags = set( (x, y, z) for x in self.pyversions for y in self.abis for z in self.plats ) def support_index_min(self, tags=None): """ Return the lowest index that one of the wheel's file_tag combinations achieves in the supported_tags list e.g. if there are 8 supported tags, and one of the file tags is first in the list, then return 0. Returns None is the wheel is not supported. """ if tags is None: # for mock tags = pep425tags.supported_tags indexes = [tags.index(c) for c in self.file_tags if c in tags] return min(indexes) if indexes else None def supported(self, tags=None): """Is this wheel supported on this system?""" if tags is None: # for mock tags = pep425tags.supported_tags return bool(set(tags).intersection(self.file_tags)) class WheelBuilder(object): """Build wheels from a RequirementSet.""" def __init__(self, requirement_set, finder, build_options=None, global_options=None): self.requirement_set = requirement_set self.finder = finder self._cache_root = requirement_set._wheel_cache._cache_dir self._wheel_dir = requirement_set.wheel_download_dir self.build_options = build_options or [] self.global_options = global_options or [] def _build_one(self, req, output_dir): """Build one wheel. :return: The filename of the built wheel, or None if the build failed. """ tempd = tempfile.mkdtemp('pip-wheel-') try: if self.__build_one(req, tempd): try: wheel_name = os.listdir(tempd)[0] wheel_path = os.path.join(output_dir, wheel_name) shutil.move(os.path.join(tempd, wheel_name), wheel_path) logger.info('Stored in directory: %s', output_dir) return wheel_path except: return None return None finally: rmtree(tempd) def __build_one(self, req, tempd): base_args = [ sys.executable, '-c', "import setuptools;__file__=%r;" "exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), " "__file__, 'exec'))" % req.setup_py ] + list(self.global_options) logger.info('Running setup.py bdist_wheel for %s', req.name) logger.debug('Destination directory: %s', tempd) wheel_args = base_args + ['bdist_wheel', '-d', tempd] \ + self.build_options try: call_subprocess(wheel_args, cwd=req.source_dir, show_stdout=False) return True except: logger.error('Failed building wheel for %s', req.name) return False def build(self, autobuilding=False): """Build wheels. :param unpack: If True, replace the sdist we built from the with the newly built wheel, in preparation for installation. :return: True if all the wheels built correctly. """ assert self._wheel_dir or (autobuilding and self._cache_root) # unpack sdists and constructs req set self.requirement_set.prepare_files(self.finder) reqset = self.requirement_set.requirements.values() buildset = [] for req in reqset: if req.constraint: continue if req.is_wheel: if not autobuilding: logger.info( 'Skipping %s, due to already being wheel.', req.name) elif req.editable: if not autobuilding: logger.info( 'Skipping bdist_wheel for %s, due to being editable', req.name) elif autobuilding and req.link and not req.link.is_artifact: pass elif autobuilding and not req.source_dir: pass else: if autobuilding: link = req.link base, ext = link.splitext() if pip.index.egg_info_matches(base, None, link) is None: # Doesn't look like a package - don't autobuild a wheel # because we'll have no way to lookup the result sanely continue if "binary" not in pip.index.fmt_ctl_formats( self.finder.format_control, pkg_resources.safe_name(req.name).lower()): logger.info( "Skipping bdist_wheel for %s, due to binaries " "being disabled for it.", req.name) continue buildset.append(req) if not buildset: return True # Build the wheels. logger.info( 'Building wheels for collected packages: %s', ', '.join([req.name for req in buildset]), ) with indent_log(): build_success, build_failure = [], [] for req in buildset: if autobuilding: output_dir = _cache_for_link(self._cache_root, req.link) try: ensure_dir(output_dir) except OSError as e: logger.warn("Building wheel for %s failed: %s", req.name, e) build_failure.append(req) continue else: output_dir = self._wheel_dir wheel_file = self._build_one(req, output_dir) if wheel_file: build_success.append(req) if autobuilding: # XXX: This is mildly duplicative with prepare_files, # but not close enough to pull out to a single common # method. # The code below assumes temporary source dirs - # prevent it doing bad things. if req.source_dir and not os.path.exists(os.path.join( req.source_dir, PIP_DELETE_MARKER_FILENAME)): raise AssertionError( "bad source dir - missing marker") # Delete the source we built the wheel from req.remove_temporary_source() # set the build directory again - name is known from # the work prepare_files did. req.source_dir = req.build_location( self.requirement_set.build_dir) # Update the link for this. req.link = pip.index.Link( path_to_url(wheel_file), trusted=True) assert req.link.is_wheel # extract the wheel into the dir unpack_url( req.link, req.source_dir, None, False, session=self.requirement_set.session) else: build_failure.append(req) # notify success/failure if build_success: logger.info( 'Successfully built %s', ' '.join([req.name for req in build_success]), ) if build_failure: logger.info( 'Failed to build %s', ' '.join([req.name for req in build_failure]), ) # Return True if all builds were successful return len(build_failure) == 0
gpl-2.0
[ 624, 199, 11532, 367, 22200, 436, 10015, 314, 298, 11798, 2, 3366, 2559, 1475, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 6555, 452, 199, 646, 7392, 199, 646, 7554, 199, 646, 9143, 199, 646, 8337, 199, 646, 2050, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5145, 199, 646, 5672, 199, 646, 984, 199, 646, 5549, 199, 646, 3598, 199, 199, 504, 1300, 772, 492, 8187, 6504, 63, 66, 772, 2143, 199, 504, 3031, 14, 2087, 492, 10191, 199, 199, 504, 7305, 423, 9884, 14, 4174, 492, 5228, 199, 199, 646, 7305, 199, 504, 7305, 14, 4249, 492, 931, 63, 475, 63, 633, 12, 7787, 63, 633, 199, 504, 7305, 14, 3924, 492, 6378, 25663, 8117, 12, 19022, 25663, 199, 504, 7305, 14, 8022, 492, 7065, 63, 5512, 12, 510, 1772, 63, 7014, 63, 18997, 63, 15440, 199, 504, 7305, 492, 22602, 24398, 2969, 199, 504, 7305, 14, 1208, 492, 334, 272, 1240, 63, 5781, 12, 4868, 63, 694, 12, 1852, 63, 515, 63, 6188, 12, 17487, 63, 2703, 12, 272, 20978, 9, 199, 504, 7305, 14, 1208, 14, 4806, 492, 4363, 63, 793, 199, 504, 7305, 423, 9884, 14, 2686, 773, 14, 6429, 492, 14914, 23560, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 21230, 421, 199, 11798, 63, 832, 275, 1987, 2191, 76, 7, 199, 199, 4612, 63, 29720, 7187, 275, 334, 17, 12, 378, 9, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 26161, 4437, 8, 785, 304, 272, 408, 33, 2581, 402, 28300, 367, 6466, 25801, 1041, 339, 347, 636, 826, 721, 277, 12, 2581, 63, 694, 12, 1475, 63, 2785, 304, 267, 408, 2499, 282, 9989, 2581, 14, 398, 520, 635, 2581, 63, 694, 26, 710, 1738, 402, 314, 2581, 14, 267, 520, 635, 1475, 63, 2785, 26, 437, 7305, 14, 1080, 14, 3484, 3717, 909, 370, 2304, 288, 21984, 3769, 1586, 687, 314, 2581, 14, 267, 408, 267, 291, 423, 1637, 63, 694, 275, 747, 14, 515, 14, 12131, 8, 1637, 63, 694, 9, 340, 2581, 63, 694, 587, 488, 267, 291, 423, 908, 63, 2785, 275, 1475, 63, 2785, 339, 347, 6328, 63, 11798, 8, 277, 12, 2142, 12, 2559, 63, 354, 304, 267, 372, 6328, 63, 11798, 8, 288, 291, 423, 1637, 63, 694, 12, 2142, 12, 291, 423, 908, 63, 2785, 12, 2559, 63, 354, 9, 421, 199, 318, 485, 1637, 63, 509, 63, 1073, 8, 1637, 63, 694, 12, 2142, 304, 272, 408, 272, 1432, 282, 2082, 370, 3877, 6328, 28300, 315, 367, 2142, 14, 339, 13821, 2337, 787, 603, 28300, 367, 1263, 1373, 26644, 12, 781, 5647, 282, 2082, 272, 370, 2581, 3062, 315, 12, 436, 2066, 13447, 427, 626, 2082, 1380, 10023, 1536, 272, 2581, 19745, 14, 339, 2136, 1454, 5518, 7645, 1901, 314, 2581, 340, 2985, 1172, 299, 416, 85, 1164, 1015, 272, 5579, 12, 880, 626, 781, 2793, 1133, 13770, 455, 23043, 314, 2581, 543, 7645, 626, 4898, 440, 272, 3747, 14, 662, 14, 71, 14, 16605, 2491, 5594, 1172, 886, 5193, 83, 402, 25801, 4224, 367, 652, 436, 1900, 272, 282, 1015, 402, 378, 14, 16, 1396, 460, 340, 781, 6137, 436, 6328, 282, 9989, 12, 781, 5121, 1284, 1536, 1808, 272, 314, 2011, 9989, 2755, 340, 314, 1350, 965, 2757, 21062, 14, 339, 520, 635, 2581, 63, 694, 26, 710, 2581, 63, 694, 3769, 1202, 701, 7305, 14, 272, 520, 635, 2142, 26, 710, 2142, 402, 314, 26644, 367, 1314, 642, 911, 2581, 28300, 14, 272, 408, 339, 327, 2136, 2934, 370, 3550, 376, 1166, 370, 675, 465, 4154, 2581, 790, 12, 781, 2793, 1133, 2934, 370, 2951, 272, 327, 295, 13, 1180, 314, 2851, 2952, 652, 5594, 1172, 1163, 2974, 315, 314, 7956, 436, 781, 272, 327, 2793, 1133, 10296, 3595, 5204, 14, 272, 790, 63, 4181, 275, 359, 1073, 14, 633, 63, 7395, 63, 7677, 61, 272, 340, 2142, 14, 2227, 63, 354, 365, 440, 488, 436, 2142, 14, 2227, 365, 440, 488, 26, 267, 790, 63, 4181, 14, 740, 480, 25356, 904, 779, 1073, 14, 2227, 63, 354, 12, 2142, 14, 2227, 2459, 272, 790, 63, 633, 275, 5426, 1674, 904, 8, 498, 63, 4181, 9, 339, 327, 19244, 4154, 790, 1166, 543, 7793, 8731, 12, 781, 7171, 675, 642, 2952, 652, 965, 8545, 272, 327, 6391, 4382, 370, 7793, 3912, 12, 1325, 543, 282, 18299, 3141, 1072, 334, 460, 12850, 272, 327, 6656, 11153, 680, 9738, 314, 15109, 2793, 1133, 1852, 282, 13918, 402, 8865, 367, 272, 327, 4154, 675, 1930, 2348, 14, 272, 19871, 275, 8337, 14, 4835, 8731, 8, 498, 63, 633, 14, 2143, 8801, 11453, 342, 339, 327, 2136, 2934, 370, 10715, 314, 6602, 2005, 370, 7981, 9445, 282, 307, 265, 402, 2746, 2166, 272, 327, 6602, 2382, 781, 5594, 1255, 734, 402, 1007, 6602, 641, 2005, 27500, 14, 272, 4184, 275, 359, 26368, 1491, 18, 467, 19871, 59, 18, 26, 20, 467, 19871, 59, 20, 26, 22, 467, 19871, 59, 22, 21316, 339, 327, 1010, 2441, 402, 314, 1300, 2909, 367, 6328, 28300, 12, 6544, 4154, 4184, 436, 4263, 272, 327, 3062, 1006, 10451, 14, 272, 372, 747, 14, 515, 14, 904, 8, 1637, 63, 694, 12, 298, 11798, 83, 401, 627, 4181, 9, 421, 199, 318, 6328, 63, 11798, 8, 1637, 63, 694, 12, 2142, 12, 1475, 63, 2785, 12, 2559, 63, 354, 304, 272, 340, 440, 2581, 63, 694, 26, 267, 372, 2142, 272, 340, 440, 2142, 26, 267, 372, 2142, 272, 340, 2142, 14, 374, 63, 11798, 26, 267, 372, 2142, 272, 340, 440, 2142, 14, 374, 63, 16154, 26, 267, 372, 2142, 272, 340, 440, 2559, 63, 354, 26, 267, 372, 2142, 272, 11358, 63, 354, 275, 5496, 63, 4435, 14, 3489, 63, 354, 8, 2491, 63, 354, 680, 2325, 342, 272, 6752, 275, 7305, 14, 1080, 14, 5045, 63, 8077, 63, 6321, 8, 908, 63, 2785, 12, 11358, 63, 354, 9, 272, 340, 298, 3008, 2, 440, 315, 6752, 26, 267, 372, 2142, 272, 1738, 275, 485, 1637, 63, 509, 63, 1073, 8, 1637, 63, 694 ]
[ 199, 11532, 367, 22200, 436, 10015, 314, 298, 11798, 2, 3366, 2559, 1475, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 6555, 452, 199, 646, 7392, 199, 646, 7554, 199, 646, 9143, 199, 646, 8337, 199, 646, 2050, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5145, 199, 646, 5672, 199, 646, 984, 199, 646, 5549, 199, 646, 3598, 199, 199, 504, 1300, 772, 492, 8187, 6504, 63, 66, 772, 2143, 199, 504, 3031, 14, 2087, 492, 10191, 199, 199, 504, 7305, 423, 9884, 14, 4174, 492, 5228, 199, 199, 646, 7305, 199, 504, 7305, 14, 4249, 492, 931, 63, 475, 63, 633, 12, 7787, 63, 633, 199, 504, 7305, 14, 3924, 492, 6378, 25663, 8117, 12, 19022, 25663, 199, 504, 7305, 14, 8022, 492, 7065, 63, 5512, 12, 510, 1772, 63, 7014, 63, 18997, 63, 15440, 199, 504, 7305, 492, 22602, 24398, 2969, 199, 504, 7305, 14, 1208, 492, 334, 272, 1240, 63, 5781, 12, 4868, 63, 694, 12, 1852, 63, 515, 63, 6188, 12, 17487, 63, 2703, 12, 272, 20978, 9, 199, 504, 7305, 14, 1208, 14, 4806, 492, 4363, 63, 793, 199, 504, 7305, 423, 9884, 14, 2686, 773, 14, 6429, 492, 14914, 23560, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 21230, 421, 199, 11798, 63, 832, 275, 1987, 2191, 76, 7, 199, 199, 4612, 63, 29720, 7187, 275, 334, 17, 12, 378, 9, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 26161, 4437, 8, 785, 304, 272, 408, 33, 2581, 402, 28300, 367, 6466, 25801, 1041, 339, 347, 636, 826, 721, 277, 12, 2581, 63, 694, 12, 1475, 63, 2785, 304, 267, 408, 2499, 282, 9989, 2581, 14, 398, 520, 635, 2581, 63, 694, 26, 710, 1738, 402, 314, 2581, 14, 267, 520, 635, 1475, 63, 2785, 26, 437, 7305, 14, 1080, 14, 3484, 3717, 909, 370, 2304, 288, 21984, 3769, 1586, 687, 314, 2581, 14, 267, 408, 267, 291, 423, 1637, 63, 694, 275, 747, 14, 515, 14, 12131, 8, 1637, 63, 694, 9, 340, 2581, 63, 694, 587, 488, 267, 291, 423, 908, 63, 2785, 275, 1475, 63, 2785, 339, 347, 6328, 63, 11798, 8, 277, 12, 2142, 12, 2559, 63, 354, 304, 267, 372, 6328, 63, 11798, 8, 288, 291, 423, 1637, 63, 694, 12, 2142, 12, 291, 423, 908, 63, 2785, 12, 2559, 63, 354, 9, 421, 199, 318, 485, 1637, 63, 509, 63, 1073, 8, 1637, 63, 694, 12, 2142, 304, 272, 408, 272, 1432, 282, 2082, 370, 3877, 6328, 28300, 315, 367, 2142, 14, 339, 13821, 2337, 787, 603, 28300, 367, 1263, 1373, 26644, 12, 781, 5647, 282, 2082, 272, 370, 2581, 3062, 315, 12, 436, 2066, 13447, 427, 626, 2082, 1380, 10023, 1536, 272, 2581, 19745, 14, 339, 2136, 1454, 5518, 7645, 1901, 314, 2581, 340, 2985, 1172, 299, 416, 85, 1164, 1015, 272, 5579, 12, 880, 626, 781, 2793, 1133, 13770, 455, 23043, 314, 2581, 543, 7645, 626, 4898, 440, 272, 3747, 14, 662, 14, 71, 14, 16605, 2491, 5594, 1172, 886, 5193, 83, 402, 25801, 4224, 367, 652, 436, 1900, 272, 282, 1015, 402, 378, 14, 16, 1396, 460, 340, 781, 6137, 436, 6328, 282, 9989, 12, 781, 5121, 1284, 1536, 1808, 272, 314, 2011, 9989, 2755, 340, 314, 1350, 965, 2757, 21062, 14, 339, 520, 635, 2581, 63, 694, 26, 710, 2581, 63, 694, 3769, 1202, 701, 7305, 14, 272, 520, 635, 2142, 26, 710, 2142, 402, 314, 26644, 367, 1314, 642, 911, 2581, 28300, 14, 272, 408, 339, 327, 2136, 2934, 370, 3550, 376, 1166, 370, 675, 465, 4154, 2581, 790, 12, 781, 2793, 1133, 2934, 370, 2951, 272, 327, 295, 13, 1180, 314, 2851, 2952, 652, 5594, 1172, 1163, 2974, 315, 314, 7956, 436, 781, 272, 327, 2793, 1133, 10296, 3595, 5204, 14, 272, 790, 63, 4181, 275, 359, 1073, 14, 633, 63, 7395, 63, 7677, 61, 272, 340, 2142, 14, 2227, 63, 354, 365, 440, 488, 436, 2142, 14, 2227, 365, 440, 488, 26, 267, 790, 63, 4181, 14, 740, 480, 25356, 904, 779, 1073, 14, 2227, 63, 354, 12, 2142, 14, 2227, 2459, 272, 790, 63, 633, 275, 5426, 1674, 904, 8, 498, 63, 4181, 9, 339, 327, 19244, 4154, 790, 1166, 543, 7793, 8731, 12, 781, 7171, 675, 642, 2952, 652, 965, 8545, 272, 327, 6391, 4382, 370, 7793, 3912, 12, 1325, 543, 282, 18299, 3141, 1072, 334, 460, 12850, 272, 327, 6656, 11153, 680, 9738, 314, 15109, 2793, 1133, 1852, 282, 13918, 402, 8865, 367, 272, 327, 4154, 675, 1930, 2348, 14, 272, 19871, 275, 8337, 14, 4835, 8731, 8, 498, 63, 633, 14, 2143, 8801, 11453, 342, 339, 327, 2136, 2934, 370, 10715, 314, 6602, 2005, 370, 7981, 9445, 282, 307, 265, 402, 2746, 2166, 272, 327, 6602, 2382, 781, 5594, 1255, 734, 402, 1007, 6602, 641, 2005, 27500, 14, 272, 4184, 275, 359, 26368, 1491, 18, 467, 19871, 59, 18, 26, 20, 467, 19871, 59, 20, 26, 22, 467, 19871, 59, 22, 21316, 339, 327, 1010, 2441, 402, 314, 1300, 2909, 367, 6328, 28300, 12, 6544, 4154, 4184, 436, 4263, 272, 327, 3062, 1006, 10451, 14, 272, 372, 747, 14, 515, 14, 904, 8, 1637, 63, 694, 12, 298, 11798, 83, 401, 627, 4181, 9, 421, 199, 318, 6328, 63, 11798, 8, 1637, 63, 694, 12, 2142, 12, 1475, 63, 2785, 12, 2559, 63, 354, 304, 272, 340, 440, 2581, 63, 694, 26, 267, 372, 2142, 272, 340, 440, 2142, 26, 267, 372, 2142, 272, 340, 2142, 14, 374, 63, 11798, 26, 267, 372, 2142, 272, 340, 440, 2142, 14, 374, 63, 16154, 26, 267, 372, 2142, 272, 340, 440, 2559, 63, 354, 26, 267, 372, 2142, 272, 11358, 63, 354, 275, 5496, 63, 4435, 14, 3489, 63, 354, 8, 2491, 63, 354, 680, 2325, 342, 272, 6752, 275, 7305, 14, 1080, 14, 5045, 63, 8077, 63, 6321, 8, 908, 63, 2785, 12, 11358, 63, 354, 9, 272, 340, 298, 3008, 2, 440, 315, 6752, 26, 267, 372, 2142, 272, 1738, 275, 485, 1637, 63, 509, 63, 1073, 8, 1637, 63, 694, 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, 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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 ]
tommy-u/chaco
examples/demo/advanced/asynchronous_updates.py
1
8087
""" Perform expensive calculations based on user interactions while keeping the GUI responsive. This makes use of asynchronous programming tools in the encore package. Move the slider to blur the image. Note the slider stays responsive even though the blurring may lag the slider. Uncheck "Asynchronous" and note that the slider movement is no longer responsive - the blurring occurs on the main thread and interrupts the movement of the slider. """ # Major library imports from numpy import ogrid, pi, sin # Enthought library imports from enable.api import Component, ComponentEditor from traits.api import (Array, Bool, DelegatesTo, HasTraits, Instance, Range, on_trait_change) from traits.trait_notifiers import ui_dispatch from traitsui.api import Item, Group, View try: from encore.concurrent.futures.enhanced_thread_pool_executor import \ EnhancedThreadPoolExecutor from encore.concurrent.futures.asynchronizer import Asynchronizer except ImportError: import sys sys.exit('You need futures and encore installed to run this demo.') # Chaco imports from chaco.api import ArrayPlotData, Plot, VPlotContainer, gray class BlurPlotController(HasTraits): """ Plot controller class for an image plot and its blurred output """ #========================================================================== # Synchronization logic #========================================================================== # Flag indicating whether updates are asynchronous. asynchronous = Bool(True) # The executor. This provides a thread pool on which to process operations. _executor = Instance(EnhancedThreadPoolExecutor) # The asynchronizer. This dispatches calls to the executor while dropping # calls that cannot be handled fast enough. _asynchronizer = Instance(Asynchronizer) def __executor_default(self): # TIP: The executor should be 'shutdown' when no longer needed to avoid # creating multiple idle threads. This is not necessary in a small # demo. return EnhancedThreadPoolExecutor(max_workers=1) def __asynchronizer_default(self): # TIP: Multiple Asynchronizers can share the same executor. If you # have multiple calls that need to be "asynchronized", each should have # its own asynchronizer. return Asynchronizer(self._executor) @on_trait_change('blur_level, image', post_init=True) def _recalculate_blurred_image(self): """ Blur the image either synchronously or with the asynchronizer """ image = self.image blur_level = self.blur_level if self.asynchronous: # The 'submit' call is non-blocking, and returns almost # immediately. The asynchronizer will pass # self._blur_and_notify_plot and its arguments (the "job") to the # executor to be run on one of the executor's worker threads when # the asynchronizer's current job (if any) is complete. If another # job (presumably with a different blur_level) comes in before this # happens, this job will never be executed. self._asynchronizer.submit(self._blur_and_notify_plot, image, blur_level) else: # This happens on the calling thread, which is the GUI thread when # a change in 'blur_level' comes from the GUI (as in this demo). # The GUI must wait for these calls to complete before it can # process further user input. If the calls are slow, the GUI will # become unresponsive. self.blurred_image = blur_image(image, blur_level) self.plot_data.set_data("blurred_image", self.blurred_image) def _blur_and_notify_plot(self, image, blur_level): """ Do the work of blurring the image and notifying the plot """ self.blurred_image = blur_image(image, blur_level) # Calling 'self.plot_data.set_data' will update the blurred plot. In # general, it is not safe to send visual updates when not on the GUI # thread. Since this call is being executed on one of the executor's # worker threads, we must re-dispatch the data update to the UI thread # or suffer undefined consequences (possibly crashes). ui_dispatch(self.plot_data.set_data, "blurred_image", self.blurred_image) #========================================================================== # Visualization logic - useful, but not the point of the demo #========================================================================== # An image array to display image = Array # The blurred image to display blurred_image = Array # The level of blurring to apply blur_level = Range(low=0, high=5) # The plot data plot_data = Instance(ArrayPlotData) # The plot component component = Instance(Component) def _image_default(self): x, y = ogrid[-pi:pi:1024j, 0:2*pi:1024j] z = (sin(11*x**2)**2 * sin(5*y**2))**2 return z def _blurred_image_default(self): return self.image def _plot_data_default(self): pd = ArrayPlotData() pd.set_data("image", self.image) pd.set_data("blurred_image", self.blurred_image) return pd def _component_default(self): padding = (25, 5, 5, 25) image_plot = Plot(self.plot_data, padding=padding) image_plot.img_plot("image", origin="top left", xbounds=(-pi, pi), ybounds=(-pi, pi), colormap=gray) blurred_image_plot = Plot(self.plot_data, padding=padding) blurred_image_plot.img_plot("blurred_image", origin="top left", xbounds=(-pi, pi), ybounds=(-pi, pi), colormap=gray) container = VPlotContainer() container.add(blurred_image_plot) container.add(image_plot) return container def blur_image(image, blur_level): """ Blur the image using a potentially time-consuming algorithm """ blurred_image = image.copy() for _ in xrange(blur_level**2): blurred_image[1:-1, 1:-1] += ( blurred_image[:-2, 1:-1] + # top blurred_image[2:, 1:-1] + # bottom blurred_image[1:-1, :-2] + # left blurred_image[1:-1, 2:] + # right blurred_image[:-2, :-2] + # top-left blurred_image[:-2, 2:] + # top-right blurred_image[2:, :-2] + # bottom-left blurred_image[2:, 2:] # bottom-right ) blurred_image /= 9 return blurred_image #============================================================================== # Attributes to use for the plot view. #============================================================================== size = (800, 600) title = "Image with asynchronous blurring" #============================================================================== # Demo class that is used by the demo.py application. #============================================================================== class Demo(HasTraits): plot_controller = Instance(BlurPlotController, ()) component = DelegatesTo('plot_controller') blur_level = DelegatesTo('plot_controller') asynchronous = DelegatesTo('plot_controller') traits_view = View( Group( Item( 'component', editor=ComponentEditor(size=size), show_label=False ), Group( Item('asynchronous'), Item('blur_level'), orientation="horizontal" ), orientation="vertical" ), resizable=True, title=title ) demo = Demo() if __name__ == "__main__": demo.configure_traits()
bsd-3-clause
[ 624, 199, 20906, 23133, 24258, 4079, 641, 922, 315, 22990, 1830, 22181, 314, 17160, 199, 3853, 3398, 14, 961, 7704, 675, 402, 15608, 31768, 7249, 315, 314, 655, 1018, 199, 2491, 14, 199, 199, 10370, 314, 31608, 370, 6826, 300, 314, 1834, 14, 3390, 314, 31608, 2612, 588, 9163, 3398, 2755, 10617, 199, 1589, 6826, 300, 5985, 1443, 17891, 314, 31608, 14, 1910, 1074, 298, 2822, 9865, 2, 436, 5317, 626, 314, 199, 20860, 4057, 434, 365, 949, 8088, 9163, 3398, 446, 314, 6826, 300, 5985, 11058, 641, 314, 2446, 199, 2671, 436, 1640, 5505, 1086, 314, 4057, 434, 402, 314, 31608, 14, 199, 624, 199, 3, 16593, 5857, 3555, 8925, 199, 504, 2680, 492, 312, 3825, 12, 6682, 12, 9829, 199, 199, 3, 3447, 273, 20816, 3555, 8925, 199, 504, 4756, 14, 1246, 492, 12727, 12, 12727, 10423, 199, 504, 19692, 14, 1246, 492, 334, 3836, 12, 19287, 12, 1487, 4170, 2335, 1378, 12, 13481, 31116, 12, 10066, 12, 13114, 12, 717, 641, 63, 22687, 63, 1461, 9, 199, 504, 19692, 14, 22687, 63, 889, 1428, 1192, 492, 8574, 63, 6052, 199, 504, 19692, 1907, 14, 1246, 492, 7020, 12, 5611, 12, 10935, 199, 199, 893, 26, 272, 687, 655, 1018, 14, 27237, 14, 25513, 14, 287, 24384, 63, 2671, 63, 2293, 63, 13471, 492, 971, 267, 3447, 24384, 4436, 5453, 16752, 272, 687, 655, 1018, 14, 27237, 14, 25513, 14, 305, 6030, 1793, 492, 3709, 6030, 1793, 199, 2590, 3545, 26, 272, 492, 984, 272, 984, 14, 2224, 360, 5556, 1929, 27471, 436, 655, 1018, 4903, 370, 1255, 642, 14779, 2659, 199, 199, 3, 445, 2411, 331, 8925, 199, 504, 682, 13286, 14, 1246, 492, 8725, 10711, 1451, 12, 14794, 12, 812, 10711, 4076, 12, 21977, 421, 199, 533, 699, 76, 300, 10711, 7506, 8, 6362, 31116, 304, 272, 408, 14794, 7614, 1021, 367, 376, 1834, 5137, 436, 2399, 6826, 300, 581, 1072, 408, 339, 32314, 17575, 272, 327, 428, 6030, 2072, 9661, 272, 32314, 17575, 339, 327, 18241, 9297, 3775, 7029, 787, 15608, 14, 272, 15608, 275, 19287, 8, 549, 9, 339, 327, 710, 13270, 14, 961, 6571, 282, 2462, 4203, 641, 1314, 370, 2112, 5331, 14, 272, 485, 13471, 275, 10066, 8, 1327, 24384, 4436, 5453, 16752, 9, 339, 327, 710, 465, 6030, 1793, 14, 961, 7634, 397, 4882, 370, 314, 13270, 1830, 366, 20148, 272, 327, 4882, 626, 3913, 506, 8860, 7377, 8321, 14, 272, 485, 305, 6030, 1793, 275, 10066, 8, 2822, 6030, 1793, 9, 339, 347, 636, 13471, 63, 885, 8, 277, 304, 267, 327, 377, 1772, 26, 710, 13270, 1077, 506, 283, 8831, 7, 1380, 949, 8088, 4346, 370, 5126, 267, 327, 6425, 3663, 15072, 7183, 14, 961, 365, 440, 5784, 315, 282, 7425, 267, 327, 14779, 14, 267, 372, 3447, 24384, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 17, 9, 339, 347, 636, 305, 6030, 1793, 63, 885, 8, 277, 304, 267, 327, 377, 1772, 26, 14326, 3709, 6030, 6315, 883, 8663, 314, 2011, 13270, 14, 221, 982, 1265, 267, 327, 1172, 3663, 4882, 626, 1929, 370, 506, 298, 305, 6030, 1759, 401, 1924, 1077, 1172, 267, 327, 2399, 5705, 465, 6030, 1793, 14, 267, 372, 3709, 6030, 1793, 8, 277, 423, 13471, 9, 339, 768, 265, 63, 22687, 63, 1461, 360, 3345, 300, 63, 1896, 12, 1834, 297, 2963, 63, 826, 29, 549, 9, 272, 347, 485, 264, 12063, 63, 3345, 300, 581, 63, 1569, 8, 277, 304, 267, 408, 699, 76, 300, 314, 1834, 1902, 24248, 590, 503, 543, 314, 465, 6030, 1793, 408, 267, 1834, 275, 291, 14, 1569, 267, 6826, 300, 63, 1896, 275, 291, 14, 3345, 300, 63, 1896, 398, 340, 291, 14, 305, 9865, 26, 288, 327, 710, 283, 7275, 7, 1240, 365, 2222, 13, 13091, 12, 436, 2529, 18871, 288, 327, 9939, 14, 221, 710, 465, 6030, 1793, 911, 986, 288, 327, 291, 423, 3345, 300, 63, 460, 63, 6814, 63, 2798, 436, 2399, 2368, 334, 1589, 298, 2423, 531, 370, 314, 288, 327, 13270, 370, 506, 1255, 641, 1373, 402, 314, 13270, 1159, 7239, 7183, 1380, 288, 327, 314, 465, 6030, 1793, 1159, 1453, 3906, 334, 692, 1263, 9, 365, 4890, 14, 982, 4573, 288, 327, 3906, 334, 24919, 453, 6665, 543, 282, 3365, 6826, 300, 63, 1896, 9, 12477, 315, 2544, 642, 288, 327, 10986, 12, 642, 3906, 911, 7078, 506, 7934, 14, 288, 291, 423, 305, 6030, 1793, 14, 7275, 8, 277, 423, 3345, 300, 63, 460, 63, 6814, 63, 2798, 12, 1834, 12, 4318, 6826, 300, 63, 1896, 9, 267, 587, 26, 288, 327, 961, 10986, 641, 314, 6358, 2462, 12, 1314, 365, 314, 17160, 2462, 1380, 288, 327, 282, 1570, 315, 283, 3345, 300, 63, 1896, 7, 12477, 687, 314, 17160, 334, 305, 315, 642, 14779, 680, 288, 327, 710, 17160, 1471, 3618, 367, 3520, 4882, 370, 4890, 2544, 652, 883, 288, 327, 2112, 9848, 922, 1324, 14, 221, 982, 314, 4882, 787, 11999, 12, 314, 17160, 911, 288, 327, 8649, 625, 3853, 3398, 14, 288, 291, 14, 3345, 300, 581, 63, 1569, 275, 6826, 300, 63, 1569, 8, 1569, 12, 6826, 300, 63, 1896, 9, 288, 291, 14, 2798, 63, 576, 14, 409, 63, 576, 480, 3345, 300, 581, 63, 1569, 401, 291, 14, 3345, 300, 581, 63, 1569, 9, 339, 347, 485, 3345, 300, 63, 460, 63, 6814, 63, 2798, 8, 277, 12, 1834, 12, 6826, 300, 63, 1896, 304, 267, 408, 4226, 314, 1736, 402, 6826, 300, 5985, 314, 1834, 436, 11705, 316, 314, 5137, 408, 267, 291, 14, 3345, 300, 581, 63, 1569, 275, 6826, 300, 63, 1569, 8, 1569, 12, 6826, 300, 63, 1896, 9, 398, 327, 23892, 283, 277, 14, 2798, 63, 576, 14, 409, 63, 576, 7, 911, 1678, 314, 6826, 300, 581, 5137, 14, 221, 1010, 267, 327, 8605, 12, 652, 365, 440, 5048, 370, 3222, 13104, 7029, 1380, 440, 641, 314, 17160, 267, 327, 2462, 14, 9336, 642, 1240, 365, 3769, 7934, 641, 1373, 402, 314, 13270, 1159, 267, 327, 7239, 7183, 12, 781, 1471, 295, 13, 6052, 314, 666, 1678, 370, 314, 14041, 2462, 267, 327, 503, 18741, 1260, 10942, 406, 13436, 334, 19614, 2467, 9030, 680, 267, 8574, 63, 6052, 8 ]
[ 199, 20906, 23133, 24258, 4079, 641, 922, 315, 22990, 1830, 22181, 314, 17160, 199, 3853, 3398, 14, 961, 7704, 675, 402, 15608, 31768, 7249, 315, 314, 655, 1018, 199, 2491, 14, 199, 199, 10370, 314, 31608, 370, 6826, 300, 314, 1834, 14, 3390, 314, 31608, 2612, 588, 9163, 3398, 2755, 10617, 199, 1589, 6826, 300, 5985, 1443, 17891, 314, 31608, 14, 1910, 1074, 298, 2822, 9865, 2, 436, 5317, 626, 314, 199, 20860, 4057, 434, 365, 949, 8088, 9163, 3398, 446, 314, 6826, 300, 5985, 11058, 641, 314, 2446, 199, 2671, 436, 1640, 5505, 1086, 314, 4057, 434, 402, 314, 31608, 14, 199, 624, 199, 3, 16593, 5857, 3555, 8925, 199, 504, 2680, 492, 312, 3825, 12, 6682, 12, 9829, 199, 199, 3, 3447, 273, 20816, 3555, 8925, 199, 504, 4756, 14, 1246, 492, 12727, 12, 12727, 10423, 199, 504, 19692, 14, 1246, 492, 334, 3836, 12, 19287, 12, 1487, 4170, 2335, 1378, 12, 13481, 31116, 12, 10066, 12, 13114, 12, 717, 641, 63, 22687, 63, 1461, 9, 199, 504, 19692, 14, 22687, 63, 889, 1428, 1192, 492, 8574, 63, 6052, 199, 504, 19692, 1907, 14, 1246, 492, 7020, 12, 5611, 12, 10935, 199, 199, 893, 26, 272, 687, 655, 1018, 14, 27237, 14, 25513, 14, 287, 24384, 63, 2671, 63, 2293, 63, 13471, 492, 971, 267, 3447, 24384, 4436, 5453, 16752, 272, 687, 655, 1018, 14, 27237, 14, 25513, 14, 305, 6030, 1793, 492, 3709, 6030, 1793, 199, 2590, 3545, 26, 272, 492, 984, 272, 984, 14, 2224, 360, 5556, 1929, 27471, 436, 655, 1018, 4903, 370, 1255, 642, 14779, 2659, 199, 199, 3, 445, 2411, 331, 8925, 199, 504, 682, 13286, 14, 1246, 492, 8725, 10711, 1451, 12, 14794, 12, 812, 10711, 4076, 12, 21977, 421, 199, 533, 699, 76, 300, 10711, 7506, 8, 6362, 31116, 304, 272, 408, 14794, 7614, 1021, 367, 376, 1834, 5137, 436, 2399, 6826, 300, 581, 1072, 408, 339, 32314, 17575, 272, 327, 428, 6030, 2072, 9661, 272, 32314, 17575, 339, 327, 18241, 9297, 3775, 7029, 787, 15608, 14, 272, 15608, 275, 19287, 8, 549, 9, 339, 327, 710, 13270, 14, 961, 6571, 282, 2462, 4203, 641, 1314, 370, 2112, 5331, 14, 272, 485, 13471, 275, 10066, 8, 1327, 24384, 4436, 5453, 16752, 9, 339, 327, 710, 465, 6030, 1793, 14, 961, 7634, 397, 4882, 370, 314, 13270, 1830, 366, 20148, 272, 327, 4882, 626, 3913, 506, 8860, 7377, 8321, 14, 272, 485, 305, 6030, 1793, 275, 10066, 8, 2822, 6030, 1793, 9, 339, 347, 636, 13471, 63, 885, 8, 277, 304, 267, 327, 377, 1772, 26, 710, 13270, 1077, 506, 283, 8831, 7, 1380, 949, 8088, 4346, 370, 5126, 267, 327, 6425, 3663, 15072, 7183, 14, 961, 365, 440, 5784, 315, 282, 7425, 267, 327, 14779, 14, 267, 372, 3447, 24384, 4436, 5453, 16752, 8, 988, 63, 11009, 29, 17, 9, 339, 347, 636, 305, 6030, 1793, 63, 885, 8, 277, 304, 267, 327, 377, 1772, 26, 14326, 3709, 6030, 6315, 883, 8663, 314, 2011, 13270, 14, 221, 982, 1265, 267, 327, 1172, 3663, 4882, 626, 1929, 370, 506, 298, 305, 6030, 1759, 401, 1924, 1077, 1172, 267, 327, 2399, 5705, 465, 6030, 1793, 14, 267, 372, 3709, 6030, 1793, 8, 277, 423, 13471, 9, 339, 768, 265, 63, 22687, 63, 1461, 360, 3345, 300, 63, 1896, 12, 1834, 297, 2963, 63, 826, 29, 549, 9, 272, 347, 485, 264, 12063, 63, 3345, 300, 581, 63, 1569, 8, 277, 304, 267, 408, 699, 76, 300, 314, 1834, 1902, 24248, 590, 503, 543, 314, 465, 6030, 1793, 408, 267, 1834, 275, 291, 14, 1569, 267, 6826, 300, 63, 1896, 275, 291, 14, 3345, 300, 63, 1896, 398, 340, 291, 14, 305, 9865, 26, 288, 327, 710, 283, 7275, 7, 1240, 365, 2222, 13, 13091, 12, 436, 2529, 18871, 288, 327, 9939, 14, 221, 710, 465, 6030, 1793, 911, 986, 288, 327, 291, 423, 3345, 300, 63, 460, 63, 6814, 63, 2798, 436, 2399, 2368, 334, 1589, 298, 2423, 531, 370, 314, 288, 327, 13270, 370, 506, 1255, 641, 1373, 402, 314, 13270, 1159, 7239, 7183, 1380, 288, 327, 314, 465, 6030, 1793, 1159, 1453, 3906, 334, 692, 1263, 9, 365, 4890, 14, 982, 4573, 288, 327, 3906, 334, 24919, 453, 6665, 543, 282, 3365, 6826, 300, 63, 1896, 9, 12477, 315, 2544, 642, 288, 327, 10986, 12, 642, 3906, 911, 7078, 506, 7934, 14, 288, 291, 423, 305, 6030, 1793, 14, 7275, 8, 277, 423, 3345, 300, 63, 460, 63, 6814, 63, 2798, 12, 1834, 12, 4318, 6826, 300, 63, 1896, 9, 267, 587, 26, 288, 327, 961, 10986, 641, 314, 6358, 2462, 12, 1314, 365, 314, 17160, 2462, 1380, 288, 327, 282, 1570, 315, 283, 3345, 300, 63, 1896, 7, 12477, 687, 314, 17160, 334, 305, 315, 642, 14779, 680, 288, 327, 710, 17160, 1471, 3618, 367, 3520, 4882, 370, 4890, 2544, 652, 883, 288, 327, 2112, 9848, 922, 1324, 14, 221, 982, 314, 4882, 787, 11999, 12, 314, 17160, 911, 288, 327, 8649, 625, 3853, 3398, 14, 288, 291, 14, 3345, 300, 581, 63, 1569, 275, 6826, 300, 63, 1569, 8, 1569, 12, 6826, 300, 63, 1896, 9, 288, 291, 14, 2798, 63, 576, 14, 409, 63, 576, 480, 3345, 300, 581, 63, 1569, 401, 291, 14, 3345, 300, 581, 63, 1569, 9, 339, 347, 485, 3345, 300, 63, 460, 63, 6814, 63, 2798, 8, 277, 12, 1834, 12, 6826, 300, 63, 1896, 304, 267, 408, 4226, 314, 1736, 402, 6826, 300, 5985, 314, 1834, 436, 11705, 316, 314, 5137, 408, 267, 291, 14, 3345, 300, 581, 63, 1569, 275, 6826, 300, 63, 1569, 8, 1569, 12, 6826, 300, 63, 1896, 9, 398, 327, 23892, 283, 277, 14, 2798, 63, 576, 14, 409, 63, 576, 7, 911, 1678, 314, 6826, 300, 581, 5137, 14, 221, 1010, 267, 327, 8605, 12, 652, 365, 440, 5048, 370, 3222, 13104, 7029, 1380, 440, 641, 314, 17160, 267, 327, 2462, 14, 9336, 642, 1240, 365, 3769, 7934, 641, 1373, 402, 314, 13270, 1159, 267, 327, 7239, 7183, 12, 781, 1471, 295, 13, 6052, 314, 666, 1678, 370, 314, 14041, 2462, 267, 327, 503, 18741, 1260, 10942, 406, 13436, 334, 19614, 2467, 9030, 680, 267, 8574, 63, 6052, 8, 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, 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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 ]
simudream/django-rest-framework
tests/utils.py
84
2061
from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import NoReverseMatch class UsingURLPatterns(object): """ Isolates URL patterns used during testing on the test class itself. For example: class MyTestCase(UsingURLPatterns, TestCase): urlpatterns = [ ... ] def test_something(self): ... """ urls = __name__ def setUp(self): global urlpatterns urlpatterns = self.urlpatterns def tearDown(self): global urlpatterns urlpatterns = [] class MockObject(object): def __init__(self, **kwargs): self._kwargs = kwargs for key, val in kwargs.items(): setattr(self, key, val) def __str__(self): kwargs_str = ', '.join([ '%s=%s' % (key, value) for key, value in sorted(self._kwargs.items()) ]) return '<MockObject %s>' % kwargs_str class MockQueryset(object): def __init__(self, iterable): self.items = iterable def get(self, **lookup): for item in self.items: if all([ getattr(item, key, None) == value for key, value in lookup.items() ]): return item raise ObjectDoesNotExist() class BadType(object): """ When used as a lookup with a `MockQueryset`, these objects will raise a `TypeError`, as occurs in Django when making queryset lookups with an incorrect type for the lookup value. """ def __eq__(self): raise TypeError() def mock_reverse(view_name, args=None, kwargs=None, request=None, format=None): args = args or [] kwargs = kwargs or {} value = (args + list(kwargs.values()) + ['-'])[0] prefix = 'http://example.org' if request else '' suffix = ('.' + format) if (format is not None) else '' return '%s/%s/%s%s/' % (prefix, view_name, value, suffix) def fail_reverse(view_name, args=None, kwargs=None, request=None, format=None): raise NoReverseMatch()
bsd-2-clause
[ 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 421, 199, 533, 11719, 2632, 25662, 8, 785, 304, 272, 408, 272, 6596, 393, 2335, 2851, 7970, 1202, 5309, 5343, 641, 314, 511, 1021, 6337, 14, 272, 2104, 2893, 26, 339, 1021, 4932, 1746, 8, 10369, 2632, 25662, 12, 7640, 304, 267, 26177, 275, 359, 288, 2263, 267, 1622, 398, 347, 511, 63, 10297, 8, 277, 304, 288, 2263, 272, 408, 272, 8187, 275, 636, 354, 363, 339, 347, 3613, 8, 277, 304, 267, 2288, 26177, 267, 26177, 275, 291, 14, 20050, 339, 347, 6766, 8, 277, 304, 267, 2288, 26177, 267, 26177, 275, 942, 421, 199, 533, 4420, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 291, 423, 958, 275, 2074, 267, 367, 790, 12, 1139, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 790, 12, 1139, 9, 339, 347, 636, 495, 721, 277, 304, 267, 2074, 63, 495, 275, 1656, 1987, 904, 779, 288, 1543, 83, 2458, 83, 7, 450, 334, 498, 12, 574, 9, 288, 367, 790, 12, 574, 315, 3355, 8, 277, 423, 958, 14, 1744, 1012, 267, 4794, 267, 372, 2650, 3346, 1692, 450, 83, 3524, 450, 2074, 63, 495, 421, 199, 533, 4420, 6940, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6076, 304, 267, 291, 14, 1744, 275, 6076, 339, 347, 664, 8, 277, 12, 1011, 3892, 304, 267, 367, 1242, 315, 291, 14, 1744, 26, 288, 340, 1006, 779, 355, 2519, 8, 1053, 12, 790, 12, 488, 9, 508, 574, 355, 367, 790, 12, 574, 315, 4237, 14, 1744, 342, 288, 1622, 304, 355, 372, 1242, 267, 746, 24803, 342, 421, 199, 533, 8857, 804, 8, 785, 304, 272, 408, 272, 3979, 1202, 465, 282, 4237, 543, 282, 658, 3346, 6940, 3559, 3520, 2251, 272, 911, 746, 282, 658, 4333, 3559, 465, 11058, 315, 5634, 1380, 10663, 272, 7594, 16807, 543, 376, 8927, 730, 367, 314, 4237, 574, 14, 272, 408, 272, 347, 636, 4077, 721, 277, 304, 267, 746, 3146, 342, 421, 199, 318, 1683, 63, 4471, 8, 1345, 63, 354, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1056, 29, 403, 12, 1475, 29, 403, 304, 272, 1249, 275, 1249, 503, 942, 272, 2074, 275, 2074, 503, 1052, 272, 574, 275, 334, 589, 435, 769, 8, 958, 14, 1459, 1012, 435, 11573, 25945, 16, 61, 272, 2403, 275, 283, 1014, 921, 2694, 14, 1308, 7, 340, 1056, 587, 2125, 272, 4739, 275, 661, 3530, 435, 1475, 9, 340, 334, 908, 365, 440, 488, 9, 587, 2125, 272, 372, 1543, 83, 3149, 83, 3149, 83, 5, 83, 4805, 450, 334, 1861, 12, 2455, 63, 354, 12, 574, 12, 4739, 9, 421, 199, 318, 2449, 63, 4471, 8, 1345, 63, 354, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1056, 29, 403, 12, 1475, 29, 403, 304, 272, 746, 32036, 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 ]
[ 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1018, 14, 16522, 492, 32036, 421, 199, 533, 11719, 2632, 25662, 8, 785, 304, 272, 408, 272, 6596, 393, 2335, 2851, 7970, 1202, 5309, 5343, 641, 314, 511, 1021, 6337, 14, 272, 2104, 2893, 26, 339, 1021, 4932, 1746, 8, 10369, 2632, 25662, 12, 7640, 304, 267, 26177, 275, 359, 288, 2263, 267, 1622, 398, 347, 511, 63, 10297, 8, 277, 304, 288, 2263, 272, 408, 272, 8187, 275, 636, 354, 363, 339, 347, 3613, 8, 277, 304, 267, 2288, 26177, 267, 26177, 275, 291, 14, 20050, 339, 347, 6766, 8, 277, 304, 267, 2288, 26177, 267, 26177, 275, 942, 421, 199, 533, 4420, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 291, 423, 958, 275, 2074, 267, 367, 790, 12, 1139, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 790, 12, 1139, 9, 339, 347, 636, 495, 721, 277, 304, 267, 2074, 63, 495, 275, 1656, 1987, 904, 779, 288, 1543, 83, 2458, 83, 7, 450, 334, 498, 12, 574, 9, 288, 367, 790, 12, 574, 315, 3355, 8, 277, 423, 958, 14, 1744, 1012, 267, 4794, 267, 372, 2650, 3346, 1692, 450, 83, 3524, 450, 2074, 63, 495, 421, 199, 533, 4420, 6940, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6076, 304, 267, 291, 14, 1744, 275, 6076, 339, 347, 664, 8, 277, 12, 1011, 3892, 304, 267, 367, 1242, 315, 291, 14, 1744, 26, 288, 340, 1006, 779, 355, 2519, 8, 1053, 12, 790, 12, 488, 9, 508, 574, 355, 367, 790, 12, 574, 315, 4237, 14, 1744, 342, 288, 1622, 304, 355, 372, 1242, 267, 746, 24803, 342, 421, 199, 533, 8857, 804, 8, 785, 304, 272, 408, 272, 3979, 1202, 465, 282, 4237, 543, 282, 658, 3346, 6940, 3559, 3520, 2251, 272, 911, 746, 282, 658, 4333, 3559, 465, 11058, 315, 5634, 1380, 10663, 272, 7594, 16807, 543, 376, 8927, 730, 367, 314, 4237, 574, 14, 272, 408, 272, 347, 636, 4077, 721, 277, 304, 267, 746, 3146, 342, 421, 199, 318, 1683, 63, 4471, 8, 1345, 63, 354, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1056, 29, 403, 12, 1475, 29, 403, 304, 272, 1249, 275, 1249, 503, 942, 272, 2074, 275, 2074, 503, 1052, 272, 574, 275, 334, 589, 435, 769, 8, 958, 14, 1459, 1012, 435, 11573, 25945, 16, 61, 272, 2403, 275, 283, 1014, 921, 2694, 14, 1308, 7, 340, 1056, 587, 2125, 272, 4739, 275, 661, 3530, 435, 1475, 9, 340, 334, 908, 365, 440, 488, 9, 587, 2125, 272, 372, 1543, 83, 3149, 83, 3149, 83, 5, 83, 4805, 450, 334, 1861, 12, 2455, 63, 354, 12, 574, 12, 4739, 9, 421, 199, 318, 2449, 63, 4471, 8, 1345, 63, 354, 12, 1249, 29, 403, 12, 2074, 29, 403, 12, 1056, 29, 403, 12, 1475, 29, 403, 304, 272, 746, 32036, 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, 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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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 ]
FundacionZamoraTeran/Genios
sugargame/event.py
2
9092
from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject import pygame import pygame.event class _MockEvent(object): def __init__(self, keyval): self.keyval = keyval class Translator(object): key_trans = { 'Alt_L': pygame.K_LALT, 'Alt_R': pygame.K_RALT, 'Control_L': pygame.K_LCTRL, 'Control_R': pygame.K_RCTRL, 'Shift_L': pygame.K_LSHIFT, 'Shift_R': pygame.K_RSHIFT, 'Super_L': pygame.K_LSUPER, 'Super_R': pygame.K_RSUPER, 'KP_Page_Up' : pygame.K_KP9, 'KP_Page_Down' : pygame.K_KP3, 'KP_End' : pygame.K_KP1, 'KP_Home' : pygame.K_KP7, 'KP_Up' : pygame.K_KP8, 'KP_Down' : pygame.K_KP2, 'KP_Left' : pygame.K_KP4, 'KP_Right' : pygame.K_KP6, } mod_map = { pygame.K_LALT: pygame.KMOD_LALT, pygame.K_RALT: pygame.KMOD_RALT, pygame.K_LCTRL: pygame.KMOD_LCTRL, pygame.K_RCTRL: pygame.KMOD_RCTRL, pygame.K_LSHIFT: pygame.KMOD_LSHIFT, pygame.K_RSHIFT: pygame.KMOD_RSHIFT, } def __init__(self, mainwindow, inner_evb): """Initialise the Translator with the windows to which to listen""" self._mainwindow = mainwindow self._inner_evb = inner_evb # Enable events # (add instead of set here because the main window is already realized) self._mainwindow.add_events( Gdk.EventMask.KEY_PRESS_MASK | \ Gdk.EventMask.KEY_RELEASE_MASK | \ Gdk.EventMask.VISIBILITY_NOTIFY_MASK ) self._inner_evb.set_events( Gdk.EventMask.POINTER_MOTION_MASK | \ Gdk.EventMask.POINTER_MOTION_HINT_MASK | \ Gdk.EventMask.BUTTON_MOTION_MASK | \ Gdk.EventMask.BUTTON_PRESS_MASK | \ Gdk.EventMask.BUTTON_RELEASE_MASK ) self._mainwindow.set_can_focus(True) self._inner_evb.set_can_focus(True) # Callback functions to link the event systems self._mainwindow.connect('unrealize', self._quit_cb) self._mainwindow.connect('visibility_notify_event', self._visibility_cb) self._inner_evb.connect('key_press_event', self._keydown_cb) self._inner_evb.connect('key_release_event', self._keyup_cb) self._inner_evb.connect('button_press_event', self._mousedown_cb) self._inner_evb.connect('button_release_event', self._mouseup_cb) self._inner_evb.connect('motion-notify-event', self._mousemove_cb) self._inner_evb.connect('draw', self._draw_cb) self._inner_evb.connect('configure-event', self._resize_cb) self._inner_evb.connect('screen-changed', self._screen_changed_cb) # Internal data self.__stopped = False self.__keystate = [0] * 323 self.__button_state = [0,0,0] self.__mouse_pos = (0,0) self.__repeat = (None, None) self.__held = set() self.__held_time_left = {} self.__held_last_time = {} self.__tick_id = None def hook_pygame(self): pygame.key.get_pressed = self._get_pressed pygame.key.set_repeat = self._set_repeat pygame.mouse.get_pressed = self._get_mouse_pressed pygame.mouse.get_pos = self._get_mouse_pos def update_display(self): pygame.event.post(pygame.event.Event(pygame.VIDEOEXPOSE)) def _draw_cb(self, widget, event): if pygame.display.get_init(): pygame.event.post(pygame.event.Event(pygame.VIDEOEXPOSE)) return True def _resize_cb(self, widget, event): evt = pygame.event.Event(pygame.VIDEORESIZE, size=(event.width,event.height), width=event.width, height=event.height) pygame.event.post(evt) return False # continue processing def _screen_changed_cb(self, widget, previous_screen): if pygame.display.get_init(): self.update_display() def _quit_cb(self, data=None): self.__stopped = True pygame.event.post(pygame.event.Event(pygame.QUIT)) def _visibility_cb(self, widget, event): if pygame.display.get_init(): self.update_display() return False def _keydown_cb(self, widget, event): key = event.keyval if key in self.__held: return True else: if self.__repeat[0] is not None: self.__held_last_time[key] = pygame.time.get_ticks() self.__held_time_left[key] = self.__repeat[0] self.__held.add(key) return self._keyevent(widget, event, pygame.KEYDOWN) def _keyup_cb(self, widget, event): key = event.keyval if self.__repeat[0] is not None: if key in self.__held: # This is possibly false if set_repeat() is called with a key held del self.__held_time_left[key] del self.__held_last_time[key] self.__held.discard(key) return self._keyevent(widget, event, pygame.KEYUP) def _keymods(self): mod = 0 for key_val, mod_val in self.mod_map.iteritems(): mod |= self.__keystate[key_val] and mod_val return mod def _keyevent(self, widget, event, type): key = Gdk.keyval_name(event.keyval) if key is None: # No idea what this key is. return False keycode = None if key in self.key_trans: keycode = self.key_trans[key] elif hasattr(pygame, 'K_'+key.upper()): keycode = getattr(pygame, 'K_'+key.upper()) elif hasattr(pygame, 'K_'+key.lower()): keycode = getattr(pygame, 'K_'+key.lower()) elif key == 'XF86Start': # view source request, specially handled... self._mainwindow.view_source() else: print 'Key %s unrecognized' % key if keycode is not None: if type == pygame.KEYDOWN: mod = self._keymods() self.__keystate[keycode] = type == pygame.KEYDOWN if type == pygame.KEYUP: mod = self._keymods() ukey = unichr(Gdk.keyval_to_unicode(event.keyval)) if ukey == '\000': ukey = '' evt = pygame.event.Event(type, key=keycode, unicode=ukey, mod=mod) self._post(evt) return True def _get_pressed(self): return self.__keystate def _get_mouse_pressed(self): return self.__button_state def _mousedown_cb(self, widget, event): self.__button_state[event.button-1] = 1 return self._mouseevent(widget, event, pygame.MOUSEBUTTONDOWN) def _mouseup_cb(self, widget, event): self.__button_state[event.button-1] = 0 return self._mouseevent(widget, event, pygame.MOUSEBUTTONUP) def _mouseevent(self, widget, event, type): evt = pygame.event.Event(type, button=event.button, pos=(event.x, event.y)) self._post(evt) return True def _mousemove_cb(self, widget, event): # From http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/ # if this is a hint, then let's get all the necessary # information, if not it's all we need. if event.is_hint: win, x, y, state = event.window.get_device_position(event.device) else: x = event.x y = event.y state = event.get_state() rel = (x - self.__mouse_pos[0], y - self.__mouse_pos[1]) self.__mouse_pos = (x, y) self.__button_state = [ state & Gdk.ModifierType.BUTTON1_MASK and 1 or 0, state & Gdk.ModifierType.BUTTON2_MASK and 1 or 0, state & Gdk.ModifierType.BUTTON3_MASK and 1 or 0, ] evt = pygame.event.Event(pygame.MOUSEMOTION, pos=self.__mouse_pos, rel=rel, buttons=self.__button_state) self._post(evt) return True def _tick_cb(self): cur_time = pygame.time.get_ticks() for key in self.__held: delta = cur_time - self.__held_last_time[key] self.__held_last_time[key] = cur_time self.__held_time_left[key] -= delta if self.__held_time_left[key] <= 0: self.__held_time_left[key] = self.__repeat[1] self._keyevent(None, _MockEvent(key), pygame.KEYDOWN) return True def _set_repeat(self, delay=None, interval=None): if delay is not None and self.__repeat[0] is None: self.__tick_id = GObject.timeout_add(10, self._tick_cb) elif delay is None and self.__repeat[0] is not None: GObject.source_remove(self.__tick_id) self.__repeat = (delay, interval) def _get_mouse_pos(self): return self.__mouse_pos def _post(self, evt): try: pygame.event.post(evt) except pygame.error, e: if str(e) == 'Event queue full': pass else: raise e
mit
[ 504, 18895, 14, 8421, 492, 11424, 199, 504, 18895, 14, 8421, 492, 31392, 199, 504, 18895, 14, 8421, 492, 31264, 199, 646, 9193, 199, 646, 9193, 14, 1430, 421, 199, 533, 485, 3346, 2390, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 790, 637, 304, 267, 291, 14, 31217, 275, 790, 637, 199, 199, 533, 6266, 13693, 8, 785, 304, 272, 790, 63, 1515, 275, 469, 267, 283, 16985, 63, 44, 356, 9193, 14, 43, 63, 44, 19600, 12, 267, 283, 16985, 63, 50, 356, 9193, 14, 43, 63, 50, 19600, 12, 267, 283, 3717, 63, 44, 356, 9193, 14, 43, 63, 44, 22584, 12, 267, 283, 3717, 63, 50, 356, 9193, 14, 43, 63, 50, 22584, 12, 267, 283, 14379, 63, 44, 356, 9193, 14, 43, 63, 44, 18013, 12, 267, 283, 14379, 63, 50, 356, 9193, 14, 43, 63, 50, 18013, 12, 267, 283, 11823, 63, 44, 356, 9193, 14, 43, 63, 5296, 2160, 540, 12, 267, 283, 11823, 63, 50, 356, 9193, 14, 43, 63, 50, 7380, 540, 12, 267, 283, 24974, 63, 3276, 63, 1721, 7, 520, 9193, 14, 43, 63, 24974, 25, 12, 267, 283, 24974, 63, 3276, 63, 3514, 7, 520, 9193, 14, 43, 63, 24974, 19, 12, 267, 283, 24974, 63, 3005, 7, 520, 9193, 14, 43, 63, 24974, 17, 12, 267, 283, 24974, 63, 12054, 7, 520, 9193, 14, 43, 63, 24974, 23, 12, 267, 283, 24974, 63, 1721, 7, 520, 9193, 14, 43, 63, 24974, 24, 12, 267, 283, 24974, 63, 3514, 7, 520, 9193, 14, 43, 63, 24974, 18, 12, 267, 283, 24974, 63, 8185, 7, 520, 9193, 14, 43, 63, 24974, 20, 12, 267, 283, 24974, 63, 9121, 7, 520, 9193, 14, 43, 63, 24974, 22, 12, 339, 789, 339, 3413, 63, 1130, 275, 469, 267, 9193, 14, 43, 63, 44, 19600, 26, 9193, 14, 43, 8816, 63, 44, 19600, 12, 267, 9193, 14, 43, 63, 50, 19600, 26, 9193, 14, 43, 8816, 63, 50, 19600, 12, 267, 9193, 14, 43, 63, 44, 22584, 26, 9193, 14, 43, 8816, 63, 44, 22584, 12, 267, 9193, 14, 43, 63, 50, 22584, 26, 9193, 14, 43, 8816, 63, 50, 22584, 12, 267, 9193, 14, 43, 63, 44, 18013, 26, 9193, 14, 43, 8816, 63, 44, 18013, 12, 267, 9193, 14, 43, 63, 50, 18013, 26, 9193, 14, 43, 8816, 63, 50, 18013, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 2446, 3806, 12, 6506, 63, 6857, 66, 304, 267, 408, 5733, 572, 314, 6266, 13693, 543, 314, 10061, 370, 1314, 370, 6938, 624, 267, 291, 423, 973, 3806, 275, 2446, 3806, 267, 291, 423, 5216, 63, 6857, 66, 275, 6506, 63, 6857, 66, 398, 327, 12030, 4474, 267, 327, 334, 525, 3140, 402, 663, 2348, 2952, 314, 2446, 4353, 365, 2575, 3363, 1759, 9, 267, 291, 423, 973, 3806, 14, 525, 63, 4368, 8, 288, 31392, 14, 2390, 5144, 14, 3078, 63, 5786, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 3078, 63, 19736, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 11793, 9002, 63, 24972, 63, 12880, 267, 776, 398, 291, 423, 5216, 63, 6857, 66, 14, 409, 63, 4368, 8, 288, 31392, 14, 2390, 5144, 14, 11260, 63, 27235, 1075, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 11260, 63, 27235, 1075, 63, 32456, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 27235, 1075, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 5786, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 19736, 63, 12880, 267, 776, 398, 291, 423, 973, 3806, 14, 409, 63, 2425, 63, 12283, 8, 549, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 409, 63, 2425, 63, 12283, 8, 549, 9, 398, 327, 17555, 3423, 370, 2142, 314, 1566, 10460, 267, 291, 423, 973, 3806, 14, 2242, 360, 324, 3093, 794, 297, 291, 423, 10589, 63, 2894, 9, 267, 291, 423, 973, 3806, 14, 2242, 360, 11269, 63, 6814, 63, 1430, 297, 291, 423, 11269, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 498, 63, 2915, 63, 1430, 297, 291, 423, 498, 2110, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 498, 63, 3221, 63, 1430, 297, 291, 423, 498, 384, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 3887, 63, 2915, 63, 1430, 297, 291, 423, 573, 2972, 944, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 3887, 63, 3221, 63, 1430, 297, 291, 423, 10544, 384, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 15335, 13, 6814, 13, 1430, 297, 291, 423, 10544, 1185, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 5485, 297, 291, 423, 5485, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 6472, 13, 1430, 297, 291, 423, 8709, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 5410, 13, 2489, 297, 291, 423, 5410, 63, 2489, 63, 2894, 9, 398, 327, 12624, 666, 267, 291, 855, 14661, 275, 756, 267, 291, 855, 498, 929, 275, 359, 16, 61, 627, 650, 1789, 267, 291, 855, 3887, 63, 929, 275, 359, 16, 12, 16, 12, 16, 61, 267, 291, 855, 10544, 63, 1712, 275, 334, 16, 12, 16, 9, 267, 291, 855, 8755, 275, 334, 403, 12, 488, 9, 267, 291, 855, 31415, 275, 663, 342, 267, 291, 855, 31415, 63, 521, 63, 3039, 275, 1052, 267, 291, 855, 31415, 63, 2019, 63, 521, 275, 1052, 267, 291, 855, 8284, 63, 344, 275, 488, 339, 347, 5759, 63, 22278, 8, 277, 304, 267, 9193, 14, 498, 14, 362, 63, 30455, 275, 291, 423, 362, 63, 30455, 267, 9193, 14, 498, 14, 409, 63, 8755, 275, 291, 423, 409, 63, 8755, 267, 9193, 14, 10544, 14, 362, 63, 30455, 275, 291, 423, 362, 63, 10544, 63, 30455, 267, 9193, 14, 10544, 14, 362, 63, 1712, 275, 291, 423, 362, 63, 10544, 63, 1712, 339, 347, 1678, 63, 2918, 8, 277, 304, 267, 9193, 14 ]
[ 18895, 14, 8421, 492, 11424, 199, 504, 18895, 14, 8421, 492, 31392, 199, 504, 18895, 14, 8421, 492, 31264, 199, 646, 9193, 199, 646, 9193, 14, 1430, 421, 199, 533, 485, 3346, 2390, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 790, 637, 304, 267, 291, 14, 31217, 275, 790, 637, 199, 199, 533, 6266, 13693, 8, 785, 304, 272, 790, 63, 1515, 275, 469, 267, 283, 16985, 63, 44, 356, 9193, 14, 43, 63, 44, 19600, 12, 267, 283, 16985, 63, 50, 356, 9193, 14, 43, 63, 50, 19600, 12, 267, 283, 3717, 63, 44, 356, 9193, 14, 43, 63, 44, 22584, 12, 267, 283, 3717, 63, 50, 356, 9193, 14, 43, 63, 50, 22584, 12, 267, 283, 14379, 63, 44, 356, 9193, 14, 43, 63, 44, 18013, 12, 267, 283, 14379, 63, 50, 356, 9193, 14, 43, 63, 50, 18013, 12, 267, 283, 11823, 63, 44, 356, 9193, 14, 43, 63, 5296, 2160, 540, 12, 267, 283, 11823, 63, 50, 356, 9193, 14, 43, 63, 50, 7380, 540, 12, 267, 283, 24974, 63, 3276, 63, 1721, 7, 520, 9193, 14, 43, 63, 24974, 25, 12, 267, 283, 24974, 63, 3276, 63, 3514, 7, 520, 9193, 14, 43, 63, 24974, 19, 12, 267, 283, 24974, 63, 3005, 7, 520, 9193, 14, 43, 63, 24974, 17, 12, 267, 283, 24974, 63, 12054, 7, 520, 9193, 14, 43, 63, 24974, 23, 12, 267, 283, 24974, 63, 1721, 7, 520, 9193, 14, 43, 63, 24974, 24, 12, 267, 283, 24974, 63, 3514, 7, 520, 9193, 14, 43, 63, 24974, 18, 12, 267, 283, 24974, 63, 8185, 7, 520, 9193, 14, 43, 63, 24974, 20, 12, 267, 283, 24974, 63, 9121, 7, 520, 9193, 14, 43, 63, 24974, 22, 12, 339, 789, 339, 3413, 63, 1130, 275, 469, 267, 9193, 14, 43, 63, 44, 19600, 26, 9193, 14, 43, 8816, 63, 44, 19600, 12, 267, 9193, 14, 43, 63, 50, 19600, 26, 9193, 14, 43, 8816, 63, 50, 19600, 12, 267, 9193, 14, 43, 63, 44, 22584, 26, 9193, 14, 43, 8816, 63, 44, 22584, 12, 267, 9193, 14, 43, 63, 50, 22584, 26, 9193, 14, 43, 8816, 63, 50, 22584, 12, 267, 9193, 14, 43, 63, 44, 18013, 26, 9193, 14, 43, 8816, 63, 44, 18013, 12, 267, 9193, 14, 43, 63, 50, 18013, 26, 9193, 14, 43, 8816, 63, 50, 18013, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 2446, 3806, 12, 6506, 63, 6857, 66, 304, 267, 408, 5733, 572, 314, 6266, 13693, 543, 314, 10061, 370, 1314, 370, 6938, 624, 267, 291, 423, 973, 3806, 275, 2446, 3806, 267, 291, 423, 5216, 63, 6857, 66, 275, 6506, 63, 6857, 66, 398, 327, 12030, 4474, 267, 327, 334, 525, 3140, 402, 663, 2348, 2952, 314, 2446, 4353, 365, 2575, 3363, 1759, 9, 267, 291, 423, 973, 3806, 14, 525, 63, 4368, 8, 288, 31392, 14, 2390, 5144, 14, 3078, 63, 5786, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 3078, 63, 19736, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 11793, 9002, 63, 24972, 63, 12880, 267, 776, 398, 291, 423, 5216, 63, 6857, 66, 14, 409, 63, 4368, 8, 288, 31392, 14, 2390, 5144, 14, 11260, 63, 27235, 1075, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 11260, 63, 27235, 1075, 63, 32456, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 27235, 1075, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 5786, 63, 12880, 1204, 971, 288, 31392, 14, 2390, 5144, 14, 13272, 63, 19736, 63, 12880, 267, 776, 398, 291, 423, 973, 3806, 14, 409, 63, 2425, 63, 12283, 8, 549, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 409, 63, 2425, 63, 12283, 8, 549, 9, 398, 327, 17555, 3423, 370, 2142, 314, 1566, 10460, 267, 291, 423, 973, 3806, 14, 2242, 360, 324, 3093, 794, 297, 291, 423, 10589, 63, 2894, 9, 267, 291, 423, 973, 3806, 14, 2242, 360, 11269, 63, 6814, 63, 1430, 297, 291, 423, 11269, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 498, 63, 2915, 63, 1430, 297, 291, 423, 498, 2110, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 498, 63, 3221, 63, 1430, 297, 291, 423, 498, 384, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 3887, 63, 2915, 63, 1430, 297, 291, 423, 573, 2972, 944, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 3887, 63, 3221, 63, 1430, 297, 291, 423, 10544, 384, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 15335, 13, 6814, 13, 1430, 297, 291, 423, 10544, 1185, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 5485, 297, 291, 423, 5485, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 6472, 13, 1430, 297, 291, 423, 8709, 63, 2894, 9, 267, 291, 423, 5216, 63, 6857, 66, 14, 2242, 360, 5410, 13, 2489, 297, 291, 423, 5410, 63, 2489, 63, 2894, 9, 398, 327, 12624, 666, 267, 291, 855, 14661, 275, 756, 267, 291, 855, 498, 929, 275, 359, 16, 61, 627, 650, 1789, 267, 291, 855, 3887, 63, 929, 275, 359, 16, 12, 16, 12, 16, 61, 267, 291, 855, 10544, 63, 1712, 275, 334, 16, 12, 16, 9, 267, 291, 855, 8755, 275, 334, 403, 12, 488, 9, 267, 291, 855, 31415, 275, 663, 342, 267, 291, 855, 31415, 63, 521, 63, 3039, 275, 1052, 267, 291, 855, 31415, 63, 2019, 63, 521, 275, 1052, 267, 291, 855, 8284, 63, 344, 275, 488, 339, 347, 5759, 63, 22278, 8, 277, 304, 267, 9193, 14, 498, 14, 362, 63, 30455, 275, 291, 423, 362, 63, 30455, 267, 9193, 14, 498, 14, 409, 63, 8755, 275, 291, 423, 409, 63, 8755, 267, 9193, 14, 10544, 14, 362, 63, 30455, 275, 291, 423, 362, 63, 10544, 63, 30455, 267, 9193, 14, 10544, 14, 362, 63, 1712, 275, 291, 423, 362, 63, 10544, 63, 1712, 339, 347, 1678, 63, 2918, 8, 277, 304, 267, 9193, 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, 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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 ]
gdub/django
tests/prefetch_related/test_uuid.py
291
4347
from __future__ import unicode_literals from django.test import TestCase from .models import Flea, House, Person, Pet, Room class UUIDPrefetchRelated(TestCase): def test_prefetch_related_from_uuid_model(self): Pet.objects.create(name='Fifi').people.add( Person.objects.create(name='Ellen'), Person.objects.create(name='George'), ) with self.assertNumQueries(2): pet = Pet.objects.prefetch_related('people').get(name='Fifi') with self.assertNumQueries(0): self.assertEqual(2, len(pet.people.all())) def test_prefetch_related_to_uuid_model(self): Person.objects.create(name='Bella').pets.add( Pet.objects.create(name='Socks'), Pet.objects.create(name='Coffee'), ) with self.assertNumQueries(2): person = Person.objects.prefetch_related('pets').get(name='Bella') with self.assertNumQueries(0): self.assertEqual(2, len(person.pets.all())) def test_prefetch_related_from_uuid_model_to_uuid_model(self): fleas = [Flea.objects.create() for i in range(3)] Pet.objects.create(name='Fifi').fleas_hosted.add(*fleas) Pet.objects.create(name='Bobo').fleas_hosted.add(*fleas) with self.assertNumQueries(2): pet = Pet.objects.prefetch_related('fleas_hosted').get(name='Fifi') with self.assertNumQueries(0): self.assertEqual(3, len(pet.fleas_hosted.all())) with self.assertNumQueries(2): flea = Flea.objects.prefetch_related('pets_visited').get(pk=fleas[0].pk) with self.assertNumQueries(0): self.assertEqual(2, len(flea.pets_visited.all())) class UUIDPrefetchRelatedLookups(TestCase): @classmethod def setUpTestData(cls): house = House.objects.create(name='Redwood', address='Arcata') room = Room.objects.create(name='Racoon', house=house) fleas = [Flea.objects.create(current_room=room) for i in range(3)] pet = Pet.objects.create(name='Spooky') pet.fleas_hosted.add(*fleas) person = Person.objects.create(name='Bob') person.houses.add(house) person.pets.add(pet) person.fleas_hosted.add(*fleas) def test_from_uuid_pk_lookup_uuid_pk_integer_pk(self): # From uuid-pk model, prefetch <uuid-pk model>.<integer-pk model>: with self.assertNumQueries(4): spooky = Pet.objects.prefetch_related('fleas_hosted__current_room__house').get(name='Spooky') with self.assertNumQueries(0): self.assertEqual('Racoon', spooky.fleas_hosted.all()[0].current_room.name) def test_from_uuid_pk_lookup_integer_pk2_uuid_pk2(self): # From uuid-pk model, prefetch <integer-pk model>.<integer-pk model>.<uuid-pk model>.<uuid-pk model>: with self.assertNumQueries(5): spooky = Pet.objects.prefetch_related('people__houses__rooms__fleas').get(name='Spooky') with self.assertNumQueries(0): self.assertEqual(3, len(spooky.people.all()[0].houses.all()[0].rooms.all()[0].fleas.all())) def test_from_integer_pk_lookup_uuid_pk_integer_pk(self): # From integer-pk model, prefetch <uuid-pk model>.<integer-pk model>: with self.assertNumQueries(3): racoon = Room.objects.prefetch_related('fleas__people_visited').get(name='Racoon') with self.assertNumQueries(0): self.assertEqual('Bob', racoon.fleas.all()[0].people_visited.all()[0].name) def test_from_integer_pk_lookup_integer_pk_uuid_pk(self): # From integer-pk model, prefetch <integer-pk model>.<uuid-pk model>: with self.assertNumQueries(3): redwood = House.objects.prefetch_related('rooms__fleas').get(name='Redwood') with self.assertNumQueries(0): self.assertEqual(3, len(redwood.rooms.all()[0].fleas.all())) def test_from_integer_pk_lookup_integer_pk_uuid_pk_uuid_pk(self): # From integer-pk model, prefetch <integer-pk model>.<uuid-pk model>.<uuid-pk model>: with self.assertNumQueries(4): redwood = House.objects.prefetch_related('rooms__fleas__pets_visited').get(name='Redwood') with self.assertNumQueries(0): self.assertEqual('Spooky', redwood.rooms.all()[0].fleas.all()[0].pets_visited.all()[0].name)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 481, 274, 65, 12, 869, 7130, 12, 8028, 12, 31449, 12, 6848, 676, 421, 199, 533, 11134, 18441, 2367, 13885, 8, 1746, 304, 339, 347, 511, 63, 15576, 63, 2407, 63, 504, 63, 2580, 63, 1238, 8, 277, 304, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 38, 1903, 1959, 13562, 14, 525, 8, 288, 8028, 14, 1462, 14, 981, 8, 354, 534, 10420, 552, 659, 288, 8028, 14, 1462, 14, 981, 8, 354, 534, 4240, 24591, 659, 267, 776, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 299, 386, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 13562, 1959, 362, 8, 354, 534, 38, 1903, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 8096, 14, 13562, 14, 452, 4059, 339, 347, 511, 63, 15576, 63, 2407, 63, 475, 63, 2580, 63, 1238, 8, 277, 304, 267, 8028, 14, 1462, 14, 981, 8, 354, 534, 34, 352, 416, 1959, 14582, 14, 525, 8, 288, 31449, 14, 1462, 14, 981, 8, 354, 534, 51, 27416, 659, 288, 31449, 14, 1462, 14, 981, 8, 354, 534, 967, 24715, 659, 267, 776, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 4954, 275, 8028, 14, 1462, 14, 15576, 63, 2407, 360, 14582, 1959, 362, 8, 354, 534, 34, 352, 416, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 5484, 14, 14582, 14, 452, 4059, 339, 347, 511, 63, 15576, 63, 2407, 63, 504, 63, 2580, 63, 1238, 63, 475, 63, 2580, 63, 1238, 8, 277, 304, 267, 289, 274, 305, 275, 359, 38, 274, 65, 14, 1462, 14, 981, 342, 367, 284, 315, 1425, 8, 19, 1874, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 38, 1903, 1959, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 2208, 656, 1959, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 299, 386, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 63, 24127, 1959, 362, 8, 354, 534, 38, 1903, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 19, 12, 822, 8, 8096, 14, 21599, 305, 63, 24127, 14, 452, 4059, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 289, 274, 65, 275, 481, 274, 65, 14, 1462, 14, 15576, 63, 2407, 360, 14582, 63, 21736, 1959, 362, 8, 2051, 29, 21599, 305, 59, 16, 1055, 2051, 9, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 21599, 65, 14, 14582, 63, 21736, 14, 452, 4059, 421, 199, 533, 11134, 18441, 2367, 13885, 7521, 83, 8, 1746, 304, 339, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 25284, 275, 869, 7130, 14, 1462, 14, 981, 8, 354, 534, 10858, 22736, 297, 2287, 534, 27604, 419, 358, 267, 14726, 275, 6848, 676, 14, 1462, 14, 981, 8, 354, 534, 1537, 331, 265, 297, 25284, 29, 6740, 9, 267, 289, 274, 305, 275, 359, 38, 274, 65, 14, 1462, 14, 981, 8, 1818, 63, 11245, 29, 11245, 9, 367, 284, 315, 1425, 8, 19, 1874, 267, 299, 386, 275, 31449, 14, 1462, 14, 981, 8, 354, 534, 51, 555, 745, 89, 358, 267, 299, 386, 14, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 267, 4954, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 22593, 358, 267, 4954, 14, 526, 5589, 14, 525, 8, 6740, 9, 267, 4954, 14, 14582, 14, 525, 8, 8096, 9, 267, 4954, 14, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 339, 347, 511, 63, 504, 63, 2580, 63, 2051, 63, 3892, 63, 2580, 63, 2051, 63, 4115, 63, 2051, 8, 277, 304, 267, 327, 11606, 5377, 13, 2051, 1402, 12, 21544, 665, 2580, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 20, 304, 288, 25664, 745, 89, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 63, 24127, 363, 1818, 63, 11245, 363, 6740, 1959, 362, 8, 354, 534, 51, 555, 745, 89, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 360, 1537, 331, 265, 297, 25664, 745, 89, 14, 21599, 305, 63, 24127, 14, 452, 3430, 16, 1055, 1818, 63, 11245, 14, 354, 9, 339, 347, 511, 63, 504, 63, 2580, 63, 2051, 63, 3892, 63, 4115, 63, 2051, 18, 63, 2580, 63, 2051, 18, 8, 277, 304, 267, 327, 11606, 5377, 13, 2051, 1402, 12, 21544, 665, 4115, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 10827, 28, 2580, 13, 2051, 1402, 10827, 28, 2580, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 21, 304, 288, 25664, 745, 89, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 13562, 363, 526, 5589, 363, 29191, 363, 21599, 305, 1959, 362, 8, 354, 534, 51, 555, 745, 89, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 19, 12, 822, 8, 22522, 745, 89, 14, 13562, 14, 452, 3430, 16, 1055, 526, 5589, 14, 452, 3430, 16, 1055, 29191, 14, 452, 3430, 16, 1055, 21599, 305, 14, 452, 4059, 339, 347, 511, 63, 504, 63, 4115, 63, 2051, 63, 3892, 63, 2580, 63, 2051, 63, 4115, 63, 2051, 8, 277, 304, 267, 327, 11606, 3000, 13, 2051, 1402, 12, 21544, 665, 2580, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 19, 304, 288, 660, 331, 265, 275, 6848, 676, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 363, 13562, 63, 21736, 1959, 362, 8, 354, 534, 1537, 331, 265, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 360, 22593, 297, 660, 331, 265, 14, 21599, 305, 14, 452, 3430, 16, 1055, 13562, 63, 21736, 14, 452, 3430, 16, 1055, 354, 9, 339, 347, 511, 63, 504, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 481, 274, 65, 12, 869, 7130, 12, 8028, 12, 31449, 12, 6848, 676, 421, 199, 533, 11134, 18441, 2367, 13885, 8, 1746, 304, 339, 347, 511, 63, 15576, 63, 2407, 63, 504, 63, 2580, 63, 1238, 8, 277, 304, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 38, 1903, 1959, 13562, 14, 525, 8, 288, 8028, 14, 1462, 14, 981, 8, 354, 534, 10420, 552, 659, 288, 8028, 14, 1462, 14, 981, 8, 354, 534, 4240, 24591, 659, 267, 776, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 299, 386, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 13562, 1959, 362, 8, 354, 534, 38, 1903, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 8096, 14, 13562, 14, 452, 4059, 339, 347, 511, 63, 15576, 63, 2407, 63, 475, 63, 2580, 63, 1238, 8, 277, 304, 267, 8028, 14, 1462, 14, 981, 8, 354, 534, 34, 352, 416, 1959, 14582, 14, 525, 8, 288, 31449, 14, 1462, 14, 981, 8, 354, 534, 51, 27416, 659, 288, 31449, 14, 1462, 14, 981, 8, 354, 534, 967, 24715, 659, 267, 776, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 4954, 275, 8028, 14, 1462, 14, 15576, 63, 2407, 360, 14582, 1959, 362, 8, 354, 534, 34, 352, 416, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 5484, 14, 14582, 14, 452, 4059, 339, 347, 511, 63, 15576, 63, 2407, 63, 504, 63, 2580, 63, 1238, 63, 475, 63, 2580, 63, 1238, 8, 277, 304, 267, 289, 274, 305, 275, 359, 38, 274, 65, 14, 1462, 14, 981, 342, 367, 284, 315, 1425, 8, 19, 1874, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 38, 1903, 1959, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 267, 31449, 14, 1462, 14, 981, 8, 354, 534, 2208, 656, 1959, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 299, 386, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 63, 24127, 1959, 362, 8, 354, 534, 38, 1903, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 19, 12, 822, 8, 8096, 14, 21599, 305, 63, 24127, 14, 452, 4059, 398, 543, 291, 14, 16463, 8, 18, 304, 288, 289, 274, 65, 275, 481, 274, 65, 14, 1462, 14, 15576, 63, 2407, 360, 14582, 63, 21736, 1959, 362, 8, 2051, 29, 21599, 305, 59, 16, 1055, 2051, 9, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 18, 12, 822, 8, 21599, 65, 14, 14582, 63, 21736, 14, 452, 4059, 421, 199, 533, 11134, 18441, 2367, 13885, 7521, 83, 8, 1746, 304, 339, 768, 3744, 272, 347, 3613, 16550, 8, 1886, 304, 267, 25284, 275, 869, 7130, 14, 1462, 14, 981, 8, 354, 534, 10858, 22736, 297, 2287, 534, 27604, 419, 358, 267, 14726, 275, 6848, 676, 14, 1462, 14, 981, 8, 354, 534, 1537, 331, 265, 297, 25284, 29, 6740, 9, 267, 289, 274, 305, 275, 359, 38, 274, 65, 14, 1462, 14, 981, 8, 1818, 63, 11245, 29, 11245, 9, 367, 284, 315, 1425, 8, 19, 1874, 267, 299, 386, 275, 31449, 14, 1462, 14, 981, 8, 354, 534, 51, 555, 745, 89, 358, 267, 299, 386, 14, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 267, 4954, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 22593, 358, 267, 4954, 14, 526, 5589, 14, 525, 8, 6740, 9, 267, 4954, 14, 14582, 14, 525, 8, 8096, 9, 267, 4954, 14, 21599, 305, 63, 24127, 14, 525, 2031, 21599, 305, 9, 339, 347, 511, 63, 504, 63, 2580, 63, 2051, 63, 3892, 63, 2580, 63, 2051, 63, 4115, 63, 2051, 8, 277, 304, 267, 327, 11606, 5377, 13, 2051, 1402, 12, 21544, 665, 2580, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 20, 304, 288, 25664, 745, 89, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 63, 24127, 363, 1818, 63, 11245, 363, 6740, 1959, 362, 8, 354, 534, 51, 555, 745, 89, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 360, 1537, 331, 265, 297, 25664, 745, 89, 14, 21599, 305, 63, 24127, 14, 452, 3430, 16, 1055, 1818, 63, 11245, 14, 354, 9, 339, 347, 511, 63, 504, 63, 2580, 63, 2051, 63, 3892, 63, 4115, 63, 2051, 18, 63, 2580, 63, 2051, 18, 8, 277, 304, 267, 327, 11606, 5377, 13, 2051, 1402, 12, 21544, 665, 4115, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 10827, 28, 2580, 13, 2051, 1402, 10827, 28, 2580, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 21, 304, 288, 25664, 745, 89, 275, 31449, 14, 1462, 14, 15576, 63, 2407, 360, 13562, 363, 526, 5589, 363, 29191, 363, 21599, 305, 1959, 362, 8, 354, 534, 51, 555, 745, 89, 358, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 19, 12, 822, 8, 22522, 745, 89, 14, 13562, 14, 452, 3430, 16, 1055, 526, 5589, 14, 452, 3430, 16, 1055, 29191, 14, 452, 3430, 16, 1055, 21599, 305, 14, 452, 4059, 339, 347, 511, 63, 504, 63, 4115, 63, 2051, 63, 3892, 63, 2580, 63, 2051, 63, 4115, 63, 2051, 8, 277, 304, 267, 327, 11606, 3000, 13, 2051, 1402, 12, 21544, 665, 2580, 13, 2051, 1402, 10827, 28, 4115, 13, 2051, 1402, 20020, 267, 543, 291, 14, 16463, 8, 19, 304, 288, 660, 331, 265, 275, 6848, 676, 14, 1462, 14, 15576, 63, 2407, 360, 21599, 305, 363, 13562, 63, 21736, 1959, 362, 8, 354, 534, 1537, 331, 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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 ]
psyhofreak/ft-engine
mysql-test/suite/tokudb/t/change_column_int_key.py
56
1671
#!/usr/bin/env python import sys def gen_test(types): for a in range(len(types)): for b in range(len(types)): if a < b: print print "CREATE TABLE t (a %s, PRIMARY KEY(a));" % (types[a]) print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/" print "--error ER_UNSUPPORTED_EXTENSION" print "ALTER TABLE t CHANGE COLUMN a a %s;" % (types[b]) print "DROP TABLE t;" print "CREATE TABLE t (a %s, KEY(a));" % (types[a]) print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/" print "--error ER_UNSUPPORTED_EXTENSION" print "ALTER TABLE t CHANGE COLUMN a a %s;" % (types[b]) print "DROP TABLE t;" print "CREATE TABLE t (a %s, CLUSTERING KEY(a));" % (types[a]) print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/" print "--error ER_UNSUPPORTED_EXTENSION" print "ALTER TABLE t CHANGE COLUMN a a %s;" % (types[b]) print "DROP TABLE t;" def main(): print "# this test is generated by change_int_key.py" print "# ensure that changing an int column that is part of a key is not hot" print "--disable_warnings" print "DROP TABLE IF EXISTS t;" print "--enable_warnings" print "SET SESSION DEFAULT_STORAGE_ENGINE=\"TokuDB\";" print "SET SESSION TOKUDB_DISABLE_SLOW_ALTER=1;" gen_test([ "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT" ]) gen_test([ "TINYINT UNSIGNED", "SMALLINT UNSIGNED", "MEDIUMINT UNSIGNED", "INT UNSIGNED", "BIGINT UNSIGNED" ]) return 0 sys.exit(main())
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 318, 3805, 63, 396, 8, 1313, 304, 272, 367, 282, 315, 1425, 8, 552, 8, 1313, 2298, 267, 367, 330, 315, 1425, 8, 552, 8, 1313, 2298, 288, 340, 282, 665, 330, 26, 355, 870, 355, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 19770, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 2234, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 2234, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 13354, 22992, 1206, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 199, 199, 318, 2446, 837, 272, 870, 5426, 642, 511, 365, 4046, 701, 1570, 63, 442, 63, 498, 14, 647, 2, 272, 870, 5426, 4868, 626, 13729, 376, 1109, 2763, 626, 365, 1777, 402, 282, 790, 365, 440, 18469, 2, 272, 870, 4320, 5993, 63, 5451, 2, 272, 870, 298, 14764, 9934, 8036, 23875, 307, 9426, 272, 870, 4320, 4296, 63, 5451, 2, 272, 870, 298, 3597, 428, 9577, 6186, 63, 17467, 63, 15956, 8178, 29117, 85, 2846, 4451, 9426, 272, 870, 298, 3597, 428, 9577, 2296, 43, 53, 2846, 63, 13052, 63, 51, 5896, 63, 19350, 29, 17, 9426, 272, 3805, 63, 396, 779, 298, 31178, 2919, 401, 298, 28570, 2919, 401, 298, 9754, 2639, 2919, 401, 298, 2919, 401, 298, 18643, 2919, 2, 4794, 272, 3805, 63, 396, 779, 298, 31178, 2919, 32708, 3203, 1149, 401, 298, 28570, 2919, 32708, 3203, 1149, 401, 298, 9754, 2639, 2919, 32708, 3203, 1149, 401, 298, 2919, 32708, 3203, 1149, 401, 298, 18643, 2919, 32708, 3203, 1149, 2, 4794, 272, 372, 378, 199, 1274, 14, 2224, 8, 973, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 318, 3805, 63, 396, 8, 1313, 304, 272, 367, 282, 315, 1425, 8, 552, 8, 1313, 2298, 267, 367, 330, 315, 1425, 8, 552, 8, 1313, 2298, 288, 340, 282, 665, 330, 26, 355, 870, 355, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 19770, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 2234, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 2234, 870, 298, 8366, 9934, 307, 334, 65, 450, 83, 12, 13354, 22992, 1206, 9301, 8, 65, 430, 9426, 450, 334, 1313, 59, 65, 566, 355, 870, 4320, 1814, 63, 3821, 1182, 45, 27957, 2846, 15, 16694, 15, 1182, 20784, 15, 16694, 6687, 355, 870, 4320, 705, 221, 540, 63, 1734, 15925, 63, 15498, 2, 355, 870, 298, 19350, 9934, 307, 6624, 9011, 29955, 282, 282, 450, 83, 9426, 450, 334, 1313, 59, 66, 566, 355, 870, 298, 14764, 9934, 307, 9426, 199, 199, 318, 2446, 837, 272, 870, 5426, 642, 511, 365, 4046, 701, 1570, 63, 442, 63, 498, 14, 647, 2, 272, 870, 5426, 4868, 626, 13729, 376, 1109, 2763, 626, 365, 1777, 402, 282, 790, 365, 440, 18469, 2, 272, 870, 4320, 5993, 63, 5451, 2, 272, 870, 298, 14764, 9934, 8036, 23875, 307, 9426, 272, 870, 4320, 4296, 63, 5451, 2, 272, 870, 298, 3597, 428, 9577, 6186, 63, 17467, 63, 15956, 8178, 29117, 85, 2846, 4451, 9426, 272, 870, 298, 3597, 428, 9577, 2296, 43, 53, 2846, 63, 13052, 63, 51, 5896, 63, 19350, 29, 17, 9426, 272, 3805, 63, 396, 779, 298, 31178, 2919, 401, 298, 28570, 2919, 401, 298, 9754, 2639, 2919, 401, 298, 2919, 401, 298, 18643, 2919, 2, 4794, 272, 3805, 63, 396, 779, 298, 31178, 2919, 32708, 3203, 1149, 401, 298, 28570, 2919, 32708, 3203, 1149, 401, 298, 9754, 2639, 2919, 32708, 3203, 1149, 401, 298, 2919, 32708, 3203, 1149, 401, 298, 18643, 2919, 32708, 3203, 1149, 2, 4794, 272, 372, 378, 199, 1274, 14, 2224, 8, 973, 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, 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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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 ]
tonk/ansible
lib/ansible/modules/system/setup.py
7
8274
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan <michael.dehaan@gmail.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': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = ''' --- module: setup version_added: historical short_description: Gathers facts about remote hosts options: gather_subset: version_added: "2.1" description: - "If supplied, restrict the additional facts collected to the given subset. Possible values: C(all), C(min), C(hardware), C(network), C(virtual), C(ohai), and C(facter). Can specify a list of values to specify a larger subset. Values can also be used with an initial C(!) to specify that that specific subset should not be collected. For instance: C(!hardware,!network,!virtual,!ohai,!facter). If C(!all) is specified then only the min subset is collected. To avoid collecting even the min subset, specify C(!all,!min). To collect only specific facts, use C(!all,!min), and specify the particular fact subsets. Use the filter parameter if you do not want to display some collected facts." required: false default: "all" gather_timeout: version_added: "2.2" description: - Set the default timeout in seconds for individual fact gathering. required: false default: 10 filter: version_added: "1.1" description: - If supplied, only return facts that match this shell-style (fnmatch) wildcard. required: false default: "*" fact_path: version_added: "1.3" description: - Path used for local ansible facts (C(*.fact)) - files in this dir will be run (if executable) and their results be added to C(ansible_local) facts. If a file is not executable it is read instead. Check notes for Windows options. (from 2.1 on) File/results format can be JSON or INI-format. The default C(fact_path) can be specified in C(ansible.cfg) for when setup is automatically called as part of C(gather_facts). NOTE - For windows clients, the results will be added to a variable named after the local file (without extension suffix), rather than C(ansible_local). required: false default: /etc/ansible/facts.d description: - This module is automatically called by playbooks to gather useful variables about remote hosts that can be used in playbooks. It can also be executed directly by C(/usr/bin/ansible) to check what variables are available to a host. Ansible provides many I(facts) about the system, automatically. - This module is also supported for Windows targets. notes: - More ansible facts will be added with successive releases. If I(facter) or I(ohai) are installed, variables from these programs will also be snapshotted into the JSON file for usage in templating. These variables are prefixed with C(facter_) and C(ohai_) so it's easy to tell their source. All variables are bubbled up to the caller. Using the ansible facts and choosing to not install I(facter) and I(ohai) means you can avoid Ruby-dependencies on your remote systems. (See also M(facter) and M(ohai).) - The filter option filters only the first level subkey below ansible_facts. - If the target host is Windows, you will not currently have the ability to use C(filter) as this is provided by a simpler implementation of the module. - If the target host is Windows you can now use C(fact_path). Make sure that this path exists on the target host. Files in this path MUST be PowerShell scripts (``*.ps1``) and their output must be formattable in JSON (Ansible will take care of this). Test the output of your scripts. This option was added in Ansible 2.1. - This module is also supported for Windows targets. - This module should be run with elevated privileges on BSD systems to gather facts like ansible_product_version. author: - "Ansible Core Team" - "Michael DeHaan" ''' EXAMPLES = """ # Display facts from all hosts and store them indexed by I(hostname) at C(/tmp/facts). # ansible all -m setup --tree /tmp/facts # Display only facts regarding memory found by ansible on all hosts and output them. # ansible all -m setup -a 'filter=ansible_*_mb' # Display only facts returned by facter. # ansible all -m setup -a 'filter=facter_*' # Collect only facts returned by facter. # ansible all -m setup -a 'gather_subset=!all,!any,facter' - name: Collect only facts returned by facter setup: gather_subset: - '!all' - '!any' - facter # Display only facts about certain interfaces. # ansible all -m setup -a 'filter=ansible_eth[0-2]' # Restrict additional gathered facts to network and virtual (includes default minimum facts) # ansible all -m setup -a 'gather_subset=network,virtual' # Collect only network and virtual (excludes default minimum facts) # ansible all -m setup -a 'gather_subset=!all,!any,network,virtual' # Do not call puppet facter or ohai even if present. # ansible all -m setup -a 'gather_subset=!facter,!ohai' # Only collect the default minimum amount of facts: # ansible all -m setup -a 'gather_subset=!all' # Collect no facts, even the default minimum subset of facts: # ansible all -m setup -a 'gather_subset=!all,!min' # Display facts from Windows hosts with custom facts stored in C(C:\\custom_facts). # ansible windows -m setup -a "fact_path='c:\\custom_facts'" """ # import module snippets from ...module_utils.basic import AnsibleModule from ansible.module_utils.facts.namespace import PrefixFactNamespace from ansible.module_utils.facts import ansible_collector from ansible.module_utils.facts import default_collectors def main(): module = AnsibleModule( argument_spec=dict( gather_subset=dict(default=["all"], required=False, type='list'), gather_timeout=dict(default=10, required=False, type='int'), filter=dict(default="*", required=False), fact_path=dict(default='/etc/ansible/facts.d', required=False, type='path'), ), supports_check_mode=True, ) gather_subset = module.params['gather_subset'] gather_timeout = module.params['gather_timeout'] filter_spec = module.params['filter'] # TODO: this mimics existing behavior where gather_subset=["!all"] actually means # to collect nothing except for the below list # TODO: decide what '!all' means, I lean towards making it mean none, but likely needs # some tweaking on how gather_subset operations are performed minimal_gather_subset = frozenset(['apparmor', 'caps', 'cmdline', 'date_time', 'distribution', 'dns', 'env', 'fips', 'local', 'lsb', 'pkg_mgr', 'platform', 'python', 'selinux', 'service_mgr', 'ssh_pub_keys', 'user']) all_collector_classes = default_collectors.collectors # rename namespace_name to root_key? namespace = PrefixFactNamespace(namespace_name='ansible', prefix='ansible_') fact_collector = \ ansible_collector.get_ansible_collector(all_collector_classes=all_collector_classes, namespace=namespace, filter_spec=filter_spec, gather_subset=gather_subset, gather_timeout=gather_timeout, minimal_gather_subset=minimal_gather_subset) facts_dict = fact_collector.collect(module=module) module.exit_json(ansible_facts=facts_dict) 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, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 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, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 3272, 199, 1023, 63, 3270, 26, 32530, 199, 3612, 63, 1802, 26, 19634, 83, 9036, 3595, 3982, 7057, 199, 1419, 26, 272, 13082, 63, 9401, 26, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 267, 1369, 26, 288, 446, 298, 3917, 6841, 12, 18152, 314, 4722, 9036, 13736, 370, 314, 1627, 10026, 14, 1598, 18558, 1338, 26, 445, 8, 452, 395, 445, 8, 827, 395, 445, 8, 16529, 395, 445, 8, 1200, 395, 445, 8, 2065, 395, 445, 8, 79, 17945, 395, 436, 1598, 445, 8, 70, 6747, 680, 6855, 4165, 282, 769, 402, 1338, 370, 4165, 282, 12142, 10026, 14, 1598, 13468, 883, 2597, 506, 1202, 543, 376, 2536, 445, 8, 21866, 370, 4165, 626, 1598, 626, 2488, 10026, 1077, 440, 506, 13736, 14, 221, 2104, 1256, 26, 1598, 445, 8, 1, 16529, 12, 1, 1200, 12, 1, 2065, 12, 1, 79, 17945, 12, 1, 70, 6747, 680, 982, 445, 8, 1, 452, 9, 365, 2013, 1598, 2066, 1454, 314, 1748, 10026, 365, 13736, 14, 4005, 5126, 32223, 2755, 314, 1598, 1748, 10026, 12, 4165, 445, 8, 1, 452, 12, 1, 827, 680, 4005, 8775, 1454, 2488, 9036, 12, 1598, 675, 445, 8, 1, 452, 12, 1, 827, 395, 436, 4165, 314, 6770, 10572, 30767, 14, 1598, 3645, 314, 2457, 2725, 340, 1265, 886, 440, 2934, 370, 2929, 2005, 13736, 1598, 9036, 2122, 267, 1415, 26, 3055, 267, 849, 26, 298, 452, 2, 272, 13082, 63, 2593, 26, 267, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 267, 1369, 26, 288, 446, 2494, 314, 849, 2653, 315, 4696, 367, 8212, 10572, 13082, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 1616, 272, 2457, 26, 267, 1015, 63, 3270, 26, 298, 17, 14, 17, 2, 267, 1369, 26, 288, 446, 982, 6841, 12, 1454, 372, 9036, 626, 1336, 642, 5218, 13, 2487, 334, 15359, 9, 16792, 14, 267, 1415, 26, 3055, 267, 849, 26, 22423, 272, 10572, 63, 515, 26, 267, 1015, 63, 3270, 26, 298, 17, 14, 19, 2, 267, 1369, 26, 288, 446, 6912, 1202, 367, 2257, 3242, 9036, 334, 35, 2031, 14, 7783, 430, 446, 1584, 315, 642, 2935, 1598, 911, 506, 1255, 334, 692, 7286, 9, 436, 3932, 2058, 506, 3483, 370, 445, 8, 4853, 63, 1832, 9, 9036, 14, 1598, 982, 282, 570, 365, 440, 7286, 652, 365, 1586, 3140, 14, 2670, 12681, 367, 5417, 1511, 14, 334, 504, 499, 14, 17, 641, 9, 1598, 3814, 15, 2604, 1475, 883, 506, 4840, 503, 1621, 41, 13, 908, 14, 710, 849, 445, 8, 7783, 63, 515, 9, 883, 506, 1598, 2013, 315, 445, 8, 4853, 14, 4128, 9, 367, 1380, 3272, 365, 5847, 2797, 465, 1777, 402, 1598, 445, 8, 13737, 63, 5047, 680, 1598, 6944, 446, 2104, 10061, 13431, 12, 314, 2058, 911, 506, 3483, 370, 282, 1750, 4310, 2410, 314, 1598, 2257, 570, 334, 7395, 3329, 4739, 395, 7830, 2419, 445, 8, 4853, 63, 1832, 680, 267, 1415, 26, 3055, 267, 849, 26, 1182, 6839, 15, 4853, 15, 5047, 14, 68, 199, 1802, 26, 272, 446, 961, 859, 365, 5847, 2797, 701, 5232, 8858, 370, 13082, 2997, 489, 2860, 3595, 3982, 7057, 626, 883, 506, 1202, 315, 5232, 8858, 14, 2779, 883, 2597, 506, 489, 7934, 5370, 701, 445, 29478, 2647, 15, 1393, 15, 4853, 9, 370, 1104, 4052, 2860, 787, 489, 2808, 370, 282, 1591, 14, 2622, 6571, 5002, 473, 8, 5047, 9, 3595, 314, 2656, 12, 489, 5847, 14, 272, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 199, 5983, 26, 272, 446, 16917, 3242, 9036, 911, 506, 3483, 543, 27028, 3398, 19015, 14, 982, 473, 8, 70, 6747, 9, 503, 489, 473, 8, 79, 17945, 9, 787, 4903, 12, 2860, 687, 3520, 18572, 911, 2597, 506, 5740, 471, 489, 1901, 314, 4840, 570, 367, 4503, 315, 2388, 24615, 14, 5723, 2860, 787, 18239, 489, 543, 445, 8, 70, 6747, 4602, 436, 445, 8, 79, 17945, 4602, 880, 652, 1159, 8837, 370, 11480, 3932, 1350, 14, 2900, 2860, 787, 489, 330, 21749, 68, 1536, 370, 314, 8025, 14, 11719, 314, 3242, 9036, 436, 2468, 26056, 370, 440, 489, 3907, 473, 8, 70, 6747, 9, 436, 473, 8, 79, 17945, 9, 4910, 1265, 883, 5126, 820, 10972, 13, 5714, 641, 2195, 489, 3982, 10460, 14, 334, 9295, 2597, 603, 8, 70, 6747, 9, 436, 603, 8, 79, 17945, 680, 9, 272, 446, 710, 2457, 945, 4766, 1454, 314, 1642, 2166, 1007, 498, 5084, 3242, 63, 5047, 14, 272, 446, 982, 314, 1347, 1591, 365, 5417, 12, 1265, 911, 440, 5544, 1172, 314, 21255, 370, 675, 489, 445, 8, 1541, 9, 465, 642, 365, 2741, 701, 282, 28293, 4514, 402, 314, 859, 14, 272, 446, 982, 314, 1347, 1591, 365, 5417, 1265, 883, 3063, 675, 445, 8, 7783, 63, 515, 680, 4155, 3238, 626, 642, 931, 489, 3495, 641, 314, 1347, 1591, 14, 16920, 315, 642, 931, 18095, 506, 18879, 8529, 10554, 15693, 4856, 1190, 17, 16580, 436, 489, 3932, 1072, 1471, 506, 1475, 1224, 315, 4840, 334, 10047, 911, 5452, 10296, 402, 642, 680, 1379, 314, 489, 1072, 402, 2195, 10554, 14, 489, 961, 945, 1990, 3483, 315, 2622, 499, 14, 17, 14, 272, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 272, 446, 961, 859, 1077, 506, 1255, 543, 325, 6972, 972, 20001, 641, 6289, 10460, 370, 13082, 9036, 2839, 3242, 63, 2558, 63, 1023, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 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, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 3272, 199, 1023, 63, 3270, 26, 32530, 199, 3612, 63, 1802, 26, 19634, 83, 9036, 3595, 3982, 7057, 199, 1419, 26, 272, 13082, 63, 9401, 26, 267, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 267, 1369, 26, 288, 446, 298, 3917, 6841, 12, 18152, 314, 4722, 9036, 13736, 370, 314, 1627, 10026, 14, 1598, 18558, 1338, 26, 445, 8, 452, 395, 445, 8, 827, 395, 445, 8, 16529, 395, 445, 8, 1200, 395, 445, 8, 2065, 395, 445, 8, 79, 17945, 395, 436, 1598, 445, 8, 70, 6747, 680, 6855, 4165, 282, 769, 402, 1338, 370, 4165, 282, 12142, 10026, 14, 1598, 13468, 883, 2597, 506, 1202, 543, 376, 2536, 445, 8, 21866, 370, 4165, 626, 1598, 626, 2488, 10026, 1077, 440, 506, 13736, 14, 221, 2104, 1256, 26, 1598, 445, 8, 1, 16529, 12, 1, 1200, 12, 1, 2065, 12, 1, 79, 17945, 12, 1, 70, 6747, 680, 982, 445, 8, 1, 452, 9, 365, 2013, 1598, 2066, 1454, 314, 1748, 10026, 365, 13736, 14, 4005, 5126, 32223, 2755, 314, 1598, 1748, 10026, 12, 4165, 445, 8, 1, 452, 12, 1, 827, 680, 4005, 8775, 1454, 2488, 9036, 12, 1598, 675, 445, 8, 1, 452, 12, 1, 827, 395, 436, 4165, 314, 6770, 10572, 30767, 14, 1598, 3645, 314, 2457, 2725, 340, 1265, 886, 440, 2934, 370, 2929, 2005, 13736, 1598, 9036, 2122, 267, 1415, 26, 3055, 267, 849, 26, 298, 452, 2, 272, 13082, 63, 2593, 26, 267, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 267, 1369, 26, 288, 446, 2494, 314, 849, 2653, 315, 4696, 367, 8212, 10572, 13082, 316, 14, 267, 1415, 26, 3055, 267, 849, 26, 1616, 272, 2457, 26, 267, 1015, 63, 3270, 26, 298, 17, 14, 17, 2, 267, 1369, 26, 288, 446, 982, 6841, 12, 1454, 372, 9036, 626, 1336, 642, 5218, 13, 2487, 334, 15359, 9, 16792, 14, 267, 1415, 26, 3055, 267, 849, 26, 22423, 272, 10572, 63, 515, 26, 267, 1015, 63, 3270, 26, 298, 17, 14, 19, 2, 267, 1369, 26, 288, 446, 6912, 1202, 367, 2257, 3242, 9036, 334, 35, 2031, 14, 7783, 430, 446, 1584, 315, 642, 2935, 1598, 911, 506, 1255, 334, 692, 7286, 9, 436, 3932, 2058, 506, 3483, 370, 445, 8, 4853, 63, 1832, 9, 9036, 14, 1598, 982, 282, 570, 365, 440, 7286, 652, 365, 1586, 3140, 14, 2670, 12681, 367, 5417, 1511, 14, 334, 504, 499, 14, 17, 641, 9, 1598, 3814, 15, 2604, 1475, 883, 506, 4840, 503, 1621, 41, 13, 908, 14, 710, 849, 445, 8, 7783, 63, 515, 9, 883, 506, 1598, 2013, 315, 445, 8, 4853, 14, 4128, 9, 367, 1380, 3272, 365, 5847, 2797, 465, 1777, 402, 1598, 445, 8, 13737, 63, 5047, 680, 1598, 6944, 446, 2104, 10061, 13431, 12, 314, 2058, 911, 506, 3483, 370, 282, 1750, 4310, 2410, 314, 1598, 2257, 570, 334, 7395, 3329, 4739, 395, 7830, 2419, 445, 8, 4853, 63, 1832, 680, 267, 1415, 26, 3055, 267, 849, 26, 1182, 6839, 15, 4853, 15, 5047, 14, 68, 199, 1802, 26, 272, 446, 961, 859, 365, 5847, 2797, 701, 5232, 8858, 370, 13082, 2997, 489, 2860, 3595, 3982, 7057, 626, 883, 506, 1202, 315, 5232, 8858, 14, 2779, 883, 2597, 506, 489, 7934, 5370, 701, 445, 29478, 2647, 15, 1393, 15, 4853, 9, 370, 1104, 4052, 2860, 787, 489, 2808, 370, 282, 1591, 14, 2622, 6571, 5002, 473, 8, 5047, 9, 3595, 314, 2656, 12, 489, 5847, 14, 272, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 199, 5983, 26, 272, 446, 16917, 3242, 9036, 911, 506, 3483, 543, 27028, 3398, 19015, 14, 982, 473, 8, 70, 6747, 9, 503, 489, 473, 8, 79, 17945, 9, 787, 4903, 12, 2860, 687, 3520, 18572, 911, 2597, 506, 5740, 471, 489, 1901, 314, 4840, 570, 367, 4503, 315, 2388, 24615, 14, 5723, 2860, 787, 18239, 489, 543, 445, 8, 70, 6747, 4602, 436, 445, 8, 79, 17945, 4602, 880, 652, 1159, 8837, 370, 11480, 3932, 1350, 14, 2900, 2860, 787, 489, 330, 21749, 68, 1536, 370, 314, 8025, 14, 11719, 314, 3242, 9036, 436, 2468, 26056, 370, 440, 489, 3907, 473, 8, 70, 6747, 9, 436, 473, 8, 79, 17945, 9, 4910, 1265, 883, 5126, 820, 10972, 13, 5714, 641, 2195, 489, 3982, 10460, 14, 334, 9295, 2597, 603, 8, 70, 6747, 9, 436, 603, 8, 79, 17945, 680, 9, 272, 446, 710, 2457, 945, 4766, 1454, 314, 1642, 2166, 1007, 498, 5084, 3242, 63, 5047, 14, 272, 446, 982, 314, 1347, 1591, 365, 5417, 12, 1265, 911, 440, 5544, 1172, 314, 21255, 370, 675, 489, 445, 8, 1541, 9, 465, 642, 365, 2741, 701, 282, 28293, 4514, 402, 314, 859, 14, 272, 446, 982, 314, 1347, 1591, 365, 5417, 1265, 883, 3063, 675, 445, 8, 7783, 63, 515, 680, 4155, 3238, 626, 642, 931, 489, 3495, 641, 314, 1347, 1591, 14, 16920, 315, 642, 931, 18095, 506, 18879, 8529, 10554, 15693, 4856, 1190, 17, 16580, 436, 489, 3932, 1072, 1471, 506, 1475, 1224, 315, 4840, 334, 10047, 911, 5452, 10296, 402, 642, 680, 1379, 314, 489, 1072, 402, 2195, 10554, 14, 489, 961, 945, 1990, 3483, 315, 2622, 499, 14, 17, 14, 272, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 272, 446, 961, 859, 1077, 506, 1255, 543, 325, 6972, 972, 20001, 641, 6289, 10460, 370, 13082, 9036, 2839, 3242, 63, 2558, 63, 1023, 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,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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 ]
n1889/gitinspector
gitinspector/clone.py
48
1473
# coding: utf-8 # # Copyright © 2014 Ejwa Software. All rights reserved. # # This file is part of gitinspector. # # gitinspector 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. # # gitinspector 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 gitinspector. If not, see <http://www.gnu.org/licenses/>. from __future__ import unicode_literals import shutil import subprocess import sys import tempfile __cloned_path__ = None def create(url): if url.startswith("file://") or url.startswith("git://") or url.startswith("http://") or \ url.startswith("https://") or url.startswith("ssh://"): global __cloned_path__ location = tempfile.mkdtemp(suffix=".gitinspector") git_clone = subprocess.Popen("git clone {0} {1}".format(url, location), shell=True, bufsize=1, stdout=sys.stderr) git_clone.wait() if git_clone.returncode != 0: sys.exit(git_clone.returncode) __cloned_path__ = location return location return url def delete(): if __cloned_path__: shutil.rmtree(__cloned_path__, ignore_errors=True)
gpl-3.0
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 22405, 103, 6927, 662, 74, 758, 2290, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6135, 26047, 14, 199, 3, 199, 3, 6135, 26047, 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, 6135, 26047, 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, 6135, 26047, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 363, 30315, 63, 515, 363, 275, 488, 199, 199, 318, 1218, 8, 633, 304, 199, 198, 692, 1166, 14, 2460, 480, 493, 921, 531, 503, 1166, 14, 2460, 480, 3187, 921, 531, 503, 1166, 14, 2460, 480, 1014, 921, 531, 503, 971, 21979, 1166, 14, 2460, 480, 2859, 921, 531, 503, 1166, 14, 2460, 480, 5510, 921, 2349, 507, 198, 2966, 636, 30315, 63, 515, 363, 2742, 198, 1985, 275, 5549, 14, 11983, 8, 4511, 25356, 3187, 26047, 531, 507, 198, 3187, 63, 6311, 275, 3873, 14, 7942, 480, 3187, 7289, 469, 16, 93, 469, 17, 5469, 908, 8, 633, 12, 2909, 395, 5218, 29, 549, 12, 17080, 29, 17, 12, 3839, 29, 1274, 14, 3083, 9, 507, 198, 3187, 63, 6311, 14, 2573, 342, 2742, 198, 692, 6135, 63, 6311, 14, 9913, 1137, 378, 26, 686, 198, 1274, 14, 2224, 8, 3187, 63, 6311, 14, 9913, 9, 2742, 198, 363, 30315, 63, 515, 363, 275, 2909, 507, 198, 1107, 2909, 199, 198, 1107, 1166, 199, 199, 318, 3145, 837, 199, 198, 692, 636, 30315, 63, 515, 10651, 507, 198, 20938, 14, 9242, 3460, 30315, 63, 515, 3108, 3686, 63, 2550, 29, 549, 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 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 22405, 103, 6927, 662, 74, 758, 2290, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6135, 26047, 14, 199, 3, 199, 3, 6135, 26047, 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, 6135, 26047, 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, 6135, 26047, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 363, 30315, 63, 515, 363, 275, 488, 199, 199, 318, 1218, 8, 633, 304, 199, 198, 692, 1166, 14, 2460, 480, 493, 921, 531, 503, 1166, 14, 2460, 480, 3187, 921, 531, 503, 1166, 14, 2460, 480, 1014, 921, 531, 503, 971, 21979, 1166, 14, 2460, 480, 2859, 921, 531, 503, 1166, 14, 2460, 480, 5510, 921, 2349, 507, 198, 2966, 636, 30315, 63, 515, 363, 2742, 198, 1985, 275, 5549, 14, 11983, 8, 4511, 25356, 3187, 26047, 531, 507, 198, 3187, 63, 6311, 275, 3873, 14, 7942, 480, 3187, 7289, 469, 16, 93, 469, 17, 5469, 908, 8, 633, 12, 2909, 395, 5218, 29, 549, 12, 17080, 29, 17, 12, 3839, 29, 1274, 14, 3083, 9, 507, 198, 3187, 63, 6311, 14, 2573, 342, 2742, 198, 692, 6135, 63, 6311, 14, 9913, 1137, 378, 26, 686, 198, 1274, 14, 2224, 8, 3187, 63, 6311, 14, 9913, 9, 2742, 198, 363, 30315, 63, 515, 363, 275, 2909, 507, 198, 1107, 2909, 199, 198, 1107, 1166, 199, 199, 318, 3145, 837, 199, 198, 692, 636, 30315, 63, 515, 10651, 507, 198, 20938, 14, 9242, 3460, 30315, 63, 515, 3108, 3686, 63, 2550, 29, 549, 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, 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,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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 ]
radicalbit/ambari
ambari-server/src/test/python/stacks/2.0.6/HDFS/test_alert_checkpoint_time.py
3
3594
#!/usr/bin/env python ''' 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 os import sys import json import time from mock.mock import patch, MagicMock # Local imports from stacks.utils.RMFTestCase import * COMMON_SERVICES_ALERTS_DIR = "HDFS/2.1.0.2.0/package/alerts" file_path = os.path.dirname(os.path.abspath(__file__)) file_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(file_path))))) file_path = os.path.join(file_path, "main", "resources", "common-services", COMMON_SERVICES_ALERTS_DIR) RESULT_STATE_OK = "OK" RESULT_STATE_WARNING = "WARNING" RESULT_STATE_CRITICAL = "CRITICAL" RESULT_STATE_UNKNOWN = "UNKNOWN" RESULT_STATE_SKIPPED = "SKIPPED" class TestAlertCheckpointTime(RMFTestCase): def setUp(self): """ Import the class under test. Because the class is present in a different folder, append its dir to the system path. Also, shorten the import name and make it a global so the test functions can access it. :return: """ sys.path.append(file_path) global alert import alert_checkpoint_time as alert global configs configs = { "{{hdfs-site}}" : {'dfs.namenode.http-address' : 'c6401.ambari.apache.org:50470', 'dfs.http.policy': 'HTTP_ONLY', 'dfs.namenode.checkpoint.period': 100, 'security_enabled': 'false', 'dfs.namenode.checkpoint.txns': 100}, '{{hdfs-site/dfs.namenode.http-address}}': 'c6401.ambari.apache.org:50470', '{{hdfs-site/dfs.http.policy}}': 'HTTP_ONLY', '{{hdfs-site/dfs.namenode.checkpoint.period}}': 100, '{{cluster-env/security_enabled}}': 'false', '{{hdfs-site/dfs.namenode.checkpoint.txns}}': 100, } global parameters parameters = { 'connection.timeout': 200.0, 'checkpoint.time.warning.threshold': 2.0, 'checkpoint.time.critical.threshold': 4.0, 'checkpoint.txns.multiplier.warning.threshold': 2.0, 'checkpoint.txns.multiplier.critical.threshold': 4.0 } @patch("urllib2.urlopen") def test_uncommitted_txn_exceeded(self, urlopen_mock): current_time = int(round(time.time() * 1000)) jmx_output = { 'beans' : [ { "LastCheckpointTime" : current_time - 3600000, "JournalTransactionInfo" : "{\"MostRecentCheckpointTxId\":\"2000\"," "\"LastAppliedOrWrittenTxId\":\"3000\"}" } ] } response = MagicMock() response.read.return_value = json.dumps(jmx_output) urlopen_mock.return_value = response [status, messages] = alert.execute(configurations=configs, parameters=parameters, host_name="c6401.ambari.apache.org") self.assertEqual(status, RESULT_STATE_CRITICAL) self.assertEqual(messages[0], 'Last Checkpoint: [1 hours, 0 minutes, 1000 transactions]')
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2022, 199, 646, 900, 199, 199, 504, 1683, 14, 1805, 492, 3371, 12, 10079, 199, 199, 3, 10111, 8925, 199, 504, 26733, 14, 1208, 14, 11026, 38, 1746, 492, 627, 199, 199, 21637, 63, 3279, 8670, 63, 748, 5397, 51, 63, 3022, 275, 298, 30165, 51, 15, 18, 14, 17, 14, 16, 14, 18, 14, 16, 15, 2491, 15, 24501, 2, 199, 199, 493, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 493, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 493, 63, 515, 430, 1724, 199, 493, 63, 515, 275, 747, 14, 515, 14, 904, 8, 493, 63, 515, 12, 298, 973, 401, 298, 4435, 401, 298, 2330, 13, 5950, 401, 11293, 615, 63, 3279, 8670, 63, 748, 5397, 51, 63, 3022, 9, 199, 199, 9517, 63, 6689, 63, 3593, 275, 298, 3593, 2, 199, 9517, 63, 6689, 63, 9171, 275, 298, 9171, 2, 199, 9517, 63, 6689, 63, 21539, 275, 298, 21539, 2, 199, 9517, 63, 6689, 63, 11588, 275, 298, 11588, 2, 199, 9517, 63, 6689, 63, 13525, 19359, 275, 298, 13525, 19359, 2, 199, 199, 533, 1379, 18758, 22005, 1366, 8, 11026, 38, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 408, 272, 3161, 314, 1021, 1334, 511, 14, 272, 13821, 314, 1021, 365, 3451, 315, 282, 3365, 4922, 12, 5666, 2399, 2935, 370, 314, 2656, 931, 14, 272, 6121, 12, 25123, 314, 492, 536, 436, 1852, 652, 282, 2288, 880, 314, 511, 3423, 883, 2879, 652, 14, 272, 520, 1107, 26, 272, 408, 272, 984, 14, 515, 14, 740, 8, 493, 63, 515, 9, 272, 2288, 10459, 339, 492, 10459, 63, 10109, 63, 521, 465, 10459, 272, 2288, 11585, 272, 11585, 275, 469, 7370, 19055, 13, 2124, 30618, 520, 791, 10434, 14, 354, 932, 14, 1014, 13, 1562, 7, 520, 283, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 26, 24081, 2760, 297, 3521, 283, 10434, 14, 1014, 14, 3185, 356, 283, 2856, 63, 10452, 297, 3521, 283, 10434, 14, 354, 932, 14, 10109, 14, 5191, 356, 2948, 12, 3521, 283, 4416, 63, 3827, 356, 283, 3910, 297, 3521, 283, 10434, 14, 354, 932, 14, 10109, 14, 2347, 561, 356, 2948, 1386, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 1014, 13, 1562, 4863, 356, 283, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 26, 24081, 2760, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 1014, 14, 3185, 4863, 356, 283, 2856, 63, 10452, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 10109, 14, 5191, 4863, 356, 2948, 12, 489, 11400, 4201, 13, 1813, 15, 4416, 63, 3827, 4863, 356, 283, 3910, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 10109, 14, 2347, 561, 4863, 356, 2948, 12, 272, 789, 272, 2288, 2633, 272, 2633, 275, 469, 489, 283, 2105, 14, 2593, 356, 1926, 14, 16, 12, 489, 283, 10109, 14, 521, 14, 3764, 14, 7227, 356, 499, 14, 16, 12, 489, 283, 10109, 14, 521, 14, 13138, 14, 7227, 356, 841, 14, 16, 12, 489, 283, 10109, 14, 2347, 561, 14, 15812, 14, 3764, 14, 7227, 356, 499, 14, 16, 12, 489, 283, 10109, 14, 2347, 561, 14, 15812, 14, 13138, 14, 7227, 356, 841, 14, 16, 272, 789, 819, 768, 2068, 480, 4078, 18, 14, 10890, 531, 523, 347, 511, 63, 324, 20300, 63, 18174, 63, 476, 19750, 8, 277, 12, 18279, 63, 1805, 304, 272, 1453, 63, 521, 275, 1109, 8, 2363, 8, 521, 14, 521, 342, 627, 5198, 430, 339, 1335, 9457, 63, 1199, 275, 469, 283, 1235, 796, 7, 520, 359, 489, 469, 298, 6090, 22005, 1366, 2, 520, 1453, 63, 521, 446, 8780, 5345, 12, 267, 298, 25909, 10161, 2354, 2, 520, 5310, 4451, 24625, 29574, 22005, 8052, 1304, 19354, 4451, 8269, 60, 2266, 639, 30768, 6090, 2640, 1857, 2844, 32329, 8052, 1304, 19354, 4451, 19962, 60, 3570, 2, 789, 272, 1622, 789, 339, 1177, 275, 10079, 342, 272, 1177, 14, 739, 14, 1107, 63, 585, 275, 2022, 14, 4180, 8, 74, 9457, 63, 1199, 9, 272, 18279, 63, 1805, 14, 1107, 63, 585, 275, 1177, 339, 359, 1205, 12, 3788, 61, 275, 10459, 14, 2526, 8, 10057, 29, 7532, 12, 2633, 29, 3214, 12, 1591, 63, 354, 628, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 531, 339, 291, 14, 629, 8, 1205, 12, 20668, 63, 6689, 63, 21539, 9, 272, 291, 14, 629, 8, 3431, 59, 16, 467, 283, 6090, 2670, 1403, 26, 359, 17, 10857, 12, 378, 9395, 12, 5198, 15809, 10374, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2344, 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2022, 199, 646, 900, 199, 199, 504, 1683, 14, 1805, 492, 3371, 12, 10079, 199, 199, 3, 10111, 8925, 199, 504, 26733, 14, 1208, 14, 11026, 38, 1746, 492, 627, 199, 199, 21637, 63, 3279, 8670, 63, 748, 5397, 51, 63, 3022, 275, 298, 30165, 51, 15, 18, 14, 17, 14, 16, 14, 18, 14, 16, 15, 2491, 15, 24501, 2, 199, 199, 493, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 493, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 493, 63, 515, 430, 1724, 199, 493, 63, 515, 275, 747, 14, 515, 14, 904, 8, 493, 63, 515, 12, 298, 973, 401, 298, 4435, 401, 298, 2330, 13, 5950, 401, 11293, 615, 63, 3279, 8670, 63, 748, 5397, 51, 63, 3022, 9, 199, 199, 9517, 63, 6689, 63, 3593, 275, 298, 3593, 2, 199, 9517, 63, 6689, 63, 9171, 275, 298, 9171, 2, 199, 9517, 63, 6689, 63, 21539, 275, 298, 21539, 2, 199, 9517, 63, 6689, 63, 11588, 275, 298, 11588, 2, 199, 9517, 63, 6689, 63, 13525, 19359, 275, 298, 13525, 19359, 2, 199, 199, 533, 1379, 18758, 22005, 1366, 8, 11026, 38, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 408, 272, 3161, 314, 1021, 1334, 511, 14, 272, 13821, 314, 1021, 365, 3451, 315, 282, 3365, 4922, 12, 5666, 2399, 2935, 370, 314, 2656, 931, 14, 272, 6121, 12, 25123, 314, 492, 536, 436, 1852, 652, 282, 2288, 880, 314, 511, 3423, 883, 2879, 652, 14, 272, 520, 1107, 26, 272, 408, 272, 984, 14, 515, 14, 740, 8, 493, 63, 515, 9, 272, 2288, 10459, 339, 492, 10459, 63, 10109, 63, 521, 465, 10459, 272, 2288, 11585, 272, 11585, 275, 469, 7370, 19055, 13, 2124, 30618, 520, 791, 10434, 14, 354, 932, 14, 1014, 13, 1562, 7, 520, 283, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 26, 24081, 2760, 297, 3521, 283, 10434, 14, 1014, 14, 3185, 356, 283, 2856, 63, 10452, 297, 3521, 283, 10434, 14, 354, 932, 14, 10109, 14, 5191, 356, 2948, 12, 3521, 283, 4416, 63, 3827, 356, 283, 3910, 297, 3521, 283, 10434, 14, 354, 932, 14, 10109, 14, 2347, 561, 356, 2948, 1386, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 1014, 13, 1562, 4863, 356, 283, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 26, 24081, 2760, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 1014, 14, 3185, 4863, 356, 283, 2856, 63, 10452, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 10109, 14, 5191, 4863, 356, 2948, 12, 489, 11400, 4201, 13, 1813, 15, 4416, 63, 3827, 4863, 356, 283, 3910, 297, 489, 11400, 19055, 13, 2124, 15, 10434, 14, 354, 932, 14, 10109, 14, 2347, 561, 4863, 356, 2948, 12, 272, 789, 272, 2288, 2633, 272, 2633, 275, 469, 489, 283, 2105, 14, 2593, 356, 1926, 14, 16, 12, 489, 283, 10109, 14, 521, 14, 3764, 14, 7227, 356, 499, 14, 16, 12, 489, 283, 10109, 14, 521, 14, 13138, 14, 7227, 356, 841, 14, 16, 12, 489, 283, 10109, 14, 2347, 561, 14, 15812, 14, 3764, 14, 7227, 356, 499, 14, 16, 12, 489, 283, 10109, 14, 2347, 561, 14, 15812, 14, 13138, 14, 7227, 356, 841, 14, 16, 272, 789, 819, 768, 2068, 480, 4078, 18, 14, 10890, 531, 523, 347, 511, 63, 324, 20300, 63, 18174, 63, 476, 19750, 8, 277, 12, 18279, 63, 1805, 304, 272, 1453, 63, 521, 275, 1109, 8, 2363, 8, 521, 14, 521, 342, 627, 5198, 430, 339, 1335, 9457, 63, 1199, 275, 469, 283, 1235, 796, 7, 520, 359, 489, 469, 298, 6090, 22005, 1366, 2, 520, 1453, 63, 521, 446, 8780, 5345, 12, 267, 298, 25909, 10161, 2354, 2, 520, 5310, 4451, 24625, 29574, 22005, 8052, 1304, 19354, 4451, 8269, 60, 2266, 639, 30768, 6090, 2640, 1857, 2844, 32329, 8052, 1304, 19354, 4451, 19962, 60, 3570, 2, 789, 272, 1622, 789, 339, 1177, 275, 10079, 342, 272, 1177, 14, 739, 14, 1107, 63, 585, 275, 2022, 14, 4180, 8, 74, 9457, 63, 1199, 9, 272, 18279, 63, 1805, 14, 1107, 63, 585, 275, 1177, 339, 359, 1205, 12, 3788, 61, 275, 10459, 14, 2526, 8, 10057, 29, 7532, 12, 2633, 29, 3214, 12, 1591, 63, 354, 628, 67, 772, 614, 14, 11020, 759, 14, 3796, 14, 1308, 531, 339, 291, 14, 629, 8, 1205, 12, 20668, 63, 6689, 63, 21539, 9, 272, 291, 14, 629, 8, 3431, 59, 16, 467, 283, 6090, 2670, 1403, 26, 359, 17, 10857, 12, 378, 9395, 12, 5198, 15809, 10374, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
pilou-/ansible
test/units/parsing/utils/test_addresses.py
62
3762
# -*- coding: utf-8 -*- import unittest from ansible.parsing.utils.addresses import parse_address class TestParseAddress(unittest.TestCase): tests = { # IPv4 addresses '192.0.2.3': ['192.0.2.3', None], '192.0.2.3:23': ['192.0.2.3', 23], # IPv6 addresses '::': ['::', None], '::1': ['::1', None], '[::1]:442': ['::1', 442], 'abcd:ef98:7654:3210:abcd:ef98:7654:3210': ['abcd:ef98:7654:3210:abcd:ef98:7654:3210', None], '[abcd:ef98:7654:3210:abcd:ef98:7654:3210]:42': ['abcd:ef98:7654:3210:abcd:ef98:7654:3210', 42], '1234:5678:9abc:def0:1234:5678:9abc:def0': ['1234:5678:9abc:def0:1234:5678:9abc:def0', None], '1234::9abc:def0:1234:5678:9abc:def0': ['1234::9abc:def0:1234:5678:9abc:def0', None], '1234:5678::def0:1234:5678:9abc:def0': ['1234:5678::def0:1234:5678:9abc:def0', None], '1234:5678:9abc::1234:5678:9abc:def0': ['1234:5678:9abc::1234:5678:9abc:def0', None], '1234:5678:9abc:def0::5678:9abc:def0': ['1234:5678:9abc:def0::5678:9abc:def0', None], '1234:5678:9abc:def0:1234::9abc:def0': ['1234:5678:9abc:def0:1234::9abc:def0', None], '1234:5678:9abc:def0:1234:5678::def0': ['1234:5678:9abc:def0:1234:5678::def0', None], '1234:5678:9abc:def0:1234:5678::': ['1234:5678:9abc:def0:1234:5678::', None], '::9abc:def0:1234:5678:9abc:def0': ['::9abc:def0:1234:5678:9abc:def0', None], '0:0:0:0:0:ffff:1.2.3.4': ['0:0:0:0:0:ffff:1.2.3.4', None], '0:0:0:0:0:0:1.2.3.4': ['0:0:0:0:0:0:1.2.3.4', None], '::ffff:1.2.3.4': ['::ffff:1.2.3.4', None], '::1.2.3.4': ['::1.2.3.4', None], '1234::': ['1234::', None], # Hostnames 'some-host': ['some-host', None], 'some-host:80': ['some-host', 80], 'some.host.com:492': ['some.host.com', 492], '[some.host.com]:493': ['some.host.com', 493], 'a-b.3foo_bar.com:23': ['a-b.3foo_bar.com', 23], u'fóöbär': [u'fóöbär', None], u'fóöbär:32': [u'fóöbär', 32], u'fóöbär.éxàmplê.com:632': [u'fóöbär.éxàmplê.com', 632], # Various errors '': [None, None], 'some..host': [None, None], 'some.': [None, None], '[example.com]': [None, None], 'some-': [None, None], 'some-.foo.com': [None, None], 'some.-foo.com': [None, None], } range_tests = { '192.0.2.[3:10]': ['192.0.2.[3:10]', None], '192.0.2.[3:10]:23': ['192.0.2.[3:10]', 23], 'abcd:ef98::7654:[1:9]': ['abcd:ef98::7654:[1:9]', None], '[abcd:ef98::7654:[6:32]]:2222': ['abcd:ef98::7654:[6:32]', 2222], '[abcd:ef98::7654:[9ab3:fcb7]]:2222': ['abcd:ef98::7654:[9ab3:fcb7]', 2222], u'fóöb[a:c]r.éxàmplê.com:632': [u'fóöb[a:c]r.éxàmplê.com', 632], '[a:b]foo.com': ['[a:b]foo.com', None], 'foo[a:b].com': ['foo[a:b].com', None], 'foo[a:b]:42': ['foo[a:b]', 42], 'foo[a-b]-.com': [None, None], 'foo[a-b]:32': [None, None], 'foo[x-y]': [None, None], } def test_without_ranges(self): for t in self.tests: test = self.tests[t] try: (host, port) = parse_address(t) except Exception: host = None port = None assert host == test[0] assert port == test[1] def test_with_ranges(self): for t in self.range_tests: test = self.range_tests[t] try: (host, port) = parse_address(t, allow_ranges=True) except Exception: host = None port = None assert host == test[0] assert port == test[1]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 2882, 199, 199, 504, 3242, 14, 11059, 14, 1208, 14, 7423, 492, 2198, 63, 1562, 421, 199, 533, 1379, 4003, 1476, 8, 2796, 14, 1746, 304, 339, 2295, 275, 469, 267, 327, 6509, 20, 7149, 267, 283, 5756, 14, 16, 14, 18, 14, 19, 356, 788, 5756, 14, 16, 14, 18, 14, 19, 297, 488, 467, 267, 283, 5756, 14, 16, 14, 18, 14, 19, 26, 1789, 356, 788, 5756, 14, 16, 14, 18, 14, 19, 297, 6546, 467, 398, 327, 6509, 22, 7149, 267, 19069, 356, 359, 356, 6536, 488, 467, 267, 19069, 17, 356, 359, 356, 26, 17, 297, 488, 467, 267, 6730, 447, 17, 2189, 24338, 356, 359, 356, 26, 17, 297, 841, 2260, 467, 267, 283, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 356, 788, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 297, 488, 467, 267, 6730, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 2189, 2260, 356, 788, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 297, 5685, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 447, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 447, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 447, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 447, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 447, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 447, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 447, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 447, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 447, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 447, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 297, 488, 467, 267, 19069, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 359, 356, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 356, 788, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 283, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 17, 14, 18, 14, 19, 14, 20, 356, 788, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 19069, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 356, 359, 356, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 19069, 17, 14, 18, 14, 19, 14, 20, 356, 359, 356, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 283, 4321, 447, 356, 788, 4321, 447, 297, 488, 467, 398, 327, 10891, 1247, 267, 283, 3972, 13, 1102, 356, 788, 3972, 13, 1102, 297, 488, 467, 267, 283, 3972, 13, 1102, 26, 1257, 356, 788, 3972, 13, 1102, 297, 5939, 467, 267, 283, 3972, 14, 1102, 14, 957, 26, 25722, 356, 788, 3972, 14, 1102, 14, 957, 297, 841, 2942, 467, 267, 6730, 3972, 14, 1102, 14, 957, 2189, 25919, 356, 788, 3972, 14, 1102, 14, 957, 297, 841, 3129, 467, 267, 283, 65, 13, 66, 14, 19, 1421, 63, 1700, 14, 957, 26, 1789, 356, 788, 65, 13, 66, 14, 19, 1421, 63, 1700, 14, 957, 297, 6546, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 297, 488, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 26, 708, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 297, 4337, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 14, 5741, 88, 26482, 2421, 28413, 14, 957, 26, 27250, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 14, 5741, 88, 26482, 2421, 28413, 14, 957, 297, 1227, 708, 467, 398, 327, 21107, 1785, 2552, 267, 8061, 359, 403, 12, 488, 467, 267, 283, 3972, 703, 1102, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 10586, 359, 403, 12, 488, 467, 267, 6730, 2694, 14, 957, 61, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 13, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 30858, 1421, 14, 957, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 23683, 1421, 14, 957, 356, 359, 403, 12, 488, 467, 272, 789, 339, 1425, 63, 2219, 275, 469, 267, 283, 5756, 14, 16, 14, 18, 24097, 19 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 2882, 199, 199, 504, 3242, 14, 11059, 14, 1208, 14, 7423, 492, 2198, 63, 1562, 421, 199, 533, 1379, 4003, 1476, 8, 2796, 14, 1746, 304, 339, 2295, 275, 469, 267, 327, 6509, 20, 7149, 267, 283, 5756, 14, 16, 14, 18, 14, 19, 356, 788, 5756, 14, 16, 14, 18, 14, 19, 297, 488, 467, 267, 283, 5756, 14, 16, 14, 18, 14, 19, 26, 1789, 356, 788, 5756, 14, 16, 14, 18, 14, 19, 297, 6546, 467, 398, 327, 6509, 22, 7149, 267, 19069, 356, 359, 356, 6536, 488, 467, 267, 19069, 17, 356, 359, 356, 26, 17, 297, 488, 467, 267, 6730, 447, 17, 2189, 24338, 356, 359, 356, 26, 17, 297, 841, 2260, 467, 267, 283, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 356, 788, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 297, 488, 467, 267, 6730, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 2189, 2260, 356, 788, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 26, 13591, 26, 2829, 2905, 26, 2114, 1477, 26, 708, 709, 297, 5685, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 447, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 447, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 447, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 447, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 447, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 447, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 447, 12970, 26, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 447, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 447, 25, 3175, 26, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 447, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 318, 16, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 318, 16, 297, 488, 467, 267, 283, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 356, 788, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 447, 297, 488, 467, 267, 19069, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 356, 359, 356, 26, 25, 3175, 26, 318, 16, 26, 4321, 26, 12970, 26, 25, 3175, 26, 318, 16, 297, 488, 467, 267, 283, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 356, 788, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 283, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 17, 14, 18, 14, 19, 14, 20, 356, 788, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 16, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 19069, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 356, 359, 356, 26, 4717, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 19069, 17, 14, 18, 14, 19, 14, 20, 356, 359, 356, 26, 17, 14, 18, 14, 19, 14, 20, 297, 488, 467, 267, 283, 4321, 447, 356, 788, 4321, 447, 297, 488, 467, 398, 327, 10891, 1247, 267, 283, 3972, 13, 1102, 356, 788, 3972, 13, 1102, 297, 488, 467, 267, 283, 3972, 13, 1102, 26, 1257, 356, 788, 3972, 13, 1102, 297, 5939, 467, 267, 283, 3972, 14, 1102, 14, 957, 26, 25722, 356, 788, 3972, 14, 1102, 14, 957, 297, 841, 2942, 467, 267, 6730, 3972, 14, 1102, 14, 957, 2189, 25919, 356, 788, 3972, 14, 1102, 14, 957, 297, 841, 3129, 467, 267, 283, 65, 13, 66, 14, 19, 1421, 63, 1700, 14, 957, 26, 1789, 356, 788, 65, 13, 66, 14, 19, 1421, 63, 1700, 14, 957, 297, 6546, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 297, 488, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 26, 708, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 297, 4337, 467, 267, 399, 7, 70, 11980, 14614, 66, 13733, 82, 14, 5741, 88, 26482, 2421, 28413, 14, 957, 26, 27250, 356, 359, 85, 7, 70, 11980, 14614, 66, 13733, 82, 14, 5741, 88, 26482, 2421, 28413, 14, 957, 297, 1227, 708, 467, 398, 327, 21107, 1785, 2552, 267, 8061, 359, 403, 12, 488, 467, 267, 283, 3972, 703, 1102, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 10586, 359, 403, 12, 488, 467, 267, 6730, 2694, 14, 957, 61, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 13, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 30858, 1421, 14, 957, 356, 359, 403, 12, 488, 467, 267, 283, 3972, 23683, 1421, 14, 957, 356, 359, 403, 12, 488, 467, 272, 789, 339, 1425, 63, 2219, 275, 469, 267, 283, 5756, 14, 16, 14, 18, 24097, 19, 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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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 ]
hdd/bigcouch
couchjs/scons/scons-local-2.0.1/SCons/Scanner/RC.py
61
2068
"""SCons.Scanner.RC This module implements the depenency scanner for RC (Interface Definition Language) files. """ # # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "src/engine/SCons/Scanner/RC.py 5134 2010/08/16 23:02:40 bdeegan" import SCons.Node.FS import SCons.Scanner import re def RCScan(): """Return a prototype Scanner instance for scanning RC source files""" res_re= r'^(?:\s*#\s*(?:include)|' \ '.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \ '\s*.*?)' \ '\s*(<|"| )([^>"\s]+)(?:[>" ])*$' resScanner = SCons.Scanner.ClassicCPP( "ResourceScanner", "$RCSUFFIXES", "CPPPATH", res_re ) return resScanner # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
apache-2.0
[ 624, 18521, 14, 20843, 14, 8205, 199, 199, 2765, 859, 9031, 314, 477, 897, 9501, 19121, 367, 29256, 334, 4267, 199, 10701, 8466, 9, 1584, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 20843, 15, 8205, 14, 647, 959, 7582, 7129, 15, 2036, 15, 975, 6546, 26, 996, 26, 2167, 330, 271, 5902, 290, 2, 199, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 20843, 199, 646, 295, 199, 199, 318, 820, 3298, 2425, 837, 272, 408, 1767, 282, 19393, 28628, 1256, 367, 24928, 29256, 1350, 1584, 624, 20950, 522, 63, 264, 29, 519, 4289, 15840, 83, 10, 20262, 83, 10, 5169, 2613, 9, 5227, 971, 288, 1987, 10, 8995, 83, 11, 5169, 15903, 92, 30189, 92, 31321, 92, 4943, 92, 18398, 92, 7388, 1254, 775, 2617, 92, 2711, 5617, 92, 25304, 57, 92, 36, 19, 3888, 56, 3171, 971, 288, 1557, 83, 10, 6697, 3171, 971, 288, 1557, 83, 5830, 28, 25576, 92, 776, 7059, 30, 3212, 83, 11896, 25060, 4335, 4794, 10, 12913, 272, 522, 20843, 275, 8218, 14, 20843, 14, 30722, 67, 14533, 8, 298, 4031, 20843, 401, 5644, 7880, 50, 3298, 8158, 3867, 654, 401, 5644, 298, 14533, 3243, 401, 5644, 522, 63, 264, 776, 2286, 372, 522, 20843, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 29, 20, 26, 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 ]
[ 18521, 14, 20843, 14, 8205, 199, 199, 2765, 859, 9031, 314, 477, 897, 9501, 19121, 367, 29256, 334, 4267, 199, 10701, 8466, 9, 1584, 14, 199, 199, 624, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 20843, 15, 8205, 14, 647, 959, 7582, 7129, 15, 2036, 15, 975, 6546, 26, 996, 26, 2167, 330, 271, 5902, 290, 2, 199, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 20843, 199, 646, 295, 199, 199, 318, 820, 3298, 2425, 837, 272, 408, 1767, 282, 19393, 28628, 1256, 367, 24928, 29256, 1350, 1584, 624, 20950, 522, 63, 264, 29, 519, 4289, 15840, 83, 10, 20262, 83, 10, 5169, 2613, 9, 5227, 971, 288, 1987, 10, 8995, 83, 11, 5169, 15903, 92, 30189, 92, 31321, 92, 4943, 92, 18398, 92, 7388, 1254, 775, 2617, 92, 2711, 5617, 92, 25304, 57, 92, 36, 19, 3888, 56, 3171, 971, 288, 1557, 83, 10, 6697, 3171, 971, 288, 1557, 83, 5830, 28, 25576, 92, 776, 7059, 30, 3212, 83, 11896, 25060, 4335, 4794, 10, 12913, 272, 522, 20843, 275, 8218, 14, 20843, 14, 30722, 67, 14533, 8, 298, 4031, 20843, 401, 5644, 7880, 50, 3298, 8158, 3867, 654, 401, 5644, 298, 14533, 3243, 401, 5644, 522, 63, 264, 776, 2286, 372, 522, 20843, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 29, 20, 26, 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, 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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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 ]
KenV99/script.service.kodi.callbacks
default.py
3
5603
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2015 KenV99 # # 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/>. # debug = False # TODO: check testdebug = False # TODO: check testTasks = False # TODO: check branch = 'master' build = '1018' from resources.lib.utils.debugger import startdebugger if debug: startdebugger() import os import sys import threading import xbmc import xbmcaddon import resources.lib.pubsub as PubSub_Threaded from resources.lib.kodilogging import KodiLogger from resources.lib.publisherfactory import PublisherFactory from resources.lib.subscriberfactory import SubscriberFactory from resources.lib.settings import Settings from resources.lib.utils.poutil import KodiPo import xbmcgui kodipo = KodiPo() _ = kodipo.getLocalizedString log = KodiLogger.log try: _addonversion_ = xbmcaddon.Addon().getAddonInfo('version') except RuntimeError: try: _addonversion_ = xbmcaddon.Addon('script.service.kodi.callbacks').getAddonInfo('version') except RuntimeError: _addonversion_ = 'ERROR getting version' class Cache(object): publishers = None dispatcher = None class MainMonitor(xbmc.Monitor): def __init__(self): super(MainMonitor, self).__init__() def onSettingsChanged(self): dialog = xbmcgui.Dialog() msg = _('If improperly implemented, running user tasks can damage your system.\nThe user assumes all risks and liability for running tasks.').split('\n') dialog.ok(_('Kodi Callbacks'), line1=msg[0], line2=msg[1]) log(msg=_('Settings change detected - attempting to restart')) abortall() start() def abortall(): for p in Cache.publishers: try: p.abort() except threading.ThreadError as e: log(msg=_('Error aborting: %s - Error: %s') % (str(p), str(e))) Cache.dispatcher.abort() for p in Cache.publishers: p.join(0.5) Cache.dispatcher.join(0.5) if len(threading.enumerate()) > 1: main_thread = threading.current_thread() log(msg=_('Enumerating threads to kill others than main (%i)') % main_thread.ident) for t in threading.enumerate(): if t is not main_thread and t.is_alive(): log(msg=_('Attempting to kill thread: %i: %s') % (t.ident, t.name)) try: t.abort(0.5) except (threading.ThreadError, AttributeError): log(msg=_('Error killing thread')) else: if not t.is_alive(): log(msg=_('Thread killed succesfully')) else: log(msg=_('Error killing thread')) def start(): global log settings = Settings() settings.getSettings() kl = KodiLogger() if settings.general['elevate_loglevel'] is True: kl.setLogLevel(xbmc.LOGNOTICE) else: kl.setLogLevel(xbmc.LOGDEBUG) log = kl.log log(msg=_('Settings read')) Cache.dispatcher = PubSub_Threaded.Dispatcher(interval=settings.general['TaskFreq'], sleepfxn=xbmc.sleep) log(msg=_('Dispatcher initialized')) subscriberfactory = SubscriberFactory(settings, kl) subscribers = subscriberfactory.createSubscribers() for subscriber in subscribers: Cache.dispatcher.addSubscriber(subscriber) publisherfactory = PublisherFactory(settings, subscriberfactory.topics, Cache.dispatcher, kl, debug) publisherfactory.createPublishers() Cache.publishers = publisherfactory.ipublishers Cache.dispatcher.start() log(msg=_('Dispatcher started')) for p in Cache.publishers: try: p.start() except threading.ThreadError: raise log(msg=_('Publisher(s) started')) def main(): msg = _(u'$$$ [kodi.callbacks] - Staring kodi.callbacks ver: %s (%s:build %s) python: %s').encode('utf-8') % (str(_addonversion_), branch, build, sys.version) xbmc.log(msg=msg, level=xbmc.LOGNOTICE) if branch != 'master': xbmcaddon.Addon().setSetting('installed branch', branch) start() Cache.dispatcher.q_message(PubSub_Threaded.Message(PubSub_Threaded.Topic('onStartup'))) monitor = MainMonitor() log(msg=_('Entering wait loop')) monitor.waitForAbort() # Shutdown tasks Cache.dispatcher.q_message(PubSub_Threaded.Message(PubSub_Threaded.Topic('onShutdown'), pid=os.getpid())) log(msg=_('Shutdown started')) abortall() log(msg='Shutdown complete') if __name__ == '__main__': if testTasks: KodiLogger.setLogLevel(KodiLogger.LOGNOTICE) startdebugger() from resources.lib.tests.testTasks import testTasks tt = testTasks() tt.runTests() else: if branch != 'master': try: from resources.lib.utils.githubtools import processargs except ImportError: pass else: processargs(sys.argv) main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 1898, 334, 35, 9, 6900, 1804, 287, 54, 1020, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 1757, 275, 756, 221, 327, 3254, 26, 1104, 199, 396, 1757, 275, 756, 221, 327, 3254, 26, 1104, 199, 396, 19295, 275, 756, 221, 327, 3254, 26, 1104, 199, 4694, 275, 283, 4133, 7, 199, 1506, 275, 283, 4893, 24, 7, 199, 199, 504, 5944, 14, 773, 14, 1208, 14, 17612, 492, 1343, 17612, 199, 199, 692, 3105, 26, 272, 1343, 17612, 342, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5796, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 5944, 14, 773, 14, 20213, 465, 510, 456, 2610, 63, 31699, 199, 504, 5944, 14, 773, 14, 7697, 328, 4806, 492, 1804, 79, 328, 4455, 199, 504, 5944, 14, 773, 14, 12789, 3702, 492, 19952, 281, 2927, 199, 504, 5944, 14, 773, 14, 17256, 3702, 492, 4804, 10979, 2927, 199, 504, 5944, 14, 773, 14, 1751, 492, 13303, 199, 504, 5944, 14, 773, 14, 1208, 14, 555, 1974, 492, 1804, 79, 328, 1575, 199, 646, 26418, 199, 199, 7697, 328, 555, 275, 1804, 79, 328, 1575, 342, 199, 63, 275, 20817, 328, 555, 14, 362, 29925, 1558, 199, 793, 275, 1804, 79, 328, 4455, 14, 793, 199, 199, 893, 26, 272, 485, 9291, 1023, 63, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 1023, 358, 199, 2590, 6064, 26, 272, 862, 26, 267, 485, 9291, 1023, 63, 275, 11709, 9291, 14, 19654, 360, 1579, 14, 1364, 14, 7697, 328, 14, 11948, 1959, 362, 19654, 2354, 360, 1023, 358, 272, 871, 6064, 26, 267, 485, 9291, 1023, 63, 275, 283, 3170, 10232, 1015, 7, 421, 199, 533, 11977, 8, 785, 304, 272, 2780, 1192, 275, 488, 272, 17475, 275, 488, 421, 199, 533, 11298, 13189, 8, 21382, 14, 13189, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 6756, 13189, 12, 291, 2843, 826, 4533, 339, 347, 641, 5268, 6970, 8, 277, 304, 267, 9592, 275, 26418, 14, 5619, 342, 267, 1499, 275, 4018, 3917, 1742, 10567, 6366, 12, 3879, 922, 6527, 883, 12927, 960, 2195, 2656, 3134, 13705, 922, 15194, 1006, 22633, 83, 436, 1212, 3616, 367, 3879, 6527, 14, 1959, 1294, 2258, 78, 358, 267, 9592, 14, 745, 6723, 31305, 328, 17555, 83, 659, 1004, 17, 29, 1328, 59, 16, 467, 1004, 18, 29, 1328, 59, 17, 566, 267, 943, 8, 1328, 12397, 5268, 1570, 10501, 446, 19595, 370, 11004, 1333, 267, 12004, 452, 342, 267, 1343, 342, 421, 199, 318, 12004, 452, 837, 272, 367, 299, 315, 11977, 14, 4763, 1192, 26, 267, 862, 26, 288, 299, 14, 13845, 342, 267, 871, 5796, 14, 4436, 547, 465, 325, 26, 288, 943, 8, 1328, 12397, 547, 12004, 316, 26, 450, 83, 446, 4520, 26, 450, 83, 358, 450, 334, 495, 8, 80, 395, 620, 8, 69, 1724, 272, 11977, 14, 14913, 14, 13845, 342, 272, 367, 299, 315, 11977, 14, 4763, 1192, 26, 267, 299, 14, 904, 8, 16, 14, 21, 9, 272, 11977, 14, 14913, 14, 904, 8, 16, 14, 21, 9, 272, 340, 822, 8, 12562, 14, 26318, 1012, 690, 413, 26, 267, 2446, 63, 2671, 275, 5796, 14, 1818, 63, 2671, 342, 267, 943, 8, 1328, 12397, 28858, 10417, 7183, 370, 14561, 11789, 2419, 2446, 4366, 73, 5942, 450, 2446, 63, 2671, 14, 5425, 9, 267, 367, 307, 315, 5796, 14, 26318, 837, 288, 340, 307, 365, 440, 2446, 63, 2671, 436, 307, 14, 374, 63, 9631, 837, 355, 943, 8, 1328, 12397, 15322, 1337, 370, 14561, 2462, 26, 450, 73, 26, 450, 83, 358, 450, 334, 84, 14, 5425, 12, 307, 14, 354, 430, 355, 862, 26, 490, 307, 14, 13845, 8, 16, 14, 21, 9, 355, 871, 334, 12562, 14, 4436, 547, 12, 4281, 304, 490, 943, 8, 1328, 12397, 547, 1022, 12687, 2462, 1333, 355, 587, 26, 490, 340, 440, 307, 14, 374, 63, 9631, 837, 717, 943, 8, 1328, 12397, 4436, 26659, 27028, 5836, 1333, 490, 587, 26, 717, 943, 8, 1328, 12397, 547, 1022, 12687, 2462, 1333, 421, 199, 318, 1343, 837, 272, 2288, 943, 272, 2202, 275, 13303, 342, 272, 2202, 14, 362, 5268, 342, 272, 26151, 275, 1804, 79, 328, 4455, 342, 272, 340, 2202, 14, 10706, 459, 8081, 2409, 63, 26629, 418, 365, 715, 26, 267, 26151, 14, 409, 2445, 4670, 8, 21382, 14, 4947, 4609, 4047, 9, 272, 587, 26, 267, 26151, 14, 409, 2445, 4670, 8, 21382, 14, 4947, 5287, 9, 272, 943, 275, 26151, 14, 793, 272, 943, 8, 1328, 12397, 5268, 1586, 1333, 272, 11977, 14, 14913, 275, 510, 456, 2610, 63, 31699, 14, 15461, 8, 4284, 29, 1751, 14, 10706, 459, 4476, 13875, 995, 9435, 70, 5032, 29, 21382, 14, 4532, 9, 272, 943, 8, 1328, 12397, 15461, 10038, 1333, 339, 22148, 3702, 275, 4804, 10979, 2927, 8, 1751, 12, 26151, 9, 272, 22148, 83, 275, 22148, 3702, 14, 981, 28638, 83, 342, 272, 367, 22148, 315, 22148, 83, 26, 267, 11977, 14, 14913, 14, 525, 28638, 8, 17256, 9, 272, 19704, 3702, 275, 19952, 281, 2927, 8, 1751, 12, 22148, 3702, 14, 11299, 12, 11977, 14, 14913 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 1898, 334, 35, 9, 6900, 1804, 287, 54, 1020, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 1757, 275, 756, 221, 327, 3254, 26, 1104, 199, 396, 1757, 275, 756, 221, 327, 3254, 26, 1104, 199, 396, 19295, 275, 756, 221, 327, 3254, 26, 1104, 199, 4694, 275, 283, 4133, 7, 199, 1506, 275, 283, 4893, 24, 7, 199, 199, 504, 5944, 14, 773, 14, 1208, 14, 17612, 492, 1343, 17612, 199, 199, 692, 3105, 26, 272, 1343, 17612, 342, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5796, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 5944, 14, 773, 14, 20213, 465, 510, 456, 2610, 63, 31699, 199, 504, 5944, 14, 773, 14, 7697, 328, 4806, 492, 1804, 79, 328, 4455, 199, 504, 5944, 14, 773, 14, 12789, 3702, 492, 19952, 281, 2927, 199, 504, 5944, 14, 773, 14, 17256, 3702, 492, 4804, 10979, 2927, 199, 504, 5944, 14, 773, 14, 1751, 492, 13303, 199, 504, 5944, 14, 773, 14, 1208, 14, 555, 1974, 492, 1804, 79, 328, 1575, 199, 646, 26418, 199, 199, 7697, 328, 555, 275, 1804, 79, 328, 1575, 342, 199, 63, 275, 20817, 328, 555, 14, 362, 29925, 1558, 199, 793, 275, 1804, 79, 328, 4455, 14, 793, 199, 199, 893, 26, 272, 485, 9291, 1023, 63, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 360, 1023, 358, 199, 2590, 6064, 26, 272, 862, 26, 267, 485, 9291, 1023, 63, 275, 11709, 9291, 14, 19654, 360, 1579, 14, 1364, 14, 7697, 328, 14, 11948, 1959, 362, 19654, 2354, 360, 1023, 358, 272, 871, 6064, 26, 267, 485, 9291, 1023, 63, 275, 283, 3170, 10232, 1015, 7, 421, 199, 533, 11977, 8, 785, 304, 272, 2780, 1192, 275, 488, 272, 17475, 275, 488, 421, 199, 533, 11298, 13189, 8, 21382, 14, 13189, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 6756, 13189, 12, 291, 2843, 826, 4533, 339, 347, 641, 5268, 6970, 8, 277, 304, 267, 9592, 275, 26418, 14, 5619, 342, 267, 1499, 275, 4018, 3917, 1742, 10567, 6366, 12, 3879, 922, 6527, 883, 12927, 960, 2195, 2656, 3134, 13705, 922, 15194, 1006, 22633, 83, 436, 1212, 3616, 367, 3879, 6527, 14, 1959, 1294, 2258, 78, 358, 267, 9592, 14, 745, 6723, 31305, 328, 17555, 83, 659, 1004, 17, 29, 1328, 59, 16, 467, 1004, 18, 29, 1328, 59, 17, 566, 267, 943, 8, 1328, 12397, 5268, 1570, 10501, 446, 19595, 370, 11004, 1333, 267, 12004, 452, 342, 267, 1343, 342, 421, 199, 318, 12004, 452, 837, 272, 367, 299, 315, 11977, 14, 4763, 1192, 26, 267, 862, 26, 288, 299, 14, 13845, 342, 267, 871, 5796, 14, 4436, 547, 465, 325, 26, 288, 943, 8, 1328, 12397, 547, 12004, 316, 26, 450, 83, 446, 4520, 26, 450, 83, 358, 450, 334, 495, 8, 80, 395, 620, 8, 69, 1724, 272, 11977, 14, 14913, 14, 13845, 342, 272, 367, 299, 315, 11977, 14, 4763, 1192, 26, 267, 299, 14, 904, 8, 16, 14, 21, 9, 272, 11977, 14, 14913, 14, 904, 8, 16, 14, 21, 9, 272, 340, 822, 8, 12562, 14, 26318, 1012, 690, 413, 26, 267, 2446, 63, 2671, 275, 5796, 14, 1818, 63, 2671, 342, 267, 943, 8, 1328, 12397, 28858, 10417, 7183, 370, 14561, 11789, 2419, 2446, 4366, 73, 5942, 450, 2446, 63, 2671, 14, 5425, 9, 267, 367, 307, 315, 5796, 14, 26318, 837, 288, 340, 307, 365, 440, 2446, 63, 2671, 436, 307, 14, 374, 63, 9631, 837, 355, 943, 8, 1328, 12397, 15322, 1337, 370, 14561, 2462, 26, 450, 73, 26, 450, 83, 358, 450, 334, 84, 14, 5425, 12, 307, 14, 354, 430, 355, 862, 26, 490, 307, 14, 13845, 8, 16, 14, 21, 9, 355, 871, 334, 12562, 14, 4436, 547, 12, 4281, 304, 490, 943, 8, 1328, 12397, 547, 1022, 12687, 2462, 1333, 355, 587, 26, 490, 340, 440, 307, 14, 374, 63, 9631, 837, 717, 943, 8, 1328, 12397, 4436, 26659, 27028, 5836, 1333, 490, 587, 26, 717, 943, 8, 1328, 12397, 547, 1022, 12687, 2462, 1333, 421, 199, 318, 1343, 837, 272, 2288, 943, 272, 2202, 275, 13303, 342, 272, 2202, 14, 362, 5268, 342, 272, 26151, 275, 1804, 79, 328, 4455, 342, 272, 340, 2202, 14, 10706, 459, 8081, 2409, 63, 26629, 418, 365, 715, 26, 267, 26151, 14, 409, 2445, 4670, 8, 21382, 14, 4947, 4609, 4047, 9, 272, 587, 26, 267, 26151, 14, 409, 2445, 4670, 8, 21382, 14, 4947, 5287, 9, 272, 943, 275, 26151, 14, 793, 272, 943, 8, 1328, 12397, 5268, 1586, 1333, 272, 11977, 14, 14913, 275, 510, 456, 2610, 63, 31699, 14, 15461, 8, 4284, 29, 1751, 14, 10706, 459, 4476, 13875, 995, 9435, 70, 5032, 29, 21382, 14, 4532, 9, 272, 943, 8, 1328, 12397, 15461, 10038, 1333, 339, 22148, 3702, 275, 4804, 10979, 2927, 8, 1751, 12, 26151, 9, 272, 22148, 83, 275, 22148, 3702, 14, 981, 28638, 83, 342, 272, 367, 22148, 315, 22148, 83, 26, 267, 11977, 14, 14913, 14, 525, 28638, 8, 17256, 9, 272, 19704, 3702, 275, 19952, 281, 2927, 8, 1751, 12, 22148, 3702, 14, 11299, 12, 11977, 14, 14913, 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,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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 ]
aajtodd/zipline
tests/risk/answer_key.py
39
11989
# # Copyright 2014 Quantopian, Inc. # # 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 datetime import hashlib import os import numpy as np import pandas as pd import pytz import xlrd import requests from six.moves import map def col_letter_to_index(col_letter): # Only supports single letter, # but answer key doesn't need multi-letter, yet. index = 0 for i, char in enumerate(reversed(col_letter)): index += ((ord(char) - 65) + 1) * pow(26, i) return index DIR = os.path.dirname(os.path.realpath(__file__)) ANSWER_KEY_CHECKSUMS_PATH = os.path.join(DIR, 'risk-answer-key-checksums') ANSWER_KEY_CHECKSUMS = open(ANSWER_KEY_CHECKSUMS_PATH, 'r').read().splitlines() ANSWER_KEY_FILENAME = 'risk-answer-key.xlsx' ANSWER_KEY_PATH = os.path.join(DIR, ANSWER_KEY_FILENAME) ANSWER_KEY_BUCKET_NAME = 'zipline-test_data' ANSWER_KEY_DL_TEMPLATE = """ https://s3.amazonaws.com/zipline-test-data/risk/{md5}/risk-answer-key.xlsx """.strip() LATEST_ANSWER_KEY_URL = ANSWER_KEY_DL_TEMPLATE.format( md5=ANSWER_KEY_CHECKSUMS[-1]) def answer_key_signature(): with open(ANSWER_KEY_PATH, 'rb') as f: md5 = hashlib.md5() buf = f.read(1024) md5.update(buf) while buf != b"": buf = f.read(1024) md5.update(buf) return md5.hexdigest() def ensure_latest_answer_key(): """ Get the latest answer key from a publically available location. Logic for determining what and when to download is as such: - If there is no local spreadsheet file, then get the lastest answer key, as defined by the last row in the checksum file. - If there is a local spreadsheet file: -- If the spreadsheet's checksum is in the checksum file: --- If the spreadsheet's checksum does not match the latest, then grab the the latest checksum and replace the local checksum file. --- If the spreadsheet's checksum matches the latest, then skip download, and use the local spreadsheet as a cached copy. -- If the spreadsheet's checksum is not in the checksum file, then leave the local file alone, assuming that the local xls's md5 is not in the list due to local modifications during development. It is possible that md5's could collide, if that is ever case, we should then find an alternative naming scheme. The spreadsheet answer sheet is not kept in SCM, as every edit would increase the repo size by the file size, since it is treated as a binary. """ answer_key_dl_checksum = None local_answer_key_exists = os.path.exists(ANSWER_KEY_PATH) if local_answer_key_exists: local_hash = answer_key_signature() if local_hash in ANSWER_KEY_CHECKSUMS: # Assume previously downloaded version. # Check for latest. if local_hash != ANSWER_KEY_CHECKSUMS[-1]: # More recent checksum, download answer_key_dl_checksum = ANSWER_KEY_CHECKSUMS[-1] else: # Assume local copy that is being developed on answer_key_dl_checksum = None else: answer_key_dl_checksum = ANSWER_KEY_CHECKSUMS[-1] if answer_key_dl_checksum: res = requests.get( ANSWER_KEY_DL_TEMPLATE.format(md5=answer_key_dl_checksum)) with open(ANSWER_KEY_PATH, 'wb') as f: f.write(res.content) # Get latest answer key on load. ensure_latest_answer_key() class DataIndex(object): """ Coordinates for the spreadsheet, using the values as seen in the notebook. The python-excel libraries use 0 index, while the spreadsheet in a GUI uses a 1 index. """ def __init__(self, sheet_name, col, row_start, row_end, value_type='float'): self.sheet_name = sheet_name self.col = col self.row_start = row_start self.row_end = row_end self.value_type = value_type @property def col_index(self): return col_letter_to_index(self.col) - 1 @property def row_start_index(self): return self.row_start - 1 @property def row_end_index(self): return self.row_end - 1 def __str__(self): return "'{sheet_name}'!{col}{row_start}:{col}{row_end}".format( sheet_name=self.sheet_name, col=self.col, row_start=self.row_start, row_end=self.row_end ) class AnswerKey(object): INDEXES = { 'RETURNS': DataIndex('Sim Period', 'D', 4, 255), 'BENCHMARK': { 'Dates': DataIndex('s_p', 'A', 4, 254, value_type='date'), 'Returns': DataIndex('s_p', 'H', 4, 254) }, # Below matches the inconsistent capitalization in spreadsheet 'BENCHMARK_PERIOD_RETURNS': { 'Monthly': DataIndex('s_p', 'R', 8, 19), '3-Month': DataIndex('s_p', 'S', 10, 19), '6-month': DataIndex('s_p', 'T', 13, 19), 'year': DataIndex('s_p', 'U', 19, 19), }, 'BENCHMARK_PERIOD_VOLATILITY': { 'Monthly': DataIndex('s_p', 'V', 8, 19), '3-Month': DataIndex('s_p', 'W', 10, 19), '6-month': DataIndex('s_p', 'X', 13, 19), 'year': DataIndex('s_p', 'Y', 19, 19), }, 'ALGORITHM_PERIOD_RETURNS': { 'Monthly': DataIndex('Sim Period', 'Z', 23, 34), '3-Month': DataIndex('Sim Period', 'AA', 25, 34), '6-month': DataIndex('Sim Period', 'AB', 28, 34), 'year': DataIndex('Sim Period', 'AC', 34, 34), }, 'ALGORITHM_PERIOD_VOLATILITY': { 'Monthly': DataIndex('Sim Period', 'AH', 23, 34), '3-Month': DataIndex('Sim Period', 'AI', 25, 34), '6-month': DataIndex('Sim Period', 'AJ', 28, 34), 'year': DataIndex('Sim Period', 'AK', 34, 34), }, 'ALGORITHM_PERIOD_SHARPE': { 'Monthly': DataIndex('Sim Period', 'AL', 23, 34), '3-Month': DataIndex('Sim Period', 'AM', 25, 34), '6-month': DataIndex('Sim Period', 'AN', 28, 34), 'year': DataIndex('Sim Period', 'AO', 34, 34), }, 'ALGORITHM_PERIOD_BETA': { 'Monthly': DataIndex('Sim Period', 'AP', 23, 34), '3-Month': DataIndex('Sim Period', 'AQ', 25, 34), '6-month': DataIndex('Sim Period', 'AR', 28, 34), 'year': DataIndex('Sim Period', 'AS', 34, 34), }, 'ALGORITHM_PERIOD_ALPHA': { 'Monthly': DataIndex('Sim Period', 'AT', 23, 34), '3-Month': DataIndex('Sim Period', 'AU', 25, 34), '6-month': DataIndex('Sim Period', 'AV', 28, 34), 'year': DataIndex('Sim Period', 'AW', 34, 34), }, 'ALGORITHM_PERIOD_BENCHMARK_VARIANCE': { 'Monthly': DataIndex('Sim Period', 'BJ', 23, 34), '3-Month': DataIndex('Sim Period', 'BK', 25, 34), '6-month': DataIndex('Sim Period', 'BL', 28, 34), 'year': DataIndex('Sim Period', 'BM', 34, 34), }, 'ALGORITHM_PERIOD_COVARIANCE': { 'Monthly': DataIndex('Sim Period', 'BF', 23, 34), '3-Month': DataIndex('Sim Period', 'BG', 25, 34), '6-month': DataIndex('Sim Period', 'BH', 28, 34), 'year': DataIndex('Sim Period', 'BI', 34, 34), }, 'ALGORITHM_PERIOD_DOWNSIDE_RISK': { 'Monthly': DataIndex('Sim Period', 'BN', 23, 34), '3-Month': DataIndex('Sim Period', 'BO', 25, 34), '6-month': DataIndex('Sim Period', 'BP', 28, 34), 'year': DataIndex('Sim Period', 'BQ', 34, 34), }, 'ALGORITHM_PERIOD_SORTINO': { 'Monthly': DataIndex('Sim Period', 'BR', 23, 34), '3-Month': DataIndex('Sim Period', 'BS', 25, 34), '6-month': DataIndex('Sim Period', 'BT', 28, 34), 'year': DataIndex('Sim Period', 'BU', 34, 34), }, 'ALGORITHM_RETURN_VALUES': DataIndex( 'Sim Cumulative', 'D', 4, 254), 'ALGORITHM_CUMULATIVE_VOLATILITY': DataIndex( 'Sim Cumulative', 'P', 4, 254), 'ALGORITHM_CUMULATIVE_SHARPE': DataIndex( 'Sim Cumulative', 'R', 4, 254), 'CUMULATIVE_DOWNSIDE_RISK': DataIndex( 'Sim Cumulative', 'U', 4, 254), 'CUMULATIVE_SORTINO': DataIndex( 'Sim Cumulative', 'V', 4, 254), 'CUMULATIVE_INFORMATION': DataIndex( 'Sim Cumulative', 'AA', 4, 254), 'CUMULATIVE_BETA': DataIndex( 'Sim Cumulative', 'AD', 4, 254), 'CUMULATIVE_ALPHA': DataIndex( 'Sim Cumulative', 'AE', 4, 254), 'CUMULATIVE_MAX_DRAWDOWN': DataIndex( 'Sim Cumulative', 'AH', 4, 254), } def __init__(self): self.workbook = xlrd.open_workbook(ANSWER_KEY_PATH) self.sheets = {} self.sheets['Sim Period'] = self.workbook.sheet_by_name('Sim Period') self.sheets['Sim Cumulative'] = self.workbook.sheet_by_name( 'Sim Cumulative') self.sheets['s_p'] = self.workbook.sheet_by_name('s_p') for name, index in self.INDEXES.items(): if isinstance(index, dict): subvalues = {} for subkey, subindex in index.items(): subvalues[subkey] = self.get_values(subindex) setattr(self, name, subvalues) else: setattr(self, name, self.get_values(index)) def parse_date_value(self, value): return xlrd.xldate_as_tuple(value, 0) def parse_float_value(self, value): return value if value != '' else np.nan def get_raw_values(self, data_index): return self.sheets[data_index.sheet_name].col_values( data_index.col_index, data_index.row_start_index, data_index.row_end_index + 1) @property def value_type_to_value_func(self): return { 'float': self.parse_float_value, 'date': self.parse_date_value, } def get_values(self, data_index): value_parser = self.value_type_to_value_func[data_index.value_type] return [value for value in map(value_parser, self.get_raw_values(data_index))] ANSWER_KEY = AnswerKey() BENCHMARK_DATES = ANSWER_KEY.BENCHMARK['Dates'] BENCHMARK_RETURNS = ANSWER_KEY.BENCHMARK['Returns'] DATES = [datetime.datetime(*x, tzinfo=pytz.UTC) for x in BENCHMARK_DATES] BENCHMARK = pd.Series(dict(zip(DATES, BENCHMARK_RETURNS))) ALGORITHM_RETURNS = pd.Series( dict(zip(DATES, ANSWER_KEY.ALGORITHM_RETURN_VALUES))) RETURNS_DATA = pd.DataFrame({'Benchmark Returns': BENCHMARK, 'Algorithm Returns': ALGORITHM_RETURNS}) RISK_CUMULATIVE = pd.DataFrame({ 'volatility': pd.Series(dict(zip( DATES, ANSWER_KEY.ALGORITHM_CUMULATIVE_VOLATILITY))), 'sharpe': pd.Series(dict(zip( DATES, ANSWER_KEY.ALGORITHM_CUMULATIVE_SHARPE))), 'downside_risk': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_DOWNSIDE_RISK))), 'sortino': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_SORTINO))), 'information': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_INFORMATION))), 'alpha': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_ALPHA))), 'beta': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_BETA))), 'max_drawdown': pd.Series(dict(zip( DATES, ANSWER_KEY.CUMULATIVE_MAX_DRAWDOWN))), })
apache-2.0
[ 3, 199, 3, 1898, 6927, 5843, 867, 411, 5653, 12, 3277, 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, 646, 2197, 199, 646, 8337, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 15444, 199, 646, 25077, 6883, 199, 646, 4145, 199, 199, 504, 3816, 14, 4912, 492, 2341, 421, 199, 318, 1048, 63, 9269, 63, 475, 63, 1080, 8, 761, 63, 9269, 304, 272, 327, 5972, 5171, 2849, 8082, 12, 272, 327, 1325, 6385, 790, 3181, 1133, 1929, 3510, 13, 9269, 12, 5966, 14, 272, 1478, 275, 378, 272, 367, 284, 12, 1495, 315, 3874, 8, 13501, 8, 761, 63, 9269, 2298, 267, 1478, 847, 3666, 2181, 8, 1560, 9, 446, 11738, 9, 435, 413, 9, 627, 13131, 8, 1479, 12, 284, 9, 272, 372, 1478, 199, 199, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 3022, 12, 283, 27473, 13, 5934, 13, 498, 13, 8928, 83, 358, 199, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 275, 1551, 8, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 63, 3243, 12, 283, 82, 1959, 739, 1252, 7644, 342, 199, 199, 5622, 12018, 63, 3078, 63, 15440, 275, 283, 27473, 13, 5934, 13, 498, 14, 19023, 88, 7, 199, 199, 5622, 12018, 63, 3078, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 3022, 12, 1261, 8745, 540, 63, 3078, 63, 15440, 9, 199, 199, 5622, 12018, 63, 3078, 63, 20156, 63, 2339, 275, 283, 3065, 604, 13, 396, 63, 576, 7, 199, 199, 5622, 12018, 63, 3078, 63, 8045, 63, 7433, 275, 408, 199, 2859, 921, 83, 19, 14, 21442, 14, 957, 15, 3065, 604, 13, 396, 13, 576, 15, 27473, 5321, 1064, 21, 5995, 27473, 13, 5934, 13, 498, 14, 19023, 88, 199, 23045, 1913, 342, 199, 199, 20307, 1719, 63, 5622, 12018, 63, 3078, 63, 2632, 275, 1261, 8745, 540, 63, 3078, 63, 8045, 63, 7433, 14, 908, 8, 272, 6128, 21, 29, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 566, 421, 199, 318, 6385, 63, 498, 63, 5233, 837, 272, 543, 1551, 8, 5622, 12018, 63, 3078, 63, 3243, 12, 283, 4848, 358, 465, 289, 26, 267, 6128, 21, 275, 8337, 14, 1064, 21, 342, 267, 4123, 275, 289, 14, 739, 8, 7727, 9, 267, 6128, 21, 14, 873, 8, 1436, 9, 267, 1830, 4123, 1137, 330, 29679, 288, 4123, 275, 289, 14, 739, 8, 7727, 9, 288, 6128, 21, 14, 873, 8, 1436, 9, 272, 372, 6128, 21, 14, 11453, 342, 421, 199, 318, 4868, 63, 7410, 63, 5934, 63, 498, 837, 272, 408, 272, 2372, 314, 8839, 6385, 790, 687, 282, 4575, 1183, 2808, 2909, 14, 339, 5297, 530, 367, 26638, 4052, 436, 1380, 370, 5235, 365, 465, 4066, 26, 339, 446, 982, 2337, 365, 949, 2257, 27076, 570, 12, 2066, 664, 314, 23325, 396, 6385, 790, 12, 272, 465, 3247, 701, 314, 2061, 1962, 315, 314, 9040, 570, 14, 272, 446, 982, 2337, 365, 282, 2257, 27076, 570, 26, 272, 1553, 982, 314, 27076, 1159, 9040, 365, 315, 314, 9040, 570, 26, 272, 10894, 982, 314, 27076, 1159, 9040, 1630, 440, 1336, 314, 8839, 12, 2066, 18200, 314, 272, 314, 8839, 9040, 436, 3350, 314, 2257, 9040, 570, 14, 272, 10894, 982, 314, 27076, 1159, 9040, 4450, 314, 8839, 12, 2066, 3372, 5235, 12, 272, 436, 675, 314, 2257, 27076, 465, 282, 6328, 1331, 14, 272, 1553, 982, 314, 27076, 1159, 9040, 365, 440, 315, 314, 9040, 570, 12, 2066, 10137, 272, 314, 2257, 570, 23016, 12, 18002, 626, 314, 2257, 671, 478, 1159, 6128, 21, 365, 440, 315, 314, 769, 272, 7037, 370, 2257, 23070, 5309, 16367, 14, 339, 2779, 365, 3962, 626, 6128, 21, 1159, 4293, 1048, 8409, 12, 340, 626, 365, 14433, 1930, 12, 781, 1077, 272, 2066, 2342, 376, 13943, 19720, 5687, 14, 339, 710, 27076, 6385, 12083, 365, 440, 16204, 315, 428, 9249, 12, 465, 4036, 5283, 3955, 272, 19781, 314, 3831, 1568, 701, 314, 570, 1568, 12, 3967, 652, 365, 10184, 465, 282, 3366, 14, 272, 408, 339, 6385, 63, 498, 63, 5030, 63, 8928, 275, 488, 339, 2257, 63, 5934, 63, 498, 63, 2444, 275, 747, 14, 515, 14, 2444, 8, 5622, 12018, 63, 3078, 63, 3243, 9, 272, 340, 2257, 63, 5934, 63, 498, 63, 2444, 26, 267, 2257, 63, 2227, 275, 6385, 63, 498, 63, 5233, 342, 398, 340, 2257, 63, 2227, 315, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 26, 288, 327, 16269, 10889, 13557, 1015, 14, 288, 327, 2670, 367, 8839, 14, 288, 340, 2257, 63, 2227, 1137, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 2189, 355, 327, 16917, 8058, 9040, 12, 5235, 355, 6385, 63, 498, 63, 5030, 63, 8928, 275, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 61, 288, 587, 26, 355, 327, 16269, 2257, 1331, 626, 365, 3769, 477, 27813, 641, 355, 6385, 63, 498, 63, 5030, 63, 8928, 275, 488, 272, 587, 26, 267, 6385, 63, 498, 63, 5030, 63, 8928, 275, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 61, 339, 340, 6385, 63, 498, 63, 5030, 63, 8928, 26, 267, 522, 275, 4145, 14, 362, 8, 288, 1261, 8745, 540, 63, 3078, 63, 8045, 63 ]
[ 199, 3, 1898, 6927, 5843, 867, 411, 5653, 12, 3277, 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, 646, 2197, 199, 646, 8337, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 15444, 199, 646, 25077, 6883, 199, 646, 4145, 199, 199, 504, 3816, 14, 4912, 492, 2341, 421, 199, 318, 1048, 63, 9269, 63, 475, 63, 1080, 8, 761, 63, 9269, 304, 272, 327, 5972, 5171, 2849, 8082, 12, 272, 327, 1325, 6385, 790, 3181, 1133, 1929, 3510, 13, 9269, 12, 5966, 14, 272, 1478, 275, 378, 272, 367, 284, 12, 1495, 315, 3874, 8, 13501, 8, 761, 63, 9269, 2298, 267, 1478, 847, 3666, 2181, 8, 1560, 9, 446, 11738, 9, 435, 413, 9, 627, 13131, 8, 1479, 12, 284, 9, 272, 372, 1478, 199, 199, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 3022, 12, 283, 27473, 13, 5934, 13, 498, 13, 8928, 83, 358, 199, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 275, 1551, 8, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 63, 3243, 12, 283, 82, 1959, 739, 1252, 7644, 342, 199, 199, 5622, 12018, 63, 3078, 63, 15440, 275, 283, 27473, 13, 5934, 13, 498, 14, 19023, 88, 7, 199, 199, 5622, 12018, 63, 3078, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 3022, 12, 1261, 8745, 540, 63, 3078, 63, 15440, 9, 199, 199, 5622, 12018, 63, 3078, 63, 20156, 63, 2339, 275, 283, 3065, 604, 13, 396, 63, 576, 7, 199, 199, 5622, 12018, 63, 3078, 63, 8045, 63, 7433, 275, 408, 199, 2859, 921, 83, 19, 14, 21442, 14, 957, 15, 3065, 604, 13, 396, 13, 576, 15, 27473, 5321, 1064, 21, 5995, 27473, 13, 5934, 13, 498, 14, 19023, 88, 199, 23045, 1913, 342, 199, 199, 20307, 1719, 63, 5622, 12018, 63, 3078, 63, 2632, 275, 1261, 8745, 540, 63, 3078, 63, 8045, 63, 7433, 14, 908, 8, 272, 6128, 21, 29, 5622, 12018, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 566, 421, 199, 318, 6385, 63, 498, 63, 5233, 837, 272, 543, 1551, 8, 5622, 12018, 63, 3078, 63, 3243, 12, 283, 4848, 358, 465, 289, 26, 267, 6128, 21, 275, 8337, 14, 1064, 21, 342, 267, 4123, 275, 289, 14, 739, 8, 7727, 9, 267, 6128, 21, 14, 873, 8, 1436, 9, 267, 1830, 4123, 1137, 330, 29679, 288, 4123, 275, 289, 14, 739, 8, 7727, 9, 288, 6128, 21, 14, 873, 8, 1436, 9, 272, 372, 6128, 21, 14, 11453, 342, 421, 199, 318, 4868, 63, 7410, 63, 5934, 63, 498, 837, 272, 408, 272, 2372, 314, 8839, 6385, 790, 687, 282, 4575, 1183, 2808, 2909, 14, 339, 5297, 530, 367, 26638, 4052, 436, 1380, 370, 5235, 365, 465, 4066, 26, 339, 446, 982, 2337, 365, 949, 2257, 27076, 570, 12, 2066, 664, 314, 23325, 396, 6385, 790, 12, 272, 465, 3247, 701, 314, 2061, 1962, 315, 314, 9040, 570, 14, 272, 446, 982, 2337, 365, 282, 2257, 27076, 570, 26, 272, 1553, 982, 314, 27076, 1159, 9040, 365, 315, 314, 9040, 570, 26, 272, 10894, 982, 314, 27076, 1159, 9040, 1630, 440, 1336, 314, 8839, 12, 2066, 18200, 314, 272, 314, 8839, 9040, 436, 3350, 314, 2257, 9040, 570, 14, 272, 10894, 982, 314, 27076, 1159, 9040, 4450, 314, 8839, 12, 2066, 3372, 5235, 12, 272, 436, 675, 314, 2257, 27076, 465, 282, 6328, 1331, 14, 272, 1553, 982, 314, 27076, 1159, 9040, 365, 440, 315, 314, 9040, 570, 12, 2066, 10137, 272, 314, 2257, 570, 23016, 12, 18002, 626, 314, 2257, 671, 478, 1159, 6128, 21, 365, 440, 315, 314, 769, 272, 7037, 370, 2257, 23070, 5309, 16367, 14, 339, 2779, 365, 3962, 626, 6128, 21, 1159, 4293, 1048, 8409, 12, 340, 626, 365, 14433, 1930, 12, 781, 1077, 272, 2066, 2342, 376, 13943, 19720, 5687, 14, 339, 710, 27076, 6385, 12083, 365, 440, 16204, 315, 428, 9249, 12, 465, 4036, 5283, 3955, 272, 19781, 314, 3831, 1568, 701, 314, 570, 1568, 12, 3967, 652, 365, 10184, 465, 282, 3366, 14, 272, 408, 339, 6385, 63, 498, 63, 5030, 63, 8928, 275, 488, 339, 2257, 63, 5934, 63, 498, 63, 2444, 275, 747, 14, 515, 14, 2444, 8, 5622, 12018, 63, 3078, 63, 3243, 9, 272, 340, 2257, 63, 5934, 63, 498, 63, 2444, 26, 267, 2257, 63, 2227, 275, 6385, 63, 498, 63, 5233, 342, 398, 340, 2257, 63, 2227, 315, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 26, 288, 327, 16269, 10889, 13557, 1015, 14, 288, 327, 2670, 367, 8839, 14, 288, 340, 2257, 63, 2227, 1137, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 2189, 355, 327, 16917, 8058, 9040, 12, 5235, 355, 6385, 63, 498, 63, 5030, 63, 8928, 275, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 61, 288, 587, 26, 355, 327, 16269, 2257, 1331, 626, 365, 3769, 477, 27813, 641, 355, 6385, 63, 498, 63, 5030, 63, 8928, 275, 488, 272, 587, 26, 267, 6385, 63, 498, 63, 5030, 63, 8928, 275, 1261, 8745, 540, 63, 3078, 63, 8936, 13285, 51, 1988, 17, 61, 339, 340, 6385, 63, 498, 63, 5030, 63, 8928, 26, 267, 522, 275, 4145, 14, 362, 8, 288, 1261, 8745, 540, 63, 3078, 63, 8045, 63, 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,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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 ]
ideasiii/ControllerPlatform
Controller-WheelPies/extLibs/mongo-cxx-driver/src/third_party/gtest-1.7.0/test/gtest_env_var_test.py
2408
3487
#!/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 parses environment variables.""" __author__ = 'wan@google.com (Zhanyong Wan)' import os import gtest_test_utils IS_WINDOWS = os.name == 'nt' IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_') environ = os.environ.copy() def AssertEq(expected, actual): if expected != actual: print 'Expected: %s' % (expected,) print ' Actual: %s' % (actual,) raise AssertionError def SetEnvVar(env_var, value): """Sets the env variable to 'value'; unsets it when 'value' is None.""" if value is not None: environ[env_var] = value elif env_var in environ: del environ[env_var] def GetFlag(flag): """Runs gtest_env_var_test_ and returns its output.""" args = [COMMAND] if flag is not None: args += [flag] return gtest_test_utils.Subprocess(args, env=environ).output def TestFlag(flag, test_val, default_val): """Verifies that the given flag is affected by the corresponding env var.""" env_var = 'GTEST_' + flag.upper() SetEnvVar(env_var, test_val) AssertEq(test_val, GetFlag(flag)) SetEnvVar(env_var, None) AssertEq(default_val, GetFlag(flag)) class GTestEnvVarTest(gtest_test_utils.TestCase): def testEnvVarAffectsFlag(self): """Tests that environment variable should affect the corresponding flag.""" TestFlag('break_on_failure', '1', '0') TestFlag('color', 'yes', 'auto') TestFlag('filter', 'FooTest.Bar', '*') TestFlag('output', 'xml:tmp/foo.xml', '') TestFlag('print_time', '0', '1') TestFlag('repeat', '999', '1') TestFlag('throw_on_failure', '1', '0') TestFlag('death_test_style', 'threadsafe', 'fast') TestFlag('catch_exceptions', '0', '1') if IS_LINUX: TestFlag('death_test_use_fork', '1', '0') TestFlag('stack_trace_depth', '0', '100') if __name__ == '__main__': gtest_test_utils.Main()
gpl-3.0
[ 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, 19953, 3734, 2860, 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, 508, 283, 343, 7, 199, 1311, 63, 26030, 275, 747, 14, 354, 508, 283, 9228, 7, 436, 747, 14, 16040, 3430, 16, 61, 508, 283, 14091, 7, 199, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1813, 63, 1391, 63, 396, 15452, 199, 199, 2314, 275, 747, 14, 2314, 14, 1574, 342, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 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, 6160, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 6160, 26, 272, 2150, 6160, 59, 1813, 63, 1391, 61, 421, 199, 318, 2372, 5318, 8, 4173, 304, 523, 408, 16291, 9088, 63, 1813, 63, 1391, 63, 396, 63, 436, 2529, 2399, 1072, 1041, 819, 1249, 275, 359, 10761, 61, 523, 340, 3305, 365, 440, 488, 26, 272, 1249, 847, 359, 4173, 61, 523, 372, 9088, 63, 396, 63, 1208, 14, 22299, 8, 589, 12, 2589, 29, 2314, 680, 1199, 421, 199, 318, 1379, 5318, 8, 4173, 12, 511, 63, 637, 12, 849, 63, 637, 304, 523, 408, 21168, 626, 314, 1627, 3305, 365, 16955, 701, 314, 5226, 2589, 2729, 1041, 819, 2589, 63, 1391, 275, 283, 16151, 8650, 435, 3305, 14, 4142, 342, 523, 30306, 8, 1813, 63, 1391, 12, 511, 63, 637, 9, 523, 10716, 19706, 8, 396, 63, 637, 12, 2372, 5318, 8, 4173, 430, 523, 30306, 8, 1813, 63, 1391, 12, 488, 9, 523, 10716, 19706, 8, 885, 63, 637, 12, 2372, 5318, 8, 4173, 430, 421, 199, 533, 598, 774, 19342, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 19342, 33, 5551, 83, 5318, 8, 277, 304, 272, 408, 2925, 626, 3734, 1750, 1077, 12787, 314, 5226, 3305, 1041, 339, 1379, 5318, 360, 4785, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 2326, 297, 283, 5066, 297, 283, 2495, 358, 272, 1379, 5318, 360, 1541, 297, 283, 24676, 14, 5281, 297, 6438, 358, 272, 1379, 5318, 360, 1199, 297, 283, 1652, 26, 2791, 15, 1421, 14, 1652, 297, 4074, 272, 1379, 5318, 360, 1361, 63, 521, 297, 283, 16, 297, 283, 17, 358, 272, 1379, 5318, 360, 8755, 297, 283, 5637, 297, 283, 17, 358, 272, 1379, 5318, 360, 11964, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 23727, 63, 396, 63, 2487, 297, 283, 2671, 3489, 297, 283, 7015, 358, 272, 1379, 5318, 360, 9341, 63, 3924, 297, 283, 16, 297, 283, 17, 358, 339, 340, 2281, 63, 26030, 26, 489, 1379, 5318, 360, 23727, 63, 396, 63, 1180, 63, 11796, 297, 283, 17, 297, 283, 16, 358, 489, 1379, 5318, 360, 2340, 63, 3446, 63, 4631, 297, 283, 16, 297, 283, 1960, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 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 ]
[ 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, 19953, 3734, 2860, 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, 508, 283, 343, 7, 199, 1311, 63, 26030, 275, 747, 14, 354, 508, 283, 9228, 7, 436, 747, 14, 16040, 3430, 16, 61, 508, 283, 14091, 7, 199, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1813, 63, 1391, 63, 396, 15452, 199, 199, 2314, 275, 747, 14, 2314, 14, 1574, 342, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 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, 6160, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 6160, 26, 272, 2150, 6160, 59, 1813, 63, 1391, 61, 421, 199, 318, 2372, 5318, 8, 4173, 304, 523, 408, 16291, 9088, 63, 1813, 63, 1391, 63, 396, 63, 436, 2529, 2399, 1072, 1041, 819, 1249, 275, 359, 10761, 61, 523, 340, 3305, 365, 440, 488, 26, 272, 1249, 847, 359, 4173, 61, 523, 372, 9088, 63, 396, 63, 1208, 14, 22299, 8, 589, 12, 2589, 29, 2314, 680, 1199, 421, 199, 318, 1379, 5318, 8, 4173, 12, 511, 63, 637, 12, 849, 63, 637, 304, 523, 408, 21168, 626, 314, 1627, 3305, 365, 16955, 701, 314, 5226, 2589, 2729, 1041, 819, 2589, 63, 1391, 275, 283, 16151, 8650, 435, 3305, 14, 4142, 342, 523, 30306, 8, 1813, 63, 1391, 12, 511, 63, 637, 9, 523, 10716, 19706, 8, 396, 63, 637, 12, 2372, 5318, 8, 4173, 430, 523, 30306, 8, 1813, 63, 1391, 12, 488, 9, 523, 10716, 19706, 8, 885, 63, 637, 12, 2372, 5318, 8, 4173, 430, 421, 199, 533, 598, 774, 19342, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 19342, 33, 5551, 83, 5318, 8, 277, 304, 272, 408, 2925, 626, 3734, 1750, 1077, 12787, 314, 5226, 3305, 1041, 339, 1379, 5318, 360, 4785, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 2326, 297, 283, 5066, 297, 283, 2495, 358, 272, 1379, 5318, 360, 1541, 297, 283, 24676, 14, 5281, 297, 6438, 358, 272, 1379, 5318, 360, 1199, 297, 283, 1652, 26, 2791, 15, 1421, 14, 1652, 297, 4074, 272, 1379, 5318, 360, 1361, 63, 521, 297, 283, 16, 297, 283, 17, 358, 272, 1379, 5318, 360, 8755, 297, 283, 5637, 297, 283, 17, 358, 272, 1379, 5318, 360, 11964, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 23727, 63, 396, 63, 2487, 297, 283, 2671, 3489, 297, 283, 7015, 358, 272, 1379, 5318, 360, 9341, 63, 3924, 297, 283, 16, 297, 283, 17, 358, 339, 340, 2281, 63, 26030, 26, 489, 1379, 5318, 360, 23727, 63, 396, 63, 1180, 63, 11796, 297, 283, 17, 297, 283, 16, 358, 489, 1379, 5318, 360, 2340, 63, 3446, 63, 4631, 297, 283, 16, 297, 283, 1960, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 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, 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 ]
sdague/home-assistant
homeassistant/components/freebox/switch.py
12
2386
"""Support for Freebox Delta, Revolution and Mini 4K.""" import logging from typing import Dict from aiofreepybox.exceptions import InsufficientPermissionsError from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType from .const import DOMAIN from .router import FreeboxRouter _LOGGER = logging.getLogger(__name__) async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up the switch.""" router = hass.data[DOMAIN][entry.unique_id] async_add_entities([FreeboxWifiSwitch(router)], True) class FreeboxWifiSwitch(SwitchEntity): """Representation of a freebox wifi switch.""" def __init__(self, router: FreeboxRouter) -> None: """Initialize the Wifi switch.""" self._name = "Freebox WiFi" self._state = None self._router = router self._unique_id = f"{self._router.mac} {self._name}" @property def unique_id(self) -> str: """Return a unique ID.""" return self._unique_id @property def name(self) -> str: """Return the name of the switch.""" return self._name @property def is_on(self) -> bool: """Return true if device is on.""" return self._state @property def device_info(self) -> Dict[str, any]: """Return the device information.""" return self._router.device_info async def _async_set_state(self, enabled: bool): """Turn the switch on or off.""" wifi_config = {"enabled": enabled} try: await self._router.wifi.set_global_config(wifi_config) except InsufficientPermissionsError: _LOGGER.warning( "Home Assistant does not have permissions to modify the Freebox settings. Please refer to documentation" ) async def async_turn_on(self, **kwargs): """Turn the switch on.""" await self._async_set_state(True) async def async_turn_off(self, **kwargs): """Turn the switch off.""" await self._async_set_state(False) async def async_update(self): """Get the state and update it.""" datas = await self._router.wifi.get_global_config() active = datas["enabled"] self._state = bool(active)
apache-2.0
[ 624, 11532, 367, 2868, 1977, 18464, 502, 12, 799, 86, 3347, 436, 24954, 841, 43, 1041, 199, 646, 2050, 199, 504, 14090, 492, 7448, 199, 199, 504, 15933, 1618, 850, 647, 1977, 14, 3924, 492, 12062, 12983, 17004, 547, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 17711, 7302, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 199, 504, 1275, 1297, 492, 15265, 199, 504, 1275, 4995, 492, 2868, 1977, 11691, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 272, 6298, 26, 29913, 804, 12, 2397, 26, 4094, 3900, 12, 5316, 63, 525, 63, 8327, 199, 9, 1035, 488, 26, 272, 408, 1084, 1536, 314, 6258, 1041, 272, 6197, 275, 6298, 14, 576, 59, 7378, 1527, 2373, 14, 3235, 63, 344, 61, 272, 5316, 63, 525, 63, 8327, 779, 10146, 1977, 3848, 10167, 8, 4995, 4360, 715, 9, 421, 199, 533, 2868, 1977, 3848, 10167, 8, 10167, 7302, 304, 272, 408, 20609, 402, 282, 2867, 1977, 7912, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 6197, 26, 2868, 1977, 11691, 9, 1035, 488, 26, 267, 408, 9345, 314, 644, 1903, 6258, 1041, 267, 291, 423, 354, 275, 298, 10146, 1977, 644, 73, 9047, 2, 267, 291, 423, 929, 275, 488, 267, 291, 423, 4995, 275, 6197, 267, 291, 423, 3235, 63, 344, 275, 289, 14381, 277, 423, 4995, 14, 3088, 93, 469, 277, 423, 354, 7063, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 282, 3747, 2870, 1041, 267, 372, 291, 423, 3235, 63, 344, 339, 768, 1829, 272, 347, 536, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 314, 536, 402, 314, 6258, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 9, 1035, 2155, 26, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 2243, 63, 815, 8, 277, 9, 1035, 7448, 59, 495, 12, 1263, 2189, 267, 408, 1767, 314, 2243, 2556, 1041, 267, 372, 291, 423, 4995, 14, 1782, 63, 815, 339, 5316, 347, 485, 4146, 63, 409, 63, 929, 8, 277, 12, 5223, 26, 2155, 304, 267, 408, 16838, 314, 6258, 641, 503, 2331, 1041, 267, 7912, 63, 888, 275, 2420, 3827, 582, 5223, 93, 267, 862, 26, 288, 5517, 291, 423, 4995, 14, 4326, 14, 409, 63, 2966, 63, 888, 8, 4326, 63, 888, 9, 267, 871, 12062, 12983, 17004, 547, 26, 288, 485, 10186, 14, 3764, 8, 355, 298, 12054, 3709, 18832, 1630, 440, 1172, 3443, 370, 2811, 314, 2868, 1977, 2202, 14, 7754, 10618, 370, 3794, 2, 288, 776, 339, 5316, 347, 5316, 63, 353, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 6258, 641, 1041, 267, 5517, 291, 423, 4146, 63, 409, 63, 929, 8, 549, 9, 339, 5316, 347, 5316, 63, 353, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 6258, 2331, 1041, 267, 5517, 291, 423, 4146, 63, 409, 63, 929, 8, 797, 9, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 1002, 314, 1174, 436, 1678, 652, 1041, 267, 15012, 275, 5517, 291, 423, 4995, 14, 4326, 14, 362, 63, 2966, 63, 888, 342, 267, 4702, 275, 15012, 905, 3827, 937, 267, 291, 423, 929, 275, 2155, 8, 2682, 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 ]
[ 11532, 367, 2868, 1977, 18464, 502, 12, 799, 86, 3347, 436, 24954, 841, 43, 1041, 199, 646, 2050, 199, 504, 14090, 492, 7448, 199, 199, 504, 15933, 1618, 850, 647, 1977, 14, 3924, 492, 12062, 12983, 17004, 547, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 17711, 7302, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 199, 504, 1275, 1297, 492, 15265, 199, 504, 1275, 4995, 492, 2868, 1977, 11691, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 272, 6298, 26, 29913, 804, 12, 2397, 26, 4094, 3900, 12, 5316, 63, 525, 63, 8327, 199, 9, 1035, 488, 26, 272, 408, 1084, 1536, 314, 6258, 1041, 272, 6197, 275, 6298, 14, 576, 59, 7378, 1527, 2373, 14, 3235, 63, 344, 61, 272, 5316, 63, 525, 63, 8327, 779, 10146, 1977, 3848, 10167, 8, 4995, 4360, 715, 9, 421, 199, 533, 2868, 1977, 3848, 10167, 8, 10167, 7302, 304, 272, 408, 20609, 402, 282, 2867, 1977, 7912, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 6197, 26, 2868, 1977, 11691, 9, 1035, 488, 26, 267, 408, 9345, 314, 644, 1903, 6258, 1041, 267, 291, 423, 354, 275, 298, 10146, 1977, 644, 73, 9047, 2, 267, 291, 423, 929, 275, 488, 267, 291, 423, 4995, 275, 6197, 267, 291, 423, 3235, 63, 344, 275, 289, 14381, 277, 423, 4995, 14, 3088, 93, 469, 277, 423, 354, 7063, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 282, 3747, 2870, 1041, 267, 372, 291, 423, 3235, 63, 344, 339, 768, 1829, 272, 347, 536, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 314, 536, 402, 314, 6258, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 9, 1035, 2155, 26, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 2243, 63, 815, 8, 277, 9, 1035, 7448, 59, 495, 12, 1263, 2189, 267, 408, 1767, 314, 2243, 2556, 1041, 267, 372, 291, 423, 4995, 14, 1782, 63, 815, 339, 5316, 347, 485, 4146, 63, 409, 63, 929, 8, 277, 12, 5223, 26, 2155, 304, 267, 408, 16838, 314, 6258, 641, 503, 2331, 1041, 267, 7912, 63, 888, 275, 2420, 3827, 582, 5223, 93, 267, 862, 26, 288, 5517, 291, 423, 4995, 14, 4326, 14, 409, 63, 2966, 63, 888, 8, 4326, 63, 888, 9, 267, 871, 12062, 12983, 17004, 547, 26, 288, 485, 10186, 14, 3764, 8, 355, 298, 12054, 3709, 18832, 1630, 440, 1172, 3443, 370, 2811, 314, 2868, 1977, 2202, 14, 7754, 10618, 370, 3794, 2, 288, 776, 339, 5316, 347, 5316, 63, 353, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 6258, 641, 1041, 267, 5517, 291, 423, 4146, 63, 409, 63, 929, 8, 549, 9, 339, 5316, 347, 5316, 63, 353, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 6258, 2331, 1041, 267, 5517, 291, 423, 4146, 63, 409, 63, 929, 8, 797, 9, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 1002, 314, 1174, 436, 1678, 652, 1041, 267, 15012, 275, 5517, 291, 423, 4995, 14, 4326, 14, 362, 63, 2966, 63, 888, 342, 267, 4702, 275, 15012, 905, 3827, 937, 267, 291, 423, 929, 275, 2155, 8, 2682, 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, 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,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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 ]
georgtroska/root
interpreter/llvm/src/tools/clang/bindings/python/examples/cindex/cindex-includes.py
110
1644
#!/usr/bin/env python #===- cindex-includes.py - cindex/Python Inclusion Graph -----*- python -*--===# # # The LLVM Compiler Infrastructure # # This file is distributed under the University of Illinois Open Source # License. See LICENSE.TXT for details. # #===------------------------------------------------------------------------===# """ A simple command line tool for dumping a Graphviz description (dot) that describes include dependencies. """ def main(): import sys from clang.cindex import Index from optparse import OptionParser, OptionGroup parser = OptionParser("usage: %prog [options] {filename} [clang-args*]") parser.disable_interspersed_args() (opts, args) = parser.parse_args() if len(args) == 0: parser.error('invalid number arguments') # FIXME: Add an output file option out = sys.stdout index = Index.create() tu = index.parse(None, args) if not tu: parser.error("unable to load input") # A helper function for generating the node name. def name(f): if f: return "\"" + f.name + "\"" # Generate the include graph out.write("digraph G {\n") for i in tu.get_includes(): line = " "; if i.is_input_file: # Always write the input file as a node just in case it doesn't # actually include anything. This would generate a 1 node graph. line += name(i.include) else: line += '%s->%s' % (name(i.source), name(i.include)) line += "\n"; out.write(line) out.write("}\n") if __name__ == '__main__': main()
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 389, 4022, 286, 1080, 13, 9441, 14, 647, 446, 286, 1080, 15, 4718, 1010, 10248, 11513, 9063, 1837, 2366, 446, 10, 306, 5918, 3, 199, 3, 199, 3, 9326, 710, 491, 28631, 27154, 1010, 21844, 6976, 199, 3, 199, 3, 961, 570, 365, 1854, 1334, 314, 15904, 402, 473, 76, 472, 79, 374, 3232, 5800, 199, 3, 844, 14, 1666, 5113, 14, 17715, 367, 2436, 14, 199, 3, 199, 3, 5918, 3606, 518, 5918, 3, 199, 199, 624, 199, 33, 3486, 1414, 1004, 4744, 367, 5461, 316, 282, 11513, 17249, 1369, 334, 3287, 9, 626, 199, 271, 729, 11562, 2387, 5124, 14, 199, 624, 199, 199, 318, 2446, 837, 272, 492, 984, 272, 687, 25444, 14, 67, 1080, 492, 5499, 339, 687, 8691, 492, 13491, 12, 3207, 2448, 339, 1798, 275, 13491, 480, 3807, 26, 450, 6595, 359, 1419, 61, 469, 1501, 93, 359, 16066, 13, 589, 10, 12523, 272, 1798, 14, 5993, 63, 11005, 529, 939, 63, 589, 342, 272, 334, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 508, 378, 26, 267, 1798, 14, 705, 360, 3197, 1329, 2368, 358, 339, 327, 7600, 26, 2654, 376, 1072, 570, 945, 272, 734, 275, 984, 14, 2703, 339, 1478, 275, 5499, 14, 981, 342, 272, 30799, 275, 1478, 14, 1122, 8, 403, 12, 1249, 9, 272, 340, 440, 30799, 26, 267, 1798, 14, 705, 480, 17200, 370, 2248, 1324, 531, 339, 327, 437, 5922, 805, 367, 12999, 314, 1031, 536, 14, 272, 347, 536, 8, 70, 304, 267, 340, 289, 26, 288, 372, 1867, 341, 435, 289, 14, 354, 435, 1867, 341, 339, 327, 7958, 314, 2387, 3343, 272, 734, 14, 952, 480, 328, 2180, 598, 9459, 78, 531, 272, 367, 284, 315, 30799, 14, 362, 63, 9441, 837, 267, 1004, 275, 298, 221, 28036, 267, 340, 284, 14, 374, 63, 1210, 63, 493, 26, 288, 327, 16763, 2218, 314, 1324, 570, 465, 282, 1031, 2951, 315, 1930, 652, 3181, 1133, 288, 327, 5965, 2387, 7003, 14, 961, 3955, 3550, 282, 413, 1031, 3343, 14, 288, 1004, 847, 536, 8, 73, 14, 2613, 9, 267, 587, 26, 288, 1004, 847, 1543, 83, 26103, 83, 7, 450, 334, 354, 8, 73, 14, 1365, 395, 536, 8, 73, 14, 2613, 430, 267, 1004, 847, 1867, 78, 11436, 267, 734, 14, 952, 8, 604, 9, 272, 734, 14, 952, 480, 4988, 78, 531, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 389, 4022, 286, 1080, 13, 9441, 14, 647, 446, 286, 1080, 15, 4718, 1010, 10248, 11513, 9063, 1837, 2366, 446, 10, 306, 5918, 3, 199, 3, 199, 3, 9326, 710, 491, 28631, 27154, 1010, 21844, 6976, 199, 3, 199, 3, 961, 570, 365, 1854, 1334, 314, 15904, 402, 473, 76, 472, 79, 374, 3232, 5800, 199, 3, 844, 14, 1666, 5113, 14, 17715, 367, 2436, 14, 199, 3, 199, 3, 5918, 3606, 518, 5918, 3, 199, 199, 624, 199, 33, 3486, 1414, 1004, 4744, 367, 5461, 316, 282, 11513, 17249, 1369, 334, 3287, 9, 626, 199, 271, 729, 11562, 2387, 5124, 14, 199, 624, 199, 199, 318, 2446, 837, 272, 492, 984, 272, 687, 25444, 14, 67, 1080, 492, 5499, 339, 687, 8691, 492, 13491, 12, 3207, 2448, 339, 1798, 275, 13491, 480, 3807, 26, 450, 6595, 359, 1419, 61, 469, 1501, 93, 359, 16066, 13, 589, 10, 12523, 272, 1798, 14, 5993, 63, 11005, 529, 939, 63, 589, 342, 272, 334, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 508, 378, 26, 267, 1798, 14, 705, 360, 3197, 1329, 2368, 358, 339, 327, 7600, 26, 2654, 376, 1072, 570, 945, 272, 734, 275, 984, 14, 2703, 339, 1478, 275, 5499, 14, 981, 342, 272, 30799, 275, 1478, 14, 1122, 8, 403, 12, 1249, 9, 272, 340, 440, 30799, 26, 267, 1798, 14, 705, 480, 17200, 370, 2248, 1324, 531, 339, 327, 437, 5922, 805, 367, 12999, 314, 1031, 536, 14, 272, 347, 536, 8, 70, 304, 267, 340, 289, 26, 288, 372, 1867, 341, 435, 289, 14, 354, 435, 1867, 341, 339, 327, 7958, 314, 2387, 3343, 272, 734, 14, 952, 480, 328, 2180, 598, 9459, 78, 531, 272, 367, 284, 315, 30799, 14, 362, 63, 9441, 837, 267, 1004, 275, 298, 221, 28036, 267, 340, 284, 14, 374, 63, 1210, 63, 493, 26, 288, 327, 16763, 2218, 314, 1324, 570, 465, 282, 1031, 2951, 315, 1930, 652, 3181, 1133, 288, 327, 5965, 2387, 7003, 14, 961, 3955, 3550, 282, 413, 1031, 3343, 14, 288, 1004, 847, 536, 8, 73, 14, 2613, 9, 267, 587, 26, 288, 1004, 847, 1543, 83, 26103, 83, 7, 450, 334, 354, 8, 73, 14, 1365, 395, 536, 8, 73, 14, 2613, 430, 267, 1004, 847, 1867, 78, 11436, 267, 734, 14, 952, 8, 604, 9, 272, 734, 14, 952, 480, 4988, 78, 531, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
jdemonasterio/Bayes-for-Hackers
ExamplesFromChapters/Chapter3/ClusteringWithGaussians.py
90
1034
import numpy as np import pymc as pm data = np.loadtxt("../../Chapter3_MCMC/data/mixture_data.csv", delimiter=",") p = pm.Uniform("p", 0, 1) assignment = pm.Categorical("assignment", [p, 1 - p], size=data.shape[0]) taus = 1.0 / pm.Uniform("stds", 0, 100, size=2) ** 2 # notice the size! centers = pm.Normal("centers", [150, 150], [0.001, 0.001], size=2) """ The below deterministic functions map a assingment, in this case 0 or 1, to a set of parameters, located in the (1,2) arrays `taus` and `centers.` """ @pm.deterministic def center_i(assignment=assignment, centers=centers): return centers[assignment] @pm.deterministic def tau_i(assignment=assignment, taus=taus): return taus[assignment] # and to combine it with the observations: observations = pm.Normal("obs", center_i, tau_i, value=data, observed=True) # below we create a model class model = pm.Model([p, assignment, taus, centers]) map_ = pm.MAP(model) map_.fit() mcmc = pm.MCMC(model) mcmc.sample(100000, 50000)
mit
[ 646, 2680, 465, 980, 199, 646, 1134, 5466, 465, 14207, 421, 199, 576, 275, 980, 14, 27992, 480, 9707, 30791, 19, 63, 7608, 7608, 15, 576, 15, 2664, 4167, 63, 576, 14, 4737, 401, 221, 11172, 11107, 531, 421, 199, 80, 275, 14207, 14, 12421, 480, 80, 401, 378, 12, 413, 9, 199, 199, 10861, 275, 14207, 14, 23306, 480, 10861, 401, 359, 80, 12, 413, 446, 299, 467, 1568, 29, 576, 14, 1392, 59, 16, 566, 199, 199, 502, 527, 275, 413, 14, 16, 1182, 14207, 14, 12421, 480, 270, 795, 401, 378, 12, 2948, 12, 1568, 29, 18, 9, 1011, 499, 221, 327, 4245, 314, 1568, 1, 199, 15660, 275, 14207, 14, 6241, 480, 15660, 401, 359, 8251, 12, 14711, 467, 359, 16, 14, 4587, 12, 378, 14, 4587, 467, 1568, 29, 18, 9, 199, 199, 624, 199, 1918, 5084, 25286, 3423, 2341, 282, 2661, 316, 434, 12, 315, 642, 1930, 378, 503, 413, 12, 199, 475, 282, 663, 402, 2633, 12, 16180, 315, 314, 334, 17, 12, 18, 9, 6572, 658, 502, 527, 64, 436, 658, 15660, 14, 64, 199, 624, 421, 199, 32, 7073, 14, 30709, 199, 318, 8126, 63, 73, 8, 10861, 29, 10861, 12, 19190, 29, 15660, 304, 267, 372, 19190, 59, 10861, 61, 421, 199, 32, 7073, 14, 30709, 199, 318, 19188, 63, 73, 8, 10861, 29, 10861, 12, 3052, 527, 29, 502, 527, 304, 267, 372, 3052, 527, 59, 10861, 61, 199, 199, 3, 436, 370, 13323, 652, 543, 314, 19739, 26, 199, 2873, 12225, 275, 14207, 14, 6241, 480, 11226, 401, 8126, 63, 73, 12, 19188, 63, 73, 12, 586, 574, 29, 576, 12, 20802, 29, 549, 9, 199, 199, 3, 5084, 781, 1218, 282, 1402, 1021, 199, 1238, 275, 14207, 14, 1685, 779, 80, 12, 9801, 12, 3052, 527, 12, 19190, 566, 421, 199, 1130, 63, 275, 14207, 14, 5443, 8, 1238, 9, 199, 1130, 3754, 3269, 342, 199, 77, 4400, 67, 275, 14207, 14, 7608, 7608, 8, 1238, 9, 199, 77, 4400, 67, 14, 3271, 8, 15274, 12, 959, 993, 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 ]
[ 2680, 465, 980, 199, 646, 1134, 5466, 465, 14207, 421, 199, 576, 275, 980, 14, 27992, 480, 9707, 30791, 19, 63, 7608, 7608, 15, 576, 15, 2664, 4167, 63, 576, 14, 4737, 401, 221, 11172, 11107, 531, 421, 199, 80, 275, 14207, 14, 12421, 480, 80, 401, 378, 12, 413, 9, 199, 199, 10861, 275, 14207, 14, 23306, 480, 10861, 401, 359, 80, 12, 413, 446, 299, 467, 1568, 29, 576, 14, 1392, 59, 16, 566, 199, 199, 502, 527, 275, 413, 14, 16, 1182, 14207, 14, 12421, 480, 270, 795, 401, 378, 12, 2948, 12, 1568, 29, 18, 9, 1011, 499, 221, 327, 4245, 314, 1568, 1, 199, 15660, 275, 14207, 14, 6241, 480, 15660, 401, 359, 8251, 12, 14711, 467, 359, 16, 14, 4587, 12, 378, 14, 4587, 467, 1568, 29, 18, 9, 199, 199, 624, 199, 1918, 5084, 25286, 3423, 2341, 282, 2661, 316, 434, 12, 315, 642, 1930, 378, 503, 413, 12, 199, 475, 282, 663, 402, 2633, 12, 16180, 315, 314, 334, 17, 12, 18, 9, 6572, 658, 502, 527, 64, 436, 658, 15660, 14, 64, 199, 624, 421, 199, 32, 7073, 14, 30709, 199, 318, 8126, 63, 73, 8, 10861, 29, 10861, 12, 19190, 29, 15660, 304, 267, 372, 19190, 59, 10861, 61, 421, 199, 32, 7073, 14, 30709, 199, 318, 19188, 63, 73, 8, 10861, 29, 10861, 12, 3052, 527, 29, 502, 527, 304, 267, 372, 3052, 527, 59, 10861, 61, 199, 199, 3, 436, 370, 13323, 652, 543, 314, 19739, 26, 199, 2873, 12225, 275, 14207, 14, 6241, 480, 11226, 401, 8126, 63, 73, 12, 19188, 63, 73, 12, 586, 574, 29, 576, 12, 20802, 29, 549, 9, 199, 199, 3, 5084, 781, 1218, 282, 1402, 1021, 199, 1238, 275, 14207, 14, 1685, 779, 80, 12, 9801, 12, 3052, 527, 12, 19190, 566, 421, 199, 1130, 63, 275, 14207, 14, 5443, 8, 1238, 9, 199, 1130, 3754, 3269, 342, 199, 77, 4400, 67, 275, 14207, 14, 7608, 7608, 8, 1238, 9, 199, 77, 4400, 67, 14, 3271, 8, 15274, 12, 959, 993, 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, 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 ]
akshayka/projection-methods
projection_methods/projectables/polyhedron.py
1
2281
from projection_methods.projectables.halfspace import Halfspace from projection_methods.projectables.hyperplane import Hyperplane from projection_methods.projectables.projectable import Projectable class Polyhedron(Projectable): """A projectable polyhedron Defines a polyhedron via a set of hyperplanes and halfspaces. An unconventional Projectable in that it implements an optional maximum size (defined as a maximum number of halfspaces and a maximum number of hyperplanes) and implements policies by which halfspaces and hyperplanes are evicted when maximum capacity is met. Attributes: max_hyperplanes: maximum number of hyperplanes (default infinite) max_halfspaces: maximum number of halfspaces (default infinite) eviction_policy: policy by which to evict halfspaces """ def __init__(self, x, information=[]): """ Args: x (cvxpy.Variable): a symbolic representation of members of the set information (list of Halfspace and/or Hyperplane): halfspaces and hyperplanes defining polyhedron """ self._hyperplanes = [] self._halfspaces = [] self._constr = [] self.add(information) super(Polyhedron, self).__init__(x, self._constr) def halfspaces(self): return self._halfspaces def hyperplanes(self): return self._hyperplanes def add(self, information): """Adds hyperplanes and halfspaces to polyhedron Args: information (list of Hyperplane and/or Halfspace): halfspaces and hyperplanes to add to polyhedron Raises: ValueError if information contains an object that is not a Hyperplane or a Halfspace """ if type(information) is not list: information = [information] for info in information: if type(info) == Hyperplane: self._hyperplanes.append(info) self._constr += [c for c in info._constr] elif type(info) == Halfspace: self._halfspaces.append(info) self._constr += [c for c in info._constr] else: raise ValueError, "Only Halfspaces or Hyperplanes can be added"
gpl-3.0
[ 504, 14777, 63, 2474, 14, 1715, 5921, 14, 10220, 2638, 492, 869, 7411, 2638, 199, 504, 14777, 63, 2474, 14, 1715, 5921, 14, 9547, 15365, 492, 21344, 15365, 199, 504, 14777, 63, 2474, 14, 1715, 5921, 14, 1715, 461, 492, 7290, 461, 421, 199, 533, 16869, 19985, 2641, 8, 4761, 461, 304, 272, 408, 33, 2199, 461, 8446, 19985, 2641, 339, 25022, 282, 8446, 19985, 2641, 4799, 282, 663, 402, 10342, 5140, 397, 436, 12995, 10749, 14, 1626, 272, 625, 388, 18803, 279, 7290, 461, 315, 626, 652, 9031, 376, 2716, 5696, 272, 1568, 334, 4037, 465, 282, 5696, 1329, 402, 12995, 10749, 436, 282, 5696, 1329, 402, 272, 10342, 5140, 397, 9, 436, 9031, 14118, 701, 1314, 12995, 10749, 436, 10342, 5140, 397, 272, 787, 24656, 1522, 1380, 5696, 14893, 365, 7647, 14, 339, 9382, 26, 267, 1390, 63, 9547, 5140, 397, 26, 5696, 1329, 402, 10342, 5140, 397, 334, 885, 15258, 9, 267, 1390, 63, 10220, 10749, 26, 5696, 1329, 402, 12995, 10749, 334, 885, 15258, 9, 267, 24656, 414, 63, 3185, 26, 4592, 701, 1314, 370, 24656, 319, 12995, 10749, 272, 408, 272, 347, 636, 826, 721, 277, 12, 671, 12, 2556, 17894, 267, 408, 267, 3033, 26, 267, 671, 334, 5107, 88, 647, 14, 2773, 304, 282, 13673, 6025, 402, 288, 7556, 402, 314, 663, 267, 2556, 334, 513, 402, 869, 7411, 2638, 436, 15, 269, 21344, 15365, 304, 12995, 10749, 436, 288, 10342, 5140, 397, 12669, 8446, 19985, 2641, 267, 408, 267, 291, 423, 9547, 5140, 397, 275, 942, 267, 291, 423, 10220, 10749, 275, 942, 267, 291, 423, 388, 495, 275, 942, 267, 291, 14, 525, 8, 11697, 9, 267, 1613, 8, 12747, 19985, 2641, 12, 291, 2843, 826, 721, 88, 12, 291, 423, 388, 495, 9, 2378, 347, 12995, 10749, 8, 277, 304, 372, 291, 423, 10220, 10749, 272, 347, 10342, 5140, 397, 8, 277, 304, 372, 291, 423, 9547, 5140, 397, 339, 347, 1050, 8, 277, 12, 2556, 304, 267, 408, 14995, 10342, 5140, 397, 436, 12995, 10749, 370, 8446, 19985, 2641, 398, 3033, 26, 288, 2556, 334, 513, 402, 21344, 15365, 436, 15, 269, 869, 7411, 2638, 304, 12995, 10749, 436, 355, 10342, 5140, 397, 370, 1050, 370, 8446, 19985, 2641, 267, 6218, 26, 288, 1722, 340, 2556, 3509, 376, 909, 626, 365, 440, 282, 355, 21344, 15365, 503, 282, 869, 7411, 2638, 267, 408, 267, 340, 730, 8, 11697, 9, 365, 440, 769, 26, 288, 2556, 275, 359, 11697, 61, 267, 367, 2256, 315, 2556, 26, 288, 340, 730, 8, 815, 9, 508, 21344, 15365, 26, 355, 291, 423, 9547, 5140, 397, 14, 740, 8, 815, 9, 355, 291, 423, 388, 495, 847, 359, 67, 367, 286, 315, 2256, 423, 388, 495, 61, 288, 916, 730, 8, 815, 9, 508, 869, 7411, 2638, 26, 355, 291, 423, 10220, 10749, 14, 740, 8, 815, 9, 355, 291, 423, 388, 495, 847, 359, 67, 367, 286, 315, 2256, 423, 388, 495, 61, 288, 587, 26, 355, 746, 1722, 12, 298, 5903, 869, 7411, 10749, 503, 21344, 5140, 397, 883, 506, 3483, 2, 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 ]
[ 14777, 63, 2474, 14, 1715, 5921, 14, 10220, 2638, 492, 869, 7411, 2638, 199, 504, 14777, 63, 2474, 14, 1715, 5921, 14, 9547, 15365, 492, 21344, 15365, 199, 504, 14777, 63, 2474, 14, 1715, 5921, 14, 1715, 461, 492, 7290, 461, 421, 199, 533, 16869, 19985, 2641, 8, 4761, 461, 304, 272, 408, 33, 2199, 461, 8446, 19985, 2641, 339, 25022, 282, 8446, 19985, 2641, 4799, 282, 663, 402, 10342, 5140, 397, 436, 12995, 10749, 14, 1626, 272, 625, 388, 18803, 279, 7290, 461, 315, 626, 652, 9031, 376, 2716, 5696, 272, 1568, 334, 4037, 465, 282, 5696, 1329, 402, 12995, 10749, 436, 282, 5696, 1329, 402, 272, 10342, 5140, 397, 9, 436, 9031, 14118, 701, 1314, 12995, 10749, 436, 10342, 5140, 397, 272, 787, 24656, 1522, 1380, 5696, 14893, 365, 7647, 14, 339, 9382, 26, 267, 1390, 63, 9547, 5140, 397, 26, 5696, 1329, 402, 10342, 5140, 397, 334, 885, 15258, 9, 267, 1390, 63, 10220, 10749, 26, 5696, 1329, 402, 12995, 10749, 334, 885, 15258, 9, 267, 24656, 414, 63, 3185, 26, 4592, 701, 1314, 370, 24656, 319, 12995, 10749, 272, 408, 272, 347, 636, 826, 721, 277, 12, 671, 12, 2556, 17894, 267, 408, 267, 3033, 26, 267, 671, 334, 5107, 88, 647, 14, 2773, 304, 282, 13673, 6025, 402, 288, 7556, 402, 314, 663, 267, 2556, 334, 513, 402, 869, 7411, 2638, 436, 15, 269, 21344, 15365, 304, 12995, 10749, 436, 288, 10342, 5140, 397, 12669, 8446, 19985, 2641, 267, 408, 267, 291, 423, 9547, 5140, 397, 275, 942, 267, 291, 423, 10220, 10749, 275, 942, 267, 291, 423, 388, 495, 275, 942, 267, 291, 14, 525, 8, 11697, 9, 267, 1613, 8, 12747, 19985, 2641, 12, 291, 2843, 826, 721, 88, 12, 291, 423, 388, 495, 9, 2378, 347, 12995, 10749, 8, 277, 304, 372, 291, 423, 10220, 10749, 272, 347, 10342, 5140, 397, 8, 277, 304, 372, 291, 423, 9547, 5140, 397, 339, 347, 1050, 8, 277, 12, 2556, 304, 267, 408, 14995, 10342, 5140, 397, 436, 12995, 10749, 370, 8446, 19985, 2641, 398, 3033, 26, 288, 2556, 334, 513, 402, 21344, 15365, 436, 15, 269, 869, 7411, 2638, 304, 12995, 10749, 436, 355, 10342, 5140, 397, 370, 1050, 370, 8446, 19985, 2641, 267, 6218, 26, 288, 1722, 340, 2556, 3509, 376, 909, 626, 365, 440, 282, 355, 21344, 15365, 503, 282, 869, 7411, 2638, 267, 408, 267, 340, 730, 8, 11697, 9, 365, 440, 769, 26, 288, 2556, 275, 359, 11697, 61, 267, 367, 2256, 315, 2556, 26, 288, 340, 730, 8, 815, 9, 508, 21344, 15365, 26, 355, 291, 423, 9547, 5140, 397, 14, 740, 8, 815, 9, 355, 291, 423, 388, 495, 847, 359, 67, 367, 286, 315, 2256, 423, 388, 495, 61, 288, 916, 730, 8, 815, 9, 508, 869, 7411, 2638, 26, 355, 291, 423, 10220, 10749, 14, 740, 8, 815, 9, 355, 291, 423, 388, 495, 847, 359, 67, 367, 286, 315, 2256, 423, 388, 495, 61, 288, 587, 26, 355, 746, 1722, 12, 298, 5903, 869, 7411, 10749, 503, 21344, 5140, 397, 883, 506, 3483, 2, 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, 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,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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 ]
ekalosak/boto
tests/integration/cloudsearch/test_layers.py
130
2742
# Copyright (c) 2013 Amazon.com, Inc. or its affiliates. # All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. """ Tests for Layer1 of Cloudsearch """ import time from tests.unit import unittest from boto.cloudsearch.layer1 import Layer1 from boto.cloudsearch.layer2 import Layer2 from boto.regioninfo import RegionInfo class CloudSearchLayer1Test(unittest.TestCase): cloudsearch = True def setUp(self): super(CloudSearchLayer1Test, self).setUp() self.layer1 = Layer1() self.domain_name = 'test-%d' % int(time.time()) def test_create_domain(self): resp = self.layer1.create_domain(self.domain_name) self.addCleanup(self.layer1.delete_domain, self.domain_name) self.assertTrue(resp.get('created', False)) class CloudSearchLayer2Test(unittest.TestCase): cloudsearch = True def setUp(self): super(CloudSearchLayer2Test, self).setUp() self.layer2 = Layer2() self.domain_name = 'test-%d' % int(time.time()) def test_create_domain(self): domain = self.layer2.create_domain(self.domain_name) self.addCleanup(domain.delete) self.assertTrue(domain.created, False) self.assertEqual(domain.domain_name, self.domain_name) self.assertEqual(domain.num_searchable_docs, 0) def test_initialization_regression(self): us_west_2 = RegionInfo( name='us-west-2', endpoint='cloudsearch.us-west-2.amazonaws.com' ) self.layer2 = Layer2( region=us_west_2, host='cloudsearch.us-west-2.amazonaws.com' ) self.assertEqual( self.layer2.layer1.host, 'cloudsearch.us-west-2.amazonaws.com' )
mit
[ 3, 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 2925, 367, 11915, 17, 402, 8142, 1733, 199, 624, 199, 646, 900, 199, 199, 504, 2295, 14, 3248, 492, 2882, 199, 504, 6055, 14, 4091, 1733, 14, 1897, 17, 492, 11915, 17, 199, 504, 6055, 14, 4091, 1733, 14, 1897, 18, 492, 11915, 18, 199, 504, 6055, 14, 4551, 815, 492, 22240, 2354, 421, 199, 533, 8142, 5278, 5003, 17, 774, 8, 2796, 14, 1746, 304, 272, 8002, 1733, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9089, 5278, 5003, 17, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1897, 17, 275, 11915, 17, 342, 267, 291, 14, 2261, 63, 354, 275, 283, 396, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 339, 347, 511, 63, 981, 63, 2261, 8, 277, 304, 267, 3085, 275, 291, 14, 1897, 17, 14, 981, 63, 2261, 8, 277, 14, 2261, 63, 354, 9, 267, 291, 14, 12808, 8, 277, 14, 1897, 17, 14, 1807, 63, 2261, 12, 291, 14, 2261, 63, 354, 9, 267, 291, 14, 1815, 8, 4518, 14, 362, 360, 3966, 297, 756, 430, 421, 199, 533, 8142, 5278, 5003, 18, 774, 8, 2796, 14, 1746, 304, 272, 8002, 1733, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9089, 5278, 5003, 18, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1897, 18, 275, 11915, 18, 342, 267, 291, 14, 2261, 63, 354, 275, 283, 396, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 339, 347, 511, 63, 981, 63, 2261, 8, 277, 304, 267, 2881, 275, 291, 14, 1897, 18, 14, 981, 63, 2261, 8, 277, 14, 2261, 63, 354, 9, 267, 291, 14, 12808, 8, 2261, 14, 1807, 9, 267, 291, 14, 1815, 8, 2261, 14, 3966, 12, 756, 9, 267, 291, 14, 629, 8, 2261, 14, 2261, 63, 354, 12, 291, 14, 2261, 63, 354, 9, 267, 291, 14, 629, 8, 2261, 14, 1507, 63, 1733, 461, 63, 4757, 12, 378, 9, 339, 347, 511, 63, 27876, 63, 12513, 8, 277, 304, 267, 2739, 63, 19082, 63, 18, 275, 22240, 2354, 8, 288, 536, 534, 527, 13, 19082, 13, 18, 297, 288, 6037, 534, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 267, 291, 14, 1897, 18, 275, 11915, 18, 8, 288, 4897, 29, 527, 63, 19082, 63, 18, 12, 288, 1591, 534, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 267, 291, 14, 629, 8, 288, 291, 14, 1897, 18, 14, 1897, 17, 14, 1102, 12, 288, 283, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 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 ]
[ 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 2925, 367, 11915, 17, 402, 8142, 1733, 199, 624, 199, 646, 900, 199, 199, 504, 2295, 14, 3248, 492, 2882, 199, 504, 6055, 14, 4091, 1733, 14, 1897, 17, 492, 11915, 17, 199, 504, 6055, 14, 4091, 1733, 14, 1897, 18, 492, 11915, 18, 199, 504, 6055, 14, 4551, 815, 492, 22240, 2354, 421, 199, 533, 8142, 5278, 5003, 17, 774, 8, 2796, 14, 1746, 304, 272, 8002, 1733, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9089, 5278, 5003, 17, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1897, 17, 275, 11915, 17, 342, 267, 291, 14, 2261, 63, 354, 275, 283, 396, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 339, 347, 511, 63, 981, 63, 2261, 8, 277, 304, 267, 3085, 275, 291, 14, 1897, 17, 14, 981, 63, 2261, 8, 277, 14, 2261, 63, 354, 9, 267, 291, 14, 12808, 8, 277, 14, 1897, 17, 14, 1807, 63, 2261, 12, 291, 14, 2261, 63, 354, 9, 267, 291, 14, 1815, 8, 4518, 14, 362, 360, 3966, 297, 756, 430, 421, 199, 533, 8142, 5278, 5003, 18, 774, 8, 2796, 14, 1746, 304, 272, 8002, 1733, 275, 715, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9089, 5278, 5003, 18, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 1897, 18, 275, 11915, 18, 342, 267, 291, 14, 2261, 63, 354, 275, 283, 396, 3295, 68, 7, 450, 1109, 8, 521, 14, 521, 1012, 339, 347, 511, 63, 981, 63, 2261, 8, 277, 304, 267, 2881, 275, 291, 14, 1897, 18, 14, 981, 63, 2261, 8, 277, 14, 2261, 63, 354, 9, 267, 291, 14, 12808, 8, 2261, 14, 1807, 9, 267, 291, 14, 1815, 8, 2261, 14, 3966, 12, 756, 9, 267, 291, 14, 629, 8, 2261, 14, 2261, 63, 354, 12, 291, 14, 2261, 63, 354, 9, 267, 291, 14, 629, 8, 2261, 14, 1507, 63, 1733, 461, 63, 4757, 12, 378, 9, 339, 347, 511, 63, 27876, 63, 12513, 8, 277, 304, 267, 2739, 63, 19082, 63, 18, 275, 22240, 2354, 8, 288, 536, 534, 527, 13, 19082, 13, 18, 297, 288, 6037, 534, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 267, 291, 14, 1897, 18, 275, 11915, 18, 8, 288, 4897, 29, 527, 63, 19082, 63, 18, 12, 288, 1591, 534, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 267, 291, 14, 629, 8, 288, 291, 14, 1897, 18, 14, 1897, 17, 14, 1102, 12, 288, 283, 4091, 1733, 14, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 7, 267, 776, 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, 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, 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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 ]
Pikecillo/genna
external/4Suite-XML-1.0.2/Ft/Xml/XPath/ParsedRelativeLocationPath.py
1
1412
######################################################################## # $Header: /var/local/cvsroot/4Suite/Ft/Xml/XPath/ParsedRelativeLocationPath.py,v 1.4 2005/02/09 11:10:54 mbrown Exp $ """ A parsed token that represents a relative location path in the parsed result tree. Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/ """ class ParsedRelativeLocationPath: def __init__(self, left, right): self._left = left self._right = right return def evaluate(self, context): nodeset = self._left.select(context) state = context.copy() result = [] size = len(nodeset) for pos in xrange(size): context.node, context.position, context.size = \ nodeset[pos], pos + 1, size result.extend(self._right.select(context)) context.set(state) return result select = evaluate def pprint(self, indent=''): print indent + str(self) self._left.pprint(indent + ' ') self._right.pprint(indent + ' ') def __str__(self): return '<RelativeLocationPath at %x: %s>' % ( id(self), repr(self), ) def __repr__(self): return repr(self._left) + '/' + repr(self._right)
gpl-2.0
[ 3949, 257, 199, 3, 2672, 2567, 26, 1182, 1391, 15, 1832, 15, 28151, 1231, 15, 20, 6207, 15, 38, 84, 15, 8672, 15, 27645, 15, 1262, 939, 15277, 6592, 2042, 14, 647, 12, 86, 413, 14, 20, 11811, 15, 996, 15, 1643, 4119, 26, 709, 26, 1477, 333, 27133, 7910, 2672, 199, 624, 199, 33, 4565, 1526, 626, 8469, 282, 3847, 2909, 931, 315, 314, 4565, 754, 3123, 14, 1362, 199, 7384, 11811, 23843, 273, 20816, 12, 3277, 14, 334, 1668, 33, 680, 199, 36, 1841, 1672, 4190, 436, 4248, 2556, 26, 1455, 921, 20, 5768, 14, 1308, 15, 32324, 5716, 199, 4761, 5629, 12, 3794, 12, 10208, 26, 1455, 921, 20, 5768, 14, 1308, 15, 199, 624, 199, 199, 533, 2235, 939, 15277, 6592, 2042, 26, 272, 347, 636, 826, 721, 277, 12, 3602, 12, 2451, 304, 267, 291, 423, 3039, 275, 3602, 267, 291, 423, 1019, 275, 2451, 267, 372, 339, 347, 9352, 8, 277, 12, 1067, 304, 267, 1031, 409, 275, 291, 423, 3039, 14, 2416, 8, 1100, 9, 398, 1174, 275, 1067, 14, 1574, 342, 398, 754, 275, 942, 267, 1568, 275, 822, 8, 932, 409, 9, 267, 367, 2086, 315, 4945, 8, 890, 304, 288, 1067, 14, 932, 12, 1067, 14, 3124, 12, 1067, 14, 890, 275, 971, 2079, 1031, 409, 59, 1712, 467, 2086, 435, 413, 12, 1568, 288, 754, 14, 2880, 8, 277, 423, 1019, 14, 2416, 8, 1100, 430, 398, 1067, 14, 409, 8, 929, 9, 267, 372, 754, 272, 3504, 275, 9352, 339, 347, 10933, 8, 277, 12, 4363, 9280, 267, 870, 4363, 435, 620, 8, 277, 9, 267, 291, 423, 3039, 14, 15380, 8, 3724, 435, 283, 221, 5320, 267, 291, 423, 1019, 14, 15380, 8, 3724, 435, 283, 221, 5320, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 15277, 6592, 2042, 737, 450, 88, 26, 450, 83, 3524, 450, 334, 288, 1305, 8, 277, 395, 288, 4700, 8, 277, 395, 288, 776, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 423, 3039, 9, 435, 7324, 435, 4700, 8, 277, 423, 1019, 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 ]
[ 257, 199, 3, 2672, 2567, 26, 1182, 1391, 15, 1832, 15, 28151, 1231, 15, 20, 6207, 15, 38, 84, 15, 8672, 15, 27645, 15, 1262, 939, 15277, 6592, 2042, 14, 647, 12, 86, 413, 14, 20, 11811, 15, 996, 15, 1643, 4119, 26, 709, 26, 1477, 333, 27133, 7910, 2672, 199, 624, 199, 33, 4565, 1526, 626, 8469, 282, 3847, 2909, 931, 315, 314, 4565, 754, 3123, 14, 1362, 199, 7384, 11811, 23843, 273, 20816, 12, 3277, 14, 334, 1668, 33, 680, 199, 36, 1841, 1672, 4190, 436, 4248, 2556, 26, 1455, 921, 20, 5768, 14, 1308, 15, 32324, 5716, 199, 4761, 5629, 12, 3794, 12, 10208, 26, 1455, 921, 20, 5768, 14, 1308, 15, 199, 624, 199, 199, 533, 2235, 939, 15277, 6592, 2042, 26, 272, 347, 636, 826, 721, 277, 12, 3602, 12, 2451, 304, 267, 291, 423, 3039, 275, 3602, 267, 291, 423, 1019, 275, 2451, 267, 372, 339, 347, 9352, 8, 277, 12, 1067, 304, 267, 1031, 409, 275, 291, 423, 3039, 14, 2416, 8, 1100, 9, 398, 1174, 275, 1067, 14, 1574, 342, 398, 754, 275, 942, 267, 1568, 275, 822, 8, 932, 409, 9, 267, 367, 2086, 315, 4945, 8, 890, 304, 288, 1067, 14, 932, 12, 1067, 14, 3124, 12, 1067, 14, 890, 275, 971, 2079, 1031, 409, 59, 1712, 467, 2086, 435, 413, 12, 1568, 288, 754, 14, 2880, 8, 277, 423, 1019, 14, 2416, 8, 1100, 430, 398, 1067, 14, 409, 8, 929, 9, 267, 372, 754, 272, 3504, 275, 9352, 339, 347, 10933, 8, 277, 12, 4363, 9280, 267, 870, 4363, 435, 620, 8, 277, 9, 267, 291, 423, 3039, 14, 15380, 8, 3724, 435, 283, 221, 5320, 267, 291, 423, 1019, 14, 15380, 8, 3724, 435, 283, 221, 5320, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 15277, 6592, 2042, 737, 450, 88, 26, 450, 83, 3524, 450, 334, 288, 1305, 8, 277, 395, 288, 4700, 8, 277, 395, 288, 776, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 423, 3039, 9, 435, 7324, 435, 4700, 8, 277, 423, 1019, 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, 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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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 ]
thp44/delphin_6_automation
data_process/2d_1d/archieve/temperature.py
1
18075
__author__ = "Christian Kongsgaard" __license__ = 'MIT' # -------------------------------------------------------------------------------------------------------------------- # # IMPORTS # Modules import matplotlib.pyplot as plt import numpy as np import os import datetime import matplotlib.dates as mdates import pandas as pd # RiBuild Modules from delphin_6_automation.file_parsing import delphin_parser # -------------------------------------------------------------------------------------------------------------------- # # RIBuild # Application colors = {'top': '#FBBA00', 'mid': '#B81A5D', 'bottom': '#79C6C0', '1d_brick': '#000000', '1d_mortar': '#BDCCD4'} project_dict = {'dresden_zp_high_ratio_uninsulated_4a': {'map': {'5ad9e0352e2cb22f2c4f15b4': 'brick_1d', '5ad9e3bf2e2cb22f2c4f166b': 'mortar_1d', '5adb0a102e2cb22f2c4f17e9': '2d'} }, 'dresden_zd_high_ratio_uninsulated_4a': {'map': {'5ad9e0ba2e2cb22f2c4f15f1': 'brick_1d', '5ad9e3bf2e2cb22f2c4f166b': 'mortar_1d', '5adb2dc02e2cb22f2c4f1873': '2d'} }, 'potsdam_high_ratio_uninsulated_4a': {'map': {'5ad9e3462e2cb22f2c4f162e': 'brick_1d', '5ad9e3bf2e2cb22f2c4f166b': 'mortar_1d', '5adcc9702e2cb22f2c4f18fd': '2d'} }, 'dresden_zp_low_ratio_uninsulated_4a': {'map': {'5ad9e6192e2cb22f2c4f175f': 'brick_1d', '5ad9e5812e2cb22f2c4f1722': 'mortar_1d', '5adda7172e2cb20baca57c6e': '2d'} }, 'dresden_zd_low_ratio_uninsulated_4a': {'map': {'5ad9e44f2e2cb22f2c4f16a8': 'brick_1d', '5ad9e5812e2cb22f2c4f1722': 'mortar_1d', '5adcd4402e2cb22f2c4f1987': '2d'} }, 'potsdam_low_ratio_uninsulated_4a': {'map': {'5ad9e4f22e2cb22f2c4f16e5': 'brick_1d', '5ad9e5812e2cb22f2c4f1722': 'mortar_1d', '5add9b902e2cb20baca57be4': '2d'} }, 'dresden_zp_high_ratio_insulated_4a': {'map': {'5ae824252e2cb22d48db5955': 'brick_1d', '5ae82c222e2cb2156000902b': 'mortar_1d', '5ae355cf2e2cb2201055c1a4': '2d'} }, 'dresden_zd_high_ratio_insulated_4a': {'map': {'5ae824d82e2cb22d48db5998': 'brick_1d', '5ae82c222e2cb2156000902b': 'mortar_1d', '5ae398f12e2cb2201055c263': '2d'} }, 'potsdam_high_ratio_insulated_4a': {'map': {'5ae82bac2e2cb21560008fe8': 'brick_1d', '5ae82c222e2cb2156000902b': 'mortar_1d', '5ae6ca982e2cb2201055c322': '2d'} }, 'dresden_zp_low_ratio_insulated_4a': {'map': {'5ae82e5d2e2cb21560009137': 'brick_1d', '5ae82dc02e2cb215600090f4': 'mortar_1d', '5ae6fdbf2e2cb20d5891272f': '2d'} }, 'dresden_zd_low_ratio_insulated_4a': {'map': {'5ae82cb12e2cb2156000906e': 'brick_1d', '5ae82dc02e2cb215600090f4': 'mortar_1d', '5ae6d9bf2e2cb2201055c3e1': '2d'} }, 'potsdam_low_ratio_insulated_4a': {'map': {'5ae82d3b2e2cb215600090b1': 'brick_1d', '5ae82dc02e2cb215600090f4': 'mortar_1d', '5ae6edaf2e2cb20d58912670': '2d'} }, } result_folder = r'U:\RIBuild\2D_1D\Results' files = ['temperature profile.d6o'] # Functions def get_points(result: dict, geo: dict): points = [] for index_ in result['indices']: x_ = geo['element_geometry'][index_][1] y_ = geo['element_geometry'][index_][2] points.append({'cell': index_, 'x': x_, 'y': y_}) return points def add_data_to_points(points: list, results: dict, result_name: str): for cell_ in results['result'].keys(): cell_index = int(cell_.split('_')[1]) for point in points: if point['cell'] == cell_index: point[result_name] = np.array(results['result'][cell_][8760:]) break def main(project_): projects = list(project_dict[project_]['map'].keys()) parsed_dicts = {'brick_1d': {'temp': {}, 'geo': {}}, 'mortar_1d': {'temp': {}, 'geo': {}}, '2d': {'temp': {}, 'geo': {}}, } for p_ in projects: for mp_key in project_dict[project_]['map'].keys(): if p_ == mp_key: key = project_dict[project_]['map'][mp_key] folder = result_folder + f'/{p_}/results' geo_file = [file for file in os.listdir(folder) if file.endswith('.g6a')][0] parsed_dicts[key]['temp'], _ = delphin_parser.d6o_to_dict(folder, files[0]) parsed_dicts[key]['geo'] = delphin_parser.g6a_to_dict(folder, geo_file) x_date = [datetime.datetime(2020, 1, 1) + datetime.timedelta(hours=i) for i in range(len(parsed_dicts['brick_1d']['temp']['result']['cell_0'][8760:]))] # Brick 1D brick_1d = get_points(parsed_dicts['brick_1d']['temp'], parsed_dicts['brick_1d']['geo']) brick_1d.sort(key=lambda point: point['x']) add_data_to_points(brick_1d, parsed_dicts['brick_1d']['temp'], 'temperature') # Mortar 1D mortar_1d = get_points(parsed_dicts['mortar_1d']['temp'], parsed_dicts['mortar_1d']['geo']) mortar_1d.sort(key=lambda point: point['x']) add_data_to_points(mortar_1d, parsed_dicts['mortar_1d']['temp'], 'temperature') # 2D sim_2d = get_points(parsed_dicts['2d']['temp'], parsed_dicts['2d']['geo']) sim_2d.sort(key=lambda point: (point['x'], point['y'])) add_data_to_points(sim_2d, parsed_dicts['2d']['temp'], 'temperature') # Plots def plot_locations(quantity): # Axes 00 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[0]['x']:.4f} and 2D-Location: {sim_2d[0]['x']:.4f}") plt.plot(x_date, brick_1d[0][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[0][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[0][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[1][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[2][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') # Axes 01 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[1]['x']:.4f} and 2D-Location: {sim_2d[3]['x']:.4f}") plt.plot(x_date, brick_1d[1][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[1][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[3][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[4][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[5][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') # Axes 10 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[2]['x']:.4f} and 2D-Location: {sim_2d[6]['x']:.4f}") plt.plot(x_date, brick_1d[2][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[2][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[6][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[7][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[8][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') # Axes 11 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[3]['x']:.4f} and 2D-Location: {sim_2d[9]['x']:.4f}") plt.plot(x_date, brick_1d[3][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[3][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[9][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[10][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[11][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') # Axes 20 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[4]['x']:.4f} and 2D-Location: {sim_2d[12]['x']:.4f}") plt.plot(x_date, brick_1d[4][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[4][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[12][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[13][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[14][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') # Axes 21 plt.figure() plt.title(f"{quantity}\n1D-Location: {brick_1d[5]['x']:.4f} and 2D-Location: {sim_2d[15]['x']:.4f}") plt.plot(x_date, brick_1d[5][quantity], color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_1d[5][quantity], color=colors['1d_mortar'], label=f"1D Mortar") plt.plot(x_date, sim_2d[15][quantity], color=colors['bottom'], label=f"2D Bottom") plt.plot(x_date, sim_2d[16][quantity], color=colors['mid'], label=f"2D Mid") plt.plot(x_date, sim_2d[17][quantity], color=colors['top'], label=f"2D Top") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel(f'{quantity}') #plot_locations(quantity='temperature') #plt.show() def abs_diff(x1, x2): return x2 - x1 def rel_diff(x1, x2): return (abs(x2 - x1))/abs(x2) * 100 def differences(i, plots=False): avg_2d = np.mean([sim_2d[i]['temperature'], sim_2d[i+2]['temperature'], sim_2d[i+2]['temperature']], axis=0) brick_abs = abs_diff(brick_1d[i]['temperature'], avg_2d) mortar_abs = abs_diff(mortar_1d[i]['temperature'], avg_2d) brick_rel = rel_diff(brick_1d[i]['temperature'], avg_2d) mortar_rel = rel_diff(mortar_1d[i]['temperature'], avg_2d) if plots: # Plot plt.figure() plt.title(f"Temperature - Absolute Difference\n" f"1D-Location: {brick_1d[i]['x']:.4f} and 2D-Location: {sim_2d[i*3]['x']:.4f}") plt.plot(x_date, brick_abs, color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_abs, color=colors['1d_mortar'], label=f"1D Mortar") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel('C') plt.figure() plt.title(f"Temperature - Relative Difference\n" f"1D-Location: {brick_1d[i]['x']:.4f} and 2D-Location: {sim_2d[i*3]['x']:.4f}") plt.plot(x_date, brick_rel, color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_rel, color=colors['1d_mortar'], label=f"1D Mortar") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel('%') local_df = pd.DataFrame(columns=[f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}"], index=pd.DatetimeIndex(start=datetime.datetime(2020, 1, 1), freq='h', periods=len(brick_rel)), data=np.vstack([brick_rel, brick_abs, mortar_rel, mortar_abs]).T) local_df.columns = pd.MultiIndex.from_arrays([local_df.columns, ['brick', 'brick', 'mortar', 'mortar'], ['relative', 'absolute', 'relative', 'absolute']], names=['location', 'material', 'type']) return local_df def differences_weighted(i, plots=False): avg_2d = np.average(a=[sim_2d[i]['temperature'], sim_2d[i+2]['temperature'], sim_2d[i+2]['temperature']], axis=0, weights=[56, 24., 56]) brick_abs = abs_diff(brick_1d[i]['temperature'], avg_2d) mortar_abs = abs_diff(mortar_1d[i]['temperature'], avg_2d) brick_rel = rel_diff(brick_1d[i]['temperature'], avg_2d) mortar_rel = rel_diff(mortar_1d[i]['temperature'], avg_2d) if plots: # Plot plt.figure() plt.title(f"Temperature - Weighted Absolute Difference\n" f"1D-Location: {brick_1d[i]['x']:.4f} and 2D-Location: {sim_2d[i*3]['x']:.4f}") plt.plot(x_date, brick_abs, color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_abs, color=colors['1d_mortar'], label=f"1D Mortar") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel('%') plt.figure() plt.title(f"Temperature - Weighted Relative Difference\n" f"1D-Location: {brick_1d[i]['x']:.4f} and 2D-Location: {sim_2d[i*3]['x']:.4f}") plt.plot(x_date, brick_rel, color=colors['1d_brick'], label=f"1D Brick") plt.plot(x_date, mortar_rel, color=colors['1d_mortar'], label=f"1D Mortar") plt.legend() plt.gcf().autofmt_xdate() plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%B')) plt.ylabel('%') local_df = pd.DataFrame(columns=[f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}", f"{brick_1d[i]['x']:.04f}"], index=pd.DatetimeIndex(start=datetime.datetime(2020, 1, 1), freq='h', periods=len(brick_rel)), data=np.vstack([brick_rel, brick_abs, mortar_rel, mortar_abs]).T) local_df.columns = pd.MultiIndex.from_arrays([local_df.columns, ['brick', 'brick', 'mortar', 'mortar'], ['relative', 'absolute', 'relative', 'absolute']], names=['location', 'material', 'type']) return local_df dataframes = [] weighted_dataframes = [] for index in range(len(brick_1d)): dataframes.append(differences(index)) weighted_dataframes.append(differences_weighted(index)) #plt.show() result_dataframe = pd.concat(dataframes, axis=1) w_result_dataframe = pd.concat(weighted_dataframes, axis=1) absolute_df = result_dataframe.loc[:, pd.IndexSlice[:, :, 'absolute']] absolute_df.columns = absolute_df.columns.droplevel(level=2) relative_df = result_dataframe.loc[:, pd.IndexSlice[:, :, 'relative']] relative_df.columns = relative_df.columns.droplevel(level=2) w_absolute_df = w_result_dataframe.loc[:, pd.IndexSlice[:, :, 'absolute']] w_absolute_df.columns = w_absolute_df.columns.droplevel(level=2) w_relative_df = w_result_dataframe.loc[:, pd.IndexSlice[:, :, 'relative']] w_relative_df.columns = w_relative_df.columns.droplevel(level=2) plt.figure() ax = absolute_df.boxplot() ax.set_ylim(-20, 20) ax.set_ylabel('Temperature - C') ax.set_title('Absolute Differences') #plt.show() out_folder = r'C:\Users\ocni\PycharmProjects\delphin_6_automation\data_process\2d_1d\processed_data' def excel(): writer = pd.ExcelWriter(out_folder + '/temperature.xlsx') relative_df.describe().to_excel(writer, 'relative') absolute_df.describe().to_excel(writer, 'absolute') writer.save() #excel() def save_relative(): hdf_file = out_folder + '/relative_temperature.h5' w_relative_df.to_hdf(hdf_file, project_, append=True) save_relative() for project_key in project_dict.keys(): print(f'Processing {project_key}') main(project_key)
mit
[ 363, 2502, 363, 275, 298, 1049, 18824, 5653, 1804, 12358, 5294, 1005, 2, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 5025, 2596, 51, 199, 199, 3, 18167, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 646, 747, 199, 646, 2197, 199, 646, 8027, 14, 9356, 465, 333, 9356, 199, 646, 10634, 465, 6454, 199, 199, 3, 820, 73, 3425, 18167, 199, 504, 2150, 838, 262, 63, 22, 63, 23867, 14, 493, 63, 11059, 492, 2150, 838, 262, 63, 2087, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 820, 41, 3425, 28154, 199, 3, 13515, 199, 7120, 275, 791, 2119, 356, 3943, 8223, 4134, 383, 297, 283, 8523, 356, 3943, 34, 2835, 33, 21, 36, 297, 283, 8305, 356, 3943, 1965, 35, 22, 35, 16, 297, 283, 17, 68, 63, 29541, 356, 3943, 3273, 297, 283, 17, 68, 63, 77, 361, 285, 356, 3943, 11156, 2571, 36, 20, 936, 199, 1715, 63, 807, 275, 791, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 16, 15139, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1046, 66, 20, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 13741, 16, 65, 7759, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 69, 25, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 16, 2470, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1046, 70, 17, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 13741, 18, 3833, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1085, 2898, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 1082, 2789, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 12438, 69, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 350, 2055, 2576, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1085, 2592, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 22, 5756, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10848, 70, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 525, 65, 23, 10419, 69, 18, 2894, 1165, 28150, 65, 1641, 67, 22, 69, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 1602, 70, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 975, 65, 24, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 350, 2866, 1602, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 30828, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 350, 25, 69, 20, 70, 1081, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 975, 69, 21, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 525, 25, 66, 29929, 69, 18, 2894, 1165, 28150, 65, 1641, 1235, 20, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 3624, 31831, 6390, 69, 18, 2894, 1081, 68, 2006, 697, 1427, 1229, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 3624, 10156, 2177, 18, 69, 18, 2894, 1081, 9523, 1229, 67, 17, 65, 20, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 3624, 31831, 68, 2564, 69, 18, 2894, 1081, 68, 2006, 697, 21, 13830, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 3624, 13944, 70, 713, 69, 18, 2894, 1081, 9523, 1229, 67, 14622, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 3624, 2564, 28150, 18, 69, 18, 2894, 7842, 22, 19141, 771, 24, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 356 ]
[ 2502, 363, 275, 298, 1049, 18824, 5653, 1804, 12358, 5294, 1005, 2, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 5025, 2596, 51, 199, 199, 3, 18167, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 646, 747, 199, 646, 2197, 199, 646, 8027, 14, 9356, 465, 333, 9356, 199, 646, 10634, 465, 6454, 199, 199, 3, 820, 73, 3425, 18167, 199, 504, 2150, 838, 262, 63, 22, 63, 23867, 14, 493, 63, 11059, 492, 2150, 838, 262, 63, 2087, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 820, 41, 3425, 28154, 199, 3, 13515, 199, 7120, 275, 791, 2119, 356, 3943, 8223, 4134, 383, 297, 283, 8523, 356, 3943, 34, 2835, 33, 21, 36, 297, 283, 8305, 356, 3943, 1965, 35, 22, 35, 16, 297, 283, 17, 68, 63, 29541, 356, 3943, 3273, 297, 283, 17, 68, 63, 77, 361, 285, 356, 3943, 11156, 2571, 36, 20, 936, 199, 1715, 63, 807, 275, 791, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 16, 15139, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1046, 66, 20, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 13741, 16, 65, 7759, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 69, 25, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 16, 2470, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1046, 70, 17, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 13741, 18, 3833, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1085, 2898, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 1082, 2789, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 12438, 69, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 19, 4361, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10642, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 350, 2055, 2576, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1085, 2592, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 22, 5756, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 10848, 70, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 525, 65, 23, 10419, 69, 18, 2894, 1165, 28150, 65, 1641, 67, 22, 69, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 350, 25, 69, 1602, 70, 18, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 975, 65, 24, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2079, 283, 21, 350, 2866, 1602, 996, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 30828, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 350, 25, 69, 20, 70, 1081, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 975, 69, 21, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 350, 25, 69, 2010, 713, 69, 18, 2894, 1081, 70, 18, 67, 20, 70, 1196, 1081, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 525, 25, 66, 29929, 69, 18, 2894, 1165, 28150, 65, 1641, 1235, 20, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 3624, 31831, 6390, 69, 18, 2894, 1081, 68, 2006, 697, 1427, 1229, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 3624, 10156, 2177, 18, 69, 18, 2894, 1081, 9523, 1229, 67, 17, 65, 20, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 791, 21, 3624, 31831, 68, 2564, 69, 18, 2894, 1081, 68, 2006, 697, 21, 13830, 356, 283, 29541, 63, 17, 68, 297, 2490, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 356, 283, 77, 361, 285, 63, 17, 68, 297, 2490, 283, 21, 3624, 13944, 70, 713, 69, 18, 2894, 1081, 9523, 1229, 67, 14622, 356, 283, 18, 68, 936, 2151, 1660, 355, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 356, 490, 791, 1130, 356, 586, 791, 21, 3624, 2564, 28150, 18, 69, 18, 2894, 7842, 22, 19141, 771, 24, 356, 283, 29541, 63, 17, 68, 297, 2079, 283, 21, 3624, 2564, 67, 9485, 69, 18, 2894, 7842, 22, 21144, 996, 66, 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, 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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 ]
marcoitur/Freecad_test
src/Mod/TemplatePyMod/Texture.py
58
1835
# (c) 2012 Werner Mayer LGPL import FreeCAD, FreeCADGui from FreeCAD import Base from pivy import coin class Texture: def __init__(self, obj, source): "Add some custom properties to our box feature" obj.addProperty("App::PropertyLink","Source","Texture", "Link to the shape").Source = source obj.Proxy = self def onChanged(self, fp, prop): return def execute(self, fp): return class ViewProviderTexture: def __init__(self, obj): obj.addProperty("App::PropertyPath","File","Texture", "File name to the texture resource") self.obj = obj obj.Proxy = self def onChanged(self, obj, prop): if prop == "File": self.tex.filename = str(obj.File) return def updateData(self, fp, prop): return def getDisplayModes(self,obj): ''' Return a list of display modes. ''' modes=["Texture"] return modes def attach(self, obj): self.grp = coin.SoGroup() self.tex = coin.SoTexture2() #self.env = coin.SoTextureCoordinateEnvironment() self.grp.addChild(self.tex) #self.grp.addChild(self.env) root = obj.Object.Source.ViewObject.RootNode self.grp.addChild(root) obj.addDisplayMode(self.grp,"Texture") # move the original node doc = obj.Object.Document doc = FreeCADGui.getDocument(doc.Name) graph = doc.ActiveView.getSceneGraph() graph.removeChild(root) def claimChildren(self): return [self.obj.Object.Source] def __getstate__(self): return None def __setstate__(self,state): return None def makeTexture(): FreeCAD.newDocument() box = FreeCAD.ActiveDocument.addObject("Part::Box","Box") tex=FreeCAD.ActiveDocument.addObject("App::FeaturePython","Texture") Texture(tex, box) box.ViewObject.Selectable = False ViewProviderTexture(tex.ViewObject) box.touch() FreeCAD.ActiveDocument.recompute()
lgpl-2.1
[ 3, 334, 67, 9, 6029, 644, 281, 1372, 10162, 281, 32426, 2999, 199, 646, 20914, 12, 20914, 4324, 202, 199, 504, 20914, 492, 3523, 202, 199, 504, 299, 10241, 492, 21914, 2999, 199, 533, 4516, 608, 26, 1223, 198, 318, 636, 826, 721, 277, 12, 1559, 12, 1350, 304, 4122, 198, 2, 1123, 2005, 3537, 4382, 370, 4154, 5689, 3878, 2, 4122, 198, 1113, 14, 525, 3697, 480, 2640, 447, 3697, 3834, 2266, 2980, 2266, 17165, 401, 298, 3834, 370, 314, 2215, 3471, 2980, 275, 1350, 4122, 198, 1113, 14, 4936, 275, 291, 10060, 198, 318, 641, 6970, 8, 277, 12, 4090, 12, 5931, 304, 4122, 198, 1107, 10060, 198, 318, 5341, 8, 277, 12, 4090, 304, 4122, 198, 1107, 2999, 199, 533, 10935, 6663, 17165, 26, 1223, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 4122, 198, 1113, 14, 525, 3697, 480, 2640, 447, 3697, 2042, 2266, 1173, 2266, 17165, 401, 298, 1173, 536, 370, 314, 14855, 2073, 531, 4122, 198, 277, 14, 1113, 275, 1559, 4122, 198, 1113, 14, 4936, 275, 291, 10060, 198, 318, 641, 6970, 8, 277, 12, 1559, 12, 5931, 304, 4122, 198, 692, 5931, 508, 298, 1173, 582, 7903, 198, 277, 14, 3858, 14, 1501, 275, 620, 8, 1113, 14, 1173, 9, 4122, 198, 1107, 10060, 198, 318, 1678, 1451, 8, 277, 12, 4090, 12, 5931, 304, 4122, 198, 1107, 10060, 198, 318, 664, 7687, 19578, 8, 277, 12, 1113, 304, 4122, 198, 2344, 1432, 282, 769, 402, 2929, 12404, 14, 1449, 4122, 198, 10433, 6270, 17165, 937, 4122, 198, 1107, 12404, 10060, 198, 318, 6554, 8, 277, 12, 1559, 304, 4122, 198, 277, 14, 12599, 275, 21914, 14, 5158, 2448, 342, 4122, 198, 277, 14, 3858, 275, 21914, 14, 5158, 17165, 18, 342, 4122, 198, 3, 277, 14, 1813, 275, 21914, 14, 5158, 17165, 18017, 8263, 342, 10292, 4122, 198, 277, 14, 12599, 14, 23897, 8, 277, 14, 3858, 9, 4122, 198, 3, 277, 14, 12599, 14, 23897, 8, 277, 14, 1813, 9, 4122, 198, 1231, 275, 1559, 14, 1692, 14, 2980, 14, 2768, 1692, 14, 6405, 1716, 4122, 198, 277, 14, 12599, 14, 23897, 8, 1231, 9, 4122, 198, 1113, 14, 525, 7687, 1385, 8, 277, 14, 12599, 4589, 17165, 531, 4122, 198, 3, 4057, 314, 3379, 1031, 4122, 198, 1301, 275, 1559, 14, 1692, 14, 5564, 4122, 198, 1301, 275, 20914, 4324, 14, 362, 5564, 8, 1301, 14, 985, 9, 4122, 198, 2180, 275, 1382, 14, 7472, 2768, 14, 362, 14216, 4578, 342, 4122, 198, 2180, 14, 2168, 3493, 8, 1231, 9, 202, 421, 198, 318, 22498, 7139, 8, 277, 304, 507, 198, 1107, 359, 277, 14, 1113, 14, 1692, 14, 2980, 61, 199, 1223, 198, 318, 636, 16011, 721, 277, 304, 4122, 198, 1107, 488, 10292, 1223, 198, 318, 636, 17212, 721, 277, 12, 929, 304, 4122, 198, 1107, 488, 2999, 199, 318, 1852, 17165, 837, 1223, 198, 10146, 17238, 14, 1222, 5564, 342, 1223, 198, 1977, 275, 20914, 14, 7472, 5564, 14, 525, 1692, 480, 8416, 447, 3532, 2266, 3532, 531, 1223, 198, 3858, 29, 10146, 17238, 14, 7472, 5564, 14, 525, 1692, 480, 2640, 447, 5968, 4718, 2266, 17165, 531, 1223, 198, 17165, 8, 3858, 12, 5689, 9, 1223, 198, 1977, 14, 2768, 1692, 14, 5446, 461, 275, 756, 1223, 198, 2768, 6663, 17165, 8, 3858, 14, 2768, 1692, 9, 1223, 198, 1977, 14, 12376, 342, 1223, 198, 10146, 17238, 14, 7472, 5564, 14, 264, 3357, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 6029, 644, 281, 1372, 10162, 281, 32426, 2999, 199, 646, 20914, 12, 20914, 4324, 202, 199, 504, 20914, 492, 3523, 202, 199, 504, 299, 10241, 492, 21914, 2999, 199, 533, 4516, 608, 26, 1223, 198, 318, 636, 826, 721, 277, 12, 1559, 12, 1350, 304, 4122, 198, 2, 1123, 2005, 3537, 4382, 370, 4154, 5689, 3878, 2, 4122, 198, 1113, 14, 525, 3697, 480, 2640, 447, 3697, 3834, 2266, 2980, 2266, 17165, 401, 298, 3834, 370, 314, 2215, 3471, 2980, 275, 1350, 4122, 198, 1113, 14, 4936, 275, 291, 10060, 198, 318, 641, 6970, 8, 277, 12, 4090, 12, 5931, 304, 4122, 198, 1107, 10060, 198, 318, 5341, 8, 277, 12, 4090, 304, 4122, 198, 1107, 2999, 199, 533, 10935, 6663, 17165, 26, 1223, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 4122, 198, 1113, 14, 525, 3697, 480, 2640, 447, 3697, 2042, 2266, 1173, 2266, 17165, 401, 298, 1173, 536, 370, 314, 14855, 2073, 531, 4122, 198, 277, 14, 1113, 275, 1559, 4122, 198, 1113, 14, 4936, 275, 291, 10060, 198, 318, 641, 6970, 8, 277, 12, 1559, 12, 5931, 304, 4122, 198, 692, 5931, 508, 298, 1173, 582, 7903, 198, 277, 14, 3858, 14, 1501, 275, 620, 8, 1113, 14, 1173, 9, 4122, 198, 1107, 10060, 198, 318, 1678, 1451, 8, 277, 12, 4090, 12, 5931, 304, 4122, 198, 1107, 10060, 198, 318, 664, 7687, 19578, 8, 277, 12, 1113, 304, 4122, 198, 2344, 1432, 282, 769, 402, 2929, 12404, 14, 1449, 4122, 198, 10433, 6270, 17165, 937, 4122, 198, 1107, 12404, 10060, 198, 318, 6554, 8, 277, 12, 1559, 304, 4122, 198, 277, 14, 12599, 275, 21914, 14, 5158, 2448, 342, 4122, 198, 277, 14, 3858, 275, 21914, 14, 5158, 17165, 18, 342, 4122, 198, 3, 277, 14, 1813, 275, 21914, 14, 5158, 17165, 18017, 8263, 342, 10292, 4122, 198, 277, 14, 12599, 14, 23897, 8, 277, 14, 3858, 9, 4122, 198, 3, 277, 14, 12599, 14, 23897, 8, 277, 14, 1813, 9, 4122, 198, 1231, 275, 1559, 14, 1692, 14, 2980, 14, 2768, 1692, 14, 6405, 1716, 4122, 198, 277, 14, 12599, 14, 23897, 8, 1231, 9, 4122, 198, 1113, 14, 525, 7687, 1385, 8, 277, 14, 12599, 4589, 17165, 531, 4122, 198, 3, 4057, 314, 3379, 1031, 4122, 198, 1301, 275, 1559, 14, 1692, 14, 5564, 4122, 198, 1301, 275, 20914, 4324, 14, 362, 5564, 8, 1301, 14, 985, 9, 4122, 198, 2180, 275, 1382, 14, 7472, 2768, 14, 362, 14216, 4578, 342, 4122, 198, 2180, 14, 2168, 3493, 8, 1231, 9, 202, 421, 198, 318, 22498, 7139, 8, 277, 304, 507, 198, 1107, 359, 277, 14, 1113, 14, 1692, 14, 2980, 61, 199, 1223, 198, 318, 636, 16011, 721, 277, 304, 4122, 198, 1107, 488, 10292, 1223, 198, 318, 636, 17212, 721, 277, 12, 929, 304, 4122, 198, 1107, 488, 2999, 199, 318, 1852, 17165, 837, 1223, 198, 10146, 17238, 14, 1222, 5564, 342, 1223, 198, 1977, 275, 20914, 14, 7472, 5564, 14, 525, 1692, 480, 8416, 447, 3532, 2266, 3532, 531, 1223, 198, 3858, 29, 10146, 17238, 14, 7472, 5564, 14, 525, 1692, 480, 2640, 447, 5968, 4718, 2266, 17165, 531, 1223, 198, 17165, 8, 3858, 12, 5689, 9, 1223, 198, 1977, 14, 2768, 1692, 14, 5446, 461, 275, 756, 1223, 198, 2768, 6663, 17165, 8, 3858, 14, 2768, 1692, 9, 1223, 198, 1977, 14, 12376, 342, 1223, 198, 10146, 17238, 14, 7472, 5564, 14, 264, 3357, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
weechat/weechat.org
weechat/news/views.py
1
3923
# # Copyright (C) 2003-2021 Sébastien Helleu <flashcode@flashtux.org> # # This file is part of WeeChat.org. # # WeeChat.org 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. # # WeeChat.org 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 WeeChat.org. If not, see <https://www.gnu.org/licenses/>. # """Views for news.""" from datetime import datetime from django.core.exceptions import ObjectDoesNotExist from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.shortcuts import render from weechat.download.models import Release from weechat.news.models import Info def home(request, max_info=None, max_event=None): """Homepage.""" now = datetime.now() info_list = (Info.objects.all().filter(visible=1).filter(date__lte=now) .order_by('-date')) if max_info: info_list = info_list[:max_info] event_list = (Info.objects.all().filter(visible=1).filter(date__gt=now) .order_by('date')) if max_event: event_list = event_list[:max_event] try: stable_version = Release.objects.get(version='stable').description release_stable = Release.objects.get(version=stable_version) except ObjectDoesNotExist: release_stable = None return render( request, 'home/home.html', { 'release_stable': release_stable, 'info_list': info_list, 'event_list': event_list, }, ) def paginate_news(request, info_list, pagesize): """Paginate list of news.""" paginator = Paginator(info_list, pagesize) page = request.GET.get('page') try: infos = paginator.page(page) except PageNotAnInteger: infos = paginator.page(1) except EmptyPage: infos = paginator.page(paginator.num_pages) first_page = max(infos.number - 2, 1) last_page = min(infos.number + 2, paginator.num_pages) if first_page == 3: first_page = 1 if last_page == paginator.num_pages - 2: last_page = paginator.num_pages smart_page_range = range(first_page, last_page + 1) return (infos, smart_page_range) def render_news(request, info_list, info_id, page_name): """Render the paginated news.""" pagesize = request.GET.get('pagesize', 10) try: pagesize = max(int(pagesize), 1) except ValueError: pagesize = 10 infos, smart_page_range = paginate_news(request, info_list, pagesize) event = infos and infos[0].date > datetime.now() return render(request, 'home/news.html', { 'infos': infos, 'info_id': info_id, 'event': event, 'page_name': page_name, 'smart_page_range': smart_page_range, 'pagesize': pagesize, }) def news(request, info_id=None): """List of news.""" try: if info_id: info_list = [Info.objects.get(id=info_id, visible=1)] else: info_list = (Info.objects.all().filter(visible=1) .filter(date__lte=datetime.now()).order_by('-date')) except ObjectDoesNotExist: info_list = [] return render_news(request, info_list, info_id, 'news') def events(request): """List of upcoming events.""" try: info_list = (Info.objects.all().filter(visible=1) .filter(date__gt=datetime.now()).order_by('date')) except ObjectDoesNotExist: info_list = [] return render_news(request, info_list, None, 'events')
gpl-3.0
[ 3, 199, 3, 1898, 334, 35, 9, 13004, 13, 22150, 428, 5741, 66, 1810, 24555, 869, 352, 274, 85, 665, 11331, 600, 32, 2327, 305, 517, 2521, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 644, 1024, 21954, 14, 1308, 14, 199, 3, 199, 3, 644, 1024, 21954, 14, 1308, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 644, 1024, 21954, 14, 1308, 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, 644, 1024, 21954, 14, 1308, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 21180, 367, 19497, 1041, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 12, 9630, 3276, 12, 10331, 1763, 2493, 2674, 199, 504, 1639, 14, 17469, 492, 3795, 199, 199, 504, 781, 69, 10289, 14, 4249, 14, 992, 492, 17646, 199, 504, 781, 69, 10289, 14, 13224, 14, 992, 492, 10332, 421, 199, 318, 5629, 8, 1069, 12, 1390, 63, 815, 29, 403, 12, 1390, 63, 1430, 29, 403, 304, 272, 408, 12054, 1606, 1041, 272, 3063, 275, 2197, 14, 2131, 342, 272, 2256, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 680, 1541, 8, 602, 363, 20740, 29, 2131, 9, 326, 1275, 1648, 63, 991, 3654, 602, 1333, 272, 340, 1390, 63, 815, 26, 267, 2256, 63, 513, 275, 2256, 63, 513, 1491, 988, 63, 815, 61, 272, 1566, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 680, 1541, 8, 602, 363, 3308, 29, 2131, 9, 2116, 1275, 1648, 63, 991, 360, 602, 1333, 272, 340, 1390, 63, 1430, 26, 267, 1566, 63, 513, 275, 1566, 63, 513, 1491, 988, 63, 1430, 61, 272, 862, 26, 267, 17830, 63, 1023, 275, 17646, 14, 1462, 14, 362, 8, 1023, 534, 11989, 1959, 1802, 267, 4683, 63, 11989, 275, 17646, 14, 1462, 14, 362, 8, 1023, 29, 11989, 63, 1023, 9, 272, 871, 24803, 26, 267, 4683, 63, 11989, 275, 488, 272, 372, 3795, 8, 267, 1056, 12, 267, 283, 4219, 15, 4219, 14, 1360, 297, 267, 469, 288, 283, 3221, 63, 11989, 356, 4683, 63, 11989, 12, 288, 283, 815, 63, 513, 356, 2256, 63, 513, 12, 288, 283, 1430, 63, 513, 356, 1566, 63, 513, 12, 267, 1660, 272, 776, 421, 199, 318, 9881, 23043, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2034, 890, 304, 272, 408, 23862, 23043, 769, 402, 19497, 1041, 272, 21398, 275, 28006, 8566, 8, 815, 63, 513, 12, 2034, 890, 9, 272, 2034, 275, 1056, 14, 2970, 14, 362, 360, 1606, 358, 272, 862, 26, 267, 24485, 275, 21398, 14, 1606, 8, 1606, 9, 272, 871, 10331, 1763, 2493, 2674, 26, 267, 24485, 275, 21398, 14, 1606, 8, 17, 9, 272, 871, 9630, 3276, 26, 267, 24485, 275, 21398, 14, 1606, 8, 22073, 14, 1507, 63, 5856, 9, 339, 1642, 63, 1606, 275, 1390, 8, 14195, 14, 1955, 446, 499, 12, 413, 9, 272, 2061, 63, 1606, 275, 1748, 8, 14195, 14, 1955, 435, 499, 12, 21398, 14, 1507, 63, 5856, 9, 272, 340, 1642, 63, 1606, 508, 650, 26, 267, 1642, 63, 1606, 275, 413, 272, 340, 2061, 63, 1606, 508, 21398, 14, 1507, 63, 5856, 446, 499, 26, 267, 2061, 63, 1606, 275, 21398, 14, 1507, 63, 5856, 272, 11179, 63, 1606, 63, 1842, 275, 1425, 8, 2246, 63, 1606, 12, 2061, 63, 1606, 435, 413, 9, 339, 372, 334, 14195, 12, 11179, 63, 1606, 63, 1842, 9, 421, 199, 318, 3795, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2256, 63, 344, 12, 2034, 63, 354, 304, 272, 408, 9216, 314, 9881, 23831, 19497, 1041, 272, 2034, 890, 275, 1056, 14, 2970, 14, 362, 360, 1606, 890, 297, 1616, 9, 272, 862, 26, 267, 2034, 890, 275, 1390, 8, 442, 8, 1606, 890, 395, 413, 9, 272, 871, 1722, 26, 267, 2034, 890, 275, 1616, 272, 24485, 12, 11179, 63, 1606, 63, 1842, 275, 9881, 23043, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2034, 890, 9, 272, 1566, 275, 24485, 436, 24485, 59, 16, 1055, 602, 690, 2197, 14, 2131, 342, 272, 372, 3795, 8, 1069, 12, 283, 4219, 15, 13224, 14, 1360, 297, 469, 267, 283, 14195, 356, 24485, 12, 267, 283, 815, 63, 344, 356, 2256, 63, 344, 12, 267, 283, 1430, 356, 1566, 12, 267, 283, 1606, 63, 354, 356, 2034, 63, 354, 12, 267, 283, 7853, 63, 1606, 63, 1842, 356, 11179, 63, 1606, 63, 1842, 12, 267, 283, 1606, 890, 356, 2034, 890, 12, 272, 3828, 421, 199, 318, 19497, 8, 1069, 12, 2256, 63, 344, 29, 403, 304, 272, 408, 1296, 402, 19497, 1041, 272, 862, 26, 267, 340, 2256, 63, 344, 26, 288, 2256, 63, 513, 275, 359, 2354, 14, 1462, 14, 362, 8, 344, 29, 815, 63, 344, 12, 8917, 29, 17, 1874, 267, 587, 26, 288, 2256, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 9, 586, 1275, 1541, 8, 602, 363, 20740, 29, 2083, 14, 2131, 8801, 1648, 63, 991, 3654, 602, 1333, 272, 871, 24803, 26, 267, 2256, 63, 513, 275, 942, 272, 372, 3795, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2256, 63, 344, 12, 283, 13224, 358, 421, 199, 318, 4474, 8, 1069, 304, 272, 408, 1296, 402, 1536, 7909, 4474, 1041, 272, 862, 26, 267, 2256 ]
[ 199, 3, 1898, 334, 35, 9, 13004, 13, 22150, 428, 5741, 66, 1810, 24555, 869, 352, 274, 85, 665, 11331, 600, 32, 2327, 305, 517, 2521, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 644, 1024, 21954, 14, 1308, 14, 199, 3, 199, 3, 644, 1024, 21954, 14, 1308, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 644, 1024, 21954, 14, 1308, 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, 644, 1024, 21954, 14, 1308, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 21180, 367, 19497, 1041, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 12, 9630, 3276, 12, 10331, 1763, 2493, 2674, 199, 504, 1639, 14, 17469, 492, 3795, 199, 199, 504, 781, 69, 10289, 14, 4249, 14, 992, 492, 17646, 199, 504, 781, 69, 10289, 14, 13224, 14, 992, 492, 10332, 421, 199, 318, 5629, 8, 1069, 12, 1390, 63, 815, 29, 403, 12, 1390, 63, 1430, 29, 403, 304, 272, 408, 12054, 1606, 1041, 272, 3063, 275, 2197, 14, 2131, 342, 272, 2256, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 680, 1541, 8, 602, 363, 20740, 29, 2131, 9, 326, 1275, 1648, 63, 991, 3654, 602, 1333, 272, 340, 1390, 63, 815, 26, 267, 2256, 63, 513, 275, 2256, 63, 513, 1491, 988, 63, 815, 61, 272, 1566, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 680, 1541, 8, 602, 363, 3308, 29, 2131, 9, 2116, 1275, 1648, 63, 991, 360, 602, 1333, 272, 340, 1390, 63, 1430, 26, 267, 1566, 63, 513, 275, 1566, 63, 513, 1491, 988, 63, 1430, 61, 272, 862, 26, 267, 17830, 63, 1023, 275, 17646, 14, 1462, 14, 362, 8, 1023, 534, 11989, 1959, 1802, 267, 4683, 63, 11989, 275, 17646, 14, 1462, 14, 362, 8, 1023, 29, 11989, 63, 1023, 9, 272, 871, 24803, 26, 267, 4683, 63, 11989, 275, 488, 272, 372, 3795, 8, 267, 1056, 12, 267, 283, 4219, 15, 4219, 14, 1360, 297, 267, 469, 288, 283, 3221, 63, 11989, 356, 4683, 63, 11989, 12, 288, 283, 815, 63, 513, 356, 2256, 63, 513, 12, 288, 283, 1430, 63, 513, 356, 1566, 63, 513, 12, 267, 1660, 272, 776, 421, 199, 318, 9881, 23043, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2034, 890, 304, 272, 408, 23862, 23043, 769, 402, 19497, 1041, 272, 21398, 275, 28006, 8566, 8, 815, 63, 513, 12, 2034, 890, 9, 272, 2034, 275, 1056, 14, 2970, 14, 362, 360, 1606, 358, 272, 862, 26, 267, 24485, 275, 21398, 14, 1606, 8, 1606, 9, 272, 871, 10331, 1763, 2493, 2674, 26, 267, 24485, 275, 21398, 14, 1606, 8, 17, 9, 272, 871, 9630, 3276, 26, 267, 24485, 275, 21398, 14, 1606, 8, 22073, 14, 1507, 63, 5856, 9, 339, 1642, 63, 1606, 275, 1390, 8, 14195, 14, 1955, 446, 499, 12, 413, 9, 272, 2061, 63, 1606, 275, 1748, 8, 14195, 14, 1955, 435, 499, 12, 21398, 14, 1507, 63, 5856, 9, 272, 340, 1642, 63, 1606, 508, 650, 26, 267, 1642, 63, 1606, 275, 413, 272, 340, 2061, 63, 1606, 508, 21398, 14, 1507, 63, 5856, 446, 499, 26, 267, 2061, 63, 1606, 275, 21398, 14, 1507, 63, 5856, 272, 11179, 63, 1606, 63, 1842, 275, 1425, 8, 2246, 63, 1606, 12, 2061, 63, 1606, 435, 413, 9, 339, 372, 334, 14195, 12, 11179, 63, 1606, 63, 1842, 9, 421, 199, 318, 3795, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2256, 63, 344, 12, 2034, 63, 354, 304, 272, 408, 9216, 314, 9881, 23831, 19497, 1041, 272, 2034, 890, 275, 1056, 14, 2970, 14, 362, 360, 1606, 890, 297, 1616, 9, 272, 862, 26, 267, 2034, 890, 275, 1390, 8, 442, 8, 1606, 890, 395, 413, 9, 272, 871, 1722, 26, 267, 2034, 890, 275, 1616, 272, 24485, 12, 11179, 63, 1606, 63, 1842, 275, 9881, 23043, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2034, 890, 9, 272, 1566, 275, 24485, 436, 24485, 59, 16, 1055, 602, 690, 2197, 14, 2131, 342, 272, 372, 3795, 8, 1069, 12, 283, 4219, 15, 13224, 14, 1360, 297, 469, 267, 283, 14195, 356, 24485, 12, 267, 283, 815, 63, 344, 356, 2256, 63, 344, 12, 267, 283, 1430, 356, 1566, 12, 267, 283, 1606, 63, 354, 356, 2034, 63, 354, 12, 267, 283, 7853, 63, 1606, 63, 1842, 356, 11179, 63, 1606, 63, 1842, 12, 267, 283, 1606, 890, 356, 2034, 890, 12, 272, 3828, 421, 199, 318, 19497, 8, 1069, 12, 2256, 63, 344, 29, 403, 304, 272, 408, 1296, 402, 19497, 1041, 272, 862, 26, 267, 340, 2256, 63, 344, 26, 288, 2256, 63, 513, 275, 359, 2354, 14, 1462, 14, 362, 8, 344, 29, 815, 63, 344, 12, 8917, 29, 17, 1874, 267, 587, 26, 288, 2256, 63, 513, 275, 334, 2354, 14, 1462, 14, 452, 1252, 1541, 8, 6604, 29, 17, 9, 586, 1275, 1541, 8, 602, 363, 20740, 29, 2083, 14, 2131, 8801, 1648, 63, 991, 3654, 602, 1333, 272, 871, 24803, 26, 267, 2256, 63, 513, 275, 942, 272, 372, 3795, 63, 13224, 8, 1069, 12, 2256, 63, 513, 12, 2256, 63, 344, 12, 283, 13224, 358, 421, 199, 318, 4474, 8, 1069, 304, 272, 408, 1296, 402, 1536, 7909, 4474, 1041, 272, 862, 26, 267, 2256, 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,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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 ]
hzy001/ansible
v1/ansible/runner/lookup_plugins/together.py
174
2135
# (c) 2013, Bradley Young <young.bradley@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/>. import ansible.utils as utils from ansible.utils import safe_eval import ansible.errors as errors from itertools import izip_longest def flatten(terms): ret = [] for term in terms: if isinstance(term, list): ret.extend(term) elif isinstance(term, tuple): ret.extend(term) else: ret.append(term) return ret class LookupModule(object): """ Transpose a list of arrays: [1, 2, 3], [4, 5, 6] -> [1, 4], [2, 5], [3, 6] Replace any empty spots in 2nd array with None: [1, 2], [3] -> [1, 3], [2, None] """ def __init__(self, basedir=None, **kwargs): self.basedir = basedir def __lookup_injects(self, terms, inject): results = [] for x in terms: intermediate = utils.listify_lookup_plugin_terms(x, self.basedir, inject) results.append(intermediate) return results def run(self, terms, inject=None, **kwargs): # this code is common with 'items.py' consider moving to utils if we need it again terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) terms = self.__lookup_injects(terms, inject) my_list = terms[:] if len(my_list) == 0: raise errors.AnsibleError("with_together requires at least one element in each list") return [flatten(x) for x in izip_longest(*my_list, fillvalue=None)]
gpl-3.0
[ 3, 334, 67, 9, 6171, 12, 32377, 3011, 89, 1488, 79, 10335, 665, 16540, 10335, 14, 7828, 3011, 89, 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, 199, 199, 646, 3242, 14, 1208, 465, 3778, 199, 504, 3242, 14, 1208, 492, 5048, 63, 2579, 199, 646, 3242, 14, 2550, 465, 2552, 199, 504, 7975, 492, 28697, 63, 20820, 199, 199, 318, 9378, 8, 9187, 304, 272, 2203, 275, 942, 272, 367, 6707, 315, 2895, 26, 267, 340, 1228, 8, 5125, 12, 769, 304, 288, 2203, 14, 2880, 8, 5125, 9, 267, 916, 1228, 8, 5125, 12, 2008, 304, 288, 2203, 14, 2880, 8, 5125, 9, 267, 587, 26, 288, 2203, 14, 740, 8, 5125, 9, 272, 372, 2203, 199, 199, 533, 12785, 2377, 8, 785, 304, 272, 408, 272, 6266, 4070, 282, 769, 402, 6572, 26, 272, 359, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 61, 1035, 359, 17, 12, 841, 467, 359, 18, 12, 959, 467, 359, 19, 12, 1227, 61, 272, 14402, 1263, 2701, 2249, 16673, 315, 499, 977, 1625, 543, 488, 26, 272, 359, 17, 12, 499, 467, 359, 19, 61, 1035, 359, 17, 12, 650, 467, 359, 18, 12, 488, 61, 272, 408, 339, 347, 636, 826, 721, 277, 12, 19380, 29, 403, 12, 1011, 958, 304, 267, 291, 14, 12484, 275, 19380, 339, 347, 636, 3892, 63, 14815, 83, 8, 277, 12, 2895, 12, 16182, 304, 267, 2058, 275, 942, 267, 367, 671, 315, 2895, 26, 288, 13197, 275, 3778, 14, 513, 2021, 63, 3892, 63, 2718, 63, 9187, 8, 88, 12, 291, 14, 12484, 12, 16182, 9, 288, 2058, 14, 740, 8, 15940, 9, 267, 372, 2058, 339, 347, 1255, 8, 277, 12, 2895, 12, 16182, 29, 403, 12, 1011, 958, 304, 398, 327, 642, 1233, 365, 2863, 543, 283, 1744, 14, 647, 7, 11201, 12876, 370, 3778, 340, 781, 1929, 652, 4020, 398, 2895, 275, 3778, 14, 513, 2021, 63, 3892, 63, 2718, 63, 9187, 8, 9187, 12, 291, 14, 12484, 12, 16182, 9, 267, 2895, 275, 291, 855, 3892, 63, 14815, 83, 8, 9187, 12, 16182, 9, 398, 3002, 63, 513, 275, 2895, 5873, 267, 340, 822, 8, 1662, 63, 513, 9, 508, 378, 26, 288, 746, 2552, 14, 29107, 480, 1045, 63, 6314, 5074, 737, 5210, 1373, 1819, 315, 1924, 769, 531, 267, 372, 359, 8487, 8, 88, 9, 367, 671, 315, 28697, 63, 20820, 2031, 1662, 63, 513, 12, 5554, 585, 29, 403, 1874, 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 ]
[ 334, 67, 9, 6171, 12, 32377, 3011, 89, 1488, 79, 10335, 665, 16540, 10335, 14, 7828, 3011, 89, 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, 199, 199, 646, 3242, 14, 1208, 465, 3778, 199, 504, 3242, 14, 1208, 492, 5048, 63, 2579, 199, 646, 3242, 14, 2550, 465, 2552, 199, 504, 7975, 492, 28697, 63, 20820, 199, 199, 318, 9378, 8, 9187, 304, 272, 2203, 275, 942, 272, 367, 6707, 315, 2895, 26, 267, 340, 1228, 8, 5125, 12, 769, 304, 288, 2203, 14, 2880, 8, 5125, 9, 267, 916, 1228, 8, 5125, 12, 2008, 304, 288, 2203, 14, 2880, 8, 5125, 9, 267, 587, 26, 288, 2203, 14, 740, 8, 5125, 9, 272, 372, 2203, 199, 199, 533, 12785, 2377, 8, 785, 304, 272, 408, 272, 6266, 4070, 282, 769, 402, 6572, 26, 272, 359, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 61, 1035, 359, 17, 12, 841, 467, 359, 18, 12, 959, 467, 359, 19, 12, 1227, 61, 272, 14402, 1263, 2701, 2249, 16673, 315, 499, 977, 1625, 543, 488, 26, 272, 359, 17, 12, 499, 467, 359, 19, 61, 1035, 359, 17, 12, 650, 467, 359, 18, 12, 488, 61, 272, 408, 339, 347, 636, 826, 721, 277, 12, 19380, 29, 403, 12, 1011, 958, 304, 267, 291, 14, 12484, 275, 19380, 339, 347, 636, 3892, 63, 14815, 83, 8, 277, 12, 2895, 12, 16182, 304, 267, 2058, 275, 942, 267, 367, 671, 315, 2895, 26, 288, 13197, 275, 3778, 14, 513, 2021, 63, 3892, 63, 2718, 63, 9187, 8, 88, 12, 291, 14, 12484, 12, 16182, 9, 288, 2058, 14, 740, 8, 15940, 9, 267, 372, 2058, 339, 347, 1255, 8, 277, 12, 2895, 12, 16182, 29, 403, 12, 1011, 958, 304, 398, 327, 642, 1233, 365, 2863, 543, 283, 1744, 14, 647, 7, 11201, 12876, 370, 3778, 340, 781, 1929, 652, 4020, 398, 2895, 275, 3778, 14, 513, 2021, 63, 3892, 63, 2718, 63, 9187, 8, 9187, 12, 291, 14, 12484, 12, 16182, 9, 267, 2895, 275, 291, 855, 3892, 63, 14815, 83, 8, 9187, 12, 16182, 9, 398, 3002, 63, 513, 275, 2895, 5873, 267, 340, 822, 8, 1662, 63, 513, 9, 508, 378, 26, 288, 746, 2552, 14, 29107, 480, 1045, 63, 6314, 5074, 737, 5210, 1373, 1819, 315, 1924, 769, 531, 267, 372, 359, 8487, 8, 88, 9, 367, 671, 315, 28697, 63, 20820, 2031, 1662, 63, 513, 12, 5554, 585, 29, 403, 1874, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
BiaDarkia/scikit-learn
examples/semi_supervised/plot_label_propagation_digits_active_learning.py
33
4174
""" ======================================== Label Propagation digits active learning ======================================== Demonstrates an active learning technique to learn handwritten digits using label propagation. We start by training a label propagation model with only 10 labeled points, then we select the top five most uncertain points to label. Next, we train with 15 labeled points (original 10 + 5 new ones). We repeat this process four times to have a model trained with 30 labeled examples. Note you can increase this to label more than 30 by changing `max_iterations`. Labeling more than 30 can be useful to get a sense for the speed of convergence of this active learning technique. A plot will appear showing the top 5 most uncertain digits for each iteration of training. These may or may not contain mistakes, but we will train the next model with their true labels. """ print(__doc__) # Authors: Clay Woolam <clay@woolam.org> # License: BSD import numpy as np import matplotlib.pyplot as plt from scipy import stats from sklearn import datasets from sklearn.semi_supervised import label_propagation from sklearn.metrics import classification_report, confusion_matrix digits = datasets.load_digits() rng = np.random.RandomState(0) indices = np.arange(len(digits.data)) rng.shuffle(indices) X = digits.data[indices[:330]] y = digits.target[indices[:330]] images = digits.images[indices[:330]] n_total_samples = len(y) n_labeled_points = 10 max_iterations = 5 unlabeled_indices = np.arange(n_total_samples)[n_labeled_points:] f = plt.figure() for i in range(max_iterations): if len(unlabeled_indices) == 0: print("No unlabeled items left to label.") break y_train = np.copy(y) y_train[unlabeled_indices] = -1 lp_model = label_propagation.LabelSpreading(gamma=0.25, max_iter=5) lp_model.fit(X, y_train) predicted_labels = lp_model.transduction_[unlabeled_indices] true_labels = y[unlabeled_indices] cm = confusion_matrix(true_labels, predicted_labels, labels=lp_model.classes_) print("Iteration %i %s" % (i, 70 * "_")) print("Label Spreading model: %d labeled & %d unlabeled (%d total)" % (n_labeled_points, n_total_samples - n_labeled_points, n_total_samples)) print(classification_report(true_labels, predicted_labels)) print("Confusion matrix") print(cm) # compute the entropies of transduced label distributions pred_entropies = stats.distributions.entropy( lp_model.label_distributions_.T) # select up to 5 digit examples that the classifier is most uncertain about uncertainty_index = np.argsort(pred_entropies)[::-1] uncertainty_index = uncertainty_index[ np.in1d(uncertainty_index, unlabeled_indices)][:5] # keep track of indices that we get labels for delete_indices = np.array([]) # for more than 5 iterations, visualize the gain only on the first 5 if i < 5: f.text(.05, (1 - (i + 1) * .183), "model %d\n\nfit with\n%d labels" % ((i + 1), i * 5 + 10), size=10) for index, image_index in enumerate(uncertainty_index): image = images[image_index] # for more than 5 iterations, visualize the gain only on the first 5 if i < 5: sub = f.add_subplot(5, 5, index + 1 + (5 * i)) sub.imshow(image, cmap=plt.cm.gray_r, interpolation='none') sub.set_title("predict: %i\ntrue: %i" % ( lp_model.transduction_[image_index], y[image_index]), size=10) sub.axis('off') # labeling 5 points, remote from labeled set delete_index, = np.where(unlabeled_indices == image_index) delete_indices = np.concatenate((delete_indices, delete_index)) unlabeled_indices = np.delete(unlabeled_indices, delete_indices) n_labeled_points += len(uncertainty_index) f.suptitle("Active learning with Label Propagation.\nRows show 5 most " "uncertain labels to learn with the next model.", y=1.15) plt.subplots_adjust(left=0.2, bottom=0.03, right=0.9, top=0.9, wspace=0.2, hspace=0.85) plt.show()
bsd-3-clause
[ 624, 199, 2486, 763, 199, 4314, 2165, 6861, 7576, 4702, 9328, 199, 2486, 763, 199, 199, 872, 2106, 31216, 376, 4702, 9328, 32414, 370, 12537, 4926, 8938, 7576, 199, 4941, 1768, 17012, 14, 199, 199, 6004, 1343, 701, 6093, 282, 1768, 17012, 1402, 543, 1454, 1616, 23677, 4501, 12, 199, 12726, 781, 3504, 314, 2746, 24187, 4750, 30043, 4501, 370, 1768, 14, 16840, 12, 781, 3560, 199, 1045, 4114, 23677, 4501, 334, 5043, 1616, 435, 959, 892, 7869, 680, 2136, 11982, 642, 2112, 199, 13672, 5431, 370, 1172, 282, 1402, 28161, 543, 4233, 23677, 7251, 14, 3390, 1265, 883, 199, 31687, 642, 370, 1768, 1655, 2419, 4233, 701, 13729, 658, 988, 63, 13570, 2313, 10354, 316, 199, 6878, 2419, 4233, 883, 506, 2997, 370, 664, 282, 12249, 367, 314, 8112, 402, 21346, 402, 199, 3749, 4702, 9328, 32414, 14, 199, 199, 33, 5137, 911, 7468, 21207, 314, 2746, 959, 4750, 30043, 7576, 367, 1924, 8494, 199, 1618, 6093, 14, 5723, 1443, 503, 1443, 440, 1395, 27572, 4364, 12, 1325, 781, 911, 3560, 314, 2163, 199, 1238, 543, 3932, 2549, 3628, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6642, 26, 445, 817, 644, 21943, 455, 665, 67, 817, 32, 2027, 393, 455, 14, 1308, 30, 199, 3, 844, 26, 6289, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 492, 5020, 199, 199, 504, 6357, 492, 13148, 199, 504, 6357, 14, 19290, 63, 4792, 17311, 492, 1768, 63, 13535, 199, 504, 6357, 14, 6759, 492, 12505, 63, 3070, 12, 26314, 63, 3642, 199, 199, 7022, 275, 13148, 14, 912, 63, 7022, 342, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 4108, 275, 980, 14, 5605, 8, 552, 8, 7022, 14, 576, 430, 199, 12686, 14, 11777, 8, 4108, 9, 199, 199, 56, 275, 7576, 14, 576, 59, 4108, 1491, 14137, 2677, 199, 89, 275, 7576, 14, 1375, 59, 4108, 1491, 14137, 2677, 199, 4782, 275, 7576, 14, 4782, 59, 4108, 1491, 14137, 2677, 199, 199, 78, 63, 2923, 63, 3356, 275, 822, 8, 89, 9, 199, 78, 63, 21242, 63, 3438, 275, 1616, 199, 988, 63, 13570, 275, 959, 199, 199, 324, 21242, 63, 4108, 275, 980, 14, 5605, 8, 78, 63, 2923, 63, 3356, 2788, 78, 63, 21242, 63, 3438, 2938, 199, 70, 275, 4488, 14, 8941, 342, 199, 199, 509, 284, 315, 1425, 8, 988, 63, 13570, 304, 272, 340, 822, 8, 324, 21242, 63, 4108, 9, 508, 378, 26, 267, 870, 480, 1944, 625, 21242, 2974, 3602, 370, 1768, 2685, 267, 2059, 272, 612, 63, 2834, 275, 980, 14, 1574, 8, 89, 9, 272, 612, 63, 2834, 59, 324, 21242, 63, 4108, 61, 275, 446, 17, 339, 13204, 63, 1238, 275, 1768, 63, 13535, 14, 4314, 51, 657, 5384, 8, 7325, 29, 16, 14, 821, 12, 1390, 63, 1661, 29, 21, 9, 272, 13204, 63, 1238, 14, 3269, 8, 56, 12, 612, 63, 2834, 9, 339, 14746, 63, 3512, 275, 13204, 63, 1238, 14, 1515, 5199, 9925, 324, 21242, 63, 4108, 61, 272, 2549, 63, 3512, 275, 612, 59, 324, 21242, 63, 4108, 61, 339, 6904, 275, 26314, 63, 3642, 8, 2052, 63, 3512, 12, 14746, 63, 3512, 12, 2079, 3628, 29, 10343, 63, 1238, 14, 2888, 4602, 339, 870, 480, 8666, 450, 73, 450, 83, 2, 450, 334, 73, 12, 10045, 627, 2668, 2237, 272, 870, 480, 4314, 428, 657, 5384, 1402, 26, 450, 68, 23677, 1253, 450, 68, 625, 21242, 4366, 68, 3141, 2924, 881, 450, 334, 78, 63, 21242, 63, 3438, 12, 302, 63, 2923, 63, 3356, 446, 302, 63, 21242, 63, 3438, 12, 1467, 302, 63, 2923, 63, 3356, 430, 339, 870, 8, 14368, 63, 3070, 8, 2052, 63, 3512, 12, 14746, 63, 3512, 430, 339, 870, 480, 8930, 12444, 3634, 531, 272, 870, 8, 4400, 9, 339, 327, 4526, 314, 15992, 293, 1038, 397, 402, 1752, 16584, 1768, 10208, 272, 8869, 63, 484, 293, 1038, 397, 275, 5020, 14, 5613, 14, 10435, 8, 267, 13204, 63, 1238, 14, 1302, 63, 5613, 3754, 52, 9, 339, 327, 3504, 1536, 370, 959, 10964, 7251, 626, 314, 12429, 365, 4750, 30043, 3595, 272, 30043, 369, 63, 1080, 275, 980, 14, 20188, 8, 5991, 63, 484, 293, 1038, 397, 2788, 21123, 17, 61, 272, 30043, 369, 63, 1080, 275, 30043, 369, 63, 1080, 59, 267, 980, 14, 262, 17, 68, 8, 31794, 877, 369, 63, 1080, 12, 625, 21242, 63, 4108, 1874, 1491, 21, 61, 339, 327, 4215, 4426, 402, 4918, 626, 781, 664, 3628, 367, 272, 3145, 63, 4108, 275, 980, 14, 1144, 4157, 339, 327, 367, 1655, 2419, 959, 10615, 12, 13104, 794, 314, 15334, 1454, 641, 314, 1642, 959, 272, 340, 284, 665, 959, 26, 267, 289, 14, 505, 13417, 1717, 12, 334, 17, 446, 334, 73, 435, 413, 9, 627, 1275, 12363, 395, 2049, 298, 1238, 450, 68, 60, 78, 60, 78, 3269, 543, 60, 78, 5, 68, 3628, 2, 450, 2049, 3666, 73, 435, 413, 395, 284, 627, 959, 435, 1616, 395, 1568, 29, 709, 9, 272, 367, 1478, 12, 1834, 63, 1080, 315, 3874, 8, 31794, 877, 369, 63, 1080, 304, 267, 1834, 275, 5935, 59, 1569, 63, 1080, 61, 398, 327, 367, 1655, 2419, 959, 10615, 12, 13104, 794, 314, 15334, 1454, 641, 314, 1642, 959, 267, 340, 284, 665, 959, 26, 288, 1007, 275, 289, 14, 525, 63, 13334, 8, 21, 12, 959, 12, 1478, 435, 413, 435, 334, 21, 627, 284, 430, 288, 1007, 14, 20413, 8, 1569, 12, 14920, 29, 6003, 14, 4400, 14, 12150, 63, 82, 12, 14046, 534, 3592, 358, 288, 1007, 14, 409, 63, 1213, 480, 6892, 26, 450, 73, 60, 343, 431, 26, 450, 73, 2, 450, 334, 355, 13204, 63, 1238, 14, 1515, 5199, 9925, 1569, 63, 1080, 467, 612, 59, 1569, 63, 1080, 2522, 1568, 29, 709, 9, 288, 1007, 14, 3127, 360, 1997, 358, 398, 327, 1768, 316, 959, 4501, 12, 3982, 687, 23677, 663, 267, 3145, 63, 1080, 12, 275, 980, 14, 4509, 8, 324, 21242, 63, 4108, 508, 1834, 63, 1080, 9, 267, 3145, 63, 4108, 275, 980, 14, 13433, 1332, 1807, 63, 4108, 12, 3145, 63 ]
[ 199, 2486, 763, 199, 4314, 2165, 6861, 7576, 4702, 9328, 199, 2486, 763, 199, 199, 872, 2106, 31216, 376, 4702, 9328, 32414, 370, 12537, 4926, 8938, 7576, 199, 4941, 1768, 17012, 14, 199, 199, 6004, 1343, 701, 6093, 282, 1768, 17012, 1402, 543, 1454, 1616, 23677, 4501, 12, 199, 12726, 781, 3504, 314, 2746, 24187, 4750, 30043, 4501, 370, 1768, 14, 16840, 12, 781, 3560, 199, 1045, 4114, 23677, 4501, 334, 5043, 1616, 435, 959, 892, 7869, 680, 2136, 11982, 642, 2112, 199, 13672, 5431, 370, 1172, 282, 1402, 28161, 543, 4233, 23677, 7251, 14, 3390, 1265, 883, 199, 31687, 642, 370, 1768, 1655, 2419, 4233, 701, 13729, 658, 988, 63, 13570, 2313, 10354, 316, 199, 6878, 2419, 4233, 883, 506, 2997, 370, 664, 282, 12249, 367, 314, 8112, 402, 21346, 402, 199, 3749, 4702, 9328, 32414, 14, 199, 199, 33, 5137, 911, 7468, 21207, 314, 2746, 959, 4750, 30043, 7576, 367, 1924, 8494, 199, 1618, 6093, 14, 5723, 1443, 503, 1443, 440, 1395, 27572, 4364, 12, 1325, 781, 911, 3560, 314, 2163, 199, 1238, 543, 3932, 2549, 3628, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6642, 26, 445, 817, 644, 21943, 455, 665, 67, 817, 32, 2027, 393, 455, 14, 1308, 30, 199, 3, 844, 26, 6289, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 492, 5020, 199, 199, 504, 6357, 492, 13148, 199, 504, 6357, 14, 19290, 63, 4792, 17311, 492, 1768, 63, 13535, 199, 504, 6357, 14, 6759, 492, 12505, 63, 3070, 12, 26314, 63, 3642, 199, 199, 7022, 275, 13148, 14, 912, 63, 7022, 342, 199, 12686, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 199, 4108, 275, 980, 14, 5605, 8, 552, 8, 7022, 14, 576, 430, 199, 12686, 14, 11777, 8, 4108, 9, 199, 199, 56, 275, 7576, 14, 576, 59, 4108, 1491, 14137, 2677, 199, 89, 275, 7576, 14, 1375, 59, 4108, 1491, 14137, 2677, 199, 4782, 275, 7576, 14, 4782, 59, 4108, 1491, 14137, 2677, 199, 199, 78, 63, 2923, 63, 3356, 275, 822, 8, 89, 9, 199, 78, 63, 21242, 63, 3438, 275, 1616, 199, 988, 63, 13570, 275, 959, 199, 199, 324, 21242, 63, 4108, 275, 980, 14, 5605, 8, 78, 63, 2923, 63, 3356, 2788, 78, 63, 21242, 63, 3438, 2938, 199, 70, 275, 4488, 14, 8941, 342, 199, 199, 509, 284, 315, 1425, 8, 988, 63, 13570, 304, 272, 340, 822, 8, 324, 21242, 63, 4108, 9, 508, 378, 26, 267, 870, 480, 1944, 625, 21242, 2974, 3602, 370, 1768, 2685, 267, 2059, 272, 612, 63, 2834, 275, 980, 14, 1574, 8, 89, 9, 272, 612, 63, 2834, 59, 324, 21242, 63, 4108, 61, 275, 446, 17, 339, 13204, 63, 1238, 275, 1768, 63, 13535, 14, 4314, 51, 657, 5384, 8, 7325, 29, 16, 14, 821, 12, 1390, 63, 1661, 29, 21, 9, 272, 13204, 63, 1238, 14, 3269, 8, 56, 12, 612, 63, 2834, 9, 339, 14746, 63, 3512, 275, 13204, 63, 1238, 14, 1515, 5199, 9925, 324, 21242, 63, 4108, 61, 272, 2549, 63, 3512, 275, 612, 59, 324, 21242, 63, 4108, 61, 339, 6904, 275, 26314, 63, 3642, 8, 2052, 63, 3512, 12, 14746, 63, 3512, 12, 2079, 3628, 29, 10343, 63, 1238, 14, 2888, 4602, 339, 870, 480, 8666, 450, 73, 450, 83, 2, 450, 334, 73, 12, 10045, 627, 2668, 2237, 272, 870, 480, 4314, 428, 657, 5384, 1402, 26, 450, 68, 23677, 1253, 450, 68, 625, 21242, 4366, 68, 3141, 2924, 881, 450, 334, 78, 63, 21242, 63, 3438, 12, 302, 63, 2923, 63, 3356, 446, 302, 63, 21242, 63, 3438, 12, 1467, 302, 63, 2923, 63, 3356, 430, 339, 870, 8, 14368, 63, 3070, 8, 2052, 63, 3512, 12, 14746, 63, 3512, 430, 339, 870, 480, 8930, 12444, 3634, 531, 272, 870, 8, 4400, 9, 339, 327, 4526, 314, 15992, 293, 1038, 397, 402, 1752, 16584, 1768, 10208, 272, 8869, 63, 484, 293, 1038, 397, 275, 5020, 14, 5613, 14, 10435, 8, 267, 13204, 63, 1238, 14, 1302, 63, 5613, 3754, 52, 9, 339, 327, 3504, 1536, 370, 959, 10964, 7251, 626, 314, 12429, 365, 4750, 30043, 3595, 272, 30043, 369, 63, 1080, 275, 980, 14, 20188, 8, 5991, 63, 484, 293, 1038, 397, 2788, 21123, 17, 61, 272, 30043, 369, 63, 1080, 275, 30043, 369, 63, 1080, 59, 267, 980, 14, 262, 17, 68, 8, 31794, 877, 369, 63, 1080, 12, 625, 21242, 63, 4108, 1874, 1491, 21, 61, 339, 327, 4215, 4426, 402, 4918, 626, 781, 664, 3628, 367, 272, 3145, 63, 4108, 275, 980, 14, 1144, 4157, 339, 327, 367, 1655, 2419, 959, 10615, 12, 13104, 794, 314, 15334, 1454, 641, 314, 1642, 959, 272, 340, 284, 665, 959, 26, 267, 289, 14, 505, 13417, 1717, 12, 334, 17, 446, 334, 73, 435, 413, 9, 627, 1275, 12363, 395, 2049, 298, 1238, 450, 68, 60, 78, 60, 78, 3269, 543, 60, 78, 5, 68, 3628, 2, 450, 2049, 3666, 73, 435, 413, 395, 284, 627, 959, 435, 1616, 395, 1568, 29, 709, 9, 272, 367, 1478, 12, 1834, 63, 1080, 315, 3874, 8, 31794, 877, 369, 63, 1080, 304, 267, 1834, 275, 5935, 59, 1569, 63, 1080, 61, 398, 327, 367, 1655, 2419, 959, 10615, 12, 13104, 794, 314, 15334, 1454, 641, 314, 1642, 959, 267, 340, 284, 665, 959, 26, 288, 1007, 275, 289, 14, 525, 63, 13334, 8, 21, 12, 959, 12, 1478, 435, 413, 435, 334, 21, 627, 284, 430, 288, 1007, 14, 20413, 8, 1569, 12, 14920, 29, 6003, 14, 4400, 14, 12150, 63, 82, 12, 14046, 534, 3592, 358, 288, 1007, 14, 409, 63, 1213, 480, 6892, 26, 450, 73, 60, 343, 431, 26, 450, 73, 2, 450, 334, 355, 13204, 63, 1238, 14, 1515, 5199, 9925, 1569, 63, 1080, 467, 612, 59, 1569, 63, 1080, 2522, 1568, 29, 709, 9, 288, 1007, 14, 3127, 360, 1997, 358, 398, 327, 1768, 316, 959, 4501, 12, 3982, 687, 23677, 663, 267, 3145, 63, 1080, 12, 275, 980, 14, 4509, 8, 324, 21242, 63, 4108, 508, 1834, 63, 1080, 9, 267, 3145, 63, 4108, 275, 980, 14, 13433, 1332, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Petr-Kovalev/nupic-win32
py/regions/ImageSensorExplorers/RepetitiveSweep.py
2
6558
# ---------------------------------------------------------------------- # 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/ # ---------------------------------------------------------------------- import random from nupic.regions.ImageSensorExplorers.BaseExplorer import BaseExplorer from nupic.math.cross import cross class RepetitiveSweep(BaseExplorer): """ This explorer performs random sweeps that are of specified length, and are repeated identically a specified number of times. """ def __init__(self, sweepLength=4, numRepetitions=1, sweepOffMode=False, maxOffset=None, minVelocity=1, maxVelocity=3, seed=42, *args, **kwargs): """ @param sweepLen: number of presentations per sweep sequence. @param numRepetitions: number of times to present each inward sweep. """ BaseExplorer.__init__(self, *args, **kwargs) # Parameter checking if type(sweepLength) is not int or sweepLength < 1: raise RuntimeError("'sweepLength' should be a positive integer") if type(numRepetitions) is not int or numRepetitions < 1: raise RuntimeError("'numRepetitions' should be a positive integer") # Parameters self._sweepLength = sweepLength self._numRepetitions = numRepetitions self._minVelocity = minVelocity self._maxVelocity = maxVelocity self._sweepOffMode = sweepOffMode self._maxOffset = maxOffset # Internal state self._seqIndex = 0 self._repIndex = 0 self._state = None self._repMemory = None # Prepare PRNG self._rng = random.Random() self._rng.seed(seed) def _initSequence(self): bbox = self.getOriginalImage().getbbox() patternWidth = bbox[2] - bbox[0] patternHeight = bbox[3] - bbox[1] slopX = (self.enabledWidth - patternWidth) // 2 slopY = (self.enabledHeight - patternHeight) // 2 if self._sweepOffMode: slopX = abs(slopX) slopY = abs(slopY) if self._maxOffset is not None: slopX = min(abs(slopX), self._maxOffset) slopY = min(abs(slopY), self._maxOffset) posnX = self._rng.choice(xrange(-slopX, slopX + 1)) posnY = self._rng.choice(xrange(-slopY, slopY + 1)) velocityX = self._rng.choice([-1, +1]) \ * self._rng.choice(xrange(self._minVelocity, self._maxVelocity + 1)) velocityY = self._rng.choice([-1, +1]) \ * self._rng.choice(xrange(self._minVelocity, self._maxVelocity + 1)) # Choose a category random catIndex = self._rng.choice(range(self.numImages)) # Make sure we don't allow stationary (no velocity) if self._maxVelocity > 0: if velocityX == 0 and velocityY == 0: velocityX, velocityY = self._rng.choice([(-1, -1), (-1, 1), (1, -1), (1, 1)]) self.position['reset'] = True self.position['image'] = catIndex self.position['offset'] = [posnX, posnY] # Store internal state self._state = dict(posnX=posnX, posnY=posnY, velocityX=velocityX, velocityY=velocityY, catIndex=catIndex) def _updateSequence(self): posnX = self._state['posnX'] posnY = self._state['posnY'] posnX += self._state['velocityX'] posnY += self._state['velocityY'] self._state['posnX'] = posnX self._state['posnY'] = posnY self.position['offset'] = [posnX, posnY] self.position['reset'] = False self.position['image'] = self._state['catIndex'] def _computeNextPosn(self): """ Helper method that deterministically computes the next inward sweep position. """ # Start new pattern to be repeated if not self._repIndex: if self._seqIndex == 0: self._repMemory = [] self._initSequence() else: self._updateSequence() self._repMemory += [self.position.copy()] else: self.position = self._repMemory[self._seqIndex] # Debugging output to console if False: print "[%04d] %d: (%d, %d) %s" % ( \ self._seqIndex, self.position['image'], self.position['offset'][0], self.position['offset'][1], "RESET" if self.position['reset'] else "") # Update count self._seqIndex += 1 if self._seqIndex == self._sweepLength: self._seqIndex = 0 self._repIndex = (self._repIndex + 1) % self._numRepetitions def seek(self, iteration=None, position=None): """ Seek to the specified position or iteration. iteration -- Target iteration number (or None). position -- Target position (or None). ImageSensor checks validity of inputs, checks that one (but not both) of position and iteration are None, and checks that if position is not None, at least one of its values is not None. Updates value of position. """ self.first() def first(self): """ Set up the position. BaseExplorer picks image 0, offset (0,0), etc., but explorers that wish to set a different first position should extend this method. Such explorers may wish to call BaseExplorer.first(center=False), which initializes the position tuple but does not call centerImage() (which could cause unnecessary filtering to occur). """ BaseExplorer.first(self, center=False) self._computeNextPosn() def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ self._computeNextPosn()
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, 646, 2196, 199, 504, 26084, 14, 11963, 14, 3491, 10160, 4527, 320, 21105, 14, 1563, 4527, 22732, 492, 3523, 4527, 22732, 199, 504, 26084, 14, 3442, 14, 7925, 492, 8059, 421, 199, 533, 21973, 280, 857, 10941, 7840, 8, 1563, 4527, 22732, 304, 819, 408, 523, 961, 15868, 3859, 18628, 2196, 5584, 1024, 1190, 626, 787, 402, 2013, 2582, 12, 436, 523, 787, 10877, 6120, 17269, 282, 2013, 1329, 402, 5431, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 5584, 7840, 4625, 29, 20, 12, 2151, 1967, 12945, 7752, 29, 17, 12, 2151, 5584, 7840, 5195, 1385, 29, 797, 12, 2151, 1390, 6397, 29, 403, 12, 2151, 1748, 23213, 29, 17, 12, 2151, 1390, 23213, 29, 19, 12, 2151, 6347, 29, 2260, 12, 2151, 627, 589, 12, 1011, 958, 304, 272, 408, 272, 768, 635, 5584, 7840, 3166, 26, 1329, 402, 3451, 1298, 1126, 5584, 7840, 3414, 14, 272, 768, 635, 1967, 12945, 7752, 26, 1329, 402, 5431, 370, 3451, 1924, 315, 3079, 5584, 7840, 14, 272, 408, 272, 3523, 4527, 22732, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 327, 12009, 7907, 272, 340, 730, 8, 31701, 4625, 9, 365, 440, 1109, 503, 5584, 7840, 4625, 665, 413, 26, 489, 746, 6064, 15587, 31701, 4625, 7, 1077, 506, 282, 7317, 3000, 531, 272, 340, 730, 8, 1507, 12945, 7752, 9, 365, 440, 1109, 503, 1967, 12945, 7752, 665, 413, 26, 489, 746, 6064, 15587, 1507, 12945, 7752, 7, 1077, 506, 282, 7317, 3000, 531, 272, 327, 3897, 272, 291, 423, 31701, 4625, 275, 5584, 7840, 4625, 272, 291, 423, 1507, 12945, 7752, 275, 1967, 12945, 7752, 272, 291, 423, 827, 23213, 275, 1748, 23213, 272, 291, 423, 988, 23213, 275, 1390, 23213, 272, 291, 423, 31701, 5195, 1385, 275, 5584, 7840, 5195, 1385, 272, 291, 423, 988, 6397, 275, 1390, 6397, 272, 327, 12624, 1174, 272, 291, 423, 3610, 2681, 275, 378, 272, 291, 423, 1155, 2681, 275, 378, 272, 291, 423, 929, 275, 488, 272, 291, 423, 1155, 8628, 275, 488, 272, 327, 17008, 12218, 12259, 272, 291, 423, 12686, 275, 2196, 14, 3883, 342, 272, 291, 423, 12686, 14, 5176, 8, 5176, 9, 8330, 347, 485, 826, 5826, 8, 277, 304, 339, 12494, 275, 291, 14, 362, 17286, 3491, 1252, 362, 11246, 342, 272, 3851, 6216, 275, 12494, 59, 18, 61, 446, 12494, 59, 16, 61, 272, 3851, 8436, 275, 12494, 59, 19, 61, 446, 12494, 59, 17, 61, 339, 308, 18630, 56, 275, 334, 277, 14, 3827, 6216, 221, 446, 3851, 6216, 9, 5001, 499, 272, 308, 18630, 57, 275, 334, 277, 14, 3827, 8436, 446, 3851, 8436, 9, 5001, 499, 272, 340, 291, 423, 31701, 5195, 1385, 26, 489, 308, 18630, 56, 275, 2853, 8, 83, 18630, 56, 9, 489, 308, 18630, 57, 275, 2853, 8, 83, 18630, 57, 9, 272, 340, 291, 423, 988, 6397, 365, 440, 488, 26, 489, 308, 18630, 56, 275, 1748, 8, 2101, 8, 83, 18630, 56, 395, 291, 423, 988, 6397, 9, 489, 308, 18630, 57, 275, 1748, 8, 2101, 8, 83, 18630, 57, 395, 291, 423, 988, 6397, 9, 272, 2086, 78, 56, 275, 291, 423, 12686, 14, 5095, 8, 21120, 2801, 83, 18630, 56, 12, 308, 18630, 56, 435, 413, 430, 272, 2086, 78, 57, 275, 291, 423, 12686, 14, 5095, 8, 21120, 2801, 83, 18630, 57, 12, 308, 18630, 57, 435, 413, 430, 272, 20508, 56, 275, 291, 423, 12686, 14, 5095, 11468, 17, 12, 435, 17, 566, 971, 1598, 627, 291, 423, 12686, 14, 5095, 8, 21120, 8, 277, 423, 827, 23213, 12, 291, 423, 988, 23213, 435, 413, 430, 272, 20508, 57, 275, 291, 423, 12686, 14, 5095, 11468, 17, 12, 435, 17, 566, 971, 1598, 627, 291, 423, 12686, 14, 5095, 8, 21120, 8, 277, 423, 827, 23213, 12, 291, 423, 988, 23213, 435, 413, 430, 272, 327, 29826, 282, 4637, 2196, 272, 6230, 2681, 275, 291, 423, 12686, 14, 5095, 8, 1842, 8, 277, 14, 1507, 18882, 430, 339, 327, 4155, 3238, 781, 2793, 1133, 2040, 16518, 695, 334, 889, 20508, 9, 272, 340, 291, 423, 988, 23213, 690, 378, 26, 489, 340, 20508, 56, 508, 378, 436, 20508, 57, 508, 378, 26, 267, 20508, 56, 12, 20508, 57, 275, 291, 423, 12686, 14, 5095, 779, 2801, 17, 12, 446, 17, 395, 5868, 17, 12, 413, 395, 334, 17, 12, 446, 17, 395, 334, 17, 12, 413, 3948, 339, 291, 14, 3124, 459, 3958, 418, 275, 715, 272, 291, 14, 3124, 459, 1569, 418, 275, 6230, 2681, 272, 291, 14, 3124, 459, 2743, 418, 275, 359, 1712, 78, 56, 12, 2086, 78, 57, 61, 272, 327, 13874, 5007, 1174, 272, 291, 423, 929, 275, 1211, 8, 1712, 78, 56, 29, 1712, 78, 56, 12, 2086, 78, 57, 29, 1712, 78, 57, 12, 2432, 20508, 56, 29, 16350, 56, 12, 20508, 57, 29, 16350, 57, 12, 2432, 6230, 2681, 29, 3385, 2681, 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, 646, 2196, 199, 504, 26084, 14, 11963, 14, 3491, 10160, 4527, 320, 21105, 14, 1563, 4527, 22732, 492, 3523, 4527, 22732, 199, 504, 26084, 14, 3442, 14, 7925, 492, 8059, 421, 199, 533, 21973, 280, 857, 10941, 7840, 8, 1563, 4527, 22732, 304, 819, 408, 523, 961, 15868, 3859, 18628, 2196, 5584, 1024, 1190, 626, 787, 402, 2013, 2582, 12, 436, 523, 787, 10877, 6120, 17269, 282, 2013, 1329, 402, 5431, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 5584, 7840, 4625, 29, 20, 12, 2151, 1967, 12945, 7752, 29, 17, 12, 2151, 5584, 7840, 5195, 1385, 29, 797, 12, 2151, 1390, 6397, 29, 403, 12, 2151, 1748, 23213, 29, 17, 12, 2151, 1390, 23213, 29, 19, 12, 2151, 6347, 29, 2260, 12, 2151, 627, 589, 12, 1011, 958, 304, 272, 408, 272, 768, 635, 5584, 7840, 3166, 26, 1329, 402, 3451, 1298, 1126, 5584, 7840, 3414, 14, 272, 768, 635, 1967, 12945, 7752, 26, 1329, 402, 5431, 370, 3451, 1924, 315, 3079, 5584, 7840, 14, 272, 408, 272, 3523, 4527, 22732, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 327, 12009, 7907, 272, 340, 730, 8, 31701, 4625, 9, 365, 440, 1109, 503, 5584, 7840, 4625, 665, 413, 26, 489, 746, 6064, 15587, 31701, 4625, 7, 1077, 506, 282, 7317, 3000, 531, 272, 340, 730, 8, 1507, 12945, 7752, 9, 365, 440, 1109, 503, 1967, 12945, 7752, 665, 413, 26, 489, 746, 6064, 15587, 1507, 12945, 7752, 7, 1077, 506, 282, 7317, 3000, 531, 272, 327, 3897, 272, 291, 423, 31701, 4625, 275, 5584, 7840, 4625, 272, 291, 423, 1507, 12945, 7752, 275, 1967, 12945, 7752, 272, 291, 423, 827, 23213, 275, 1748, 23213, 272, 291, 423, 988, 23213, 275, 1390, 23213, 272, 291, 423, 31701, 5195, 1385, 275, 5584, 7840, 5195, 1385, 272, 291, 423, 988, 6397, 275, 1390, 6397, 272, 327, 12624, 1174, 272, 291, 423, 3610, 2681, 275, 378, 272, 291, 423, 1155, 2681, 275, 378, 272, 291, 423, 929, 275, 488, 272, 291, 423, 1155, 8628, 275, 488, 272, 327, 17008, 12218, 12259, 272, 291, 423, 12686, 275, 2196, 14, 3883, 342, 272, 291, 423, 12686, 14, 5176, 8, 5176, 9, 8330, 347, 485, 826, 5826, 8, 277, 304, 339, 12494, 275, 291, 14, 362, 17286, 3491, 1252, 362, 11246, 342, 272, 3851, 6216, 275, 12494, 59, 18, 61, 446, 12494, 59, 16, 61, 272, 3851, 8436, 275, 12494, 59, 19, 61, 446, 12494, 59, 17, 61, 339, 308, 18630, 56, 275, 334, 277, 14, 3827, 6216, 221, 446, 3851, 6216, 9, 5001, 499, 272, 308, 18630, 57, 275, 334, 277, 14, 3827, 8436, 446, 3851, 8436, 9, 5001, 499, 272, 340, 291, 423, 31701, 5195, 1385, 26, 489, 308, 18630, 56, 275, 2853, 8, 83, 18630, 56, 9, 489, 308, 18630, 57, 275, 2853, 8, 83, 18630, 57, 9, 272, 340, 291, 423, 988, 6397, 365, 440, 488, 26, 489, 308, 18630, 56, 275, 1748, 8, 2101, 8, 83, 18630, 56, 395, 291, 423, 988, 6397, 9, 489, 308, 18630, 57, 275, 1748, 8, 2101, 8, 83, 18630, 57, 395, 291, 423, 988, 6397, 9, 272, 2086, 78, 56, 275, 291, 423, 12686, 14, 5095, 8, 21120, 2801, 83, 18630, 56, 12, 308, 18630, 56, 435, 413, 430, 272, 2086, 78, 57, 275, 291, 423, 12686, 14, 5095, 8, 21120, 2801, 83, 18630, 57, 12, 308, 18630, 57, 435, 413, 430, 272, 20508, 56, 275, 291, 423, 12686, 14, 5095, 11468, 17, 12, 435, 17, 566, 971, 1598, 627, 291, 423, 12686, 14, 5095, 8, 21120, 8, 277, 423, 827, 23213, 12, 291, 423, 988, 23213, 435, 413, 430, 272, 20508, 57, 275, 291, 423, 12686, 14, 5095, 11468, 17, 12, 435, 17, 566, 971, 1598, 627, 291, 423, 12686, 14, 5095, 8, 21120, 8, 277, 423, 827, 23213, 12, 291, 423, 988, 23213, 435, 413, 430, 272, 327, 29826, 282, 4637, 2196, 272, 6230, 2681, 275, 291, 423, 12686, 14, 5095, 8, 1842, 8, 277, 14, 1507, 18882, 430, 339, 327, 4155, 3238, 781, 2793, 1133, 2040, 16518, 695, 334, 889, 20508, 9, 272, 340, 291, 423, 988, 23213, 690, 378, 26, 489, 340, 20508, 56, 508, 378, 436, 20508, 57, 508, 378, 26, 267, 20508, 56, 12, 20508, 57, 275, 291, 423, 12686, 14, 5095, 779, 2801, 17, 12, 446, 17, 395, 5868, 17, 12, 413, 395, 334, 17, 12, 446, 17, 395, 334, 17, 12, 413, 3948, 339, 291, 14, 3124, 459, 3958, 418, 275, 715, 272, 291, 14, 3124, 459, 1569, 418, 275, 6230, 2681, 272, 291, 14, 3124, 459, 2743, 418, 275, 359, 1712, 78, 56, 12, 2086, 78, 57, 61, 272, 327, 13874, 5007, 1174, 272, 291, 423, 929, 275, 1211, 8, 1712, 78, 56, 29, 1712, 78, 56, 12, 2086, 78, 57, 29, 1712, 78, 57, 12, 2432, 20508, 56, 29, 16350, 56, 12, 20508, 57, 29, 16350, 57, 12, 2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