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
|
|---|---|---|---|---|---|---|---|---|
rickerc/neutron_audit
|
neutron/openstack/common/rpc/impl_kombu.py
|
1
|
32063
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation
#
# 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 functools
import itertools
import socket
import ssl
import sys
import time
import uuid
import eventlet
import greenlet
import kombu
import kombu.connection
import kombu.entity
import kombu.messaging
from oslo.config import cfg
from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _
from neutron.openstack.common import network_utils
from neutron.openstack.common.rpc import amqp as rpc_amqp
from neutron.openstack.common.rpc import common as rpc_common
kombu_opts = [
cfg.StrOpt('kombu_ssl_version',
default='',
help='SSL version to use (valid only if SSL enabled)'),
cfg.StrOpt('kombu_ssl_keyfile',
default='',
help='SSL key file (valid only if SSL enabled)'),
cfg.StrOpt('kombu_ssl_certfile',
default='',
help='SSL cert file (valid only if SSL enabled)'),
cfg.StrOpt('kombu_ssl_ca_certs',
default='',
help=('SSL certification authority file '
'(valid only if SSL enabled)')),
cfg.StrOpt('rabbit_host',
default='localhost',
help='The RabbitMQ broker address where a single node is used'),
cfg.IntOpt('rabbit_port',
default=5672,
help='The RabbitMQ broker port where a single node is used'),
cfg.ListOpt('rabbit_hosts',
default=['$rabbit_host:$rabbit_port'],
help='RabbitMQ HA cluster host:port pairs'),
cfg.BoolOpt('rabbit_use_ssl',
default=False,
help='connect over SSL for RabbitMQ'),
cfg.StrOpt('rabbit_userid',
default='guest',
help='the RabbitMQ userid'),
cfg.StrOpt('rabbit_password',
default='guest',
help='the RabbitMQ password',
secret=True),
cfg.StrOpt('rabbit_virtual_host',
default='/',
help='the RabbitMQ virtual host'),
cfg.IntOpt('rabbit_retry_interval',
default=1,
help='how frequently to retry connecting with RabbitMQ'),
cfg.IntOpt('rabbit_retry_backoff',
default=2,
help='how long to backoff for between retries when connecting '
'to RabbitMQ'),
cfg.IntOpt('rabbit_max_retries',
default=0,
help='maximum retries with trying to connect to RabbitMQ '
'(the default of 0 implies an infinite retry count)'),
cfg.BoolOpt('rabbit_ha_queues',
default=False,
help='use H/A queues in RabbitMQ (x-ha-policy: all).'
'You need to wipe RabbitMQ database when '
'changing this option.'),
]
cfg.CONF.register_opts(kombu_opts)
LOG = rpc_common.LOG
def _get_queue_arguments(conf):
"""Construct the arguments for declaring a queue.
If the rabbit_ha_queues option is set, we declare a mirrored queue
as described here:
http://www.rabbitmq.com/ha.html
Setting x-ha-policy to all means that the queue will be mirrored
to all nodes in the cluster.
"""
return {'x-ha-policy': 'all'} if conf.rabbit_ha_queues else {}
class ConsumerBase(object):
"""Consumer base class."""
def __init__(self, channel, callback, tag, **kwargs):
"""Declare a queue on an amqp channel.
'channel' is the amqp channel to use
'callback' is the callback to call when messages are received
'tag' is a unique ID for the consumer on the channel
queue name, exchange name, and other kombu options are
passed in here as a dictionary.
"""
self.callback = callback
self.tag = str(tag)
self.kwargs = kwargs
self.queue = None
self.reconnect(channel)
def reconnect(self, channel):
"""Re-declare the queue after a rabbit reconnect."""
self.channel = channel
self.kwargs['channel'] = channel
self.queue = kombu.entity.Queue(**self.kwargs)
self.queue.declare()
def consume(self, *args, **kwargs):
"""Actually declare the consumer on the amqp channel. This will
start the flow of messages from the queue. Using the
Connection.iterconsume() iterator will process the messages,
calling the appropriate callback.
If a callback is specified in kwargs, use that. Otherwise,
use the callback passed during __init__()
If kwargs['nowait'] is True, then this call will block until
a message is read.
Messages will automatically be acked if the callback doesn't
raise an exception
"""
options = {'consumer_tag': self.tag}
options['nowait'] = kwargs.get('nowait', False)
callback = kwargs.get('callback', self.callback)
if not callback:
raise ValueError("No callback defined")
def _callback(raw_message):
message = self.channel.message_to_python(raw_message)
try:
msg = rpc_common.deserialize_msg(message.payload)
callback(msg)
except Exception:
LOG.exception(_("Failed to process message... skipping it."))
finally:
message.ack()
self.queue.consume(*args, callback=_callback, **options)
def cancel(self):
"""Cancel the consuming from the queue, if it has started."""
try:
self.queue.cancel(self.tag)
except KeyError as e:
# NOTE(comstud): Kludge to get around a amqplib bug
if str(e) != "u'%s'" % self.tag:
raise
self.queue = None
class DirectConsumer(ConsumerBase):
"""Queue/consumer class for 'direct'."""
def __init__(self, conf, channel, msg_id, callback, tag, **kwargs):
"""Init a 'direct' queue.
'channel' is the amqp channel to use
'msg_id' is the msg_id to listen on
'callback' is the callback to call when messages are received
'tag' is a unique ID for the consumer on the channel
Other kombu options may be passed
"""
# Default options
options = {'durable': False,
'queue_arguments': _get_queue_arguments(conf),
'auto_delete': True,
'exclusive': False}
options.update(kwargs)
exchange = kombu.entity.Exchange(name=msg_id,
type='direct',
durable=options['durable'],
auto_delete=options['auto_delete'])
super(DirectConsumer, self).__init__(channel,
callback,
tag,
name=msg_id,
exchange=exchange,
routing_key=msg_id,
**options)
class TopicConsumer(ConsumerBase):
"""Consumer class for 'topic'."""
def __init__(self, conf, channel, topic, callback, tag, name=None,
exchange_name=None, **kwargs):
"""Init a 'topic' queue.
:param channel: the amqp channel to use
:param topic: the topic to listen on
:paramtype topic: str
:param callback: the callback to call when messages are received
:param tag: a unique ID for the consumer on the channel
:param name: optional queue name, defaults to topic
:paramtype name: str
Other kombu options may be passed as keyword arguments
"""
# Default options
options = {'durable': conf.amqp_durable_queues,
'queue_arguments': _get_queue_arguments(conf),
'auto_delete': conf.amqp_auto_delete,
'exclusive': False}
options.update(kwargs)
exchange_name = exchange_name or rpc_amqp.get_control_exchange(conf)
exchange = kombu.entity.Exchange(name=exchange_name,
type='topic',
durable=options['durable'],
auto_delete=options['auto_delete'])
super(TopicConsumer, self).__init__(channel,
callback,
tag,
name=name or topic,
exchange=exchange,
routing_key=topic,
**options)
class FanoutConsumer(ConsumerBase):
"""Consumer class for 'fanout'."""
def __init__(self, conf, channel, topic, callback, tag, **kwargs):
"""Init a 'fanout' queue.
'channel' is the amqp channel to use
'topic' is the topic to listen on
'callback' is the callback to call when messages are received
'tag' is a unique ID for the consumer on the channel
Other kombu options may be passed
"""
unique = uuid.uuid4().hex
exchange_name = '%s_fanout' % topic
queue_name = '%s_fanout_%s' % (topic, unique)
# Default options
options = {'durable': False,
'queue_arguments': _get_queue_arguments(conf),
'auto_delete': True,
'exclusive': False}
options.update(kwargs)
exchange = kombu.entity.Exchange(name=exchange_name, type='fanout',
durable=options['durable'],
auto_delete=options['auto_delete'])
super(FanoutConsumer, self).__init__(channel, callback, tag,
name=queue_name,
exchange=exchange,
routing_key=topic,
**options)
class Publisher(object):
"""Base Publisher class."""
def __init__(self, channel, exchange_name, routing_key, **kwargs):
"""Init the Publisher class with the exchange_name, routing_key,
and other options
"""
self.exchange_name = exchange_name
self.routing_key = routing_key
self.kwargs = kwargs
self.reconnect(channel)
def reconnect(self, channel):
"""Re-establish the Producer after a rabbit reconnection."""
self.exchange = kombu.entity.Exchange(name=self.exchange_name,
**self.kwargs)
self.producer = kombu.messaging.Producer(exchange=self.exchange,
channel=channel,
routing_key=self.routing_key)
def send(self, msg, timeout=None):
"""Send a message."""
if timeout:
#
# AMQP TTL is in milliseconds when set in the header.
#
self.producer.publish(msg, headers={'ttl': (timeout * 1000)})
else:
self.producer.publish(msg)
class DirectPublisher(Publisher):
"""Publisher class for 'direct'."""
def __init__(self, conf, channel, msg_id, **kwargs):
"""init a 'direct' publisher.
Kombu options may be passed as keyword args to override defaults
"""
options = {'durable': False,
'auto_delete': True,
'exclusive': False}
options.update(kwargs)
super(DirectPublisher, self).__init__(channel, msg_id, msg_id,
type='direct', **options)
class TopicPublisher(Publisher):
"""Publisher class for 'topic'."""
def __init__(self, conf, channel, topic, **kwargs):
"""init a 'topic' publisher.
Kombu options may be passed as keyword args to override defaults
"""
options = {'durable': conf.amqp_durable_queues,
'auto_delete': conf.amqp_auto_delete,
'exclusive': False}
options.update(kwargs)
exchange_name = rpc_amqp.get_control_exchange(conf)
super(TopicPublisher, self).__init__(channel,
exchange_name,
topic,
type='topic',
**options)
class FanoutPublisher(Publisher):
"""Publisher class for 'fanout'."""
def __init__(self, conf, channel, topic, **kwargs):
"""init a 'fanout' publisher.
Kombu options may be passed as keyword args to override defaults
"""
options = {'durable': False,
'auto_delete': True,
'exclusive': False}
options.update(kwargs)
super(FanoutPublisher, self).__init__(channel, '%s_fanout' % topic,
None, type='fanout', **options)
class NotifyPublisher(TopicPublisher):
"""Publisher class for 'notify'."""
def __init__(self, conf, channel, topic, **kwargs):
self.durable = kwargs.pop('durable', conf.amqp_durable_queues)
self.queue_arguments = _get_queue_arguments(conf)
super(NotifyPublisher, self).__init__(conf, channel, topic, **kwargs)
def reconnect(self, channel):
super(NotifyPublisher, self).reconnect(channel)
# NOTE(jerdfelt): Normally the consumer would create the queue, but
# we do this to ensure that messages don't get dropped if the
# consumer is started after we do
queue = kombu.entity.Queue(channel=channel,
exchange=self.exchange,
durable=self.durable,
name=self.routing_key,
routing_key=self.routing_key,
queue_arguments=self.queue_arguments)
queue.declare()
class Connection(object):
"""Connection object."""
pool = None
def __init__(self, conf, server_params=None):
self.consumers = []
self.consumer_thread = None
self.proxy_callbacks = []
self.conf = conf
self.max_retries = self.conf.rabbit_max_retries
# Try forever?
if self.max_retries <= 0:
self.max_retries = None
self.interval_start = self.conf.rabbit_retry_interval
self.interval_stepping = self.conf.rabbit_retry_backoff
# max retry-interval = 30 seconds
self.interval_max = 30
self.memory_transport = False
if server_params is None:
server_params = {}
# Keys to translate from server_params to kombu params
server_params_to_kombu_params = {'username': 'userid'}
ssl_params = self._fetch_ssl_params()
params_list = []
for adr in self.conf.rabbit_hosts:
hostname, port = network_utils.parse_host_port(
adr, default_port=self.conf.rabbit_port)
params = {
'hostname': hostname,
'port': port,
'userid': self.conf.rabbit_userid,
'password': self.conf.rabbit_password,
'virtual_host': self.conf.rabbit_virtual_host,
}
for sp_key, value in server_params.iteritems():
p_key = server_params_to_kombu_params.get(sp_key, sp_key)
params[p_key] = value
if self.conf.fake_rabbit:
params['transport'] = 'memory'
if self.conf.rabbit_use_ssl:
params['ssl'] = ssl_params
params_list.append(params)
self.params_list = params_list
brokers_count = len(self.params_list)
self.next_broker_indices = itertools.cycle(range(brokers_count))
self.memory_transport = self.conf.fake_rabbit
self.connection = None
self.reconnect()
def _fetch_ssl_params(self):
"""Handles fetching what ssl params should be used for the connection
(if any).
"""
ssl_params = dict()
# http://docs.python.org/library/ssl.html - ssl.wrap_socket
if self.conf.kombu_ssl_version:
ssl_params['ssl_version'] = self.conf.kombu_ssl_version
if self.conf.kombu_ssl_keyfile:
ssl_params['keyfile'] = self.conf.kombu_ssl_keyfile
if self.conf.kombu_ssl_certfile:
ssl_params['certfile'] = self.conf.kombu_ssl_certfile
if self.conf.kombu_ssl_ca_certs:
ssl_params['ca_certs'] = self.conf.kombu_ssl_ca_certs
# We might want to allow variations in the
# future with this?
ssl_params['cert_reqs'] = ssl.CERT_REQUIRED
if not ssl_params:
# Just have the default behavior
return True
else:
# Return the extended behavior
return ssl_params
def _connect(self, params):
"""Connect to rabbit. Re-establish any queues that may have
been declared before if we are reconnecting. Exceptions should
be handled by the caller.
"""
if self.connection:
LOG.info(_("Reconnecting to AMQP server on "
"%(hostname)s:%(port)d") % params)
try:
self.connection.release()
except self.connection_errors:
pass
# Setting this in case the next statement fails, though
# it shouldn't be doing any network operations, yet.
self.connection = None
self.connection = kombu.connection.BrokerConnection(**params)
self.connection_errors = self.connection.connection_errors
if self.memory_transport:
# Kludge to speed up tests.
self.connection.transport.polling_interval = 0.0
self.consumer_num = itertools.count(1)
self.connection.connect()
self.channel = self.connection.channel()
# work around 'memory' transport bug in 1.1.3
if self.memory_transport:
self.channel._new_queue('ae.undeliver')
for consumer in self.consumers:
consumer.reconnect(self.channel)
LOG.info(_('Connected to AMQP server on %(hostname)s:%(port)d') %
params)
def reconnect(self):
"""Handles reconnecting and re-establishing queues.
Will retry up to self.max_retries number of times.
self.max_retries = 0 means to retry forever.
Sleep between tries, starting at self.interval_start
seconds, backing off self.interval_stepping number of seconds
each attempt.
"""
attempt = 0
while True:
params = self.params_list[next(self.next_broker_indices)]
attempt += 1
try:
self._connect(params)
return
except (IOError, self.connection_errors) as e:
pass
except Exception as e:
# NOTE(comstud): Unfortunately it's possible for amqplib
# to return an error not covered by its transport
# connection_errors in the case of a timeout waiting for
# a protocol response. (See paste link in LP888621)
# So, we check all exceptions for 'timeout' in them
# and try to reconnect in this case.
if 'timeout' not in str(e):
raise
log_info = {}
log_info['err_str'] = str(e)
log_info['max_retries'] = self.max_retries
log_info.update(params)
if self.max_retries and attempt == self.max_retries:
LOG.error(_('Unable to connect to AMQP server on '
'%(hostname)s:%(port)d after %(max_retries)d '
'tries: %(err_str)s') % log_info)
# NOTE(comstud): Copied from original code. There's
# really no better recourse because if this was a queue we
# need to consume on, we have no way to consume anymore.
sys.exit(1)
if attempt == 1:
sleep_time = self.interval_start or 1
elif attempt > 1:
sleep_time += self.interval_stepping
if self.interval_max:
sleep_time = min(sleep_time, self.interval_max)
log_info['sleep_time'] = sleep_time
LOG.error(_('AMQP server on %(hostname)s:%(port)d is '
'unreachable: %(err_str)s. Trying again in '
'%(sleep_time)d seconds.') % log_info)
time.sleep(sleep_time)
def ensure(self, error_callback, method, *args, **kwargs):
while True:
try:
return method(*args, **kwargs)
except (self.connection_errors, socket.timeout, IOError) as e:
if error_callback:
error_callback(e)
except Exception as e:
# NOTE(comstud): Unfortunately it's possible for amqplib
# to return an error not covered by its transport
# connection_errors in the case of a timeout waiting for
# a protocol response. (See paste link in LP888621)
# So, we check all exceptions for 'timeout' in them
# and try to reconnect in this case.
if 'timeout' not in str(e):
raise
if error_callback:
error_callback(e)
self.reconnect()
def get_channel(self):
"""Convenience call for bin/clear_rabbit_queues."""
return self.channel
def close(self):
"""Close/release this connection."""
self.cancel_consumer_thread()
self.wait_on_proxy_callbacks()
self.connection.release()
self.connection = None
def reset(self):
"""Reset a connection so it can be used again."""
self.cancel_consumer_thread()
self.wait_on_proxy_callbacks()
self.channel.close()
self.channel = self.connection.channel()
# work around 'memory' transport bug in 1.1.3
if self.memory_transport:
self.channel._new_queue('ae.undeliver')
self.consumers = []
def declare_consumer(self, consumer_cls, topic, callback):
"""Create a Consumer using the class that was passed in and
add it to our list of consumers
"""
def _connect_error(exc):
log_info = {'topic': topic, 'err_str': str(exc)}
LOG.error(_("Failed to declare consumer for topic '%(topic)s': "
"%(err_str)s") % log_info)
def _declare_consumer():
consumer = consumer_cls(self.conf, self.channel, topic, callback,
self.consumer_num.next())
self.consumers.append(consumer)
return consumer
return self.ensure(_connect_error, _declare_consumer)
def iterconsume(self, limit=None, timeout=None):
"""Return an iterator that will consume from all queues/consumers."""
info = {'do_consume': True}
def _error_callback(exc):
if isinstance(exc, socket.timeout):
LOG.debug(_('Timed out waiting for RPC response: %s') %
str(exc))
raise rpc_common.Timeout()
else:
LOG.exception(_('Failed to consume message from queue: %s') %
str(exc))
info['do_consume'] = True
def _consume():
if info['do_consume']:
queues_head = self.consumers[:-1]
queues_tail = self.consumers[-1]
for queue in queues_head:
queue.consume(nowait=True)
queues_tail.consume(nowait=False)
info['do_consume'] = False
return self.connection.drain_events(timeout=timeout)
for iteration in itertools.count(0):
if limit and iteration >= limit:
raise StopIteration
yield self.ensure(_error_callback, _consume)
def cancel_consumer_thread(self):
"""Cancel a consumer thread."""
if self.consumer_thread is not None:
self.consumer_thread.kill()
try:
self.consumer_thread.wait()
except greenlet.GreenletExit:
pass
self.consumer_thread = None
def wait_on_proxy_callbacks(self):
"""Wait for all proxy callback threads to exit."""
for proxy_cb in self.proxy_callbacks:
proxy_cb.wait()
def publisher_send(self, cls, topic, msg, timeout=None, **kwargs):
"""Send to a publisher based on the publisher class."""
def _error_callback(exc):
log_info = {'topic': topic, 'err_str': str(exc)}
LOG.exception(_("Failed to publish message to topic "
"'%(topic)s': %(err_str)s") % log_info)
def _publish():
publisher = cls(self.conf, self.channel, topic, **kwargs)
publisher.send(msg, timeout)
self.ensure(_error_callback, _publish)
def declare_direct_consumer(self, topic, callback):
"""Create a 'direct' queue.
In nova's use, this is generally a msg_id queue used for
responses for call/multicall
"""
self.declare_consumer(DirectConsumer, topic, callback)
def declare_topic_consumer(self, topic, callback=None, queue_name=None,
exchange_name=None):
"""Create a 'topic' consumer."""
self.declare_consumer(functools.partial(TopicConsumer,
name=queue_name,
exchange_name=exchange_name,
),
topic, callback)
def declare_fanout_consumer(self, topic, callback):
"""Create a 'fanout' consumer."""
self.declare_consumer(FanoutConsumer, topic, callback)
def direct_send(self, msg_id, msg):
"""Send a 'direct' message."""
self.publisher_send(DirectPublisher, msg_id, msg)
def topic_send(self, topic, msg, timeout=None):
"""Send a 'topic' message."""
self.publisher_send(TopicPublisher, topic, msg, timeout)
def fanout_send(self, topic, msg):
"""Send a 'fanout' message."""
self.publisher_send(FanoutPublisher, topic, msg)
def notify_send(self, topic, msg, **kwargs):
"""Send a notify message on a topic."""
self.publisher_send(NotifyPublisher, topic, msg, None, **kwargs)
def consume(self, limit=None):
"""Consume from all queues/consumers."""
it = self.iterconsume(limit=limit)
while True:
try:
it.next()
except StopIteration:
return
def consume_in_thread(self):
"""Consumer from all queues/consumers in a greenthread."""
@excutils.forever_retry_uncaught_exceptions
def _consumer_thread():
try:
self.consume()
except greenlet.GreenletExit:
return
if self.consumer_thread is None:
self.consumer_thread = eventlet.spawn(_consumer_thread)
return self.consumer_thread
def create_consumer(self, topic, proxy, fanout=False):
"""Create a consumer that calls a method in a proxy object."""
proxy_cb = rpc_amqp.ProxyCallback(
self.conf, proxy,
rpc_amqp.get_connection_pool(self.conf, Connection))
self.proxy_callbacks.append(proxy_cb)
if fanout:
self.declare_fanout_consumer(topic, proxy_cb)
else:
self.declare_topic_consumer(topic, proxy_cb)
def create_worker(self, topic, proxy, pool_name):
"""Create a worker that calls a method in a proxy object."""
proxy_cb = rpc_amqp.ProxyCallback(
self.conf, proxy,
rpc_amqp.get_connection_pool(self.conf, Connection))
self.proxy_callbacks.append(proxy_cb)
self.declare_topic_consumer(topic, proxy_cb, pool_name)
def join_consumer_pool(self, callback, pool_name, topic,
exchange_name=None):
"""Register as a member of a group of consumers for a given topic from
the specified exchange.
Exactly one member of a given pool will receive each message.
A message will be delivered to multiple pools, if more than
one is created.
"""
callback_wrapper = rpc_amqp.CallbackWrapper(
conf=self.conf,
callback=callback,
connection_pool=rpc_amqp.get_connection_pool(self.conf,
Connection),
)
self.proxy_callbacks.append(callback_wrapper)
self.declare_topic_consumer(
queue_name=pool_name,
topic=topic,
exchange_name=exchange_name,
callback=callback_wrapper,
)
def create_connection(conf, new=True):
"""Create a connection."""
return rpc_amqp.create_connection(
conf, new,
rpc_amqp.get_connection_pool(conf, Connection))
def multicall(conf, context, topic, msg, timeout=None):
"""Make a call that returns multiple times."""
return rpc_amqp.multicall(
conf, context, topic, msg, timeout,
rpc_amqp.get_connection_pool(conf, Connection))
def call(conf, context, topic, msg, timeout=None):
"""Sends a message on a topic and wait for a response."""
return rpc_amqp.call(
conf, context, topic, msg, timeout,
rpc_amqp.get_connection_pool(conf, Connection))
def cast(conf, context, topic, msg):
"""Sends a message on a topic without waiting for a response."""
return rpc_amqp.cast(
conf, context, topic, msg,
rpc_amqp.get_connection_pool(conf, Connection))
def fanout_cast(conf, context, topic, msg):
"""Sends a message on a fanout exchange without waiting for a response."""
return rpc_amqp.fanout_cast(
conf, context, topic, msg,
rpc_amqp.get_connection_pool(conf, Connection))
def cast_to_server(conf, context, server_params, topic, msg):
"""Sends a message on a topic to a specific server."""
return rpc_amqp.cast_to_server(
conf, context, server_params, topic, msg,
rpc_amqp.get_connection_pool(conf, Connection))
def fanout_cast_to_server(conf, context, server_params, topic, msg):
"""Sends a message on a fanout exchange to a specific server."""
return rpc_amqp.fanout_cast_to_server(
conf, context, server_params, topic, msg,
rpc_amqp.get_connection_pool(conf, Connection))
def notify(conf, context, topic, msg, envelope):
"""Sends a notification event on a topic."""
return rpc_amqp.notify(
conf, context, topic, msg,
rpc_amqp.get_connection_pool(conf, Connection),
envelope)
def cleanup():
return rpc_amqp.cleanup(Connection.pool)
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
259,
1898,
7760,
14260,
2752,
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,
646,
9143,
199,
646,
7975,
199,
646,
2838,
199,
646,
6149,
199,
646,
984,
199,
646,
900,
199,
646,
5377,
199,
199,
646,
21819,
199,
646,
12431,
2723,
199,
646,
1022,
676,
464,
199,
646,
1022,
676,
464,
14,
2105,
199,
646,
1022,
676,
464,
14,
4502,
199,
646,
1022,
676,
464,
14,
27782,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
8224,
14,
8512,
14,
2330,
492,
32763,
199,
504,
8224,
14,
8512,
14,
2330,
14,
5152,
1208,
492,
485,
199,
504,
8224,
14,
8512,
14,
2330,
492,
2784,
63,
1208,
199,
504,
8224,
14,
8512,
14,
2330,
14,
4354,
492,
8140,
15202,
465,
8985,
63,
455,
15202,
199,
504,
8224,
14,
8512,
14,
2330,
14,
4354,
492,
2863,
465,
8985,
63,
2330,
199,
199,
75,
676,
464,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
1023,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
1015,
370,
675,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
21856,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
790,
570,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
28340,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
6250,
570,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
696,
63,
8356,
297,
2049,
849,
4581,
2049,
1720,
7782,
5413,
3361,
3793,
18330,
570,
283,
2151,
8189,
1078,
1454,
340,
7799,
5223,
9,
3855,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
1102,
297,
2049,
849,
534,
5967,
297,
2049,
1720,
534,
1918,
820,
371,
2075,
14449,
15416,
2287,
2382,
282,
2849,
1031,
365,
1202,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
719,
297,
2049,
849,
29,
1367,
2819,
12,
2049,
1720,
534,
1918,
820,
371,
2075,
14449,
15416,
1844,
2382,
282,
2849,
1031,
365,
1202,
659,
272,
4810,
14,
1296,
9985,
360,
14411,
2075,
63,
5146,
297,
355,
849,
2968,
4,
14411,
2075,
63,
1102,
26,
4,
14411,
2075,
63,
719,
995,
355,
1720,
534,
50,
371,
2075,
14449,
16100,
4350,
1591,
26,
719,
6342,
659,
272,
4810,
14,
10349,
9985,
360,
14411,
2075,
63,
1180,
63,
4266,
297,
355,
849,
29,
797,
12,
355,
1720,
534,
2242,
1806,
7799,
367,
820,
371,
2075,
14449,
659,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
19737,
297,
2049,
849,
534,
10409,
297,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
25580,
659,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
2060,
297,
2049,
849,
534,
10409,
297,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
2505,
297,
2049,
7565,
29,
549,
395,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
2065,
63,
1102,
297,
2049,
849,
25412,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
5791,
1591,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
7154,
63,
4284,
297,
2049,
849,
29,
17,
12,
2049,
1720,
534,
1917,
28914,
590,
370,
7269,
18170,
543,
820,
371,
2075,
14449,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
7154,
63,
21061,
297,
2049,
849,
29,
18,
12,
2049,
1720,
534,
1917,
1846,
370,
22735,
367,
3382,
10086,
1380,
18170,
283,
490,
283,
475,
820,
371,
2075,
14449,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
988,
63,
10937,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
11555,
10086,
543,
9936,
370,
4907,
370,
820,
371,
2075,
14449,
283,
490,
8189,
1589,
849,
402,
378,
22660,
376,
15258,
7269,
2338,
11218,
272,
4810,
14,
10349,
9985,
360,
14411,
2075,
63,
2411,
63,
18849,
297,
355,
849,
29,
797,
12,
355,
1720,
534,
1180,
869,
15,
33,
21366,
315,
820,
371,
2075,
14449,
334,
88,
13,
2411,
13,
3185,
26,
1006,
28823,
2151,
283,
5556,
1929,
370,
336,
3662,
820,
371,
2075,
14449,
3050,
1380,
283,
2151,
283,
29131,
642,
945,
8038,
199,
199,
61,
199,
199,
4128,
14,
3103,
14,
2683,
63,
3291,
8,
75,
676,
464,
63,
3291,
9,
199,
199,
4947,
275,
8985,
63,
2330,
14,
4947,
421,
199,
318,
485,
362,
63,
1825,
63,
4958,
8,
2190,
304,
272,
408,
11493,
314,
2368,
367,
13507,
316,
282,
4126,
14,
339,
982,
314,
29773,
2075,
63,
2411,
63,
18849,
945,
365,
663,
12,
781,
20771,
282,
333,
27533,
4126,
272,
465,
11736,
2348,
26,
2541,
1455,
921,
1544,
14,
14411,
29490,
14,
957,
15,
2411,
14,
1360,
339,
13510,
671,
13,
2411,
13,
3185,
370,
1006,
4910,
626,
314,
4126,
911,
506,
333,
27533,
272,
370,
1006,
3380,
315,
314,
4350,
14,
272,
408,
272,
372,
791,
88,
13,
2411,
13,
3185,
356,
283,
452,
936,
340,
3743,
14,
14411,
2075,
63,
2411,
63,
18849,
587,
1052,
421,
199,
533,
1448,
5391,
1563,
8,
785,
304,
272,
408,
18186,
1300,
1021,
1041,
339,
347,
636,
826,
721,
277,
12,
3623,
12,
3233,
12,
1947,
12,
1011,
958,
304,
267,
408,
8584,
29200,
282,
4126,
641,
376,
8140,
15202,
3623,
14,
398,
283,
2775,
7,
365,
314,
8140,
15202,
3623,
370,
675,
267,
283,
3058,
7,
365,
314,
3233,
370,
1240,
1380,
3788,
787,
3086,
267,
283,
1450,
7,
365
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
259,
1898,
7760,
14260,
2752,
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,
646,
9143,
199,
646,
7975,
199,
646,
2838,
199,
646,
6149,
199,
646,
984,
199,
646,
900,
199,
646,
5377,
199,
199,
646,
21819,
199,
646,
12431,
2723,
199,
646,
1022,
676,
464,
199,
646,
1022,
676,
464,
14,
2105,
199,
646,
1022,
676,
464,
14,
4502,
199,
646,
1022,
676,
464,
14,
27782,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
8224,
14,
8512,
14,
2330,
492,
32763,
199,
504,
8224,
14,
8512,
14,
2330,
14,
5152,
1208,
492,
485,
199,
504,
8224,
14,
8512,
14,
2330,
492,
2784,
63,
1208,
199,
504,
8224,
14,
8512,
14,
2330,
14,
4354,
492,
8140,
15202,
465,
8985,
63,
455,
15202,
199,
504,
8224,
14,
8512,
14,
2330,
14,
4354,
492,
2863,
465,
8985,
63,
2330,
199,
199,
75,
676,
464,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
1023,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
1015,
370,
675,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
21856,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
790,
570,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
28340,
297,
2049,
849,
4581,
2049,
1720,
534,
5413,
6250,
570,
334,
1078,
1454,
340,
7799,
5223,
11218,
272,
4810,
14,
19340,
360,
75,
676,
464,
63,
4266,
63,
696,
63,
8356,
297,
2049,
849,
4581,
2049,
1720,
7782,
5413,
3361,
3793,
18330,
570,
283,
2151,
8189,
1078,
1454,
340,
7799,
5223,
9,
3855,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
1102,
297,
2049,
849,
534,
5967,
297,
2049,
1720,
534,
1918,
820,
371,
2075,
14449,
15416,
2287,
2382,
282,
2849,
1031,
365,
1202,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
719,
297,
2049,
849,
29,
1367,
2819,
12,
2049,
1720,
534,
1918,
820,
371,
2075,
14449,
15416,
1844,
2382,
282,
2849,
1031,
365,
1202,
659,
272,
4810,
14,
1296,
9985,
360,
14411,
2075,
63,
5146,
297,
355,
849,
2968,
4,
14411,
2075,
63,
1102,
26,
4,
14411,
2075,
63,
719,
995,
355,
1720,
534,
50,
371,
2075,
14449,
16100,
4350,
1591,
26,
719,
6342,
659,
272,
4810,
14,
10349,
9985,
360,
14411,
2075,
63,
1180,
63,
4266,
297,
355,
849,
29,
797,
12,
355,
1720,
534,
2242,
1806,
7799,
367,
820,
371,
2075,
14449,
659,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
19737,
297,
2049,
849,
534,
10409,
297,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
25580,
659,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
2060,
297,
2049,
849,
534,
10409,
297,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
2505,
297,
2049,
7565,
29,
549,
395,
272,
4810,
14,
19340,
360,
14411,
2075,
63,
2065,
63,
1102,
297,
2049,
849,
25412,
2049,
1720,
534,
1589,
820,
371,
2075,
14449,
5791,
1591,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
7154,
63,
4284,
297,
2049,
849,
29,
17,
12,
2049,
1720,
534,
1917,
28914,
590,
370,
7269,
18170,
543,
820,
371,
2075,
14449,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
7154,
63,
21061,
297,
2049,
849,
29,
18,
12,
2049,
1720,
534,
1917,
1846,
370,
22735,
367,
3382,
10086,
1380,
18170,
283,
490,
283,
475,
820,
371,
2075,
14449,
659,
272,
4810,
14,
3241,
9985,
360,
14411,
2075,
63,
988,
63,
10937,
297,
2049,
849,
29,
16,
12,
2049,
1720,
534,
11555,
10086,
543,
9936,
370,
4907,
370,
820,
371,
2075,
14449,
283,
490,
8189,
1589,
849,
402,
378,
22660,
376,
15258,
7269,
2338,
11218,
272,
4810,
14,
10349,
9985,
360,
14411,
2075,
63,
2411,
63,
18849,
297,
355,
849,
29,
797,
12,
355,
1720,
534,
1180,
869,
15,
33,
21366,
315,
820,
371,
2075,
14449,
334,
88,
13,
2411,
13,
3185,
26,
1006,
28823,
2151,
283,
5556,
1929,
370,
336,
3662,
820,
371,
2075,
14449,
3050,
1380,
283,
2151,
283,
29131,
642,
945,
8038,
199,
199,
61,
199,
199,
4128,
14,
3103,
14,
2683,
63,
3291,
8,
75,
676,
464,
63,
3291,
9,
199,
199,
4947,
275,
8985,
63,
2330,
14,
4947,
421,
199,
318,
485,
362,
63,
1825,
63,
4958,
8,
2190,
304,
272,
408,
11493,
314,
2368,
367,
13507,
316,
282,
4126,
14,
339,
982,
314,
29773,
2075,
63,
2411,
63,
18849,
945,
365,
663,
12,
781,
20771,
282,
333,
27533,
4126,
272,
465,
11736,
2348,
26,
2541,
1455,
921,
1544,
14,
14411,
29490,
14,
957,
15,
2411,
14,
1360,
339,
13510,
671,
13,
2411,
13,
3185,
370,
1006,
4910,
626,
314,
4126,
911,
506,
333,
27533,
272,
370,
1006,
3380,
315,
314,
4350,
14,
272,
408,
272,
372,
791,
88,
13,
2411,
13,
3185,
356,
283,
452,
936,
340,
3743,
14,
14411,
2075,
63,
2411,
63,
18849,
587,
1052,
421,
199,
533,
1448,
5391,
1563,
8,
785,
304,
272,
408,
18186,
1300,
1021,
1041,
339,
347,
636,
826,
721,
277,
12,
3623,
12,
3233,
12,
1947,
12,
1011,
958,
304,
267,
408,
8584,
29200,
282,
4126,
641,
376,
8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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
] |
abhishek070193/mapreduce
|
hadoop-2.6.0-src/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/job_history_summary.py
|
323
|
3444
|
#!/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 re
import sys
pat = re.compile('(?P<name>[^=]+)="(?P<value>[^"]*)" *')
counterPat = re.compile('(?P<name>[^:]+):(?P<value>[^,]*),?')
def parse(tail):
result = {}
for n,v in re.findall(pat, tail):
result[n] = v
return result
mapStartTime = {}
mapEndTime = {}
reduceStartTime = {}
reduceShuffleTime = {}
reduceSortTime = {}
reduceEndTime = {}
reduceBytes = {}
for line in sys.stdin:
words = line.split(" ",1)
event = words[0]
attrs = parse(words[1])
if event == 'MapAttempt':
if attrs.has_key("START_TIME"):
mapStartTime[attrs["TASKID"]] = int(attrs["START_TIME"])/1000
elif attrs.has_key("FINISH_TIME"):
mapEndTime[attrs["TASKID"]] = int(attrs["FINISH_TIME"])/1000
elif event == 'ReduceAttempt':
if attrs.has_key("START_TIME"):
reduceStartTime[attrs["TASKID"]] = int(attrs["START_TIME"]) / 1000
elif attrs.has_key("FINISH_TIME"):
reduceShuffleTime[attrs["TASKID"]] = int(attrs["SHUFFLE_FINISHED"])/1000
reduceSortTime[attrs["TASKID"]] = int(attrs["SORT_FINISHED"])/1000
reduceEndTime[attrs["TASKID"]] = int(attrs["FINISH_TIME"])/1000
elif event == 'Task':
if attrs["TASK_TYPE"] == "REDUCE" and attrs.has_key("COUNTERS"):
for n,v in re.findall(counterPat, attrs["COUNTERS"]):
if n == "File Systems.HDFS bytes written":
reduceBytes[attrs["TASKID"]] = int(v)
runningMaps = {}
shufflingReduces = {}
sortingReduces = {}
runningReduces = {}
startTime = min(reduce(min, mapStartTime.values()),
reduce(min, reduceStartTime.values()))
endTime = max(reduce(max, mapEndTime.values()),
reduce(max, reduceEndTime.values()))
reduces = reduceBytes.keys()
reduces.sort()
print "Name reduce-output-bytes shuffle-finish reduce-finish"
for r in reduces:
print r, reduceBytes[r], reduceShuffleTime[r] - startTime,
print reduceEndTime[r] - startTime
print
for t in range(startTime, endTime):
runningMaps[t] = 0
shufflingReduces[t] = 0
sortingReduces[t] = 0
runningReduces[t] = 0
for map in mapStartTime.keys():
for t in range(mapStartTime[map], mapEndTime[map]):
runningMaps[t] += 1
for reduce in reduceStartTime.keys():
for t in range(reduceStartTime[reduce], reduceShuffleTime[reduce]):
shufflingReduces[t] += 1
for t in range(reduceShuffleTime[reduce], reduceSortTime[reduce]):
sortingReduces[t] += 1
for t in range(reduceSortTime[reduce], reduceEndTime[reduce]):
runningReduces[t] += 1
print "time maps shuffle merge reduce"
for t in range(startTime, endTime):
print t - startTime, runningMaps[t], shufflingReduces[t], sortingReduces[t],
print runningReduces[t]
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
295,
199,
646,
984,
199,
199,
10853,
275,
295,
14,
2014,
28353,
48,
28,
354,
13489,
29,
11896,
628,
2229,
48,
28,
585,
13489,
937,
25952,
627,
358,
199,
5337,
48,
292,
275,
295,
14,
2014,
28353,
48,
28,
354,
13489,
26,
2807,
304,
2229,
48,
28,
585,
13489,
12,
3672,
395,
18478,
199,
199,
318,
2198,
8,
1521,
304,
523,
754,
275,
1052,
523,
367,
302,
12,
86,
315,
295,
14,
6452,
8,
10853,
12,
9483,
304,
272,
754,
59,
78,
61,
275,
373,
523,
372,
754,
199,
199,
1130,
25087,
275,
1052,
199,
1130,
3005,
1366,
275,
1052,
199,
5270,
25087,
275,
1052,
199,
5270,
19779,
1366,
275,
1052,
199,
5270,
14376,
1366,
275,
1052,
199,
5270,
3005,
1366,
275,
1052,
199,
5270,
5571,
275,
1052,
199,
199,
509,
1004,
315,
984,
14,
6626,
26,
523,
5932,
275,
1004,
14,
1294,
480,
3872,
17,
9,
523,
1566,
275,
5932,
59,
16,
61,
523,
3290,
275,
2198,
8,
3148,
59,
17,
566,
523,
340,
1566,
508,
283,
2956,
23272,
356,
272,
340,
3290,
14,
1989,
63,
498,
480,
7363,
63,
4961,
2349,
489,
2341,
25087,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
7363,
63,
4961,
3135,
15,
5279,
272,
916,
3290,
14,
1989,
63,
498,
480,
17383,
13898,
63,
4961,
2349,
489,
2341,
3005,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
17383,
13898,
63,
4961,
3135,
15,
5279,
523,
916,
1566,
508,
283,
21822,
23272,
356,
272,
340,
3290,
14,
1989,
63,
498,
480,
7363,
63,
4961,
2349,
489,
7114,
25087,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
7363,
63,
4961,
3135,
1182,
5198,
272,
916,
3290,
14,
1989,
63,
498,
480,
17383,
13898,
63,
4961,
2349,
489,
7114,
19779,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
3234,
8158,
906,
63,
17383,
20450,
3135,
15,
5279,
489,
7114,
14376,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
23447,
63,
17383,
20450,
3135,
15,
5279,
489,
7114,
3005,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
17383,
13898,
63,
4961,
3135,
15,
5279,
523,
916,
1566,
508,
283,
4476,
356,
272,
340,
3290,
905,
17179,
63,
2711,
937,
508,
298,
907,
4980,
2089,
2,
436,
3290,
14,
1989,
63,
498,
480,
23049,
51,
2349,
489,
367,
302,
12,
86,
315,
295,
14,
6452,
8,
5337,
48,
292,
12,
3290,
905,
23049,
51,
21473,
267,
340,
302,
508,
298,
1173,
15285,
14,
30165,
51,
2783,
5313,
582,
881,
7114,
5571,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
86,
9,
199,
199,
5720,
24995,
275,
1052,
199,
609,
3043,
2983,
50,
8654,
823,
275,
1052,
199,
29411,
50,
8654,
823,
275,
1052,
199,
5720,
50,
8654,
823,
275,
1052,
199,
28276,
275,
1748,
8,
5270,
8,
827,
12,
2341,
25087,
14,
1459,
4000,
355,
7114,
8,
827,
12,
7114,
25087,
14,
1459,
4059,
199,
500,
1366,
275,
1390,
8,
5270,
8,
988,
12,
2341,
3005,
1366,
14,
1459,
4000,
1598,
7114,
8,
988,
12,
7114,
3005,
1366,
14,
1459,
4059,
199,
199,
19493,
823,
275,
7114,
5571,
14,
1612,
342,
199,
19493,
823,
14,
3191,
342,
199,
199,
1361,
298,
985,
7114,
13,
1199,
13,
2394,
13031,
13,
8192,
7114,
13,
8192,
2,
199,
509,
519,
315,
295,
10569,
26,
523,
870,
519,
12,
7114,
5571,
59,
82,
467,
7114,
19779,
1366,
59,
82,
61,
446,
28517,
12,
523,
870,
7114,
3005,
1366,
59,
82,
61,
446,
28517,
199,
199,
1361,
199,
199,
509,
307,
315,
1425,
8,
28276,
12,
1284,
1366,
304,
523,
3879,
24995,
59,
84,
61,
275,
378,
523,
28126,
2983,
50,
8654,
823,
59,
84,
61,
275,
378,
523,
13351,
50,
8654,
823,
59,
84,
61,
275,
378,
523,
3879,
50,
8654,
823,
59,
84,
61,
275,
378,
199,
199,
509,
2341,
315,
2341,
25087,
14,
1612,
837,
523,
367,
307,
315,
1425,
8,
1130,
25087,
59,
1130,
467,
2341,
3005,
1366,
59,
1130,
4682,
272,
3879,
24995,
59,
84,
61,
847,
413,
199,
509,
7114,
315,
7114,
25087,
14,
1612,
837,
523,
367,
307,
315,
1425,
8,
5270,
25087,
59,
5270,
467,
7114,
19779,
1366,
59,
5270,
4682,
272,
28126,
2983,
50,
8654,
823,
59,
84,
61,
847,
413,
523,
367,
307,
315,
1425,
8,
5270,
19779,
1366,
59,
5270,
467,
7114,
14376,
1366,
59,
5270,
4682,
272,
13351,
50,
8654,
823,
59,
84,
61,
847,
413,
523,
367,
307,
315,
1425,
8,
5270,
14376,
1366,
59,
5270,
467,
7114,
3005,
1366,
59,
5270,
4682,
272,
3879,
50,
8654,
823,
59,
84,
61,
847,
413,
199,
199,
1361,
298,
521,
9033,
13031,
5389,
7114,
2,
199,
509,
307,
315,
1425,
8,
28276,
12,
1284,
1366,
304,
523,
870,
307,
446,
28517,
12,
3879,
24995,
59,
84,
467,
28126,
2983,
50,
8654,
823,
59,
84,
467,
13351,
50,
8654,
823,
59,
84,
467,
16421,
870,
3879,
50,
8654,
823,
59,
84,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
295,
199,
646,
984,
199,
199,
10853,
275,
295,
14,
2014,
28353,
48,
28,
354,
13489,
29,
11896,
628,
2229,
48,
28,
585,
13489,
937,
25952,
627,
358,
199,
5337,
48,
292,
275,
295,
14,
2014,
28353,
48,
28,
354,
13489,
26,
2807,
304,
2229,
48,
28,
585,
13489,
12,
3672,
395,
18478,
199,
199,
318,
2198,
8,
1521,
304,
523,
754,
275,
1052,
523,
367,
302,
12,
86,
315,
295,
14,
6452,
8,
10853,
12,
9483,
304,
272,
754,
59,
78,
61,
275,
373,
523,
372,
754,
199,
199,
1130,
25087,
275,
1052,
199,
1130,
3005,
1366,
275,
1052,
199,
5270,
25087,
275,
1052,
199,
5270,
19779,
1366,
275,
1052,
199,
5270,
14376,
1366,
275,
1052,
199,
5270,
3005,
1366,
275,
1052,
199,
5270,
5571,
275,
1052,
199,
199,
509,
1004,
315,
984,
14,
6626,
26,
523,
5932,
275,
1004,
14,
1294,
480,
3872,
17,
9,
523,
1566,
275,
5932,
59,
16,
61,
523,
3290,
275,
2198,
8,
3148,
59,
17,
566,
523,
340,
1566,
508,
283,
2956,
23272,
356,
272,
340,
3290,
14,
1989,
63,
498,
480,
7363,
63,
4961,
2349,
489,
2341,
25087,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
7363,
63,
4961,
3135,
15,
5279,
272,
916,
3290,
14,
1989,
63,
498,
480,
17383,
13898,
63,
4961,
2349,
489,
2341,
3005,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
17383,
13898,
63,
4961,
3135,
15,
5279,
523,
916,
1566,
508,
283,
21822,
23272,
356,
272,
340,
3290,
14,
1989,
63,
498,
480,
7363,
63,
4961,
2349,
489,
7114,
25087,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
7363,
63,
4961,
3135,
1182,
5198,
272,
916,
3290,
14,
1989,
63,
498,
480,
17383,
13898,
63,
4961,
2349,
489,
7114,
19779,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
3234,
8158,
906,
63,
17383,
20450,
3135,
15,
5279,
489,
7114,
14376,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
23447,
63,
17383,
20450,
3135,
15,
5279,
489,
7114,
3005,
1366,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
3288,
905,
17383,
13898,
63,
4961,
3135,
15,
5279,
523,
916,
1566,
508,
283,
4476,
356,
272,
340,
3290,
905,
17179,
63,
2711,
937,
508,
298,
907,
4980,
2089,
2,
436,
3290,
14,
1989,
63,
498,
480,
23049,
51,
2349,
489,
367,
302,
12,
86,
315,
295,
14,
6452,
8,
5337,
48,
292,
12,
3290,
905,
23049,
51,
21473,
267,
340,
302,
508,
298,
1173,
15285,
14,
30165,
51,
2783,
5313,
582,
881,
7114,
5571,
59,
3288,
905,
17179,
998,
15261,
275,
1109,
8,
86,
9,
199,
199,
5720,
24995,
275,
1052,
199,
609,
3043,
2983,
50,
8654,
823,
275,
1052,
199,
29411,
50,
8654,
823,
275,
1052,
199,
5720,
50,
8654,
823,
275,
1052,
199,
28276,
275,
1748,
8,
5270,
8,
827,
12,
2341,
25087,
14,
1459,
4000,
355,
7114,
8,
827,
12,
7114,
25087,
14,
1459,
4059,
199,
500,
1366,
275,
1390,
8,
5270,
8,
988,
12,
2341,
3005,
1366,
14,
1459,
4000,
1598,
7114,
8,
988,
12,
7114,
3005,
1366,
14,
1459,
4059,
199,
199,
19493,
823,
275,
7114,
5571,
14,
1612,
342,
199,
19493,
823,
14,
3191,
342,
199,
199,
1361,
298,
985,
7114,
13,
1199,
13,
2394,
13031,
13,
8192,
7114,
13,
8192,
2,
199,
509,
519,
315,
295,
10569,
26,
523,
870,
519,
12,
7114,
5571,
59,
82,
467,
7114,
19779,
1366,
59,
82,
61,
446,
28517,
12,
523,
870,
7114,
3005,
1366,
59,
82,
61,
446,
28517,
199,
199,
1361,
199,
199,
509,
307,
315,
1425,
8,
28276,
12,
1284,
1366,
304,
523,
3879,
24995,
59,
84,
61,
275,
378,
523,
28126,
2983,
50,
8654,
823,
59,
84,
61,
275,
378,
523,
13351,
50,
8654,
823,
59,
84,
61,
275,
378,
523,
3879,
50,
8654,
823,
59,
84,
61,
275,
378,
199,
199,
509,
2341,
315,
2341,
25087,
14,
1612,
837,
523,
367,
307,
315,
1425,
8,
1130,
25087,
59,
1130,
467,
2341,
3005,
1366,
59,
1130,
4682,
272,
3879,
24995,
59,
84,
61,
847,
413,
199,
509,
7114,
315,
7114,
25087,
14,
1612,
837,
523,
367,
307,
315,
1425,
8,
5270,
25087,
59,
5270,
467,
7114,
19779,
1366,
59,
5270,
4682,
272,
28126,
2983,
50,
8654,
823,
59,
84,
61,
847,
413,
523,
367,
307,
315,
1425,
8,
5270,
19779,
1366,
59,
5270,
467,
7114,
14376,
1366,
59,
5270,
4682,
272,
13351,
50,
8654,
823,
59,
84,
61,
847,
413,
523,
367,
307,
315,
1425,
8,
5270,
14376,
1366,
59,
5270,
467,
7114,
3005,
1366,
59,
5270,
4682,
272,
3879,
50,
8654,
823,
59,
84,
61,
847,
413,
199,
199,
1361,
298,
521,
9033,
13031,
5389,
7114,
2,
199,
509,
307,
315,
1425,
8,
28276,
12,
1284,
1366,
304,
523,
870,
307,
446,
28517,
12,
3879,
24995,
59,
84,
467,
28126,
2983,
50,
8654,
823,
59,
84,
467,
13351,
50,
8654,
823,
59,
84,
467,
16421,
870,
3879,
50,
8654,
823,
59,
84,
61,
199,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
VirtueSecurity/aws-extender
|
BappModules/docutils/languages/cs.py
|
148
|
1928
|
# $Id: cs.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: Marek Blaha <mb@dat.cz>
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages.
"""
Czech-language mappings for language-dependent features of Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
# fixed: language-dependent
'author': u'Autor',
'authors': u'Auto\u0159i',
'organization': u'Organizace',
'address': u'Adresa',
'contact': u'Kontakt',
'version': u'Verze',
'revision': u'Revize',
'status': u'Stav',
'date': u'Datum',
'copyright': u'Copyright',
'dedication': u'V\u011Bnov\u00E1n\u00ED',
'abstract': u'Abstrakt',
'attention': u'Pozor!',
'caution': u'Opatrn\u011B!',
'danger': u'!NEBEZPE\u010C\u00CD!',
'error': u'Chyba',
'hint': u'Rada',
'important': u'D\u016Fle\u017Eit\u00E9',
'note': u'Pozn\u00E1mka',
'tip': u'Tip',
'warning': u'Varov\u00E1n\u00ED',
'contents': u'Obsah'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
# language-dependent: fixed
u'autor': 'author',
u'auto\u0159i': 'authors',
u'organizace': 'organization',
u'adresa': 'address',
u'kontakt': 'contact',
u'verze': 'version',
u'revize': 'revision',
u'stav': 'status',
u'datum': 'date',
u'copyright': 'copyright',
u'v\u011Bnov\u00E1n\u00ED': 'dedication',
u'abstrakt': 'abstract'}
"""Czech (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
|
mit
|
[
3,
2672,
1304,
26,
7117,
14,
647,
10416,
772,
8315,
13,
1717,
13,
2025,
3388,
26,
1602,
26,
2260,
58,
336,
1873,
20059,
2672,
199,
3,
6529,
26,
603,
1530,
75,
699,
416,
2411,
665,
887,
32,
4616,
14,
16823,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
3,
7053,
2637,
13546,
787,
336,
14628,
14,
221,
21467,
9689,
282,
892,
7761,
12,
8749,
199,
3,
1586,
665,
1014,
921,
27114,
14,
7646,
14,
846,
15,
4757,
15,
21232,
15,
73,
1085,
78,
14,
1360,
10827,
221,
16853,
1584,
1471,
506,
199,
3,
14598,
367,
1924,
2637,
26,
1373,
315,
18382,
15,
13209,
12,
314,
1163,
315,
199,
3,
18382,
15,
11531,
15,
8332,
15,
13209,
14,
199,
199,
624,
199,
35,
806,
335,
13,
3671,
13546,
367,
2637,
13,
7106,
4534,
402,
5454,
1208,
14,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
3512,
275,
469,
489,
327,
6317,
26,
2637,
13,
7106,
489,
283,
2502,
356,
399,
7,
33,
4139,
297,
489,
283,
8149,
356,
399,
7,
3358,
60,
85,
614,
1427,
73,
297,
489,
283,
9071,
356,
399,
7,
11014,
290,
565,
7984,
297,
489,
283,
1562,
356,
399,
7,
2767,
470,
65,
297,
489,
283,
7811,
356,
399,
7,
43,
265,
502,
5973,
297,
489,
283,
1023,
356,
399,
7,
3673,
806,
297,
489,
283,
5792,
356,
399,
7,
497,
433,
806,
297,
489,
283,
1205,
356,
399,
7,
3391,
86,
297,
489,
283,
602,
356,
399,
7,
6456,
297,
489,
283,
7307,
356,
399,
7,
7384,
297,
489,
283,
271,
21171,
356,
399,
7,
54,
60,
85,
13059,
34,
30442,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
297,
489,
283,
6198,
356,
399,
7,
5583,
14183,
5973,
297,
489,
283,
22393,
356,
399,
7,
1575,
90,
269,
12389,
489,
283,
696,
2206,
356,
399,
7,
4619,
292,
11641,
60,
85,
13059,
34,
12389,
489,
283,
68,
12974,
356,
399,
7,
1,
6388,
6773,
58,
1510,
60,
85,
9523,
35,
60,
85,
383,
7695,
12389,
489,
283,
705,
356,
399,
7,
1049,
89,
2470,
297,
489,
283,
6479,
356,
399,
7,
50,
10641,
297,
489,
283,
19559,
356,
399,
7,
36,
60,
85,
10882,
38,
274,
60,
85,
9570,
37,
390,
60,
85,
383,
37,
25,
297,
489,
283,
4610,
356,
399,
7,
1575,
31591,
60,
85,
383,
37,
17,
3880,
65,
297,
489,
283,
8996,
356,
399,
7,
15915,
297,
489,
283,
3764,
356,
399,
7,
5894,
8822,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
297,
489,
283,
4407,
356,
399,
7,
31004,
11326,
936,
199,
624,
7674,
402,
1031,
1021,
536,
370,
1768,
1318,
1041,
199,
199,
30892,
63,
955,
275,
469,
489,
327,
2637,
13,
7106,
26,
6317,
489,
399,
7,
65,
4139,
356,
283,
2502,
297,
489,
399,
7,
2495,
60,
85,
614,
1427,
73,
356,
283,
8149,
297,
489,
399,
7,
19916,
565,
7984,
356,
283,
9071,
297,
489,
399,
7,
350,
470,
65,
356,
283,
1562,
297,
489,
399,
7,
75,
265,
502,
5973,
356,
283,
7811,
297,
489,
399,
9064,
82,
806,
356,
283,
1023,
297,
489,
399,
3984,
433,
806,
356,
283,
5792,
297,
489,
399,
1159,
502,
86,
356,
283,
1205,
297,
489,
399,
5121,
5729,
356,
283,
602,
297,
489,
399,
7,
7307,
356,
283,
7307,
297,
489,
399,
7,
86,
60,
85,
13059,
34,
30442,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
356,
283,
271,
21171,
297,
489,
399,
7,
371,
14183,
5973,
356,
283,
6198,
936,
199,
624,
35,
806,
335,
334,
674,
32738,
9,
370,
11358,
536,
4412,
367,
11314,
24623,
1504,
1041,
199,
199,
2502,
63,
29862,
275,
788,
10805,
1656,
418,
199,
624,
1296,
402,
9432,
3326,
367,
314,
283,
2817,
1384,
7,
11314,
24623,
901,
14,
12480,
379,
315,
199,
1648,
1041,
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
] |
[
2672,
1304,
26,
7117,
14,
647,
10416,
772,
8315,
13,
1717,
13,
2025,
3388,
26,
1602,
26,
2260,
58,
336,
1873,
20059,
2672,
199,
3,
6529,
26,
603,
1530,
75,
699,
416,
2411,
665,
887,
32,
4616,
14,
16823,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
3,
7053,
2637,
13546,
787,
336,
14628,
14,
221,
21467,
9689,
282,
892,
7761,
12,
8749,
199,
3,
1586,
665,
1014,
921,
27114,
14,
7646,
14,
846,
15,
4757,
15,
21232,
15,
73,
1085,
78,
14,
1360,
10827,
221,
16853,
1584,
1471,
506,
199,
3,
14598,
367,
1924,
2637,
26,
1373,
315,
18382,
15,
13209,
12,
314,
1163,
315,
199,
3,
18382,
15,
11531,
15,
8332,
15,
13209,
14,
199,
199,
624,
199,
35,
806,
335,
13,
3671,
13546,
367,
2637,
13,
7106,
4534,
402,
5454,
1208,
14,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
3512,
275,
469,
489,
327,
6317,
26,
2637,
13,
7106,
489,
283,
2502,
356,
399,
7,
33,
4139,
297,
489,
283,
8149,
356,
399,
7,
3358,
60,
85,
614,
1427,
73,
297,
489,
283,
9071,
356,
399,
7,
11014,
290,
565,
7984,
297,
489,
283,
1562,
356,
399,
7,
2767,
470,
65,
297,
489,
283,
7811,
356,
399,
7,
43,
265,
502,
5973,
297,
489,
283,
1023,
356,
399,
7,
3673,
806,
297,
489,
283,
5792,
356,
399,
7,
497,
433,
806,
297,
489,
283,
1205,
356,
399,
7,
3391,
86,
297,
489,
283,
602,
356,
399,
7,
6456,
297,
489,
283,
7307,
356,
399,
7,
7384,
297,
489,
283,
271,
21171,
356,
399,
7,
54,
60,
85,
13059,
34,
30442,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
297,
489,
283,
6198,
356,
399,
7,
5583,
14183,
5973,
297,
489,
283,
22393,
356,
399,
7,
1575,
90,
269,
12389,
489,
283,
696,
2206,
356,
399,
7,
4619,
292,
11641,
60,
85,
13059,
34,
12389,
489,
283,
68,
12974,
356,
399,
7,
1,
6388,
6773,
58,
1510,
60,
85,
9523,
35,
60,
85,
383,
7695,
12389,
489,
283,
705,
356,
399,
7,
1049,
89,
2470,
297,
489,
283,
6479,
356,
399,
7,
50,
10641,
297,
489,
283,
19559,
356,
399,
7,
36,
60,
85,
10882,
38,
274,
60,
85,
9570,
37,
390,
60,
85,
383,
37,
25,
297,
489,
283,
4610,
356,
399,
7,
1575,
31591,
60,
85,
383,
37,
17,
3880,
65,
297,
489,
283,
8996,
356,
399,
7,
15915,
297,
489,
283,
3764,
356,
399,
7,
5894,
8822,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
297,
489,
283,
4407,
356,
399,
7,
31004,
11326,
936,
199,
624,
7674,
402,
1031,
1021,
536,
370,
1768,
1318,
1041,
199,
199,
30892,
63,
955,
275,
469,
489,
327,
2637,
13,
7106,
26,
6317,
489,
399,
7,
65,
4139,
356,
283,
2502,
297,
489,
399,
7,
2495,
60,
85,
614,
1427,
73,
356,
283,
8149,
297,
489,
399,
7,
19916,
565,
7984,
356,
283,
9071,
297,
489,
399,
7,
350,
470,
65,
356,
283,
1562,
297,
489,
399,
7,
75,
265,
502,
5973,
356,
283,
7811,
297,
489,
399,
9064,
82,
806,
356,
283,
1023,
297,
489,
399,
3984,
433,
806,
356,
283,
5792,
297,
489,
399,
1159,
502,
86,
356,
283,
1205,
297,
489,
399,
5121,
5729,
356,
283,
602,
297,
489,
399,
7,
7307,
356,
283,
7307,
297,
489,
399,
7,
86,
60,
85,
13059,
34,
30442,
60,
85,
383,
37,
17,
78,
60,
85,
383,
1149,
356,
283,
271,
21171,
297,
489,
399,
7,
371,
14183,
5973,
356,
283,
6198,
936,
199,
624,
35,
806,
335,
334,
674,
32738,
9,
370,
11358,
536,
4412,
367,
11314,
24623,
1504,
1041,
199,
199,
2502,
63,
29862,
275,
788,
10805,
1656,
418,
199,
624,
1296,
402,
9432,
3326,
367,
314,
283,
2817,
1384,
7,
11314,
24623,
901,
14,
12480,
379,
315,
199,
1648,
1041,
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,
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,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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
] |
AccelAI/accel.ai
|
flask-aws/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/latin1prober.py
|
1778
|
5232
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
# Shy Shalom - original C code
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from .charsetprober import CharSetProber
from .constants import eNotMe
from .compat import wrap_ord
FREQ_CAT_NUM = 4
UDF = 0 # undefined
OTH = 1 # other
ASC = 2 # ascii capital letter
ASS = 3 # ascii small letter
ACV = 4 # accent capital vowel
ACO = 5 # accent capital other
ASV = 6 # accent small vowel
ASO = 7 # accent small other
CLASS_NUM = 8 # total classes
Latin1_CharToClass = (
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F
OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47
ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F
ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57
ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F
OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67
ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F
ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77
ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F
OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87
OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F
UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97
OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF
ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7
ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF
ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7
ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF
ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7
ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF
ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7
ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF
)
# 0 : illegal
# 1 : very unlikely
# 2 : normal
# 3 : very likely
Latin1ClassModel = (
# UDF OTH ASC ASS ACV ACO ASV ASO
0, 0, 0, 0, 0, 0, 0, 0, # UDF
0, 3, 3, 3, 3, 3, 3, 3, # OTH
0, 3, 3, 3, 3, 3, 3, 3, # ASC
0, 3, 3, 3, 1, 1, 3, 3, # ASS
0, 3, 3, 3, 1, 2, 1, 2, # ACV
0, 3, 3, 3, 3, 3, 3, 3, # ACO
0, 3, 1, 3, 1, 1, 1, 3, # ASV
0, 3, 1, 3, 1, 1, 3, 3, # ASO
)
class Latin1Prober(CharSetProber):
def __init__(self):
CharSetProber.__init__(self)
self.reset()
def reset(self):
self._mLastCharClass = OTH
self._mFreqCounter = [0] * FREQ_CAT_NUM
CharSetProber.reset(self)
def get_charset_name(self):
return "windows-1252"
def feed(self, aBuf):
aBuf = self.filter_with_english_letters(aBuf)
for c in aBuf:
charClass = Latin1_CharToClass[wrap_ord(c)]
freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)
+ charClass]
if freq == 0:
self._mState = eNotMe
break
self._mFreqCounter[freq] += 1
self._mLastCharClass = charClass
return self.get_state()
def get_confidence(self):
if self.get_state() == eNotMe:
return 0.01
total = sum(self._mFreqCounter)
if total < 0.01:
confidence = 0.0
else:
confidence = ((self._mFreqCounter[3] - self._mFreqCounter[1] * 20.0)
/ total)
if confidence < 0.0:
confidence = 0.0
# lower the confidence of latin1 so that other more accurate
# detector can take priority.
confidence = confidence * 0.73
return confidence
|
mit
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
5559,
492,
325,
1763,
1352,
199,
504,
1275,
5819,
492,
4816,
63,
2181,
199,
199,
38,
14583,
63,
11206,
63,
7125,
275,
841,
199,
199,
3383,
38,
275,
378,
221,
327,
10942,
199,
22949,
275,
413,
221,
327,
1163,
199,
22767,
275,
499,
221,
327,
13294,
17094,
8082,
199,
3755,
275,
650,
221,
327,
13294,
7425,
8082,
199,
1348,
54,
275,
841,
221,
327,
1066,
2946,
17094,
373,
11797,
199,
1348,
47,
275,
959,
221,
327,
1066,
2946,
17094,
1163,
199,
1179,
54,
275,
1227,
221,
327,
1066,
2946,
7425,
373,
11797,
199,
1179,
47,
275,
1520,
221,
327,
1066,
2946,
7425,
1163,
199,
6885,
63,
7125,
275,
1695,
221,
327,
3141,
3992,
199,
199,
27317,
17,
63,
18139,
2543,
275,
334,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
8733,
446,
24937,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
19363,
446,
378,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
1616,
446,
5557,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
6155,
446,
413,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
3388,
446,
8087,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
7294,
446,
499,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
4233,
446,
6877,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
10448,
446,
650,
38,
272,
4418,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
6335,
446,
10954,
272,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
9615,
446,
841,
38,
272,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
5238,
446,
12699,
272,
20955,
12,
20955,
12,
20955,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
13713,
446,
959,
38,
272,
4418,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
5212,
446,
13296,
272,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
10851,
446,
1227,
38,
272,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
10045,
446,
8375,
272,
17567,
12,
17567,
12,
17567,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
14679,
446,
1520,
38,
272,
4418,
12,
738,
3888,
12,
4418,
12,
437,
4118,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
5939,
446,
10513,
272,
4418,
12,
4418,
12,
437,
1439,
12,
4418,
12,
437,
1439,
12,
738,
3888,
12,
437,
1439,
12,
738,
3888,
12,
257,
327,
10523,
446,
1695,
38,
272,
738,
3888,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
9137,
446,
15997,
272,
4418,
12,
4418,
12,
437,
4118,
12,
4418,
12,
437,
4118,
12,
738,
3888,
12,
437,
4118,
12,
437,
1439,
12,
257,
327,
16096,
446,
1749,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
437,
16,
446,
437,
23,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
437,
24,
446,
20089,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
699,
16,
446,
699,
23,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
699,
24,
446,
699,
38,
272,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
437,
1439,
12,
437,
1439,
12,
257,
327,
445,
16,
446,
445,
23,
272,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
257,
327,
445,
24,
446,
6035,
272,
437,
1439,
12,
437,
1439,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
4418,
12
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
5559,
492,
325,
1763,
1352,
199,
504,
1275,
5819,
492,
4816,
63,
2181,
199,
199,
38,
14583,
63,
11206,
63,
7125,
275,
841,
199,
199,
3383,
38,
275,
378,
221,
327,
10942,
199,
22949,
275,
413,
221,
327,
1163,
199,
22767,
275,
499,
221,
327,
13294,
17094,
8082,
199,
3755,
275,
650,
221,
327,
13294,
7425,
8082,
199,
1348,
54,
275,
841,
221,
327,
1066,
2946,
17094,
373,
11797,
199,
1348,
47,
275,
959,
221,
327,
1066,
2946,
17094,
1163,
199,
1179,
54,
275,
1227,
221,
327,
1066,
2946,
7425,
373,
11797,
199,
1179,
47,
275,
1520,
221,
327,
1066,
2946,
7425,
1163,
199,
6885,
63,
7125,
275,
1695,
221,
327,
3141,
3992,
199,
199,
27317,
17,
63,
18139,
2543,
275,
334,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
8733,
446,
24937,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
19363,
446,
378,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
1616,
446,
5557,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
6155,
446,
413,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
3388,
446,
8087,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
7294,
446,
499,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
4233,
446,
6877,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
10448,
446,
650,
38,
272,
4418,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
6335,
446,
10954,
272,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
9615,
446,
841,
38,
272,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
20955,
12,
257,
327,
5238,
446,
12699,
272,
20955,
12,
20955,
12,
20955,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
13713,
446,
959,
38,
272,
4418,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
5212,
446,
13296,
272,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
10851,
446,
1227,
38,
272,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
17567,
12,
257,
327,
10045,
446,
8375,
272,
17567,
12,
17567,
12,
17567,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
14679,
446,
1520,
38,
272,
4418,
12,
738,
3888,
12,
4418,
12,
437,
4118,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
5939,
446,
10513,
272,
4418,
12,
4418,
12,
437,
1439,
12,
4418,
12,
437,
1439,
12,
738,
3888,
12,
437,
1439,
12,
738,
3888,
12,
257,
327,
10523,
446,
1695,
38,
272,
738,
3888,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
9137,
446,
15997,
272,
4418,
12,
4418,
12,
437,
4118,
12,
4418,
12,
437,
4118,
12,
738,
3888,
12,
437,
4118,
12,
437,
1439,
12,
257,
327,
16096,
446,
1749,
38,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
437,
16,
446,
437,
23,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
437,
24,
446,
20089,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
699,
16,
446,
699,
23,
272,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
4418,
12,
257,
327,
699,
24,
446,
699,
38,
272,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
30950,
12,
437,
1439,
12,
437,
1439,
12,
257,
327,
445,
16,
446,
445,
23,
272,
30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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
] |
Letractively/timeside
|
timeside/analyzer/aubio_specdesc.py
|
2
|
3126
|
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 Paul Brossier <piem@piem.org>
# This file is part of TimeSide.
# TimeSide 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.
# TimeSide 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 TimeSide. If not, see <http://www.gnu.org/licenses/>.
# Author: Paul Brossier <piem@piem.org>
from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
from timeside.analyzer.core import Analyzer
from timeside.api import IAnalyzer
from preprocessors import downmix_to_mono, frames_adapter
from aubio import specdesc, pvoc
class AubioSpecdesc(Analyzer):
implements(IAnalyzer)
def __init__(self):
super(AubioSpecdesc, self).__init__()
self.input_blocksize = 1024
self.input_stepsize = self.input_blocksize / 4
@interfacedoc
def setup(self, channels=None, samplerate=None,
blocksize=None, totalframes=None):
super(
AubioSpecdesc,
self).setup(
channels,
samplerate,
blocksize,
totalframes)
self.block_read = 0
self.pvoc = pvoc(self.input_blocksize, self.input_stepsize)
self.methods = [
'default', 'energy', 'hfc', 'complex', 'phase', 'specdiff', 'kl',
'mkl', 'specflux', 'centroid', 'slope', 'rolloff', 'spread', 'skewness',
'kurtosis', 'decrease']
self.specdesc = {}
self.specdesc_results = {}
for method in self.methods:
self.specdesc[method] = specdesc(method, self.input_blocksize)
self.specdesc_results[method] = []
@staticmethod
@interfacedoc
def id():
return "aubio_specdesc"
@staticmethod
@interfacedoc
def name():
return "Spectral Descriptor (aubio)"
@staticmethod
@interfacedoc
def unit():
return ""
@downmix_to_mono
@frames_adapter
def process(self, frames, eod=False):
fftgrain = self.pvoc(frames)
for method in self.methods:
self.specdesc_results[method] += [
self.specdesc[method](fftgrain)[0]]
return frames, eod
def post_process(self):
# For each method store results in container
for method in self.methods:
res_specdesc = self.new_result(data_mode='value',
time_mode='framewise')
# Set metadata
res_specdesc.id_metadata.id += '.' + method
res_specdesc.id_metadata.name = ' ' + method
res_specdesc.data_object.value = self.specdesc_results[method]
self.process_pipe.results.add(res_specdesc)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
6171,
28574,
699,
4796,
338,
281,
665,
1038,
5633,
32,
1038,
5633,
14,
1308,
30,
199,
199,
3,
961,
570,
365,
1777,
402,
4703,
15414,
14,
199,
199,
3,
4703,
15414,
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,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
3,
4703,
15414,
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,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
4703,
15414,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6529,
26,
28574,
699,
4796,
338,
281,
665,
1038,
5633,
32,
1038,
5633,
14,
1308,
30,
199,
199,
504,
900,
2441,
14,
1018,
492,
31500,
12,
9031,
12,
3217,
1301,
12,
18659,
2320,
3205,
10200,
199,
504,
900,
2441,
14,
17965,
14,
1018,
492,
14279,
2282,
199,
504,
900,
2441,
14,
1246,
492,
473,
17606,
199,
504,
876,
10547,
492,
3224,
13979,
63,
475,
63,
19758,
12,
11223,
63,
10394,
199,
199,
504,
282,
456,
2308,
492,
3158,
3257,
12,
20279,
679,
421,
199,
533,
437,
456,
2308,
5307,
3257,
8,
17606,
304,
272,
9031,
8,
41,
17606,
9,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
33,
456,
2308,
5307,
3257,
12,
291,
2843,
826,
4533,
267,
291,
14,
1210,
63,
25959,
275,
6619,
267,
291,
14,
1210,
63,
2926,
890,
275,
291,
14,
1210,
63,
25959,
1182,
841,
339,
768,
3266,
1301,
272,
347,
3272,
8,
277,
12,
9245,
29,
403,
12,
2690,
1866,
29,
403,
12,
1598,
27461,
29,
403,
12,
12657,
7411,
1186,
83,
29,
403,
304,
267,
1613,
8,
288,
437,
456,
2308,
5307,
3257,
12,
288,
291,
680,
2758,
8,
288,
9245,
12,
288,
2690,
1866,
12,
288,
27461,
12,
288,
12657,
7411,
1186,
83,
9,
267,
291,
14,
1457,
63,
739,
275,
378,
267,
291,
14,
1381,
679,
275,
20279,
679,
8,
277,
14,
1210,
63,
25959,
12,
291,
14,
1210,
63,
2926,
890,
9,
267,
291,
14,
2474,
275,
359,
288,
283,
885,
297,
283,
8443,
297,
283,
72,
3003,
297,
283,
5254,
297,
283,
6971,
297,
283,
1650,
3028,
297,
283,
9503,
297,
288,
283,
3880,
76,
297,
283,
1650,
14477,
297,
283,
22098,
297,
283,
25278,
297,
283,
8459,
320,
556,
297,
283,
29889,
297,
283,
27424,
4171,
297,
288,
283,
75,
32746,
297,
283,
271,
16772,
418,
267,
291,
14,
1650,
3257,
275,
1052,
267,
291,
14,
1650,
3257,
63,
2604,
275,
1052,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
291,
14,
1650,
3257,
59,
765,
61,
275,
3158,
3257,
8,
765,
12,
291,
14,
1210,
63,
25959,
9,
288,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
275,
942,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
1305,
837,
267,
372,
298,
65,
456,
2308,
63,
1650,
3257,
2,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
536,
837,
267,
372,
298,
51,
15832,
28131,
334,
65,
456,
2308,
2924,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
4137,
837,
267,
372,
3087,
339,
768,
2110,
13979,
63,
475,
63,
19758,
272,
768,
8444,
63,
10394,
272,
347,
2112,
8,
277,
12,
11223,
12,
325,
364,
29,
797,
304,
267,
18160,
926,
262,
275,
291,
14,
1381,
679,
8,
8444,
9,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
847,
359,
355,
291,
14,
1650,
3257,
59,
765,
8738,
9996,
926,
262,
2788,
16,
2677,
267,
372,
11223,
12,
325,
364,
339,
347,
2963,
63,
1412,
8,
277,
304,
398,
327,
2104,
1924,
1083,
3877,
2058,
315,
3970,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
522,
63,
1650,
3257,
275,
291,
14,
1222,
63,
1099,
8,
576,
63,
632,
534,
585,
297,
5644,
900,
63,
632,
534,
1943,
2605,
358,
288,
327,
2494,
3341,
288,
522,
63,
1650,
3257,
14,
344,
63,
2343,
14,
344,
847,
7815,
435,
1083,
288,
522,
63,
1650,
3257,
14,
344,
63,
2343,
14,
354,
275,
283,
283,
435,
1083,
288,
522,
63,
1650,
3257,
14,
576,
63,
785,
14,
585,
275,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
953,
291,
14,
1412,
63,
4990,
14,
2604,
14,
525,
8,
470,
63,
1650,
3257,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
6171,
28574,
699,
4796,
338,
281,
665,
1038,
5633,
32,
1038,
5633,
14,
1308,
30,
199,
199,
3,
961,
570,
365,
1777,
402,
4703,
15414,
14,
199,
199,
3,
4703,
15414,
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,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
3,
4703,
15414,
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,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
4703,
15414,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
6529,
26,
28574,
699,
4796,
338,
281,
665,
1038,
5633,
32,
1038,
5633,
14,
1308,
30,
199,
199,
504,
900,
2441,
14,
1018,
492,
31500,
12,
9031,
12,
3217,
1301,
12,
18659,
2320,
3205,
10200,
199,
504,
900,
2441,
14,
17965,
14,
1018,
492,
14279,
2282,
199,
504,
900,
2441,
14,
1246,
492,
473,
17606,
199,
504,
876,
10547,
492,
3224,
13979,
63,
475,
63,
19758,
12,
11223,
63,
10394,
199,
199,
504,
282,
456,
2308,
492,
3158,
3257,
12,
20279,
679,
421,
199,
533,
437,
456,
2308,
5307,
3257,
8,
17606,
304,
272,
9031,
8,
41,
17606,
9,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
33,
456,
2308,
5307,
3257,
12,
291,
2843,
826,
4533,
267,
291,
14,
1210,
63,
25959,
275,
6619,
267,
291,
14,
1210,
63,
2926,
890,
275,
291,
14,
1210,
63,
25959,
1182,
841,
339,
768,
3266,
1301,
272,
347,
3272,
8,
277,
12,
9245,
29,
403,
12,
2690,
1866,
29,
403,
12,
1598,
27461,
29,
403,
12,
12657,
7411,
1186,
83,
29,
403,
304,
267,
1613,
8,
288,
437,
456,
2308,
5307,
3257,
12,
288,
291,
680,
2758,
8,
288,
9245,
12,
288,
2690,
1866,
12,
288,
27461,
12,
288,
12657,
7411,
1186,
83,
9,
267,
291,
14,
1457,
63,
739,
275,
378,
267,
291,
14,
1381,
679,
275,
20279,
679,
8,
277,
14,
1210,
63,
25959,
12,
291,
14,
1210,
63,
2926,
890,
9,
267,
291,
14,
2474,
275,
359,
288,
283,
885,
297,
283,
8443,
297,
283,
72,
3003,
297,
283,
5254,
297,
283,
6971,
297,
283,
1650,
3028,
297,
283,
9503,
297,
288,
283,
3880,
76,
297,
283,
1650,
14477,
297,
283,
22098,
297,
283,
25278,
297,
283,
8459,
320,
556,
297,
283,
29889,
297,
283,
27424,
4171,
297,
288,
283,
75,
32746,
297,
283,
271,
16772,
418,
267,
291,
14,
1650,
3257,
275,
1052,
267,
291,
14,
1650,
3257,
63,
2604,
275,
1052,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
291,
14,
1650,
3257,
59,
765,
61,
275,
3158,
3257,
8,
765,
12,
291,
14,
1210,
63,
25959,
9,
288,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
275,
942,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
1305,
837,
267,
372,
298,
65,
456,
2308,
63,
1650,
3257,
2,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
536,
837,
267,
372,
298,
51,
15832,
28131,
334,
65,
456,
2308,
2924,
339,
768,
4639,
272,
768,
3266,
1301,
272,
347,
4137,
837,
267,
372,
3087,
339,
768,
2110,
13979,
63,
475,
63,
19758,
272,
768,
8444,
63,
10394,
272,
347,
2112,
8,
277,
12,
11223,
12,
325,
364,
29,
797,
304,
267,
18160,
926,
262,
275,
291,
14,
1381,
679,
8,
8444,
9,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
847,
359,
355,
291,
14,
1650,
3257,
59,
765,
8738,
9996,
926,
262,
2788,
16,
2677,
267,
372,
11223,
12,
325,
364,
339,
347,
2963,
63,
1412,
8,
277,
304,
398,
327,
2104,
1924,
1083,
3877,
2058,
315,
3970,
267,
367,
1083,
315,
291,
14,
2474,
26,
288,
522,
63,
1650,
3257,
275,
291,
14,
1222,
63,
1099,
8,
576,
63,
632,
534,
585,
297,
5644,
900,
63,
632,
534,
1943,
2605,
358,
288,
327,
2494,
3341,
288,
522,
63,
1650,
3257,
14,
344,
63,
2343,
14,
344,
847,
7815,
435,
1083,
288,
522,
63,
1650,
3257,
14,
344,
63,
2343,
14,
354,
275,
283,
283,
435,
1083,
288,
522,
63,
1650,
3257,
14,
576,
63,
785,
14,
585,
275,
291,
14,
1650,
3257,
63,
2604,
59,
765,
61,
953,
291,
14,
1412,
63,
4990,
14,
2604,
14,
525,
8,
470,
63,
1650,
3257,
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,
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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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
] |
piffey/ansible
|
lib/ansible/modules/cloud/ovirt/ovirt_vmpools.py
|
75
|
7594
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: ovirt_vmpools
short_description: Module to manage VM pools in oVirt/RHV
version_added: "2.3"
author: "Ondra Machacek (@machacekondra)"
description:
- "Module to manage VM pools in oVirt/RHV."
options:
name:
description:
- "Name of the VM pool to manage."
required: true
state:
description:
- "Should the VM pool be present/absent."
- "Note that when C(state) is I(absent) all VMs in VM pool are stopped and removed."
choices: ['present', 'absent']
default: present
template:
description:
- "Name of the template, which will be used to create VM pool."
description:
description:
- "Description of the VM pool."
cluster:
description:
- "Name of the cluster, where VM pool should be created."
type:
description:
- "Type of the VM pool. Either manual or automatic."
- "C(manual) - The administrator is responsible for explicitly returning the virtual machine to the pool.
The virtual machine reverts to the original base image after the administrator returns it to the pool."
- "C(Automatic) - When the virtual machine is shut down, it automatically reverts to its base image and
is returned to the virtual machine pool."
- "Default value is set by engine."
choices: ['manual', 'automatic']
vm_per_user:
description:
- "Maximum number of VMs a single user can attach to from this pool."
- "Default value is set by engine."
prestarted:
description:
- "Number of pre-started VMs defines the number of VMs in run state, that are waiting
to be attached to Users."
- "Default value is set by engine."
vm_count:
description:
- "Number of VMs in the pool."
- "Default value is set by engine."
extends_documentation_fragment: ovirt
'''
EXAMPLES = '''
# Examples don't contain auth parameter for simplicity,
# look at ovirt_auth module to see how to reuse authentication:
# Create VM pool from template
- ovirt_vmpools:
cluster: mycluster
name: myvmpool
template: rhel7
vm_count: 2
prestarted: 2
vm_per_user: 1
# Remove vmpool, note that all VMs in pool will be stopped and removed:
- ovirt_vmpools:
state: absent
name: myvmpool
'''
RETURN = '''
id:
description: ID of the VM pool which is managed
returned: On success if VM pool is found.
type: str
sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c
vm_pool:
description: "Dictionary of all the VM pool attributes. VM pool attributes can be found on your oVirt/RHV instance
at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm_pool."
returned: On success if VM pool is found.
type: dict
'''
try:
import ovirtsdk4.types as otypes
except ImportError:
pass
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ovirt import (
BaseModule,
check_params,
check_sdk,
create_connection,
equal,
get_link_name,
ovirt_full_argument_spec,
wait,
)
class VmPoolsModule(BaseModule):
def build_entity(self):
return otypes.VmPool(
name=self._module.params['name'],
description=self._module.params['description'],
comment=self._module.params['comment'],
cluster=otypes.Cluster(
name=self._module.params['cluster']
) if self._module.params['cluster'] else None,
template=otypes.Template(
name=self._module.params['template']
) if self._module.params['template'] else None,
max_user_vms=self._module.params['vm_per_user'],
prestarted_vms=self._module.params['prestarted'],
size=self._module.params['vm_count'],
type=otypes.VmPoolType(
self._module.params['type']
) if self._module.params['type'] else None,
)
def update_check(self, entity):
return (
equal(self._module.params.get('cluster'), get_link_name(self._connection, entity.cluster)) and
equal(self._module.params.get('description'), entity.description) and
equal(self._module.params.get('comment'), entity.comment) and
equal(self._module.params.get('vm_per_user'), entity.max_user_vms) and
equal(self._module.params.get('prestarted'), entity.prestarted_vms) and
equal(self._module.params.get('vm_count'), entity.size)
)
def main():
argument_spec = ovirt_full_argument_spec(
state=dict(
choices=['present', 'absent'],
default='present',
),
name=dict(default=None, required=True),
template=dict(default=None),
cluster=dict(default=None),
description=dict(default=None),
comment=dict(default=None),
vm_per_user=dict(default=None, type='int'),
prestarted=dict(default=None, type='int'),
vm_count=dict(default=None, type='int'),
type=dict(default=None, choices=['automatic', 'manual']),
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
)
check_sdk(module)
check_params(module)
try:
auth = module.params.pop('auth')
connection = create_connection(auth)
vm_pools_service = connection.system_service().vm_pools_service()
vm_pools_module = VmPoolsModule(
connection=connection,
module=module,
service=vm_pools_service,
)
state = module.params['state']
if state == 'present':
ret = vm_pools_module.create()
# Wait for all VM pool VMs to be created:
if module.params['wait']:
vms_service = connection.system_service().vms_service()
for vm in vms_service.list(search='pool=%s' % module.params['name']):
wait(
service=vms_service.service(vm.id),
condition=lambda vm: vm.status in [otypes.VmStatus.DOWN, otypes.VmStatus.UP],
timeout=module.params['timeout'],
)
elif state == 'absent':
ret = vm_pools_module.remove()
module.exit_json(**ret)
except Exception as e:
module.fail_json(msg=str(e), exception=traceback.format_exc())
finally:
connection.close(logout=auth.get('token') is None)
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
7800,
9572,
13002,
12,
3277,
14,
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,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21353,
63,
86,
311,
5998,
199,
3612,
63,
1802,
26,
5673,
370,
9635,
7525,
20092,
315,
312,
17146,
15,
50,
16566,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
47,
977,
345,
30611,
7984,
75,
8593,
14121,
7984,
75,
7835,
345,
2924,
199,
1802,
26,
272,
446,
298,
2377,
370,
9635,
7525,
20092,
315,
312,
17146,
15,
50,
16566,
2122,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
7525,
4203,
370,
9635,
2122,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
288,
446,
298,
11408,
314,
7525,
4203,
506,
3451,
15,
5575,
2122,
288,
446,
298,
7443,
626,
1380,
445,
8,
929,
9,
365,
473,
8,
5575,
9,
1006,
30641,
315,
7525,
4203,
787,
15248,
436,
4829,
2122,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
849,
26,
3451,
272,
1978,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
1978,
12,
1314,
911,
506,
1202,
370,
1218,
7525,
4203,
2122,
272,
1369,
26,
267,
1369,
26,
288,
446,
298,
5831,
402,
314,
7525,
4203,
2122,
272,
4350,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
4350,
12,
2382,
7525,
4203,
1077,
506,
2737,
2122,
272,
730,
26,
267,
1369,
26,
288,
446,
298,
804,
402,
314,
7525,
4203,
14,
13083,
8722,
503,
4834,
2122,
288,
446,
298,
35,
8,
9285,
9,
446,
710,
31056,
365,
17845,
367,
7662,
8152,
314,
5791,
6844,
370,
314,
4203,
14,
2049,
710,
5791,
6844,
295,
21505,
370,
314,
3379,
1300,
1834,
2410,
314,
31056,
2529,
652,
370,
314,
4203,
2122,
288,
446,
298,
35,
8,
3358,
3889,
9,
446,
3979,
314,
5791,
6844,
365,
24761,
3224,
12,
652,
5847,
295,
21505,
370,
2399,
1300,
1834,
436,
2049,
365,
2138,
370,
314,
5791,
6844,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
267,
3415,
26,
788,
9285,
297,
283,
23292,
418,
272,
4169,
63,
529,
63,
751,
26,
267,
1369,
26,
288,
446,
298,
10915,
1329,
402,
30641,
282,
2849,
922,
883,
6554,
370,
687,
642,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
876,
8924,
26,
267,
1369,
26,
288,
446,
298,
3259,
402,
876,
13,
8924,
30641,
7890,
314,
1329,
402,
30641,
315,
1255,
1174,
12,
626,
787,
10923,
2049,
370,
506,
10102,
370,
20123,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
4169,
63,
835,
26,
267,
1369,
26,
288,
446,
298,
3259,
402,
30641,
315,
314,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
199,
11036,
63,
9970,
63,
7677,
26,
21353,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6058,
2793,
1133,
1395,
1790,
2725,
367,
17553,
3690,
12,
199,
3,
3648,
737,
21353,
63,
1178,
859,
370,
1937,
4212,
370,
12598,
6299,
26,
199,
199,
3,
2790,
7525,
4203,
687,
1978,
199,
13,
21353,
63,
86,
311,
5998,
26,
272,
4350,
26,
3002,
4201,
272,
536,
26,
3002,
86,
18205,
272,
1978,
26,
26006,
352,
23,
272,
4169,
63,
835,
26,
499,
272,
876,
8924,
26,
499,
272,
4169,
63,
529,
63,
751,
26,
413,
199,
199,
3,
5852,
373,
18205,
12,
5317,
626,
1006,
30641,
315,
4203,
911,
506,
15248,
436,
4829,
26,
199,
13,
21353,
63,
86,
311,
5998,
26,
272,
1174,
26,
9552,
272,
536,
26,
3002,
86,
18205,
199,
2344,
199,
199,
9677,
275,
1449,
199,
344,
26,
272,
1369,
26,
2870,
402,
314,
7525,
4203,
1314,
365,
12883,
272,
2138,
26,
4068,
3182,
340,
7525,
4203,
365,
1911,
14,
272,
730,
26,
620,
272,
2690,
26,
1520,
271,
2710,
70,
2192,
13,
9485,
67,
13,
26319,
67,
13,
65,
17,
696,
13,
23,
69,
10027,
3691,
21,
66,
2259,
67,
199,
2611,
63,
2293,
26,
272,
1369,
26,
298,
11728,
402,
1006,
314,
7525,
4203,
3004,
14,
7525,
4203,
3004,
883,
506,
1911,
641,
2195,
312,
17146,
15,
50,
16566,
1256,
2116,
737,
2569,
1166,
26,
1455,
921,
23334,
14,
5031,
14,
2308,
15,
23334,
13,
3908,
13,
1246,
13,
1238,
15,
4133,
12645,
1313,
15,
2611,
63,
2293,
2122,
272,
2138,
26,
4068,
3182,
340,
7525,
4203,
365,
1911,
14,
272,
730,
26,
1211,
199,
2344,
199,
199,
893,
26,
272,
492,
312,
1042,
1086,
6341,
20,
14,
1313,
465,
312,
1313,
199,
2590,
3545,
26,
272,
986,
199,
199,
646,
5190,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
23334,
492,
334,
272,
3523,
2377,
12,
272,
1104,
63,
1162,
12,
272,
1104,
63,
9277,
12,
272,
1218,
63,
2105,
12,
272,
4472,
12,
272,
664,
63,
1073,
63,
354,
12,
272,
21353,
63,
2861,
63,
2094,
63,
1650,
12,
272,
3618,
12,
199
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
7800,
9572,
13002,
12,
3277,
14,
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,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
21353,
63,
86,
311,
5998,
199,
3612,
63,
1802,
26,
5673,
370,
9635,
7525,
20092,
315,
312,
17146,
15,
50,
16566,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
47,
977,
345,
30611,
7984,
75,
8593,
14121,
7984,
75,
7835,
345,
2924,
199,
1802,
26,
272,
446,
298,
2377,
370,
9635,
7525,
20092,
315,
312,
17146,
15,
50,
16566,
2122,
199,
1419,
26,
272,
536,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
7525,
4203,
370,
9635,
2122,
267,
1415,
26,
2549,
272,
1174,
26,
267,
1369,
26,
288,
446,
298,
11408,
314,
7525,
4203,
506,
3451,
15,
5575,
2122,
288,
446,
298,
7443,
626,
1380,
445,
8,
929,
9,
365,
473,
8,
5575,
9,
1006,
30641,
315,
7525,
4203,
787,
15248,
436,
4829,
2122,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
849,
26,
3451,
272,
1978,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
1978,
12,
1314,
911,
506,
1202,
370,
1218,
7525,
4203,
2122,
272,
1369,
26,
267,
1369,
26,
288,
446,
298,
5831,
402,
314,
7525,
4203,
2122,
272,
4350,
26,
267,
1369,
26,
288,
446,
298,
985,
402,
314,
4350,
12,
2382,
7525,
4203,
1077,
506,
2737,
2122,
272,
730,
26,
267,
1369,
26,
288,
446,
298,
804,
402,
314,
7525,
4203,
14,
13083,
8722,
503,
4834,
2122,
288,
446,
298,
35,
8,
9285,
9,
446,
710,
31056,
365,
17845,
367,
7662,
8152,
314,
5791,
6844,
370,
314,
4203,
14,
2049,
710,
5791,
6844,
295,
21505,
370,
314,
3379,
1300,
1834,
2410,
314,
31056,
2529,
652,
370,
314,
4203,
2122,
288,
446,
298,
35,
8,
3358,
3889,
9,
446,
3979,
314,
5791,
6844,
365,
24761,
3224,
12,
652,
5847,
295,
21505,
370,
2399,
1300,
1834,
436,
2049,
365,
2138,
370,
314,
5791,
6844,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
267,
3415,
26,
788,
9285,
297,
283,
23292,
418,
272,
4169,
63,
529,
63,
751,
26,
267,
1369,
26,
288,
446,
298,
10915,
1329,
402,
30641,
282,
2849,
922,
883,
6554,
370,
687,
642,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
876,
8924,
26,
267,
1369,
26,
288,
446,
298,
3259,
402,
876,
13,
8924,
30641,
7890,
314,
1329,
402,
30641,
315,
1255,
1174,
12,
626,
787,
10923,
2049,
370,
506,
10102,
370,
20123,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
272,
4169,
63,
835,
26,
267,
1369,
26,
288,
446,
298,
3259,
402,
30641,
315,
314,
4203,
2122,
288,
446,
298,
2698,
574,
365,
663,
701,
6869,
2122,
199,
11036,
63,
9970,
63,
7677,
26,
21353,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6058,
2793,
1133,
1395,
1790,
2725,
367,
17553,
3690,
12,
199,
3,
3648,
737,
21353,
63,
1178,
859,
370,
1937,
4212,
370,
12598,
6299,
26,
199,
199,
3,
2790,
7525,
4203,
687,
1978,
199,
13,
21353,
63,
86,
311,
5998,
26,
272,
4350,
26,
3002,
4201,
272,
536,
26,
3002,
86,
18205,
272,
1978,
26,
26006,
352,
23,
272,
4169,
63,
835,
26,
499,
272,
876,
8924,
26,
499,
272,
4169,
63,
529,
63,
751,
26,
413,
199,
199,
3,
5852,
373,
18205,
12,
5317,
626,
1006,
30641,
315,
4203,
911,
506,
15248,
436,
4829,
26,
199,
13,
21353,
63,
86,
311,
5998,
26,
272,
1174,
26,
9552,
272,
536,
26,
3002,
86,
18205,
199,
2344,
199,
199,
9677,
275,
1449,
199,
344,
26,
272,
1369,
26,
2870,
402,
314,
7525,
4203,
1314,
365,
12883,
272,
2138,
26,
4068,
3182,
340,
7525,
4203,
365,
1911,
14,
272,
730,
26,
620,
272,
2690,
26,
1520,
271,
2710,
70,
2192,
13,
9485,
67,
13,
26319,
67,
13,
65,
17,
696,
13,
23,
69,
10027,
3691,
21,
66,
2259,
67,
199,
2611,
63,
2293,
26,
272,
1369,
26,
298,
11728,
402,
1006,
314,
7525,
4203,
3004,
14,
7525,
4203,
3004,
883,
506,
1911,
641,
2195,
312,
17146,
15,
50,
16566,
1256,
2116,
737,
2569,
1166,
26,
1455,
921,
23334,
14,
5031,
14,
2308,
15,
23334,
13,
3908,
13,
1246,
13,
1238,
15,
4133,
12645,
1313,
15,
2611,
63,
2293,
2122,
272,
2138,
26,
4068,
3182,
340,
7525,
4203,
365,
1911,
14,
272,
730,
26,
1211,
199,
2344,
199,
199,
893,
26,
272,
492,
312,
1042,
1086,
6341,
20,
14,
1313,
465,
312,
1313,
199,
2590,
3545,
26,
272,
986,
199,
199,
646,
5190,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
23334,
492,
334,
272,
3523,
2377,
12,
272,
1104,
63,
1162,
12,
272,
1104,
63,
9277,
12,
272,
1218,
63,
2105,
12,
272,
4472,
12,
272,
664,
63,
1073,
63,
354,
12,
272,
21353,
63,
2861,
63,
2094,
63,
1650,
12,
272,
3618,
12,
199,
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,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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
] |
jakereps/qiime2
|
qiime2/core/testing/format.py
|
2
|
5025
|
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2021, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------
from qiime2.plugin import TextFileFormat, ValidationError
import qiime2.plugin.model as model
class IntSequenceFormat(TextFileFormat):
"""
A sequence of integers stored on new lines in a file. Since this is a
sequence, the integers have an order and repetition of elements is
allowed. Sequential values must have an inter-value distance other than 3
to be valid.
"""
def _validate_n_ints(self, n):
with self.open() as fh:
last_val = None
for idx, line in enumerate(fh, 1):
if n is not None and idx >= n:
break
try:
val = int(line.rstrip('\n'))
except (TypeError, ValueError):
raise ValidationError("Line %d is not an integer." % idx)
if last_val is not None and last_val + 3 == val:
raise ValidationError("Line %d is 3 more than line %d"
% (idx, idx-1))
last_val = val
def _validate_(self, level):
record_map = {'min': 5, 'max': None}
self._validate_n_ints(record_map[level])
class IntSequenceFormatV2(IntSequenceFormat):
"""
Same as IntSequenceFormat, but has a header "VERSION 2"
"""
def _validate_(self, level):
with self.open() as fh:
if fh.readline() != 'VERSION 2\n':
raise ValidationError("Missing header: VERSION 2")
class MappingFormat(TextFileFormat):
"""
A mapping of keys to values stored in a TSV file. Since this is a
mapping, key-value pairs do not have an order and duplicate keys are
disallowed.
"""
def _validate_(self, level):
with self.open() as fh:
for line, idx in zip(fh, range(1, 6)):
cells = line.rstrip('\n').split('\t')
if len(cells) != 2:
raise ValidationError("Line %d does not have exactly 2 "
"elements seperated by a tab." % idx)
class SingleIntFormat(TextFileFormat):
"""
Exactly one int on a single line in the file.
"""
def _validate_(self, level):
with self.open() as fh:
try:
int(fh.readline().rstrip('\n'))
except (TypeError, ValueError):
raise ValidationError("File does not contain an integer")
if fh.readline():
raise ValidationError("Too many lines in file.")
IntSequenceDirectoryFormat = model.SingleFileDirectoryFormat(
'IntSequenceDirectoryFormat', 'ints.txt', IntSequenceFormat)
IntSequenceV2DirectoryFormat = model.SingleFileDirectoryFormat(
'IntSequenceV2DirectoryFormat', 'integers.txt', IntSequenceFormatV2)
class IntSequenceMultiFileDirectoryFormat(model.DirectoryFormat):
pass
# This could have been a `SingleFileDirectoryFormat`, but isn't for testing
# purposes
class MappingDirectoryFormat(model.DirectoryFormat):
mapping = model.File('mapping.tsv', format=MappingFormat)
class FourIntsDirectoryFormat(model.DirectoryFormat):
"""
A sequence of exactly four integers stored across multiple files, some of
which are in a nested directory. Each file contains a single integer.
Since this is a sequence, the integers have an order (corresponding to
filename) and repetition of elements is allowed.
"""
single_ints = model.FileCollection(
r'file[1-2]\.txt|nested/file[3-4]\.txt', format=SingleIntFormat)
@single_ints.set_path_maker
def single_ints_path_maker(self, num):
if not 0 < num < 5:
raise ValueError("`num` must be 1-4, not %r." % num)
if num > 2:
return 'nested/file%d.txt' % num
else:
return 'file%d.txt' % num
class RedundantSingleIntDirectoryFormat(model.DirectoryFormat):
"""
Two files of SingleIntFormat which are exactly the same.
"""
int1 = model.File('file1.txt', format=SingleIntFormat)
int2 = model.File('file2.txt', format=SingleIntFormat)
def _validate_(self, level):
if self.int1.view(int) != self.int2.view(int):
raise ValidationError("file1.txt does not match file2.txt")
class UnimportableFormat(TextFileFormat):
"""
Unimportable format used for testing.
"""
UnimportableDirectoryFormat = model.SingleFileDirectoryFormat(
'UnimportableDirectoryFormat', 'ints.txt', UnimportableFormat)
class EchoFormat(TextFileFormat):
def _validate_(self, level):
pass # Anything is a valid echo file
EchoDirectoryFormat = model.SingleFileDirectoryFormat(
'EchoDirectoryFormat', 'echo.txt', EchoFormat)
|
bsd-3-clause
|
[
3,
27103,
199,
3,
1898,
334,
67,
9,
7800,
13,
22150,
12,
1413,
41,
3465,
499,
16367,
8099,
14,
199,
3,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
3,
199,
3,
710,
2615,
4190,
365,
315,
314,
570,
5113,
12,
1854,
543,
642,
2032,
14,
199,
3,
27103,
199,
199,
504,
31402,
1036,
18,
14,
2718,
492,
4516,
1173,
3484,
12,
8505,
199,
646,
31402,
1036,
18,
14,
2718,
14,
1238,
465,
1402,
421,
199,
533,
9805,
5826,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
437,
3414,
402,
9446,
5489,
641,
892,
2385,
315,
282,
570,
14,
9336,
642,
365,
282,
272,
3414,
12,
314,
9446,
1172,
376,
1865,
436,
6375,
3348,
402,
4008,
365,
272,
4370,
14,
3240,
9092,
1338,
1471,
1172,
376,
1640,
13,
585,
6033,
1163,
2419,
650,
272,
370,
506,
1686,
14,
339,
408,
272,
347,
485,
3502,
63,
78,
63,
13141,
8,
277,
12,
302,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
2061,
63,
637,
275,
488,
288,
367,
4280,
12,
1004,
315,
3874,
8,
12853,
12,
413,
304,
355,
340,
302,
365,
440,
488,
436,
4280,
2356,
302,
26,
490,
2059,
355,
862,
26,
490,
1139,
275,
1109,
8,
604,
14,
6735,
2258,
78,
1333,
355,
871,
334,
4333,
12,
1722,
304,
490,
746,
8505,
480,
3049,
450,
68,
365,
440,
376,
3000,
2122,
450,
4280,
9,
355,
340,
2061,
63,
637,
365,
440,
488,
436,
2061,
63,
637,
435,
650,
508,
1139,
26,
490,
746,
8505,
480,
3049,
450,
68,
365,
650,
1655,
2419,
1004,
450,
68,
2,
5101,
450,
334,
2996,
12,
4280,
13,
17,
430,
355,
2061,
63,
637,
275,
1139,
339,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
2777,
63,
1130,
275,
791,
827,
356,
959,
12,
283,
988,
356,
488,
93,
267,
291,
423,
3502,
63,
78,
63,
13141,
8,
3059,
63,
1130,
59,
1896,
566,
421,
199,
533,
9805,
5826,
3484,
54,
18,
8,
3241,
5826,
3484,
304,
272,
408,
272,
14766,
465,
9805,
5826,
3484,
12,
1325,
965,
282,
1406,
298,
4612,
499,
2,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
340,
11155,
14,
6407,
342,
1137,
283,
4612,
499,
60,
78,
356,
355,
746,
8505,
480,
7718,
1406,
26,
15945,
499,
531,
421,
199,
533,
12340,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
437,
4412,
402,
2883,
370,
1338,
5489,
315,
282,
377,
4985,
570,
14,
9336,
642,
365,
282,
272,
4412,
12,
790,
13,
585,
6342,
886,
440,
1172,
376,
1865,
436,
9250,
2883,
787,
272,
30994,
14,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
367,
1004,
12,
4280,
315,
3482,
8,
12853,
12,
1425,
8,
17,
12,
1227,
2298,
355,
10106,
275,
1004,
14,
6735,
2258,
78,
1959,
1294,
2258,
84,
358,
355,
340,
822,
8,
9041,
9,
1137,
499,
26,
490,
746,
8505,
480,
3049,
450,
68,
1630,
440,
1172,
8840,
499,
298,
5101,
298,
5527,
542,
529,
972,
701,
282,
5174,
2122,
450,
4280,
9,
421,
199,
533,
13050,
3241,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
1316,
2442,
590,
1373,
1109,
641,
282,
2849,
1004,
315,
314,
570,
14,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
862,
26,
355,
1109,
8,
12853,
14,
6407,
1252,
6735,
2258,
78,
1333,
288,
871,
334,
4333,
12,
1722,
304,
355,
746,
8505,
480,
1173,
1630,
440,
1395,
376,
3000,
531,
288,
340,
11155,
14,
6407,
837,
355,
746,
8505,
480,
13749,
5002,
2385,
315,
570,
2685,
421,
199,
3241,
5826,
6231,
3484,
275,
1402,
14,
7200,
1173,
6231,
3484,
8,
272,
283,
3241,
5826,
6231,
3484,
297,
283,
13141,
14,
2424,
297,
9805,
5826,
3484,
9,
199,
199,
3241,
5826,
54,
18,
6231,
3484,
275,
1402,
14,
7200,
1173,
6231,
3484,
8,
272,
283,
3241,
5826,
54,
18,
6231,
3484,
297,
283,
23931,
14,
2424,
297,
9805,
5826,
3484,
54,
18,
9,
421,
199,
533,
9805,
5826,
3947,
1173,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
986,
421,
199,
3,
961,
4293,
1172,
2757,
282,
658,
7200,
1173,
6231,
3484,
3559,
1325,
5712,
1133,
367,
5343,
199,
3,
12901,
199,
533,
12340,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
4412,
275,
1402,
14,
1173,
360,
4745,
14,
29362,
297,
1475,
29,
7674,
3484,
9,
421,
199,
533,
23843,
3241,
83,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
408,
272,
437,
3414,
402,
8840,
11648,
9446,
5489,
9371,
3663,
1584,
12,
2005,
402,
272,
1314,
787,
315,
282,
6032,
2082,
14,
7048,
570,
3509,
282,
2849,
3000,
14,
272,
9336,
642,
365,
282,
3414,
12,
314,
9446,
1172,
376,
1865,
334,
989,
31137,
370,
272,
1788,
9,
436,
6375,
3348,
402,
4008,
365,
4370,
14,
339,
408,
272,
2849,
63,
13141,
275,
1402,
14,
1173,
7768,
8,
267,
519,
7,
493,
59,
17,
13,
18,
61,
4537,
2424,
92,
6376,
15,
493,
59,
19,
13,
20,
61,
4537,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
339,
768,
4780,
63,
13141,
14,
409,
63,
515,
63,
14367,
272,
347,
2849,
63,
13141,
63,
515,
63,
14367,
8,
277,
12,
1967,
304,
267,
340,
440,
378,
665,
1967,
665,
959,
26,
288,
746,
1722,
32684,
1507,
64,
1471,
506,
413,
13,
20,
12,
440,
450,
82,
2122,
450,
1967,
9,
267,
340,
1967,
690,
499,
26,
288,
372,
283,
6376,
15,
493,
5,
68,
14,
2424,
7,
450,
1967,
267,
587,
26,
288,
372,
283,
493,
5,
68,
14,
2424,
7,
450,
1967,
421,
199,
533,
9572,
17013,
7200,
3241,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
408,
272,
16853,
1584,
402,
13050,
3241,
3484,
1314,
787,
8840,
314,
2011,
14,
339,
408,
272,
1109,
17,
275,
1402,
14,
1173,
360,
493,
17,
14,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
272,
1109,
18,
275,
1402,
14,
1173,
360,
493,
18,
14,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
339
] |
[
27103,
199,
3,
1898,
334,
67,
9,
7800,
13,
22150,
12,
1413,
41,
3465,
499,
16367,
8099,
14,
199,
3,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
3,
199,
3,
710,
2615,
4190,
365,
315,
314,
570,
5113,
12,
1854,
543,
642,
2032,
14,
199,
3,
27103,
199,
199,
504,
31402,
1036,
18,
14,
2718,
492,
4516,
1173,
3484,
12,
8505,
199,
646,
31402,
1036,
18,
14,
2718,
14,
1238,
465,
1402,
421,
199,
533,
9805,
5826,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
437,
3414,
402,
9446,
5489,
641,
892,
2385,
315,
282,
570,
14,
9336,
642,
365,
282,
272,
3414,
12,
314,
9446,
1172,
376,
1865,
436,
6375,
3348,
402,
4008,
365,
272,
4370,
14,
3240,
9092,
1338,
1471,
1172,
376,
1640,
13,
585,
6033,
1163,
2419,
650,
272,
370,
506,
1686,
14,
339,
408,
272,
347,
485,
3502,
63,
78,
63,
13141,
8,
277,
12,
302,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
2061,
63,
637,
275,
488,
288,
367,
4280,
12,
1004,
315,
3874,
8,
12853,
12,
413,
304,
355,
340,
302,
365,
440,
488,
436,
4280,
2356,
302,
26,
490,
2059,
355,
862,
26,
490,
1139,
275,
1109,
8,
604,
14,
6735,
2258,
78,
1333,
355,
871,
334,
4333,
12,
1722,
304,
490,
746,
8505,
480,
3049,
450,
68,
365,
440,
376,
3000,
2122,
450,
4280,
9,
355,
340,
2061,
63,
637,
365,
440,
488,
436,
2061,
63,
637,
435,
650,
508,
1139,
26,
490,
746,
8505,
480,
3049,
450,
68,
365,
650,
1655,
2419,
1004,
450,
68,
2,
5101,
450,
334,
2996,
12,
4280,
13,
17,
430,
355,
2061,
63,
637,
275,
1139,
339,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
2777,
63,
1130,
275,
791,
827,
356,
959,
12,
283,
988,
356,
488,
93,
267,
291,
423,
3502,
63,
78,
63,
13141,
8,
3059,
63,
1130,
59,
1896,
566,
421,
199,
533,
9805,
5826,
3484,
54,
18,
8,
3241,
5826,
3484,
304,
272,
408,
272,
14766,
465,
9805,
5826,
3484,
12,
1325,
965,
282,
1406,
298,
4612,
499,
2,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
340,
11155,
14,
6407,
342,
1137,
283,
4612,
499,
60,
78,
356,
355,
746,
8505,
480,
7718,
1406,
26,
15945,
499,
531,
421,
199,
533,
12340,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
437,
4412,
402,
2883,
370,
1338,
5489,
315,
282,
377,
4985,
570,
14,
9336,
642,
365,
282,
272,
4412,
12,
790,
13,
585,
6342,
886,
440,
1172,
376,
1865,
436,
9250,
2883,
787,
272,
30994,
14,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
367,
1004,
12,
4280,
315,
3482,
8,
12853,
12,
1425,
8,
17,
12,
1227,
2298,
355,
10106,
275,
1004,
14,
6735,
2258,
78,
1959,
1294,
2258,
84,
358,
355,
340,
822,
8,
9041,
9,
1137,
499,
26,
490,
746,
8505,
480,
3049,
450,
68,
1630,
440,
1172,
8840,
499,
298,
5101,
298,
5527,
542,
529,
972,
701,
282,
5174,
2122,
450,
4280,
9,
421,
199,
533,
13050,
3241,
3484,
8,
1872,
1173,
3484,
304,
272,
408,
272,
1316,
2442,
590,
1373,
1109,
641,
282,
2849,
1004,
315,
314,
570,
14,
339,
408,
272,
347,
485,
3502,
2531,
277,
12,
2166,
304,
267,
543,
291,
14,
1490,
342,
465,
11155,
26,
288,
862,
26,
355,
1109,
8,
12853,
14,
6407,
1252,
6735,
2258,
78,
1333,
288,
871,
334,
4333,
12,
1722,
304,
355,
746,
8505,
480,
1173,
1630,
440,
1395,
376,
3000,
531,
288,
340,
11155,
14,
6407,
837,
355,
746,
8505,
480,
13749,
5002,
2385,
315,
570,
2685,
421,
199,
3241,
5826,
6231,
3484,
275,
1402,
14,
7200,
1173,
6231,
3484,
8,
272,
283,
3241,
5826,
6231,
3484,
297,
283,
13141,
14,
2424,
297,
9805,
5826,
3484,
9,
199,
199,
3241,
5826,
54,
18,
6231,
3484,
275,
1402,
14,
7200,
1173,
6231,
3484,
8,
272,
283,
3241,
5826,
54,
18,
6231,
3484,
297,
283,
23931,
14,
2424,
297,
9805,
5826,
3484,
54,
18,
9,
421,
199,
533,
9805,
5826,
3947,
1173,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
986,
421,
199,
3,
961,
4293,
1172,
2757,
282,
658,
7200,
1173,
6231,
3484,
3559,
1325,
5712,
1133,
367,
5343,
199,
3,
12901,
199,
533,
12340,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
4412,
275,
1402,
14,
1173,
360,
4745,
14,
29362,
297,
1475,
29,
7674,
3484,
9,
421,
199,
533,
23843,
3241,
83,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
408,
272,
437,
3414,
402,
8840,
11648,
9446,
5489,
9371,
3663,
1584,
12,
2005,
402,
272,
1314,
787,
315,
282,
6032,
2082,
14,
7048,
570,
3509,
282,
2849,
3000,
14,
272,
9336,
642,
365,
282,
3414,
12,
314,
9446,
1172,
376,
1865,
334,
989,
31137,
370,
272,
1788,
9,
436,
6375,
3348,
402,
4008,
365,
4370,
14,
339,
408,
272,
2849,
63,
13141,
275,
1402,
14,
1173,
7768,
8,
267,
519,
7,
493,
59,
17,
13,
18,
61,
4537,
2424,
92,
6376,
15,
493,
59,
19,
13,
20,
61,
4537,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
339,
768,
4780,
63,
13141,
14,
409,
63,
515,
63,
14367,
272,
347,
2849,
63,
13141,
63,
515,
63,
14367,
8,
277,
12,
1967,
304,
267,
340,
440,
378,
665,
1967,
665,
959,
26,
288,
746,
1722,
32684,
1507,
64,
1471,
506,
413,
13,
20,
12,
440,
450,
82,
2122,
450,
1967,
9,
267,
340,
1967,
690,
499,
26,
288,
372,
283,
6376,
15,
493,
5,
68,
14,
2424,
7,
450,
1967,
267,
587,
26,
288,
372,
283,
493,
5,
68,
14,
2424,
7,
450,
1967,
421,
199,
533,
9572,
17013,
7200,
3241,
6231,
3484,
8,
1238,
14,
6231,
3484,
304,
272,
408,
272,
16853,
1584,
402,
13050,
3241,
3484,
1314,
787,
8840,
314,
2011,
14,
339,
408,
272,
1109,
17,
275,
1402,
14,
1173,
360,
493,
17,
14,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
272,
1109,
18,
275,
1402,
14,
1173,
360,
493,
18,
14,
2424,
297,
1475,
29,
7200,
3241,
3484,
9,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jlcarmic/producthunt_simulator
|
venv/lib/python2.7/site-packages/scipy/integrate/odepack.py
|
62
|
9420
|
# Author: Travis Oliphant
from __future__ import division, print_function, absolute_import
__all__ = ['odeint']
from . import _odepack
from copy import copy
import warnings
class ODEintWarning(Warning):
pass
_msgs = {2: "Integration successful.",
1: "Nothing was done; the integration time was 0.",
-1: "Excess work done on this call (perhaps wrong Dfun type).",
-2: "Excess accuracy requested (tolerances too small).",
-3: "Illegal input detected (internal error).",
-4: "Repeated error test failures (internal error).",
-5: "Repeated convergence failures (perhaps bad Jacobian or tolerances).",
-6: "Error weight became zero during problem.",
-7: "Internal workspace insufficient to finish (internal error)."
}
def odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0,
ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0,
hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12,
mxords=5, printmessg=0):
"""
Integrate a system of ordinary differential equations.
Solve a system of ordinary differential equations using lsoda from the
FORTRAN library odepack.
Solves the initial value problem for stiff or non-stiff systems
of first order ode-s::
dy/dt = func(y, t0, ...)
where y can be a vector.
*Note*: The first two arguments of ``func(y, t0, ...)`` are in the
opposite order of the arguments in the system definition function used
by the `scipy.integrate.ode` class.
Parameters
----------
func : callable(y, t0, ...)
Computes the derivative of y at t0.
y0 : array
Initial condition on y (can be a vector).
t : array
A sequence of time points for which to solve for y. The initial
value point should be the first element of this sequence.
args : tuple, optional
Extra arguments to pass to function.
Dfun : callable(y, t0, ...)
Gradient (Jacobian) of `func`.
col_deriv : bool, optional
True if `Dfun` defines derivatives down columns (faster),
otherwise `Dfun` should define derivatives across rows.
full_output : bool, optional
True if to return a dictionary of optional outputs as the second output
printmessg : bool, optional
Whether to print the convergence message
Returns
-------
y : array, shape (len(t), len(y0))
Array containing the value of y for each desired time in t,
with the initial value `y0` in the first row.
infodict : dict, only returned if full_output == True
Dictionary containing additional output information
======= ============================================================
key meaning
======= ============================================================
'hu' vector of step sizes successfully used for each time step.
'tcur' vector with the value of t reached for each time step.
(will always be at least as large as the input times).
'tolsf' vector of tolerance scale factors, greater than 1.0,
computed when a request for too much accuracy was detected.
'tsw' value of t at the time of the last method switch
(given for each time step)
'nst' cumulative number of time steps
'nfe' cumulative number of function evaluations for each time step
'nje' cumulative number of jacobian evaluations for each time step
'nqu' a vector of method orders for each successful step.
'imxer' index of the component of largest magnitude in the
weighted local error vector (e / ewt) on an error return, -1
otherwise.
'lenrw' the length of the double work array required.
'leniw' the length of integer work array required.
'mused' a vector of method indicators for each successful time step:
1: adams (nonstiff), 2: bdf (stiff)
======= ============================================================
Other Parameters
----------------
ml, mu : int, optional
If either of these are not None or non-negative, then the
Jacobian is assumed to be banded. These give the number of
lower and upper non-zero diagonals in this banded matrix.
For the banded case, `Dfun` should return a matrix whose
rows contain the non-zero bands (starting with the lowest diagonal).
Thus, the return matrix `jac` from `Dfun` should have shape
``(ml + mu + 1, len(y0))`` when ``ml >=0`` or ``mu >=0``.
The data in `jac` must be stored such that ``jac[i - j + mu, j]``
holds the derivative of the `i`th equation with respect to the `j`th
state variable. If `col_deriv` is True, the transpose of this
`jac` must be returned.
rtol, atol : float, optional
The input parameters `rtol` and `atol` determine the error
control performed by the solver. The solver will control the
vector, e, of estimated local errors in y, according to an
inequality of the form ``max-norm of (e / ewt) <= 1``,
where ewt is a vector of positive error weights computed as
``ewt = rtol * abs(y) + atol``.
rtol and atol can be either vectors the same length as y or scalars.
Defaults to 1.49012e-8.
tcrit : ndarray, optional
Vector of critical points (e.g. singularities) where integration
care should be taken.
h0 : float, (0: solver-determined), optional
The step size to be attempted on the first step.
hmax : float, (0: solver-determined), optional
The maximum absolute step size allowed.
hmin : float, (0: solver-determined), optional
The minimum absolute step size allowed.
ixpr : bool, optional
Whether to generate extra printing at method switches.
mxstep : int, (0: solver-determined), optional
Maximum number of (internally defined) steps allowed for each
integration point in t.
mxhnil : int, (0: solver-determined), optional
Maximum number of messages printed.
mxordn : int, (0: solver-determined), optional
Maximum order to be allowed for the non-stiff (Adams) method.
mxords : int, (0: solver-determined), optional
Maximum order to be allowed for the stiff (BDF) method.
See Also
--------
ode : a more object-oriented integrator based on VODE.
quad : for finding the area under a curve.
Examples
--------
The second order differential equation for the angle `theta` of a
pendulum acted on by gravity with friction can be written::
theta''(t) + b*theta'(t) + c*sin(theta(t)) = 0
where `b` and `c` are positive constants, and a prime (') denotes a
derivative. To solve this equation with `odeint`, we must first convert
it to a system of first order equations. By defining the angular
velocity ``omega(t) = theta'(t)``, we obtain the system::
theta'(t) = omega(t)
omega'(t) = -b*omega(t) - c*sin(theta(t))
Let `y` be the vector [`theta`, `omega`]. We implement this system
in python as:
>>> def pend(y, t, b, c):
... theta, omega = y
... dydt = [omega, -b*omega - c*np.sin(theta)]
... return dydt
...
We assume the constants are `b` = 0.25 and `c` = 5.0:
>>> b = 0.25
>>> c = 5.0
For initial conditions, we assume the pendulum is nearly vertical
with `theta(0)` = `pi` - 0.1, and it initially at rest, so
`omega(0)` = 0. Then the vector of initial conditions is
>>> y0 = [np.pi - 0.1, 0.0]
We generate a solution 101 evenly spaced samples in the interval
0 <= `t` <= 10. So our array of times is:
>>> t = np.linspace(0, 10, 101)
Call `odeint` to generate the solution. To pass the parameters
`b` and `c` to `pend`, we give them to `odeint` using the `args`
argument.
>>> from scipy.integrate import odeint
>>> sol = odeint(pend, y0, t, args=(b, c))
The solution is an array with shape (101, 2). The first column
is `theta(t)`, and the second is `omega(t)`. The following code
plots both components.
>>> import matplotlib.pyplot as plt
>>> plt.plot(t, sol[:, 0], 'b', label='theta(t)')
>>> plt.plot(t, sol[:, 1], 'g', label='omega(t)')
>>> plt.legend(loc='best')
>>> plt.xlabel('t')
>>> plt.grid()
>>> plt.show()
"""
if ml is None:
ml = -1 # changed to zero inside function call
if mu is None:
mu = -1 # changed to zero inside function call
t = copy(t)
y0 = copy(y0)
output = _odepack.odeint(func, y0, t, args, Dfun, col_deriv, ml, mu,
full_output, rtol, atol, tcrit, h0, hmax, hmin,
ixpr, mxstep, mxhnil, mxordn, mxords)
if output[-1] < 0:
warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information."
warnings.warn(warning_msg, ODEintWarning)
elif printmessg:
warning_msg = _msgs[output[-1]]
warnings.warn(warning_msg, ODEintWarning)
if full_output:
output[1]['message'] = _msgs[output[-1]]
output = output[:-1]
if len(output) == 1:
return output[0]
else:
return output
|
mit
|
[
3,
6529,
26,
12643,
5068,
593,
317,
838,
867,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
363,
452,
363,
275,
788,
380,
442,
418,
199,
199,
504,
1275,
492,
485,
380,
1389,
199,
504,
1331,
492,
1331,
199,
646,
3598,
199,
199,
533,
593,
1093,
442,
3849,
8,
3849,
304,
272,
986,
199,
199,
63,
13429,
275,
469,
18,
26,
298,
20405,
9512,
4765,
268,
413,
26,
298,
19627,
1990,
4224,
27,
314,
13150,
900,
1990,
378,
4765,
268,
446,
17,
26,
298,
920,
670,
1736,
4224,
641,
642,
1240,
334,
529,
17396,
6835,
577,
7036,
730,
680,
401,
268,
446,
18,
26,
298,
920,
670,
12862,
5839,
334,
16312,
83,
4634,
7425,
680,
401,
268,
446,
19,
26,
298,
25501,
1324,
10501,
334,
4672,
1125,
680,
401,
268,
446,
20,
26,
298,
19390,
1125,
511,
9081,
334,
4672,
1125,
680,
401,
268,
446,
21,
26,
298,
19390,
21346,
9081,
334,
529,
17396,
4875,
30633,
503,
13464,
83,
680,
401,
268,
446,
22,
26,
298,
547,
5401,
506,
27467,
4697,
5309,
5160,
4765,
268,
446,
23,
26,
298,
8405,
14466,
5261,
12983,
370,
9578,
334,
4672,
1125,
17617,
268,
789,
421,
199,
318,
312,
271,
442,
8,
1532,
12,
612,
16,
12,
307,
12,
1249,
16729,
577,
7036,
29,
403,
12,
1048,
63,
17922,
29,
16,
12,
2615,
63,
1199,
29,
16,
12,
1779,
19184,
29,
403,
12,
8504,
29,
403,
12,
10561,
29,
403,
12,
9543,
29,
403,
12,
307,
29506,
29,
403,
12,
394,
16,
29,
16,
14,
16,
12,
1779,
394,
988,
29,
16,
14,
16,
12,
394,
827,
29,
16,
14,
16,
12,
20593,
2700,
29,
16,
12,
8728,
2926,
29,
16,
12,
8728,
6164,
382,
29,
16,
12,
8728,
2181,
78,
29,
713,
12,
1779,
8728,
5630,
29,
21,
12,
870,
17091,
71,
29,
16,
304,
272,
408,
272,
8883,
14841,
282,
2656,
402,
24801,
31605,
26426,
14,
339,
428,
3344,
282,
2656,
402,
24801,
31605,
26426,
1808,
9100,
364,
65,
687,
314,
272,
2381,
17433,
3555,
312,
271,
1389,
14,
339,
17991,
2310,
314,
2536,
574,
5160,
367,
410,
15126,
503,
2222,
13,
270,
15126,
10460,
272,
402,
1642,
1865,
312,
271,
13,
83,
447,
398,
13119,
15,
3583,
275,
2562,
8,
89,
12,
307,
16,
12,
19172,
339,
2382,
612,
883,
506,
282,
5477,
14,
339,
627,
7443,
19429,
710,
1642,
2877,
2368,
402,
1124,
1532,
8,
89,
12,
307,
16,
12,
2263,
9719,
787,
315,
314,
272,
26912,
1865,
402,
314,
2368,
315,
314,
2656,
5492,
805,
1202,
272,
701,
314,
658,
14248,
14,
26248,
14,
380,
64,
1021,
14,
339,
3897,
272,
4143,
272,
2562,
520,
4550,
8,
89,
12,
307,
16,
12,
19172,
267,
28040,
314,
18883,
402,
612,
737,
307,
16,
14,
272,
612,
16,
520,
1625,
267,
6026,
5558,
641,
612,
334,
2425,
506,
282,
5477,
680,
272,
307,
520,
1625,
267,
437,
3414,
402,
900,
4501,
367,
1314,
370,
14241,
367,
612,
14,
221,
710,
2536,
267,
574,
2376,
1077,
506,
314,
1642,
1819,
402,
642,
3414,
14,
272,
1249,
520,
2008,
12,
2716,
267,
11177,
2368,
370,
986,
370,
805,
14,
272,
577,
7036,
520,
4550,
8,
89,
12,
307,
16,
12,
19172,
267,
19603,
334,
42,
22065,
9,
402,
658,
1532,
2313,
272,
1048,
63,
17922,
520,
2155,
12,
2716,
267,
715,
340,
658,
36,
7036,
64,
7890,
28059,
3224,
4362,
334,
70,
2311,
395,
267,
4257,
658,
36,
7036,
64,
1077,
5627,
28059,
9371,
4730,
14,
272,
2615,
63,
1199,
520,
2155,
12,
2716,
267,
715,
340,
370,
372,
282,
2600,
402,
2716,
4704,
465,
314,
3499,
1072,
272,
870,
17091,
71,
520,
2155,
12,
2716,
267,
7480,
370,
870,
314,
21346,
1245,
339,
1803,
272,
5514,
272,
612,
520,
1625,
12,
2215,
334,
552,
8,
84,
395,
822,
8,
89,
16,
430,
267,
8725,
3035,
314,
574,
402,
612,
367,
1924,
6387,
900,
315,
307,
12,
267,
543,
314,
2536,
574,
658,
89,
16,
64,
315,
314,
1642,
1962,
14,
272,
2256,
807,
520,
1211,
12,
1454,
2138,
340,
2615,
63,
1199,
508,
715,
267,
11932,
3035,
4722,
1072,
2556,
398,
9310,
389,
221,
19691,
21326,
267,
790,
420,
11150,
267,
9310,
389,
221,
19691,
21326,
267,
283,
10616,
7,
258,
5477,
402,
3650,
10627,
8792,
1202,
367,
1924,
900,
3650,
14,
267,
283,
84,
895,
7,
257,
5477,
543,
314,
574,
402,
307,
13075,
367,
1924,
900,
3650,
14,
326,
334,
14117,
3544,
506,
737,
5210,
465,
7031,
465,
314,
1324,
5431,
680,
267,
283,
84,
1446,
70,
7,
221,
5477,
402,
13464,
4666,
17704,
12,
8932,
2419,
413,
14,
16,
12,
326,
9235,
1380,
282,
1056,
367,
4634,
8298,
12862,
1990,
10501,
14,
267,
283,
1086,
87,
7,
259,
574,
402,
307,
737,
314,
900,
402,
314,
2061,
1083,
6258,
326,
334,
11809,
367,
1924,
900,
3650,
9,
267,
283,
78,
270,
7,
259,
25814,
1329,
402,
900,
7124,
267,
283,
78,
771,
7,
259,
25814,
1329,
402,
805,
8031,
1298,
367,
1924,
900,
3650,
267,
283,
78,
6532,
7,
259,
25814,
1329,
402,
1335,
22065,
8031,
1298,
367,
1924,
900,
3650,
267,
283,
78,
392,
7,
259,
282,
5477,
402,
1083,
15460,
367,
1924,
9512,
3650,
14,
267,
283,
1017,
32200,
7,
221,
1478,
402,
314,
3931,
402,
17451,
22877,
315,
314,
326,
14609,
2257,
1125,
5477,
334,
69,
1182,
325,
9115,
9,
641,
376,
1125,
372,
12,
446,
17,
326,
4257,
14,
267,
283,
552,
13057,
7,
221,
314,
2582,
402,
314,
4270,
1736,
1625,
1415,
14,
267,
283,
552,
73,
87,
7,
221,
314,
2582,
402,
3000,
1736,
1625,
1415,
14,
267,
283,
77,
2972,
7,
221,
282,
5477,
402,
1083,
7262,
2750,
367,
1924,
9512,
900,
3650,
26,
326,
413,
26,
1503,
19470,
334,
2865,
270,
15126,
395,
499,
26,
330,
1587,
334,
270,
15126,
9,
267,
9310,
389,
221,
19691,
21326,
339,
5439,
3897,
272,
10652,
272,
19184,
12,
8504,
520,
1109,
12,
2716,
267,
982,
1902,
402,
3520,
787,
440,
488,
503,
2222,
13,
7371,
12,
2066,
314,
267,
30633,
365,
10826,
370,
506,
330,
7028,
14,
221,
5723,
8120,
314,
1329,
402,
267,
5117,
436,
7008,
2222,
13
] |
[
6529,
26,
12643,
5068,
593,
317,
838,
867,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
363,
452,
363,
275,
788,
380,
442,
418,
199,
199,
504,
1275,
492,
485,
380,
1389,
199,
504,
1331,
492,
1331,
199,
646,
3598,
199,
199,
533,
593,
1093,
442,
3849,
8,
3849,
304,
272,
986,
199,
199,
63,
13429,
275,
469,
18,
26,
298,
20405,
9512,
4765,
268,
413,
26,
298,
19627,
1990,
4224,
27,
314,
13150,
900,
1990,
378,
4765,
268,
446,
17,
26,
298,
920,
670,
1736,
4224,
641,
642,
1240,
334,
529,
17396,
6835,
577,
7036,
730,
680,
401,
268,
446,
18,
26,
298,
920,
670,
12862,
5839,
334,
16312,
83,
4634,
7425,
680,
401,
268,
446,
19,
26,
298,
25501,
1324,
10501,
334,
4672,
1125,
680,
401,
268,
446,
20,
26,
298,
19390,
1125,
511,
9081,
334,
4672,
1125,
680,
401,
268,
446,
21,
26,
298,
19390,
21346,
9081,
334,
529,
17396,
4875,
30633,
503,
13464,
83,
680,
401,
268,
446,
22,
26,
298,
547,
5401,
506,
27467,
4697,
5309,
5160,
4765,
268,
446,
23,
26,
298,
8405,
14466,
5261,
12983,
370,
9578,
334,
4672,
1125,
17617,
268,
789,
421,
199,
318,
312,
271,
442,
8,
1532,
12,
612,
16,
12,
307,
12,
1249,
16729,
577,
7036,
29,
403,
12,
1048,
63,
17922,
29,
16,
12,
2615,
63,
1199,
29,
16,
12,
1779,
19184,
29,
403,
12,
8504,
29,
403,
12,
10561,
29,
403,
12,
9543,
29,
403,
12,
307,
29506,
29,
403,
12,
394,
16,
29,
16,
14,
16,
12,
1779,
394,
988,
29,
16,
14,
16,
12,
394,
827,
29,
16,
14,
16,
12,
20593,
2700,
29,
16,
12,
8728,
2926,
29,
16,
12,
8728,
6164,
382,
29,
16,
12,
8728,
2181,
78,
29,
713,
12,
1779,
8728,
5630,
29,
21,
12,
870,
17091,
71,
29,
16,
304,
272,
408,
272,
8883,
14841,
282,
2656,
402,
24801,
31605,
26426,
14,
339,
428,
3344,
282,
2656,
402,
24801,
31605,
26426,
1808,
9100,
364,
65,
687,
314,
272,
2381,
17433,
3555,
312,
271,
1389,
14,
339,
17991,
2310,
314,
2536,
574,
5160,
367,
410,
15126,
503,
2222,
13,
270,
15126,
10460,
272,
402,
1642,
1865,
312,
271,
13,
83,
447,
398,
13119,
15,
3583,
275,
2562,
8,
89,
12,
307,
16,
12,
19172,
339,
2382,
612,
883,
506,
282,
5477,
14,
339,
627,
7443,
19429,
710,
1642,
2877,
2368,
402,
1124,
1532,
8,
89,
12,
307,
16,
12,
2263,
9719,
787,
315,
314,
272,
26912,
1865,
402,
314,
2368,
315,
314,
2656,
5492,
805,
1202,
272,
701,
314,
658,
14248,
14,
26248,
14,
380,
64,
1021,
14,
339,
3897,
272,
4143,
272,
2562,
520,
4550,
8,
89,
12,
307,
16,
12,
19172,
267,
28040,
314,
18883,
402,
612,
737,
307,
16,
14,
272,
612,
16,
520,
1625,
267,
6026,
5558,
641,
612,
334,
2425,
506,
282,
5477,
680,
272,
307,
520,
1625,
267,
437,
3414,
402,
900,
4501,
367,
1314,
370,
14241,
367,
612,
14,
221,
710,
2536,
267,
574,
2376,
1077,
506,
314,
1642,
1819,
402,
642,
3414,
14,
272,
1249,
520,
2008,
12,
2716,
267,
11177,
2368,
370,
986,
370,
805,
14,
272,
577,
7036,
520,
4550,
8,
89,
12,
307,
16,
12,
19172,
267,
19603,
334,
42,
22065,
9,
402,
658,
1532,
2313,
272,
1048,
63,
17922,
520,
2155,
12,
2716,
267,
715,
340,
658,
36,
7036,
64,
7890,
28059,
3224,
4362,
334,
70,
2311,
395,
267,
4257,
658,
36,
7036,
64,
1077,
5627,
28059,
9371,
4730,
14,
272,
2615,
63,
1199,
520,
2155,
12,
2716,
267,
715,
340,
370,
372,
282,
2600,
402,
2716,
4704,
465,
314,
3499,
1072,
272,
870,
17091,
71,
520,
2155,
12,
2716,
267,
7480,
370,
870,
314,
21346,
1245,
339,
1803,
272,
5514,
272,
612,
520,
1625,
12,
2215,
334,
552,
8,
84,
395,
822,
8,
89,
16,
430,
267,
8725,
3035,
314,
574,
402,
612,
367,
1924,
6387,
900,
315,
307,
12,
267,
543,
314,
2536,
574,
658,
89,
16,
64,
315,
314,
1642,
1962,
14,
272,
2256,
807,
520,
1211,
12,
1454,
2138,
340,
2615,
63,
1199,
508,
715,
267,
11932,
3035,
4722,
1072,
2556,
398,
9310,
389,
221,
19691,
21326,
267,
790,
420,
11150,
267,
9310,
389,
221,
19691,
21326,
267,
283,
10616,
7,
258,
5477,
402,
3650,
10627,
8792,
1202,
367,
1924,
900,
3650,
14,
267,
283,
84,
895,
7,
257,
5477,
543,
314,
574,
402,
307,
13075,
367,
1924,
900,
3650,
14,
326,
334,
14117,
3544,
506,
737,
5210,
465,
7031,
465,
314,
1324,
5431,
680,
267,
283,
84,
1446,
70,
7,
221,
5477,
402,
13464,
4666,
17704,
12,
8932,
2419,
413,
14,
16,
12,
326,
9235,
1380,
282,
1056,
367,
4634,
8298,
12862,
1990,
10501,
14,
267,
283,
1086,
87,
7,
259,
574,
402,
307,
737,
314,
900,
402,
314,
2061,
1083,
6258,
326,
334,
11809,
367,
1924,
900,
3650,
9,
267,
283,
78,
270,
7,
259,
25814,
1329,
402,
900,
7124,
267,
283,
78,
771,
7,
259,
25814,
1329,
402,
805,
8031,
1298,
367,
1924,
900,
3650,
267,
283,
78,
6532,
7,
259,
25814,
1329,
402,
1335,
22065,
8031,
1298,
367,
1924,
900,
3650,
267,
283,
78,
392,
7,
259,
282,
5477,
402,
1083,
15460,
367,
1924,
9512,
3650,
14,
267,
283,
1017,
32200,
7,
221,
1478,
402,
314,
3931,
402,
17451,
22877,
315,
314,
326,
14609,
2257,
1125,
5477,
334,
69,
1182,
325,
9115,
9,
641,
376,
1125,
372,
12,
446,
17,
326,
4257,
14,
267,
283,
552,
13057,
7,
221,
314,
2582,
402,
314,
4270,
1736,
1625,
1415,
14,
267,
283,
552,
73,
87,
7,
221,
314,
2582,
402,
3000,
1736,
1625,
1415,
14,
267,
283,
77,
2972,
7,
221,
282,
5477,
402,
1083,
7262,
2750,
367,
1924,
9512,
900,
3650,
26,
326,
413,
26,
1503,
19470,
334,
2865,
270,
15126,
395,
499,
26,
330,
1587,
334,
270,
15126,
9,
267,
9310,
389,
221,
19691,
21326,
339,
5439,
3897,
272,
10652,
272,
19184,
12,
8504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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
] |
qPCR4vir/orange
|
Orange/orng/orngABCN2.py
|
6
|
1113
|
""" This module implements argument based rule learning.
The main learner class is ABCN2. The first few classes are some variants of ABCN2 with reasonable settings. """
from Orange.classification.rules import DefaultLearner
from Orange.classification.rules import ABCN2
from Orange.classification.rules import ABCN2Ordered
from Orange.classification.rules import ABCN2M
from Orange.classification.rules import ABBeamFilter
from Orange.classification.rules import CoversArguments
from Orange.classification.rules import SelectorAdder
from Orange.classification.rules import ArgFilter
from Orange.classification.rules import SelectorArgConditions
from Orange.classification.rules import CovererAndRemover_Prob
from Orange.classification.rules import avg
from Orange.classification.rules import var
from Orange.classification.rules import perc
from Orange.classification.rules import EVDFitter
from Orange.classification.rules import CrossValidation
from Orange.classification.rules import PILAR
from Orange.classification.rules import CN2UnorderedClassifier
from orngABML import *
#print createDichotomousClass
|
gpl-3.0
|
[
624,
961,
859,
9031,
1423,
4079,
2332,
9328,
14,
199,
1918,
2446,
22876,
1021,
365,
17281,
46,
18,
14,
710,
1642,
9284,
3992,
787,
2005,
21169,
402,
17281,
46,
18,
543,
23255,
2202,
14,
221,
408,
421,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3758,
21424,
281,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
22567,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
45,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
14840,
3655,
455,
4131,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1849,
14895,
14517,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3240,
3283,
2767,
424,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
29560,
4131,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3240,
3283,
6373,
23107,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1849,
432,
3859,
3325,
497,
573,
422,
63,
20122,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
12402,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
2729,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1126,
67,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
30069,
3888,
390,
351,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
28965,
13816,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
14937,
689,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
445,
46,
18,
1358,
8235,
8508,
199,
504,
503,
2753,
1217,
1698,
492,
627,
199,
199,
3,
1361,
1218,
36,
1158,
3459,
7376,
2543,
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
] |
[
961,
859,
9031,
1423,
4079,
2332,
9328,
14,
199,
1918,
2446,
22876,
1021,
365,
17281,
46,
18,
14,
710,
1642,
9284,
3992,
787,
2005,
21169,
402,
17281,
46,
18,
543,
23255,
2202,
14,
221,
408,
421,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3758,
21424,
281,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
22567,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
17281,
46,
18,
45,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
14840,
3655,
455,
4131,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1849,
14895,
14517,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3240,
3283,
2767,
424,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
29560,
4131,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
3240,
3283,
6373,
23107,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1849,
432,
3859,
3325,
497,
573,
422,
63,
20122,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
12402,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
2729,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
1126,
67,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
30069,
3888,
390,
351,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
28965,
13816,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
14937,
689,
199,
504,
593,
1842,
14,
14368,
14,
4423,
492,
445,
46,
18,
1358,
8235,
8508,
199,
504,
503,
2753,
1217,
1698,
492,
627,
199,
199,
3,
1361,
1218,
36,
1158,
3459,
7376,
2543,
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,
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,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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
] |
raytung/Slice
|
account/hooks.py
|
1
|
2621
|
import hashlib
import random
from django.core.mail import send_mail
from django.template.loader import render_to_string
from account.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
class AccountDefaultHookSet(object):
def send_invitation_email(self, to, ctx):
subject = render_to_string("account/email/invite_user_subject.txt", ctx)
message = render_to_string("account/email/invite_user.txt", ctx)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, to)
def send_confirmation_email(self, to, ctx):
subject = render_to_string("account/email/email_confirmation_subject.txt", ctx)
subject = "".join(subject.splitlines()) # remove superfluous line breaks
message = render_to_string("account/email/email_confirmation_message.txt", ctx)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, to)
def send_password_change_email(self, to, ctx):
subject = render_to_string("account/email/password_change_subject.txt", ctx)
subject = "".join(subject.splitlines())
message = render_to_string("account/email/password_change.txt", ctx)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, to)
def send_password_reset_email(self, to, ctx):
subject = render_to_string("account/email/password_reset_subject.txt", ctx)
subject = "".join(subject.splitlines())
message = render_to_string("account/email/password_reset.txt", ctx)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, to)
def generate_random_token(self, extra=None, hash_func=hashlib.sha256):
if extra is None:
extra = []
bits = extra + [str(random.SystemRandom().getrandbits(512))]
return hash_func("".join(bits).encode("utf-8")).hexdigest()
def generate_signup_code_token(self, email=None):
return self.generate_random_token([email])
def generate_email_confirmation_token(self, email):
return self.generate_random_token([email])
def get_user_credentials(self, form, identifier_field):
try:
username = User.objects.get(email=form.cleaned_data[identifier_field])
username = username.username
except ObjectDoesNotExist:
username = form.cleaned_data[identifier_field]
return {
"username": username,
"password": form.cleaned_data["password"],
}
class HookProxy(object):
def __getattr__(self, attr):
return getattr(settings.ACCOUNT_HOOKSET, attr)
hookset = HookProxy()
|
mit
|
[
646,
8337,
199,
646,
2196,
199,
199,
504,
1639,
14,
1018,
14,
1198,
492,
3222,
63,
1198,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
199,
504,
2933,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
421,
199,
533,
9973,
2698,
8481,
1084,
8,
785,
304,
339,
347,
3222,
63,
5350,
5314,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
19061,
63,
751,
63,
5875,
14,
2424,
401,
4027,
9,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
19061,
63,
751,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
20903,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2123,
63,
20903,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
327,
2813,
1613,
2327,
7514,
1004,
18277,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2123,
63,
20903,
63,
1188,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
2060,
63,
1461,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
1461,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
1461,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
2060,
63,
3958,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
3958,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
3958,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3550,
63,
2355,
63,
1418,
8,
277,
12,
2402,
29,
403,
12,
2631,
63,
1532,
29,
24722,
14,
4835,
3912,
304,
267,
340,
2402,
365,
488,
26,
288,
2402,
275,
942,
267,
5821,
275,
2402,
435,
359,
495,
8,
2355,
14,
3989,
3883,
1252,
362,
3759,
5609,
8,
7736,
10524,
267,
372,
2631,
63,
1532,
31059,
904,
8,
5609,
680,
2143,
480,
1624,
13,
24,
21688,
11453,
342,
339,
347,
3550,
63,
19799,
63,
600,
63,
1418,
8,
277,
12,
3031,
29,
403,
304,
267,
372,
291,
14,
4208,
63,
2355,
63,
1418,
779,
2123,
566,
339,
347,
3550,
63,
2123,
63,
20903,
63,
1418,
8,
277,
12,
3031,
304,
267,
372,
291,
14,
4208,
63,
2355,
63,
1418,
779,
2123,
566,
339,
347,
664,
63,
751,
63,
6942,
8,
277,
12,
1824,
12,
5148,
63,
698,
304,
267,
862,
26,
288,
3434,
275,
2876,
14,
1462,
14,
362,
8,
2123,
29,
964,
14,
8275,
63,
576,
59,
5364,
63,
698,
566,
288,
3434,
275,
3434,
14,
2473,
267,
871,
24803,
26,
288,
3434,
275,
1824,
14,
8275,
63,
576,
59,
5364,
63,
698,
61,
267,
372,
469,
288,
298,
2473,
582,
3434,
12,
288,
298,
2060,
582,
1824,
14,
8275,
63,
576,
905,
2060,
2255,
267,
789,
421,
199,
533,
24837,
4936,
8,
785,
304,
339,
347,
636,
5675,
721,
277,
12,
1921,
304,
267,
372,
2519,
8,
1751,
14,
18928,
63,
28706,
3597,
12,
1921,
9,
421,
199,
3664,
409,
275,
24837,
4936,
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
] |
[
8337,
199,
646,
2196,
199,
199,
504,
1639,
14,
1018,
14,
1198,
492,
3222,
63,
1198,
199,
504,
1639,
14,
1160,
14,
3422,
492,
3795,
63,
475,
63,
875,
199,
199,
504,
2933,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
421,
199,
533,
9973,
2698,
8481,
1084,
8,
785,
304,
339,
347,
3222,
63,
5350,
5314,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
19061,
63,
751,
63,
5875,
14,
2424,
401,
4027,
9,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
19061,
63,
751,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
20903,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2123,
63,
20903,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
327,
2813,
1613,
2327,
7514,
1004,
18277,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2123,
63,
20903,
63,
1188,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
2060,
63,
1461,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
1461,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
1461,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3222,
63,
2060,
63,
3958,
63,
2123,
8,
277,
12,
370,
12,
4027,
304,
267,
5420,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
3958,
63,
5875,
14,
2424,
401,
4027,
9,
267,
5420,
275,
10587,
904,
8,
5875,
14,
7644,
1012,
267,
1245,
275,
3795,
63,
475,
63,
875,
480,
2048,
15,
2123,
15,
2060,
63,
3958,
14,
2424,
401,
4027,
9,
267,
3222,
63,
1198,
8,
5875,
12,
1245,
12,
2202,
14,
3472,
63,
12491,
63,
10089,
12,
370,
9,
339,
347,
3550,
63,
2355,
63,
1418,
8,
277,
12,
2402,
29,
403,
12,
2631,
63,
1532,
29,
24722,
14,
4835,
3912,
304,
267,
340,
2402,
365,
488,
26,
288,
2402,
275,
942,
267,
5821,
275,
2402,
435,
359,
495,
8,
2355,
14,
3989,
3883,
1252,
362,
3759,
5609,
8,
7736,
10524,
267,
372,
2631,
63,
1532,
31059,
904,
8,
5609,
680,
2143,
480,
1624,
13,
24,
21688,
11453,
342,
339,
347,
3550,
63,
19799,
63,
600,
63,
1418,
8,
277,
12,
3031,
29,
403,
304,
267,
372,
291,
14,
4208,
63,
2355,
63,
1418,
779,
2123,
566,
339,
347,
3550,
63,
2123,
63,
20903,
63,
1418,
8,
277,
12,
3031,
304,
267,
372,
291,
14,
4208,
63,
2355,
63,
1418,
779,
2123,
566,
339,
347,
664,
63,
751,
63,
6942,
8,
277,
12,
1824,
12,
5148,
63,
698,
304,
267,
862,
26,
288,
3434,
275,
2876,
14,
1462,
14,
362,
8,
2123,
29,
964,
14,
8275,
63,
576,
59,
5364,
63,
698,
566,
288,
3434,
275,
3434,
14,
2473,
267,
871,
24803,
26,
288,
3434,
275,
1824,
14,
8275,
63,
576,
59,
5364,
63,
698,
61,
267,
372,
469,
288,
298,
2473,
582,
3434,
12,
288,
298,
2060,
582,
1824,
14,
8275,
63,
576,
905,
2060,
2255,
267,
789,
421,
199,
533,
24837,
4936,
8,
785,
304,
339,
347,
636,
5675,
721,
277,
12,
1921,
304,
267,
372,
2519,
8,
1751,
14,
18928,
63,
28706,
3597,
12,
1921,
9,
421,
199,
3664,
409,
275,
24837,
4936,
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,
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,
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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
] |
AMOboxTV/AMOBox.LegoBuild
|
script.module.unidecode/lib/unidecode/x0ad.py
|
253
|
4766
|
data = (
'gwan', # 0x00
'gwanj', # 0x01
'gwanh', # 0x02
'gwad', # 0x03
'gwal', # 0x04
'gwalg', # 0x05
'gwalm', # 0x06
'gwalb', # 0x07
'gwals', # 0x08
'gwalt', # 0x09
'gwalp', # 0x0a
'gwalh', # 0x0b
'gwam', # 0x0c
'gwab', # 0x0d
'gwabs', # 0x0e
'gwas', # 0x0f
'gwass', # 0x10
'gwang', # 0x11
'gwaj', # 0x12
'gwac', # 0x13
'gwak', # 0x14
'gwat', # 0x15
'gwap', # 0x16
'gwah', # 0x17
'gwae', # 0x18
'gwaeg', # 0x19
'gwaegg', # 0x1a
'gwaegs', # 0x1b
'gwaen', # 0x1c
'gwaenj', # 0x1d
'gwaenh', # 0x1e
'gwaed', # 0x1f
'gwael', # 0x20
'gwaelg', # 0x21
'gwaelm', # 0x22
'gwaelb', # 0x23
'gwaels', # 0x24
'gwaelt', # 0x25
'gwaelp', # 0x26
'gwaelh', # 0x27
'gwaem', # 0x28
'gwaeb', # 0x29
'gwaebs', # 0x2a
'gwaes', # 0x2b
'gwaess', # 0x2c
'gwaeng', # 0x2d
'gwaej', # 0x2e
'gwaec', # 0x2f
'gwaek', # 0x30
'gwaet', # 0x31
'gwaep', # 0x32
'gwaeh', # 0x33
'goe', # 0x34
'goeg', # 0x35
'goegg', # 0x36
'goegs', # 0x37
'goen', # 0x38
'goenj', # 0x39
'goenh', # 0x3a
'goed', # 0x3b
'goel', # 0x3c
'goelg', # 0x3d
'goelm', # 0x3e
'goelb', # 0x3f
'goels', # 0x40
'goelt', # 0x41
'goelp', # 0x42
'goelh', # 0x43
'goem', # 0x44
'goeb', # 0x45
'goebs', # 0x46
'goes', # 0x47
'goess', # 0x48
'goeng', # 0x49
'goej', # 0x4a
'goec', # 0x4b
'goek', # 0x4c
'goet', # 0x4d
'goep', # 0x4e
'goeh', # 0x4f
'gyo', # 0x50
'gyog', # 0x51
'gyogg', # 0x52
'gyogs', # 0x53
'gyon', # 0x54
'gyonj', # 0x55
'gyonh', # 0x56
'gyod', # 0x57
'gyol', # 0x58
'gyolg', # 0x59
'gyolm', # 0x5a
'gyolb', # 0x5b
'gyols', # 0x5c
'gyolt', # 0x5d
'gyolp', # 0x5e
'gyolh', # 0x5f
'gyom', # 0x60
'gyob', # 0x61
'gyobs', # 0x62
'gyos', # 0x63
'gyoss', # 0x64
'gyong', # 0x65
'gyoj', # 0x66
'gyoc', # 0x67
'gyok', # 0x68
'gyot', # 0x69
'gyop', # 0x6a
'gyoh', # 0x6b
'gu', # 0x6c
'gug', # 0x6d
'gugg', # 0x6e
'gugs', # 0x6f
'gun', # 0x70
'gunj', # 0x71
'gunh', # 0x72
'gud', # 0x73
'gul', # 0x74
'gulg', # 0x75
'gulm', # 0x76
'gulb', # 0x77
'guls', # 0x78
'gult', # 0x79
'gulp', # 0x7a
'gulh', # 0x7b
'gum', # 0x7c
'gub', # 0x7d
'gubs', # 0x7e
'gus', # 0x7f
'guss', # 0x80
'gung', # 0x81
'guj', # 0x82
'guc', # 0x83
'guk', # 0x84
'gut', # 0x85
'gup', # 0x86
'guh', # 0x87
'gweo', # 0x88
'gweog', # 0x89
'gweogg', # 0x8a
'gweogs', # 0x8b
'gweon', # 0x8c
'gweonj', # 0x8d
'gweonh', # 0x8e
'gweod', # 0x8f
'gweol', # 0x90
'gweolg', # 0x91
'gweolm', # 0x92
'gweolb', # 0x93
'gweols', # 0x94
'gweolt', # 0x95
'gweolp', # 0x96
'gweolh', # 0x97
'gweom', # 0x98
'gweob', # 0x99
'gweobs', # 0x9a
'gweos', # 0x9b
'gweoss', # 0x9c
'gweong', # 0x9d
'gweoj', # 0x9e
'gweoc', # 0x9f
'gweok', # 0xa0
'gweot', # 0xa1
'gweop', # 0xa2
'gweoh', # 0xa3
'gwe', # 0xa4
'gweg', # 0xa5
'gwegg', # 0xa6
'gwegs', # 0xa7
'gwen', # 0xa8
'gwenj', # 0xa9
'gwenh', # 0xaa
'gwed', # 0xab
'gwel', # 0xac
'gwelg', # 0xad
'gwelm', # 0xae
'gwelb', # 0xaf
'gwels', # 0xb0
'gwelt', # 0xb1
'gwelp', # 0xb2
'gwelh', # 0xb3
'gwem', # 0xb4
'gweb', # 0xb5
'gwebs', # 0xb6
'gwes', # 0xb7
'gwess', # 0xb8
'gweng', # 0xb9
'gwej', # 0xba
'gwec', # 0xbb
'gwek', # 0xbc
'gwet', # 0xbd
'gwep', # 0xbe
'gweh', # 0xbf
'gwi', # 0xc0
'gwig', # 0xc1
'gwigg', # 0xc2
'gwigs', # 0xc3
'gwin', # 0xc4
'gwinj', # 0xc5
'gwinh', # 0xc6
'gwid', # 0xc7
'gwil', # 0xc8
'gwilg', # 0xc9
'gwilm', # 0xca
'gwilb', # 0xcb
'gwils', # 0xcc
'gwilt', # 0xcd
'gwilp', # 0xce
'gwilh', # 0xcf
'gwim', # 0xd0
'gwib', # 0xd1
'gwibs', # 0xd2
'gwis', # 0xd3
'gwiss', # 0xd4
'gwing', # 0xd5
'gwij', # 0xd6
'gwic', # 0xd7
'gwik', # 0xd8
'gwit', # 0xd9
'gwip', # 0xda
'gwih', # 0xdb
'gyu', # 0xdc
'gyug', # 0xdd
'gyugg', # 0xde
'gyugs', # 0xdf
'gyun', # 0xe0
'gyunj', # 0xe1
'gyunh', # 0xe2
'gyud', # 0xe3
'gyul', # 0xe4
'gyulg', # 0xe5
'gyulm', # 0xe6
'gyulb', # 0xe7
'gyuls', # 0xe8
'gyult', # 0xe9
'gyulp', # 0xea
'gyulh', # 0xeb
'gyum', # 0xec
'gyub', # 0xed
'gyubs', # 0xee
'gyus', # 0xef
'gyuss', # 0xf0
'gyung', # 0xf1
'gyuj', # 0xf2
'gyuc', # 0xf3
'gyuk', # 0xf4
'gyut', # 0xf5
'gyup', # 0xf6
'gyuh', # 0xf7
'geu', # 0xf8
'geug', # 0xf9
'geugg', # 0xfa
'geugs', # 0xfb
'geun', # 0xfc
'geunj', # 0xfd
'geunh', # 0xfe
'geud', # 0xff
)
|
gpl-2.0
|
[
576,
275,
334,
199,
7,
8392,
290,
297,
259,
327,
378,
88,
383,
199,
7,
8392,
290,
74,
297,
259,
327,
378,
88,
614,
199,
7,
8392,
290,
72,
297,
259,
327,
378,
88,
996,
199,
7,
8392,
350,
297,
259,
327,
378,
88,
1644,
199,
7,
8392,
279,
297,
259,
327,
378,
88,
966,
199,
7,
8392,
6731,
297,
259,
327,
378,
88,
1717,
199,
7,
8392,
279,
77,
297,
259,
327,
378,
88,
1690,
199,
7,
8392,
279,
66,
297,
259,
327,
378,
88,
1780,
199,
7,
8392,
2551,
297,
259,
327,
378,
88,
2036,
199,
7,
8392,
4478,
297,
259,
327,
378,
88,
1643,
199,
7,
8392,
279,
80,
297,
259,
327,
378,
88,
16,
65,
199,
7,
8392,
279,
72,
297,
259,
327,
378,
88,
16,
66,
199,
7,
8392,
455,
297,
259,
327,
378,
88,
16,
67,
199,
7,
8392,
371,
297,
259,
327,
378,
88,
16,
68,
199,
7,
8392,
2101,
297,
259,
327,
378,
88,
16,
69,
199,
7,
8392,
305,
297,
259,
327,
378,
88,
16,
70,
199,
7,
8392,
405,
297,
259,
327,
378,
88,
709,
199,
7,
8392,
621,
297,
259,
327,
378,
88,
845,
199,
7,
71,
758,
74,
297,
259,
327,
378,
88,
713,
199,
7,
8392,
645,
297,
259,
327,
378,
88,
969,
199,
7,
71,
758,
75,
297,
259,
327,
378,
88,
1079,
199,
7,
8392,
292,
297,
259,
327,
378,
88,
1046,
199,
7,
8392,
439,
297,
259,
327,
378,
88,
975,
199,
7,
71,
758,
72,
297,
259,
327,
378,
88,
1196,
199,
7,
71,
758,
69,
297,
259,
327,
378,
88,
1085,
199,
7,
71,
758,
5902,
297,
259,
327,
378,
88,
1167,
199,
7,
71,
758,
5799,
297,
259,
327,
378,
88,
17,
65,
199,
7,
71,
758,
69,
458,
297,
259,
327,
378,
88,
17,
66,
199,
7,
71,
758,
287,
297,
259,
327,
378,
88,
17,
67,
199,
7,
71,
758,
287,
74,
297,
259,
327,
378,
88,
17,
68,
199,
7,
71,
758,
287,
72,
297,
259,
327,
378,
88,
17,
69,
199,
7,
71,
758,
379,
297,
259,
327,
378,
88,
17,
70,
199,
7,
71,
758,
352,
297,
259,
327,
378,
88,
1165,
199,
7,
71,
758,
352,
71,
297,
259,
327,
378,
88,
2025,
199,
7,
71,
758,
21226,
297,
259,
327,
378,
88,
1081,
199,
7,
71,
758,
17778,
297,
259,
327,
378,
88,
1789,
199,
7,
71,
758,
18099,
297,
259,
327,
378,
88,
1194,
199,
7,
71,
758,
15330,
297,
259,
327,
378,
88,
821,
199,
7,
71,
758,
1357,
297,
259,
327,
378,
88,
1479,
199,
7,
71,
758,
352,
72,
297,
259,
327,
378,
88,
1465,
199,
7,
71,
758,
5633,
297,
259,
327,
378,
88,
1651,
199,
7,
71,
758,
2871,
297,
259,
327,
378,
88,
1398,
199,
7,
71,
758,
69,
1533,
297,
259,
327,
378,
88,
18,
65,
199,
7,
71,
758,
397,
297,
259,
327,
378,
88,
18,
66,
199,
7,
71,
758,
16709,
297,
259,
327,
378,
88,
18,
67,
199,
7,
71,
758,
7420,
297,
259,
327,
378,
88,
18,
68,
199,
7,
71,
758,
69,
74,
297,
259,
327,
378,
88,
18,
69,
199,
7,
71,
758,
825,
297,
259,
327,
378,
88,
18,
70,
199,
7,
71,
758,
5711,
297,
259,
327,
378,
88,
1216,
199,
7,
71,
758,
386,
297,
259,
327,
378,
88,
2192,
199,
7,
71,
758,
1545,
297,
259,
327,
378,
88,
708,
199,
7,
71,
758,
24528,
297,
259,
327,
378,
88,
1153,
199,
7,
1939,
69,
297,
259,
327,
378,
88,
1082,
199,
7,
1939,
5902,
297,
259,
327,
378,
88,
1276,
199,
7,
1939,
5799,
297,
259,
327,
378,
88,
1344,
199,
7,
1939,
69,
458,
297,
259,
327,
378,
88,
1401,
199,
7,
1939,
287,
297,
259,
327,
378,
88,
1703,
199,
7,
1939,
287,
74,
297,
259,
327,
378,
88,
1355,
199,
7,
1939,
287,
72,
297,
259,
327,
378,
88,
19,
65,
199,
7,
1939,
379,
297,
259,
327,
378,
88,
19,
66,
199,
7,
1939,
352,
297,
259,
327,
378,
88,
19,
67,
199,
7,
1939,
352,
71,
297,
259,
327,
378,
88,
19,
68,
199,
7,
1939,
21226,
297,
259,
327,
378,
88,
19,
69,
199,
7,
1939,
17778,
297,
259,
327,
378,
88,
19,
70,
199,
7,
1939,
18099,
297,
259,
327,
378,
88,
2167,
199,
7,
1939,
15330,
297,
259,
327,
378,
88,
2953,
199,
7,
1939,
1357,
297,
259,
327,
378,
88,
2260,
199,
7,
1939,
352,
72,
297,
259,
327,
378,
88,
2824,
199,
7,
1939,
5633,
297,
259,
327,
378,
88,
1602,
199,
7,
1939,
2871,
297,
259,
327,
378,
88,
2322,
199,
7,
1939,
69,
1533,
297,
259,
327,
378,
88,
2466,
199,
7,
1939,
397,
297,
259,
327,
378,
88,
2417,
199,
7,
1939,
16709,
297,
259,
327,
378,
88,
2006,
199,
7,
1939,
7420,
297,
259,
327,
378,
88,
1887,
199,
7,
1939,
69,
74,
297,
259,
327,
378,
88,
20,
65,
199,
7,
1939,
825,
297,
259,
327,
378,
88,
20,
66,
199,
7,
1939,
5711,
297,
259,
327,
378,
88,
20,
67,
199,
7,
1939,
386,
297,
259,
327,
378,
88,
20,
68,
199,
7,
1939,
1545,
297,
259,
327,
378,
88,
20,
69,
199,
7,
1939,
24528,
297,
259,
327,
378,
88,
20,
70,
199,
7,
4312,
79,
297,
259,
327,
378,
88,
1400,
199,
7,
4312,
974,
297,
259,
327,
378,
88,
2869,
199,
7,
4312,
24798,
297,
259,
327,
378,
88,
2528,
199,
7,
4312,
79,
458,
297,
259,
327,
378,
88,
2481,
199,
7,
4312,
265,
297,
259,
327,
378,
88,
1477,
199,
7,
4312,
265,
74,
297,
259,
327,
378,
88,
1229,
199,
7,
4312,
265,
72,
297,
259,
327,
378,
88,
1367,
199,
7,
4312,
364,
297,
259,
327,
378,
88,
1641,
199,
7,
4312,
393,
297,
259,
327,
378,
88,
2010,
199,
7,
4312,
393,
71,
297,
259,
327,
378,
88,
1427,
199,
7,
4312,
393,
77,
297,
259,
327,
378,
88,
21,
65,
199,
7,
4312,
393,
66,
297,
259,
327,
378,
88,
21,
66,
199,
7,
4312,
1446,
297,
259,
327,
378,
88,
21,
67,
199
] |
[
275,
334,
199,
7,
8392,
290,
297,
259,
327,
378,
88,
383,
199,
7,
8392,
290,
74,
297,
259,
327,
378,
88,
614,
199,
7,
8392,
290,
72,
297,
259,
327,
378,
88,
996,
199,
7,
8392,
350,
297,
259,
327,
378,
88,
1644,
199,
7,
8392,
279,
297,
259,
327,
378,
88,
966,
199,
7,
8392,
6731,
297,
259,
327,
378,
88,
1717,
199,
7,
8392,
279,
77,
297,
259,
327,
378,
88,
1690,
199,
7,
8392,
279,
66,
297,
259,
327,
378,
88,
1780,
199,
7,
8392,
2551,
297,
259,
327,
378,
88,
2036,
199,
7,
8392,
4478,
297,
259,
327,
378,
88,
1643,
199,
7,
8392,
279,
80,
297,
259,
327,
378,
88,
16,
65,
199,
7,
8392,
279,
72,
297,
259,
327,
378,
88,
16,
66,
199,
7,
8392,
455,
297,
259,
327,
378,
88,
16,
67,
199,
7,
8392,
371,
297,
259,
327,
378,
88,
16,
68,
199,
7,
8392,
2101,
297,
259,
327,
378,
88,
16,
69,
199,
7,
8392,
305,
297,
259,
327,
378,
88,
16,
70,
199,
7,
8392,
405,
297,
259,
327,
378,
88,
709,
199,
7,
8392,
621,
297,
259,
327,
378,
88,
845,
199,
7,
71,
758,
74,
297,
259,
327,
378,
88,
713,
199,
7,
8392,
645,
297,
259,
327,
378,
88,
969,
199,
7,
71,
758,
75,
297,
259,
327,
378,
88,
1079,
199,
7,
8392,
292,
297,
259,
327,
378,
88,
1046,
199,
7,
8392,
439,
297,
259,
327,
378,
88,
975,
199,
7,
71,
758,
72,
297,
259,
327,
378,
88,
1196,
199,
7,
71,
758,
69,
297,
259,
327,
378,
88,
1085,
199,
7,
71,
758,
5902,
297,
259,
327,
378,
88,
1167,
199,
7,
71,
758,
5799,
297,
259,
327,
378,
88,
17,
65,
199,
7,
71,
758,
69,
458,
297,
259,
327,
378,
88,
17,
66,
199,
7,
71,
758,
287,
297,
259,
327,
378,
88,
17,
67,
199,
7,
71,
758,
287,
74,
297,
259,
327,
378,
88,
17,
68,
199,
7,
71,
758,
287,
72,
297,
259,
327,
378,
88,
17,
69,
199,
7,
71,
758,
379,
297,
259,
327,
378,
88,
17,
70,
199,
7,
71,
758,
352,
297,
259,
327,
378,
88,
1165,
199,
7,
71,
758,
352,
71,
297,
259,
327,
378,
88,
2025,
199,
7,
71,
758,
21226,
297,
259,
327,
378,
88,
1081,
199,
7,
71,
758,
17778,
297,
259,
327,
378,
88,
1789,
199,
7,
71,
758,
18099,
297,
259,
327,
378,
88,
1194,
199,
7,
71,
758,
15330,
297,
259,
327,
378,
88,
821,
199,
7,
71,
758,
1357,
297,
259,
327,
378,
88,
1479,
199,
7,
71,
758,
352,
72,
297,
259,
327,
378,
88,
1465,
199,
7,
71,
758,
5633,
297,
259,
327,
378,
88,
1651,
199,
7,
71,
758,
2871,
297,
259,
327,
378,
88,
1398,
199,
7,
71,
758,
69,
1533,
297,
259,
327,
378,
88,
18,
65,
199,
7,
71,
758,
397,
297,
259,
327,
378,
88,
18,
66,
199,
7,
71,
758,
16709,
297,
259,
327,
378,
88,
18,
67,
199,
7,
71,
758,
7420,
297,
259,
327,
378,
88,
18,
68,
199,
7,
71,
758,
69,
74,
297,
259,
327,
378,
88,
18,
69,
199,
7,
71,
758,
825,
297,
259,
327,
378,
88,
18,
70,
199,
7,
71,
758,
5711,
297,
259,
327,
378,
88,
1216,
199,
7,
71,
758,
386,
297,
259,
327,
378,
88,
2192,
199,
7,
71,
758,
1545,
297,
259,
327,
378,
88,
708,
199,
7,
71,
758,
24528,
297,
259,
327,
378,
88,
1153,
199,
7,
1939,
69,
297,
259,
327,
378,
88,
1082,
199,
7,
1939,
5902,
297,
259,
327,
378,
88,
1276,
199,
7,
1939,
5799,
297,
259,
327,
378,
88,
1344,
199,
7,
1939,
69,
458,
297,
259,
327,
378,
88,
1401,
199,
7,
1939,
287,
297,
259,
327,
378,
88,
1703,
199,
7,
1939,
287,
74,
297,
259,
327,
378,
88,
1355,
199,
7,
1939,
287,
72,
297,
259,
327,
378,
88,
19,
65,
199,
7,
1939,
379,
297,
259,
327,
378,
88,
19,
66,
199,
7,
1939,
352,
297,
259,
327,
378,
88,
19,
67,
199,
7,
1939,
352,
71,
297,
259,
327,
378,
88,
19,
68,
199,
7,
1939,
21226,
297,
259,
327,
378,
88,
19,
69,
199,
7,
1939,
17778,
297,
259,
327,
378,
88,
19,
70,
199,
7,
1939,
18099,
297,
259,
327,
378,
88,
2167,
199,
7,
1939,
15330,
297,
259,
327,
378,
88,
2953,
199,
7,
1939,
1357,
297,
259,
327,
378,
88,
2260,
199,
7,
1939,
352,
72,
297,
259,
327,
378,
88,
2824,
199,
7,
1939,
5633,
297,
259,
327,
378,
88,
1602,
199,
7,
1939,
2871,
297,
259,
327,
378,
88,
2322,
199,
7,
1939,
69,
1533,
297,
259,
327,
378,
88,
2466,
199,
7,
1939,
397,
297,
259,
327,
378,
88,
2417,
199,
7,
1939,
16709,
297,
259,
327,
378,
88,
2006,
199,
7,
1939,
7420,
297,
259,
327,
378,
88,
1887,
199,
7,
1939,
69,
74,
297,
259,
327,
378,
88,
20,
65,
199,
7,
1939,
825,
297,
259,
327,
378,
88,
20,
66,
199,
7,
1939,
5711,
297,
259,
327,
378,
88,
20,
67,
199,
7,
1939,
386,
297,
259,
327,
378,
88,
20,
68,
199,
7,
1939,
1545,
297,
259,
327,
378,
88,
20,
69,
199,
7,
1939,
24528,
297,
259,
327,
378,
88,
20,
70,
199,
7,
4312,
79,
297,
259,
327,
378,
88,
1400,
199,
7,
4312,
974,
297,
259,
327,
378,
88,
2869,
199,
7,
4312,
24798,
297,
259,
327,
378,
88,
2528,
199,
7,
4312,
79,
458,
297,
259,
327,
378,
88,
2481,
199,
7,
4312,
265,
297,
259,
327,
378,
88,
1477,
199,
7,
4312,
265,
74,
297,
259,
327,
378,
88,
1229,
199,
7,
4312,
265,
72,
297,
259,
327,
378,
88,
1367,
199,
7,
4312,
364,
297,
259,
327,
378,
88,
1641,
199,
7,
4312,
393,
297,
259,
327,
378,
88,
2010,
199,
7,
4312,
393,
71,
297,
259,
327,
378,
88,
1427,
199,
7,
4312,
393,
77,
297,
259,
327,
378,
88,
21,
65,
199,
7,
4312,
393,
66,
297,
259,
327,
378,
88,
21,
66,
199,
7,
4312,
1446,
297,
259,
327,
378,
88,
21,
67,
199,
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,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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
] |
UnrememberMe/pants
|
migrations/options/src/python/migrate_config.py
|
10
|
5076
|
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
import sys
from colors import cyan, green, red, yellow
from pants.option import custom_types
from pants.option.config import Config
from pants.option.errors import ParseError
migrations = {
# E.g.:
#('backends', 'packages'): ('DEFAULT', 'backend_packages'),
#('unknown-arguments', 'ignored'): None,
('gen', 'thrift'): ('gen', 'thrift-java'),
}
notes = {
# E.g.:
#('jvm', 'debug_port'): 'For now must be defined for each JvmTask subtask separately. Will soon '
# 'move to a subsystem, which will fix this requirement.',
}
def check_option(cp, src, dst):
def has_explicit_option(section, key):
# David tried to avoid poking into cp's guts in https://rbcommons.com/s/twitter/r/1451/ but
# that approach fails for the important case of boolean options. Since this is a ~short term
# tool and its highly likely its lifetime will be shorter than the time the private
# ConfigParser_sections API we use here changes, it's worth the risk.
if section == 'DEFAULT':
# NB: The 'DEFAULT' section is not tracked via `has_section` or `_sections`, so we use a
# different API to check for an explicit default.
return key in cp.defaults()
else:
return cp.has_section(section) and (key in cp._sections[section])
def sect(s):
return cyan('[{}]'.format(s))
src_section, src_key = src
if has_explicit_option(src_section, src_key):
if dst is not None:
dst_section, dst_key = dst
print('Found {src_key} in section {src_section}. Should be {dst_key} in section '
'{dst_section}.'.format(src_key=green(src_key), src_section=sect(src_section),
dst_key=green(dst_key), dst_section=sect(dst_section)),
file=sys.stderr)
elif src not in notes:
print('Found {src_key} in section {src_section} and there is no automated migration path'
'for this option. Please consult the '
'codebase.'.format(src_key=red(src_key), src_section=red(src_section)))
if (src_section, src_key) in notes:
print(' Note for {src_key} in section {src_section}: {note}'
.format(src_key=green(src_key),
src_section=sect(src_section),
note=yellow(notes[(src_section, src_key)])))
def check_config_file(path):
cp = Config._create_parser()
with open(path, 'r') as ini:
cp.readfp(ini)
print('Checking config file at {} for unmigrated keys.'.format(path), file=sys.stderr)
def section(s):
return cyan('[{}]'.format(s))
for src, dst in migrations.items():
check_option(cp, src, dst)
# Special-case handling of per-task subsystem options, so we can sweep them up in all
# sections easily.
def check_task_subsystem_options(subsystem_sec, options_map, sections=None):
sections = sections or cp.sections()
for src_sec in ['DEFAULT'] + sections:
dst_sec = subsystem_sec if src_sec == 'DEFAULT' else '{}.{}'.format(subsystem_sec, src_sec)
for src_key, dst_key in options_map.items():
check_option(cp, (src_sec, src_key), (dst_sec, dst_key))
artifact_cache_options_map = {
'read_from_artifact_cache': 'read',
'write_to_artifact_cache': 'write',
'overwrite_cache_artifacts': 'overwrite',
'read_artifact_caches': 'read_from',
'write_artifact_caches': 'write_to',
'cache_compression': 'compression_level',
}
check_task_subsystem_options('cache', artifact_cache_options_map)
jvm_options_map = {
'jvm_options': 'options',
'args': 'program_args',
'debug': 'debug',
'debug_port': 'debug_port',
'debug_args': 'debug_args',
}
jvm_options_sections = [
'repl.scala', 'test.junit', 'run.jvm', 'bench', 'doc.javadoc', 'doc.scaladoc'
]
check_task_subsystem_options('jvm', jvm_options_map, sections=jvm_options_sections)
# Check that all values are parseable.
for sec in ['DEFAULT'] + cp.sections():
for key, value in cp.items(sec):
value = value.strip()
if value.startswith('['):
try:
custom_types.list_option(value)
except ParseError:
print('Value of {key} in section {section} is not a valid '
'JSON list.'.format(key=green(key), section=section(sec)))
elif value.startswith('{'):
try:
custom_types.dict_option(value)
except ParseError:
print('Value of {key} in section {section} is not a valid '
'JSON object.'.format(key=green(key), section=section(sec)))
if __name__ == '__main__':
if len(sys.argv) > 2:
print('Usage: migrate_config.py [path to pants.ini file]', file=sys.stderr)
sys.exit(1)
elif len(sys.argv) > 1:
path = sys.argv[1]
else:
path = './pants.ini'
check_config_file(path)
|
apache-2.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
3,
1898,
6927,
510,
2285,
2199,
8417,
334,
3239,
6483,
14,
1064,
680,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
3239,
5113,
680,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
16952,
12,
6032,
63,
14129,
12,
870,
63,
1593,
12,
717,
2649,
63,
5955,
12,
543,
63,
6242,
9,
199,
199,
646,
984,
199,
199,
504,
9229,
492,
6325,
290,
12,
12431,
12,
8992,
12,
31194,
199,
199,
504,
18081,
14,
1422,
492,
3537,
63,
1313,
199,
504,
18081,
14,
1422,
14,
888,
492,
4094,
199,
504,
18081,
14,
1422,
14,
2550,
492,
21743,
421,
199,
7685,
275,
469,
523,
327,
662,
14,
71,
16781,
523,
327,
360,
7765,
297,
283,
5154,
735,
661,
3472,
297,
283,
4620,
63,
5154,
659,
523,
327,
360,
5187,
13,
4958,
297,
283,
11996,
735,
488,
12,
819,
661,
2268,
297,
283,
8430,
735,
661,
2268,
297,
283,
8430,
13,
6138,
659,
199,
93,
421,
199,
5983,
275,
469,
523,
327,
662,
14,
71,
16781,
523,
327,
360,
15813,
297,
283,
1757,
63,
719,
735,
283,
1858,
3063,
1471,
506,
3247,
367,
1924,
1603,
2611,
4476,
31135,
18159,
14,
221,
12823,
18930,
283,
523,
327,
9668,
283,
1185,
370,
282,
1007,
2253,
12,
1314,
911,
5325,
642,
10685,
3130,
199,
93,
421,
199,
318,
1104,
63,
1422,
8,
1850,
12,
2928,
12,
5042,
304,
523,
347,
965,
63,
10306,
63,
1422,
8,
2792,
12,
790,
304,
272,
327,
20232,
16416,
370,
5126,
299,
17967,
1901,
7667,
1159,
486,
14608,
315,
4178,
921,
4848,
2330,
83,
14,
957,
15,
83,
15,
13746,
15,
82,
15,
1079,
2869,
15,
1325,
272,
327,
626,
18140,
6918,
367,
314,
11012,
1930,
402,
5046,
1511,
14,
221,
9336,
642,
365,
282,
6146,
3612,
6707,
272,
327,
4744,
436,
2399,
4721,
590,
12060,
2399,
30097,
911,
506,
18299,
2419,
314,
900,
314,
5726,
272,
327,
14196,
63,
7786,
3261,
781,
675,
2348,
4493,
12,
652,
1159,
25235,
314,
22633,
14,
272,
340,
3420,
508,
283,
3472,
356,
489,
327,
25377,
26,
710,
283,
3472,
7,
3420,
365,
440,
23268,
4799,
658,
1989,
63,
2792,
64,
503,
18494,
7786,
3559,
880,
781,
675,
282,
489,
327,
3365,
3261,
370,
1104,
367,
376,
5027,
849,
14,
489,
372,
790,
315,
7667,
14,
4322,
342,
272,
587,
26,
489,
372,
7667,
14,
1989,
63,
2792,
8,
2792,
9,
436,
334,
498,
315,
7667,
423,
7786,
59,
2792,
566,
819,
347,
21750,
8,
83,
304,
272,
372,
6325,
290,
11894,
27922,
1370,
908,
8,
83,
430,
819,
2928,
63,
2792,
12,
2928,
63,
498,
275,
2928,
523,
340,
965,
63,
10306,
63,
1422,
8,
2164,
63,
2792,
12,
2928,
63,
498,
304,
272,
340,
5042,
365,
440,
488,
26,
489,
5042,
63,
2792,
12,
5042,
63,
498,
275,
5042,
489,
870,
360,
3601,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
5565,
7719,
506,
469,
5119,
63,
498,
93,
315,
3420,
283,
288,
5041,
5119,
63,
2792,
5565,
1370,
908,
8,
2164,
63,
498,
29,
7731,
8,
2164,
63,
498,
395,
2928,
63,
2792,
29,
8519,
8,
2164,
63,
2792,
395,
2511,
5042,
63,
498,
29,
7731,
8,
5119,
63,
498,
395,
5042,
63,
2792,
29,
8519,
8,
5119,
63,
2792,
1826,
288,
570,
29,
1274,
14,
3083,
9,
272,
916,
2928,
440,
315,
12681,
26,
489,
870,
360,
3601,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
93,
436,
2337,
365,
949,
6384,
23513,
8367,
931,
7,
288,
283,
509,
642,
945,
14,
221,
7754,
13447,
427,
314,
283,
288,
283,
600,
1095,
17374,
908,
8,
2164,
63,
498,
29,
581,
8,
2164,
63,
498,
395,
2928,
63,
2792,
29,
581,
8,
2164,
63,
2792,
1724,
339,
340,
334,
2164,
63,
2792,
12,
2928,
63,
498,
9,
315,
12681,
26,
489,
870,
360,
221,
3390,
367,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
9160,
469,
4610,
6834,
288,
1275,
908,
8,
2164,
63,
498,
29,
7731,
8,
2164,
63,
498,
395,
490,
2928,
63,
2792,
29,
8519,
8,
2164,
63,
2792,
395,
490,
5317,
29,
14514,
8,
5983,
7528,
2164,
63,
2792,
12,
2928,
63,
498,
1874,
1724,
421,
199,
318,
1104,
63,
888,
63,
493,
8,
515,
304,
523,
7667,
275,
4094,
423,
981,
63,
2087,
342,
523,
543,
1551,
8,
515,
12,
283,
82,
358,
465,
20364,
26,
272,
7667,
14,
739,
3997,
8,
2730,
9,
819,
870,
360,
14740,
1101,
570,
737,
1052,
367,
625,
31544,
2883,
17374,
908,
8,
515,
395,
570,
29,
1274,
14,
3083,
9,
819,
347,
3420,
8,
83,
304,
272,
372,
6325,
290,
11894,
27922,
1370,
908,
8,
83,
430,
819,
367,
2928,
12,
5042,
315,
6180,
14,
1744,
837,
272,
1104,
63,
1422,
8,
1850,
12,
2928,
12,
5042,
9,
819,
327,
12568,
13,
2546,
7252,
402,
1126,
13,
1765,
1007,
2253,
1511,
12,
880,
781,
883,
5584,
7840,
3062,
1536,
315,
1006,
523,
327,
10189,
16174,
14,
819,
347,
1104,
63,
1765,
63,
954,
2253,
63,
1419,
8,
954,
2253,
63,
3321,
12,
1511,
63,
1130,
12,
10189,
29,
403,
304,
272,
10189,
275,
10189,
503,
7667,
14,
7786,
342,
272,
367,
2928,
63,
3321,
315,
788,
3472,
418,
435,
10189,
26,
489,
5042,
63,
3321,
275,
1007,
2253,
63,
3321,
340,
2928,
63,
3321,
508,
283,
3472,
7,
587,
9005,
14,
11123,
908,
8,
954,
2253,
63,
3321,
12,
2928,
63,
3321,
9,
489,
367,
2928,
63,
498,
12,
5042,
63,
498,
315,
1511,
63,
1130,
14,
1744,
837,
267,
1104,
63,
1422,
8,
1850,
12,
334,
2164,
63,
3321,
12,
2928,
63,
498,
395,
334,
5119,
63,
3321,
12,
5042,
63,
498,
430,
819,
18115,
63,
1637,
63,
1419,
63,
1130,
275,
469,
272,
283,
739,
63,
504,
63,
16154,
63,
1637,
356,
283,
739,
297,
272,
283,
952,
63,
475,
63,
16154,
63,
1637,
356,
283,
952,
297,
272,
283,
14658,
63,
1637,
63,
30129,
356,
283,
14658,
297,
272,
283,
739,
63,
16154,
63,
17595,
356,
283,
739,
63,
504,
297,
272,
283,
952,
63,
16154,
63,
17595,
356,
283,
952,
63,
475
] |
[
2803,
29,
1624,
13,
24,
199,
3,
1898,
6927,
510,
2285,
2199,
8417,
334,
3239,
6483,
14,
1064,
680,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
3239,
5113,
680,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
16952,
12,
6032,
63,
14129,
12,
870,
63,
1593,
12,
717,
2649,
63,
5955,
12,
543,
63,
6242,
9,
199,
199,
646,
984,
199,
199,
504,
9229,
492,
6325,
290,
12,
12431,
12,
8992,
12,
31194,
199,
199,
504,
18081,
14,
1422,
492,
3537,
63,
1313,
199,
504,
18081,
14,
1422,
14,
888,
492,
4094,
199,
504,
18081,
14,
1422,
14,
2550,
492,
21743,
421,
199,
7685,
275,
469,
523,
327,
662,
14,
71,
16781,
523,
327,
360,
7765,
297,
283,
5154,
735,
661,
3472,
297,
283,
4620,
63,
5154,
659,
523,
327,
360,
5187,
13,
4958,
297,
283,
11996,
735,
488,
12,
819,
661,
2268,
297,
283,
8430,
735,
661,
2268,
297,
283,
8430,
13,
6138,
659,
199,
93,
421,
199,
5983,
275,
469,
523,
327,
662,
14,
71,
16781,
523,
327,
360,
15813,
297,
283,
1757,
63,
719,
735,
283,
1858,
3063,
1471,
506,
3247,
367,
1924,
1603,
2611,
4476,
31135,
18159,
14,
221,
12823,
18930,
283,
523,
327,
9668,
283,
1185,
370,
282,
1007,
2253,
12,
1314,
911,
5325,
642,
10685,
3130,
199,
93,
421,
199,
318,
1104,
63,
1422,
8,
1850,
12,
2928,
12,
5042,
304,
523,
347,
965,
63,
10306,
63,
1422,
8,
2792,
12,
790,
304,
272,
327,
20232,
16416,
370,
5126,
299,
17967,
1901,
7667,
1159,
486,
14608,
315,
4178,
921,
4848,
2330,
83,
14,
957,
15,
83,
15,
13746,
15,
82,
15,
1079,
2869,
15,
1325,
272,
327,
626,
18140,
6918,
367,
314,
11012,
1930,
402,
5046,
1511,
14,
221,
9336,
642,
365,
282,
6146,
3612,
6707,
272,
327,
4744,
436,
2399,
4721,
590,
12060,
2399,
30097,
911,
506,
18299,
2419,
314,
900,
314,
5726,
272,
327,
14196,
63,
7786,
3261,
781,
675,
2348,
4493,
12,
652,
1159,
25235,
314,
22633,
14,
272,
340,
3420,
508,
283,
3472,
356,
489,
327,
25377,
26,
710,
283,
3472,
7,
3420,
365,
440,
23268,
4799,
658,
1989,
63,
2792,
64,
503,
18494,
7786,
3559,
880,
781,
675,
282,
489,
327,
3365,
3261,
370,
1104,
367,
376,
5027,
849,
14,
489,
372,
790,
315,
7667,
14,
4322,
342,
272,
587,
26,
489,
372,
7667,
14,
1989,
63,
2792,
8,
2792,
9,
436,
334,
498,
315,
7667,
423,
7786,
59,
2792,
566,
819,
347,
21750,
8,
83,
304,
272,
372,
6325,
290,
11894,
27922,
1370,
908,
8,
83,
430,
819,
2928,
63,
2792,
12,
2928,
63,
498,
275,
2928,
523,
340,
965,
63,
10306,
63,
1422,
8,
2164,
63,
2792,
12,
2928,
63,
498,
304,
272,
340,
5042,
365,
440,
488,
26,
489,
5042,
63,
2792,
12,
5042,
63,
498,
275,
5042,
489,
870,
360,
3601,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
5565,
7719,
506,
469,
5119,
63,
498,
93,
315,
3420,
283,
288,
5041,
5119,
63,
2792,
5565,
1370,
908,
8,
2164,
63,
498,
29,
7731,
8,
2164,
63,
498,
395,
2928,
63,
2792,
29,
8519,
8,
2164,
63,
2792,
395,
2511,
5042,
63,
498,
29,
7731,
8,
5119,
63,
498,
395,
5042,
63,
2792,
29,
8519,
8,
5119,
63,
2792,
1826,
288,
570,
29,
1274,
14,
3083,
9,
272,
916,
2928,
440,
315,
12681,
26,
489,
870,
360,
3601,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
93,
436,
2337,
365,
949,
6384,
23513,
8367,
931,
7,
288,
283,
509,
642,
945,
14,
221,
7754,
13447,
427,
314,
283,
288,
283,
600,
1095,
17374,
908,
8,
2164,
63,
498,
29,
581,
8,
2164,
63,
498,
395,
2928,
63,
2792,
29,
581,
8,
2164,
63,
2792,
1724,
339,
340,
334,
2164,
63,
2792,
12,
2928,
63,
498,
9,
315,
12681,
26,
489,
870,
360,
221,
3390,
367,
469,
2164,
63,
498,
93,
315,
3420,
469,
2164,
63,
2792,
9160,
469,
4610,
6834,
288,
1275,
908,
8,
2164,
63,
498,
29,
7731,
8,
2164,
63,
498,
395,
490,
2928,
63,
2792,
29,
8519,
8,
2164,
63,
2792,
395,
490,
5317,
29,
14514,
8,
5983,
7528,
2164,
63,
2792,
12,
2928,
63,
498,
1874,
1724,
421,
199,
318,
1104,
63,
888,
63,
493,
8,
515,
304,
523,
7667,
275,
4094,
423,
981,
63,
2087,
342,
523,
543,
1551,
8,
515,
12,
283,
82,
358,
465,
20364,
26,
272,
7667,
14,
739,
3997,
8,
2730,
9,
819,
870,
360,
14740,
1101,
570,
737,
1052,
367,
625,
31544,
2883,
17374,
908,
8,
515,
395,
570,
29,
1274,
14,
3083,
9,
819,
347,
3420,
8,
83,
304,
272,
372,
6325,
290,
11894,
27922,
1370,
908,
8,
83,
430,
819,
367,
2928,
12,
5042,
315,
6180,
14,
1744,
837,
272,
1104,
63,
1422,
8,
1850,
12,
2928,
12,
5042,
9,
819,
327,
12568,
13,
2546,
7252,
402,
1126,
13,
1765,
1007,
2253,
1511,
12,
880,
781,
883,
5584,
7840,
3062,
1536,
315,
1006,
523,
327,
10189,
16174,
14,
819,
347,
1104,
63,
1765,
63,
954,
2253,
63,
1419,
8,
954,
2253,
63,
3321,
12,
1511,
63,
1130,
12,
10189,
29,
403,
304,
272,
10189,
275,
10189,
503,
7667,
14,
7786,
342,
272,
367,
2928,
63,
3321,
315,
788,
3472,
418,
435,
10189,
26,
489,
5042,
63,
3321,
275,
1007,
2253,
63,
3321,
340,
2928,
63,
3321,
508,
283,
3472,
7,
587,
9005,
14,
11123,
908,
8,
954,
2253,
63,
3321,
12,
2928,
63,
3321,
9,
489,
367,
2928,
63,
498,
12,
5042,
63,
498,
315,
1511,
63,
1130,
14,
1744,
837,
267,
1104,
63,
1422,
8,
1850,
12,
334,
2164,
63,
3321,
12,
2928,
63,
498,
395,
334,
5119,
63,
3321,
12,
5042,
63,
498,
430,
819,
18115,
63,
1637,
63,
1419,
63,
1130,
275,
469,
272,
283,
739,
63,
504,
63,
16154,
63,
1637,
356,
283,
739,
297,
272,
283,
952,
63,
475,
63,
16154,
63,
1637,
356,
283,
952,
297,
272,
283,
14658,
63,
1637,
63,
30129,
356,
283,
14658,
297,
272,
283,
739,
63,
16154,
63,
17595,
356,
283,
739,
63,
504,
297,
272,
283,
952,
63,
16154,
63,
17595,
356,
283,
952,
63,
475,
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,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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
] |
bocaaust/FreshLife
|
django_project/env/lib/python2.7/site-packages/django/contrib/auth/middleware.py
|
56
|
4526
|
from django.contrib import auth
from django.contrib.auth import load_backend
from django.contrib.auth.backends import RemoteUserBackend
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import SimpleLazyObject
def get_user(request):
if not hasattr(request, '_cached_user'):
request._cached_user = auth.get_user(request)
return request._cached_user
class AuthenticationMiddleware(object):
def process_request(self, request):
assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
request.user = SimpleLazyObject(lambda: get_user(request))
class RemoteUserMiddleware(object):
"""
Middleware for utilizing Web-server-provided authentication.
If request.user is not authenticated, then this middleware attempts to
authenticate the username passed in the ``REMOTE_USER`` request header.
If authentication is successful, the user is automatically logged in to
persist the user in the session.
The header used is configurable and defaults to ``REMOTE_USER``. Subclass
this class and change the ``header`` attribute if you need to use a
different header.
"""
# Name of request header to grab username from. This will be the key as
# used in the request.META dictionary, i.e. the normalization of headers to
# all uppercase and the addition of "HTTP_" prefix apply.
header = "REMOTE_USER"
def process_request(self, request):
# AuthenticationMiddleware is required so that request.user exists.
if not hasattr(request, 'user'):
raise ImproperlyConfigured(
"The Django remote user auth middleware requires the"
" authentication middleware to be installed. Edit your"
" MIDDLEWARE_CLASSES setting to insert"
" 'django.contrib.auth.middleware.AuthenticationMiddleware'"
" before the RemoteUserMiddleware class.")
try:
username = request.META[self.header]
except KeyError:
# If specified header doesn't exist then remove any existing
# authenticated remote-user, or return (leaving request.user set to
# AnonymousUser by the AuthenticationMiddleware).
if request.user.is_authenticated():
self._remove_invalid_user(request)
return
# If the user is already authenticated and that user is the user we are
# getting passed in the headers, then the correct user is already
# persisted in the session and we don't need to continue.
if request.user.is_authenticated():
if request.user.get_username() == self.clean_username(username, request):
return
else:
# An authenticated user is associated with the request, but
# it does not match the authorized user in the header.
self._remove_invalid_user(request)
# We are seeing this user for the first time in this session, attempt
# to authenticate the user.
user = auth.authenticate(remote_user=username)
if user:
# User is valid. Set request.user and persist user in the session
# by logging the user in.
request.user = user
auth.login(request, user)
def clean_username(self, username, request):
"""
Allows the backend to clean the username, if the backend defines a
clean_username method.
"""
backend_str = request.session[auth.BACKEND_SESSION_KEY]
backend = auth.load_backend(backend_str)
try:
username = backend.clean_username(username)
except AttributeError: # Backend has no clean_username method.
pass
return username
def _remove_invalid_user(self, request):
"""
Removes the current authenticated user in the request which is invalid
but only if the user is authenticated via the RemoteUserBackend.
"""
try:
stored_backend = load_backend(request.session.get(auth.BACKEND_SESSION_KEY, ''))
except ImproperlyConfigured:
# backend failed to load
auth.logout(request)
else:
if isinstance(stored_backend, RemoteUserBackend):
auth.logout(request)
|
apache-2.0
|
[
504,
1639,
14,
2828,
492,
1790,
199,
504,
1639,
14,
2828,
14,
1178,
492,
2248,
63,
4620,
199,
504,
1639,
14,
2828,
14,
1178,
14,
7765,
492,
17283,
1899,
8447,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1208,
14,
15481,
492,
5870,
14269,
1692,
421,
199,
318,
664,
63,
751,
8,
1069,
304,
272,
340,
440,
2688,
8,
1069,
12,
2513,
5245,
63,
751,
735,
267,
1056,
423,
5245,
63,
751,
275,
1790,
14,
362,
63,
751,
8,
1069,
9,
272,
372,
1056,
423,
5245,
63,
751,
421,
199,
533,
15995,
6608,
8,
785,
304,
272,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
702,
2688,
8,
1069,
12,
283,
1730,
659,
298,
1918,
5634,
6299,
10816,
5074,
2351,
10816,
370,
506,
4903,
14,
16407,
2195,
30718,
63,
13748,
4260,
370,
5518,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
16669,
398,
1056,
14,
751,
275,
5870,
14269,
1692,
8,
2734,
26,
664,
63,
751,
8,
1069,
430,
421,
199,
533,
17283,
1899,
6608,
8,
785,
304,
272,
408,
272,
603,
3551,
367,
7678,
19030,
316,
6001,
13,
1000,
13,
16929,
6299,
14,
339,
982,
1056,
14,
751,
365,
440,
15082,
12,
2066,
642,
10816,
12454,
370,
272,
12895,
314,
3434,
3032,
315,
314,
1124,
16058,
63,
3791,
1040,
1056,
1406,
14,
272,
982,
6299,
365,
9512,
12,
314,
922,
365,
5847,
10367,
315,
370,
272,
22400,
314,
922,
315,
314,
2351,
14,
339,
710,
1406,
1202,
365,
30241,
436,
4243,
370,
1124,
16058,
63,
3791,
4345,
221,
30184,
272,
642,
1021,
436,
1570,
314,
1124,
1291,
1040,
2225,
340,
1265,
1929,
370,
675,
282,
272,
3365,
1406,
14,
272,
408,
339,
327,
2812,
402,
1056,
1406,
370,
18200,
3434,
687,
14,
221,
961,
911,
506,
314,
790,
465,
272,
327,
1202,
315,
314,
1056,
14,
10614,
2600,
12,
284,
14,
69,
14,
314,
16973,
402,
2323,
370,
272,
327,
1006,
22681,
436,
314,
10234,
402,
298,
2856,
12172,
2403,
4838,
14,
272,
1406,
275,
298,
16058,
63,
3791,
2,
339,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
327,
15995,
6608,
365,
1415,
880,
626,
1056,
14,
751,
3495,
14,
267,
340,
440,
2688,
8,
1069,
12,
283,
751,
735,
288,
746,
11897,
8,
355,
298,
1918,
5634,
3982,
922,
1790,
10816,
5074,
314,
2,
355,
298,
6299,
10816,
370,
506,
4903,
14,
221,
16407,
2195,
2,
355,
298,
30718,
63,
13748,
4260,
370,
5518,
2,
355,
298,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
4065,
355,
298,
2544,
314,
17283,
1899,
6608,
1021,
2685,
267,
862,
26,
288,
3434,
275,
1056,
14,
10614,
59,
277,
14,
1291,
61,
267,
871,
4067,
26,
288,
327,
982,
2013,
1406,
3181,
1133,
2187,
2066,
2813,
1263,
3411,
288,
327,
15082,
3982,
13,
751,
12,
503,
372,
334,
274,
5519,
1056,
14,
751,
663,
370,
288,
327,
29952,
701,
314,
15995,
6608,
680,
288,
340,
1056,
14,
751,
14,
374,
63,
12177,
837,
355,
291,
423,
2168,
63,
3197,
63,
751,
8,
1069,
9,
288,
372,
267,
327,
982,
314,
922,
365,
2575,
15082,
436,
626,
922,
365,
314,
922,
781,
787,
267,
327,
10232,
3032,
315,
314,
2323,
12,
2066,
314,
3211,
922,
365,
2575,
267,
327,
1126,
24925,
315,
314,
2351,
436,
781,
2793,
1133,
1929,
370,
1980,
14,
267,
340,
1056,
14,
751,
14,
374,
63,
12177,
837,
288,
340,
1056,
14,
751,
14,
362,
63,
2473,
342,
508,
291,
14,
3118,
63,
2473,
8,
2473,
12,
1056,
304,
355,
372,
288,
587,
26,
355,
327,
1626,
15082,
922,
365,
4568,
543,
314,
1056,
12,
1325,
355,
327,
652,
1630,
440,
1336,
314,
18788,
922,
315,
314,
1406,
14,
355,
291,
423,
2168,
63,
3197,
63,
751,
8,
1069,
9,
398,
327,
2136,
787,
1937,
316,
642,
922,
367,
314,
1642,
900,
315,
642,
2351,
12,
7427,
267,
327,
370,
12895,
314,
922,
14,
267,
922,
275,
1790,
14,
13975,
8,
3846,
63,
751,
29,
2473,
9,
267,
340,
922,
26,
288,
327,
2876,
365,
1686,
14,
221,
2494,
1056,
14,
751,
436,
22400,
922,
315,
314,
2351,
288,
327,
701,
2050,
314,
922,
315,
14,
288,
1056,
14,
751,
275,
922,
288,
1790,
14,
2886,
8,
1069,
12,
922,
9,
339,
347,
3633,
63,
2473,
8,
277,
12,
3434,
12,
1056,
304,
267,
408,
267,
22819,
314,
4865,
370,
3633,
314,
3434,
12,
340,
314,
4865,
7890,
282,
267,
3633,
63,
2473,
1083,
14,
267,
408,
267,
4865,
63,
495,
275,
1056,
14,
1730,
59,
1178,
14,
18145,
63,
12763,
63,
3078,
61,
267,
4865,
275,
1790,
14,
912,
63,
4620,
8,
4620,
63,
495,
9,
267,
862,
26,
288,
3434,
275,
4865,
14,
3118,
63,
2473,
8,
2473,
9,
267,
871,
4281,
26,
221,
327,
25674,
965,
949,
3633,
63,
2473,
1083,
14,
288,
986,
267,
372,
3434,
339,
347,
485,
2168,
63,
3197,
63,
751,
8,
277,
12,
1056,
304,
267,
408,
267,
23169,
314,
1453,
15082,
922,
315,
314,
1056,
1314,
365,
3866,
267,
1325,
1454,
340,
314,
922,
365,
15082,
4799,
314,
17283,
1899,
8447,
14,
267,
408,
267,
862,
26,
288,
5489,
63,
4620,
275,
2248,
63,
4620,
8,
1069,
14,
1730,
14,
362,
8,
1178,
14,
18145,
63,
12763,
63,
3078,
12,
12381,
267,
871,
11897,
26,
288,
327,
4865,
3405,
370,
2248,
288,
1790,
14,
11646,
8,
1069,
9,
267,
587,
26,
288,
340,
1228,
8,
16431,
63,
4620,
12,
17283,
1899,
8447,
304,
355,
1790,
14,
11646,
8,
1069,
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
] |
[
1639,
14,
2828,
492,
1790,
199,
504,
1639,
14,
2828,
14,
1178,
492,
2248,
63,
4620,
199,
504,
1639,
14,
2828,
14,
1178,
14,
7765,
492,
17283,
1899,
8447,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1208,
14,
15481,
492,
5870,
14269,
1692,
421,
199,
318,
664,
63,
751,
8,
1069,
304,
272,
340,
440,
2688,
8,
1069,
12,
2513,
5245,
63,
751,
735,
267,
1056,
423,
5245,
63,
751,
275,
1790,
14,
362,
63,
751,
8,
1069,
9,
272,
372,
1056,
423,
5245,
63,
751,
421,
199,
533,
15995,
6608,
8,
785,
304,
272,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
702,
2688,
8,
1069,
12,
283,
1730,
659,
298,
1918,
5634,
6299,
10816,
5074,
2351,
10816,
370,
506,
4903,
14,
16407,
2195,
30718,
63,
13748,
4260,
370,
5518,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
16669,
398,
1056,
14,
751,
275,
5870,
14269,
1692,
8,
2734,
26,
664,
63,
751,
8,
1069,
430,
421,
199,
533,
17283,
1899,
6608,
8,
785,
304,
272,
408,
272,
603,
3551,
367,
7678,
19030,
316,
6001,
13,
1000,
13,
16929,
6299,
14,
339,
982,
1056,
14,
751,
365,
440,
15082,
12,
2066,
642,
10816,
12454,
370,
272,
12895,
314,
3434,
3032,
315,
314,
1124,
16058,
63,
3791,
1040,
1056,
1406,
14,
272,
982,
6299,
365,
9512,
12,
314,
922,
365,
5847,
10367,
315,
370,
272,
22400,
314,
922,
315,
314,
2351,
14,
339,
710,
1406,
1202,
365,
30241,
436,
4243,
370,
1124,
16058,
63,
3791,
4345,
221,
30184,
272,
642,
1021,
436,
1570,
314,
1124,
1291,
1040,
2225,
340,
1265,
1929,
370,
675,
282,
272,
3365,
1406,
14,
272,
408,
339,
327,
2812,
402,
1056,
1406,
370,
18200,
3434,
687,
14,
221,
961,
911,
506,
314,
790,
465,
272,
327,
1202,
315,
314,
1056,
14,
10614,
2600,
12,
284,
14,
69,
14,
314,
16973,
402,
2323,
370,
272,
327,
1006,
22681,
436,
314,
10234,
402,
298,
2856,
12172,
2403,
4838,
14,
272,
1406,
275,
298,
16058,
63,
3791,
2,
339,
347,
2112,
63,
1069,
8,
277,
12,
1056,
304,
267,
327,
15995,
6608,
365,
1415,
880,
626,
1056,
14,
751,
3495,
14,
267,
340,
440,
2688,
8,
1069,
12,
283,
751,
735,
288,
746,
11897,
8,
355,
298,
1918,
5634,
3982,
922,
1790,
10816,
5074,
314,
2,
355,
298,
6299,
10816,
370,
506,
4903,
14,
221,
16407,
2195,
2,
355,
298,
30718,
63,
13748,
4260,
370,
5518,
2,
355,
298,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
4065,
355,
298,
2544,
314,
17283,
1899,
6608,
1021,
2685,
267,
862,
26,
288,
3434,
275,
1056,
14,
10614,
59,
277,
14,
1291,
61,
267,
871,
4067,
26,
288,
327,
982,
2013,
1406,
3181,
1133,
2187,
2066,
2813,
1263,
3411,
288,
327,
15082,
3982,
13,
751,
12,
503,
372,
334,
274,
5519,
1056,
14,
751,
663,
370,
288,
327,
29952,
701,
314,
15995,
6608,
680,
288,
340,
1056,
14,
751,
14,
374,
63,
12177,
837,
355,
291,
423,
2168,
63,
3197,
63,
751,
8,
1069,
9,
288,
372,
267,
327,
982,
314,
922,
365,
2575,
15082,
436,
626,
922,
365,
314,
922,
781,
787,
267,
327,
10232,
3032,
315,
314,
2323,
12,
2066,
314,
3211,
922,
365,
2575,
267,
327,
1126,
24925,
315,
314,
2351,
436,
781,
2793,
1133,
1929,
370,
1980,
14,
267,
340,
1056,
14,
751,
14,
374,
63,
12177,
837,
288,
340,
1056,
14,
751,
14,
362,
63,
2473,
342,
508,
291,
14,
3118,
63,
2473,
8,
2473,
12,
1056,
304,
355,
372,
288,
587,
26,
355,
327,
1626,
15082,
922,
365,
4568,
543,
314,
1056,
12,
1325,
355,
327,
652,
1630,
440,
1336,
314,
18788,
922,
315,
314,
1406,
14,
355,
291,
423,
2168,
63,
3197,
63,
751,
8,
1069,
9,
398,
327,
2136,
787,
1937,
316,
642,
922,
367,
314,
1642,
900,
315,
642,
2351,
12,
7427,
267,
327,
370,
12895,
314,
922,
14,
267,
922,
275,
1790,
14,
13975,
8,
3846,
63,
751,
29,
2473,
9,
267,
340,
922,
26,
288,
327,
2876,
365,
1686,
14,
221,
2494,
1056,
14,
751,
436,
22400,
922,
315,
314,
2351,
288,
327,
701,
2050,
314,
922,
315,
14,
288,
1056,
14,
751,
275,
922,
288,
1790,
14,
2886,
8,
1069,
12,
922,
9,
339,
347,
3633,
63,
2473,
8,
277,
12,
3434,
12,
1056,
304,
267,
408,
267,
22819,
314,
4865,
370,
3633,
314,
3434,
12,
340,
314,
4865,
7890,
282,
267,
3633,
63,
2473,
1083,
14,
267,
408,
267,
4865,
63,
495,
275,
1056,
14,
1730,
59,
1178,
14,
18145,
63,
12763,
63,
3078,
61,
267,
4865,
275,
1790,
14,
912,
63,
4620,
8,
4620,
63,
495,
9,
267,
862,
26,
288,
3434,
275,
4865,
14,
3118,
63,
2473,
8,
2473,
9,
267,
871,
4281,
26,
221,
327,
25674,
965,
949,
3633,
63,
2473,
1083,
14,
288,
986,
267,
372,
3434,
339,
347,
485,
2168,
63,
3197,
63,
751,
8,
277,
12,
1056,
304,
267,
408,
267,
23169,
314,
1453,
15082,
922,
315,
314,
1056,
1314,
365,
3866,
267,
1325,
1454,
340,
314,
922,
365,
15082,
4799,
314,
17283,
1899,
8447,
14,
267,
408,
267,
862,
26,
288,
5489,
63,
4620,
275,
2248,
63,
4620,
8,
1069,
14,
1730,
14,
362,
8,
1178,
14,
18145,
63,
12763,
63,
3078,
12,
12381,
267,
871,
11897,
26,
288,
327,
4865,
3405,
370,
2248,
288,
1790,
14,
11646,
8,
1069,
9,
267,
587,
26,
288,
340,
1228,
8,
16431,
63,
4620,
12,
17283,
1899,
8447,
304,
355,
1790,
14,
11646,
8,
1069,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ericawright/bedrock
|
tests/pages/firefox/new/download.py
|
2
|
2137
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.common.by import By
from pages.base import BasePage
from pages.regions.download_button import DownloadButton
from pages.regions.modal import ModalProtocol
class DownloadPage(BasePage):
URL_TEMPLATE = '/{locale}/firefox/new/{params}'
_download_button_locator = (By.ID, 'download-button-desktop-release')
_platforms_modal_link_locator = (By.CLASS_NAME, 'js-platform-modal-button')
_platforms_modal_content_locator = (By.CLASS_NAME, 'mzp-u-modal-content')
_legacy_platforms_modal_link_locator = (By.ID, 'other-platforms-modal-link')
_legacy_platforms_modal_content_locator = (By.ID, 'other-platforms')
_join_firefox_modal_content_locator = (By.CLASS_NAME, 'join-firefox-content')
_yandex_download_button_locator = (By.CSS_SELECTOR, '.hero-yandex .mzp-c-button.mzp-t-product')
@property
def download_button(self):
el = self.find_element(*self._download_button_locator)
return DownloadButton(self, root=el)
def download_firefox(self):
self.download_button.click()
from pages.firefox.new.thank_you import ThankYouPage
return ThankYouPage(self.selenium, self.base_url).wait_for_page_to_load()
def open_other_platforms_modal(self):
modal = ModalProtocol(self)
self.find_element(*self._platforms_modal_link_locator).click()
self.wait.until(lambda s: modal.displays(self._platforms_modal_content_locator))
return modal
def open_join_firefox_modal(self):
modal = ModalProtocol(self)
self.download_button.click()
self.wait.until(lambda s: modal.displays(self._join_firefox_modal_content_locator))
return modal
@property
def is_yandex_download_button_displayed(self):
button = self.find_element(*self._yandex_download_button_locator)
return button.is_displayed() and 'https://yandex.ru/firefox/mozilla/' in button.get_attribute('href')
|
mpl-2.0
|
[
3,
961,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
504,
19481,
14,
17946,
14,
2330,
14,
991,
492,
4885,
199,
199,
504,
6497,
14,
1095,
492,
3523,
3276,
199,
504,
6497,
14,
11963,
14,
4249,
63,
3887,
492,
17955,
4259,
199,
504,
6497,
14,
11963,
14,
17713,
492,
22035,
279,
3658,
421,
199,
533,
17955,
3276,
8,
1563,
3276,
304,
339,
2851,
63,
7433,
275,
1994,
91,
5508,
5995,
15394,
15,
1222,
5321,
1162,
6834,
339,
485,
4249,
63,
3887,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
4249,
13,
3887,
13,
14487,
13,
3221,
358,
272,
485,
19601,
63,
17713,
63,
1073,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
3596,
13,
3246,
13,
17713,
13,
3887,
358,
272,
485,
19601,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
28808,
80,
13,
85,
13,
17713,
13,
1317,
358,
272,
485,
10000,
63,
19601,
63,
17713,
63,
1073,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
1848,
13,
19601,
13,
17713,
13,
1073,
358,
272,
485,
10000,
63,
19601,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
1848,
13,
19601,
358,
272,
485,
904,
63,
15394,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
904,
13,
15394,
13,
1317,
358,
272,
485,
89,
290,
731,
63,
4249,
63,
3887,
63,
6354,
275,
334,
2175,
14,
14391,
63,
25691,
12,
1987,
31863,
13,
89,
290,
731,
1275,
28808,
80,
13,
67,
13,
3887,
14,
28808,
80,
13,
84,
13,
2558,
358,
339,
768,
1829,
272,
347,
5235,
63,
3887,
8,
277,
304,
267,
579,
275,
291,
14,
1623,
63,
2108,
2031,
277,
423,
4249,
63,
3887,
63,
6354,
9,
267,
372,
17955,
4259,
8,
277,
12,
1738,
29,
352,
9,
339,
347,
5235,
63,
15394,
8,
277,
304,
267,
291,
14,
4249,
63,
3887,
14,
4891,
342,
267,
687,
6497,
14,
15394,
14,
1222,
14,
273,
3580,
63,
13297,
492,
3868,
3580,
5556,
3276,
267,
372,
3868,
3580,
5556,
3276,
8,
277,
14,
15041,
12,
291,
14,
1095,
63,
633,
680,
2573,
63,
509,
63,
1606,
63,
475,
63,
912,
342,
339,
347,
1551,
63,
1848,
63,
19601,
63,
17713,
8,
277,
304,
267,
21698,
275,
22035,
279,
3658,
8,
277,
9,
267,
291,
14,
1623,
63,
2108,
2031,
277,
423,
19601,
63,
17713,
63,
1073,
63,
6354,
680,
4891,
342,
267,
291,
14,
2573,
14,
8111,
8,
2734,
308,
26,
21698,
14,
13654,
9316,
8,
277,
423,
19601,
63,
17713,
63,
1317,
63,
6354,
430,
267,
372,
21698,
339,
347,
1551,
63,
904,
63,
15394,
63,
17713,
8,
277,
304,
267,
21698,
275,
22035,
279,
3658,
8,
277,
9,
267,
291,
14,
4249,
63,
3887,
14,
4891,
342,
267,
291,
14,
2573,
14,
8111,
8,
2734,
308,
26,
21698,
14,
13654,
9316,
8,
277,
423,
904,
63,
15394,
63,
17713,
63,
1317,
63,
6354,
430,
267,
372,
21698,
339,
768,
1829,
272,
347,
365,
63,
89,
290,
731,
63,
4249,
63,
3887,
63,
22283,
8,
277,
304,
267,
5528,
275,
291,
14,
1623,
63,
2108,
2031,
277,
423,
89,
290,
731,
63,
4249,
63,
3887,
63,
6354,
9,
267,
372,
5528,
14,
374,
63,
22283,
342,
436,
283,
2859,
921,
89,
290,
731,
14,
6558,
15,
15394,
15,
12102,
4805,
315,
5528,
14,
362,
63,
3215,
360,
6399,
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
] |
[
961,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
504,
19481,
14,
17946,
14,
2330,
14,
991,
492,
4885,
199,
199,
504,
6497,
14,
1095,
492,
3523,
3276,
199,
504,
6497,
14,
11963,
14,
4249,
63,
3887,
492,
17955,
4259,
199,
504,
6497,
14,
11963,
14,
17713,
492,
22035,
279,
3658,
421,
199,
533,
17955,
3276,
8,
1563,
3276,
304,
339,
2851,
63,
7433,
275,
1994,
91,
5508,
5995,
15394,
15,
1222,
5321,
1162,
6834,
339,
485,
4249,
63,
3887,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
4249,
13,
3887,
13,
14487,
13,
3221,
358,
272,
485,
19601,
63,
17713,
63,
1073,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
3596,
13,
3246,
13,
17713,
13,
3887,
358,
272,
485,
19601,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
28808,
80,
13,
85,
13,
17713,
13,
1317,
358,
272,
485,
10000,
63,
19601,
63,
17713,
63,
1073,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
1848,
13,
19601,
13,
17713,
13,
1073,
358,
272,
485,
10000,
63,
19601,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
998,
12,
283,
1848,
13,
19601,
358,
272,
485,
904,
63,
15394,
63,
17713,
63,
1317,
63,
6354,
275,
334,
2175,
14,
6885,
63,
2339,
12,
283,
904,
13,
15394,
13,
1317,
358,
272,
485,
89,
290,
731,
63,
4249,
63,
3887,
63,
6354,
275,
334,
2175,
14,
14391,
63,
25691,
12,
1987,
31863,
13,
89,
290,
731,
1275,
28808,
80,
13,
67,
13,
3887,
14,
28808,
80,
13,
84,
13,
2558,
358,
339,
768,
1829,
272,
347,
5235,
63,
3887,
8,
277,
304,
267,
579,
275,
291,
14,
1623,
63,
2108,
2031,
277,
423,
4249,
63,
3887,
63,
6354,
9,
267,
372,
17955,
4259,
8,
277,
12,
1738,
29,
352,
9,
339,
347,
5235,
63,
15394,
8,
277,
304,
267,
291,
14,
4249,
63,
3887,
14,
4891,
342,
267,
687,
6497,
14,
15394,
14,
1222,
14,
273,
3580,
63,
13297,
492,
3868,
3580,
5556,
3276,
267,
372,
3868,
3580,
5556,
3276,
8,
277,
14,
15041,
12,
291,
14,
1095,
63,
633,
680,
2573,
63,
509,
63,
1606,
63,
475,
63,
912,
342,
339,
347,
1551,
63,
1848,
63,
19601,
63,
17713,
8,
277,
304,
267,
21698,
275,
22035,
279,
3658,
8,
277,
9,
267,
291,
14,
1623,
63,
2108,
2031,
277,
423,
19601,
63,
17713,
63,
1073,
63,
6354,
680,
4891,
342,
267,
291,
14,
2573,
14,
8111,
8,
2734,
308,
26,
21698,
14,
13654,
9316,
8,
277,
423,
19601,
63,
17713,
63,
1317,
63,
6354,
430,
267,
372,
21698,
339,
347,
1551,
63,
904,
63,
15394,
63,
17713,
8,
277,
304,
267,
21698,
275,
22035,
279,
3658,
8,
277,
9,
267,
291,
14,
4249,
63,
3887,
14,
4891,
342,
267,
291,
14,
2573,
14,
8111,
8,
2734,
308,
26,
21698,
14,
13654,
9316,
8,
277,
423,
904,
63,
15394,
63,
17713,
63,
1317,
63,
6354,
430,
267,
372,
21698,
339,
768,
1829,
272,
347,
365,
63,
89,
290,
731,
63,
4249,
63,
3887,
63,
22283,
8,
277,
304,
267,
5528,
275,
291,
14,
1623,
63,
2108,
2031,
277,
423,
89,
290,
731,
63,
4249,
63,
3887,
63,
6354,
9,
267,
372,
5528,
14,
374,
63,
22283,
342,
436,
283,
2859,
921,
89,
290,
731,
14,
6558,
15,
15394,
15,
12102,
4805,
315,
5528,
14,
362,
63,
3215,
360,
6399,
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,
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,
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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
] |
cchurch/ansible
|
lib/ansible/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py
|
23
|
2969
|
#
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#############################################
# WARNING #
#############################################
#
# This file is auto generated by the resource
# module builder playbook.
#
# Do not edit this file manually.
#
# Changes to this file will be over written
# by the resource module builder.
#
# Changes should be made in the model used to
# generate this file or in the resource module
# builder template.
#
#############################################
"""
The arg spec for the vyos_l3_interfaces module
"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
class L3_interfacesArgs(object): # pylint: disable=R0903
"""The arg spec for the vyos_l3_interfaces module
"""
def __init__(self, **kwargs):
pass
argument_spec = {
'config': {
'elements': 'dict',
'options': {
'ipv4': {
'elements': 'dict',
'options': {
'address': {
'type': 'str'
}
},
'type': 'list'
},
'ipv6': {
'elements': 'dict',
'options': {
'address': {
'type': 'str'
}
},
'type': 'list'
},
'name': {
'required': True,
'type': 'str'
},
'vifs': {
'elements': 'dict',
'options': {
'ipv4': {
'elements': 'dict',
'options': {
'address': {
'type': 'str'
}
},
'type': 'list'
},
'ipv6': {
'elements': 'dict',
'options': {
'address': {
'type': 'str'
}
},
'type': 'list'
},
'vlan_id': {
'type': 'int'
}
},
'type': 'list'
}
},
'type': 'list'
},
'state': {
'choices': ['merged', 'replaced', 'overridden', 'deleted'],
'default': 'merged',
'type': 'str'
}
} # pylint: disable=C0301
|
gpl-3.0
|
[
3,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
20312,
9572,
13002,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
199,
3,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
26634,
8776,
199,
3,
4483,
14750,
8540,
327,
199,
26634,
8776,
199,
3,
199,
3,
961,
570,
365,
2599,
4046,
701,
314,
2073,
199,
3,
257,
859,
6545,
15695,
14,
199,
3,
199,
3,
4226,
440,
5283,
642,
570,
10250,
14,
199,
3,
199,
3,
18784,
370,
642,
570,
911,
506,
1806,
5313,
199,
3,
257,
701,
314,
2073,
859,
6545,
14,
199,
3,
199,
3,
18784,
1077,
506,
6326,
315,
314,
1402,
1202,
370,
199,
3,
257,
3550,
642,
570,
503,
315,
314,
2073,
859,
199,
3,
257,
6545,
1978,
14,
199,
3,
199,
26634,
8776,
199,
624,
199,
1918,
1680,
3158,
367,
314,
31766,
736,
63,
76,
19,
63,
7436,
859,
199,
624,
421,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
533,
491,
19,
63,
7436,
6213,
8,
785,
304,
221,
327,
4287,
26,
3507,
29,
50,
1643,
1644,
272,
408,
1918,
1680,
3158,
367,
314,
31766,
736,
63,
76,
19,
63,
7436,
859,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
986,
339,
1423,
63,
1650,
275,
469,
267,
283,
888,
356,
469,
288,
283,
5527,
356,
283,
807,
297,
288,
283,
1419,
356,
469,
355,
283,
4774,
20,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
1562,
356,
469,
1169,
283,
466,
356,
283,
495,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
1660,
355,
283,
4774,
22,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
1562,
356,
469,
1169,
283,
466,
356,
283,
495,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
1660,
355,
283,
354,
356,
469,
490,
283,
2427,
356,
715,
12,
490,
283,
466,
356,
283,
495,
7,
355,
1660,
355,
283,
433,
2319,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
4774,
20,
356,
469,
1169,
283,
5527,
356,
283,
807,
297,
1169,
283,
1419,
356,
469,
1816,
283,
1562,
356,
469,
2511,
283,
466,
356,
283,
495,
7,
1816,
789,
1169,
1660,
1169,
283,
466,
356,
283,
513,
7,
717,
1660,
717,
283,
4774,
22,
356,
469,
1169,
283,
5527,
356,
283,
807,
297,
1169,
283,
1419,
356,
469,
1816,
283,
1562,
356,
469,
2511,
283,
466,
356,
283,
495,
7,
1816,
789,
1169,
1660,
1169,
283,
466,
356,
283,
513,
7,
717,
1660,
717,
283,
7175,
63,
344,
356,
469,
1169,
283,
466,
356,
283,
442,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
789,
288,
1660,
288,
283,
466,
356,
283,
513,
7,
267,
1660,
267,
283,
929,
356,
469,
288,
283,
4577,
356,
788,
15269,
297,
283,
31473,
297,
283,
30769,
297,
283,
6062,
995,
288,
283,
885,
356,
283,
15269,
297,
288,
283,
466,
356,
283,
495,
7,
267,
789,
272,
789,
221,
327,
4287,
26,
3507,
29,
35,
1644,
614,
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
] |
[
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
20312,
9572,
13002,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
199,
3,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
26634,
8776,
199,
3,
4483,
14750,
8540,
327,
199,
26634,
8776,
199,
3,
199,
3,
961,
570,
365,
2599,
4046,
701,
314,
2073,
199,
3,
257,
859,
6545,
15695,
14,
199,
3,
199,
3,
4226,
440,
5283,
642,
570,
10250,
14,
199,
3,
199,
3,
18784,
370,
642,
570,
911,
506,
1806,
5313,
199,
3,
257,
701,
314,
2073,
859,
6545,
14,
199,
3,
199,
3,
18784,
1077,
506,
6326,
315,
314,
1402,
1202,
370,
199,
3,
257,
3550,
642,
570,
503,
315,
314,
2073,
859,
199,
3,
257,
6545,
1978,
14,
199,
3,
199,
26634,
8776,
199,
624,
199,
1918,
1680,
3158,
367,
314,
31766,
736,
63,
76,
19,
63,
7436,
859,
199,
624,
421,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
533,
491,
19,
63,
7436,
6213,
8,
785,
304,
221,
327,
4287,
26,
3507,
29,
50,
1643,
1644,
272,
408,
1918,
1680,
3158,
367,
314,
31766,
736,
63,
76,
19,
63,
7436,
859,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
986,
339,
1423,
63,
1650,
275,
469,
267,
283,
888,
356,
469,
288,
283,
5527,
356,
283,
807,
297,
288,
283,
1419,
356,
469,
355,
283,
4774,
20,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
1562,
356,
469,
1169,
283,
466,
356,
283,
495,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
1660,
355,
283,
4774,
22,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
1562,
356,
469,
1169,
283,
466,
356,
283,
495,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
1660,
355,
283,
354,
356,
469,
490,
283,
2427,
356,
715,
12,
490,
283,
466,
356,
283,
495,
7,
355,
1660,
355,
283,
433,
2319,
356,
469,
490,
283,
5527,
356,
283,
807,
297,
490,
283,
1419,
356,
469,
717,
283,
4774,
20,
356,
469,
1169,
283,
5527,
356,
283,
807,
297,
1169,
283,
1419,
356,
469,
1816,
283,
1562,
356,
469,
2511,
283,
466,
356,
283,
495,
7,
1816,
789,
1169,
1660,
1169,
283,
466,
356,
283,
513,
7,
717,
1660,
717,
283,
4774,
22,
356,
469,
1169,
283,
5527,
356,
283,
807,
297,
1169,
283,
1419,
356,
469,
1816,
283,
1562,
356,
469,
2511,
283,
466,
356,
283,
495,
7,
1816,
789,
1169,
1660,
1169,
283,
466,
356,
283,
513,
7,
717,
1660,
717,
283,
7175,
63,
344,
356,
469,
1169,
283,
466,
356,
283,
442,
7,
717,
789,
490,
1660,
490,
283,
466,
356,
283,
513,
7,
355,
789,
288,
1660,
288,
283,
466,
356,
283,
513,
7,
267,
1660,
267,
283,
929,
356,
469,
288,
283,
4577,
356,
788,
15269,
297,
283,
31473,
297,
283,
30769,
297,
283,
6062,
995,
288,
283,
885,
356,
283,
15269,
297,
288,
283,
466,
356,
283,
495,
7,
267,
789,
272,
789,
221,
327,
4287,
26,
3507,
29,
35,
1644,
614,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nopjmp/SickRage
|
lib/hachoir_metadata/misc.py
|
57
|
8595
|
from hachoir_metadata.metadata import RootMetadata, registerExtractor
from hachoir_metadata.safe import fault_tolerant
from hachoir_parser.container import SwfFile
from hachoir_parser.misc import TorrentFile, TrueTypeFontFile, OLE2_File, PcfFile
from hachoir_core.field import isString
from hachoir_core.error import warning
from hachoir_parser import guessParser
from hachoir_metadata.setter import normalizeString
class TorrentMetadata(RootMetadata):
KEY_TO_ATTR = {
u"announce": "url",
u"comment": "comment",
u"creation_date": "creation_date",
}
INFO_TO_ATTR = {
u"length": "file_size",
u"name": "filename",
}
def extract(self, torrent):
for field in torrent[0]:
self.processRoot(field)
@fault_tolerant
def processRoot(self, field):
if field.name in self.KEY_TO_ATTR:
key = self.KEY_TO_ATTR[field.name]
value = field.value
setattr(self, key, value)
elif field.name == "info" and "value" in field:
for field in field["value"]:
self.processInfo(field)
@fault_tolerant
def processInfo(self, field):
if field.name in self.INFO_TO_ATTR:
key = self.INFO_TO_ATTR[field.name]
value = field.value
setattr(self, key, value)
elif field.name == "piece_length":
self.comment = "Piece length: %s" % field.display
class TTF_Metadata(RootMetadata):
NAMEID_TO_ATTR = {
0: "copyright", # Copyright notice
3: "title", # Unique font identifier
5: "version", # Version string
8: "author", # Manufacturer name
11: "url", # URL Vendor
14: "copyright", # License info URL
}
def extract(self, ttf):
if "header" in ttf:
self.extractHeader(ttf["header"])
if "names" in ttf:
self.extractNames(ttf["names"])
@fault_tolerant
def extractHeader(self, header):
self.creation_date = header["created"].value
self.last_modification = header["modified"].value
self.comment = u"Smallest readable size in pixels: %s pixels" % header["lowest"].value
self.comment = u"Font direction: %s" % header["font_dir"].display
@fault_tolerant
def extractNames(self, names):
offset = names["offset"].value
for header in names.array("header"):
key = header["nameID"].value
foffset = offset + header["offset"].value
field = names.getFieldByAddress(foffset*8)
if not field or not isString(field):
continue
value = field.value
if key not in self.NAMEID_TO_ATTR:
continue
key = self.NAMEID_TO_ATTR[key]
if key == "version" and value.startswith(u"Version "):
# "Version 1.2" => "1.2"
value = value[8:]
setattr(self, key, value)
class OLE2_Metadata(RootMetadata):
SUMMARY_ID_TO_ATTR = {
2: "title", # Title
3: "title", # Subject
4: "author",
6: "comment",
8: "author", # Last saved by
12: "creation_date",
13: "last_modification",
14: "nb_page",
18: "producer",
}
IGNORE_SUMMARY = set((
1, # Code page
))
DOC_SUMMARY_ID_TO_ATTR = {
3: "title", # Subject
14: "author", # Manager
}
IGNORE_DOC_SUMMARY = set((
1, # Code page
))
def extract(self, ole2):
self._extract(ole2)
def _extract(self, fieldset):
try:
fieldset._feedAll()
except StopIteration:
pass
if "root[0]" in fieldset:
self._extract(self.getFragment(fieldset["root[0]"]))
doc_summary = self.getField(fieldset, "doc_summary[0]")
if doc_summary:
self.useSummary(doc_summary, True)
word_doc = self.getField(fieldset, "word_doc[0]")
if word_doc:
self.useWordDocument(word_doc)
summary = self.getField(fieldset, "summary[0]")
if summary:
self.useSummary(summary, False)
def getFragment(self, frag):
stream = frag.getSubIStream()
ministream = guessParser(stream)
if not ministream:
warning("Unable to create the OLE2 mini stream parser!")
return frag
return ministream
def getField(self, fieldset, name):
# _feedAll() is needed to make sure that we get all fragments
# eg. summary[0], summary[1], ..., summary[n]
try:
fieldset._feedAll()
except StopIteration:
pass
if name not in fieldset:
return None
field = fieldset[name]
return self.getFragment(field)
@fault_tolerant
def useSummary(self, summary, is_doc_summary):
if "os" in summary:
self.os = summary["os"].display
if "section[0]" not in summary:
return
summary = summary["section[0]"]
for property in summary.array("property_index"):
self.useProperty(summary, property, is_doc_summary)
@fault_tolerant
def useWordDocument(self, doc):
self.comment = "Encrypted: %s" % doc["FIB/fEncrypted"].value
@fault_tolerant
def useProperty(self, summary, property, is_doc_summary):
field = summary.getFieldByAddress(property["offset"].value*8)
if not field \
or "value" not in field:
return
field = field["value"]
if not field.hasValue():
return
# Get value
value = field.value
if isinstance(value, (str, unicode)):
value = normalizeString(value)
if not value:
return
# Get property identifier
prop_id = property["id"].value
if is_doc_summary:
id_to_attr = self.DOC_SUMMARY_ID_TO_ATTR
ignore = self.IGNORE_DOC_SUMMARY
else:
id_to_attr = self.SUMMARY_ID_TO_ATTR
ignore = self.IGNORE_SUMMARY
if prop_id in ignore:
return
# Get Hachoir metadata key
try:
key = id_to_attr[prop_id]
use_prefix = False
except LookupError:
key = "comment"
use_prefix = True
if use_prefix:
prefix = property["id"].display
if (prefix in ("TotalEditingTime", "LastPrinted")) \
and (not field):
# Ignore null time delta
return
value = "%s: %s" % (prefix, value)
else:
if (key == "last_modification") and (not field):
# Ignore null timestamp
return
setattr(self, key, value)
class PcfMetadata(RootMetadata):
PROP_TO_KEY = {
'CHARSET_REGISTRY': 'charset',
'COPYRIGHT': 'copyright',
'WEIGHT_NAME': 'font_weight',
'FOUNDRY': 'author',
'FONT': 'title',
'_XMBDFED_INFO': 'producer',
}
def extract(self, pcf):
if "properties" in pcf:
self.useProperties(pcf["properties"])
def useProperties(self, properties):
last = properties["total_str_length"]
offset0 = last.address + last.size
for index in properties.array("property"):
# Search name and value
value = properties.getFieldByAddress(offset0+index["value_offset"].value*8)
if not value:
continue
value = value.value
if not value:
continue
name = properties.getFieldByAddress(offset0+index["name_offset"].value*8)
if not name:
continue
name = name.value
if name not in self.PROP_TO_KEY:
warning("Skip %s=%r" % (name, value))
continue
key = self.PROP_TO_KEY[name]
setattr(self, key, value)
class SwfMetadata(RootMetadata):
def extract(self, swf):
self.height = swf["rect/ymax"].value # twips
self.width = swf["rect/xmax"].value # twips
self.format_version = "flash version %s" % swf["version"].value
self.frame_rate = swf["frame_rate"].value
self.comment = "Frame count: %s" % swf["frame_count"].value
registerExtractor(TorrentFile, TorrentMetadata)
registerExtractor(TrueTypeFontFile, TTF_Metadata)
registerExtractor(OLE2_File, OLE2_Metadata)
registerExtractor(PcfFile, PcfMetadata)
registerExtractor(SwfFile, SwfMetadata)
|
gpl-3.0
|
[
504,
394,
21301,
63,
2343,
14,
2343,
492,
12826,
5142,
12,
2274,
11039,
199,
504,
394,
21301,
63,
2343,
14,
3489,
492,
16898,
63,
475,
1435,
867,
199,
504,
394,
21301,
63,
2087,
14,
3600,
492,
428,
14114,
1173,
199,
504,
394,
21301,
63,
2087,
14,
9923,
492,
29659,
640,
1173,
12,
715,
804,
6986,
1173,
12,
593,
906,
18,
63,
1173,
12,
510,
2177,
1173,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
365,
1558,
199,
504,
394,
21301,
63,
1018,
14,
705,
492,
5721,
199,
504,
394,
21301,
63,
2087,
492,
9519,
2842,
199,
504,
394,
21301,
63,
2343,
14,
8345,
492,
7666,
1558,
199,
199,
533,
29659,
640,
5142,
8,
6405,
5142,
304,
272,
9301,
63,
2566,
63,
5280,
275,
469,
267,
399,
2,
17803,
582,
298,
633,
401,
267,
399,
2,
3349,
582,
298,
3349,
401,
267,
399,
2,
8782,
63,
602,
582,
298,
8782,
63,
602,
401,
272,
789,
272,
24008,
63,
2566,
63,
5280,
275,
469,
267,
399,
2,
1267,
582,
298,
493,
63,
890,
401,
267,
399,
2,
354,
582,
298,
1501,
401,
272,
789,
339,
347,
5536,
8,
277,
12,
17671,
304,
267,
367,
901,
315,
17671,
59,
16,
2189,
288,
291,
14,
1412,
6405,
8,
698,
9,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
2112,
6405,
8,
277,
12,
901,
304,
267,
340,
901,
14,
354,
315,
291,
14,
3078,
63,
2566,
63,
5280,
26,
288,
790,
275,
291,
14,
3078,
63,
2566,
63,
5280,
59,
698,
14,
354,
61,
288,
574,
275,
901,
14,
585,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
267,
916,
901,
14,
354,
508,
298,
815,
2,
436,
298,
585,
2,
315,
901,
26,
288,
367,
901,
315,
901,
905,
585,
6229,
355,
291,
14,
1412,
2354,
8,
698,
9,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
2112,
2354,
8,
277,
12,
901,
304,
267,
340,
901,
14,
354,
315,
291,
14,
4531,
63,
2566,
63,
5280,
26,
288,
790,
275,
291,
14,
4531,
63,
2566,
63,
5280,
59,
698,
14,
354,
61,
288,
574,
275,
901,
14,
585,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
267,
916,
901,
14,
354,
508,
298,
20082,
63,
1267,
582,
288,
291,
14,
3349,
275,
298,
48,
21564,
2582,
26,
450,
83,
2,
450,
901,
14,
2918,
199,
199,
533,
377,
6145,
63,
5142,
8,
6405,
5142,
304,
272,
13637,
998,
63,
2566,
63,
5280,
275,
469,
267,
378,
26,
298,
7307,
401,
257,
327,
1898,
4245,
267,
650,
26,
298,
1213,
401,
755,
327,
18276,
5023,
5148,
267,
959,
26,
298,
1023,
401,
258,
327,
3394,
1059,
267,
1695,
26,
298,
2502,
401,
420,
327,
4688,
21087,
536,
267,
4119,
26,
298,
633,
401,
263,
327,
2851,
812,
7454,
267,
4329,
26,
298,
7307,
401,
221,
327,
844,
2256,
2851,
272,
789,
339,
347,
5536,
8,
277,
12,
307,
3249,
304,
267,
340,
298,
1291,
2,
315,
307,
3249,
26,
288,
291,
14,
5005,
2567,
8,
32264,
905,
1291,
3135,
267,
340,
298,
1247,
2,
315,
307,
3249,
26,
288,
291,
14,
5005,
5866,
8,
32264,
905,
1247,
3135,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
5536,
2567,
8,
277,
12,
1406,
304,
267,
291,
14,
8782,
63,
602,
275,
1406,
905,
3966,
4140,
585,
267,
291,
14,
2019,
63,
20945,
275,
1406,
905,
5540,
4140,
585,
267,
291,
14,
3349,
275,
399,
2,
51,
2174,
14899,
12701,
1568,
315,
11094,
26,
450,
83,
11094,
2,
450,
1406,
905,
674,
597,
4140,
585,
267,
291,
14,
3349,
275,
399,
2,
6986,
7581,
26,
450,
83,
2,
450,
1406,
905,
4246,
63,
694,
4140,
2918,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
5536,
5866,
8,
277,
12,
1561,
304,
267,
3268,
275,
1561,
905,
2743,
4140,
585,
267,
367,
1406,
315,
1561,
14,
1144,
480,
1291,
2349,
288,
790,
275,
1406,
905,
354,
998,
4140,
585,
288,
289,
2743,
275,
3268,
435,
1406,
905,
2743,
4140,
585,
288,
901,
275,
1561,
14,
362,
792,
2175,
1476,
8,
545,
12449,
10,
24,
9,
288,
340,
440,
901,
503,
440,
365,
1558,
8,
698,
304,
355,
1980,
288,
574,
275,
901,
14,
585,
288,
340,
790,
440,
315,
291,
14,
2339,
998,
63,
2566,
63,
5280,
26,
355,
1980,
288,
790,
275,
291,
14,
2339,
998,
63,
2566,
63,
5280,
59,
498,
61,
288,
340,
790,
508,
298,
1023,
2,
436,
574,
14,
2460,
8,
85,
2,
3353,
26699,
355,
327,
298,
3353,
413,
14,
18,
2,
9265,
298,
17,
14,
18,
2,
355,
574,
275,
574,
59,
24,
2938,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
199,
199,
533,
593,
906,
18,
63,
5142,
8,
6405,
5142,
304,
272,
24558,
24794,
63,
998,
63,
2566,
63,
5280,
275,
469,
268,
499,
26,
298,
1213,
401,
258,
327,
16881,
268,
650,
26,
298,
1213,
401,
258,
327,
26793,
268,
841,
26,
298,
2502,
401,
268,
1227,
26,
298,
3349,
401,
268,
1695,
26,
298,
2502,
401,
259,
327,
15237,
6290,
701,
267,
3144,
26,
298,
8782,
63,
602,
401,
267,
4944,
26,
298,
2019,
63,
20945,
401,
267,
4329,
26,
298,
4994,
63,
1606,
401,
267,
6155,
26,
298,
16376,
401,
272,
789,
272,
27499,
5788,
63,
29508,
275,
663,
1332,
267,
413,
12,
327,
5495,
2034,
272,
5082,
339,
3506,
35,
63,
29508,
63,
998,
63,
2566,
63,
5280,
275,
469,
268,
650,
26,
298,
1213,
401,
258,
327,
26793,
267,
4329,
26,
298,
2502,
401,
259,
327,
13537,
272,
789,
272,
27499,
5788,
63,
16618,
63,
29508,
275,
663,
1332,
267,
413,
12,
327,
5495,
2034,
272,
5082,
339,
347,
5536,
8,
277,
12,
312,
274,
18,
304,
267,
291,
423,
5005,
8,
16721,
18,
9,
339,
347,
485,
5005,
8,
277,
12,
901,
409,
304,
267,
862,
26,
288,
901,
409,
423,
3871,
2422,
342,
267,
871,
10852,
26,
288,
986,
267,
340,
298,
1231,
59,
16,
8480,
315,
901,
409,
26,
288,
291,
423,
5005,
8,
277,
14,
362,
11080,
8,
698,
409,
905,
1231,
59,
16,
61,
13045,
267,
1382,
63,
4705,
275,
291,
14,
362,
792,
8,
698,
409,
12,
298,
1301,
63,
4705
] |
[
394,
21301,
63,
2343,
14,
2343,
492,
12826,
5142,
12,
2274,
11039,
199,
504,
394,
21301,
63,
2343,
14,
3489,
492,
16898,
63,
475,
1435,
867,
199,
504,
394,
21301,
63,
2087,
14,
3600,
492,
428,
14114,
1173,
199,
504,
394,
21301,
63,
2087,
14,
9923,
492,
29659,
640,
1173,
12,
715,
804,
6986,
1173,
12,
593,
906,
18,
63,
1173,
12,
510,
2177,
1173,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
365,
1558,
199,
504,
394,
21301,
63,
1018,
14,
705,
492,
5721,
199,
504,
394,
21301,
63,
2087,
492,
9519,
2842,
199,
504,
394,
21301,
63,
2343,
14,
8345,
492,
7666,
1558,
199,
199,
533,
29659,
640,
5142,
8,
6405,
5142,
304,
272,
9301,
63,
2566,
63,
5280,
275,
469,
267,
399,
2,
17803,
582,
298,
633,
401,
267,
399,
2,
3349,
582,
298,
3349,
401,
267,
399,
2,
8782,
63,
602,
582,
298,
8782,
63,
602,
401,
272,
789,
272,
24008,
63,
2566,
63,
5280,
275,
469,
267,
399,
2,
1267,
582,
298,
493,
63,
890,
401,
267,
399,
2,
354,
582,
298,
1501,
401,
272,
789,
339,
347,
5536,
8,
277,
12,
17671,
304,
267,
367,
901,
315,
17671,
59,
16,
2189,
288,
291,
14,
1412,
6405,
8,
698,
9,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
2112,
6405,
8,
277,
12,
901,
304,
267,
340,
901,
14,
354,
315,
291,
14,
3078,
63,
2566,
63,
5280,
26,
288,
790,
275,
291,
14,
3078,
63,
2566,
63,
5280,
59,
698,
14,
354,
61,
288,
574,
275,
901,
14,
585,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
267,
916,
901,
14,
354,
508,
298,
815,
2,
436,
298,
585,
2,
315,
901,
26,
288,
367,
901,
315,
901,
905,
585,
6229,
355,
291,
14,
1412,
2354,
8,
698,
9,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
2112,
2354,
8,
277,
12,
901,
304,
267,
340,
901,
14,
354,
315,
291,
14,
4531,
63,
2566,
63,
5280,
26,
288,
790,
275,
291,
14,
4531,
63,
2566,
63,
5280,
59,
698,
14,
354,
61,
288,
574,
275,
901,
14,
585,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
267,
916,
901,
14,
354,
508,
298,
20082,
63,
1267,
582,
288,
291,
14,
3349,
275,
298,
48,
21564,
2582,
26,
450,
83,
2,
450,
901,
14,
2918,
199,
199,
533,
377,
6145,
63,
5142,
8,
6405,
5142,
304,
272,
13637,
998,
63,
2566,
63,
5280,
275,
469,
267,
378,
26,
298,
7307,
401,
257,
327,
1898,
4245,
267,
650,
26,
298,
1213,
401,
755,
327,
18276,
5023,
5148,
267,
959,
26,
298,
1023,
401,
258,
327,
3394,
1059,
267,
1695,
26,
298,
2502,
401,
420,
327,
4688,
21087,
536,
267,
4119,
26,
298,
633,
401,
263,
327,
2851,
812,
7454,
267,
4329,
26,
298,
7307,
401,
221,
327,
844,
2256,
2851,
272,
789,
339,
347,
5536,
8,
277,
12,
307,
3249,
304,
267,
340,
298,
1291,
2,
315,
307,
3249,
26,
288,
291,
14,
5005,
2567,
8,
32264,
905,
1291,
3135,
267,
340,
298,
1247,
2,
315,
307,
3249,
26,
288,
291,
14,
5005,
5866,
8,
32264,
905,
1247,
3135,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
5536,
2567,
8,
277,
12,
1406,
304,
267,
291,
14,
8782,
63,
602,
275,
1406,
905,
3966,
4140,
585,
267,
291,
14,
2019,
63,
20945,
275,
1406,
905,
5540,
4140,
585,
267,
291,
14,
3349,
275,
399,
2,
51,
2174,
14899,
12701,
1568,
315,
11094,
26,
450,
83,
11094,
2,
450,
1406,
905,
674,
597,
4140,
585,
267,
291,
14,
3349,
275,
399,
2,
6986,
7581,
26,
450,
83,
2,
450,
1406,
905,
4246,
63,
694,
4140,
2918,
339,
768,
1879,
63,
475,
1435,
867,
272,
347,
5536,
5866,
8,
277,
12,
1561,
304,
267,
3268,
275,
1561,
905,
2743,
4140,
585,
267,
367,
1406,
315,
1561,
14,
1144,
480,
1291,
2349,
288,
790,
275,
1406,
905,
354,
998,
4140,
585,
288,
289,
2743,
275,
3268,
435,
1406,
905,
2743,
4140,
585,
288,
901,
275,
1561,
14,
362,
792,
2175,
1476,
8,
545,
12449,
10,
24,
9,
288,
340,
440,
901,
503,
440,
365,
1558,
8,
698,
304,
355,
1980,
288,
574,
275,
901,
14,
585,
288,
340,
790,
440,
315,
291,
14,
2339,
998,
63,
2566,
63,
5280,
26,
355,
1980,
288,
790,
275,
291,
14,
2339,
998,
63,
2566,
63,
5280,
59,
498,
61,
288,
340,
790,
508,
298,
1023,
2,
436,
574,
14,
2460,
8,
85,
2,
3353,
26699,
355,
327,
298,
3353,
413,
14,
18,
2,
9265,
298,
17,
14,
18,
2,
355,
574,
275,
574,
59,
24,
2938,
288,
5371,
8,
277,
12,
790,
12,
574,
9,
199,
199,
533,
593,
906,
18,
63,
5142,
8,
6405,
5142,
304,
272,
24558,
24794,
63,
998,
63,
2566,
63,
5280,
275,
469,
268,
499,
26,
298,
1213,
401,
258,
327,
16881,
268,
650,
26,
298,
1213,
401,
258,
327,
26793,
268,
841,
26,
298,
2502,
401,
268,
1227,
26,
298,
3349,
401,
268,
1695,
26,
298,
2502,
401,
259,
327,
15237,
6290,
701,
267,
3144,
26,
298,
8782,
63,
602,
401,
267,
4944,
26,
298,
2019,
63,
20945,
401,
267,
4329,
26,
298,
4994,
63,
1606,
401,
267,
6155,
26,
298,
16376,
401,
272,
789,
272,
27499,
5788,
63,
29508,
275,
663,
1332,
267,
413,
12,
327,
5495,
2034,
272,
5082,
339,
3506,
35,
63,
29508,
63,
998,
63,
2566,
63,
5280,
275,
469,
268,
650,
26,
298,
1213,
401,
258,
327,
26793,
267,
4329,
26,
298,
2502,
401,
259,
327,
13537,
272,
789,
272,
27499,
5788,
63,
16618,
63,
29508,
275,
663,
1332,
267,
413,
12,
327,
5495,
2034,
272,
5082,
339,
347,
5536,
8,
277,
12,
312,
274,
18,
304,
267,
291,
423,
5005,
8,
16721,
18,
9,
339,
347,
485,
5005,
8,
277,
12,
901,
409,
304,
267,
862,
26,
288,
901,
409,
423,
3871,
2422,
342,
267,
871,
10852,
26,
288,
986,
267,
340,
298,
1231,
59,
16,
8480,
315,
901,
409,
26,
288,
291,
423,
5005,
8,
277,
14,
362,
11080,
8,
698,
409,
905,
1231,
59,
16,
61,
13045,
267,
1382,
63,
4705,
275,
291,
14,
362,
792,
8,
698,
409,
12,
298,
1301,
63,
4705,
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,
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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
] |
anselal/antminer-monitor
|
antminermonitor/blueprints/user/models.py
|
1
|
1102
|
from flask_login.mixins import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from sqlalchemy import Column, Integer, VARCHAR
from antminermonitor.database import Base
class User(UserMixin, Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True)
username = Column(VARCHAR(64), index=True, unique=True)
email = Column(VARCHAR(120), index=True, unique=True)
password_hash = Column(VARCHAR(128))
surname = Column(VARCHAR(100))
firstname = Column(VARCHAR(100))
active = Column(Integer, default=1)
@property
def serialize(self):
return {
'id': self.id,
'username': self.username,
'firstname': self.firstname,
'surname': self.surname,
'email': self.email
}
def __repr__(self):
return '<User {}>'.format(self.username)
def set_password(self, password):
self.password_hash = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.password_hash, password)
|
gpl-3.0
|
[
504,
7209,
63,
2886,
14,
30192,
492,
2876,
4256,
199,
504,
10380,
14,
4416,
492,
3550,
63,
2060,
63,
2227,
12,
1104,
63,
2060,
63,
2227,
199,
199,
504,
8335,
492,
4996,
12,
7225,
12,
28490,
199,
504,
27384,
827,
281,
7157,
14,
4659,
492,
3523,
421,
199,
533,
2876,
8,
1899,
4256,
12,
3523,
304,
272,
636,
10983,
363,
275,
283,
751,
7,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
3434,
275,
4996,
8,
24800,
8,
772,
395,
1478,
29,
549,
12,
3747,
29,
549,
9,
272,
3031,
275,
4996,
8,
24800,
8,
6708,
395,
1478,
29,
549,
12,
3747,
29,
549,
9,
272,
2505,
63,
2227,
275,
4996,
8,
24800,
8,
3933,
430,
272,
308,
21121,
275,
4996,
8,
24800,
8,
1960,
430,
272,
1642,
354,
275,
4996,
8,
24800,
8,
1960,
430,
272,
4702,
275,
4996,
8,
2674,
12,
849,
29,
17,
9,
339,
768,
1829,
272,
347,
8437,
8,
277,
304,
267,
372,
469,
288,
283,
344,
356,
291,
14,
344,
12,
288,
283,
2473,
356,
291,
14,
2473,
12,
288,
283,
25603,
356,
291,
14,
25603,
12,
288,
283,
30959,
356,
291,
14,
30959,
12,
288,
283,
2123,
356,
291,
14,
2123,
267,
789,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
2650,
1899,
1052,
22936,
908,
8,
277,
14,
2473,
9,
339,
347,
663,
63,
2060,
8,
277,
12,
2505,
304,
267,
291,
14,
2060,
63,
2227,
275,
3550,
63,
2060,
63,
2227,
8,
2060,
9,
339,
347,
1104,
63,
2060,
8,
277,
12,
2505,
304,
267,
372,
1104,
63,
2060,
63,
2227,
8,
277,
14,
2060,
63,
2227,
12,
2505,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
7209,
63,
2886,
14,
30192,
492,
2876,
4256,
199,
504,
10380,
14,
4416,
492,
3550,
63,
2060,
63,
2227,
12,
1104,
63,
2060,
63,
2227,
199,
199,
504,
8335,
492,
4996,
12,
7225,
12,
28490,
199,
504,
27384,
827,
281,
7157,
14,
4659,
492,
3523,
421,
199,
533,
2876,
8,
1899,
4256,
12,
3523,
304,
272,
636,
10983,
363,
275,
283,
751,
7,
272,
1305,
275,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
272,
3434,
275,
4996,
8,
24800,
8,
772,
395,
1478,
29,
549,
12,
3747,
29,
549,
9,
272,
3031,
275,
4996,
8,
24800,
8,
6708,
395,
1478,
29,
549,
12,
3747,
29,
549,
9,
272,
2505,
63,
2227,
275,
4996,
8,
24800,
8,
3933,
430,
272,
308,
21121,
275,
4996,
8,
24800,
8,
1960,
430,
272,
1642,
354,
275,
4996,
8,
24800,
8,
1960,
430,
272,
4702,
275,
4996,
8,
2674,
12,
849,
29,
17,
9,
339,
768,
1829,
272,
347,
8437,
8,
277,
304,
267,
372,
469,
288,
283,
344,
356,
291,
14,
344,
12,
288,
283,
2473,
356,
291,
14,
2473,
12,
288,
283,
25603,
356,
291,
14,
25603,
12,
288,
283,
30959,
356,
291,
14,
30959,
12,
288,
283,
2123,
356,
291,
14,
2123,
267,
789,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
2650,
1899,
1052,
22936,
908,
8,
277,
14,
2473,
9,
339,
347,
663,
63,
2060,
8,
277,
12,
2505,
304,
267,
291,
14,
2060,
63,
2227,
275,
3550,
63,
2060,
63,
2227,
8,
2060,
9,
339,
347,
1104,
63,
2060,
8,
277,
12,
2505,
304,
267,
372,
1104,
63,
2060,
63,
2227,
8,
277,
14,
2060,
63,
2227,
12,
2505,
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,
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
] |
MarsZone/DreamLand
|
evennia/evennia/contrib/multidescer.py
|
4
|
9755
|
"""
Evennia Mutltidescer
Contrib - Griatch 2016
A "multidescer" is a concept from the MUSH world. It allows for
creating, managing and switching between multiple character
descriptions. This multidescer will not require any changes to the
Character class, rather it will use the `multidescs` Attribute (a
list) and create it if it does not exist.
This contrib also works well together with the rpsystem contrib (which
also adds the short descriptions and the `sdesc` command).
Installation:
Edit `mygame/commands/default_cmdsets.py` and add
`from contrib.multidesc import CmdMultiDesc` to the top.
Next, look up the `at_cmdset_create` method of the `CharacterCmdSet`
class and add a line `self.add(CmdMultiDesc())` to the end
of it.
Reload the server and you should have the +desc command available (it
will replace the default `desc` command).
"""
import re
from evennia import default_cmds
from evennia.utils.utils import crop
from evennia.utils.eveditor import EvEditor
# regex for the set functionality
_RE_KEYS = re.compile(r"([\w\s]+)(?:\+*?)", re.U + re.I)
# Helper functions for the Command
class DescValidateError(ValueError):
"Used for tracebacks from desc systems"
pass
def _update_store(caller, key=None, desc=None, delete=False, swapkey=None):
"""
Helper function for updating the database store.
Args:
caller (Object): The caller of the command.
key (str): Description identifier
desc (str): Description text.
delete (bool): Delete given key.
swapkey (str): Swap list positions of `key` and this key.
"""
if not caller.db.multidesc:
# initialize the multidesc attribute
caller.db.multidesc = [("caller", caller.db.desc or "")]
if not key:
return
lokey = key.lower()
match = [ind for ind, tup in enumerate(caller.db.multidesc) if tup[0] == lokey]
if match:
idesc = match[0]
if delete:
# delete entry
del caller.db.multidesc[idesc]
elif swapkey:
# swap positions
loswapkey = swapkey.lower()
swapmatch = [ind for ind, tup in enumerate(caller.db.multidesc) if tup[0] == loswapkey]
if swapmatch:
iswap = swapmatch[0]
if idesc == iswap:
raise DescValidateError("Swapping a key with itself does nothing.")
temp = caller.db.multidesc[idesc]
caller.db.multidesc[idesc] = caller.db.multidesc[iswap]
caller.db.multidesc[iswap] = temp
else:
raise DescValidateError("Description key '|w%s|n' not found." % swapkey)
elif desc:
# update in-place
caller.db.multidesc[idesc] = (lokey, desc)
else:
raise DescValidateError("No description was set.")
else:
# no matching key
if delete or swapkey:
raise DescValidateError("Description key '|w%s|n' not found." % key)
elif desc:
# insert new at the top of the stack
caller.db.multidesc.insert(0, (lokey, desc))
else:
raise DescValidateError("No description was set.")
# eveditor save/load/quit functions
def _save_editor(caller, buffer):
"Called when the editor saves its contents"
key = caller.db._multidesc_editkey
_update_store(caller, key, buffer)
caller.msg("Saved description to key '%s'." % key)
return True
def _load_editor(caller):
"Called when the editor loads contents"
key = caller.db._multidesc_editkey
match = [ind for ind, tup in enumerate(caller.db.multidesc) if tup[0] == key]
if match:
return caller.db.multidesc[match[0]][1]
return ""
def _quit_editor(caller):
"Called when the editor quits"
del caller.db._multidesc_editkey
caller.msg("Exited editor.")
# The actual command class
class CmdMultiDesc(default_cmds.MuxCommand):
"""
Manage multiple descriptions
Usage:
+desc [key] - show current desc desc with <key>
+desc <key> = <text> - add/replace desc with <key>
+desc/list - list descriptions (abbreviated)
+desc/list/full - list descriptions (full texts)
+desc/edit <key> - add/edit desc <key> in line editor
+desc/del <key> - delete desc <key>
+desc/swap <key1>-<key2> - swap positions of <key1> and <key2> in list
+desc/set <key> [+key+...] - set desc as default or combine multiple descs
Notes:
When combining multiple descs with +desc/set <key> + <key2> + ...,
any keys not matching an actual description will be inserted
as plain text. Use e.g. ansi line break ||/ to add a new
paragraph and + + or ansi space ||_ to add extra whitespace.
"""
key = "+desc"
aliases = ["desc"]
locks = "cmd:all()"
help_category = "General"
def func(self):
"""
Implements the multidescer. We will use `db.desc` for the
description in use and `db.multidesc` to store all descriptions.
"""
caller = self.caller
args = self.args.strip()
switches = self.switches
try:
if "list" in switches or "all" in switches:
# list all stored descriptions, either in full or cropped.
# Note that we list starting from 1, not from 0.
_update_store(caller)
do_crop = not "full" in switches
if do_crop:
outtext = ["|w%s:|n %s" % (key, crop(desc))
for key, desc in caller.db.multidesc]
else:
outtext = ["\n|w%s:|n|n\n%s\n%s" % (key, "-" * (len(key) + 1), desc)
for key, desc in caller.db.multidesc]
caller.msg("|wStored descs:|n\n" + "\n".join(outtext))
return
elif "edit" in switches:
# Use the eveditor to edit/create the named description
if not args:
caller.msg("Usage: %s/edit key" % self.key)
return
# this is used by the editor to know what to edit; it's deleted automatically
caller.db._multidesc_editkey = args
# start the editor
EvEditor(caller, loadfunc=_load_editor, savefunc=_save_editor,
quitfunc=_quit_editor, key="multidesc editor", persistent=True)
elif "delete" in switches or "del" in switches:
# delete a multidesc entry.
if not args:
caller.msg("Usage: %s/delete key" % self.key)
return
_update_store(caller, args, delete=True)
caller.msg("Deleted description with key '%s'." % args)
elif "swap" in switches or "switch" in switches or "reorder" in switches:
# Reorder list by swapping two entries. We expect numbers starting from 1
keys = [arg for arg in args.split("-", 1)]
if not len(keys) == 2:
caller.msg("Usage: %s/swap key1-key2" % self.key)
return
key1, key2 = keys
# perform the swap
_update_store(caller, key1, swapkey=key2)
caller.msg("Swapped descs '%s' and '%s'." % (key1, key2))
elif "set" in switches:
# switches one (or more) of the multidescs to be the "active" description
_update_store(caller)
if not args:
caller.msg("Usage: %s/set key [+ key2 + key3 + ...]" % self.key)
return
new_desc = []
multidesc = caller.db.multidesc
for key in args.split("+"):
notfound = True
lokey = key.strip().lower()
for mkey, desc in multidesc:
if lokey == mkey:
new_desc.append(desc)
notfound = False
continue
if notfound:
# if we get here, there is no desc match, we add it as a normal string
new_desc.append(key)
new_desc = "".join(new_desc)
caller.db.desc = new_desc
caller.msg("%s\n\n|wThe above was set as the current description.|n" % new_desc)
elif self.rhs or "add" in switches:
# add text directly to a new entry or an existing one.
if not (self.lhs and self.rhs):
caller.msg("Usage: %s/add key = description" % self.key)
return
key, desc = self.lhs, self.rhs
_update_store(caller, key, desc)
caller.msg("Stored description '%s': \"%s\"" % (key, crop(desc)))
else:
# display the current description or a numbered description
_update_store(caller)
if args:
key = args.lower()
multidesc = caller.db.multidesc
for mkey, desc in multidesc:
if key == mkey:
caller.msg("|wDecsription %s:|n\n%s" % (key, desc))
return
caller.msg("Description key '%s' not found." % key)
else:
caller.msg("|wCurrent desc:|n\n%s" % caller.db.desc)
except DescValidateError, err:
# This is triggered by _key_to_index
caller.msg(err)
|
bsd-3-clause
|
[
624,
199,
29704,
22042,
26550,
21934,
3257,
281,
199,
199,
714,
1925,
446,
598,
322,
693,
7800,
199,
199,
33,
298,
3029,
3257,
281,
2,
365,
282,
19834,
687,
314,
603,
14527,
6701,
14,
2779,
6127,
367,
199,
20358,
12,
28453,
436,
31620,
3382,
3663,
4528,
199,
21713,
14,
961,
3510,
3257,
281,
911,
440,
4409,
1263,
4493,
370,
314,
199,
14852,
1021,
12,
7830,
652,
911,
675,
314,
658,
3029,
3257,
83,
64,
3882,
334,
65,
199,
513,
9,
436,
1218,
652,
340,
652,
1630,
440,
2187,
14,
199,
199,
2765,
5914,
2597,
5419,
5521,
10451,
543,
314,
519,
1190,
3045,
5914,
334,
6777,
199,
12344,
9584,
314,
3974,
18714,
436,
314,
658,
83,
3257,
64,
1414,
680,
421,
199,
31456,
26,
199,
199,
4685,
658,
1662,
5097,
15,
4405,
15,
885,
63,
1760,
2193,
14,
647,
64,
436,
1050,
199,
64,
504,
5914,
14,
3029,
3257,
492,
26005,
3947,
9921,
64,
370,
314,
2746,
14,
199,
199,
5765,
12,
3648,
1536,
314,
658,
292,
63,
1760,
409,
63,
981,
64,
1083,
402,
314,
658,
14852,
7874,
1084,
64,
199,
533,
436,
1050,
282,
1004,
658,
277,
14,
525,
8,
7874,
3947,
9921,
1012,
64,
370,
314,
1284,
199,
1618,
652,
14,
199,
199,
30590,
314,
1654,
436,
1265,
1077,
1172,
314,
435,
3257,
1414,
2808,
334,
390,
199,
14117,
3350,
314,
849,
658,
3257,
64,
1414,
680,
199,
199,
624,
199,
646,
295,
199,
504,
2755,
22042,
492,
849,
63,
12975,
199,
504,
2755,
22042,
14,
1208,
14,
1208,
492,
18366,
199,
504,
2755,
22042,
14,
1208,
14,
4754,
27050,
492,
662,
86,
10423,
421,
199,
3,
5163,
367,
314,
663,
9330,
199,
63,
907,
63,
17434,
275,
295,
14,
2014,
8,
82,
2,
16510,
87,
60,
83,
11896,
15840,
11,
15279,
4186,
295,
14,
53,
435,
295,
14,
41,
9,
421,
199,
3,
11642,
3423,
367,
314,
5817,
199,
199,
533,
8055,
67,
12584,
547,
8,
3393,
304,
272,
298,
9167,
367,
5190,
83,
687,
4328,
10460,
2,
272,
986,
421,
199,
318,
485,
873,
63,
1617,
8,
11219,
12,
790,
29,
403,
12,
4328,
29,
403,
12,
3145,
29,
797,
12,
11413,
498,
29,
403,
304,
272,
408,
272,
11642,
805,
367,
12928,
314,
3050,
3877,
14,
339,
3033,
26,
267,
8025,
334,
1692,
304,
710,
8025,
402,
314,
1414,
14,
267,
790,
334,
495,
304,
11994,
5148,
267,
4328,
334,
495,
304,
11994,
1318,
14,
267,
3145,
334,
2245,
304,
8496,
1627,
790,
14,
267,
11413,
498,
334,
495,
304,
16666,
439,
769,
12266,
402,
658,
498,
64,
436,
642,
790,
14,
339,
408,
272,
340,
440,
8025,
14,
697,
14,
3029,
3257,
26,
267,
327,
8265,
314,
3510,
3257,
2225,
267,
8025,
14,
697,
14,
3029,
3257,
275,
10003,
11219,
401,
8025,
14,
697,
14,
3257,
503,
6899,
61,
272,
340,
440,
790,
26,
267,
372,
272,
560,
498,
275,
790,
14,
2325,
342,
272,
1336,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
560,
498,
61,
272,
340,
1336,
26,
267,
284,
3257,
275,
1336,
59,
16,
61,
267,
340,
3145,
26,
288,
327,
3145,
2397,
288,
2150,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
267,
916,
11413,
498,
26,
288,
327,
11413,
12266,
288,
560,
9286,
498,
275,
11413,
498,
14,
2325,
342,
288,
11413,
1431,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
560,
9286,
498,
61,
288,
340,
11413,
1431,
26,
355,
365,
25529,
275,
11413,
1431,
59,
16,
61,
355,
340,
284,
3257,
508,
365,
25529,
26,
490,
746,
8055,
67,
12584,
547,
480,
10941,
3262,
282,
790,
543,
6337,
1630,
6548,
2685,
355,
2388,
275,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
355,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
275,
8025,
14,
697,
14,
3029,
3257,
59,
374,
25529,
61,
355,
8025,
14,
697,
14,
3029,
3257,
59,
374,
25529,
61,
275,
2388,
288,
587,
26,
355,
746,
8055,
67,
12584,
547,
480,
5831,
790,
11280,
87,
5,
83,
92,
78,
7,
440,
1911,
2122,
450,
11413,
498,
9,
267,
916,
4328,
26,
288,
327,
1678,
315,
13,
2778,
288,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
275,
334,
320,
498,
12,
4328,
9,
267,
587,
26,
288,
746,
8055,
67,
12584,
547,
480,
1944,
1369,
1990,
663,
2685,
272,
587,
26,
267,
327,
949,
4877,
790,
267,
340,
3145,
503,
11413,
498,
26,
288,
746,
8055,
67,
12584,
547,
480,
5831,
790,
11280,
87,
5,
83,
92,
78,
7,
440,
1911,
2122,
450,
790,
9,
267,
916,
4328,
26,
288,
327,
5518,
892,
737,
314,
2746,
402,
314,
3464,
288,
8025,
14,
697,
14,
3029,
3257,
14,
3176,
8,
16,
12,
334,
320,
498,
12,
4328,
430,
267,
587,
26,
288,
746,
8055,
67,
12584,
547,
480,
1944,
1369,
1990,
663,
2685,
199,
199,
3,
325,
432,
27050,
3354,
15,
912,
15,
10589,
3423,
199,
199,
318,
485,
2117,
63,
7515,
8,
11219,
12,
3335,
304,
272,
298,
10474,
1380,
314,
8823,
23050,
2399,
4072,
2,
272,
790,
275,
8025,
14,
697,
423,
3029,
3257,
63,
3773,
498,
272,
485,
873,
63,
1617,
8,
11219,
12,
790,
12,
3335,
9,
272,
8025,
14,
1328,
480,
21969,
1369,
370,
790,
1543,
83,
16669,
450,
790,
9,
272,
372,
715,
199,
199,
318,
485,
912,
63,
7515,
8,
11219,
304,
272,
298,
10474,
1380,
314,
8823,
14404,
4072,
2,
272,
790,
275,
8025,
14,
697,
423,
3029,
3257,
63,
3773,
498,
272,
1336,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
790,
61,
272,
340,
1336,
26,
267,
372,
8025,
14,
697,
14,
3029,
3257,
59,
1431,
59,
16,
22235,
17,
61,
272,
372,
3087,
199,
199,
318,
485,
10589,
63,
7515,
8,
11219,
304,
272,
298,
10474,
1380,
314,
8823,
2173,
1405,
2,
272,
2150,
8025,
14,
697,
423,
3029,
3257,
63,
3773,
498,
272,
8025,
14,
1328,
480,
920,
5703,
8823,
2685,
421
] |
[
199,
29704,
22042,
26550,
21934,
3257,
281,
199,
199,
714,
1925,
446,
598,
322,
693,
7800,
199,
199,
33,
298,
3029,
3257,
281,
2,
365,
282,
19834,
687,
314,
603,
14527,
6701,
14,
2779,
6127,
367,
199,
20358,
12,
28453,
436,
31620,
3382,
3663,
4528,
199,
21713,
14,
961,
3510,
3257,
281,
911,
440,
4409,
1263,
4493,
370,
314,
199,
14852,
1021,
12,
7830,
652,
911,
675,
314,
658,
3029,
3257,
83,
64,
3882,
334,
65,
199,
513,
9,
436,
1218,
652,
340,
652,
1630,
440,
2187,
14,
199,
199,
2765,
5914,
2597,
5419,
5521,
10451,
543,
314,
519,
1190,
3045,
5914,
334,
6777,
199,
12344,
9584,
314,
3974,
18714,
436,
314,
658,
83,
3257,
64,
1414,
680,
421,
199,
31456,
26,
199,
199,
4685,
658,
1662,
5097,
15,
4405,
15,
885,
63,
1760,
2193,
14,
647,
64,
436,
1050,
199,
64,
504,
5914,
14,
3029,
3257,
492,
26005,
3947,
9921,
64,
370,
314,
2746,
14,
199,
199,
5765,
12,
3648,
1536,
314,
658,
292,
63,
1760,
409,
63,
981,
64,
1083,
402,
314,
658,
14852,
7874,
1084,
64,
199,
533,
436,
1050,
282,
1004,
658,
277,
14,
525,
8,
7874,
3947,
9921,
1012,
64,
370,
314,
1284,
199,
1618,
652,
14,
199,
199,
30590,
314,
1654,
436,
1265,
1077,
1172,
314,
435,
3257,
1414,
2808,
334,
390,
199,
14117,
3350,
314,
849,
658,
3257,
64,
1414,
680,
199,
199,
624,
199,
646,
295,
199,
504,
2755,
22042,
492,
849,
63,
12975,
199,
504,
2755,
22042,
14,
1208,
14,
1208,
492,
18366,
199,
504,
2755,
22042,
14,
1208,
14,
4754,
27050,
492,
662,
86,
10423,
421,
199,
3,
5163,
367,
314,
663,
9330,
199,
63,
907,
63,
17434,
275,
295,
14,
2014,
8,
82,
2,
16510,
87,
60,
83,
11896,
15840,
11,
15279,
4186,
295,
14,
53,
435,
295,
14,
41,
9,
421,
199,
3,
11642,
3423,
367,
314,
5817,
199,
199,
533,
8055,
67,
12584,
547,
8,
3393,
304,
272,
298,
9167,
367,
5190,
83,
687,
4328,
10460,
2,
272,
986,
421,
199,
318,
485,
873,
63,
1617,
8,
11219,
12,
790,
29,
403,
12,
4328,
29,
403,
12,
3145,
29,
797,
12,
11413,
498,
29,
403,
304,
272,
408,
272,
11642,
805,
367,
12928,
314,
3050,
3877,
14,
339,
3033,
26,
267,
8025,
334,
1692,
304,
710,
8025,
402,
314,
1414,
14,
267,
790,
334,
495,
304,
11994,
5148,
267,
4328,
334,
495,
304,
11994,
1318,
14,
267,
3145,
334,
2245,
304,
8496,
1627,
790,
14,
267,
11413,
498,
334,
495,
304,
16666,
439,
769,
12266,
402,
658,
498,
64,
436,
642,
790,
14,
339,
408,
272,
340,
440,
8025,
14,
697,
14,
3029,
3257,
26,
267,
327,
8265,
314,
3510,
3257,
2225,
267,
8025,
14,
697,
14,
3029,
3257,
275,
10003,
11219,
401,
8025,
14,
697,
14,
3257,
503,
6899,
61,
272,
340,
440,
790,
26,
267,
372,
272,
560,
498,
275,
790,
14,
2325,
342,
272,
1336,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
560,
498,
61,
272,
340,
1336,
26,
267,
284,
3257,
275,
1336,
59,
16,
61,
267,
340,
3145,
26,
288,
327,
3145,
2397,
288,
2150,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
267,
916,
11413,
498,
26,
288,
327,
11413,
12266,
288,
560,
9286,
498,
275,
11413,
498,
14,
2325,
342,
288,
11413,
1431,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
560,
9286,
498,
61,
288,
340,
11413,
1431,
26,
355,
365,
25529,
275,
11413,
1431,
59,
16,
61,
355,
340,
284,
3257,
508,
365,
25529,
26,
490,
746,
8055,
67,
12584,
547,
480,
10941,
3262,
282,
790,
543,
6337,
1630,
6548,
2685,
355,
2388,
275,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
355,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
275,
8025,
14,
697,
14,
3029,
3257,
59,
374,
25529,
61,
355,
8025,
14,
697,
14,
3029,
3257,
59,
374,
25529,
61,
275,
2388,
288,
587,
26,
355,
746,
8055,
67,
12584,
547,
480,
5831,
790,
11280,
87,
5,
83,
92,
78,
7,
440,
1911,
2122,
450,
11413,
498,
9,
267,
916,
4328,
26,
288,
327,
1678,
315,
13,
2778,
288,
8025,
14,
697,
14,
3029,
3257,
59,
2655,
551,
61,
275,
334,
320,
498,
12,
4328,
9,
267,
587,
26,
288,
746,
8055,
67,
12584,
547,
480,
1944,
1369,
1990,
663,
2685,
272,
587,
26,
267,
327,
949,
4877,
790,
267,
340,
3145,
503,
11413,
498,
26,
288,
746,
8055,
67,
12584,
547,
480,
5831,
790,
11280,
87,
5,
83,
92,
78,
7,
440,
1911,
2122,
450,
790,
9,
267,
916,
4328,
26,
288,
327,
5518,
892,
737,
314,
2746,
402,
314,
3464,
288,
8025,
14,
697,
14,
3029,
3257,
14,
3176,
8,
16,
12,
334,
320,
498,
12,
4328,
430,
267,
587,
26,
288,
746,
8055,
67,
12584,
547,
480,
1944,
1369,
1990,
663,
2685,
199,
199,
3,
325,
432,
27050,
3354,
15,
912,
15,
10589,
3423,
199,
199,
318,
485,
2117,
63,
7515,
8,
11219,
12,
3335,
304,
272,
298,
10474,
1380,
314,
8823,
23050,
2399,
4072,
2,
272,
790,
275,
8025,
14,
697,
423,
3029,
3257,
63,
3773,
498,
272,
485,
873,
63,
1617,
8,
11219,
12,
790,
12,
3335,
9,
272,
8025,
14,
1328,
480,
21969,
1369,
370,
790,
1543,
83,
16669,
450,
790,
9,
272,
372,
715,
199,
199,
318,
485,
912,
63,
7515,
8,
11219,
304,
272,
298,
10474,
1380,
314,
8823,
14404,
4072,
2,
272,
790,
275,
8025,
14,
697,
423,
3029,
3257,
63,
3773,
498,
272,
1336,
275,
359,
688,
367,
7654,
12,
16477,
315,
3874,
8,
11219,
14,
697,
14,
3029,
3257,
9,
340,
16477,
59,
16,
61,
508,
790,
61,
272,
340,
1336,
26,
267,
372,
8025,
14,
697,
14,
3029,
3257,
59,
1431,
59,
16,
22235,
17,
61,
272,
372,
3087,
199,
199,
318,
485,
10589,
63,
7515,
8,
11219,
304,
272,
298,
10474,
1380,
314,
8823,
2173,
1405,
2,
272,
2150,
8025,
14,
697,
423,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
stephane-martin/salt-debian-packaging
|
salt-2016.3.3/salt/modules/bigip.py
|
2
|
69757
|
# -*- coding: utf-8 -*-
'''
An execution module which can manipulate an f5 bigip via iControl REST
:maturity: develop
:platform: f5_bigip_11.6
'''
# Import python libs
from __future__ import absolute_import
import json
import logging as logger
# Import third party libs
try:
import requests
import requests.exceptions
HAS_LIBS = True
except ImportError:
HAS_LIBS = False
# Import 3rd-party libs
import salt.ext.six as six
# Import salt libs
import salt.utils
import salt.output
import salt.exceptions
# Setup the logger
log = logger.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'bigip'
def __virtual__():
'''
Only return if requests is installed
'''
if HAS_LIBS:
return __virtualname__
return (False, 'The bigip execution module cannot be loaded: '
'python requests library not available.')
BIG_IP_URL_BASE = 'https://{host}/mgmt/tm'
def _build_session(username, password, trans_label=None):
'''
Create a session to be used when connecting to iControl REST.
'''
bigip = requests.session()
bigip.auth = (username, password)
bigip.verify = False
bigip.headers.update({'Content-Type': 'application/json'})
if trans_label:
#pull the trans id from the grain
trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=trans_label))
if trans_id:
bigip.headers.update({'X-F5-REST-Coordination-Id': trans_id})
else:
bigip.headers.update({'X-F5-REST-Coordination-Id': None})
return bigip
def _load_response(response):
'''
Load the response from json data, return the dictionary or raw text
'''
try:
data = json.loads(response.text)
except ValueError:
data = response.text
ret = {'code': response.status_code, 'content': data}
return ret
def _load_connection_error(hostname, error):
'''
Format and Return a connection error
'''
ret = {'code': None, 'content': 'Error: Unable to connect to the bigip device: {host}\n{error}'.format(host=hostname, error=error)}
return ret
def _loop_payload(params):
'''
Pass in a dictionary of parameters, loop through them and build a payload containing,
parameters who's values are not None.
'''
#construct the payload
payload = {}
#set the payload
for param, value in six.iteritems(params):
if value is not None:
payload[param] = value
return payload
def _build_list(option_value, item_kind):
'''
pass in an option to check for a list of items, create a list of dictionary of items to set
for this option
'''
#specify profiles if provided
if option_value is not None:
items = []
#if user specified none, return an empty list
if option_value == 'none':
return items
#was a list already passed in?
if not isinstance(option_value, list):
values = option_value.split(',')
else:
values = option_value
for value in values:
# sometimes the bigip just likes a plain ol list of items
if item_kind is None:
items.append(value)
# other times it's picky and likes key value pairs...
else:
items.append({'kind': item_kind, 'name': value})
return items
return None
def _determine_toggles(payload, toggles):
'''
BigIP can't make up its mind if it likes yes / no or true or false.
Figure out what it likes to hear without confusing the user.
'''
for toggle, definition in six.iteritems(toggles):
#did the user specify anything?
if definition['value'] is not None:
#test for yes_no toggle
if (definition['value'] is True or definition['value'] == 'yes') and definition['type'] == 'yes_no':
payload[toggle] = 'yes'
elif (definition['value'] is False or definition['value'] == 'no') and definition['type'] == 'yes_no':
payload[toggle] = 'no'
#test for true_false toggle
if (definition['value'] is True or definition['value'] == 'yes') and definition['type'] == 'true_false':
payload[toggle] = True
elif (definition['value'] is False or definition['value'] == 'no') and definition['type'] == 'true_false':
payload[toggle] = False
return payload
def _set_value(value):
'''
A function to detect if user is trying to pass a dictionary or list. parse it and return a
dictionary list or a string
'''
logger.error(value)
#don't continue if already an acceptable data-type
if isinstance(value, bool) or isinstance(value, dict) or isinstance(value, list):
return value
#check if json
if value.startswith('j{') and value.endswith('}j'):
value = value.replace('j{', '{')
value = value.replace('}j', '}')
try:
return json.loads(value)
except Exception:
raise salt.exceptions.CommandExecutionError
#detect list of dictionaries
if '|' in value and r'\|' not in value:
values = value.split('|')
items = []
for value in values:
items.append(_set_value(value))
return items
#parse out dictionary if detected
if ':' in value and r'\:' not in value:
options = {}
#split out pairs
key_pairs = value.split(',')
for key_pair in key_pairs:
k = key_pair.split(':')[0]
v = key_pair.split(':')[1]
options[k] = v
return options
#try making a list
elif ',' in value and r'\,' not in value:
value_items = value.split(',')
return value_items
#just return a string
else:
#remove escape chars if added
if r'\|' in value:
value = value.replace(r'\|', '|')
if r'\:' in value:
value = value.replace(r'\:', ':')
if r'\,' in value:
value = value.replace(r'\,', ',')
return value
def start_transaction(hostname, username, password, label):
'''
A function to connect to a bigip device and start a new transaction.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
label
The name / alias for this transaction. The actual transaction
id will be stored within a grain called ``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.start_transaction bigip admin admin my_transaction
'''
#build the session
bigip_session = _build_session(username, password)
payload = {}
#post to REST to get trans id
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/transaction', data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
#extract the trans_id
data = _load_response(response)
if data['code'] == 200:
trans_id = data['content']['transId']
__salt__['grains.setval']('bigip_f5_trans', {label: trans_id})
return 'Transaction: {trans_id} - has successfully been stored in the grain: bigip_f5_trans:{label}'.format(trans_id=trans_id,
label=label)
else:
return data
def list_transaction(hostname, username, password, label):
'''
A function to connect to a bigip device and list an existing transaction.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
label
the label of this transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.list_transaction bigip admin admin my_transaction
'''
#build the session
bigip_session = _build_session(username, password)
#pull the trans id from the grain
trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=label))
if trans_id:
#post to REST to get trans id
try:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/transaction/{trans_id}/commands'.format(trans_id=trans_id))
return _load_response(response)
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
else:
return 'Error: the label for this transaction was not defined as a grain. Begin a new transaction using the' \
' bigip.start_transaction function'
def commit_transaction(hostname, username, password, label):
'''
A function to connect to a bigip device and commit an existing transaction.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
label
the label of this transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.commit_transaction bigip admin admin my_transaction
'''
#build the session
bigip_session = _build_session(username, password)
#pull the trans id from the grain
trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=label))
if trans_id:
payload = {}
payload['state'] = 'VALIDATING'
#patch to REST to get trans id
try:
response = bigip_session.patch(BIG_IP_URL_BASE.format(host=hostname)+'/transaction/{trans_id}'.format(trans_id=trans_id), data=json.dumps(payload))
return _load_response(response)
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
else:
return 'Error: the label for this transaction was not defined as a grain. Begin a new transaction using the' \
' bigip.start_transaction function'
def delete_transaction(hostname, username, password, label):
'''
A function to connect to a bigip device and delete an existing transaction.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
label
The label of this transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.delete_transaction bigip admin admin my_transaction
'''
#build the session
bigip_session = _build_session(username, password)
#pull the trans id from the grain
trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=label))
if trans_id:
#patch to REST to get trans id
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/transaction/{trans_id}'.format(trans_id=trans_id))
return _load_response(response)
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
else:
return 'Error: the label for this transaction was not defined as a grain. Begin a new transaction using the' \
' bigip.start_transaction function'
def list_node(hostname, username, password, name=None, trans_label=None):
'''
A function to connect to a bigip device and list all nodes or a specific node.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the node to list. If no name is specified than all nodes
will be listed.
trans_label
The label of the transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.list_node bigip admin admin my-node
'''
#build sessions
bigip_session = _build_session(username, password, trans_label)
#get to REST
try:
if name:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/node/{name}'.format(name=name))
else:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/node')
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def create_node(hostname, username, password, name, address, trans_label=None):
'''
A function to connect to a bigip device and create a node.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the node
address
The address of the node
trans_label
The label of the transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.create_node bigip admin admin 10.1.1.2
'''
#build session
bigip_session = _build_session(username, password, trans_label)
#construct the payload
payload = {}
payload['name'] = name
payload['address'] = address
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/node', data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_node(hostname, username, password, name,
connection_limit=None,
description=None,
dynamic_ratio=None,
logging=None,
monitor=None,
rate_limit=None,
ratio=None,
session=None,
state=None,
trans_label=None):
'''
A function to connect to a bigip device and modify an existing node.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the node to modify
connection_limit
[integer]
description
[string]
dynamic_ratio
[integer]
logging
[enabled | disabled]
monitor
[[name] | none | default]
rate_limit
[integer]
ratio
[integer]
session
[user-enabled | user-disabled]
state
[user-down | user-up ]
trans_label
The label of the transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.modify_node bigip admin admin 10.1.1.2 ratio=2 logging=enabled
'''
params = {
'connection-limit': connection_limit,
'description': description,
'dynamic-ratio': dynamic_ratio,
'logging': logging,
'monitor': monitor,
'rate-limit': rate_limit,
'ratio': ratio,
'session': session,
'state': state,
}
#build session
bigip_session = _build_session(username, password, trans_label)
#build payload
payload = _loop_payload(params)
payload['name'] = name
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/node/{name}'.format(name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_node(hostname, username, password, name, trans_label=None):
'''
A function to connect to a bigip device and delete a specific node.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the node which will be deleted.
trans_label
The label of the transaction stored within the grain:
``bigip_f5_trans:<label>``
CLI Example::
salt '*' bigip.delete_node bigip admin admin my-node
'''
#build session
bigip_session = _build_session(username, password, trans_label)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/node/{name}'.format(name=name))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
def list_pool(hostname, username, password, name=None):
'''
A function to connect to a bigip device and list all pools or a specific pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to list. If no name is specified then all pools
will be listed.
CLI Example::
salt '*' bigip.list_pool bigip admin admin my-pool
'''
#build sessions
bigip_session = _build_session(username, password)
#get to REST
try:
if name:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}/?expandSubcollections=true'.format(name=name))
else:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool')
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def create_pool(hostname, username, password, name, members=None,
allow_nat=None,
allow_snat=None,
description=None,
gateway_failsafe_device=None,
ignore_persisted_weight=None,
ip_tos_to_client=None,
ip_tos_to_server=None,
link_qos_to_client=None,
link_qos_to_server=None,
load_balancing_mode=None,
min_active_members=None,
min_up_members=None,
min_up_members_action=None,
min_up_members_checking=None,
monitor=None,
profiles=None,
queue_depth_limit=None,
queue_on_connection_limit=None,
queue_time_limit=None,
reselect_tries=None,
service_down_action=None,
slow_ramp_time=None):
'''
A function to connect to a bigip device and create a pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to create.
members
List of comma delimited pool members to add to the pool.
i.e. 10.1.1.1:80,10.1.1.2:80,10.1.1.3:80
allow_nat
[yes | no]
allow_snat
[yes | no]
description
[string]
gateway_failsafe_device
[string]
ignore_persisted_weight
[enabled | disabled]
ip_tos_to_client
[pass-through | [integer]]
ip_tos_to_server
[pass-through | [integer]]
link_qos_to_client
[pass-through | [integer]]
link_qos_to_server
[pass-through | [integer]]
load_balancing_mode
[dynamic-ratio-member | dynamic-ratio-node |
fastest-app-response | fastest-node |
least-connections-members |
least-connections-node |
least-sessions |
observed-member | observed-node |
predictive-member | predictive-node |
ratio-least-connections-member |
ratio-least-connections-node |
ratio-member | ratio-node | ratio-session |
round-robin | weighted-least-connections-member |
weighted-least-connections-node]
min_active_members
[integer]
min_up_members
[integer]
min_up_members_action
[failover | reboot | restart-all]
min_up_members_checking
[enabled | disabled]
monitor
[name]
profiles
[none | profile_name]
queue_depth_limit
[integer]
queue_on_connection_limit
[enabled | disabled]
queue_time_limit
[integer]
reselect_tries
[integer]
service_down_action
[drop | none | reselect | reset]
slow_ramp_time
[integer]
CLI Example::
salt '*' bigip.create_pool bigip admin admin my-pool 10.1.1.1:80,10.1.1.2:80,10.1.1.3:80 monitor=http
'''
params = {
'description': description,
'gateway-failsafe-device': gateway_failsafe_device,
'ignore-persisted-weight': ignore_persisted_weight,
'ip-tos-to-client': ip_tos_to_client,
'ip-tos-to-server': ip_tos_to_server,
'link-qos-to-client': link_qos_to_client,
'link-qos-to-server': link_qos_to_server,
'load-balancing-mode': load_balancing_mode,
'min-active-members': min_active_members,
'min-up-members': min_up_members,
'min-up-members-action': min_up_members_action,
'min-up-members-checking': min_up_members_checking,
'monitor': monitor,
'profiles': profiles,
'queue-on-connection-limit': queue_on_connection_limit,
'queue-depth-limit': queue_depth_limit,
'queue-time-limit': queue_time_limit,
'reselect-tries': reselect_tries,
'service-down-action': service_down_action,
'slow-ramp-time': slow_ramp_time
}
# some options take yes no others take true false. Figure out when to use which without
# confusing the end user
toggles = {
'allow-nat': {'type': 'yes_no', 'value': allow_nat},
'allow-snat': {'type': 'yes_no', 'value': allow_snat}
}
#build payload
payload = _loop_payload(params)
payload['name'] = name
#determine toggles
payload = _determine_toggles(payload, toggles)
#specify members if provided
if members is not None:
payload['members'] = _build_list(members, 'ltm:pool:members')
#build session
bigip_session = _build_session(username, password)
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool', data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_pool(hostname, username, password, name,
allow_nat=None,
allow_snat=None,
description=None,
gateway_failsafe_device=None,
ignore_persisted_weight=None,
ip_tos_to_client=None,
ip_tos_to_server=None,
link_qos_to_client=None,
link_qos_to_server=None,
load_balancing_mode=None,
min_active_members=None,
min_up_members=None,
min_up_members_action=None,
min_up_members_checking=None,
monitor=None,
profiles=None,
queue_depth_limit=None,
queue_on_connection_limit=None,
queue_time_limit=None,
reselect_tries=None,
service_down_action=None,
slow_ramp_time=None):
'''
A function to connect to a bigip device and modify an existing pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to modify.
allow_nat
[yes | no]
allow_snat
[yes | no]
description
[string]
gateway_failsafe_device
[string]
ignore_persisted_weight
[yes | no]
ip_tos_to_client
[pass-through | [integer]]
ip_tos_to_server
[pass-through | [integer]]
link_qos_to_client
[pass-through | [integer]]
link_qos_to_server
[pass-through | [integer]]
load_balancing_mode
[dynamic-ratio-member | dynamic-ratio-node |
fastest-app-response | fastest-node |
least-connections-members |
least-connections-node |
least-sessions |
observed-member | observed-node |
predictive-member | predictive-node |
ratio-least-connections-member |
ratio-least-connections-node |
ratio-member | ratio-node | ratio-session |
round-robin | weighted-least-connections-member |
weighted-least-connections-node]
min_active_members
[integer]
min_up_members
[integer]
min_up_members_action
[failover | reboot | restart-all]
min_up_members_checking
[enabled | disabled]
monitor
[name]
profiles
[none | profile_name]
queue_on_connection_limit
[enabled | disabled]
queue_depth_limit
[integer]
queue_time_limit
[integer]
reselect_tries
[integer]
service_down_action
[drop | none | reselect | reset]
slow_ramp_time
[integer]
CLI Example::
salt '*' bigip.modify_pool bigip admin admin my-pool 10.1.1.1:80,10.1.1.2:80,10.1.1.3:80 min_active_members=1
'''
params = {
'description': description,
'gateway-failsafe-device': gateway_failsafe_device,
'ignore-persisted-weight': ignore_persisted_weight,
'ip-tos-to-client': ip_tos_to_client,
'ip-tos-to-server': ip_tos_to_server,
'link-qos-to-client': link_qos_to_client,
'link-qos-to-server': link_qos_to_server,
'load-balancing-mode': load_balancing_mode,
'min-active-members': min_active_members,
'min-up-members': min_up_members,
'min-up_members-action': min_up_members_action,
'min-up-members-checking': min_up_members_checking,
'monitor': monitor,
'profiles': profiles,
'queue-on-connection-limit': queue_on_connection_limit,
'queue-depth-limit': queue_depth_limit,
'queue-time-limit': queue_time_limit,
'reselect-tries': reselect_tries,
'service-down-action': service_down_action,
'slow-ramp-time': slow_ramp_time
}
# some options take yes no others take true false. Figure out when to use which without
# confusing the end user
toggles = {
'allow-nat': {'type': 'yes_no', 'value': allow_nat},
'allow-snat': {'type': 'yes_no', 'value': allow_snat}
}
#build payload
payload = _loop_payload(params)
payload['name'] = name
#determine toggles
payload = _determine_toggles(payload, toggles)
#build session
bigip_session = _build_session(username, password)
#post to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}'.format(name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_pool(hostname, username, password, name):
'''
A function to connect to a bigip device and delete a specific pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool which will be deleted
CLI Example::
salt '*' bigip.delete_node bigip admin admin my-pool
'''
#build session
bigip_session = _build_session(username, password)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}'.format(name=name))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
def replace_pool_members(hostname, username, password, name, members):
'''
A function to connect to a bigip device and replace members of an existing pool with new members.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to modify
members
List of comma delimited pool members to replace existing members with.
i.e. 10.1.1.1:80,10.1.1.2:80,10.1.1.3:80
CLI Example::
salt '*' bigip.replace_pool_members bigip admin admin my-pool 10.2.2.1:80,10.2.2.2:80,10.2.2.3:80
'''
payload = {}
payload['name'] = name
#specify members if provided
if members is not None:
if isinstance(members, str):
members = members.split(',')
pool_members = []
for member in members:
#check to see if already a dictionary ( for states)
if isinstance(member, dict):
#check for state alternative name 'member_state', replace with state
if 'member_state' in member.keys():
member['state'] = member.pop('member_state')
#replace underscore with dash
for key in member.keys():
new_key = key.replace('_', '-')
member[new_key] = member.pop(key)
pool_members.append(member)
#parse string passed via execution command (for executions)
else:
pool_members.append({'name': member, 'address': member.split(':')[0]})
payload['members'] = pool_members
#build session
bigip_session = _build_session(username, password)
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}'.format(name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def add_pool_member(hostname, username, password, name, member):
'''
A function to connect to a bigip device and add a new member to an existing pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to modify
member
The name of the member to add
i.e. 10.1.1.2:80
CLI Example:
.. code-block:: bash
salt '*' bigip.add_pool_members bigip admin admin my-pool 10.2.2.1:80
'''
# for states
if isinstance(member, dict):
#check for state alternative name 'member_state', replace with state
if 'member_state' in member.keys():
member['state'] = member.pop('member_state')
#replace underscore with dash
for key in member.keys():
new_key = key.replace('_', '-')
member[new_key] = member.pop(key)
payload = member
# for execution
else:
payload = {'name': member, 'address': member.split(':')[0]}
#build session
bigip_session = _build_session(username, password)
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}/members'.format(name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_pool_member(hostname, username, password, name, member,
connection_limit=None,
description=None,
dynamic_ratio=None,
inherit_profile=None,
logging=None,
monitor=None,
priority_group=None,
profiles=None,
rate_limit=None,
ratio=None,
session=None,
state=None):
'''
A function to connect to a bigip device and modify an existing member of a pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to modify
member
The name of the member to modify i.e. 10.1.1.2:80
connection_limit
[integer]
description
[string]
dynamic_ratio
[integer]
inherit_profile
[enabled | disabled]
logging
[enabled | disabled]
monitor
[name]
priority_group
[integer]
profiles
[none | profile_name]
rate_limit
[integer]
ratio
[integer]
session
[user-enabled | user-disabled]
state
[ user-up | user-down ]
CLI Example::
salt '*' bigip.modify_pool_member bigip admin admin my-pool 10.2.2.1:80 state=use-down session=user-disabled
'''
params = {
'connection-limit': connection_limit,
'description': description,
'dynamic-ratio': dynamic_ratio,
'inherit-profile': inherit_profile,
'logging': logging,
'monitor': monitor,
'priority-group': priority_group,
'profiles': profiles,
'rate-limit': rate_limit,
'ratio': ratio,
'session': session,
'state': state
}
#build session
bigip_session = _build_session(username, password)
#build payload
payload = _loop_payload(params)
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}/members/{member}'.format(name=name, member=member), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_pool_member(hostname, username, password, name, member):
'''
A function to connect to a bigip device and delete a specific pool.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the pool to modify
member
The name of the pool member to delete
CLI Example::
salt '*' bigip.delete_node bigip admin admin my-pool 10.2.2.2:80
'''
#build session
bigip_session = _build_session(username, password)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/pool/{name}/members/{member}'.format(name=name, member=member))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
def list_virtual(hostname, username, password, name=None):
'''
A function to connect to a bigip device and list all virtuals or a specific virtual.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the virtual to list. If no name is specified than all
virtuals will be listed.
CLI Example::
salt '*' bigip.list_virtual bigip admin admin my-virtual
'''
#build sessions
bigip_session = _build_session(username, password)
#get to REST
try:
if name:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/virtual/{name}/?expandSubcollections=true'.format(name=name))
else:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/virtual')
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def create_virtual(hostname, username, password, name, destination,
pool=None,
address_status=None,
auto_lasthop=None,
bwc_policy=None,
cmp_enabled=None,
connection_limit=None,
dhcp_relay=None,
description=None,
fallback_persistence=None,
flow_eviction_policy=None,
gtm_score=None,
ip_forward=None,
ip_protocol=None,
internal=None,
twelve_forward=None,
last_hop_pool=None,
mask=None,
mirror=None,
nat64=None,
persist=None,
profiles=None,
policies=None,
rate_class=None,
rate_limit=None,
rate_limit_mode=None,
rate_limit_dst=None,
rate_limit_src=None,
rules=None,
related_rules=None,
reject=None,
source=None,
source_address_translation=None,
source_port=None,
state=None,
traffic_classes=None,
translate_address=None,
translate_port=None,
vlans=None):
r'''
A function to connect to a bigip device and create a virtual server.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the virtual to create
destination
[ [virtual_address_name:port] | [ipv4:port] | [ipv6.port] ]
pool
[ [pool_name] | none]
address_status
[yes | no]
auto_lasthop
[default | enabled | disabled ]
bwc_policy
[none] | string]
cmp_enabled
[yes | no]
dhcp_relay
[yes | no]
connection_limit
[integer]
description
[string]
state
[disabled | enabled]
fallback_persistence
[none | [profile name] ]
flow_eviction_policy
[none | [eviction policy name] ]
gtm_score
[integer]
ip_forward
[yes | no]
ip_protocol
[any | protocol]
internal
[yes | no]
twelve_forward
(12-forward)
[yes | no]
last_hop-pool
[ [pool_name] | none]
mask
{ [ipv4] | [ipv6] }
mirror
{ [disabled | enabled | none] }
nat64
[enabled | disabled]
persist
[none | profile1,profile2,profile3 ... ]
profiles
[none | default | profile1,profile2,profile3 ... ]
policies
[none | default | policy1,policy2,policy3 ... ]
rate_class
[name]
rate_limit
[integer]
rate_limit_mode
[destination | object | object-destination |
object-source | object-source-destination |
source | source-destination]
rate_limit_dst
[integer]
rate_limitçsrc
[integer]
rules
[none | [rule_one,rule_two ...] ]
related_rules
[none | [rule_one,rule_two ...] ]
reject
[yes | no]
source
{ [ipv4[/prefixlen]] | [ipv6[/prefixlen]] }
source_address_translation
[none | snat:pool_name | lsn | automap ]
source_port
[change | preserve | preserve-strict]
state
[enabled | disabled]
traffic_classes
[none | default | class_one,class_two ... ]
translate_address
[enabled | disabled]
translate_port
[enabled | disabled]
vlans
[none | default | [enabled|disabled]:vlan1,vlan2,vlan3 ... ]
CLI Examples::
salt '*' bigip.create_virtual bigip admin admin my-virtual-3 26.2.2.5:80 \
pool=my-http-pool-http profiles=http,tcp
salt '*' bigip.create_virtual bigip admin admin my-virtual-3 43.2.2.5:80 \
pool=test-http-pool-http profiles=http,websecurity persist=cookie,hash \
policies=asm_auto_l7_policy__http-virtual \
rules=_sys_APM_ExchangeSupport_helper,_sys_https_redirect \
related_rules=_sys_APM_activesync,_sys_APM_ExchangeSupport_helper \
source_address_translation=snat:my-snat-pool \
translate_address=enabled translate_port=enabled \
traffic_classes=my-class,other-class \
vlans=enabled:external,internal
'''
params = {
'pool': pool,
'auto-lasthop': auto_lasthop,
'bwc-policy': bwc_policy,
'connection-limit': connection_limit,
'description': description,
'fallback-persistence': fallback_persistence,
'flow-eviction-policy': flow_eviction_policy,
'gtm-score': gtm_score,
'ip-protocol': ip_protocol,
'last-hop-pool': last_hop_pool,
'mask': mask,
'mirror': mirror,
'nat64': nat64,
'persist': persist,
'rate-class': rate_class,
'rate-limit': rate_limit,
'rate-limit-mode': rate_limit_mode,
'rate-limit-dst': rate_limit_dst,
'rate-limit-src': rate_limit_src,
'source': source,
'source-port': source_port,
'translate-address': translate_address,
'translate-port': translate_port
}
# some options take yes no others take true false. Figure out when to use which without
# confusing the end user
toggles = {
'address-status': {'type': 'yes_no', 'value': address_status},
'cmp-enabled': {'type': 'yes_no', 'value': cmp_enabled},
'dhcp-relay': {'type': 'true_false', 'value': dhcp_relay},
'reject': {'type': 'true_false', 'value': reject},
'12-forward': {'type': 'true_false', 'value': twelve_forward},
'internal': {'type': 'true_false', 'value': internal},
'ip-forward': {'type': 'true_false', 'value': ip_forward}
}
#build session
bigip_session = _build_session(username, password)
#build payload
payload = _loop_payload(params)
payload['name'] = name
payload['destination'] = destination
#determine toggles
payload = _determine_toggles(payload, toggles)
#specify profiles if provided
if profiles is not None:
payload['profiles'] = _build_list(profiles, 'ltm:virtual:profile')
#specify persist if provided
if persist is not None:
payload['persist'] = _build_list(persist, 'ltm:virtual:persist')
#specify policies if provided
if policies is not None:
payload['policies'] = _build_list(policies, 'ltm:virtual:policy')
#specify rules if provided
if rules is not None:
payload['rules'] = _build_list(rules, None)
#specify related-rules if provided
if related_rules is not None:
payload['related-rules'] = _build_list(related_rules, None)
#handle source-address-translation
if source_address_translation is not None:
#check to see if this is already a dictionary first
if isinstance(source_address_translation, dict):
payload['source-address-translation'] = source_address_translation
elif source_address_translation == 'none':
payload['source-address-translation'] = {'pool': 'none', 'type': 'none'}
elif source_address_translation == 'automap':
payload['source-address-translation'] = {'pool': 'none', 'type': 'automap'}
elif source_address_translation == 'lsn':
payload['source-address-translation'] = {'pool': 'none', 'type': 'lsn'}
elif source_address_translation.startswith('snat'):
snat_pool = source_address_translation.split(':')[1]
payload['source-address-translation'] = {'pool': snat_pool, 'type': 'snat'}
#specify related-rules if provided
if traffic_classes is not None:
payload['traffic-classes'] = _build_list(traffic_classes, None)
#handle vlans
if vlans is not None:
#ceck to see if vlans is a dictionary (used when state makes use of function)
if isinstance(vlans, dict):
try:
payload['vlans'] = vlans['vlan_ids']
if vlans['enabled']:
payload['vlans-enabled'] = True
elif vlans['disabled']:
payload['vlans-disabled'] = True
except Exception:
return 'Error: Unable to Parse vlans dictionary: \n\tvlans={vlans}'.format(vlans=vlans)
elif vlans == 'none':
payload['vlans'] = 'none'
elif vlans == 'default':
payload['vlans'] = 'default'
elif isinstance(vlans, str) and (vlans.startswith('enabled') or vlans.startswith('disabled')):
try:
vlans_setting = vlans.split(':')[0]
payload['vlans'] = vlans.split(':')[1].split(',')
if vlans_setting == 'disabled':
payload['vlans-disabled'] = True
elif vlans_setting == 'enabled':
payload['vlans-enabled'] = True
except Exception:
return 'Error: Unable to Parse vlans option: \n\tvlans={vlans}'.format(vlans=vlans)
else:
return 'Error: vlans must be a dictionary or string.'
#determine state
if state is not None:
if state == 'enabled':
payload['enabled'] = True
elif state == 'disabled':
payload['disabled'] = True
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/virtual', data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_virtual(hostname, username, password, name,
destination=None,
pool=None,
address_status=None,
auto_lasthop=None,
bwc_policy=None,
cmp_enabled=None,
connection_limit=None,
dhcp_relay=None,
description=None,
fallback_persistence=None,
flow_eviction_policy=None,
gtm_score=None,
ip_forward=None,
ip_protocol=None,
internal=None,
twelve_forward=None,
last_hop_pool=None,
mask=None,
mirror=None,
nat64=None,
persist=None,
profiles=None,
policies=None,
rate_class=None,
rate_limit=None,
rate_limit_mode=None,
rate_limit_dst=None,
rate_limit_src=None,
rules=None,
related_rules=None,
reject=None,
source=None,
source_address_translation=None,
source_port=None,
state=None,
traffic_classes=None,
translate_address=None,
translate_port=None,
vlans=None):
'''
A function to connect to a bigip device and modify an existing virtual server.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the virtual to modify
destination
[ [virtual_address_name:port] | [ipv4:port] | [ipv6.port] ]
pool
[ [pool_name] | none]
address_status
[yes | no]
auto_lasthop
[default | enabled | disabled ]
bwc_policy
[none] | string]
cmp_enabled
[yes | no]
dhcp_relay
[yes | no}
connection_limit
[integer]
description
[string]
state
[disabled | enabled]
fallback_persistence
[none | [profile name] ]
flow_eviction_policy
[none | [eviction policy name] ]
gtm_score
[integer]
ip_forward
[yes | no]
ip_protocol
[any | protocol]
internal
[yes | no]
twelve_forward
(12-forward)
[yes | no]
last_hop-pool
[ [pool_name] | none]
mask
{ [ipv4] | [ipv6] }
mirror
{ [disabled | enabled | none] }
nat64
[enabled | disabled]
persist
[none | profile1,profile2,profile3 ... ]
profiles
[none | default | profile1,profile2,profile3 ... ]
policies
[none | default | policy1,policy2,policy3 ... ]
rate_class
[name]
rate_limit
[integer]
rate_limitr_mode
[destination | object | object-destination |
object-source | object-source-destination |
source | source-destination]
rate_limit_dst
[integer]
rate_limit_src
[integer]
rules
[none | [rule_one,rule_two ...] ]
related_rules
[none | [rule_one,rule_two ...] ]
reject
[yes | no]
source
{ [ipv4[/prefixlen]] | [ipv6[/prefixlen]] }
source_address_translation
[none | snat:pool_name | lsn | automap ]
source_port
[change | preserve | preserve-strict]
state
[enabled | disable]
traffic_classes
[none | default | class_one,class_two ... ]
translate_address
[enabled | disabled]
translate_port
[enabled | disabled]
vlans
[none | default | [enabled|disabled]:vlan1,vlan2,vlan3 ... ]
CLI Example::
salt '*' bigip.modify_virtual bigip admin admin my-virtual source_address_translation=none
salt '*' bigip.modify_virtual bigip admin admin my-virtual rules=my-rule,my-other-rule
'''
params = {
'destination': destination,
'pool': pool,
'auto-lasthop': auto_lasthop,
'bwc-policy': bwc_policy,
'connection-limit': connection_limit,
'description': description,
'fallback-persistence': fallback_persistence,
'flow-eviction-policy': flow_eviction_policy,
'gtm-score': gtm_score,
'ip-protocol': ip_protocol,
'last-hop-pool': last_hop_pool,
'mask': mask,
'mirror': mirror,
'nat64': nat64,
'persist': persist,
'rate-class': rate_class,
'rate-limit': rate_limit,
'rate-limit-mode': rate_limit_mode,
'rate-limit-dst': rate_limit_dst,
'rate-limit-src': rate_limit_src,
'source': source,
'source-port': source_port,
'translate-address': translate_address,
'translate-port': translate_port
}
# some options take yes no others take true false. Figure out when to use which without
# confusing the end user
toggles = {
'address-status': {'type': 'yes_no', 'value': address_status},
'cmp-enabled': {'type': 'yes_no', 'value': cmp_enabled},
'dhcp-relay': {'type': 'true_false', 'value': dhcp_relay},
'reject': {'type': 'true_false', 'value': reject},
'12-forward': {'type': 'true_false', 'value': twelve_forward},
'internal': {'type': 'true_false', 'value': internal},
'ip-forward': {'type': 'true_false', 'value': ip_forward}
}
#build session
bigip_session = _build_session(username, password)
#build payload
payload = _loop_payload(params)
payload['name'] = name
#determine toggles
payload = _determine_toggles(payload, toggles)
#specify profiles if provided
if profiles is not None:
payload['profiles'] = _build_list(profiles, 'ltm:virtual:profile')
#specify persist if provided
if persist is not None:
payload['persist'] = _build_list(persist, 'ltm:virtual:persist')
#specify policies if provided
if policies is not None:
payload['policies'] = _build_list(policies, 'ltm:virtual:policy')
#specify rules if provided
if rules is not None:
payload['rules'] = _build_list(rules, None)
#specify related-rules if provided
if related_rules is not None:
payload['related-rules'] = _build_list(related_rules, None)
#handle source-address-translation
if source_address_translation is not None:
if source_address_translation == 'none':
payload['source-address-translation'] = {'pool': 'none', 'type': 'none'}
elif source_address_translation == 'automap':
payload['source-address-translation'] = {'pool': 'none', 'type': 'automap'}
elif source_address_translation == 'lsn':
payload['source-address-translation'] = {'pool': 'none', 'type': 'lsn'}
elif source_address_translation.startswith('snat'):
snat_pool = source_address_translation.split(':')[1]
payload['source-address-translation'] = {'pool': snat_pool, 'type': 'snat'}
#specify related-rules if provided
if traffic_classes is not None:
payload['traffic-classes'] = _build_list(traffic_classes, None)
#handle vlans
if vlans is not None:
#ceck to see if vlans is a dictionary (used when state makes use of function)
if isinstance(vlans, dict):
try:
payload['vlans'] = vlans['vlan_ids']
if vlans['enabled']:
payload['vlans-enabled'] = True
elif vlans['disabled']:
payload['vlans-disabled'] = True
except Exception:
return 'Error: Unable to Parse vlans dictionary: \n\tvlans={vlans}'.format(vlans=vlans)
elif vlans == 'none':
payload['vlans'] = 'none'
elif vlans == 'default':
payload['vlans'] = 'default'
elif vlans.startswith('enabled') or vlans.startswith('disabled'):
try:
vlans_setting = vlans.split(':')[0]
payload['vlans'] = vlans.split(':')[1].split(',')
if vlans_setting == 'disabled':
payload['vlans-disabled'] = True
elif vlans_setting == 'enabled':
payload['vlans-enabled'] = True
except Exception:
return 'Error: Unable to Parse vlans option: \n\tvlans={vlans}'.format(vlans=vlans)
#determine state
if state is not None:
if state == 'enabled':
payload['enabled'] = True
elif state == 'disabled':
payload['disabled'] = True
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/virtual/{name}'.format(name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_virtual(hostname, username, password, name):
'''
A function to connect to a bigip device and delete a specific virtual.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
name
The name of the virtual to delete
CLI Example::
salt '*' bigip.delete_virtual bigip admin admin my-virtual
'''
#build session
bigip_session = _build_session(username, password)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/virtual/{name}'.format(name=name))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
def list_monitor(hostname, username, password, monitor_type, name=None, ):
'''
A function to connect to a bigip device and list an existing monitor. If no name is provided than all
monitors of the specified type will be listed.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
monitor_type
The type of monitor(s) to list
name
The name of the monitor to list
CLI Example::
salt '*' bigip.list_monitor bigip admin admin http my-http-monitor
'''
#build sessions
bigip_session = _build_session(username, password)
#get to REST
try:
if name:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/monitor/{type}/{name}?expandSubcollections=true'.format(type=monitor_type, name=name))
else:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/monitor/{type}'.format(type=monitor_type))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def create_monitor(hostname, username, password, monitor_type, name, **kwargs):
'''
A function to connect to a bigip device and create a monitor.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
monitor_type
The type of monitor to create
name
The name of the monitor to create
kwargs
Consult F5 BIGIP user guide for specific options for each monitor type.
Typically, tmsh arg names are used.
CLI Example::
salt '*' bigip.create_monitor bigip admin admin http my-http-monitor timeout=10 interval=5
'''
#build session
bigip_session = _build_session(username, password)
#construct the payload
payload = {}
payload['name'] = name
#there's a ton of different monitors and a ton of options for each type of monitor.
#this logic relies that the end user knows which options are meant for which monitor types
for key, value in six.iteritems(kwargs):
if not key.startswith('__'):
if key not in ['hostname', 'username', 'password', 'type']:
key = key.replace('_', '-')
payload[key] = value
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/monitor/{type}'.format(type=monitor_type), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_monitor(hostname, username, password, monitor_type, name, **kwargs):
'''
A function to connect to a bigip device and modify an existing monitor.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
monitor_type
The type of monitor to modify
name
The name of the monitor to modify
kwargs
Consult F5 BIGIP user guide for specific options for each monitor type.
Typically, tmsh arg names are used.
CLI Example::
salt '*' bigip.modify_monitor bigip admin admin http my-http-monitor timout=16 interval=6
'''
#build session
bigip_session = _build_session(username, password)
#construct the payload
payload = {}
#there's a ton of different monitors and a ton of options for each type of monitor.
#this logic relies that the end user knows which options are meant for which monitor types
for key, value in six.iteritems(kwargs):
if not key.startswith('__'):
if key not in ['hostname', 'username', 'password', 'type', 'name']:
key = key.replace('_', '-')
payload[key] = value
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/monitor/{type}/{name}'.format(type=monitor_type, name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_monitor(hostname, username, password, monitor_type, name):
'''
A function to connect to a bigip device and delete an existing monitor.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
monitor_type
The type of monitor to delete
name
The name of the monitor to delete
CLI Example::
salt '*' bigip.delete_monitor bigip admin admin http my-http-monitor
'''
#build sessions
bigip_session = _build_session(username, password)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/monitor/{type}/{name}'.format(type=monitor_type, name=name))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
def list_profile(hostname, username, password, profile_type, name=None, ):
'''
A function to connect to a bigip device and list an existing profile. If no name is provided than all
profiles of the specified type will be listed.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
profile_type
The type of profile(s) to list
name
The name of the profile to list
CLI Example::
salt '*' bigip.list_profile bigip admin admin http my-http-profile
'''
#build sessions
bigip_session = _build_session(username, password)
#get to REST
try:
if name:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/profile/{type}/{name}?expandSubcollections=true'.format(type=profile_type, name=name))
else:
response = bigip_session.get(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/profile/{type}'.format(type=profile_type))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def create_profile(hostname, username, password, profile_type, name, **kwargs):
r'''
A function to connect to a bigip device and create a profile.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
profile_type
The type of profile to create
name
The name of the profile to create
kwargs
``[ arg=val ] ... [arg=key1:val1,key2:val2] ...``
Consult F5 BIGIP user guide for specific options for each monitor type.
Typically, tmsh arg names are used.
Creating Complex Args
Profiles can get pretty complicated in terms of the amount of possible
config options. Use the following shorthand to create complex arguments such
as lists, dictionaries, and lists of dictionaries. An option is also
provided to pass raw json as well.
lists ``[i,i,i]``:
``param='item1,item2,item3'``
Dictionary ``[k:v,k:v,k,v]``:
``param='key-1:val-1,key-2:val2,key-3:va-3'``
List of Dictionaries ``[k:v,k:v|k:v,k:v|k:v,k:v]``:
``param='key-1:val-1,key-2:val-2|key-1:val-1,key-2:val-2|key-1:val-1,key-2:val-2'``
JSON: ``'j{ ... }j'``:
``cert-key-chain='j{ "default": { "cert": "default.crt", "chain": "default.crt", "key": "default.key" } }j'``
Escaping Delimiters:
Use ``\,`` or ``\:`` or ``\|`` to escape characters which shouldn't
be treated as delimiters i.e. ``ciphers='DEFAULT\:!SSLv3'``
CLI Examples::
salt '*' bigip.create_profile bigip admin admin http my-http-profile defaultsFrom='/Common/http'
salt '*' bigip.create_profile bigip admin admin http my-http-profile defaultsFrom='/Common/http' \
enforcement=maxHeaderCount:3200,maxRequests:10
'''
#build session
bigip_session = _build_session(username, password)
#construct the payload
payload = {}
payload['name'] = name
#there's a ton of different profiles and a ton of options for each type of profile.
#this logic relies that the end user knows which options are meant for which profile types
for key, value in six.iteritems(kwargs):
if not key.startswith('__'):
if key not in ['hostname', 'username', 'password', 'profile_type']:
key = key.replace('_', '-')
try:
payload[key] = _set_value(value)
except salt.exceptions.CommandExecutionError:
return 'Error: Unable to Parse JSON data for parameter: {key}\n{value}'.format(key=key, value=value)
#post to REST
try:
response = bigip_session.post(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/profile/{type}'.format(type=profile_type), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def modify_profile(hostname, username, password, profile_type, name, **kwargs):
r'''
A function to connect to a bigip device and create a profile.
A function to connect to a bigip device and create a profile.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
profile_type
The type of profile to create
name
The name of the profile to create
kwargs
``[ arg=val ] ... [arg=key1:val1,key2:val2] ...``
Consult F5 BIGIP user guide for specific options for each monitor type.
Typically, tmsh arg names are used.
Creating Complex Args
Profiles can get pretty complicated in terms of the amount of possible
config options. Use the following shorthand to create complex arguments such
as lists, dictionaries, and lists of dictionaries. An option is also
provided to pass raw json as well.
lists ``[i,i,i]``:
``param='item1,item2,item3'``
Dictionary ``[k:v,k:v,k,v]``:
``param='key-1:val-1,key-2:val2,key-3:va-3'``
List of Dictionaries ``[k:v,k:v|k:v,k:v|k:v,k:v]``:
``param='key-1:val-1,key-2:val-2|key-1:val-1,key-2:val-2|key-1:val-1,key-2:val-2'``
JSON: ``'j{ ... }j'``:
``cert-key-chain='j{ "default": { "cert": "default.crt", "chain": "default.crt", "key": "default.key" } }j'``
Escaping Delimiters:
Use ``\,`` or ``\:`` or ``\|`` to escape characters which shouldn't
be treated as delimiters i.e. ``ciphers='DEFAULT\:!SSLv3'``
CLI Examples::
salt '*' bigip.modify_profile bigip admin admin http my-http-profile defaultsFrom='/Common/http'
salt '*' bigip.modify_profile bigip admin admin http my-http-profile defaultsFrom='/Common/http' \
enforcement=maxHeaderCount:3200,maxRequests:10
salt '*' bigip.modify_profile bigip admin admin client-ssl my-client-ssl-1 retainCertificate=false \
ciphers='DEFAULT\:!SSLv3'
cert_key_chain='j{ "default": { "cert": "default.crt", "chain": "default.crt", "key": "default.key" } }j'
'''
#build session
bigip_session = _build_session(username, password)
#construct the payload
payload = {}
payload['name'] = name
#there's a ton of different profiles and a ton of options for each type of profile.
#this logic relies that the end user knows which options are meant for which profile types
for key, value in six.iteritems(kwargs):
if not key.startswith('__'):
if key not in ['hostname', 'username', 'password', 'profile_type']:
key = key.replace('_', '-')
try:
payload[key] = _set_value(value)
except salt.exceptions.CommandExecutionError:
return 'Error: Unable to Parse JSON data for parameter: {key}\n{value}'.format(key=key, value=value)
#put to REST
try:
response = bigip_session.put(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/profile/{type}/{name}'.format(type=profile_type, name=name), data=json.dumps(payload))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
return _load_response(response)
def delete_profile(hostname, username, password, profile_type, name):
'''
A function to connect to a bigip device and delete an existing profile.
hostname
The host/address of the bigip device
username
The iControl REST username
password
The iControl REST password
profile_type
The type of profile to delete
name
The name of the profile to delete
CLI Example::
salt '*' bigip.delete_profile bigip admin admin http my-http-profile
'''
#build sessions
bigip_session = _build_session(username, password)
#delete to REST
try:
response = bigip_session.delete(BIG_IP_URL_BASE.format(host=hostname)+'/ltm/profile/{type}/{name}'.format(type=profile_type, name=name))
except requests.exceptions.ConnectionError as e:
return _load_connection_error(hostname, e)
if _load_response(response) == '':
return True
else:
return _load_response(response)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
2344,
199,
2493,
6451,
859,
1314,
883,
27232,
376,
289,
21,
27281,
4799,
284,
3717,
14880,
272,
520,
569,
5581,
26,
420,
477,
7549,
272,
520,
3246,
26,
420,
289,
21,
63,
17833,
63,
845,
14,
22,
199,
2344,
199,
199,
3,
3161,
2366,
20314,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2022,
199,
646,
2050,
465,
2512,
199,
199,
3,
3161,
10919,
17135,
20314,
199,
893,
26,
272,
492,
4145,
272,
492,
4145,
14,
3924,
272,
7509,
63,
25161,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
25161,
275,
756,
199,
199,
3,
3161,
650,
6883,
13,
7522,
20314,
199,
646,
10105,
14,
832,
14,
4174,
465,
3816,
199,
199,
3,
3161,
10105,
20314,
199,
646,
10105,
14,
1208,
199,
646,
10105,
14,
1199,
199,
646,
10105,
14,
3924,
199,
199,
3,
12439,
314,
2512,
199,
793,
275,
2512,
14,
5572,
3460,
354,
3368,
199,
199,
3,
13930,
314,
859,
1159,
5791,
536,
199,
363,
2065,
354,
363,
275,
283,
17833,
7,
421,
199,
318,
636,
2065,
721,
304,
272,
1449,
272,
5972,
372,
340,
4145,
365,
4903,
272,
1449,
272,
340,
7509,
63,
25161,
26,
267,
372,
636,
2065,
354,
363,
272,
372,
334,
797,
12,
283,
1918,
27281,
6451,
859,
3913,
506,
6511,
26,
283,
288,
283,
1548,
4145,
3555,
440,
2808,
2659,
421,
199,
18643,
63,
1772,
63,
2632,
63,
5825,
275,
283,
2859,
20193,
1102,
5995,
9752,
15,
7574,
7,
421,
199,
318,
485,
1506,
63,
1730,
8,
2473,
12,
2505,
12,
1752,
63,
1302,
29,
403,
304,
272,
1449,
272,
2790,
282,
2351,
370,
506,
1202,
1380,
18170,
370,
284,
3717,
14880,
14,
272,
1449,
339,
27281,
275,
4145,
14,
1730,
342,
272,
27281,
14,
1178,
275,
334,
2473,
12,
2505,
9,
272,
27281,
14,
4712,
275,
756,
272,
27281,
14,
2139,
14,
873,
3252,
2714,
13,
804,
356,
283,
3578,
15,
1001,
3071,
339,
340,
1752,
63,
1302,
26,
267,
327,
9302,
314,
1752,
1305,
687,
314,
1999,
262,
267,
1752,
63,
344,
275,
636,
12597,
23010,
926,
3617,
14,
362,
418,
360,
17833,
63,
70,
21,
63,
1515,
14534,
1302,
5285,
908,
8,
1302,
29,
1515,
63,
1302,
430,
398,
340,
1752,
63,
344,
26,
288,
27281,
14,
2139,
14,
873,
3252,
56,
13,
38,
21,
13,
15740,
13,
14957,
3155,
13,
1304,
356,
1752,
63,
344,
1552,
267,
587,
26,
288,
27281,
14,
2139,
14,
873,
3252,
56,
13,
38,
21,
13,
15740,
13,
14957,
3155,
13,
1304,
356,
488,
1552,
339,
372,
27281,
421,
199,
318,
485,
912,
63,
1310,
8,
1310,
304,
272,
1449,
272,
7190,
314,
1177,
687,
2022,
666,
12,
372,
314,
2600,
503,
3066,
1318,
272,
1449,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
1310,
14,
505,
9,
272,
871,
1722,
26,
267,
666,
275,
1177,
14,
505,
339,
2203,
275,
791,
600,
356,
1177,
14,
1205,
63,
600,
12,
283,
1317,
356,
666,
93,
339,
372,
2203,
421,
199,
318,
485,
912,
63,
2105,
63,
705,
8,
4269,
12,
1125,
304,
272,
1449,
272,
9701,
436,
1432,
282,
1950,
1125,
272,
1449,
339,
2203,
275,
791,
600,
356,
488,
12,
283,
1317,
356,
283,
547,
26,
30849,
370,
4907,
370,
314,
27281,
2243,
26,
469,
1102,
4988,
78,
91,
705,
5285,
908,
8,
1102,
29,
4269,
12,
1125,
29,
705,
6769,
339,
372,
2203,
421,
199,
318,
485,
3813,
63,
4749,
8,
1162,
304,
272,
1449,
272,
8325,
315,
282,
2600,
402,
2633,
12,
4438,
4012,
3062,
436,
1900,
282,
4886,
3035,
12,
272,
2633,
3963,
1159,
1338,
787,
440,
488,
14,
272,
1449,
339,
327,
8514,
314,
4886,
272,
4886,
275,
1052,
339,
327,
409,
314,
4886,
272,
367,
1215,
12,
574,
315,
3816,
14,
4611,
8,
1162,
304,
267,
340,
574,
365,
440,
488,
26,
288,
4886,
59,
635,
61,
275,
574,
339,
372,
4886,
421,
199,
318,
485,
1506,
63,
513,
8,
1422,
63,
585,
12,
1242,
63,
5091,
304,
272,
1449,
272,
986,
315,
376,
945,
370,
1104,
367,
282,
769,
402,
2974,
12,
1218,
282,
769,
402,
2600,
402,
2974,
370,
663,
272,
367,
642,
945,
272,
1449,
272,
327,
26164,
17390,
340,
2741,
272,
340,
945,
63,
585,
365,
440,
488,
26,
398,
2974,
275,
942,
398,
327,
692,
922,
2013,
7179,
12,
372,
376,
2701,
769,
267,
340,
945,
63,
585,
508,
283,
3592,
356,
288,
372,
2974,
398,
327,
10274,
282,
769,
2575,
3032,
315,
31,
267,
340,
440,
1228,
8,
1422,
63,
585,
12,
769,
304,
288,
1338,
275,
945,
63,
585,
14,
1294,
11917,
267,
587,
26,
288,
1338,
275,
945,
63,
585,
398,
367,
574,
315,
1338,
26,
288,
327,
15026,
314,
27281,
2951,
1212,
9246,
282,
8971,
9113,
769,
402,
2974,
288,
340,
1242,
63,
5091,
365,
488,
26,
355,
2974,
14,
740,
8,
585,
9,
288,
327,
1163,
5431,
652,
1159,
3732,
89,
436,
1212,
9246,
790,
574,
6342,
1396,
288,
587,
26,
355,
2974,
14,
740,
3252,
5091,
356,
1242,
63,
5091,
12,
283,
354,
356,
574,
1552,
267,
372,
2974,
272,
372,
488,
421,
199,
318,
485,
22189,
63,
475,
2721,
2978,
8,
4749,
12,
370,
2721,
2978,
304,
272,
1449,
272,
13123,
1772,
883,
1133,
1852,
1536,
2399,
25169,
340,
652,
1212,
9246,
9456,
1182,
949,
503,
2549,
503,
3055,
14,
272,
16266,
734,
4052,
652,
1212,
9246,
370,
946,
285,
1928,
3743,
4941,
314,
922,
14,
272,
1449,
339,
367,
19420,
12,
5492,
315,
3816,
14,
4611,
8,
475,
2721,
2978,
304,
267,
327,
14887,
314,
922,
4165,
7003,
31,
267,
340,
5492,
459,
585,
418,
365,
440,
488,
26,
288,
327,
396,
367,
9456,
63,
889,
19420,
288,
340,
334,
7463,
459,
585,
418,
365,
715,
503,
5492,
459,
585,
418,
508,
283,
5066,
358,
436,
5492,
459,
466,
418,
508,
283,
5066,
63,
889,
356,
355,
4886,
59,
13396,
61,
275,
283,
5066,
7,
288,
916,
334,
7463,
459,
585,
418,
365,
756,
503,
5492,
459,
585,
418,
508,
283,
889,
358,
436,
5492,
459,
466,
418,
508,
283,
5066,
63,
889,
356,
355,
4886,
59,
13396,
61,
275,
283,
889,
7,
953
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
2344,
199,
2493,
6451,
859,
1314,
883,
27232,
376,
289,
21,
27281,
4799,
284,
3717,
14880,
272,
520,
569,
5581,
26,
420,
477,
7549,
272,
520,
3246,
26,
420,
289,
21,
63,
17833,
63,
845,
14,
22,
199,
2344,
199,
199,
3,
3161,
2366,
20314,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
646,
2022,
199,
646,
2050,
465,
2512,
199,
199,
3,
3161,
10919,
17135,
20314,
199,
893,
26,
272,
492,
4145,
272,
492,
4145,
14,
3924,
272,
7509,
63,
25161,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
25161,
275,
756,
199,
199,
3,
3161,
650,
6883,
13,
7522,
20314,
199,
646,
10105,
14,
832,
14,
4174,
465,
3816,
199,
199,
3,
3161,
10105,
20314,
199,
646,
10105,
14,
1208,
199,
646,
10105,
14,
1199,
199,
646,
10105,
14,
3924,
199,
199,
3,
12439,
314,
2512,
199,
793,
275,
2512,
14,
5572,
3460,
354,
3368,
199,
199,
3,
13930,
314,
859,
1159,
5791,
536,
199,
363,
2065,
354,
363,
275,
283,
17833,
7,
421,
199,
318,
636,
2065,
721,
304,
272,
1449,
272,
5972,
372,
340,
4145,
365,
4903,
272,
1449,
272,
340,
7509,
63,
25161,
26,
267,
372,
636,
2065,
354,
363,
272,
372,
334,
797,
12,
283,
1918,
27281,
6451,
859,
3913,
506,
6511,
26,
283,
288,
283,
1548,
4145,
3555,
440,
2808,
2659,
421,
199,
18643,
63,
1772,
63,
2632,
63,
5825,
275,
283,
2859,
20193,
1102,
5995,
9752,
15,
7574,
7,
421,
199,
318,
485,
1506,
63,
1730,
8,
2473,
12,
2505,
12,
1752,
63,
1302,
29,
403,
304,
272,
1449,
272,
2790,
282,
2351,
370,
506,
1202,
1380,
18170,
370,
284,
3717,
14880,
14,
272,
1449,
339,
27281,
275,
4145,
14,
1730,
342,
272,
27281,
14,
1178,
275,
334,
2473,
12,
2505,
9,
272,
27281,
14,
4712,
275,
756,
272,
27281,
14,
2139,
14,
873,
3252,
2714,
13,
804,
356,
283,
3578,
15,
1001,
3071,
339,
340,
1752,
63,
1302,
26,
267,
327,
9302,
314,
1752,
1305,
687,
314,
1999,
262,
267,
1752,
63,
344,
275,
636,
12597,
23010,
926,
3617,
14,
362,
418,
360,
17833,
63,
70,
21,
63,
1515,
14534,
1302,
5285,
908,
8,
1302,
29,
1515,
63,
1302,
430,
398,
340,
1752,
63,
344,
26,
288,
27281,
14,
2139,
14,
873,
3252,
56,
13,
38,
21,
13,
15740,
13,
14957,
3155,
13,
1304,
356,
1752,
63,
344,
1552,
267,
587,
26,
288,
27281,
14,
2139,
14,
873,
3252,
56,
13,
38,
21,
13,
15740,
13,
14957,
3155,
13,
1304,
356,
488,
1552,
339,
372,
27281,
421,
199,
318,
485,
912,
63,
1310,
8,
1310,
304,
272,
1449,
272,
7190,
314,
1177,
687,
2022,
666,
12,
372,
314,
2600,
503,
3066,
1318,
272,
1449,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
1310,
14,
505,
9,
272,
871,
1722,
26,
267,
666,
275,
1177,
14,
505,
339,
2203,
275,
791,
600,
356,
1177,
14,
1205,
63,
600,
12,
283,
1317,
356,
666,
93,
339,
372,
2203,
421,
199,
318,
485,
912,
63,
2105,
63,
705,
8,
4269,
12,
1125,
304,
272,
1449,
272,
9701,
436,
1432,
282,
1950,
1125,
272,
1449,
339,
2203,
275,
791,
600,
356,
488,
12,
283,
1317,
356,
283,
547,
26,
30849,
370,
4907,
370,
314,
27281,
2243,
26,
469,
1102,
4988,
78,
91,
705,
5285,
908,
8,
1102,
29,
4269,
12,
1125,
29,
705,
6769,
339,
372,
2203,
421,
199,
318,
485,
3813,
63,
4749,
8,
1162,
304,
272,
1449,
272,
8325,
315,
282,
2600,
402,
2633,
12,
4438,
4012,
3062,
436,
1900,
282,
4886,
3035,
12,
272,
2633,
3963,
1159,
1338,
787,
440,
488,
14,
272,
1449,
339,
327,
8514,
314,
4886,
272,
4886,
275,
1052,
339,
327,
409,
314,
4886,
272,
367,
1215,
12,
574,
315,
3816,
14,
4611,
8,
1162,
304,
267,
340,
574,
365,
440,
488,
26,
288,
4886,
59,
635,
61,
275,
574,
339,
372,
4886,
421,
199,
318,
485,
1506,
63,
513,
8,
1422,
63,
585,
12,
1242,
63,
5091,
304,
272,
1449,
272,
986,
315,
376,
945,
370,
1104,
367,
282,
769,
402,
2974,
12,
1218,
282,
769,
402,
2600,
402,
2974,
370,
663,
272,
367,
642,
945,
272,
1449,
272,
327,
26164,
17390,
340,
2741,
272,
340,
945,
63,
585,
365,
440,
488,
26,
398,
2974,
275,
942,
398,
327,
692,
922,
2013,
7179,
12,
372,
376,
2701,
769,
267,
340,
945,
63,
585,
508,
283,
3592,
356,
288,
372,
2974,
398,
327,
10274,
282,
769,
2575,
3032,
315,
31,
267,
340,
440,
1228,
8,
1422,
63,
585,
12,
769,
304,
288,
1338,
275,
945,
63,
585,
14,
1294,
11917,
267,
587,
26,
288,
1338,
275,
945,
63,
585,
398,
367,
574,
315,
1338,
26,
288,
327,
15026,
314,
27281,
2951,
1212,
9246,
282,
8971,
9113,
769,
402,
2974,
288,
340,
1242,
63,
5091,
365,
488,
26,
355,
2974,
14,
740,
8,
585,
9,
288,
327,
1163,
5431,
652,
1159,
3732,
89,
436,
1212,
9246,
790,
574,
6342,
1396,
288,
587,
26,
355,
2974,
14,
740,
3252,
5091,
356,
1242,
63,
5091,
12,
283,
354,
356,
574,
1552,
267,
372,
2974,
272,
372,
488,
421,
199,
318,
485,
22189,
63,
475,
2721,
2978,
8,
4749,
12,
370,
2721,
2978,
304,
272,
1449,
272,
13123,
1772,
883,
1133,
1852,
1536,
2399,
25169,
340,
652,
1212,
9246,
9456,
1182,
949,
503,
2549,
503,
3055,
14,
272,
16266,
734,
4052,
652,
1212,
9246,
370,
946,
285,
1928,
3743,
4941,
314,
922,
14,
272,
1449,
339,
367,
19420,
12,
5492,
315,
3816,
14,
4611,
8,
475,
2721,
2978,
304,
267,
327,
14887,
314,
922,
4165,
7003,
31,
267,
340,
5492,
459,
585,
418,
365,
440,
488,
26,
288,
327,
396,
367,
9456,
63,
889,
19420,
288,
340,
334,
7463,
459,
585,
418,
365,
715,
503,
5492,
459,
585,
418,
508,
283,
5066,
358,
436,
5492,
459,
466,
418,
508,
283,
5066,
63,
889,
356,
355,
4886,
59,
13396,
61,
275,
283,
5066,
7,
288,
916,
334,
7463,
459,
585,
418,
365,
756,
503,
5492,
459,
585,
418,
508,
283,
889,
358,
436,
5492,
459,
466,
418,
508,
283,
5066,
63,
889,
356,
355,
4886,
59,
13396,
61,
275,
283,
889,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,
1,
1,
1,
1
] |
wurstmineberg/alltheitems.wurstmineberg.de
|
alltheitems/cloud.py
|
1
|
67724
|
import alltheitems.__main__ as ati
import bottle
import collections
import contextlib
import datetime
import itertools
import json
import pathlib
import random
import re
import xml.sax.saxutils
import alltheitems.item
import alltheitems.util
import alltheitems.world
class FillLevel:
def __init__(self, stack_size, total_items, max_slots, *, is_smart_chest=True):
self.stack_size = stack_size
self.total_items = total_items
self.max_slots = max_slots
self.is_smart_chest = is_smart_chest
def __str__(self):
if self.total_items == 0:
return '{} is empty.'.format('SmartChest' if self.is_smart_chest else 'Chest')
elif self.total_items == self.max_items:
return '{} is full.'.format('SmartChest' if self.is_smart_chest else 'Chest')
else:
stacks, items = self.stacks
return '{} is filled {}% ({} {stack}{}{} out of {} {stack}s).'.format('SmartChest' if self.is_smart_chest else 'Chest', int(100 * self.fraction), stacks, '' if stacks == 1 else 's', ' and {} item{}'.format(items, '' if items == 1 else 's') if items > 0 else '', self.max_slots, stack='item' if self.stack_size == 1 else 'stack')
@property
def fraction(self):
return self.total_items / self.max_items
def is_empty(self):
return self.total_items == 0
def is_full(self):
return self.total_items == self.max_items
@property
def max_items(self):
return self.max_slots * self.stack_size
@property
def stacks(self):
return divmod(self.total_items, self.stack_size)
CONTAINERS = [ # layer coords of all counted container blocks in a SmartChest
(3, -7, 3),
(3, -7, 4),
(4, -7, 4),
(5, -7, 3),
(5, -7, 4),
(2, -6, 3),
(3, -6, 2),
(3, -6, 3),
(2, -5, 2),
(2, -5, 3),
(3, -5, 3),
(2, -4, 3),
(3, -4, 2),
(3, -4, 3),
(3, -3, 2),
(4, -3, 2),
(5, -3, 2),
(6, -3, 2),
(5, -2, 2),
(6, -2, 2),
(5, 0, 2),
(5, 0, 3)
]
STONE_VARIANTS = {
0: 'stone',
1: 'granite',
2: 'polished granite',
3: 'diorite',
4: 'polished diorite',
5: 'andesite',
6: 'polished andesite'
}
HOPPER_FACINGS = {
0: 'down',
1: 'up', #for droppers
2: 'north',
3: 'south',
4: 'west',
5: 'east'
}
TORCH_FACINGS = {
1: 'to its west',
2: 'to its east',
3: 'to its north',
4: 'to its south',
5: 'below'
}
HTML_COLORS = {
'cyan': '#0ff',
'cyan2': '#0ff',
'gray': '#777',
'red': '#f00',
'orange': '#f70',
'yellow': '#ff0',
'white': '#fff',
'white2': '#fff',
None: 'transparent'
}
def hopper_chain_connected(start_coords, end_coords, *, world=None, chunk_cache=None, block_at=None):
if world is None:
world = alltheitems.world.World()
if chunk_cache is None:
chunk_cache = {}
if block_at is None:
block_at=world.block_at
visited_coords = set()
x, y, z = start_coords
while (x, y, z) != end_coords:
if (x, y, z) in visited_coords:
return False, 'hopper chain points into itself at {} {} {}'.format(x, y, z)
visited_coords.add((x, y, z))
block = block_at(x, y, z, chunk_cache=chunk_cache)
if block['id'] != 'minecraft:hopper':
return False, 'block at {} {} {} is not a <a href="/block/minecraft/hopper">hopper</a>'.format(x, y, z, *end_coords)
if block['damage'] & 0x7 == 0:
y -= 1 # down
elif block['damage'] & 0x7 == 2:
z -= 1 # north
elif block['damage'] & 0x7 == 3:
z += 1 # south
elif block['damage'] & 0x7 == 4:
x -= 1 # west
elif block['damage'] & 0x7 == 5:
x += 1 # east
else:
raise ValueError('Unknown hopper facing {} at {}'.format(block['damage'] & 0x7, (x, y, z)))
return True, None
def smart_chest_schematic(document_root=ati.document_root):
layers = {}
with (document_root / 'static' / 'smartchest.txt').open() as smart_chest_layers:
current_y = None
current_layer = None
for line in smart_chest_layers:
if line == '\n':
continue
match = re.fullmatch('layer (-?[0-9]+)\n', line)
if match:
# new layer
if current_y is not None:
layers[current_y] = current_layer
current_y = int(match.group(1))
current_layer = []
else:
current_layer.append(line.rstrip('\r\n'))
if current_y is not None:
layers[current_y] = current_layer
return sorted(layers.items())
def chest_iter():
"""Returns an iterator yielding tuples (x, corridor, y, floor, z, chest)."""
with (ati.assets_root / 'json' / 'cloud.json').open() as cloud_json:
cloud_data = json.load(cloud_json)
for y, floor in enumerate(cloud_data):
for x, corridor in sorted(((int(x), corridor) for x, corridor in floor.items()), key=lambda tup: tup[0]):
for z, chest in enumerate(corridor):
yield x, corridor, y, floor, z, chest
def chest_coords(item, *, include_meta=False):
if not isinstance(item, alltheitems.item.Item):
item = alltheitems.item.Item(item)
for x, corridor, y, _, z, chest in chest_iter():
if item == chest:
if include_meta:
return (x, y, z), len(corridor), None if isinstance(chest, str) else chest.get('name'), None if isinstance(chest, str) else chest.get('sorter')
else:
return x, y, z
if include_meta:
return None, 0, None, None
def global_error_checks(*, chunk_cache=None, block_at=alltheitems.world.World().block_at):
cache_path = ati.cache_root / 'cloud-globals.json'
max_age = datetime.timedelta(hours=1, minutes=random.randrange(0, 60)) # use a random value between 1 and 2 hours for the cache expiration
if cache_path.exists() and datetime.datetime.utcfromtimestamp(cache_path.stat().st_mtime) > datetime.datetime.utcnow() - max_age:
# cached check results are recent enough
with cache_path.open() as cache_f:
cache = json.load(cache_f)
return cache
# cached check results are too old, recheck
if chunk_cache is None:
chunk_cache = {}
# error check: input hopper chain
start = 14, 61, 32 # the first hopper after the buffer elevator
end = -1, 25, 52 # the half of the uppermost overflow chest into which the hopper chain is pointing
is_connected, message = hopper_chain_connected(start, end, chunk_cache=chunk_cache, block_at=block_at)
if not is_connected:
return 'Input hopper chain at {} is not connected to the unsorted overflow at {}: {}.'.format(start, end, message)
if ati.cache_root.exists():
with cache_path.open('w') as cache_f:
json.dump(message, cache_f, sort_keys=True, indent=4)
def chest_error_checks(x, y, z, base_x, base_y, base_z, item, item_name, exists, stackable, durability, has_smart_chest, has_sorter, has_overflow, filler_item, sorting_hopper, missing_overflow_hoppers, north_half, south_half, corridor_length, pre_sorter, layer_coords, block_at, items_data, chunk_cache, document_root):
if stackable and has_sorter:
# error check: overflow exists
if not has_overflow:
if len(missing_overflow_hoppers) == 3:
return 'Missing overflow hoppers.'
elif len(missing_overflow_hoppers) > 1:
return 'Overflow hoppers at x={} do not exist.'.format(missing_overflow_hoppers)
elif len(missing_overflow_hoppers) == 1:
return 'Overflow hopper at x={} does not exist, is {}.'.format(next(iter(missing_overflow_hoppers)), block_at(next(iter(missing_overflow_hoppers)), base_y - 7, base_z - 1)['id'])
else:
return 'Missing overflow.'
# error check: pre-sorter for lower floors
if y > 4:
if pre_sorter is None:
return 'Preliminary sorter coordinate missing from cloud.json.'
pre_sorting_hopper = block_at(pre_sorter, 30, 52, chunk_cache=chunk_cache)
if pre_sorting_hopper['id'] != 'minecraft:hopper':
return 'Preliminary sorter is missing (should be at {} 30 52).'.format(pre_sorter)
if pre_sorting_hopper['damage'] != 3:
return 'Preliminary sorting hopper ({} 30 52) should be pointing south, but is facing {}.'.format(pre_sorter, HOPPER_FACINGS[pre_sorting_hopper['damage']])
empty_slots = set(range(5))
for slot in pre_sorting_hopper['tileEntity']['Items']:
empty_slots.remove(slot['Slot'])
if slot['Slot'] == 0:
if not item.matches_slot(slot):
return 'Preliminary sorting hopper is sorting the wrong item: {}.'.format(alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
else:
if not filler_item.matches_slot(slot):
return 'Preliminary sorting hopper has wrong filler item in slot {}: {} (should be {}).'.format(slot['Slot'], alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text(), filler_item.link_text())
if slot['Count'] > 1:
return 'Preliminary sorting hopper: too much {} in slot {}.'.format(filler_item.link_text(), slot['Slot'])
if len(empty_slots) > 0:
if len(empty_slots) == 5:
return 'Preliminary sorting hopper is empty.'
elif len(empty_slots) == 1:
return 'Slot {} of the preliminary sorting hopper is empty.'.format(next(iter(empty_slots)))
else:
return 'Some slots in the preliminary sorting hopper are empty: {}.'.format(alltheitems.util.join(empty_slots))
if has_sorter:
# error check: sorting hopper
if sorting_hopper['damage'] != 2:
return 'Sorting hopper ({} {} {}) should be pointing north, but is facing {}.'.format(base_x - 2 if z % 2 == 0 else base_x + 2, base_y - 3, base_z, HOPPER_FACINGS[sorting_hopper['damage']])
empty_slots = set(range(5))
for slot in sorting_hopper['tileEntity']['Items']:
empty_slots.remove(slot['Slot'])
if slot['Slot'] == 0 and stackable:
if not item.matches_slot(slot) and not filler_item.matches_slot(slot):
return 'Sorting hopper is sorting the wrong item: {}.'.format(alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
else:
if not filler_item.matches_slot(slot):
return 'Sorting hopper has wrong filler item in slot {}: {} (should be {}).'.format(slot['Slot'], alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text(), filler_item.link_text())
if slot['Count'] > 1:
return 'Sorting hopper: too much {} in slot {}.'.format(filler_item.link_text(), slot['Slot'])
if len(empty_slots) > 0:
if len(empty_slots) == 5:
return 'Sorting hopper is empty.'
elif len(empty_slots) == 1:
return 'Slot {} of the sorting hopper is empty.'.format(next(iter(empty_slots)))
else:
return 'Some slots in the sorting hopper are empty: {}.'.format(alltheitems.util.join(empty_slots))
if exists:
# error check: wrong items in access chest
for slot in itertools.chain(north_half['tileEntity']['Items'], south_half['tileEntity']['Items']):
if not item.matches_slot(slot):
return 'Access chest contains items of the wrong kind: {}.'.format(alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
# error check: wrong name on sign
sign = block_at(base_x - 1 if z % 2 == 0 else base_x + 1, base_y + 1, base_z + 1, chunk_cache=chunk_cache)
if sign['id'] != 'minecraft:wall_sign':
return 'Sign is missing.'
text = []
for line in range(1, 5):
line_text = json.loads(sign['tileEntity']['Text{}'.format(line)])['text'].translate(dict.fromkeys(range(0xf700, 0xf704), None))
if len(line_text) > 0:
text.append(line_text)
text = ' '.join(text)
if text != item_name.translate({0x2161: 'II'}):
return 'Sign has wrong text: should be {!r}, is {!r}.'.format(xml.sax.saxutils.escape(item_name), xml.sax.saxutils.escape(text))
if has_overflow:
# error check: overflow hopper chain
start = base_x + 5 if z % 2 == 0 else base_x - 5, base_y - 7, base_z - 1
end = -35, 6, 38 # position of the dropper leading into the Smelting Center's item elevator
is_connected, message = hopper_chain_connected(start, end, chunk_cache=chunk_cache, block_at=block_at)
if not is_connected:
return 'Overflow hopper chain at {} is not connected to the Smelting Center item elevator at {}: {}.'.format(start, end, message)
if exists and has_smart_chest:
# error check: all blocks
for layer_y, layer in smart_chest_schematic(document_root=document_root):
for layer_x, row in enumerate(layer):
for layer_z, block_symbol in enumerate(row):
# determine the coordinate of the current block
exact_x, exact_y, exact_z = layer_coords(layer_x, layer_y, layer_z)
# determine current block
block = block_at(exact_x, exact_y, exact_z, chunk_cache=chunk_cache)
# check against schematic
if block_symbol == ' ':
# air
if block['id'] != 'minecraft:air':
return 'Block at {} {} {} should be air, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == '!':
# sign
if block['id'] != 'minecraft:wall_sign':
return 'Block at {} {} {} should be a sign, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != (4 if z % 2 == 0 else 5):
return 'Sign at {} {} {} is facing the wrong way.'.format(exact_x, exact_y, exact_z)
elif block_symbol == '#':
# chest
if block['id'] != 'minecraft:chest':
return 'Block at {} {} {} should be a chest, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage chest at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == '<':
# hopper facing south
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 3: # south
return 'Hopper at {} {} {} should be pointing south, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
storage_hoppers = {
(5, -7, 4),
(6, -5, 4)
}
if (layer_x, layer_y, layer_z) in storage_hoppers:
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage hopper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == '>':
# hopper facing north
if layer_y == -7 and layer_x == 0 and z < 8:
# the first few chests get ignored because their overflow points in the opposite direction
pass #TODO introduce special checks for them
else:
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 2: # north
return 'Hopper at {} {} {} should be pointing north, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
storage_hoppers = {
(3, -7, 3),
(3, -4, 2)
}
if (layer_x, layer_y, layer_z) in storage_hoppers:
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage hopper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == '?':
# any block
pass
elif block_symbol == 'C':
# comparator
if block['id'] != 'minecraft:unpowered_comparator':
return 'Block at {} {} {} should be a comparator, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
known_facings = {
(5, -7, 2): 0x2, # south
(5, -5, 2): 0x2, # south
(7, -3, 4): 0x0, # north
(0, -1, 1): 0x0, # north
(1, -1, 2): 0x0, # north
(2, 0, 2): 0x1 if z % 2 == 0 else 0x3, # east / west
(2, 0, 3): 0x2, # south
(4, 0, 2): 0x1 if z % 2 == 0 else 0x3, # east / west
(4, 0, 3): 0x2 # south
}
facing = block['damage'] & 0x3
if (layer_x, layer_y, layer_z) in known_facings:
if known_facings[layer_x, layer_y, layer_z] != facing:
return 'Comparator at {} {} {} is facing the wrong way.'.format(exact_x, exact_y, exact_z)
else:
return 'Direction check for comparator at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
known_modes = {
(5, -7, 2): False, # compare
(5, -5, 2): False, # compare
(7, -3, 4): False, # compare
(0, -1, 1): False, # compare
(1, -1, 2): True, # subtract
(2, 0, 2): True, # subtract
(2, 0, 3): False, # compare
(4, 0, 2): True, #subtract
(4, 0, 3): False # compare
}
mode = (block['damage'] & 0x4) == 0x4
if (layer_x, layer_y, layer_z) in known_modes:
if known_modes[layer_x, layer_y, layer_z] != mode:
return 'Comparator at {} {} {} is in {} mode, should be in {} mode.'.format(exact_x, exact_y, exact_z, 'subtraction' if mode else 'comparison', 'subtraction' if known_modes[layer_x, layer_y, layer_z] else 'comparison')
else:
return 'Mode check for comparator at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
elif block_symbol == 'D':
# dropper facing up
if block['id'] != 'minecraft:dropper':
return 'Block at {} {} {} should be a dropper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 1: # up
return 'Dropper at {} {} {} should be facing up, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Dropper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == 'F':
# furnace
if layer_y == -6 and layer_x == 0 and z < 2:
# the first few chests get ignored because their overflow points in the opposite direction
pass #TODO introduce special checks for them
elif layer_y == -1 and layer_x == 7 and layer_z == 1 and (z == corridor_length - 1 or z == corridor_length - 2 and z % 2 == 0):
# the floor ends with a quartz slab instead of a furnace here
if block['id'] != 'minecraft:stone_slab':
return 'Block at {} {} {} should be a quartz slab, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 0x7:
slab_variant = {
0: 'stone',
1: 'sandstone',
2: 'fake wood',
3: 'cobblestone',
4: 'brick',
5: 'stone brick',
6: 'Nether brick',
7: 'quartz'
}[block['damage'] & 0x7]
return 'Block at {} {} {} should be a <a href="/block/minecraft/stone_slab/7">quartz slab</a>, is a <a href="/block/minecraft/stone_slab/{}">{} slab</a>.'.format(exact_x, exact_y, exact_z, block['damage'] & 0x7, slab_variant)
if block['damage'] & 0x8 != 0x8:
return 'Quartz slab at {} {} {} should be a top slab, is a bottom slab.'.format(exact_x, exact_y, exact_z)
elif x == 0 and y == 6 and layer_y == -1 and layer_x == 7:
# the central corridor on the 6th floor uses stone bricks instead of furnaces for the floor
if block['id'] != 'minecraft:stonebrick':
return 'Block at {} {} {} should be stone bricks, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 0:
stonebrick_variant = {
0: 'regular',
1: 'mossy',
2: 'cracked',
3: 'chiseled'
}[block['damage']]
return 'Block at {} {} {} should be <a href="/block/minecraft/stonebrick/0">regular stone bricks</a>, is <a href="/block/minecraft/stonebrick/{}">{} stone bricks</a>.'.format(exact_x, exact_y, exact_z, block['damage'], stonebrick_variant)
else:
if block['id'] != 'minecraft:furnace':
return 'Block at {} {} {} should be a furnace, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
known_signals = {
(0, -6, 4): 0,
(0, -6, 5): 0,
(0, -6, 6): 0,
(0, -6, 7): 0,
(0, -1, 0): 8,
(7, -1, 1): 0,
(7, -1, 2): 0,
(7, -1, 3): 0,
(7, -1, 4): 0,
(2, 0, 4): 1,
(4, 0, 4): 5
}
signal = alltheitems.item.comparator_signal(block, items_data=items_data)
if (layer_x, layer_y, layer_z) in known_signals:
if known_signals[layer_x, layer_y, layer_z] != signal:
return 'Furnace at {} {} {} has a fill level of {}, should be {}.'.format(exact_x, exact_y, exact_z, signal, known_signals[layer_x, layer_y, layer_z])
else:
return 'Fill level check for furnace at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
elif block_symbol == 'G':
# glowstone
if block['id'] != 'minecraft:glowstone':
return 'Block at {} {} {} should be glowstone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == 'H':
# hopper, any facing
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == 'N':
# overflow hopper chain pointing north
if y > 1 and (z == 0 or z == 1):
if block['id'] == 'minecraft:hopper':
if block['damage'] != 2: # north
return 'Overflow hopper at {} {} {} should be pointing north, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
elif block['id'] == 'minecraft:air':
pass # also allow air because some overflow hopper chains don't start on the first floor
else:
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
else:
if block['id'] != 'minecraft:air':
return 'Block at {} {} {} should be air, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == 'P':
# upside-down oak stairs
if block['id'] != 'minecraft:oak_stairs':
return 'Block at {} {} {} should be oak stairs, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x3 != (0x1 if z % 2 == 0 else 0x0):
stairs_facings = {
0: 'west',
1: 'east',
2: 'south',
3: 'north'
}
return 'Stairs at {} {} {} should be facing {}, is {}.'.format(exact_x, exact_y, exact_z, stairs_facings[0x1 if z % 2 == 0 else 0x0], stairs_facings[block['damage'] & 0x3])
if block['damage'] & 0x4 != 0x4:
return 'Stairs at {} {} {} should be upside-down.'.format(exact_x, exact_y, exact_z)
elif block_symbol == 'Q':
# quartz top slab
if block['id'] != 'minecraft:stone_slab':
return 'Block at {} {} {} should be a quartz slab, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 0x7:
slab_variant = {
0: 'stone',
1: 'sandstone',
2: 'fake wood',
3: 'cobblestone',
4: 'brick',
5: 'stone brick',
6: 'Nether brick',
7: 'quartz'
}[block['damage'] & 0x7]
return 'Block at {} {} {} should be a <a href="/block/minecraft/stone_slab/7">quartz slab</a>, is a <a href="/block/minecraft/stone_slab/{}">{} slab</a>.'.format(exact_x, exact_y, exact_z, block['damage'] & 0x7, slab_variant)
if block['damage'] & 0x8 != 0x8:
return 'Quartz slab at {} {} {} should be a top slab, is a bottom slab.'.format(exact_x, exact_y, exact_z)
elif block_symbol == 'R':
# repeater
if block['id'] not in ('minecraft:unpowered_repeater', 'minecraft:powered_repeater'):
return 'Block at {} {} {} should be a repeater, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
known_facings = {
(1, -8, 2): 0x0, # north
(3, -8, 3): 0x3 if z % 2 == 0 else 0x1, # west / east
(6, -6, 2): 0x0, # north
(7, -5, 5): 0x2, # south
(3, -3, 1): 0x1 if z % 2 == 0 else 0x3 # east / west
}
facing = block['damage'] & 0x3
if (layer_x, layer_y, layer_z) in known_facings:
if known_facings[layer_x, layer_y, layer_z] != facing:
return 'Repeater at {} {} {} is facing the wrong way.'.format(exact_x, exact_y, exact_z)
else:
return 'Direction check for repeater at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
known_delays = { # in game ticks
(1, -8, 2): 4,
(3, -8, 3): 2,
(6, -6, 2): 2,
(7, -5, 5): 2,
(3, -3, 1): 2
}
delay_ticks = 2 * (block['damage'] >> 2) + 2
if (layer_x, layer_y, layer_z) in known_delays:
if known_delays[layer_x, layer_y, layer_z] != delay_ticks:
return 'Repeater at {} {} {} has a delay of {} game tick{}, should be {}.'.format(exact_x, exact_y, exact_z, delay_ticks, '' if delay_ticks == 1 else 's', known_delays[layer_x, layer_y, layer_z])
else:
return 'Delay check for repeater at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
elif block_symbol == 'S':
# stone top slab
if block['id'] != 'minecraft:stone_slab':
return 'Block at {} {} {} should be a stone slab, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 0x0:
slab_variant = {
0: 'stone',
1: 'sandstone',
2: 'fake wood',
3: 'cobblestone',
4: 'brick',
5: 'stone brick',
6: 'Nether brick',
7: 'quartz'
}[block['damage'] & 0x7]
return 'Block at {} {} {} should be a <a href="/block/minecraft/stone_slab/0">stone slab</a>, is a <a href="/block/minecraft/stone_slab/{}">{} slab</a>.'.format(exact_x, exact_y, exact_z, block['damage'] & 0x7, slab_variant)
if block['damage'] & 0x8 != 0x8:
return 'Quartz slab at {} {} {} should be a top slab.'.format(exact_x, exact_y, exact_z)
elif block_symbol == 'T':
# redstone torch attached to the side of a block
if block['id'] not in ('minecraft:unlit_redstone_torch', 'minecraft:redstone_torch'):
return 'Block at {} {} {} should be a redstone torch, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
known_facings = {
(3, -8, 1): 1 if z % 2 == 0 else 2, # west / east
(2, -7, 1): 3, # north
(4, -6, 1): 2 if z % 2 == 0 else 1, # east / west
(4, -6, 2): 3, # north
(4, -5, 1): 1 if z % 2 == 0 else 2, # west / east
(4, -5, 3): 4, # south
(7, -5, 3): 3, # north
(1, -4, 2): 4, # south
(1, -3, 3): 3, # north
(1, -1, 4): 4, # south
(5, -1, 1): 2 if z % 2 == 0 else 1, # east / west
(3, 0, 3): 4 # south
}
if (layer_x, layer_y, layer_z) in known_facings:
if known_facings[layer_x, layer_y, layer_z] != block['damage']:
return 'Redstone torch at {} {} {} attached to the block {}, should be attached to the block {}.'.format(exact_x, exact_y, exact_z, TORCH_FACINGS[block['damage']], TORCH_FACINGS[known_facings[layer_x, layer_y, layer_z]])
else:
return 'Facing check for redstone torch at {} {} {} (relative coords: {} {} {}) not yet implemented.'.format(exact_x, exact_y, exact_z, layer_x, layer_y, layer_z)
elif block_symbol == 'W':
# back wall
if z == corridor_length - 1 or z == corridor_length - 2 and z % 2 == 0:
if block['id'] != 'minecraft:stone':
return 'Block at {} {} {} should be stone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 0:
stone_variant = {
0: 'stone',
1: 'granite',
2: 'polished granite',
3: 'diorite',
4: 'polished diorite',
5: 'andesite',
6: 'polished andesite'
}[block['damage']]
return 'Block at {} {} {} should be <a href="/block/minecraft/stone/0">regular stone</a>, is <a href="/block/minecraft/stone/{}">{}</a>.'.format(exact_x, exact_y, exact_z, block['damage'], stone_variant)
elif block_symbol == 'X':
# overflow hopper chain pointing down
if layer_y < -7 and y < 6 and (z == 4 or z == 5) or layer_y > -7 and y > 1 and (z == 0 or z == 1):
if block['id'] == 'minecraft:hopper':
if block['damage'] != 0: # down
return 'Overflow hopper at {} {} {} should be pointing down, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
elif block['id'] == 'minecraft:air':
pass # also allow air because some overflow hopper chains don't start on the first floor
else:
return 'Block at {} {} {} should be air or a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
else:
if block['id'] != 'minecraft:air':
return 'Block at {} {} {} should be air, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == '^':
# hopper facing outward
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != (5 if z % 2 == 0 else 4): # east / west
return 'Hopper at {} {} {} should be pointing {}, is {}.'.format(exact_x, exact_y, exact_z, 'east' if z % 2 == 0 else 'west', HOPPER_FACINGS[block['damage']])
storage_hoppers = {
(3, -5, 3),
(6, -5, 3),
(7, -4, 3),
(5, -3, 2),
(6, -3, 2)
}
if (layer_x, layer_y, layer_z) in storage_hoppers:
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage hopper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == 'c':
# crafting table
if layer_y == -7 and (y == 6 or z < 4 or z < 6 and layer_z > 1):
if block['id'] != 'minecraft:stone':
return 'Block at {} {} {} should be stone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 0:
stone_variant = STONE_VARIANTS[block['damage']]
return 'Block at {} {} {} should be <a href="/block/minecraft/stone/0">regular stone</a>, is <a href="/block/minecraft/stone/{}">{}</a>.'.format(exact_x, exact_y, exact_z, block['damage'], stone_variant)
else:
if block['id'] != 'minecraft:crafting_table':
return 'Block at {} {} {} should be a crafting table, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == 'i':
# torch attached to the top of a block
if block['id'] != 'minecraft:torch':
return 'Block at {} {} {} should be a torch, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 5: # attached to the block below
return 'Torch at {} {} {} should be attached to the block below, is attached to the block {}'.format(exact_x, exact_y, exact_z, TORCH_FACINGS[block['damage']])
elif block_symbol == 'p':
# oak planks
if layer_y == -8 and (y == 6 or z < 4 or z < 6 and layer_z > 1):
if block['id'] != 'minecraft:stone':
return 'Block at {} {} {} should be stone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 0:
stone_variant = STONE_VARIANTS[block['damage']]
return 'Block at {} {} {} should be <a href="/block/minecraft/stone/0">regular stone</a>, is <a href="/block/minecraft/stone/{}">{}</a>.'.format(exact_x, exact_y, exact_z, block['damage'], stone_variant)
else:
if block['id'] != 'minecraft:planks':
return 'Block at {} {} {} should be oak planks, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
pass #TODO check material
elif block_symbol == 'r':
# redstone dust
if block['id'] != 'minecraft:redstone_wire':
return 'Block at {} {} {} should be redstone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
elif block_symbol == 's':
# stone
if block['id'] != 'minecraft:stone':
if exact_y < 5:
if block['id'] != 'minecraft:bedrock':
return 'Block at {} {} {} should be stone or bedrock, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
else:
return 'Block at {} {} {} should be stone, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 0:
stone_variant = STONE_VARIANTS[block['damage']]
return 'Block at {} {} {} should be <a href="/block/minecraft/stone/0">regular stone</a>, is <a href="/block/minecraft/stone/{}">{}</a>.'.format(exact_x, exact_y, exact_z, block['damage'], stone_variant)
elif block_symbol == 't':
# redstone torch attached to the top of a block
if block['id'] not in ('minecraft:unlit_redstone_torch', 'minecraft:redstone_torch'):
return 'Block at {} {} {} should be a redstone torch, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] != 5: # attached to the block below
return 'Redstone torch at {} {} {} should be attached to the block below, is attached to the block {}'.format(exact_x, exact_y, exact_z, TORCH_FACINGS[block['damage']])
elif block_symbol == 'v':
# hopper facing inwards
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != (4 if z % 2 == 0 else 5): # west / east
return 'Hopper at {} {} {} should be pointing {}, is {}.'.format(exact_x, exact_y, exact_z, 'west' if z % 2 == 0 else 'east', HOPPER_FACINGS[block['damage']])
storage_hoppers = {
(3, -7, 4),
(4, -7, 4),
(2, -6, 3)
}
if (layer_x, layer_y, layer_z) in storage_hoppers:
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage hopper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == 'x':
# hopper facing down
if block['id'] != 'minecraft:hopper':
return 'Block at {} {} {} should be a hopper, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
if block['damage'] & 0x7 != 0: # down
return 'Hopper at {} {} {} should be pointing down, is {}.'.format(exact_x, exact_y, exact_z, HOPPER_FACINGS[block['damage']])
storage_hoppers = {
(5, -1, 2)
}
if (layer_x, layer_y, layer_z) in storage_hoppers:
for slot in block['tileEntity']['Items']:
if not item.matches_slot(slot):
return 'Storage hopper at {} {} {} contains items of the wrong kind: {}.'.format(exact_x, exact_y, exact_z, alltheitems.item.Item.from_slot(slot, items_data=items_data).link_text())
elif block_symbol == '~':
# hopper chain
if block['id'] == 'minecraft:hopper':
pass #TODO check facing
pass #TODO check alignment
elif block['id'] == 'minecraft:air':
pass #TODO check alignment
else:
return 'Block at {} {} {} should be a hopper or air, is {}.'.format(exact_x, exact_y, exact_z, block['id'])
pass #TODO check hopper chain integrity
else:
return 'Not yet implemented: block at {} {} {} should be {}.'.format(exact_x, exact_y, exact_z, block_symbol)
# error check: items in storage chests but not in access chest
access_chest_fill_level = alltheitems.item.comparator_signal(north_half, south_half)
bottom_dropper_fill_level = alltheitems.item.comparator_signal(block_at(*layer_coords(5, -7, 3), chunk_cache=chunk_cache))
if access_chest_fill_level < 2 and bottom_dropper_fill_level > 2:
return 'Access chest is {}empty but there are items stuck in the storage dropper at {} {} {}.'.format('' if access_chest_fill_level == 0 else 'almost ', *layer_coords(5, -7, 3))
if durability and has_smart_chest:
# error check: damaged or enchanted tools in storage chests
storage_containers = set(CONTAINERS) - {(5, 0, 2), (5, 0, 3)}
for container in storage_containers:
for slot in block_at(*layer_coords(*container), chunk_cache=chunk_cache)['tileEntity']['Items']:
if slot.get('Damage', 0) > 0:
return 'Item in storage container at {} {} {} is damaged.'.format(*layer_coords(*container))
if len(slot.get('tag', {}).get('ench', [])) > 0:
return 'Item in storage container at {} {} {} is enchanted.'.format(*layer_coords(*container))
def chest_state(coords, item_stub, corridor_length, item_name=None, pre_sorter=None, *, items_data=None, block_at=alltheitems.world.World().block_at, document_root=ati.document_root, chunk_cache=None, cache=None, allow_cache=True):
if items_data is None:
with (ati.assets_root / 'json' / 'items.json').open() as items_file:
items_data = json.load(items_file)
if chunk_cache is None:
chunk_cache = {}
if isinstance(item_stub, str):
item_stub = {'id': item_stub}
item = alltheitems.item.Item(item_stub, items_data=items_data)
if item_name is None:
item_name = item.info()['name']
state = None, 'This SmartChest is in perfect state.', None
x, y, z = coords
# determine the base coordinate, i.e. the position of the north half of the access chest
if z % 2 == 0:
# left wall
base_x = 15 * x + 2
else:
# right wall
base_x = 15 * x - 3
base_y = 73 - 10 * y
base_z = 28 + 10 * y + 4 * (z // 2)
def layer_coords(layer_x, layer_y, layer_z):
if z % 2 == 0:
# left wall
exact_x = base_x + 5 - layer_x
else:
# right wall
exact_x = base_x - 5 + layer_x
exact_y = base_y + layer_y
exact_z = base_z + 3 - layer_z
return exact_x, exact_y, exact_z
# does the access chest exist?
exists = False
north_half = block_at(base_x, base_y, base_z, chunk_cache=chunk_cache)
south_half = block_at(base_x, base_y, base_z + 1, chunk_cache=chunk_cache)
if north_half['id'] != 'minecraft:chest' and south_half['id'] != 'minecraft:chest':
state = 'gray', 'Access chest does not exist.', None
elif north_half['id'] != 'minecraft:chest':
state = 'gray', 'North half of access chest does not exist.', None
elif south_half['id'] != 'minecraft:chest':
state = 'gray', 'South half of access chest does not exist.', None
else:
exists = True
# does it have a SmartChest?
has_smart_chest = False
missing_droppers = set()
for dropper_y in range(base_y - 7, base_y):
dropper = block_at(base_x, dropper_y, base_z, chunk_cache=chunk_cache)
if dropper['id'] != 'minecraft:dropper':
missing_droppers.add(dropper_y)
if len(missing_droppers) == 7:
if state[0] is None:
state = 'orange', 'SmartChest droppers do not exist.', None
elif len(missing_droppers) > 1:
if state[0] is None:
state = 'orange', 'SmartChest droppers at y={} do not exist.'.format(', y='.join(str(dropper) for dropper in missing_droppers)), None
elif len(missing_droppers) == 1:
if state[0] is None:
state = 'orange', 'SmartChest dropper at y={} does not exist, is {}.'.format(next(iter(missing_droppers)), block_at(base_x, dropper_y, base_z)['id']), None
else:
has_smart_chest = True
# is it stackable?
stackable = item.info().get('stackable', True)
if not stackable and state[0] is None:
state = 'cyan', "This SmartChest is in perfect state (but the item is not stackable, so it can't be sorted).", None
# does it have a durability bar?
durability = 'durability' in item.info()
# does it have a sorter?
has_sorter = False
if item == 'minecraft:crafting_table' or stackable and item.max_stack_size < 64:
filler_item = alltheitems.item.Item('minecraft:crafting_table', items_data=items_data)
else:
filler_item = alltheitems.item.Item('minecraft:ender_pearl', items_data=items_data)
sorting_hopper = block_at(base_x - 2 if z % 2 == 0 else base_x + 2, base_y - 3, base_z, chunk_cache=chunk_cache)
if sorting_hopper['id'] != 'minecraft:hopper':
if state[0] is None:
state = 'yellow', 'Sorting hopper does not exist, is {}.'.format(sorting_hopper['id']), None
else:
for slot in sorting_hopper['tileEntity']['Items']:
if slot['Slot'] == 0 and stackable and not item.matches_slot(slot) and filler_item.matches_slot(slot):
if state[0] is None or state[0] == 'cyan':
state = 'yellow', 'Sorting hopper is full of {}, but the sorted item is stackable, so the first slot should contain the item.'.format(filler_item.link_text()), None
break
else:
has_sorter = True
# does it have an overflow?
has_overflow = False
missing_overflow_hoppers = set()
for overflow_x in range(base_x + 3 if z % 2 == 0 else base_x - 3, base_x + 6 if z % 2 == 0 else base_x - 6, 1 if z % 2 == 0 else -1):
overflow_hopper = block_at(overflow_x, base_y - 7, base_z - 1, chunk_cache=chunk_cache)
if overflow_hopper['id'] != 'minecraft:hopper':
missing_overflow_hoppers.add(overflow_x)
if len(missing_overflow_hoppers) == 0:
has_overflow = True
# state determined, check for errors
if coords == (1, 1, 0): # Ender pearls
message = global_error_checks(chunk_cache=chunk_cache, block_at=block_at)
if message is not None:
return 'red', message, None
cache_path = ati.cache_root / 'cloud-chests.json'
if cache is None:
if cache_path.exists():
with cache_path.open() as cache_f:
cache = json.load(cache_f)
else:
cache = {}
max_age = datetime.timedelta(hours=1, minutes=random.randrange(0, 60)) # use a random value between 1 and 2 hours for the cache expiration
if allow_cache and str(y) in cache and str(x) in cache[str(y)] and str(z) in cache[str(y)][str(x)] and cache[str(y)][str(x)][str(z)]['errorMessage'] is None and datetime.datetime.strptime(cache[str(y)][str(x)][str(z)]['timestamp'], '%Y-%m-%d %H:%M:%S') > datetime.datetime.utcnow() - max_age:
message = cache[str(y)][str(x)][str(z)]['errorMessage']
pass # cached check results are recent enough
else:
# cached check results are too old, recheck
message = chest_error_checks(x, y, z, base_x, base_y, base_z, item, item_name, exists, stackable, durability, has_smart_chest, has_sorter, has_overflow, filler_item, sorting_hopper, missing_overflow_hoppers, north_half, south_half, corridor_length, pre_sorter, layer_coords, block_at, items_data, chunk_cache, document_root)
if ati.cache_root.exists():
if str(y) not in cache:
cache[str(y)] = {}
if str(x) not in cache[str(y)]:
cache[str(y)][str(x)] = {}
cache[str(y)][str(x)][str(z)] = {
'errorMessage': message,
'timestamp': datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
}
with cache_path.open('w') as cache_f:
json.dump(cache, cache_f, sort_keys=True, indent=4)
if message is not None:
return 'red', message, None
# no errors, determine fill level
if state[0] in (None, 'cyan', 'orange', 'yellow'):
try:
containers = CONTAINERS if state[0] in (None, 'cyan') else [ # layer coords of the access chest
(5, 0, 2),
(5, 0, 3)
]
total_items = sum(max(0, sum(slot['Count'] for slot in block_at(*layer_coords(*container), chunk_cache=chunk_cache)['tileEntity']['Items'] if slot.get('Damage', 0) == 0 or not durability) - (4 * item.max_stack_size if container == (5, -7, 3) else 0)) for container in containers) # Don't count the 4 stacks of items that are stuck in the bottom dropper. Don't count damaged tools.
max_slots = sum(alltheitems.item.NUM_SLOTS[block_at(*layer_coords(*container), chunk_cache=chunk_cache)['id']] for container in containers) - (0 if state[0] == 'orange' else 4)
return state[0], state[1], FillLevel(item.max_stack_size, total_items, max_slots, is_smart_chest=state[0] in (None, 'cyan'))
except:
# something went wrong determining fill level, re-check errors
message = chest_error_checks(x, y, z, base_x, base_y, base_z, item, item_name, exists, stackable, durability, has_smart_chest, has_sorter, has_overflow, filler_item, sorting_hopper, missing_overflow_hoppers, north_half, south_half, corridor_length, g, layer_coords, block_at, items_data, chunk_cache, document_root)
if ati.cache_root.exists():
if str(y) not in cache:
cache[str(y)] = {}
if str(x) not in cache[str(y)]:
cache[str(y)][str(x)] = {}
cache[str(y)][str(x)][str(z)] = {
'errorMessage': message,
'timestamp': datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
}
with cache_path.open('w') as cache_f:
json.dump(cache, cache_f, sort_keys=True, indent=4)
if message is None:
raise
else:
return 'red', message, None
return state
def cell_from_chest(coords, item_stub, corridor_length, item_name=None, pre_sorter=None, *, chunk_cache=None, items_data=None, colors_to_explain=None, cache=None, allow_cache=True):
color, state_message, fill_level = chest_state(coords, item_stub, corridor_length, item_name, pre_sorter, items_data=items_data, chunk_cache=chunk_cache, cache=cache, allow_cache=allow_cache)
if colors_to_explain is not None:
colors_to_explain.add(color)
if fill_level is None or fill_level.is_full():
return '<td style="background-color: {};">{}</td>'.format(HTML_COLORS[color], alltheitems.item.Item(item_stub, items_data=items_data).image())
else:
return '<td style="background-color: {};">{}<div class="durability"><div style="background-color: #f0f; width: {}px;"></div></div></td>'.format(HTML_COLORS[color], alltheitems.item.Item(item_stub, items_data=items_data).image(), 0 if fill_level.is_empty() else 2 + int(fill_level.fraction * 13) * 2)
def index(allow_cache=True):
yield ati.header(title='Cloud')
def body():
yield '<p>The <a href="//wiki.{host}/Cloud">Cloud</a> is the public item storage on <a href="//{host}/">Wurstmineberg</a>, consisting of 6 underground floors with <a href="//wiki.{host}/SmartChest">SmartChests</a> in them.</p>'.format(host=ati.host)
yield """<style type="text/css">
.item-table td {
box-sizing: content-box;
height: 32px;
width: 32px;
position: relative;
}
.item-table .left-sep {
border-left: 1px solid gray;
}
.durability {
z-index: 1;
}
</style>"""
chunk_cache = {}
with (ati.assets_root / 'json' / 'items.json').open() as items_file:
items_data = json.load(items_file)
cache_path = ati.cache_root / 'cloud-chests.json'
if cache_path.exists():
try:
with cache_path.open() as cache_f:
cache = json.load(cache_f)
except ValueError:
# cache JSON is corrupted, probably because of a full disk, try without cache
cache_path.unlink()
cache = None
else:
cache = None
colors_to_explain = set()
floors = {}
for x, corridor, y, floor, z, chest in chest_iter():
if y not in floors:
floors[y] = floor
for y, floor in sorted(floors.items(), key=lambda tup: tup[0]):
def cell(coords, item_stub, corridor):
if isinstance(item_stub, str):
item_stub = {'id': item_stub}
item_name = None
pre_sorter = None
else:
item_stub = item_stub.copy()
if 'name' in item_stub:
item_name = item_stub['name']
del item_stub['name']
else:
item_name = None
if 'sorter' in item_stub:
pre_sorter = item_stub['sorter']
del item_stub['sorter']
else:
pre_sorter = None
return cell_from_chest(coords, item_stub, len(corridor), item_name, pre_sorter, chunk_cache=chunk_cache, colors_to_explain=colors_to_explain, items_data=items_data, cache=cache, allow_cache=allow_cache)
yield bottle.template("""
%import itertools
<h2 id="floor{{y}}">{{y}}{{ordinal(y)}} floor (y={{73 - 10 * y}})</h2>
<table class="item-table" style="margin-left: auto; margin-right: auto;">
%for x in range(-3, 4):
%if x > -3:
<colgroup class="left-sep">
<col />
<col />
</colgroup>
%else:
<colgroup>
<col />
<col />
</colgroup>
%end
%end
<tbody>
%for z_left, z_right in zip(itertools.count(step=2), itertools.count(start=1, step=2)):
%found = False
<tr>
%for x in range(-3, 4):
%if str(x) not in floor:
<td></td>
<td></td>
%continue
%end
%corridor = floor[str(x)]
%if len(corridor) > z_right:
{{!cell((x, y, z_right), corridor[z_right], corridor)}}
%else:
<td></td>
%end
%if len(corridor) > z_left:
{{!cell((x, y, z_left), corridor[z_left], corridor)}}
%found = True
%else:
<td></td>
%end
%end
</tr>
%if not found:
%break
%end
%end
</tbody>
</table>
""", ordinal=alltheitems.util.ordinal, cell=cell, floor=floor, y=y)
color_explanations = collections.OrderedDict([
('red', '<p>A red background means that there is something wrong with the chest. See the item info page for details.</p>'),
('gray', "<p>A gray background means that the chest hasn't been built yet or is still located somewhere else.</p>"),
('orange', "<p>An orange background means that the chest doesn't have a SmartChest yet. It can only store 54 stacks.</p>"),
('yellow', "<p>A yellow background means that the chest doesn't have a sorter yet.</p>"),
('cyan', '<p>A cyan background means that the chest has no sorter because it stores an unstackable item. These items should not be automatically <a href="//wiki.wurstmineberg.de/Soup#Cloud">sent</a> to the Cloud.</p>'),
(None, '<p>A white background means that everything is okay: the chest has a SmartChest, a sorter, and overflow protection.</p>')
])
for chest_color in sorted(colors_to_explain, key=list(color_explanations.keys()).index):
if chest_color is not None or len(colors_to_explain) > 1:
yield color_explanations[chest_color]
yield from ati.html_exceptions(body())
yield ati.footer(linkify_headers=True)
def todo():
yield ati.header(title='Cloud by priority')
def body():
yield """<style type="text/css">
.todo-table td {
text-align: left;
vertical-align: middle !important;
}
.todo-table .coord {
width: 3em;
text-align: right;
}
.todo-table .item-image {
box-sizing: content-box;
width: 32px;
}
.todo-table .item-name {
width: 24em;
}
</style>"""
headers = collections.OrderedDict([
('red', 'Build errors'),
('gray', 'Missing chests'),
('orange', 'Missing SmartChests'),
('yellow', 'Missing sorters'),
('cyan', 'Empty SmartChests (unstackable)'),
('white', 'Empty SmartChests (stackable)'),
('cyan2', 'Missing items (unstackable)'),
('white2', 'Missing items (stackable)')
])
header_indexes = {color: i for i, color in enumerate(headers.keys())}
def priority(pair):
coords, state = pair
x, y, z = coords
color, _, fill_level, _ = state
return header_indexes[color], None if fill_level is None else fill_level.fraction * (-1 if color == 'orange' else 1), y * (-1 if color == 'orange' else 1), x if y % 2 == 0 else -x, z
chunk_cache = {}
with (ati.assets_root / 'json' / 'items.json').open() as items_file:
items_data = json.load(items_file)
cache_path = ati.cache_root / 'cloud-chests.json'
if cache_path.exists():
try:
with cache_path.open() as cache_f:
cache = json.load(cache_f)
except ValueError:
# cache JSON is corrupted, probably because of a full disk, try without cache
cache_path.unlink()
cache = None
else:
cache = None
states = {}
current_color = None
for x, corridor, y, _, z, item_stub in chest_iter():
if isinstance(item_stub, str):
item_stub = {'id': item_stub}
item_name = None
pre_sorter = None
else:
item_stub = item_stub.copy()
if 'name' in item_stub:
item_name = item_stub['name']
del item_stub['name']
else:
item_name = None
if 'sorter' in item_stub:
pre_sorter = item_stub['sorter']
del item_stub['sorter']
else:
pre_sorter = None
color, state_message, fill_level = chest_state((x, y, z), item_stub, len(corridor), item_name, pre_sorter, items_data=items_data, chunk_cache=chunk_cache, cache=cache)
if color is None:
color = 'white'
if color in ('cyan', 'white') and not fill_level.is_empty():
color += '2'
if fill_level is None or not fill_level.is_full() or color not in ('cyan', 'white', 'cyan2', 'white2'):
states[x, y, z] = color, state_message, fill_level, alltheitems.item.Item(item_stub, items_data=items_data)
for coords, state in sorted(states.items(), key=priority):
x, y, z = coords
color, state_message, fill_level, item = state
if color != current_color:
if current_color is not None:
yield '</tbody></table>'
yield bottle.template('<h2 id="{{color}}">{{header}}</h2>', color=color, header=headers[color])
yield '<table class="todo-table table table-responsive"><thead><tr><th class="coord">X</th><th class="coord">Y</th><th class="coord">Z</th><th class="item-image"> </th><th class="item-name">Item</th><th>{}</th></tr></thead><tbody>'.format('Fill Level' if color in ('cyan', 'white', 'cyan2', 'white2') else 'Info')
current_color = color
yield bottle.template("""
<tr>
<td class="coord">{{x}}</td>
<td class="coord">{{y}}</td>
<td class="coord">{{z}}</td>
<td class="item-image">{{!item.image()}}</td>
<td class="item-name">{{!item.link_text()}}</td>
<td style="background-color: {{color}}">{{!fill_level if color in ('#0ff', '#fff') else state_message}}</td>
</tr>
""", x=x, y=y, z=z, item=item, color=HTML_COLORS[color], fill_level=fill_level, state_message=state_message)
yield '</tbody></table>'
yield from ati.html_exceptions(body())
yield ati.footer(linkify_headers=True)
|
mit
|
[
646,
1006,
1589,
1744,
855,
973,
363,
465,
282,
280,
199,
199,
646,
5888,
1118,
199,
646,
5055,
199,
646,
15502,
199,
646,
2197,
199,
646,
7975,
199,
646,
2022,
199,
646,
32212,
199,
646,
2196,
199,
646,
295,
199,
646,
2748,
14,
14338,
14,
14338,
1208,
199,
199,
646,
1006,
1589,
1744,
14,
1053,
199,
646,
1006,
1589,
1744,
14,
1974,
199,
646,
1006,
1589,
1744,
14,
7617,
199,
199,
533,
24797,
4670,
26,
272,
347,
636,
826,
721,
277,
12,
3464,
63,
890,
12,
3141,
63,
1744,
12,
1390,
63,
7257,
12,
9889,
365,
63,
7853,
63,
595,
270,
29,
549,
304,
267,
291,
14,
2340,
63,
890,
275,
3464,
63,
890,
267,
291,
14,
2923,
63,
1744,
275,
3141,
63,
1744,
267,
291,
14,
988,
63,
7257,
275,
1390,
63,
7257,
267,
291,
14,
374,
63,
7853,
63,
595,
270,
275,
365,
63,
7853,
63,
595,
270,
339,
347,
636,
495,
721,
277,
304,
267,
340,
291,
14,
2923,
63,
1744,
508,
378,
26,
288,
372,
9005,
365,
2701,
17374,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
358,
267,
916,
291,
14,
2923,
63,
1744,
508,
291,
14,
988,
63,
1744,
26,
288,
372,
9005,
365,
2615,
17374,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
358,
267,
587,
26,
288,
26733,
12,
2974,
275,
291,
14,
21707,
288,
372,
9005,
365,
13457,
1052,
5,
334,
2440,
469,
2340,
93,
2440,
2440,
734,
402,
1052,
469,
2340,
93,
83,
680,
1370,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
297,
1109,
8,
1960,
627,
291,
14,
13054,
395,
26733,
12,
2125,
340,
26733,
508,
413,
587,
283,
83,
297,
283,
436,
1052,
1242,
11123,
908,
8,
1744,
12,
2125,
340,
2974,
508,
413,
587,
283,
83,
358,
340,
2974,
690,
378,
587,
3260,
291,
14,
988,
63,
7257,
12,
3464,
534,
1053,
7,
340,
291,
14,
2340,
63,
890,
508,
413,
587,
283,
2340,
358,
339,
768,
1829,
272,
347,
12347,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
1182,
291,
14,
988,
63,
1744,
339,
347,
365,
63,
1667,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
508,
378,
339,
347,
365,
63,
2861,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
508,
291,
14,
988,
63,
1744,
339,
768,
1829,
272,
347,
1390,
63,
1744,
8,
277,
304,
267,
372,
291,
14,
988,
63,
7257,
627,
291,
14,
2340,
63,
890,
339,
768,
1829,
272,
347,
26733,
8,
277,
304,
267,
372,
16438,
8,
277,
14,
2923,
63,
1744,
12,
291,
14,
2340,
63,
890,
9,
199,
199,
25207,
3960,
275,
359,
327,
4045,
13259,
402,
1006,
31662,
3970,
5664,
315,
282,
26017,
35,
12171,
272,
334,
19,
12,
446,
23,
12,
650,
395,
272,
334,
19,
12,
446,
23,
12,
841,
395,
272,
334,
20,
12,
446,
23,
12,
841,
395,
272,
334,
21,
12,
446,
23,
12,
650,
395,
272,
334,
21,
12,
446,
23,
12,
841,
395,
272,
334,
18,
12,
446,
22,
12,
650,
395,
272,
334,
19,
12,
446,
22,
12,
499,
395,
272,
334,
19,
12,
446,
22,
12,
650,
395,
272,
334,
18,
12,
446,
21,
12,
499,
395,
272,
334,
18,
12,
446,
21,
12,
650,
395,
272,
334,
19,
12,
446,
21,
12,
650,
395,
272,
334,
18,
12,
446,
20,
12,
650,
395,
272,
334,
19,
12,
446,
20,
12,
499,
395,
272,
334,
19,
12,
446,
20,
12,
650,
395,
272,
334,
19,
12,
446,
19,
12,
499,
395,
272,
334,
20,
12,
446,
19,
12,
499,
395,
272,
334,
21,
12,
446,
19,
12,
499,
395,
272,
334,
22,
12,
446,
19,
12,
499,
395,
272,
334,
21,
12,
446,
18,
12,
499,
395,
272,
334,
22,
12,
446,
18,
12,
499,
395,
272,
334,
21,
12,
378,
12,
499,
395,
272,
334,
21,
12,
378,
12,
650,
9,
199,
61,
199,
199,
840,
4817,
63,
30582,
51,
275,
469,
272,
378,
26,
283,
8361,
297,
272,
413,
26,
283,
26655,
1175,
297,
272,
499,
26,
283,
555,
1891,
379,
9202,
1175,
297,
272,
650,
26,
283,
328,
269,
1175,
297,
272,
841,
26,
283,
555,
1891,
379,
487,
269,
1175,
297,
272,
959,
26,
283,
290,
271,
2124,
297,
272,
1227,
26,
283,
555,
1891,
379,
376,
271,
2124,
7,
199,
93,
199,
199,
40,
1938,
4227,
63,
38,
1348,
3881,
275,
469,
272,
378,
26,
283,
2110,
297,
272,
413,
26,
283,
384,
297,
327,
509,
5978,
32206,
272,
499,
26,
283,
26753,
297,
272,
650,
26,
283,
22607,
297,
272,
841,
26,
283,
19082,
297,
272,
959,
26,
283,
14346,
7,
199,
93,
199,
199,
52,
726,
1244,
63,
38,
1348,
3881,
275,
469,
272,
413,
26,
283,
475,
2399,
336,
597,
297,
272,
499,
26,
283,
475,
2399,
30254,
297,
272,
650,
26,
283,
475,
2399,
6590,
273,
297,
272,
841,
26,
283,
475,
2399,
12919,
297,
272,
959,
26,
283,
12843,
7,
199,
93,
199,
199,
4943,
63,
25671,
275,
469,
272,
283,
28291,
356,
3943,
16,
556,
297,
272,
283,
28291,
18,
356,
3943,
16,
556,
297,
272,
283,
12150,
356,
3943,
11956,
297,
272,
283,
581,
356,
3943,
70,
383,
297,
272,
283,
22683,
356,
3943,
70,
2760,
297,
272,
283,
14514,
356,
3943,
556,
16,
297,
272,
283,
7510,
356,
3943,
18190,
297,
272,
283,
7510,
18,
356,
3943,
18190,
297,
272,
488,
26,
283,
24420,
7,
199,
93,
199,
199,
318,
22377,
529,
63,
4429,
63,
7113,
8,
928,
63,
8032,
12,
1284,
63,
8032,
12,
9889,
6701,
29,
403,
12,
3728,
63,
1637,
29,
403,
12,
1853,
63,
292,
29,
403,
304,
272,
340,
6701,
365,
488,
26,
267,
6701,
275,
1006,
1589,
1744,
14,
7617,
14,
15943,
342,
272,
340,
3728,
63,
1637,
365,
488,
26,
267,
3728,
63,
1637,
275,
1052,
272,
340,
1853,
63,
292,
365,
488,
26,
267,
1853,
63,
292,
29,
7617,
14,
1457,
63,
292,
272,
15867,
63,
8032,
275,
663
] |
[
1006,
1589,
1744,
855,
973,
363,
465,
282,
280,
199,
199,
646,
5888,
1118,
199,
646,
5055,
199,
646,
15502,
199,
646,
2197,
199,
646,
7975,
199,
646,
2022,
199,
646,
32212,
199,
646,
2196,
199,
646,
295,
199,
646,
2748,
14,
14338,
14,
14338,
1208,
199,
199,
646,
1006,
1589,
1744,
14,
1053,
199,
646,
1006,
1589,
1744,
14,
1974,
199,
646,
1006,
1589,
1744,
14,
7617,
199,
199,
533,
24797,
4670,
26,
272,
347,
636,
826,
721,
277,
12,
3464,
63,
890,
12,
3141,
63,
1744,
12,
1390,
63,
7257,
12,
9889,
365,
63,
7853,
63,
595,
270,
29,
549,
304,
267,
291,
14,
2340,
63,
890,
275,
3464,
63,
890,
267,
291,
14,
2923,
63,
1744,
275,
3141,
63,
1744,
267,
291,
14,
988,
63,
7257,
275,
1390,
63,
7257,
267,
291,
14,
374,
63,
7853,
63,
595,
270,
275,
365,
63,
7853,
63,
595,
270,
339,
347,
636,
495,
721,
277,
304,
267,
340,
291,
14,
2923,
63,
1744,
508,
378,
26,
288,
372,
9005,
365,
2701,
17374,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
358,
267,
916,
291,
14,
2923,
63,
1744,
508,
291,
14,
988,
63,
1744,
26,
288,
372,
9005,
365,
2615,
17374,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
358,
267,
587,
26,
288,
26733,
12,
2974,
275,
291,
14,
21707,
288,
372,
9005,
365,
13457,
1052,
5,
334,
2440,
469,
2340,
93,
2440,
2440,
734,
402,
1052,
469,
2340,
93,
83,
680,
1370,
908,
360,
29111,
35,
12171,
7,
340,
291,
14,
374,
63,
7853,
63,
595,
270,
587,
283,
35,
12171,
297,
1109,
8,
1960,
627,
291,
14,
13054,
395,
26733,
12,
2125,
340,
26733,
508,
413,
587,
283,
83,
297,
283,
436,
1052,
1242,
11123,
908,
8,
1744,
12,
2125,
340,
2974,
508,
413,
587,
283,
83,
358,
340,
2974,
690,
378,
587,
3260,
291,
14,
988,
63,
7257,
12,
3464,
534,
1053,
7,
340,
291,
14,
2340,
63,
890,
508,
413,
587,
283,
2340,
358,
339,
768,
1829,
272,
347,
12347,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
1182,
291,
14,
988,
63,
1744,
339,
347,
365,
63,
1667,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
508,
378,
339,
347,
365,
63,
2861,
8,
277,
304,
267,
372,
291,
14,
2923,
63,
1744,
508,
291,
14,
988,
63,
1744,
339,
768,
1829,
272,
347,
1390,
63,
1744,
8,
277,
304,
267,
372,
291,
14,
988,
63,
7257,
627,
291,
14,
2340,
63,
890,
339,
768,
1829,
272,
347,
26733,
8,
277,
304,
267,
372,
16438,
8,
277,
14,
2923,
63,
1744,
12,
291,
14,
2340,
63,
890,
9,
199,
199,
25207,
3960,
275,
359,
327,
4045,
13259,
402,
1006,
31662,
3970,
5664,
315,
282,
26017,
35,
12171,
272,
334,
19,
12,
446,
23,
12,
650,
395,
272,
334,
19,
12,
446,
23,
12,
841,
395,
272,
334,
20,
12,
446,
23,
12,
841,
395,
272,
334,
21,
12,
446,
23,
12,
650,
395,
272,
334,
21,
12,
446,
23,
12,
841,
395,
272,
334,
18,
12,
446,
22,
12,
650,
395,
272,
334,
19,
12,
446,
22,
12,
499,
395,
272,
334,
19,
12,
446,
22,
12,
650,
395,
272,
334,
18,
12,
446,
21,
12,
499,
395,
272,
334,
18,
12,
446,
21,
12,
650,
395,
272,
334,
19,
12,
446,
21,
12,
650,
395,
272,
334,
18,
12,
446,
20,
12,
650,
395,
272,
334,
19,
12,
446,
20,
12,
499,
395,
272,
334,
19,
12,
446,
20,
12,
650,
395,
272,
334,
19,
12,
446,
19,
12,
499,
395,
272,
334,
20,
12,
446,
19,
12,
499,
395,
272,
334,
21,
12,
446,
19,
12,
499,
395,
272,
334,
22,
12,
446,
19,
12,
499,
395,
272,
334,
21,
12,
446,
18,
12,
499,
395,
272,
334,
22,
12,
446,
18,
12,
499,
395,
272,
334,
21,
12,
378,
12,
499,
395,
272,
334,
21,
12,
378,
12,
650,
9,
199,
61,
199,
199,
840,
4817,
63,
30582,
51,
275,
469,
272,
378,
26,
283,
8361,
297,
272,
413,
26,
283,
26655,
1175,
297,
272,
499,
26,
283,
555,
1891,
379,
9202,
1175,
297,
272,
650,
26,
283,
328,
269,
1175,
297,
272,
841,
26,
283,
555,
1891,
379,
487,
269,
1175,
297,
272,
959,
26,
283,
290,
271,
2124,
297,
272,
1227,
26,
283,
555,
1891,
379,
376,
271,
2124,
7,
199,
93,
199,
199,
40,
1938,
4227,
63,
38,
1348,
3881,
275,
469,
272,
378,
26,
283,
2110,
297,
272,
413,
26,
283,
384,
297,
327,
509,
5978,
32206,
272,
499,
26,
283,
26753,
297,
272,
650,
26,
283,
22607,
297,
272,
841,
26,
283,
19082,
297,
272,
959,
26,
283,
14346,
7,
199,
93,
199,
199,
52,
726,
1244,
63,
38,
1348,
3881,
275,
469,
272,
413,
26,
283,
475,
2399,
336,
597,
297,
272,
499,
26,
283,
475,
2399,
30254,
297,
272,
650,
26,
283,
475,
2399,
6590,
273,
297,
272,
841,
26,
283,
475,
2399,
12919,
297,
272,
959,
26,
283,
12843,
7,
199,
93,
199,
199,
4943,
63,
25671,
275,
469,
272,
283,
28291,
356,
3943,
16,
556,
297,
272,
283,
28291,
18,
356,
3943,
16,
556,
297,
272,
283,
12150,
356,
3943,
11956,
297,
272,
283,
581,
356,
3943,
70,
383,
297,
272,
283,
22683,
356,
3943,
70,
2760,
297,
272,
283,
14514,
356,
3943,
556,
16,
297,
272,
283,
7510,
356,
3943,
18190,
297,
272,
283,
7510,
18,
356,
3943,
18190,
297,
272,
488,
26,
283,
24420,
7,
199,
93,
199,
199,
318,
22377,
529,
63,
4429,
63,
7113,
8,
928,
63,
8032,
12,
1284,
63,
8032,
12,
9889,
6701,
29,
403,
12,
3728,
63,
1637,
29,
403,
12,
1853,
63,
292,
29,
403,
304,
272,
340,
6701,
365,
488,
26,
267,
6701,
275,
1006,
1589,
1744,
14,
7617,
14,
15943,
342,
272,
340,
3728,
63,
1637,
365,
488,
26,
267,
3728,
63,
1637,
275,
1052,
272,
340,
1853,
63,
292,
365,
488,
26,
267,
1853,
63,
292,
29,
7617,
14,
1457,
63,
292,
272,
15867,
63,
8032,
275,
663,
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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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
] |
magicrub/MissionPlanner
|
Lib/site-packages/numpy/core/tests/test_npy_arraytypes.py
|
54
|
5864
|
import sys
import warnings
import numpy as np
from numpy.testing import *
warnings.filterwarnings('ignore',
'Casting complex values to real discards the imaginary part')
types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
np.int_, np.uint, np.longlong, np.ulonglong,
np.single, np.double, np.longdouble, np.csingle,
np.cdouble, np.clongdouble]
alltypes = list( types )
alltypes.append( np.datetime64 )
alltypes.append( np.timedelta64 )
class TestArrayTypes(TestCase):
def test_argmax( self ):
x = np.array( [False, False, True, False], dtype=np.bool )
assert x.argmax() == 2, "Broken array.argmax on np.bool"
a = np.array( [u'aaa', u'aa', u'bbb'] )
# u'aaa' > u'aa' and u'bbb' > u'aaa' Hence, argmax == 2.
assert a.argmax() == 2, "Broken array.argmax on unicode data."
a = np.array( [ 'aaa', 'aa', 'bbb'] )
# 'aaa' > 'aa' and 'bbb' > 'aaa' Hence, argmax == 2.
assert a.argmax() == 2, "Broken array.argmax on string data."
def test_argmax_numeric( self ):
# Skip the np.bool_ type as it lacks a fill function, hence can't use
# arange().
for k,t in enumerate( alltypes[1:] ):
a = np.arange( 5, dtype=t )
assert a.argmax() == 4, "Broken array.argmax on type: " + t
def test_nonzero_numeric_types( self ):
for k,t in enumerate(alltypes):
a = np.array( [ t(1) ] )
assert a, "Broken array.nonzero on type: " + t
def test_nonzero_string_types( self ):
a = np.array( [ 'aaa' ] )
assert a, "Broken array.nonzero on string elements."
a = np.array( [ u'aaa' ] )
assert a, "Broken array.nonzero on Unicode elements."
def test_compare( self ):
# Light bulb! argmax doesn't call compare() for numeric/logical
# types. It only does that for string types. Duh.
pass
def test_copyswap( self ):
# Skip np.bool_.
for k,t in enumerate( types[1:] ):
x = np.arange( 10, dtype=t )
# This should exeercise <typoe>_copyswap
x[::2].fill( t(2) )
assert_equal( x, [2,1,2,3,2,5,2,7,2,9] )
def test_copyswap_misc( self ):
x = np.array( [ u'a', u'b', u'c' ] )
x[::2].fill( u'd' )
assert_equal( x, [u'd', u'b', u'd'] )
def test_copyswapn( self ):
# bool lacks arange support.
for k,t in enumerate( alltypes[1:] ):
x = np.arange( 10, dtype=t )
y = x.byteswap()
z = y.byteswap()
assert_equal( z, x )
def test_copyswapn_misc( self ):
x = np.array( [ u'a', u'b', u'c' ] )
y = x.byteswap()
z = y.byteswap()
assert_equal( z, x )
def test_compare( self ):
for k,t in enumerate( alltypes[1:] ):
try:
a = np.arange( 10, dtype=t )
keys = a[::2]
b = a.searchsorted( keys )
c = a.copy()
np.insert( c, b, b.astype( t ) )
c.sort()
assert_equal( c, a )
except TypeError, e:
print "Trouble with type %d:" % k, e
def test_compare_bool( self ):
# bool can't handle numpy.arange(), so has to be coded separately.
a = np.array( [False, True], dtype=np.bool_ )
keys = a
b = a.searchsorted( keys )
c = a.copy()
np.insert( c, b, keys )
c.sort()
assert_equal( c, a )
def test_dot( self ):
# Do something to test dot on bool...
for k,t in enumerate( alltypes[1:] ):
a = np.arange( 3, dtype=t ) + 1
assert a.dot(a) == t(14), \
"Problem with dot product with array of type %s" % k
def test_clip( self ):
for k,t in enumerate( alltypes[1:] ):
a = np.arange( 5, dtype=t )
b = a.clip( 2, 3 )
x = np.array( [2,2,2,3,3], dtype=t )
assert_equal( b, x )
def test_clip_bool( self ):
a = np.array( [False, True], np.bool )
assert_equal( a.clip(False,False), [False, False] )
def test_array_casting( self ):
for k,t in enumerate( alltypes ):
a = np.array( [ t(1) ] )
for k2, t2 in enumerate( alltypes ):
b = a.astype( t2 )
if k2 < len(types):
assert b[0] == 1, \
"Busted array type casting: k=%d k2=%d" % (k,k2)
else:
# Casting to datetime64 yields a 1/1/1970+... result,
# which isn't so hot for checking against "1". So, in
# these cases, just cast back to the starting time, and
# make sure we got back what we started with.
c = b.astype( t )
assert_equal( c, a )
def test_take( self ):
# Test all types, but skipp np.bool_ for now, as it lacks a fill
# function. Grrr.
for k,t in enumerate( alltypes[1:] ):
a = np.arange( 10, dtype=t )
idx = np.arange(5) * 2
c = np.take( a, idx )
assert_equal( c, a[::2] )
def test_putmask( self ):
for k,t in enumerate( alltypes[1:] ):
a = np.arange( 5, dtype=t )
mask = np.zeros( 5, dtype=np.bool )
mask[::2] = True
np.putmask( a, mask, t(8) )
x = np.array( [8,1,8,3,8], dtype=t )
assert_equal( a, x )
def test_fillwithscalar( self ):
a = np.empty( 2, dtype=np.datetime64 )
a.fill( np.datetime64( 3 ) )
x = np.zeros( 2, dtype=np.datetime64 ) + 3
assert_equal( a, x )
if __name__ == "__main__":
run_module_suite()
|
gpl-3.0
|
[
646,
984,
199,
646,
3598,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
627,
421,
199,
5451,
14,
23945,
360,
4247,
297,
1467,
283,
24654,
316,
6114,
1338,
370,
3363,
4339,
5596,
314,
30249,
1777,
358,
199,
199,
1313,
275,
359,
1590,
14,
2245,
3131,
980,
14,
4414,
12,
980,
14,
20790,
12,
980,
14,
3612,
12,
980,
14,
27170,
12,
980,
14,
442,
67,
12,
980,
14,
1635,
67,
12,
268,
980,
14,
442,
3131,
980,
14,
1635,
12,
980,
14,
2809,
2809,
12,
980,
14,
32020,
12,
268,
980,
14,
4780,
12,
980,
14,
3157,
12,
980,
14,
2809,
3157,
12,
980,
14,
67,
4780,
12,
268,
980,
14,
67,
3157,
12,
980,
14,
429,
951,
3157,
61,
199,
199,
452,
1313,
275,
769,
8,
2943,
776,
199,
452,
1313,
14,
740,
8,
980,
14,
2083,
772,
776,
199,
452,
1313,
14,
740,
8,
980,
14,
7473,
772,
776,
199,
199,
533,
1379,
3836,
4100,
8,
1746,
304,
339,
347,
511,
63,
16383,
8,
291,
3461,
398,
671,
275,
980,
14,
1144,
8,
359,
797,
12,
756,
12,
715,
12,
756,
467,
2152,
29,
1590,
14,
2245,
776,
267,
702,
671,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
980,
14,
2245,
2,
398,
282,
275,
980,
14,
1144,
8,
359,
85,
7,
11629,
297,
399,
7,
2158,
297,
399,
7,
19482,
418,
776,
267,
327,
399,
7,
11629,
7,
690,
399,
7,
2158,
7,
436,
399,
7,
19482,
7,
690,
399,
7,
11629,
7,
221,
869,
4894,
12,
1680,
988,
508,
499,
14,
267,
702,
282,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
2649,
666,
2122,
398,
282,
275,
980,
14,
1144,
8,
359,
283,
11629,
297,
283,
2158,
297,
283,
19482,
418,
776,
267,
327,
283,
11629,
7,
690,
283,
2158,
7,
436,
283,
19482,
7,
690,
283,
11629,
7,
221,
869,
4894,
12,
1680,
988,
508,
499,
14,
267,
702,
282,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
1059,
666,
2122,
339,
347,
511,
63,
16383,
63,
6677,
8,
291,
3461,
398,
327,
8232,
314,
980,
14,
2245,
63,
730,
465,
652,
1127,
5618,
282,
5554,
805,
12,
19407,
883,
1133,
675,
267,
327,
20461,
1252,
267,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
282,
275,
980,
14,
5605,
8,
959,
12,
2152,
29,
84,
776,
288,
702,
282,
14,
16383,
342,
508,
841,
12,
298,
30509,
1625,
14,
16383,
641,
730,
26,
298,
435,
307,
339,
347,
511,
63,
10262,
63,
6677,
63,
1313,
8,
291,
3461,
398,
367,
1022,
12,
84,
315,
3874,
8,
452,
1313,
304,
953,
282,
275,
980,
14,
1144,
8,
359,
307,
8,
17,
9,
1622,
776,
953,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
730,
26,
298,
435,
307,
339,
347,
511,
63,
10262,
63,
875,
63,
1313,
8,
291,
3461,
398,
282,
275,
980,
14,
1144,
8,
359,
283,
11629,
7,
1622,
776,
267,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
1059,
4008,
2122,
398,
282,
275,
980,
14,
1144,
8,
359,
399,
7,
11629,
7,
1622,
776,
267,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
6140,
4008,
2122,
339,
347,
511,
63,
5785,
8,
291,
3461,
267,
327,
29684,
330,
348,
66,
1,
221,
1680,
988,
3181,
1133,
1240,
6540,
342,
367,
8950,
15,
7954,
267,
327,
2943,
14,
221,
2779,
1454,
1630,
626,
367,
1059,
2943,
14,
221,
577,
22451,
14,
398,
986,
339,
347,
511,
63,
331,
15983,
25529,
8,
291,
3461,
398,
327,
8232,
980,
14,
2245,
3754,
267,
367,
1022,
12,
84,
315,
3874,
8,
2943,
59,
17,
2938,
3461,
953,
671,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
288,
327,
961,
1077,
14778,
20616,
665,
369,
555,
69,
30,
63,
331,
15983,
25529,
288,
671,
10345,
18,
1055,
4498,
8,
307,
8,
18,
9,
776,
953,
702,
63,
1452,
8,
671,
12,
359,
18,
12,
17,
12,
18,
12,
19,
12,
18,
12,
21,
12,
18,
12,
23,
12,
18,
12,
25,
61,
776,
339,
347,
511,
63,
331,
15983,
25529,
63,
9923,
8,
291,
3461,
398,
671,
275,
980,
14,
1144,
8,
359,
399,
7,
65,
297,
399,
7,
66,
297,
399,
7,
67,
7,
1622,
776,
267,
671,
10345,
18,
1055,
4498,
8,
399,
5121,
7,
776,
267,
702,
63,
1452,
8,
671,
12,
359,
85,
5121,
297,
399,
7,
66,
297,
399,
5121,
418,
776,
339,
347,
511,
63,
331,
15983,
25529,
78,
8,
291,
3461,
398,
327,
2155,
1127,
5618,
20461,
2291,
14,
267,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
671,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
288,
612,
275,
671,
14,
2394,
25529,
342,
288,
1315,
275,
612,
14,
2394,
25529,
342,
953,
702,
63,
1452,
8,
1315,
12,
671,
776,
339,
347,
511,
63,
331,
15983,
25529,
78,
63,
9923,
8,
291,
3461,
267,
671,
275,
980,
14,
1144,
8,
359,
399,
7,
65,
297,
399,
7,
66,
297,
399,
7,
67,
7,
1622,
776,
267,
612,
275,
671,
14,
2394,
25529,
342,
267,
1315,
275,
612,
14,
2394,
25529,
342,
398,
702,
63,
1452,
8,
1315,
12,
671,
776,
339,
347,
511,
63,
5785,
8,
291,
3461,
398,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
862,
26,
355,
282,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
355,
2883,
275,
282,
10345,
18,
61,
355,
330,
275,
282,
14,
31698,
8,
2883,
776,
355,
286,
275,
282,
14,
1574,
342,
355,
980,
14,
3176,
8,
286,
12,
330,
12,
330,
14,
6041,
8,
307,
776,
776,
355,
286,
14,
3191,
342,
355,
702,
63,
1452,
8,
286,
12,
282,
776,
953,
871,
3146,
12,
325,
26,
355,
870,
298,
52,
293,
2016,
543,
730,
450,
68,
5424,
450,
1022,
12,
325,
339,
347,
511,
63,
5785,
63,
2245,
8,
291,
3461,
267,
327,
2155,
883,
1133,
2429,
2680,
14,
5605,
1062,
880,
965,
370,
506,
1233,
68,
18159,
14,
267
] |
[
984,
199,
646,
3598,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
627,
421,
199,
5451,
14,
23945,
360,
4247,
297,
1467,
283,
24654,
316,
6114,
1338,
370,
3363,
4339,
5596,
314,
30249,
1777,
358,
199,
199,
1313,
275,
359,
1590,
14,
2245,
3131,
980,
14,
4414,
12,
980,
14,
20790,
12,
980,
14,
3612,
12,
980,
14,
27170,
12,
980,
14,
442,
67,
12,
980,
14,
1635,
67,
12,
268,
980,
14,
442,
3131,
980,
14,
1635,
12,
980,
14,
2809,
2809,
12,
980,
14,
32020,
12,
268,
980,
14,
4780,
12,
980,
14,
3157,
12,
980,
14,
2809,
3157,
12,
980,
14,
67,
4780,
12,
268,
980,
14,
67,
3157,
12,
980,
14,
429,
951,
3157,
61,
199,
199,
452,
1313,
275,
769,
8,
2943,
776,
199,
452,
1313,
14,
740,
8,
980,
14,
2083,
772,
776,
199,
452,
1313,
14,
740,
8,
980,
14,
7473,
772,
776,
199,
199,
533,
1379,
3836,
4100,
8,
1746,
304,
339,
347,
511,
63,
16383,
8,
291,
3461,
398,
671,
275,
980,
14,
1144,
8,
359,
797,
12,
756,
12,
715,
12,
756,
467,
2152,
29,
1590,
14,
2245,
776,
267,
702,
671,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
980,
14,
2245,
2,
398,
282,
275,
980,
14,
1144,
8,
359,
85,
7,
11629,
297,
399,
7,
2158,
297,
399,
7,
19482,
418,
776,
267,
327,
399,
7,
11629,
7,
690,
399,
7,
2158,
7,
436,
399,
7,
19482,
7,
690,
399,
7,
11629,
7,
221,
869,
4894,
12,
1680,
988,
508,
499,
14,
267,
702,
282,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
2649,
666,
2122,
398,
282,
275,
980,
14,
1144,
8,
359,
283,
11629,
297,
283,
2158,
297,
283,
19482,
418,
776,
267,
327,
283,
11629,
7,
690,
283,
2158,
7,
436,
283,
19482,
7,
690,
283,
11629,
7,
221,
869,
4894,
12,
1680,
988,
508,
499,
14,
267,
702,
282,
14,
16383,
342,
508,
499,
12,
298,
30509,
1625,
14,
16383,
641,
1059,
666,
2122,
339,
347,
511,
63,
16383,
63,
6677,
8,
291,
3461,
398,
327,
8232,
314,
980,
14,
2245,
63,
730,
465,
652,
1127,
5618,
282,
5554,
805,
12,
19407,
883,
1133,
675,
267,
327,
20461,
1252,
267,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
282,
275,
980,
14,
5605,
8,
959,
12,
2152,
29,
84,
776,
288,
702,
282,
14,
16383,
342,
508,
841,
12,
298,
30509,
1625,
14,
16383,
641,
730,
26,
298,
435,
307,
339,
347,
511,
63,
10262,
63,
6677,
63,
1313,
8,
291,
3461,
398,
367,
1022,
12,
84,
315,
3874,
8,
452,
1313,
304,
953,
282,
275,
980,
14,
1144,
8,
359,
307,
8,
17,
9,
1622,
776,
953,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
730,
26,
298,
435,
307,
339,
347,
511,
63,
10262,
63,
875,
63,
1313,
8,
291,
3461,
398,
282,
275,
980,
14,
1144,
8,
359,
283,
11629,
7,
1622,
776,
267,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
1059,
4008,
2122,
398,
282,
275,
980,
14,
1144,
8,
359,
399,
7,
11629,
7,
1622,
776,
267,
702,
282,
12,
298,
30509,
1625,
14,
10262,
641,
6140,
4008,
2122,
339,
347,
511,
63,
5785,
8,
291,
3461,
267,
327,
29684,
330,
348,
66,
1,
221,
1680,
988,
3181,
1133,
1240,
6540,
342,
367,
8950,
15,
7954,
267,
327,
2943,
14,
221,
2779,
1454,
1630,
626,
367,
1059,
2943,
14,
221,
577,
22451,
14,
398,
986,
339,
347,
511,
63,
331,
15983,
25529,
8,
291,
3461,
398,
327,
8232,
980,
14,
2245,
3754,
267,
367,
1022,
12,
84,
315,
3874,
8,
2943,
59,
17,
2938,
3461,
953,
671,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
288,
327,
961,
1077,
14778,
20616,
665,
369,
555,
69,
30,
63,
331,
15983,
25529,
288,
671,
10345,
18,
1055,
4498,
8,
307,
8,
18,
9,
776,
953,
702,
63,
1452,
8,
671,
12,
359,
18,
12,
17,
12,
18,
12,
19,
12,
18,
12,
21,
12,
18,
12,
23,
12,
18,
12,
25,
61,
776,
339,
347,
511,
63,
331,
15983,
25529,
63,
9923,
8,
291,
3461,
398,
671,
275,
980,
14,
1144,
8,
359,
399,
7,
65,
297,
399,
7,
66,
297,
399,
7,
67,
7,
1622,
776,
267,
671,
10345,
18,
1055,
4498,
8,
399,
5121,
7,
776,
267,
702,
63,
1452,
8,
671,
12,
359,
85,
5121,
297,
399,
7,
66,
297,
399,
5121,
418,
776,
339,
347,
511,
63,
331,
15983,
25529,
78,
8,
291,
3461,
398,
327,
2155,
1127,
5618,
20461,
2291,
14,
267,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
671,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
288,
612,
275,
671,
14,
2394,
25529,
342,
288,
1315,
275,
612,
14,
2394,
25529,
342,
953,
702,
63,
1452,
8,
1315,
12,
671,
776,
339,
347,
511,
63,
331,
15983,
25529,
78,
63,
9923,
8,
291,
3461,
267,
671,
275,
980,
14,
1144,
8,
359,
399,
7,
65,
297,
399,
7,
66,
297,
399,
7,
67,
7,
1622,
776,
267,
612,
275,
671,
14,
2394,
25529,
342,
267,
1315,
275,
612,
14,
2394,
25529,
342,
398,
702,
63,
1452,
8,
1315,
12,
671,
776,
339,
347,
511,
63,
5785,
8,
291,
3461,
398,
367,
1022,
12,
84,
315,
3874,
8,
1006,
1313,
59,
17,
2938,
3461,
953,
862,
26,
355,
282,
275,
980,
14,
5605,
8,
1616,
12,
2152,
29,
84,
776,
355,
2883,
275,
282,
10345,
18,
61,
355,
330,
275,
282,
14,
31698,
8,
2883,
776,
355,
286,
275,
282,
14,
1574,
342,
355,
980,
14,
3176,
8,
286,
12,
330,
12,
330,
14,
6041,
8,
307,
776,
776,
355,
286,
14,
3191,
342,
355,
702,
63,
1452,
8,
286,
12,
282,
776,
953,
871,
3146,
12,
325,
26,
355,
870,
298,
52,
293,
2016,
543,
730,
450,
68,
5424,
450,
1022,
12,
325,
339,
347,
511,
63,
5785,
63,
2245,
8,
291,
3461,
267,
327,
2155,
883,
1133,
2429,
2680,
14,
5605,
1062,
880,
965,
370,
506,
1233,
68,
18159,
14,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
leiferikb/bitpop
|
build/third_party/requests_1_2_3/requests/packages/urllib3/request.py
|
154
|
5874
|
# urllib3/request.py
# Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
from .filepost import encode_multipart_formdata
__all__ = ['RequestMethods']
class RequestMethods(object):
"""
Convenience mixin for classes who implement a :meth:`urlopen` method, such
as :class:`~urllib3.connectionpool.HTTPConnectionPool` and
:class:`~urllib3.poolmanager.PoolManager`.
Provides behavior for making common types of HTTP request methods and
decides which type of request field encoding to use.
Specifically,
:meth:`.request_encode_url` is for sending requests whose fields are encoded
in the URL (such as GET, HEAD, DELETE).
:meth:`.request_encode_body` is for sending requests whose fields are
encoded in the *body* of the request using multipart or www-form-urlencoded
(such as for POST, PUT, PATCH).
:meth:`.request` is for making any kind of request, it will look up the
appropriate encoding format and use one of the above two methods to make
the request.
Initializer parameters:
:param headers:
Headers to include with all requests, unless other headers are given
explicitly.
"""
_encode_url_methods = set(['DELETE', 'GET', 'HEAD', 'OPTIONS'])
_encode_body_methods = set(['PATCH', 'POST', 'PUT', 'TRACE'])
def __init__(self, headers=None):
self.headers = headers or {}
def urlopen(self, method, url, body=None, headers=None,
encode_multipart=True, multipart_boundary=None,
**kw): # Abstract
raise NotImplemented("Classes extending RequestMethods must implement "
"their own ``urlopen`` method.")
def request(self, method, url, fields=None, headers=None, **urlopen_kw):
"""
Make a request using :meth:`urlopen` with the appropriate encoding of
``fields`` based on the ``method`` used.
This is a convenience method that requires the least amount of manual
effort. It can be used in most situations, while still having the option
to drop down to more specific methods when necessary, such as
:meth:`request_encode_url`, :meth:`request_encode_body`,
or even the lowest level :meth:`urlopen`.
"""
method = method.upper()
if method in self._encode_url_methods:
return self.request_encode_url(method, url, fields=fields,
headers=headers,
**urlopen_kw)
else:
return self.request_encode_body(method, url, fields=fields,
headers=headers,
**urlopen_kw)
def request_encode_url(self, method, url, fields=None, **urlopen_kw):
"""
Make a request using :meth:`urlopen` with the ``fields`` encoded in
the url. This is useful for request methods like GET, HEAD, DELETE, etc.
"""
if fields:
url += '?' + urlencode(fields)
return self.urlopen(method, url, **urlopen_kw)
def request_encode_body(self, method, url, fields=None, headers=None,
encode_multipart=True, multipart_boundary=None,
**urlopen_kw):
"""
Make a request using :meth:`urlopen` with the ``fields`` encoded in
the body. This is useful for request methods like POST, PUT, PATCH, etc.
When ``encode_multipart=True`` (default), then
:meth:`urllib3.filepost.encode_multipart_formdata` is used to encode the
payload with the appropriate content type. Otherwise
:meth:`urllib.urlencode` is used with the
'application/x-www-form-urlencoded' content type.
Multipart encoding must be used when posting files, and it's reasonably
safe to use it in other times too. However, it may break request signing,
such as with OAuth.
Supports an optional ``fields`` parameter of key/value strings AND
key/filetuple. A filetuple is a (filename, data, MIME type) tuple where
the MIME type is optional. For example: ::
fields = {
'foo': 'bar',
'fakefile': ('foofile.txt', 'contents of foofile'),
'realfile': ('barfile.txt', open('realfile').read()),
'typedfile': ('bazfile.bin', open('bazfile').read(),
'image/jpeg'),
'nonamefile': 'contents of nonamefile field',
}
When uploading a file, providing a filename (the first parameter of the
tuple) is optional but recommended to best mimick behavior of browsers.
Note that if ``headers`` are supplied, the 'Content-Type' header will be
overwritten because it depends on the dynamic random boundary string
which is used to compose the body of the request. The random boundary
string can be explicitly set with the ``multipart_boundary`` parameter.
"""
if encode_multipart:
body, content_type = encode_multipart_formdata(fields or {},
boundary=multipart_boundary)
else:
body, content_type = (urlencode(fields or {}),
'application/x-www-form-urlencoded')
if headers is None:
headers = self.headers
headers_ = {'Content-Type': content_type}
headers_.update(headers)
return self.urlopen(method, url, body=body, headers=headers_,
**urlopen_kw)
|
gpl-3.0
|
[
3,
4011,
19,
15,
1069,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
893,
26,
272,
687,
4011,
14,
1122,
492,
16511,
199,
2590,
3545,
26,
272,
687,
4011,
492,
16511,
199,
199,
504,
1275,
493,
1932,
492,
3752,
63,
10123,
63,
30942,
421,
199,
363,
452,
363,
275,
788,
2017,
10385,
418,
421,
199,
533,
4784,
10385,
8,
785,
304,
272,
408,
272,
1448,
23329,
20048,
367,
3992,
3963,
5669,
282,
520,
5247,
1705,
10890,
64,
1083,
12,
4066,
272,
465,
520,
533,
6054,
4078,
19,
14,
2105,
2293,
14,
19114,
5453,
64,
436,
272,
520,
533,
6054,
4078,
19,
14,
2293,
2609,
14,
5453,
2988,
2313,
339,
21552,
5953,
367,
10663,
2863,
2943,
402,
3101,
1056,
3102,
436,
272,
12985,
3424,
1314,
730,
402,
1056,
901,
2644,
370,
675,
14,
339,
30836,
12,
339,
520,
5247,
5026,
1069,
63,
2143,
63,
633,
64,
365,
367,
10209,
4145,
7447,
1504,
787,
5737,
272,
315,
314,
2851,
334,
10180,
465,
9576,
12,
13053,
12,
15137,
680,
339,
520,
5247,
5026,
1069,
63,
2143,
63,
2030,
64,
365,
367,
10209,
4145,
7447,
1504,
787,
272,
5737,
315,
314,
627,
2030,
10,
402,
314,
1056,
1808,
15193,
503,
20732,
13,
964,
13,
21886,
272,
334,
10180,
465,
367,
8761,
12,
18337,
12,
510,
8078,
680,
339,
520,
5247,
5026,
1069,
64,
365,
367,
10663,
1263,
4928,
402,
1056,
12,
652,
911,
3648,
1536,
314,
272,
5827,
2644,
1475,
436,
675,
1373,
402,
314,
3432,
2877,
3102,
370,
1852,
272,
314,
1056,
14,
339,
6026,
1793,
2633,
26,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
272,
408,
339,
485,
2143,
63,
633,
63,
2474,
275,
663,
2941,
7014,
297,
283,
2970,
297,
283,
5211,
297,
283,
8808,
1105,
272,
485,
2143,
63,
2030,
63,
2474,
275,
663,
2941,
17073,
297,
283,
4030,
297,
283,
4013,
297,
283,
20112,
1105,
339,
347,
636,
826,
721,
277,
12,
2323,
29,
403,
304,
267,
291,
14,
2139,
275,
2323,
503,
1052,
339,
347,
18279,
8,
277,
12,
1083,
12,
1166,
12,
2396,
29,
403,
12,
2323,
29,
403,
12,
355,
3752,
63,
10123,
29,
549,
12,
15193,
63,
9891,
29,
403,
12,
355,
1011,
829,
304,
327,
11836,
267,
746,
3784,
480,
15711,
2178,
1098,
4784,
10385,
1471,
5669,
298,
2490,
298,
1589,
723,
5705,
1124,
10890,
1040,
1083,
2685,
339,
347,
1056,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
2323,
29,
403,
12,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
5827,
2644,
402,
267,
1124,
955,
1040,
4079,
641,
314,
1124,
765,
1040,
1202,
14,
398,
961,
365,
282,
16777,
1083,
626,
5074,
314,
5210,
5982,
402,
8722,
267,
28058,
14,
2779,
883,
506,
1202,
315,
4750,
24325,
12,
1830,
5139,
9445,
314,
945,
267,
370,
5978,
3224,
370,
1655,
2488,
3102,
1380,
5784,
12,
4066,
465,
267,
520,
5247,
1705,
1069,
63,
2143,
63,
633,
3559,
520,
5247,
1705,
1069,
63,
2143,
63,
2030,
3559,
267,
503,
2755,
314,
18966,
2166,
520,
5247,
1705,
10890,
2313,
267,
408,
267,
1083,
275,
1083,
14,
4142,
342,
398,
340,
1083,
315,
291,
423,
2143,
63,
633,
63,
2474,
26,
288,
372,
291,
14,
1069,
63,
2143,
63,
633,
8,
765,
12,
1166,
12,
1504,
29,
955,
12,
4490,
2323,
29,
2139,
12,
4490,
1011,
10890,
63,
829,
9,
267,
587,
26,
288,
372,
291,
14,
1069,
63,
2143,
63,
2030,
8,
765,
12,
1166,
12,
1504,
29,
955,
12,
6163,
2323,
29,
2139,
12,
6163,
1011,
10890,
63,
829,
9,
339,
347,
1056,
63,
2143,
63,
633,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
1124,
955,
1040,
5737,
315,
267,
314,
1166,
14,
961,
365,
2997,
367,
1056,
3102,
2839,
9576,
12,
13053,
12,
15137,
12,
5423,
14,
267,
408,
267,
340,
1504,
26,
288,
1166,
847,
15539,
435,
16511,
8,
955,
9,
267,
372,
291,
14,
10890,
8,
765,
12,
1166,
12,
1011,
10890,
63,
829,
9,
339,
347,
1056,
63,
2143,
63,
2030,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
2323,
29,
403,
12,
1169,
3752,
63,
10123,
29,
549,
12,
15193,
63,
9891,
29,
403,
12,
1169,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
1124,
955,
1040,
5737,
315,
267,
314,
2396,
14,
961,
365,
2997,
367,
1056,
3102,
2839,
8761,
12,
18337,
12,
510,
8078,
12,
5423,
14,
398,
3979,
1124,
2143,
63,
10123,
29,
549,
1040,
334,
885,
395,
2066,
267,
520,
5247,
1705,
4078,
19,
14,
493,
1932,
14,
2143,
63,
10123,
63,
30942,
64,
365,
1202,
370,
3752,
314,
267,
4886,
543,
314,
5827,
1564,
730,
14,
6630,
267,
520,
5247,
1705,
4078,
14,
10738,
64,
365,
1202,
543,
314,
267,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
7,
1564,
730,
14,
398,
6879,
2064,
2644,
1471,
506,
1202,
1380,
25386,
1584,
12,
436,
652,
1159,
4499,
6665,
267,
5048,
370,
675,
652,
315,
1163,
5431,
4634,
14,
9738,
12,
652,
1443,
2059,
1056,
18057,
12,
267,
4066,
465,
543,
11715,
14,
398,
32090,
376,
2716,
1124,
955,
1040,
2725,
402,
790,
15,
585,
3326,
2401,
267,
790,
15,
493,
2960,
14,
437,
570,
2960,
365,
282,
334,
1501,
12,
666,
12,
14735,
730,
9,
2008,
2382,
267,
314,
14735,
730,
365,
2716,
14,
2104,
2893,
26,
3800,
953,
1504,
275,
469,
355,
283,
1421,
356,
283,
1700,
297,
355,
283,
3183,
493,
356,
661,
1421,
493,
14,
2424,
297,
283,
4407,
402,
3925,
493,
659,
355,
283,
264,
7411,
441,
356,
661,
1700,
493,
14,
2424,
297,
1551,
360
] |
[
4011,
19,
15,
1069,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
893,
26,
272,
687,
4011,
14,
1122,
492,
16511,
199,
2590,
3545,
26,
272,
687,
4011,
492,
16511,
199,
199,
504,
1275,
493,
1932,
492,
3752,
63,
10123,
63,
30942,
421,
199,
363,
452,
363,
275,
788,
2017,
10385,
418,
421,
199,
533,
4784,
10385,
8,
785,
304,
272,
408,
272,
1448,
23329,
20048,
367,
3992,
3963,
5669,
282,
520,
5247,
1705,
10890,
64,
1083,
12,
4066,
272,
465,
520,
533,
6054,
4078,
19,
14,
2105,
2293,
14,
19114,
5453,
64,
436,
272,
520,
533,
6054,
4078,
19,
14,
2293,
2609,
14,
5453,
2988,
2313,
339,
21552,
5953,
367,
10663,
2863,
2943,
402,
3101,
1056,
3102,
436,
272,
12985,
3424,
1314,
730,
402,
1056,
901,
2644,
370,
675,
14,
339,
30836,
12,
339,
520,
5247,
5026,
1069,
63,
2143,
63,
633,
64,
365,
367,
10209,
4145,
7447,
1504,
787,
5737,
272,
315,
314,
2851,
334,
10180,
465,
9576,
12,
13053,
12,
15137,
680,
339,
520,
5247,
5026,
1069,
63,
2143,
63,
2030,
64,
365,
367,
10209,
4145,
7447,
1504,
787,
272,
5737,
315,
314,
627,
2030,
10,
402,
314,
1056,
1808,
15193,
503,
20732,
13,
964,
13,
21886,
272,
334,
10180,
465,
367,
8761,
12,
18337,
12,
510,
8078,
680,
339,
520,
5247,
5026,
1069,
64,
365,
367,
10663,
1263,
4928,
402,
1056,
12,
652,
911,
3648,
1536,
314,
272,
5827,
2644,
1475,
436,
675,
1373,
402,
314,
3432,
2877,
3102,
370,
1852,
272,
314,
1056,
14,
339,
6026,
1793,
2633,
26,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
272,
408,
339,
485,
2143,
63,
633,
63,
2474,
275,
663,
2941,
7014,
297,
283,
2970,
297,
283,
5211,
297,
283,
8808,
1105,
272,
485,
2143,
63,
2030,
63,
2474,
275,
663,
2941,
17073,
297,
283,
4030,
297,
283,
4013,
297,
283,
20112,
1105,
339,
347,
636,
826,
721,
277,
12,
2323,
29,
403,
304,
267,
291,
14,
2139,
275,
2323,
503,
1052,
339,
347,
18279,
8,
277,
12,
1083,
12,
1166,
12,
2396,
29,
403,
12,
2323,
29,
403,
12,
355,
3752,
63,
10123,
29,
549,
12,
15193,
63,
9891,
29,
403,
12,
355,
1011,
829,
304,
327,
11836,
267,
746,
3784,
480,
15711,
2178,
1098,
4784,
10385,
1471,
5669,
298,
2490,
298,
1589,
723,
5705,
1124,
10890,
1040,
1083,
2685,
339,
347,
1056,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
2323,
29,
403,
12,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
5827,
2644,
402,
267,
1124,
955,
1040,
4079,
641,
314,
1124,
765,
1040,
1202,
14,
398,
961,
365,
282,
16777,
1083,
626,
5074,
314,
5210,
5982,
402,
8722,
267,
28058,
14,
2779,
883,
506,
1202,
315,
4750,
24325,
12,
1830,
5139,
9445,
314,
945,
267,
370,
5978,
3224,
370,
1655,
2488,
3102,
1380,
5784,
12,
4066,
465,
267,
520,
5247,
1705,
1069,
63,
2143,
63,
633,
3559,
520,
5247,
1705,
1069,
63,
2143,
63,
2030,
3559,
267,
503,
2755,
314,
18966,
2166,
520,
5247,
1705,
10890,
2313,
267,
408,
267,
1083,
275,
1083,
14,
4142,
342,
398,
340,
1083,
315,
291,
423,
2143,
63,
633,
63,
2474,
26,
288,
372,
291,
14,
1069,
63,
2143,
63,
633,
8,
765,
12,
1166,
12,
1504,
29,
955,
12,
4490,
2323,
29,
2139,
12,
4490,
1011,
10890,
63,
829,
9,
267,
587,
26,
288,
372,
291,
14,
1069,
63,
2143,
63,
2030,
8,
765,
12,
1166,
12,
1504,
29,
955,
12,
6163,
2323,
29,
2139,
12,
6163,
1011,
10890,
63,
829,
9,
339,
347,
1056,
63,
2143,
63,
633,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
1124,
955,
1040,
5737,
315,
267,
314,
1166,
14,
961,
365,
2997,
367,
1056,
3102,
2839,
9576,
12,
13053,
12,
15137,
12,
5423,
14,
267,
408,
267,
340,
1504,
26,
288,
1166,
847,
15539,
435,
16511,
8,
955,
9,
267,
372,
291,
14,
10890,
8,
765,
12,
1166,
12,
1011,
10890,
63,
829,
9,
339,
347,
1056,
63,
2143,
63,
2030,
8,
277,
12,
1083,
12,
1166,
12,
1504,
29,
403,
12,
2323,
29,
403,
12,
1169,
3752,
63,
10123,
29,
549,
12,
15193,
63,
9891,
29,
403,
12,
1169,
1011,
10890,
63,
829,
304,
267,
408,
267,
4155,
282,
1056,
1808,
520,
5247,
1705,
10890,
64,
543,
314,
1124,
955,
1040,
5737,
315,
267,
314,
2396,
14,
961,
365,
2997,
367,
1056,
3102,
2839,
8761,
12,
18337,
12,
510,
8078,
12,
5423,
14,
398,
3979,
1124,
2143,
63,
10123,
29,
549,
1040,
334,
885,
395,
2066,
267,
520,
5247,
1705,
4078,
19,
14,
493,
1932,
14,
2143,
63,
10123,
63,
30942,
64,
365,
1202,
370,
3752,
314,
267,
4886,
543,
314,
5827,
1564,
730,
14,
6630,
267,
520,
5247,
1705,
4078,
14,
10738,
64,
365,
1202,
543,
314,
267,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
7,
1564,
730,
14,
398,
6879,
2064,
2644,
1471,
506,
1202,
1380,
25386,
1584,
12,
436,
652,
1159,
4499,
6665,
267,
5048,
370,
675,
652,
315,
1163,
5431,
4634,
14,
9738,
12,
652,
1443,
2059,
1056,
18057,
12,
267,
4066,
465,
543,
11715,
14,
398,
32090,
376,
2716,
1124,
955,
1040,
2725,
402,
790,
15,
585,
3326,
2401,
267,
790,
15,
493,
2960,
14,
437,
570,
2960,
365,
282,
334,
1501,
12,
666,
12,
14735,
730,
9,
2008,
2382,
267,
314,
14735,
730,
365,
2716,
14,
2104,
2893,
26,
3800,
953,
1504,
275,
469,
355,
283,
1421,
356,
283,
1700,
297,
355,
283,
3183,
493,
356,
661,
1421,
493,
14,
2424,
297,
283,
4407,
402,
3925,
493,
659,
355,
283,
264,
7411,
441,
356,
661,
1700,
493,
14,
2424,
297,
1551,
360,
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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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
apache/airflow
|
tests/models/test_xcom_arg.py
|
9
|
5985
|
# 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.
from datetime import datetime, timedelta
import pytest
from airflow import DAG
from airflow.models.xcom_arg import XComArg
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator
from tests.test_utils.config import conf_vars
DEFAULT_ARGS = {
"owner": "test",
"depends_on_past": True,
"start_date": datetime.today(),
"retries": 1,
"retry_delay": timedelta(minutes=1),
}
VALUE = 42
def assert_is_value(num: int):
if num != VALUE:
raise Exception("The test has failed")
def build_python_op():
def f(task_id):
return f"OP:{task_id}"
with DAG(dag_id="test_xcom_dag", default_args=DEFAULT_ARGS):
operator = PythonOperator(
python_callable=f,
task_id="test_xcom_op",
do_xcom_push=True,
)
return operator
class TestXComArgBuild:
def test_xcom_ctor(self):
python_op = build_python_op()
actual = XComArg(python_op, "test_key")
assert actual
assert actual.operator == python_op
assert actual.key == "test_key"
# Asserting the overridden __eq__ method
assert actual == XComArg(python_op, "test_key")
expected_str = (
"{{ task_instance.xcom_pull(task_ids='test_xcom_op', "
"dag_id='test_xcom_dag', key='test_key') }}"
)
assert str(actual) == expected_str
assert (
f"echo {actual}" == "echo {{ task_instance.xcom_pull(task_ids='test_xcom_op', "
"dag_id='test_xcom_dag', key='test_key') }}"
)
def test_xcom_key_is_empty_str(self):
python_op = build_python_op()
actual = XComArg(python_op, key="")
assert actual.key == ""
assert (
str(actual) == "{{ task_instance.xcom_pull(task_ids='test_xcom_op', "
"dag_id='test_xcom_dag', key='') }}"
)
def test_set_downstream(self):
with DAG("test_set_downstream", default_args=DEFAULT_ARGS):
op_a = BashOperator(task_id="a", bash_command="echo a")
op_b = BashOperator(task_id="b", bash_command="echo b")
bash_op1 = BashOperator(task_id="c", bash_command="echo c")
bash_op2 = BashOperator(task_id="d", bash_command="echo c")
xcom_args_a = XComArg(op_a)
xcom_args_b = XComArg(op_b)
bash_op1 >> xcom_args_a >> xcom_args_b >> bash_op2
assert op_a in bash_op1.downstream_list
assert op_b in op_a.downstream_list
assert bash_op2 in op_b.downstream_list
def test_set_upstream(self):
with DAG("test_set_upstream", default_args=DEFAULT_ARGS):
op_a = BashOperator(task_id="a", bash_command="echo a")
op_b = BashOperator(task_id="b", bash_command="echo b")
bash_op1 = BashOperator(task_id="c", bash_command="echo c")
bash_op2 = BashOperator(task_id="d", bash_command="echo c")
xcom_args_a = XComArg(op_a)
xcom_args_b = XComArg(op_b)
bash_op1 << xcom_args_a << xcom_args_b << bash_op2
assert op_a in bash_op1.upstream_list
assert op_b in op_a.upstream_list
assert bash_op2 in op_b.upstream_list
def test_xcom_arg_property_of_base_operator(self):
with DAG("test_xcom_arg_property_of_base_operator", default_args=DEFAULT_ARGS):
op_a = BashOperator(task_id="a", bash_command="echo a")
assert op_a.output == XComArg(op_a)
def test_xcom_key_getitem(self):
python_op = build_python_op()
actual = XComArg(python_op, key="another_key")
assert actual.key == "another_key"
actual_new_key = actual["another_key_2"]
assert actual_new_key.key == "another_key_2"
@pytest.mark.system("core")
class TestXComArgRuntime:
@conf_vars({("core", "executor"): "DebugExecutor"})
def test_xcom_pass_to_op(self):
with DAG(dag_id="test_xcom_pass_to_op", default_args=DEFAULT_ARGS) as dag:
operator = PythonOperator(
python_callable=lambda: VALUE,
task_id="return_value_1",
do_xcom_push=True,
)
xarg = XComArg(operator)
operator2 = PythonOperator(
python_callable=assert_is_value,
op_args=[xarg],
task_id="assert_is_value_1",
)
operator >> operator2
dag.run()
@conf_vars({("core", "executor"): "DebugExecutor"})
def test_xcom_push_and_pass(self):
def push_xcom_value(key, value, **context):
ti = context["task_instance"]
ti.xcom_push(key, value)
with DAG(dag_id="test_xcom_push_and_pass", default_args=DEFAULT_ARGS) as dag:
op1 = PythonOperator(
python_callable=push_xcom_value,
task_id="push_xcom_value",
op_args=["my_key", VALUE],
)
xarg = XComArg(op1, key="my_key")
op2 = PythonOperator(
python_callable=assert_is_value,
task_id="assert_is_value_1",
op_args=[xarg],
)
op1 >> op2
dag.run()
|
apache-2.0
|
[
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,
504,
2197,
492,
2197,
12,
6871,
199,
199,
646,
4613,
199,
199,
504,
16321,
492,
19666,
199,
504,
16321,
14,
992,
14,
88,
957,
63,
1273,
492,
1323,
4373,
6373,
199,
504,
16321,
14,
12688,
14,
16408,
492,
699,
1119,
7961,
199,
504,
16321,
14,
12688,
14,
1548,
492,
2018,
7961,
199,
504,
2295,
14,
396,
63,
1208,
14,
888,
492,
3743,
63,
2936,
199,
199,
3472,
63,
13990,
275,
469,
272,
298,
4597,
582,
298,
396,
401,
272,
298,
8912,
63,
265,
63,
18597,
582,
715,
12,
272,
298,
928,
63,
602,
582,
2197,
14,
8136,
1062,
272,
298,
10937,
582,
413,
12,
272,
298,
7154,
63,
5814,
582,
6871,
8,
10430,
29,
17,
395,
199,
93,
199,
199,
7041,
275,
5685,
421,
199,
318,
702,
63,
374,
63,
585,
8,
1507,
26,
1109,
304,
272,
340,
1967,
1137,
21170,
26,
267,
746,
2186,
480,
1918,
511,
965,
3405,
531,
421,
199,
318,
1900,
63,
1548,
63,
411,
837,
272,
347,
289,
8,
1765,
63,
344,
304,
267,
372,
289,
2,
1938,
14534,
1765,
63,
344,
7063,
339,
543,
19666,
8,
7406,
63,
344,
628,
396,
63,
88,
957,
63,
7406,
401,
849,
63,
589,
29,
3472,
63,
13990,
304,
267,
4182,
275,
2018,
7961,
8,
288,
2366,
63,
8296,
29,
70,
12,
288,
2120,
63,
344,
628,
396,
63,
88,
957,
63,
411,
401,
288,
886,
63,
88,
957,
63,
5335,
29,
549,
12,
267,
776,
267,
372,
4182,
421,
199,
533,
1379,
56,
4373,
6373,
3425,
26,
272,
347,
511,
63,
88,
957,
63,
630,
8,
277,
304,
267,
2366,
63,
411,
275,
1900,
63,
1548,
63,
411,
342,
267,
3503,
275,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
298,
396,
63,
498,
531,
267,
702,
3503,
267,
702,
3503,
14,
3856,
508,
2366,
63,
411,
267,
702,
3503,
14,
498,
508,
298,
396,
63,
498,
2,
267,
327,
10716,
316,
314,
10087,
636,
4077,
363,
1083,
267,
702,
3503,
508,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
298,
396,
63,
498,
531,
267,
1420,
63,
495,
275,
334,
288,
7370,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
534,
396,
63,
498,
358,
7820,
267,
776,
267,
702,
620,
8,
6514,
9,
508,
1420,
63,
495,
267,
702,
334,
288,
289,
2,
7878,
469,
6514,
7063,
508,
298,
7878,
8448,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
534,
396,
63,
498,
358,
7820,
267,
776,
339,
347,
511,
63,
88,
957,
63,
498,
63,
374,
63,
1667,
63,
495,
8,
277,
304,
267,
2366,
63,
411,
275,
1900,
63,
1548,
63,
411,
342,
267,
3503,
275,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
790,
18413,
267,
702,
3503,
14,
498,
508,
3087,
267,
702,
334,
288,
620,
8,
6514,
9,
508,
7370,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
13275,
7820,
267,
776,
339,
347,
511,
63,
409,
63,
2110,
1745,
8,
277,
304,
267,
543,
19666,
480,
396,
63,
409,
63,
2110,
1745,
401,
849,
63,
589,
29,
3472,
63,
13990,
304,
288,
1687,
63,
65,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
65,
401,
20387,
63,
1531,
628,
7878,
282,
531,
288,
1687,
63,
66,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
66,
401,
20387,
63,
1531,
628,
7878,
330,
531,
288,
20387,
63,
411,
17,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
67,
401,
20387,
63,
1531,
628,
7878,
286,
531,
288,
20387,
63,
411,
18,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
68,
401,
20387,
63,
1531,
628,
7878,
286,
531,
288,
671,
957,
63,
589,
63,
65,
275,
1323,
4373,
6373,
8,
411,
63,
65,
9,
288,
671,
957,
63,
589,
63,
66,
275,
1323,
4373,
6373,
8,
411,
63,
66,
9,
953,
20387,
63,
411,
17,
4331,
671,
957,
63,
589,
63,
65,
4331,
671,
957,
63,
589,
63,
66,
4331,
20387,
63,
411,
18,
398,
702,
1687,
63,
65,
315,
20387,
63,
411,
17,
14,
2110,
1745,
63,
513,
267,
702,
1687,
63,
66,
315,
1687,
63,
65,
14,
2110,
1745,
63,
513,
267,
702,
20387,
63,
411,
18,
315,
1687,
63,
66,
14,
2110,
1745,
63,
513,
339,
347,
511,
63,
409,
63,
20099,
8,
277,
304,
267,
543,
19666,
480,
396,
63,
409,
63,
20099,
401,
849,
63,
589,
29,
3472,
63,
13990,
304,
288,
1687,
63,
65,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
65,
401,
20387,
63,
1531,
628,
7878,
282,
531,
288,
1687,
63,
66,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
66,
401,
20387,
63,
1531,
628,
7878
] |
[
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,
504,
2197,
492,
2197,
12,
6871,
199,
199,
646,
4613,
199,
199,
504,
16321,
492,
19666,
199,
504,
16321,
14,
992,
14,
88,
957,
63,
1273,
492,
1323,
4373,
6373,
199,
504,
16321,
14,
12688,
14,
16408,
492,
699,
1119,
7961,
199,
504,
16321,
14,
12688,
14,
1548,
492,
2018,
7961,
199,
504,
2295,
14,
396,
63,
1208,
14,
888,
492,
3743,
63,
2936,
199,
199,
3472,
63,
13990,
275,
469,
272,
298,
4597,
582,
298,
396,
401,
272,
298,
8912,
63,
265,
63,
18597,
582,
715,
12,
272,
298,
928,
63,
602,
582,
2197,
14,
8136,
1062,
272,
298,
10937,
582,
413,
12,
272,
298,
7154,
63,
5814,
582,
6871,
8,
10430,
29,
17,
395,
199,
93,
199,
199,
7041,
275,
5685,
421,
199,
318,
702,
63,
374,
63,
585,
8,
1507,
26,
1109,
304,
272,
340,
1967,
1137,
21170,
26,
267,
746,
2186,
480,
1918,
511,
965,
3405,
531,
421,
199,
318,
1900,
63,
1548,
63,
411,
837,
272,
347,
289,
8,
1765,
63,
344,
304,
267,
372,
289,
2,
1938,
14534,
1765,
63,
344,
7063,
339,
543,
19666,
8,
7406,
63,
344,
628,
396,
63,
88,
957,
63,
7406,
401,
849,
63,
589,
29,
3472,
63,
13990,
304,
267,
4182,
275,
2018,
7961,
8,
288,
2366,
63,
8296,
29,
70,
12,
288,
2120,
63,
344,
628,
396,
63,
88,
957,
63,
411,
401,
288,
886,
63,
88,
957,
63,
5335,
29,
549,
12,
267,
776,
267,
372,
4182,
421,
199,
533,
1379,
56,
4373,
6373,
3425,
26,
272,
347,
511,
63,
88,
957,
63,
630,
8,
277,
304,
267,
2366,
63,
411,
275,
1900,
63,
1548,
63,
411,
342,
267,
3503,
275,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
298,
396,
63,
498,
531,
267,
702,
3503,
267,
702,
3503,
14,
3856,
508,
2366,
63,
411,
267,
702,
3503,
14,
498,
508,
298,
396,
63,
498,
2,
267,
327,
10716,
316,
314,
10087,
636,
4077,
363,
1083,
267,
702,
3503,
508,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
298,
396,
63,
498,
531,
267,
1420,
63,
495,
275,
334,
288,
7370,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
534,
396,
63,
498,
358,
7820,
267,
776,
267,
702,
620,
8,
6514,
9,
508,
1420,
63,
495,
267,
702,
334,
288,
289,
2,
7878,
469,
6514,
7063,
508,
298,
7878,
8448,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
534,
396,
63,
498,
358,
7820,
267,
776,
339,
347,
511,
63,
88,
957,
63,
498,
63,
374,
63,
1667,
63,
495,
8,
277,
304,
267,
2366,
63,
411,
275,
1900,
63,
1548,
63,
411,
342,
267,
3503,
275,
1323,
4373,
6373,
8,
1548,
63,
411,
12,
790,
18413,
267,
702,
3503,
14,
498,
508,
3087,
267,
702,
334,
288,
620,
8,
6514,
9,
508,
7370,
2120,
63,
842,
14,
88,
957,
63,
9302,
8,
1765,
63,
1580,
534,
396,
63,
88,
957,
63,
411,
297,
298,
288,
298,
7406,
63,
344,
534,
396,
63,
88,
957,
63,
7406,
297,
790,
13275,
7820,
267,
776,
339,
347,
511,
63,
409,
63,
2110,
1745,
8,
277,
304,
267,
543,
19666,
480,
396,
63,
409,
63,
2110,
1745,
401,
849,
63,
589,
29,
3472,
63,
13990,
304,
288,
1687,
63,
65,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
65,
401,
20387,
63,
1531,
628,
7878,
282,
531,
288,
1687,
63,
66,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
66,
401,
20387,
63,
1531,
628,
7878,
330,
531,
288,
20387,
63,
411,
17,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
67,
401,
20387,
63,
1531,
628,
7878,
286,
531,
288,
20387,
63,
411,
18,
275,
699,
1119,
7961,
8,
1765,
63,
344,
628,
68,
401,
20387,
63,
1531,
628,
7878,
286,
531,
288,
671,
957,
63,
589,
63,
65,
275,
1323,
4373,
6373,
8,
411,
63,
65,
9,
288,
671,
957,
63,
589,
63,
66,
275,
1323,
4373,
6373,
8,
411,
63,
66,
9,
953,
20387,
63,
411,
17,
4331,
671,
957,
63,
589,
63,
65,
4331,
671,
957,
63,
589,
63,
66,
4331,
20387,
63,
411,
18,
398,
702,
1687,
63,
65,
315,
20387,
63,
411,
17,
14,
2110,
1745,
63,
513,
267,
702,
1687,
63,
66,
315,
1687,
63,
65,
14,
2110,
1745,
63,
513,
267,
702,
20387,
63,
411,
18,
315,
1687,
63,
66,
14,
2110,
1745,
63,
513,
339,
347,
511,
63,
409,
63,
20099,
8,
277,
304,
267,
543,
19666,
480,
396,
63,
409,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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
] |
srickardti/openthread
|
tools/harness-automation/cases_R140/leader_5_6_4.py
|
18
|
1877
|
#!/usr/bin/env python
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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.
# 3. Neither the name of the copyright holder 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 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.
#
import unittest
from autothreadharness.harness_case import HarnessCase
class Leader_5_6_4(HarnessCase):
role = HarnessCase.ROLE_LEADER
case = '5 6 4'
golden_devices_required = 3
def on_dialog(self, dialog, title):
pass
if __name__ == '__main__':
unittest.main()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
7800,
12,
710,
3232,
4436,
6642,
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,
7647,
26,
199,
3,
413,
14,
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,
499,
14,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
259,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
650,
14,
11443,
314,
536,
402,
314,
4248,
16712,
6590,
314,
199,
3,
259,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
199,
3,
259,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
4983,
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,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
646,
2882,
199,
199,
504,
2599,
2671,
23569,
14,
23569,
63,
2546,
492,
25378,
4171,
1538,
421,
199,
533,
7005,
669,
63,
21,
63,
22,
63,
20,
8,
18248,
4171,
1538,
304,
272,
4719,
275,
25378,
4171,
1538,
14,
15468,
63,
906,
21372,
272,
1930,
275,
283,
21,
1227,
841,
7,
272,
17631,
63,
6410,
63,
2427,
275,
650,
339,
347,
641,
63,
7196,
8,
277,
12,
9592,
12,
2538,
304,
267,
986,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
334,
67,
9,
7800,
12,
710,
3232,
4436,
6642,
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,
7647,
26,
199,
3,
413,
14,
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,
499,
14,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
259,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
650,
14,
11443,
314,
536,
402,
314,
4248,
16712,
6590,
314,
199,
3,
259,
1561,
402,
2399,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
199,
3,
259,
7131,
687,
642,
2032,
1928,
2488,
6791,
5313,
4983,
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,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
646,
2882,
199,
199,
504,
2599,
2671,
23569,
14,
23569,
63,
2546,
492,
25378,
4171,
1538,
421,
199,
533,
7005,
669,
63,
21,
63,
22,
63,
20,
8,
18248,
4171,
1538,
304,
272,
4719,
275,
25378,
4171,
1538,
14,
15468,
63,
906,
21372,
272,
1930,
275,
283,
21,
1227,
841,
7,
272,
17631,
63,
6410,
63,
2427,
275,
650,
339,
347,
641,
63,
7196,
8,
277,
12,
9592,
12,
2538,
304,
267,
986,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
amirgeva/coide
|
mainwindow.py
|
1
|
54237
|
from PyQt4 import QtCore
from PyQt4 import QtGui
import os
import re
import stat
import qutepart
from workspace import WorkSpace
import output
from consts import FileRole
from gdbwrapper import GDBWrapper
from watchestree import WatchesTree
from breakpoints import BreakpointsDB, BreakpointDialog
from properties import Properties
from functools import partial
from globals import is_src_ext
import utils
import genmake
import uis
import plugins
import dwarf
class MainWindow(QtGui.QMainWindow):
""" Main IDE Window
Contains the main code view, along with docking panes for: source files,
watches, call stack, and output
"""
LIBRARY_SCAN = "Scanning Libraries"
def __init__(self,rootDir,parent=None):
""" Initialize. rootDir indicates where data files are located """
super(MainWindow,self).__init__(parent)
s=QtCore.QSettings()
self.recent_ws=[d for d in s.value('recent_ws','').toString().split(':') if d]
self.symbolScan=s.value('symbol_scan',True).toBool()
self.setMinimumSize(QtCore.QSize(1024,768))
self.currentLine=0
self.currentFile=''
self.rootDir=rootDir
utils.setIconsDir(os.path.join(rootDir,"icons"))
self.debugger=None
self.breakpoints=BreakpointsDB()
self.findDetails=None
self.scm_mods=[]
self.setWindowIcon(utils.loadIcon('coide'))
self.setWindowTitle("Coide")
self.generateQueue=set()
self.editors={}
self.file_times={}
self.central=QtGui.QTabWidget()
self.setCentralWidget(self.central)
self.central.setTabsClosable(True)
self.central.tabCloseRequested.connect(self.closeTab)
self.central.currentChanged.connect(self.tabChanged)
self.tabOrder=[]
self.plugins=plugins.PluginsManager()
self.setupMenu()
self.setupContextMenuItems()
self.setupToolbar(rootDir)
self.showWorkspacePane()
self.showOutputPane()
self.showWatchesPane()
self.showLocalsPane()
self.showCallStackPane()
self.buildProcess=None
self.timerCall=None
self.config=s.value("config").toString()
if self.config=='':
self.config="Debug"
self.configCombo.setCurrentIndex(0 if self.config=='Debug' else 1)
self.workspaceTree.setConfig(self.config)
self.setAllFonts()
self.loadWindowSettings()
# Debugger timer that is supposed to periodically check
# if the program has stopped at a breakpoint
self.timer=QtCore.QTimer(self)
self.timer.timeout.connect(self.update)
self.runningWidget=None
self.asyncPollTimer=QtCore.QTimer(self)
self.asyncPollTimer.timeout.connect(self.pollAsync)
self.generateTimer=QtCore.QTimer()
self.generateTimer.timeout.connect(self.timer1000)
self.generateTimer.start(1000)
self.lowFreqTimer=QtCore.QTimer()
self.lowFreqTimer.timeout.connect(self.timer5000)
self.lowFreqTimer.start(5000)
#self.showStatus("Generating All Makefiles")
#self.timerCall=self.generateAllInThread
self.timerCall=None
self.paneWatches.hide()
self.paneLocals.hide()
self.paneStack.hide()
#self.sc=QtGui.QShortcut("Ctrl+F8",self)
#self.sc.activated.connect(self.prtsc)
def closeEvent(self, event):
""" Called before the application window closes
Informs sub-windows to prepare and saves window settings
to allow future sessions to look the same
"""
self.workspaceTree.onClose()
self.workspaceTree.saveTabs(self.central)
while self.central.count()>0:
if not self.closeFile():
event.ignore()
return
self.timer.stop()
self.generateTimer.stop()
if self.debugger:
self.debugger.closingApp()
settings = QtCore.QSettings()
settings.setValue("geometry", self.saveGeometry())
settings.setValue("windowState", self.saveState())
settings.sync()
self.removeTempScripts()
super(MainWindow,self).closeEvent(event)
def saveDebugWindowState(self):
"""
Save the state of the tool docks, like watches
and call stack
"""
settings = QtCore.QSettings()
settings.setValue("debugWindowState", self.saveState())
settings.sync()
def loadDebugWindowState(self):
"""
Restore previous debug windows layout
"""
settings = QtCore.QSettings()
self.restoreState(settings.value("debugWindowState").toByteArray())
def loadWindowSettings(self):
"""
Restore the window size settings from the previous session
"""
settings = QtCore.QSettings()
self.restoreGeometry(settings.value("geometry").toByteArray())
self.restoreState(settings.value("windowState").toByteArray())
self.loadTabs()
def loadTabs(self):
self.closeAllTabs()
ws=self.workspaceTree.settings()
opentabs=ws.value('opentabs','').toString()
opentabs=opentabs.split(',')
for path in opentabs:
self.openSourceFile(path)
curtab=ws.value('curtab','').toString()
if curtab:
self.setActiveSourceFile(curtab)
def setupMenu(self):
""" Creates the application main menu
The action handlers are also mapped from the toolbar icons
"""
bar=self.menuBar()
m=bar.addMenu('&File')
m.addAction(QtGui.QAction('&Initialize Workspace',self,triggered=self.initWorkspace))
m.addAction(QtGui.QAction('Open &Workspace',self,triggered=self.openWorkspace))
self.recents_menu=m.addMenu('&Recent Workspaces')
m.addAction(QtGui.QAction('&Save',self,shortcut='Ctrl+S',triggered=self.saveFile))
m.addAction(QtGui.QAction('Save &As',self,triggered=self.saveAsFile))
m.addAction(QtGui.QAction('&Close File',self,shortcut='Ctrl+F4',triggered=self.closeFile))
m.addAction(QtGui.QAction('E&xit',self,shortcut='Ctrl+Q',triggered=self.exitApp))
m=bar.addMenu('&Edit')
m.addAction(QtGui.QAction('&Copy',self,shortcut='Ctrl+C',triggered=self.onCopy))
m.addAction(QtGui.QAction('C&ut',self,shortcut='Ctrl+X',triggered=self.onCut))
m.addAction(QtGui.QAction('&Paste',self,shortcut='Ctrl+V',triggered=self.onPaste))
m.addSeparator()
m.addAction(QtGui.QAction('&Find/Replace',self,shortcut='Ctrl+F',triggered=self.onFindReplace))
m.addAction(QtGui.QAction('Find/Replace &Next',self,shortcut='F3',triggered=self.onFindNext))
m=bar.addMenu('&View')
panes=m.addMenu('Panes')
panes.addAction(QtGui.QAction('&Workspace',self,triggered=self.onViewPaneWorkspace))
panes.addAction(QtGui.QAction('&Output',self,triggered=self.onViewPaneOutput))
m.addAction(QtGui.QAction('&Next Tab',self,shortcut='Ctrl+F6',triggered=self.onViewNextTab))
m=bar.addMenu('&Build')
m.addAction(QtGui.QAction('&Build',self,shortcut='F7',triggered=self.build))
m.addAction(QtGui.QAction('&Clean',self,triggered=self.clean))
m.addAction(QtGui.QAction('&Rebuild',self,shortcut='Shift+F7',triggered=self.rebuild))
m.addAction(QtGui.QAction('&Settings',self,shortcut='Ctrl+F7',triggered=self.buildSettings))
m.addAction(QtGui.QAction('&Next Error',self,shortcut='F4',triggered=self.nextError))
m=bar.addMenu('&Debug')
m.addAction(QtGui.QAction('&Run',self,shortcut='Ctrl+F5',triggered=self.runProject))
m.addAction(QtGui.QAction('&Start/Continue Debugger',self,shortcut='F5',triggered=self.startDebug))
ma=m.addMenu('Actions')
ma.addAction(QtGui.QAction('&Step',self,shortcut='F11',triggered=self.actStep))
ma.addAction(QtGui.QAction('&Next',self,shortcut='F10',triggered=self.actNext))
ma.addAction(QtGui.QAction('Step &Out',self,shortcut='Shift+F11',triggered=self.actOut))
ma.addAction(QtGui.QAction('&Break',self,shortcut='Ctrl+C',triggered=self.actBreak))
ma.addAction(QtGui.QAction('Sto&p',self,shortcut='Shift+F5',triggered=self.actStop))
ma=m.addMenu('&Breakpoints')
ma.addAction(QtGui.QAction('&Clear',self,triggered=self.clearBreakpoints))
m=bar.addMenu('&Settings')
m.addAction(QtGui.QAction('&General',self,triggered=self.settingsGeneral))
m.addAction(QtGui.QAction('&Fonts',self,triggered=self.settingsFonts))
m.addAction(QtGui.QAction('&Editor',self,triggered=self.settingsEditor))
m.addAction(QtGui.QAction('&Templates',self,triggered=self.settingsTemplates))
m.addAction(QtGui.QAction('&Plugins',self,triggered=self.settingsPlugins))
m=bar.addMenu('&Tools')
pm=m.addMenu('&Plugins')
self.plugins.addToMenu(pm)
def onViewPaneWorkspace(self):
self.paneWorkspace.show()
def onViewPaneOutput(self):
self.paneOutput.show()
def onViewNextTab(self):
count=self.central.count()
if count>0:
if len(self.tabOrder)!=count:
self.tabOrder=range(0,self.central.count())
if self.central.currentIndex() == self.tabOrder[0]:
self.tabOrder=self.tabOrder[1:]+self.tabOrder[:1]
self.central.setCurrentIndex(self.tabOrder[0])
def setupContextMenuItems(self):
self.contextMenuItems={
'all':[
QtGui.QAction('Toggle Breakpoint',self,triggered=self.contextToggleBreakpoint)
],
'files':[
QtGui.QAction('Open Header',self,triggered=self.contextOpenHeader)
],
'breakpoints':[
QtGui.QAction('Edit Breakpoint',self,triggered=self.contextEditBreakpoint),
QtGui.QAction('Dis/Enable Breakpoint',self,triggered=self.contextAbleBreakpoint)
],
'symbols':[
QtGui.QAction('Goto Definition',self,triggered=self.contextGotoDefinition)
]
}
def insertContextMenuItems(self,editor,menu):
first=None
acts=menu.actions()
if len(acts)>0:
first=acts[0]
actions=list(self.contextMenuItems.get('all'))
path=editor.path
line=editor.contextMenuLine
word=editor.contextMenuWord
self.context=(path,line,word)
if len(word)>0:
actions.extend(self.contextMenuItems.get('symbols'))
if self.breakpoints.hasBreakpoint(path,line):
actions.extend(self.contextMenuItems.get('breakpoints'))
if self.workspaceTree.exists(editor.contextFilename):
actions.extend(self.contextMenuItems.get('files'))
menu.insertActions(first,actions)
menu.insertSeparator(first)
def contextGotoDefinition(self):
src=os.path.join(self.workspaceTree.root,'src')
intr=os.path.join(self.workspaceTree.root,'.intr')
srcpath=self.context[0]
objpath=''
if srcpath.startswith(src) and is_src_ext(srcpath):
rel=srcpath[len(src):]
rel=rel[1:-4]+'.o'
objpath=os.path.join(intr,rel)
(dir,name)=os.path.split(objpath)
objpath=os.path.join(dir,'Debug',name)
if srcpath.startswith(self.workspaceTree.root) and srcpath.endswith('.h'):
dir=self.workspaceTree.mainPath()
mkPath=os.path.join(dir,'Makefile')
objpath=utils.objForHeader(mkPath,srcpath)
if len(objpath)>0:
try:
s=dwarf.DwarfSymbols(objpath)
(path,line)=s.find(self.context[2])
if len(path)>0:
self.goToSource(path,line,1)
except IOError:
utils.message('Project must first be compiled in Debug')
def contextToggleBreakpoint(self):
e=self.central.currentWidget()
self.breakpoints.toggleBreakpoint(e)
e.update()
def contextEditBreakpoint(self):
e=self.central.currentWidget()
path=e.path
line=e.contextMenuLine
bp=self.breakpoints.getBreakpoint(path,line)
if bp:
d=BreakpointDialog()
d.condition.setText(bp.condition())
utils.setCheckbox(d.enabled,bp.isEnabled())
if d.exec_():
bp.setCondition(d.condition.text())
bp.able(utils.getCheckbox(d.enabled))
self.breakpoints.update()
e.update()
def contextAbleBreakpoint(self):
e=self.central.currentWidget()
path=e.path
line=e.contextMenuLine
bp=self.breakpoints.getBreakpoint(path,line)
if bp:
if bp.isEnabled():
bp.disable()
else:
bp.enable()
self.breakpoints.update()
e.update()
def contextOpenHeader(self):
e=self.central.currentWidget()
filename=self.workspaceTree.exists(e.contextFilename)
if filename:
self.workspaceTree.openFile(filename)
def markToggleBreakpoint(self,line):
e=self.central.currentWidget()
#path=e.path
self.breakpoints.toggleBreakpoint(e)
e.update()
def createPluginCuror(self):
from pcursor import PluginCursor
e=self.central.currentWidget()
if e:
return PluginCursor(e.textCursor())
return None
def setupToolbar(self,rootDir):
""" Creates the application main toolbar """
tb=self.addToolBar('Actions')
tb.setObjectName("Toolbar")
tb.addAction(utils.loadIcon('gear'),'Generate Makefiles').triggered.connect(self.generate)
self.configCombo=self.createConfigCombo(tb)
tb.addWidget(self.configCombo)
tb.addAction(utils.loadIcon('step.png'),'Step').triggered.connect(self.actStep)
tb.addAction(utils.loadIcon('next.png'),'Next').triggered.connect(self.actNext)
tb.addAction(utils.loadIcon('out.png'),'Out').triggered.connect(self.actOut)
tb.addAction(utils.loadIcon('cont.png'),'Continue').triggered.connect(self.actCont)
tb.addAction(utils.loadIcon('break.png'),'Break').triggered.connect(self.actBreak)
tb.addAction(utils.loadIcon('stop.png'),'Stop').triggered.connect(self.actStop)
self.createTemplatesCombo(tb)
tb.addWidget(self.tmplCombo)
def exitApp(self):
self.close()
def nextError(self):
e=self.outputEdit.getNextError()
if e:
self.showStatus(e[3])
self.goToSource(e[0],e[1],e[2],'#ff8080')
self.outputEdit.highlightLine(e[4])
def onCopy(self):
(e,p)=self.currentEditor()
if e:
e.copy()
def onCut(self):
(e,p)=self.currentEditor()
if e:
e.cut()
def onPaste(self):
(e,p)=self.currentEditor()
if e:
e.paste()
def onFindReplace(self):
(e,p)=self.currentEditor()
if e:
from finddlg import FindDialog
d=FindDialog(self)
c=e.textCursor()
if c.hasSelection:
d.setFindText(c.selectedText())
if d.exec_():
self.findDetails=d.details
self.onFindNext()
def onFindNext(self):
(e,p)=self.currentEditor()
if e and self.findDetails:
flags=QtGui.QTextDocument.FindFlags()
if not self.findDetails.get('find_case'):
flags = flags | QtGui.QTextDocument.FindCaseSensitively
if self.findDetails.get('find_words'):
flags = flags | QtGui.QTextDocument.FindWholeWords
if self.findDetails.get('find_back'):
flags = flags | QtGui.QTextDocument.FindBackward
text=self.findDetails.get('find_text')
replaceText=self.findDetails.get('find_replace_text')
replace=self.findDetails.get('find_replace')
all=self.findDetails.get('find_all')
if all and replace:
while e.find(text,flags):
e.textCursor().insertText(replaceText)
elif e.find(text,flags):
if replace:
e.textCursor().insertText(replaceText)
def settingsTemplates(self):
""" Show the code templates editing dialog """
from settings import TemplatesDialog
d=TemplatesDialog()
if d.exec_():
d.save()
self.updateTemplates()
def settingsPlugins(self):
""" Show the python plugins settings dialog """
from plugins import PluginsDialog
d=PluginsDialog()
if d.exec_():
d.save()
def settingsGeneral(self):
""" Show the general settings """
from settings import GeneralSettingsDialog
d=GeneralSettingsDialog()
if d.exec_():
d.save()
self.updateGeneralSettings()
def settingsEditor(self):
""" Show the editor settings """
from settings import EditorSettingsDialog
d=EditorSettingsDialog()
if d.exec_():
d.save()
self.updateEditorsSettings()
def settingsFonts(self):
""" Edit the font settings for the code window and various panes """
from settings import FontSettingsDialog
d=FontSettingsDialog()
if d.exec_():
self.setAllFonts()
def loadFont(self,name,target):
""" Load previously saved font settings """
settings=QtCore.QSettings()
if settings.contains(name):
fb=settings.value(name).toByteArray()
buf=QtCore.QBuffer(fb)
buf.open(QtCore.QIODevice.ReadOnly)
font=QtGui.QFont()
QtCore.QDataStream(fb) >> font
target.setFont(font)
else:
target.setFont(QtGui.QFont('Monospace',14))
def setAllFonts(self):
""" Apply fonts to the various sub-windows """
for e in self.editors:
self.loadFont('codefont',self.editors.get(e))
#self.loadFont('watchesfont',self.watchesTree)
#self.loadFont('watchesfont',self.stackList)
self.loadFont('watchesfont',self.outputEdit)
self.loadFont('sourcesfont',self.workspaceTree)
def updateGeneralSettings(self):
""" Apply general settings """
s=QtCore.QSettings()
sortFiles=s.value('sortFiles',True).toBool()
self.workspaceTree.setSorting(sortFiles)
def updateEditorsSettings(self):
""" Apply editor settings to all open tabs """
s=QtCore.QSettings()
indent=(s.value('indent',2).toInt())[0]
clang=s.value('clangCompletion',True).toBool()
for e in self.editors:
self.editors.get(e).indentWidth=indent
self.editors.get(e).clangCompletion=clang
def updateTemplates(self):
self.tmplCombo.clear()
self.tmplCombo.addItem("= Templates =")
d=QtCore.QSettings().value('tmplDir','').toString()
if d:
templates=os.listdir(d)
templates=[os.path.splitext(t)[0] for t in templates if t.endswith('.template')]
for t in templates:
self.tmplCombo.addItem(t)
def showStatus(self,status):
self.statusBar().showMessage(status)
def findUndefinedReferences(self,output):
"""
Search the linker output to find undefined reference
errors, and collect the missing symbol names
"""
undefined=set()
base='undefined reference to '
if output:
for line in output:
p=line.find(base)
if p>0:
name=line[(p+len(base)):]
if name.startswith('symbol '):
name=name[8:]
else:
name=name[1:]
p=name.find('(')
if p>0:
name=name[0:p]
else:
name=name[0:len(name)-1]
p=name.find('@')
if p>0:
name=name[0:p]
undefined.add(name)
return undefined
def toggleAdded(self,item):
if item.checkState():
self.added.add(item.text())
else:
self.added.remove(item.text())
def attemptUndefResolution(self,undefs):
if not self.symbolScan:
return
from system import getLibrarySymbols, getWorkspaceSymbols
suggested={}
syms=getLibrarySymbols()
wsSyms=getWorkspaceSymbols()
for sym in undefs:
words=sym.split(':')
words=[w for w in words if w]
words.append(sym)
for word in words:
if word in syms:
s=syms.get(word)
for l in s:
if not l in suggested:
suggested[l]=1
else:
n=suggested.get(l)+1
suggested[l]=n
if word in wsSyms:
s=wsSyms.get(word)
for l in s:
if not l in suggested:
suggested[l]=1
else:
n=suggested.get(l)+1
suggested[l]=n
self.added=set()
if len(suggested)>0:
d=uis.loadDialog('libsuggest')
model = QtGui.QStandardItemModel(d.libsList)
for s in suggested:
item=QtGui.QStandardItem(s)
item.setCheckable(True)
model.appendRow(item)
d.libsList.setModel(model)
model.itemChanged.connect(lambda item : self.toggleAdded(item))
if d.exec_():
self.workspaceTree.addLibrariesToProject(self.added)
def buildSettings(self,path=''):
from buildsettings import BuildSettingsDialog
if not path:
path=self.workspaceTree.mainPath()
if not path:
path=self.workspaceTree.root
d=BuildSettingsDialog(self,path)
d.exec_()
self.generateQueue.add(path)
def checkBuildOutput(self):
if self.buildProcess:
self.processBuildOutput(self.buildProcess.text)
self.buildProcess=None
def pollAsync(self):
rcs=utils.pollAsync()
if len(rcs)>0:
if rcs[0]==0:
utils.appendColorLine(self.outputEdit,"Success...",'#008020')
else:
utils.appendColorLine(self.outputEdit,"= Failed ({}) =".format(rcs[0]),'#ff0000')
self.checkBuildOutput()
self.asyncPollTimer.stop()
self.showStatus("Done")
def execute(self,path,cmd,*args):
if utils.pendingAsync():
self.showStatus('Busy')
return None
self.outputEdit.clearAll()
p=utils.execute(self.outputEdit,path,cmd,*args)
if not self.asyncPollTimer.isActive():
self.asyncPollTimer.start(10)
return p
def buildSpecific(self,path):
self.saveAll()
self.autoGenerate()
if len(path)>0:
self.showStatus("Building "+os.path.basename(path))
s=QtCore.QSettings()
if s.value('parallel_make',False).toBool():
self.buildProcess=self.execute(path,'/usr/bin/make','-j','3',self.config)
else:
self.buildProcess=self.execute(path,'/usr/bin/make',self.config)
def processBuildOutput(self,output):
undefs=self.findUndefinedReferences(output)
if len(undefs)>0:
self.attemptUndefResolution(undefs)
def build(self):
self.buildSpecific(self.workspaceTree.mainPath())
def cleanSpecific(self,path):
if len(path)>0:
self.execute(path,'/usr/bin/make','clean_{}'.format(self.config))
def clean(self):
self.cleanSpecific(self.workspaceTree.mainPath())
def rebuildSpecific(self,path):
if len(path)>0:
cfg=self.config
self.showStatus("Rebuilding "+os.path.basename(path))
self.buildProcess=self.execute(path,'/usr/bin/make','clean_'+cfg,cfg)
def rebuild(self):
self.rebuildSpecific(self.workspaceTree.mainPath())
def autoGenerateRun(self):
for path in self.generateQueue:
genmake.generateDirectory(self.workspaceTree.root,path)
self.generateQueue.clear()
self.showStatus('Ready')
def autoGenerate(self):
if len(self.generateQueue)>0:
self.showStatus('Generating Makefiles')
self.timerCall=self.autoGenerateRun
else:
if genmake.genThreadDone():
self.showStatus("Makefile Generate Done")
def waitForScanner(self):
if self.symbolScan:
import system
import time
while not system.isScannerDone():
time.sleep(1)
def timer1000(self):
e=self.central.currentWidget()
if e:
updates=self.breakpoints.updateLineNumbers(e.path)
for path in updates:
e=self.editors.get(path)
if e:
e.update()
if self.timerCall:
f=self.timerCall
self.timerCall=None
f()
self.autoGenerate()
#if self.statusBar().currentMessage() == MainWindow.LIBRARY_SCAN:
if self.symbolScan:
import system
if system.isScannerDone():
#if system.scanq and not system.scanq.empty():
if self.statusBar().currentMessage() == MainWindow.LIBRARY_SCAN:
self.showStatus('Ready')
system.getLibrarySymbols()
def timer5000(self):
import scm
res=scm.scan(self.workspaceTree.root)
if res:
new_scm_mods=[]
for (name,status) in res:
path=os.path.join(self.workspaceTree.root,name)
if path in self.workspaceTree.fileItems:
item=self.workspaceTree.fileItems.get(path)
if status=='Modified':
item.setForeground(0,QtGui.QBrush(QtGui.QColor(255,0,0)))
elif status=='Staged':
item.setForeground(0,QtGui.QBrush(QtGui.QColor(0,255,0)))
new_scm_mods.append(item)
for item in self.scm_mods:
if not item in new_scm_mods:
item.setForeground(0,QtGui.QBrush(QtGui.QColor(0,0,0)))
self.scm_mods=new_scm_mods
for path in self.editors:
last=self.file_times.get(path)
cur=os.path.getmtime(path)
if cur!=last:
self.file_times[path]=cur
res=QtGui.QMessageBox.question(self,'File changed','Reload {}'.format(path),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
if res==QtGui.QMessageBox.Yes:
text=''.join(open(path,'r').readlines())
self.editors.get(path).text=text
def generateAllInThread(self):
genmake.generateTree(self.workspaceTree.root,False)
def generateAll(self):
genmake.generateTree(self.workspaceTree.root,True)
def generate(self):
mb=QtGui.QMessageBox()
mb.setText("Generate make files")
mb.setInformativeText("Overwrite all make files?")
mb.setStandardButtons(QtGui.QMessageBox.Yes|QtGui.QMessageBox.No)
mb.setDefaultButton(QtGui.QMessageBox.Yes)
rc=mb.exec_()
if rc==QtGui.QMessageBox.Yes:
self.generateAll()
utils.message("Done")
def createHelloWorldProject(self,dir):
try:
os.makedirs(dir)
except OSError:
pass
mainpath=os.path.join(dir,'main.cpp')
f=open(mainpath,"w")
f.write('#include <iostream>\n\n\nint main(int argc, char* argv[])\n')
f.write('{\n std::cout << "Hello World" << std::endl;\n return 0;\n}\n')
f.close()
self.workspaceTree.update()
genmake.generateDirectory(self.workspaceTree.root,dir)
self.workspaceTree.setMainPath(dir)
def initWorkspace(self):
d=QtGui.QFileDialog()
d.setFileMode(QtGui.QFileDialog.Directory)
d.setOption(QtGui.QFileDialog.ShowDirsOnly)
if d.exec_():
ws=(d.selectedFiles())[0]
os.makedirs(os.path.join(ws,'include'))
dir=os.path.join(ws,'src','hello')
self.workspaceTree.setWorkspacePath(ws)
self.createHelloWorldProject(dir)
self.workspaceTree.saveSettings()
self.generateAll()
def updateRecents(self):
ws=self.workspaceTree.root
if ws in self.recent_ws:
del self.recent_ws[self.recent_ws.index(ws)]
self.recent_ws.insert(0,ws)
while len(self.recent_ws)>4:
del self.recent_ws[-1]
s=QtCore.QSettings()
s.setValue('recent_ws',':'.join(self.recent_ws))
s.sync()
self.recents_menu.clear()
handlers=[partial(self.openRecent,w) for w in self.recent_ws]
for ws,h in zip(self.recent_ws,handlers):
self.recents_menu.addAction(QtGui.QAction(ws,self,triggered=h))
def openRecent(self,ws):
self.workspaceTree.saveTabs(self.central)
self.closeAllTabs()
self.workspaceTree.setWorkspacePath(ws)
#self.generateAll()
self.loadTabs()
self.waitForScanner()
import symbolscanner
symbolscanner.setWorkspacePath(ws)
self.updateRecents()
def openWorkspace(self):
d=QtGui.QFileDialog()
d.setFileMode(QtGui.QFileDialog.Directory)
d.setOption(QtGui.QFileDialog.ShowDirsOnly)
if d.exec_():
ws=(d.selectedFiles())[0]
self.openRecent(ws)
def saveTabFile(self,index):
n=self.central.tabBar().count()
if index>=0 and index<n:
path=self.central.tabToolTip(index)
editor=self.editors.get(path)
if editor:
doc=editor.document()
if doc.isModified():
f=open(path,'w')
if not f:
utils.errorMessage('Cannot write file: {}'.format(path))
return
f.write(doc.toPlainText())
f.close()
doc.setModified(False)
self.file_times[path]=os.path.getmtime(path)
#dir=os.path.dirname(path)
#self.generateQueue.add(dir)
if self.symbolScan:
from system import getLibrarySymbols
getLibrarySymbols()
from symbolscanner import rescanOnFileSave
rescanOnFileSave(path)
def saveFile(self):
n=self.central.tabBar().count()
if n>0:
self.saveTabFile(self.central.currentIndex())
def saveAll(self):
n=self.central.tabBar().count()
for i in xrange(0,n):
self.saveTabFile(i)
def saveAsFile(self):
pass
def closeAllTabs(self):
while self.central.count()>0:
if not self.closeTab(0):
return False
return True
def tabChanged(self,index):
for i in xrange(0,len(self.tabOrder)):
if self.tabOrder[i]==index:
self.tabOrder=self.tabOrder[i:]+self.tabOrder[:i]
break
def closeTab(self,index):
path=self.central.tabToolTip(index)
editor=self.editors.get(path)
if editor:
doc=editor.document()
if doc.isModified():
mb = QtGui.QMessageBox()
mb.setText("{} has been modified.".format(os.path.basename(path)))
mb.setInformativeText("Do you want to save your changes?")
mb.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
mb.setDefaultButton(QtGui.QMessageBox.Save)
rc = mb.exec_()
if rc == QtGui.QMessageBox.Save:
f=open(path,'w')
if not f:
utils.errorMessage('Cannot write file: {}'.format(path))
return False
f.write(doc.toPlainText())
f.close()
elif rc == QtGui.QMessageBox.Cancel:
return False
del self.editors[path]
del self.file_times[path]
self.central.removeTab(index)
return True
def closeFile(self):
n=self.central.tabBar().count()
if n>0:
index=self.central.currentIndex()
return self.closeTab(index)
return False
def currentEditor(self):
if self.central.count()>0:
cur=self.central.currentIndex()
path=self.central.tabToolTip(cur)
if path in self.editors:
return (self.editors.get(path),path)
return (None,None)
def templateSelected(self,index):
(editor,path)=self.currentEditor()
if index>0 and editor:
template=self.tmplCombo.itemText(index)
d=QtCore.QSettings().value('tmplDir','').toString()
if d:
tpath=os.path.join(d,template+".template")
try:
f=open(tpath,'r')
code=f.read()
if code:
cursor=editor.textCursor()
props=Properties()
props.assign('PATH',path)
base=os.path.basename(path)
props.assign('FILENAME',base)
p=base.find('.')
if (p>0):
props.assign('FILEBASE',base[0:p])
props.assign('SELECTION',cursor.selectedText())
cursor.removeSelectedText()
import templates
text=templates.generateCode(code,props)
cursor.insertText(text)
except IOError:
utils.errorMessage("Cannot read file: {}".format(path))
self.tmplCombo.setCurrentIndex(0)
def showWorkspacePane(self):
""" Creates a docking pane that shows a list of source files """
self.paneWorkspace=QtGui.QDockWidget("Workspace",self)
self.paneWorkspace.setObjectName("Workspace")
self.paneWorkspace.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea)
self.workspaceTree=WorkSpace(self.paneWorkspace,self)
self.workspaceTree.depsChanged.connect(lambda path: self.generateQueue.add(path))
self.paneWorkspace.setWidget(self.workspaceTree)
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea,self.paneWorkspace)
self.updateWorkspace()
self.workspaceTree.doubleClicked.connect(self.docDoubleClicked)
self.showStatus(MainWindow.LIBRARY_SCAN)
if self.symbolScan:
from system import startSymbolScan
startSymbolScan(self.workspaceTree.root)
else:
from system import disableSymbolScan
disableSymbolScan()
self.updateRecents()
def updateWorkspace(self):
self.workspaceTree.update()
def setActiveSourceFile(self,path):
if path in self.editors:
editor=self.editors.get(path)
n=self.central.tabBar().count()
for i in xrange(0,n):
if self.central.widget(i) == editor:
self.central.tabBar().setCurrentIndex(i)
return True
return False
def fixPath(self,path):
if path.startswith(self.rootDir):
path=os.path.relpath(path,self.rootDir)
return path
'''
Makes the path given the active source file in the editor.
If the file is already open, it is made active.
If not, it is opened and made active.
Function returns true if the file is found and opened
'''
def openSourceFile(self,path):
path=self.fixPath(path)
if self.setActiveSourceFile(path):
return True
else:
try:
f=open(path,"r")
if not f:
return False
lines=f.readlines()
if lines:
firstLine=lines[0]
s=QtCore.QSettings()
editor=qutepart.Qutepart()
editor.setPath(path)
editor.detectSyntax(sourceFilePath=path, firstLine=firstLine)
editor.lineLengthEdge = 1024
editor.drawIncorrectIndentation = True
editor.drawAnyWhitespace = False
editor.indentUseTabs = False
editor.indentWidth = (s.value('indent',2).toInt())[0]
editor.text="".join(lines)
editor.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
editor.setWorkspace(self.workspaceTree)
editor.setMainWindow(self)
index=self.central.addTab(editor,os.path.basename(path))
self.central.setTabToolTip(index,path)
self.editors[path]=editor
self.file_times[path]=os.path.getmtime(path)
self.loadFont('codefont',editor)
self.central.tabBar().setCurrentIndex(index)
bps=self.breakpoints.pathBreakpoints(path)
editor.bpMarks=bps
editor._markArea.blockDoubleClicked.connect(self.markToggleBreakpoint)
return True
except IOError:
return False
return False
def docDoubleClicked(self,index):
item=self.workspaceTree.currentItem()
path=item.data(0,FileRole).toString()
if len(path)>0:
self.openSourceFile(path)
if path in self.editors:
self.editors.get(path).setFocus(QtCore.Qt.MouseFocusReason)
def goToSource(self,path,row,col,color=''):
"""
Given a file path, and a position within, open a tab
or switch to an already open tab, and scroll to that
position. Usually useful to find references or
compiler error positions
"""
path=self.fixPath(path)
if self.openSourceFile(path):
editor=self.editors.get(path)
if editor:
self.setActiveSourceFile(path)
c=editor.textCursor()
c.movePosition(QtGui.QTextCursor.Start)
c.movePosition(QtGui.QTextCursor.Down,n=row-1)
c.movePosition(QtGui.QTextCursor.Right,n=col-1)
editor.setTextCursor(c)
editor.ensureCursorVisible()
if len(color)>0:
editor.colorLine(row,color)
def showCallStackPane(self):
self.paneStack=QtGui.QDockWidget("Call Stack",self)
self.paneStack.setObjectName("CallStack")
self.paneStack.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea)
self.stackList=QtGui.QListWidget(self.paneStack)
self.paneStack.setWidget(self.stackList)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,self.paneStack)
self.loadFont('watchesfont',self.stackList)
self.stackList.itemDoubleClicked.connect(self.stackItemDoubleClicked)
def showLocalsPane(self):
self.paneLocals=QtGui.QDockWidget("Locals",self)
self.paneLocals.setObjectName("Locals")
self.paneLocals.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea)
self.localsTree=WatchesTree(self.paneLocals)
self.localsTree.setColumnCount(2)
self.localsTree.setHeaderLabels(['Name','Value'])
self.paneLocals.setWidget(self.localsTree)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,self.paneLocals)
self.loadFont('watchesfont',self.watchesTree)
def showWatchesPane(self):
self.paneWatches=QtGui.QDockWidget("Watches",self)
self.paneWatches.setObjectName("Watches")
self.paneWatches.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea)
self.watchesTree=WatchesTree(self.paneWatches)
self.watchesTree.setColumnCount(2)
self.watchesTree.setHeaderLabels(['Name','Value'])
self.paneWatches.setWidget(self.watchesTree)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,self.paneWatches)
self.loadFont('watchesfont',self.watchesTree)
self.watchesTree.addTopLevelItem(QtGui.QTreeWidgetItem(['* Double-Click for new watch']))
self.watchesTree.resizeColumnToContents(0)
self.watchesTree.itemDoubleClicked.connect(lambda item,column : self.watchDoubleClicked(item,column))
def showOutputPane(self):
self.paneOutput=QtGui.QDockWidget("Output",self)
self.paneOutput.setObjectName("Output")
self.paneOutput.setAllowedAreas(QtCore.Qt.BottomDockWidgetArea)
self.outputEdit=output.OutputWidget(self.paneOutput,self)
self.outputEdit.setReadOnly(True)
self.paneOutput.setWidget(self.outputEdit)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,self.paneOutput)
def stackItemDoubleClicked(self,item):
pat='at (.+):(\d+)'
m=re.search(pat,item.text())
if m:
g=m.groups()
path=g[0]
line=int(g[1])
self.goToSource(path,line,1)
else:
row=self.stackList.row(item)
if row<(self.stackList.count()-1):
self.stackItemDoubleClicked(self.stackList.item(row+1))
def watchDoubleClicked(self,item,column):
""" Edits existing watches, or adds a new watch """
changed=False
index=self.watchesTree.indexOfTopLevelItem(item)
if item.text(column)=='* Double-Click for new watch':
res=QtGui.QInputDialog.getText(self,'New Watch','Expression')
expr=res[0]
if len(expr)>0 and res[1]:
self.watchesTree.insertTopLevelItem(index,QtGui.QTreeWidgetItem([expr]))
changed=True
self.updateWatches()
else:
watch=item.text(0)
res=QtGui.QInputDialog.getText(self,"Edit Watch",'Expression',text=watch)
watch=res[0]
if res[1]:
changed=True
if len(watch)>0:
item.setText(0,watch)
self.updateWatches()
else:
self.watchesTree.takeTopLevelItem(index)
if changed:
self.saveWatches()
def createConfigCombo(self,parent):
configCombo=QtGui.QComboBox(parent)
configCombo.addItem("Debug")
configCombo.addItem("Release")
configCombo.currentIndexChanged.connect(self.configChanged)
return configCombo
def createTemplatesCombo(self,parent):
self.tmplCombo=QtGui.QComboBox(parent)
self.tmplCombo.currentIndexChanged.connect(self.templateSelected)
self.updateTemplates()
def configChanged(self,index):
configs=['Debug','Release']
self.config=configs[index]
s=QtCore.QSettings()
s.setValue("config",self.config)
s.sync()
self.workspaceTree.setConfig(self.config)
def addOutputText(self,added):
""" Append the new text captured
Text is appended to the end of existing text and the widget
is scrolled to show the end
"""
text=self.outputEdit.toPlainText()
self.outputEdit.setPlainText(text+added)
c=self.outputEdit.textCursor()
c.movePosition(QtGui.QTextCursor.End)
self.outputEdit.setTextCursor(c)
self.outputEdit.ensureCursorVisible()
def tempScriptPath(self):
"""
Generate a temporary script name. Used for running programs
with an additional wait for key at the end.
"""
from time import time
t=int(time()*10)
return '/tmp/coide_{}.sh'.format(t)
def removeTempScripts(self):
"""
Remove all temporary script files. Called before program
exit
"""
files=os.listdir('/tmp')
files=[f for f in files if f.startswith('coide_')]
for f in files:
os.remove('/tmp/{}'.format(f))
def runProject(self):
if not utils.checkFor('xterm'):
utils.message("xterm not installed")
return
path=self.tempScriptPath()
f=open(path,'w')
dir=self.workspaceTree.getDebugDirectory()
cmd=self.workspaceTree.getExecutablePath()
params=self.workspaceTree.getDebugParams()
if len(params)>0:
cmd=cmd+" "+params
f.write('#!/bin/sh\ncd {}\n{}\nread -r -p "Press any key..." key\n'.format(dir,cmd))
f.close()
os.chmod(path,stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
utils.run('/tmp','xterm','-fn','10x20','-e',path)
def getCurrentFile(self):
if self.central.count()==0:
return ''
return self.central.tabToolTip(self.central.currentIndex())
def getCurrentEditor(self):
path=self.getCurrentFile()
if len(path)>0:
return self.editors.get(path)
def updatePosition(self):
""" Query current position and update the code view """
changed=False
poslist=self.debugger.getCurrentPos()
if poslist and len(poslist)>0:
for (path,line) in poslist:
if self.getCurrentFile()==path:
if self.currentLine!=line:
changed=True
break
if self.openSourceFile(path):
changed=True
break
e=self.editors.get(path)
if changed and e:
e.colorLine(line,'#0080ff')
e.cursorPosition=(line-1,1)
self.currentLine=line
e.ensureCursorVisible()
def saveWatches(self):
""" Save all watches to settings, for future sessions """
res=[]
n=self.watchesTree.topLevelItemCount()-1
for i in xrange(0,n):
item=self.watchesTree.topLevelItem(i)
if len(res)>0:
res.append(';')
res.append(item.text(0))
settings=QtCore.QSettings()
key='watches:{}'.format(self.debugger.debugged)
settings.setValue(key,''.join(res))
def loadWatches(self):
""" Load all previous session watches from settings """
while self.watchesTree.topLevelItemCount()>1:
self.watchesTree.takeTopLevelItem(0)
settings=QtCore.QSettings()
key='watches:{}'.format(self.debugger.debugged)
val=settings.value(key,'').toString()
if len(val)>0:
arr=val.split(';')
if len(arr)>0:
res=[]
for watch in arr:
res.append(QtGui.QTreeWidgetItem([watch]))
self.watchesTree.insertTopLevelItems(0,res)
def updateLocals(self):
locals=self.debugger.getLocals()
self.localsTree.clear()
for var in locals.keys():
item=QtGui.QTreeWidgetItem([var])
self.localsTree.addTopLevelItem(item)
res=locals.get(var)
if res:
self.updateWatchItem(item,res)
def updateWatches(self):
""" Re-evaluate the value of each watch and update view """
n=self.watchesTree.topLevelItemCount()-1
for i in xrange(0,n):
item=self.watchesTree.topLevelItem(i)
item.takeChildren()
expr=item.text(0)
res=self.debugger.evaluate(expr)
if res:
self.updateWatchItem(item,res)
def updateWatchItem(self,item,root):
item.setText(1,root.value)
def addChildren(item,node):
for c in node.children:
subitem=QtGui.QTreeWidgetItem([c.name])
subitem.setText(1,c.value)
item.addChild(subitem)
addChildren(subitem,c)
addChildren(item,root)
def updateCallstack(self):
bt=self.debugger.getBackTrace()
self.stackList.clear()
for line in bt:
self.stackList.addItem(line)
def startDebug(self):
if self.debugger:
self.actCont()
return
self.outputEdit.setPlainText('')
cmd=[self.workspaceTree.getExecutablePath()]
args=self.workspaceTree.getDebugParams().split()
cwd=self.workspaceTree.getDebugDirectory()
if len(cwd)<1:
cwd=self.workspaceTree.mainPath()
for a in args:
cmd.append(a)
self.debugger=GDBWrapper(self.breakpoints,cmd,cwd)
#self.showWatchesPane()
#self.showCallStackPane()
#self.loadDebugWindowState()
self.showDebugPanes()
self.loadWatches()
self.timer.start(50)
qutepart.evaluator=self.debugger.evaluateAsText
def stopDebugger(self):
if self.debugger:
qutepart.evaluator=None
for path in self.editors:
e=self.editors.get(path)
e.colorLine(0,'')
self.saveDebugWindowState()
self.debugger.quitDebugger()
self.debugger=None
#self.paneWatches.close()
#self.paneWatches=None
#self.paneStack.close()
#self.paneStack=None
self.hideDebugPanes()
self.timer.stop()
def hideDebugPanes(self):
self.paneWatches.hide()
self.paneLocals.hide()
self.paneStack.hide()
def showDebugPanes(self):
self.paneWatches.show()
self.paneLocals.show()
self.paneStack.show()
def clearBreakpoints(self):
self.breakpoints.clear()
n=self.central.count()
for i in xrange(0,n):
self.central.widget(i).bpMarks={}
if self.debugger:
self.debugger.clearBreakpoints()
def actStep(self):
if self.debugger:
self.debugger.actStep()
if not self.debugger.running:
self.stopDebugger()
def actNext(self):
if self.debugger:
self.debugger.actNext()
if not self.debugger.running:
self.stopDebugger()
def actOut(self):
if self.debugger:
self.debugger.actOut()
if not self.debugger.running:
self.stopDebugger()
def actCont(self):
if self.debugger:
e=self.getCurrentEditor()
if e:
e.colorLine(0,'')
self.currentLine=-1
self.debugger.actCont()
def actBreak(self):
if self.debugger:
self.debugger.actBreak()
def actStop(self):
if self.debugger:
self.debugger.actStop()
def update(self):
""" Called every 50ms to check if a change in debugger state occurred
Basically this is waiting for a change of state, indicated by:
* self.debugger.changed
If a change is detected, everything is re-evaluated and drawn
"""
if self.debugger:
self.debugger.update()
#if len(text)>0:
# self.addOutputText(text)
if self.debugger.hasOutput():
self.addOutputText(self.debugger.getOutput())
if self.debugger.changed:
self.updatePosition()
self.updateWatches()
self.updateLocals()
self.updateCallstack()
self.debugger.changed=False
if not self.debugger.running:
self.stopDebugger()
# If the debugger is active running the program,
# create an indication using an animation in the top left
# corner of the application window
if self.debugger and self.debugger.active:
if self.runningWidget is None:
from running import RunningWidget
self.runningWidget=RunningWidget(self)
self.runningWidget.show()
self.outputEdit.setBlinkingCursor(True)
s=self.outputEdit.getInput()
if len(s)>0:
text=''.join(s)
self.debugger.sendInput(text)
self.addOutputText(text)
else:
self.outputEdit.clearInput()
self.outputEdit.setBlinkingCursor(False)
if not self.runningWidget is None:
self.runningWidget.close()
self.runningWidget=None
|
gpl-2.0
|
[
504,
14084,
20,
492,
10565,
199,
504,
14084,
20,
492,
5928,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5672,
199,
199,
646,
2173,
266,
2064,
199,
504,
14466,
492,
9361,
7643,
199,
646,
1072,
199,
504,
950,
83,
492,
3814,
7422,
199,
504,
12124,
5029,
492,
598,
2846,
4590,
199,
504,
336,
292,
595,
270,
850,
492,
29075,
397,
3987,
199,
504,
28906,
492,
22535,
3438,
2846,
12,
22535,
1403,
5619,
199,
504,
4382,
492,
19329,
199,
504,
9143,
492,
7417,
199,
504,
7992,
492,
365,
63,
2164,
63,
832,
199,
646,
3778,
199,
646,
3805,
1875,
199,
646,
399,
374,
199,
646,
8963,
199,
646,
366,
3281,
70,
199,
199,
533,
11298,
4301,
8,
10604,
14,
49,
16031,
304,
272,
408,
11298,
473,
1093,
15689,
339,
22493,
314,
2446,
1233,
2455,
12,
3180,
543,
366,
766,
316,
21379,
397,
367,
26,
1350,
1584,
12,
14821,
9626,
397,
12,
1240,
3464,
12,
436,
1072,
2286,
408,
272,
25764,
50,
4392,
63,
24078,
275,
298,
7181,
11495,
31454,
2,
2286,
347,
636,
826,
721,
277,
12,
1231,
3567,
12,
1708,
29,
403,
304,
267,
408,
11578,
14,
221,
1738,
3567,
9126,
2382,
666,
1584,
787,
16180,
408,
267,
1613,
8,
16031,
12,
277,
2843,
826,
721,
1708,
9,
398,
308,
29,
10901,
14,
49,
5268,
342,
267,
291,
14,
14951,
63,
3569,
1524,
68,
367,
366,
315,
308,
14,
585,
360,
14951,
63,
3569,
26516,
16695,
1252,
1294,
11633,
340,
366,
61,
398,
291,
14,
5155,
15936,
29,
83,
14,
585,
360,
5155,
63,
6282,
297,
549,
680,
475,
10349,
342,
267,
291,
14,
32608,
2320,
8,
10901,
14,
15531,
8,
7727,
12,
14408,
430,
398,
291,
14,
1818,
3049,
29,
16,
267,
291,
14,
1818,
1173,
19070,
267,
291,
14,
1231,
3567,
29,
1231,
3567,
267,
3778,
14,
409,
41,
8704,
3567,
8,
736,
14,
515,
14,
904,
8,
1231,
3567,
4589,
16471,
2237,
267,
291,
14,
17612,
29,
403,
267,
291,
14,
4785,
3438,
29,
13948,
3438,
2846,
342,
267,
291,
14,
1623,
11347,
29,
403,
267,
291,
14,
17143,
63,
19709,
9811,
2728,
291,
14,
25666,
8954,
8,
1208,
14,
912,
8954,
360,
331,
2655,
1333,
267,
291,
14,
30601,
480,
967,
2655,
531,
398,
291,
14,
4208,
3737,
29,
409,
342,
18418,
291,
14,
3773,
1384,
7622,
267,
291,
14,
493,
63,
4508,
7622,
267,
291,
14,
16067,
29,
10604,
14,
49,
7690,
3339,
342,
267,
291,
14,
409,
25290,
3339,
8,
277,
14,
16067,
9,
267,
291,
14,
16067,
14,
409,
23085,
3337,
83,
461,
8,
549,
9,
267,
291,
14,
16067,
14,
2902,
4724,
17935,
14,
2242,
8,
277,
14,
1600,
7690,
9,
267,
291,
14,
16067,
14,
1818,
6970,
14,
2242,
8,
277,
14,
2902,
6970,
9,
267,
291,
14,
2902,
4738,
9811,
2728,
291,
14,
5265,
29,
5265,
14,
19330,
2988,
342,
398,
291,
14,
2758,
5977,
342,
267,
291,
14,
2758,
2998,
5977,
7412,
342,
267,
291,
14,
2758,
29630,
8,
1231,
3567,
9,
267,
291,
14,
2384,
21058,
48,
5865,
342,
267,
291,
14,
2384,
2959,
48,
5865,
342,
267,
291,
14,
2384,
13978,
397,
48,
5865,
342,
267,
291,
14,
2384,
3040,
2551,
48,
5865,
342,
267,
291,
14,
2384,
2176,
4851,
48,
5865,
342,
267,
291,
14,
1506,
3498,
29,
403,
18418,
291,
14,
7414,
2176,
29,
403,
31106,
291,
14,
888,
29,
83,
14,
585,
480,
888,
3471,
16695,
342,
267,
340,
291,
14,
888,
6803,
356,
288,
291,
14,
888,
628,
7084,
2,
267,
291,
14,
888,
12413,
14,
31549,
8,
16,
340,
291,
14,
888,
6803,
7084,
7,
587,
413,
9,
267,
291,
14,
13249,
3987,
14,
409,
2028,
8,
277,
14,
888,
9,
2728,
291,
14,
409,
2422,
38,
13366,
342,
267,
291,
14,
912,
4301,
5268,
342,
2728,
327,
14245,
836,
9715,
626,
365,
20042,
370,
18745,
1183,
1104,
4960,
327,
340,
314,
2240,
965,
15248,
737,
282,
17944,
267,
291,
14,
7414,
29,
10901,
14,
49,
7929,
8,
277,
9,
267,
291,
14,
7414,
14,
2593,
14,
2242,
8,
277,
14,
873,
9,
267,
291,
14,
5720,
3339,
29,
403,
2728,
291,
14,
4146,
24022,
7929,
29,
10901,
14,
49,
7929,
8,
277,
9,
267,
291,
14,
4146,
24022,
7929,
14,
2593,
14,
2242,
8,
277,
14,
6843,
12807,
9,
2728,
291,
14,
4208,
7929,
29,
10901,
14,
49,
7929,
342,
267,
291,
14,
4208,
7929,
14,
2593,
14,
2242,
8,
277,
14,
7414,
5279,
9,
267,
291,
14,
4208,
7929,
14,
928,
8,
5279,
9,
2728,
291,
14,
674,
13875,
7929,
29,
10901,
14,
49,
7929,
342,
267,
291,
14,
674,
13875,
7929,
14,
2593,
14,
2242,
8,
277,
14,
7414,
13128,
9,
267,
291,
14,
674,
13875,
7929,
14,
928,
8,
13128,
9,
2728,
327,
277,
14,
2384,
3694,
480,
29244,
2900,
4155,
1725,
531,
267,
327,
277,
14,
7414,
2176,
29,
277,
14,
4208,
2422,
607,
4436,
267,
291,
14,
7414,
2176,
29,
403,
2728,
291,
14,
29092,
13978,
397,
14,
8191,
342,
267,
291,
14,
29092,
3040,
2551,
14,
8191,
342,
267,
291,
14,
29092,
4851,
14,
8191,
342,
2728,
327,
277,
14,
551,
29,
10604,
14,
49,
28301,
480,
9778,
11,
38,
24,
401,
277,
9,
267,
327,
277,
14,
551,
14,
18218,
14,
2242,
8,
277,
14,
80,
2591,
551,
9,
5493,
347,
4002,
2390,
8,
277,
12,
1566,
304,
267,
408,
12295,
2544,
314,
4223,
4353,
27811,
398,
1010,
3351,
1007,
13,
8258,
370,
9275,
436,
23050,
4353,
2202,
267,
370,
2040,
6466,
12184,
370,
3648,
314,
2011,
2728,
408,
267,
291,
14,
13249,
3987,
14,
265,
4724,
342,
267,
291,
14,
13249,
3987,
14,
2117,
23085,
8,
277,
14,
16067,
9,
267,
1830,
291,
14,
16067,
14,
835,
342,
30,
16,
26,
288,
340,
440,
291,
14,
1600,
1173,
837,
355,
1566,
14,
4247,
342,
355,
372,
398,
291,
14,
7414,
14,
2379,
342,
267,
291,
14,
4208,
7929,
14,
2379,
342,
267,
340,
291,
14,
17612,
26,
288,
291,
14,
17612,
14,
11707,
2640,
342,
10631,
2202,
275,
10565,
14,
49,
5268,
342,
267,
2202,
14,
14733,
480,
7660,
401,
291,
14,
2117,
6831,
1012,
267,
2202,
14,
14733,
480,
3806,
2223,
401,
291,
14,
2117
] |
[
14084,
20,
492,
10565,
199,
504,
14084,
20,
492,
5928,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5672,
199,
199,
646,
2173,
266,
2064,
199,
504,
14466,
492,
9361,
7643,
199,
646,
1072,
199,
504,
950,
83,
492,
3814,
7422,
199,
504,
12124,
5029,
492,
598,
2846,
4590,
199,
504,
336,
292,
595,
270,
850,
492,
29075,
397,
3987,
199,
504,
28906,
492,
22535,
3438,
2846,
12,
22535,
1403,
5619,
199,
504,
4382,
492,
19329,
199,
504,
9143,
492,
7417,
199,
504,
7992,
492,
365,
63,
2164,
63,
832,
199,
646,
3778,
199,
646,
3805,
1875,
199,
646,
399,
374,
199,
646,
8963,
199,
646,
366,
3281,
70,
199,
199,
533,
11298,
4301,
8,
10604,
14,
49,
16031,
304,
272,
408,
11298,
473,
1093,
15689,
339,
22493,
314,
2446,
1233,
2455,
12,
3180,
543,
366,
766,
316,
21379,
397,
367,
26,
1350,
1584,
12,
14821,
9626,
397,
12,
1240,
3464,
12,
436,
1072,
2286,
408,
272,
25764,
50,
4392,
63,
24078,
275,
298,
7181,
11495,
31454,
2,
2286,
347,
636,
826,
721,
277,
12,
1231,
3567,
12,
1708,
29,
403,
304,
267,
408,
11578,
14,
221,
1738,
3567,
9126,
2382,
666,
1584,
787,
16180,
408,
267,
1613,
8,
16031,
12,
277,
2843,
826,
721,
1708,
9,
398,
308,
29,
10901,
14,
49,
5268,
342,
267,
291,
14,
14951,
63,
3569,
1524,
68,
367,
366,
315,
308,
14,
585,
360,
14951,
63,
3569,
26516,
16695,
1252,
1294,
11633,
340,
366,
61,
398,
291,
14,
5155,
15936,
29,
83,
14,
585,
360,
5155,
63,
6282,
297,
549,
680,
475,
10349,
342,
267,
291,
14,
32608,
2320,
8,
10901,
14,
15531,
8,
7727,
12,
14408,
430,
398,
291,
14,
1818,
3049,
29,
16,
267,
291,
14,
1818,
1173,
19070,
267,
291,
14,
1231,
3567,
29,
1231,
3567,
267,
3778,
14,
409,
41,
8704,
3567,
8,
736,
14,
515,
14,
904,
8,
1231,
3567,
4589,
16471,
2237,
267,
291,
14,
17612,
29,
403,
267,
291,
14,
4785,
3438,
29,
13948,
3438,
2846,
342,
267,
291,
14,
1623,
11347,
29,
403,
267,
291,
14,
17143,
63,
19709,
9811,
2728,
291,
14,
25666,
8954,
8,
1208,
14,
912,
8954,
360,
331,
2655,
1333,
267,
291,
14,
30601,
480,
967,
2655,
531,
398,
291,
14,
4208,
3737,
29,
409,
342,
18418,
291,
14,
3773,
1384,
7622,
267,
291,
14,
493,
63,
4508,
7622,
267,
291,
14,
16067,
29,
10604,
14,
49,
7690,
3339,
342,
267,
291,
14,
409,
25290,
3339,
8,
277,
14,
16067,
9,
267,
291,
14,
16067,
14,
409,
23085,
3337,
83,
461,
8,
549,
9,
267,
291,
14,
16067,
14,
2902,
4724,
17935,
14,
2242,
8,
277,
14,
1600,
7690,
9,
267,
291,
14,
16067,
14,
1818,
6970,
14,
2242,
8,
277,
14,
2902,
6970,
9,
267,
291,
14,
2902,
4738,
9811,
2728,
291,
14,
5265,
29,
5265,
14,
19330,
2988,
342,
398,
291,
14,
2758,
5977,
342,
267,
291,
14,
2758,
2998,
5977,
7412,
342,
267,
291,
14,
2758,
29630,
8,
1231,
3567,
9,
267,
291,
14,
2384,
21058,
48,
5865,
342,
267,
291,
14,
2384,
2959,
48,
5865,
342,
267,
291,
14,
2384,
13978,
397,
48,
5865,
342,
267,
291,
14,
2384,
3040,
2551,
48,
5865,
342,
267,
291,
14,
2384,
2176,
4851,
48,
5865,
342,
267,
291,
14,
1506,
3498,
29,
403,
18418,
291,
14,
7414,
2176,
29,
403,
31106,
291,
14,
888,
29,
83,
14,
585,
480,
888,
3471,
16695,
342,
267,
340,
291,
14,
888,
6803,
356,
288,
291,
14,
888,
628,
7084,
2,
267,
291,
14,
888,
12413,
14,
31549,
8,
16,
340,
291,
14,
888,
6803,
7084,
7,
587,
413,
9,
267,
291,
14,
13249,
3987,
14,
409,
2028,
8,
277,
14,
888,
9,
2728,
291,
14,
409,
2422,
38,
13366,
342,
267,
291,
14,
912,
4301,
5268,
342,
2728,
327,
14245,
836,
9715,
626,
365,
20042,
370,
18745,
1183,
1104,
4960,
327,
340,
314,
2240,
965,
15248,
737,
282,
17944,
267,
291,
14,
7414,
29,
10901,
14,
49,
7929,
8,
277,
9,
267,
291,
14,
7414,
14,
2593,
14,
2242,
8,
277,
14,
873,
9,
267,
291,
14,
5720,
3339,
29,
403,
2728,
291,
14,
4146,
24022,
7929,
29,
10901,
14,
49,
7929,
8,
277,
9,
267,
291,
14,
4146,
24022,
7929,
14,
2593,
14,
2242,
8,
277,
14,
6843,
12807,
9,
2728,
291,
14,
4208,
7929,
29,
10901,
14,
49,
7929,
342,
267,
291,
14,
4208,
7929,
14,
2593,
14,
2242,
8,
277,
14,
7414,
5279,
9,
267,
291,
14,
4208,
7929,
14,
928,
8,
5279,
9,
2728,
291,
14,
674,
13875,
7929,
29,
10901,
14,
49,
7929,
342,
267,
291,
14,
674,
13875,
7929,
14,
2593,
14,
2242,
8,
277,
14,
7414,
13128,
9,
267,
291,
14,
674,
13875,
7929,
14,
928,
8,
13128,
9,
2728,
327,
277,
14,
2384,
3694,
480,
29244,
2900,
4155,
1725,
531,
267,
327,
277,
14,
7414,
2176,
29,
277,
14,
4208,
2422,
607,
4436,
267,
291,
14,
7414,
2176,
29,
403,
2728,
291,
14,
29092,
13978,
397,
14,
8191,
342,
267,
291,
14,
29092,
3040,
2551,
14,
8191,
342,
267,
291,
14,
29092,
4851,
14,
8191,
342,
2728,
327,
277,
14,
551,
29,
10604,
14,
49,
28301,
480,
9778,
11,
38,
24,
401,
277,
9,
267,
327,
277,
14,
551,
14,
18218,
14,
2242,
8,
277,
14,
80,
2591,
551,
9,
5493,
347,
4002,
2390,
8,
277,
12,
1566,
304,
267,
408,
12295,
2544,
314,
4223,
4353,
27811,
398,
1010,
3351,
1007,
13,
8258,
370,
9275,
436,
23050,
4353,
2202,
267,
370,
2040,
6466,
12184,
370,
3648,
314,
2011,
2728,
408,
267,
291,
14,
13249,
3987,
14,
265,
4724,
342,
267,
291,
14,
13249,
3987,
14,
2117,
23085,
8,
277,
14,
16067,
9,
267,
1830,
291,
14,
16067,
14,
835,
342,
30,
16,
26,
288,
340,
440,
291,
14,
1600,
1173,
837,
355,
1566,
14,
4247,
342,
355,
372,
398,
291,
14,
7414,
14,
2379,
342,
267,
291,
14,
4208,
7929,
14,
2379,
342,
267,
340,
291,
14,
17612,
26,
288,
291,
14,
17612,
14,
11707,
2640,
342,
10631,
2202,
275,
10565,
14,
49,
5268,
342,
267,
2202,
14,
14733,
480,
7660,
401,
291,
14,
2117,
6831,
1012,
267,
2202,
14,
14733,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kenshay/ImageScripter
|
ProgramData/SystemFiles/Python/Lib/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/html5lib/treeadapters/sax.py
|
1835
|
1661
|
from __future__ import absolute_import, division, unicode_literals
from xml.sax.xmlreader import AttributesNSImpl
from ..constants import adjustForeignAttributes, unadjustForeignAttributes
prefix_mapping = {}
for prefix, localName, namespace in adjustForeignAttributes.values():
if prefix is not None:
prefix_mapping[prefix] = namespace
def to_sax(walker, handler):
"""Call SAX-like content handler based on treewalker walker"""
handler.startDocument()
for prefix, namespace in prefix_mapping.items():
handler.startPrefixMapping(prefix, namespace)
for token in walker:
type = token["type"]
if type == "Doctype":
continue
elif type in ("StartTag", "EmptyTag"):
attrs = AttributesNSImpl(token["data"],
unadjustForeignAttributes)
handler.startElementNS((token["namespace"], token["name"]),
token["name"],
attrs)
if type == "EmptyTag":
handler.endElementNS((token["namespace"], token["name"]),
token["name"])
elif type == "EndTag":
handler.endElementNS((token["namespace"], token["name"]),
token["name"])
elif type in ("Characters", "SpaceCharacters"):
handler.characters(token["data"])
elif type == "Comment":
pass
else:
assert False, "Unknown token type"
for prefix, namespace in prefix_mapping.items():
handler.endPrefixMapping(prefix)
handler.endDocument()
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
2748,
14,
14338,
14,
1652,
5503,
492,
9382,
46,
2684,
2421,
199,
199,
504,
2508,
5559,
492,
11311,
20931,
5379,
12,
625,
10917,
20931,
5379,
199,
199,
1861,
63,
4745,
275,
1052,
199,
509,
2403,
12,
2257,
985,
12,
3231,
315,
11311,
20931,
5379,
14,
1459,
837,
272,
340,
2403,
365,
440,
488,
26,
267,
2403,
63,
4745,
59,
1861,
61,
275,
3231,
421,
199,
318,
370,
63,
14338,
8,
87,
14976,
12,
3016,
304,
272,
408,
2176,
19310,
13,
2930,
1564,
3016,
4079,
641,
20991,
546,
14976,
336,
14976,
624,
272,
3016,
14,
928,
5564,
342,
272,
367,
2403,
12,
3231,
315,
2403,
63,
4745,
14,
1744,
837,
267,
3016,
14,
928,
4793,
7674,
8,
1861,
12,
3231,
9,
339,
367,
1526,
315,
336,
14976,
26,
267,
730,
275,
1526,
905,
466,
937,
267,
340,
730,
508,
298,
21629,
582,
288,
1980,
267,
916,
730,
315,
1689,
17697,
401,
298,
4699,
1931,
2349,
288,
3290,
275,
9382,
46,
2684,
2421,
8,
1418,
905,
576,
2255,
3660,
625,
10917,
20931,
5379,
9,
288,
3016,
14,
30398,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
3521,
1526,
905,
354,
2255,
3521,
3290,
9,
288,
340,
730,
508,
298,
4699,
1931,
582,
355,
3016,
14,
31290,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
3660,
1526,
905,
354,
3135,
267,
916,
730,
508,
298,
16906,
582,
288,
3016,
14,
31290,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
639,
1526,
905,
354,
3135,
267,
916,
730,
315,
1689,
9272,
401,
298,
28501,
2349,
288,
3016,
14,
16516,
8,
1418,
905,
576,
3135,
267,
916,
730,
508,
298,
7488,
582,
288,
986,
267,
587,
26,
288,
702,
756,
12,
298,
5912,
1526,
730,
2,
339,
367,
2403,
12,
3231,
315,
2403,
63,
4745,
14,
1744,
837,
267,
3016,
14,
500,
4793,
7674,
8,
1861,
9,
272,
3016,
14,
500,
5564,
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
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
2748,
14,
14338,
14,
1652,
5503,
492,
9382,
46,
2684,
2421,
199,
199,
504,
2508,
5559,
492,
11311,
20931,
5379,
12,
625,
10917,
20931,
5379,
199,
199,
1861,
63,
4745,
275,
1052,
199,
509,
2403,
12,
2257,
985,
12,
3231,
315,
11311,
20931,
5379,
14,
1459,
837,
272,
340,
2403,
365,
440,
488,
26,
267,
2403,
63,
4745,
59,
1861,
61,
275,
3231,
421,
199,
318,
370,
63,
14338,
8,
87,
14976,
12,
3016,
304,
272,
408,
2176,
19310,
13,
2930,
1564,
3016,
4079,
641,
20991,
546,
14976,
336,
14976,
624,
272,
3016,
14,
928,
5564,
342,
272,
367,
2403,
12,
3231,
315,
2403,
63,
4745,
14,
1744,
837,
267,
3016,
14,
928,
4793,
7674,
8,
1861,
12,
3231,
9,
339,
367,
1526,
315,
336,
14976,
26,
267,
730,
275,
1526,
905,
466,
937,
267,
340,
730,
508,
298,
21629,
582,
288,
1980,
267,
916,
730,
315,
1689,
17697,
401,
298,
4699,
1931,
2349,
288,
3290,
275,
9382,
46,
2684,
2421,
8,
1418,
905,
576,
2255,
3660,
625,
10917,
20931,
5379,
9,
288,
3016,
14,
30398,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
3521,
1526,
905,
354,
2255,
3521,
3290,
9,
288,
340,
730,
508,
298,
4699,
1931,
582,
355,
3016,
14,
31290,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
3660,
1526,
905,
354,
3135,
267,
916,
730,
508,
298,
16906,
582,
288,
3016,
14,
31290,
2709,
1332,
1418,
905,
3251,
2255,
1526,
905,
354,
10252,
639,
1526,
905,
354,
3135,
267,
916,
730,
315,
1689,
9272,
401,
298,
28501,
2349,
288,
3016,
14,
16516,
8,
1418,
905,
576,
3135,
267,
916,
730,
508,
298,
7488,
582,
288,
986,
267,
587,
26,
288,
702,
756,
12,
298,
5912,
1526,
730,
2,
339,
367,
2403,
12,
3231,
315,
2403,
63,
4745,
14,
1744,
837,
267,
3016,
14,
500,
4793,
7674,
8,
1861,
9,
272,
3016,
14,
500,
5564,
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,
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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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
DelazJ/QGIS
|
python/plugins/processing/algs/gdal/pct2rgb.py
|
15
|
3807
|
# -*- coding: utf-8 -*-
"""
***************************************************************************
pct2rgb.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
import os
from qgis.PyQt.QtGui import QIcon
from qgis.core import (QgsRasterFileWriter,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
QgsProcessingParameterBoolean,
QgsProcessingParameterRasterDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.tools.system import isWindows
from processing.algs.gdal.GdalUtils import GdalUtils
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
class pct2rgb(GdalAlgorithm):
INPUT = 'INPUT'
BAND = 'BAND'
RGBA = 'RGBA'
OUTPUT = 'OUTPUT'
def __init__(self):
super().__init__()
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT, self.tr('Input layer')))
self.addParameter(QgsProcessingParameterBand(self.BAND,
self.tr('Band number'),
1,
parentLayerParameterName=self.INPUT))
self.addParameter(QgsProcessingParameterBoolean(self.RGBA,
self.tr('Generate a RGBA file'),
defaultValue=False))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('PCT to RGB')))
def name(self):
return 'pcttorgb'
def displayName(self):
return self.tr('PCT to RGB')
def group(self):
return self.tr('Raster conversion')
def groupId(self):
return 'rasterconversion'
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '8-to-24-bits.png'))
def commandName(self):
return 'pct2rgb'
def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
if inLayer is None:
raise QgsProcessingException(self.invalidRasterError(parameters, self.INPUT))
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
self.setOutputValue(self.OUTPUT, out)
arguments = [
inLayer.source(),
out,
'-of',
QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]),
'-b',
str(self.parameterAsInt(parameters, self.BAND, context)),
]
if self.parameterAsBoolean(parameters, self.RGBA, context):
arguments.append('-rgba')
return [self.commandName() + ('.bat' if isWindows() else '.py'), GdalUtils.escapeAndJoin(arguments)]
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
299,
319,
18,
10090,
14,
647,
272,
10652,
9858,
272,
6148,
463,
520,
25298,
833,
6029,
272,
1898,
3322,
520,
334,
35,
9,
6029,
701,
6561,
630,
593,
817,
65,
272,
11426,
4483,
520,
5236,
1187,
2756,
737,
29712,
6308,
2414,
199,
17623,
199,
10,
17997,
627,
199,
10,
257,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
627,
199,
10,
257,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
221,
627,
199,
10,
257,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
258,
627,
199,
10,
257,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
15530,
627,
199,
10,
17997,
627,
199,
17623,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
2201,
630,
593,
817,
65,
7,
199,
363,
602,
363,
275,
283,
21640,
833,
6029,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
6029,
12,
6561,
630,
593,
817,
65,
7,
199,
199,
646,
747,
199,
199,
504,
15640,
14,
24107,
14,
10604,
492,
1413,
8954,
199,
199,
504,
15640,
14,
1018,
492,
334,
7350,
13284,
28199,
12,
2432,
17214,
1726,
12,
2432,
23764,
13284,
5003,
12,
2432,
23764,
11675,
12,
2432,
23764,
4082,
12,
2432,
23764,
13284,
13151,
9,
199,
504,
6661,
14,
31128,
14,
11600,
14,
39,
12390,
11570,
492,
598,
12390,
11570,
199,
504,
6661,
14,
2537,
14,
2253,
492,
365,
8647,
199,
504,
6661,
14,
31128,
14,
11600,
14,
39,
12390,
7535,
492,
598,
12390,
7535,
199,
199,
2718,
2042,
275,
747,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
3475,
3460,
493,
8964,
59,
16,
11057,
16,
61,
421,
199,
533,
299,
319,
18,
10090,
8,
39,
12390,
11570,
304,
272,
21955,
275,
283,
7321,
7,
272,
699,
3649,
275,
283,
23297,
7,
272,
820,
39,
4134,
275,
283,
21631,
7,
272,
18746,
275,
283,
8414,
7,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
339,
347,
4205,
11570,
8,
277,
12,
1101,
29,
403,
304,
267,
291,
14,
26895,
8,
28559,
4720,
13284,
5003,
8,
277,
14,
7321,
12,
291,
14,
454,
360,
3205,
4045,
7058,
267,
291,
14,
26895,
8,
28559,
4720,
11675,
8,
277,
14,
23297,
12,
9349,
291,
14,
454,
360,
11675,
1329,
659,
9349,
413,
12,
9349,
1676,
5003,
4720,
985,
29,
277,
14,
7321,
430,
267,
291,
14,
26895,
8,
28559,
4720,
4082,
8,
277,
14,
21631,
12,
9144,
291,
14,
454,
360,
6864,
282,
820,
39,
4134,
570,
659,
9144,
31617,
29,
797,
430,
267,
291,
14,
26895,
8,
28559,
4720,
13284,
13151,
8,
277,
14,
8414,
12,
291,
14,
454,
360,
48,
1028,
370,
19013,
7058,
339,
347,
536,
8,
277,
304,
267,
372,
283,
20778,
84,
1308,
66,
7,
339,
347,
2929,
985,
8,
277,
304,
267,
372,
291,
14,
454,
360,
48,
1028,
370,
19013,
358,
339,
347,
1572,
8,
277,
304,
267,
372,
291,
14,
454,
360,
13284,
8603,
358,
339,
347,
1572,
1304,
8,
277,
304,
267,
372,
283,
20876,
15083,
7,
339,
347,
7016,
8,
277,
304,
267,
372,
1413,
8954,
8,
736,
14,
515,
14,
904,
8,
2718,
2042,
12,
283,
4782,
297,
283,
11600,
2537,
297,
283,
24,
13,
475,
13,
1194,
13,
5609,
14,
4524,
1333,
339,
347,
1414,
985,
8,
277,
304,
267,
372,
283,
20778,
18,
10090,
7,
339,
347,
664,
9270,
14680,
8,
277,
12,
2633,
12,
1067,
12,
17145,
12,
14043,
29,
549,
304,
267,
315,
5003,
275,
291,
14,
5329,
2822,
13284,
5003,
8,
3214,
12,
291,
14,
7321,
12,
1067,
9,
267,
340,
315,
5003,
365,
488,
26,
288,
746,
17214,
1726,
8,
277,
14,
3197,
13284,
547,
8,
3214,
12,
291,
14,
7321,
430,
398,
734,
275,
291,
14,
5329,
2822,
2959,
5003,
8,
3214,
12,
291,
14,
8414,
12,
1067,
9,
267,
291,
14,
409,
2959,
1110,
8,
277,
14,
8414,
12,
734,
9,
398,
2368,
275,
359,
288,
315,
5003,
14,
1365,
1062,
288,
734,
12,
288,
2475,
1618,
297,
288,
4888,
13284,
28199,
14,
3090,
1858,
6382,
8,
736,
14,
515,
14,
7973,
8,
548,
2788,
17,
2522,
288,
2475,
66,
297,
288,
620,
8,
277,
14,
5329,
2822,
3241,
8,
3214,
12,
291,
14,
23297,
12,
1067,
1826,
267,
1622,
398,
340,
291,
14,
5329,
2822,
4082,
8,
3214,
12,
291,
14,
21631,
12,
1067,
304,
288,
2368,
14,
740,
3654,
22118,
358,
398,
372,
359,
277,
14,
1531,
985,
342,
435,
23500,
13475,
7,
340,
365,
8647,
342,
587,
1987,
647,
659,
598,
12390,
7535,
14,
3765,
3325,
13005,
8,
4958,
1874,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
299,
319,
18,
10090,
14,
647,
272,
10652,
9858,
272,
6148,
463,
520,
25298,
833,
6029,
272,
1898,
3322,
520,
334,
35,
9,
6029,
701,
6561,
630,
593,
817,
65,
272,
11426,
4483,
520,
5236,
1187,
2756,
737,
29712,
6308,
2414,
199,
17623,
199,
10,
17997,
627,
199,
10,
257,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
627,
199,
10,
257,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
221,
627,
199,
10,
257,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
258,
627,
199,
10,
257,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
15530,
627,
199,
10,
17997,
627,
199,
17623,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
2201,
630,
593,
817,
65,
7,
199,
363,
602,
363,
275,
283,
21640,
833,
6029,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
6029,
12,
6561,
630,
593,
817,
65,
7,
199,
199,
646,
747,
199,
199,
504,
15640,
14,
24107,
14,
10604,
492,
1413,
8954,
199,
199,
504,
15640,
14,
1018,
492,
334,
7350,
13284,
28199,
12,
2432,
17214,
1726,
12,
2432,
23764,
13284,
5003,
12,
2432,
23764,
11675,
12,
2432,
23764,
4082,
12,
2432,
23764,
13284,
13151,
9,
199,
504,
6661,
14,
31128,
14,
11600,
14,
39,
12390,
11570,
492,
598,
12390,
11570,
199,
504,
6661,
14,
2537,
14,
2253,
492,
365,
8647,
199,
504,
6661,
14,
31128,
14,
11600,
14,
39,
12390,
7535,
492,
598,
12390,
7535,
199,
199,
2718,
2042,
275,
747,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
3475,
3460,
493,
8964,
59,
16,
11057,
16,
61,
421,
199,
533,
299,
319,
18,
10090,
8,
39,
12390,
11570,
304,
272,
21955,
275,
283,
7321,
7,
272,
699,
3649,
275,
283,
23297,
7,
272,
820,
39,
4134,
275,
283,
21631,
7,
272,
18746,
275,
283,
8414,
7,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
339,
347,
4205,
11570,
8,
277,
12,
1101,
29,
403,
304,
267,
291,
14,
26895,
8,
28559,
4720,
13284,
5003,
8,
277,
14,
7321,
12,
291,
14,
454,
360,
3205,
4045,
7058,
267,
291,
14,
26895,
8,
28559,
4720,
11675,
8,
277,
14,
23297,
12,
9349,
291,
14,
454,
360,
11675,
1329,
659,
9349,
413,
12,
9349,
1676,
5003,
4720,
985,
29,
277,
14,
7321,
430,
267,
291,
14,
26895,
8,
28559,
4720,
4082,
8,
277,
14,
21631,
12,
9144,
291,
14,
454,
360,
6864,
282,
820,
39,
4134,
570,
659,
9144,
31617,
29,
797,
430,
267,
291,
14,
26895,
8,
28559,
4720,
13284,
13151,
8,
277,
14,
8414,
12,
291,
14,
454,
360,
48,
1028,
370,
19013,
7058,
339,
347,
536,
8,
277,
304,
267,
372,
283,
20778,
84,
1308,
66,
7,
339,
347,
2929,
985,
8,
277,
304,
267,
372,
291,
14,
454,
360,
48,
1028,
370,
19013,
358,
339,
347,
1572,
8,
277,
304,
267,
372,
291,
14,
454,
360,
13284,
8603,
358,
339,
347,
1572,
1304,
8,
277,
304,
267,
372,
283,
20876,
15083,
7,
339,
347,
7016,
8,
277,
304,
267,
372,
1413,
8954,
8,
736,
14,
515,
14,
904,
8,
2718,
2042,
12,
283,
4782,
297,
283,
11600,
2537,
297,
283,
24,
13,
475,
13,
1194,
13,
5609,
14,
4524,
1333,
339,
347,
1414,
985,
8,
277,
304,
267,
372,
283,
20778,
18,
10090,
7,
339,
347,
664,
9270,
14680,
8,
277,
12,
2633,
12,
1067,
12,
17145,
12,
14043,
29,
549,
304,
267,
315,
5003,
275,
291,
14,
5329,
2822,
13284,
5003,
8,
3214,
12,
291,
14,
7321,
12,
1067,
9,
267,
340,
315,
5003,
365,
488,
26,
288,
746,
17214,
1726,
8,
277,
14,
3197,
13284,
547,
8,
3214,
12,
291,
14,
7321,
430,
398,
734,
275,
291,
14,
5329,
2822,
2959,
5003,
8,
3214,
12,
291,
14,
8414,
12,
1067,
9,
267,
291,
14,
409,
2959,
1110,
8,
277,
14,
8414,
12,
734,
9,
398,
2368,
275,
359,
288,
315,
5003,
14,
1365,
1062,
288,
734,
12,
288,
2475,
1618,
297,
288,
4888,
13284,
28199,
14,
3090,
1858,
6382,
8,
736,
14,
515,
14,
7973,
8,
548,
2788,
17,
2522,
288,
2475,
66,
297,
288,
620,
8,
277,
14,
5329,
2822,
3241,
8,
3214,
12,
291,
14,
23297,
12,
1067,
1826,
267,
1622,
398,
340,
291,
14,
5329,
2822,
4082,
8,
3214,
12,
291,
14,
21631,
12,
1067,
304,
288,
2368,
14,
740,
3654,
22118,
358,
398,
372,
359,
277,
14,
1531,
985,
342,
435,
23500,
13475,
7,
340,
365,
8647,
342,
587,
1987,
647,
659,
598,
12390,
7535,
14,
3765,
3325,
13005,
8,
4958,
1874,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
olefb/android_kernel_sony_msm8974
|
tools/perf/scripts/python/futex-contention.py
|
11261
|
1486
|
# futex contention
# (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com>
# Licensed under the terms of the GNU GPL License version 2
#
# Translation of:
#
# http://sourceware.org/systemtap/wiki/WSFutexContention
#
# to perf python scripting.
#
# Measures futex contention
import os, sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from Util import *
process_names = {}
thread_thislock = {}
thread_blocktime = {}
lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
process_names = {} # long-lived pid-to-execname mapping
def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, uaddr, op, val, utime, uaddr2, val3):
cmd = op & FUTEX_CMD_MASK
if cmd != FUTEX_WAIT:
return # we don't care about originators of WAKE events
process_names[tid] = comm
thread_thislock[tid] = uaddr
thread_blocktime[tid] = nsecs(s, ns)
def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, ret):
if thread_blocktime.has_key(tid):
elapsed = nsecs(s, ns) - thread_blocktime[tid]
add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
del thread_blocktime[tid]
del thread_thislock[tid]
def trace_begin():
print "Press control+C to stop and show the summary"
def trace_end():
for (tid, lock) in lock_waits:
min, max, avg, count = lock_waits[tid, lock]
print "%s[%d] lock %x contended %d times, %d avg ns" % \
(process_names[tid], tid, lock, count, avg)
|
gpl-2.0
|
[
3,
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0
] |
manjunaths/tensorflow
|
tensorflow/python/kernel_tests/atrous_conv2d_test.py
|
139
|
9770
|
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for convolution related functionality in tensorflow.ops.nn."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import gradient_checker
from tensorflow.python.ops import nn_impl
from tensorflow.python.ops import nn_ops
import tensorflow.python.ops.nn_grad # pylint: disable=unused-import
from tensorflow.python.platform import test
def _upsample_filters(filters, rate):
"""Upsamples the filters by a factor of rate along the spatial dimensions.
Args:
filters: [h, w, in_depth, out_depth]. Original filters.
rate: An int, specifying the upsampling rate.
Returns:
filters_up: [h_up, w_up, in_depth, out_depth]. Upsampled filters with
h_up = h + (h - 1) * (rate - 1)
w_up = w + (w - 1) * (rate - 1)
containing (rate - 1) zeros between consecutive filter values along
the filters' spatial dimensions.
"""
if rate == 1:
return filters
# [h, w, in_depth, out_depth] -> [in_depth, out_depth, h, w]
filters_up = np.transpose(filters, [2, 3, 0, 1])
ker = np.zeros([rate, rate], dtype=np.float32)
ker[0, 0] = 1
filters_up = np.kron(filters_up, ker)[:, :, :-(rate - 1), :-(rate - 1)]
# [in_depth, out_depth, h_up, w_up] -> [h_up, w_up, in_depth, out_depth]
filters_up = np.transpose(filters_up, [2, 3, 0, 1])
return filters_up
class AtrousConv2DTest(test.TestCase):
def testAtrousConv2DForward(self):
with self.test_session(use_gpu=True):
# Input: [batch, height, width, input_depth]
height = 9
for width in [9, 10]: # Test both odd and even width.
x_shape = [2, height, width, 2]
x = np.arange(np.prod(x_shape), dtype=np.float32).reshape(x_shape)
# Filter: [kernel_height, kernel_width, input_depth, output_depth]
for kernel_height in range(1, 4):
for kernel_width in range(1, 4):
f_shape = [kernel_height, kernel_width, 2, 2]
f = np.arange(np.prod(f_shape), dtype=np.float32).reshape(f_shape)
for rate in range(1, 4):
f_up = _upsample_filters(f, rate)
for padding in ["SAME", "VALID"]:
y1 = nn_ops.atrous_conv2d(x, f, rate, padding=padding)
y2 = nn_ops.conv2d(
x, f_up, strides=[1, 1, 1, 1], padding=padding)
self.assertAllClose(y1.eval(), y2.eval(), rtol=1e-3, atol=1e-3)
def testAtrousSequence(self):
"""Tests optimization of sequence of atrous convolutions.
Verifies that a sequence of `atrous_conv2d` operations with identical `rate`
parameters, 'SAME' `padding`, and `filters` with odd heights/ widths:
net = atrous_conv2d(net, filters1, rate, padding="SAME")
net = atrous_conv2d(net, filters2, rate, padding="SAME")
...
net = atrous_conv2d(net, filtersK, rate, padding="SAME")
is equivalent to:
pad = ... # padding so that the input dims are multiples of rate
net = space_to_batch(net, paddings=pad, block_size=rate)
net = conv2d(net, filters1, strides=[1, 1, 1, 1], padding="SAME")
net = conv2d(net, filters2, strides=[1, 1, 1, 1], padding="SAME")
...
net = conv2d(net, filtersK, strides=[1, 1, 1, 1], padding="SAME")
net = batch_to_space(net, crops=pad, block_size=rate)
"""
padding = "SAME" # The padding needs to be "SAME"
np.random.seed(1) # Make it reproducible.
with self.test_session(use_gpu=True):
# Input: [batch, height, width, input_depth]
for height in range(15, 17):
for width in range(15, 17):
x_shape = [3, height, width, 2]
x = np.random.random_sample(x_shape).astype(np.float32)
for kernel in [1, 3, 5]: # The kernel size needs to be odd.
# Filter: [kernel_height, kernel_width, input_depth, output_depth]
f_shape = [kernel, kernel, 2, 2]
f = 1e-2 * np.random.random_sample(f_shape).astype(np.float32)
for rate in range(2, 4):
# y1: three atrous_conv2d in a row.
y1 = nn_ops.atrous_conv2d(x, f, rate, padding=padding)
y1 = nn_ops.atrous_conv2d(y1, f, rate, padding=padding)
y1 = nn_ops.atrous_conv2d(y1, f, rate, padding=padding)
# y2: space_to_batch, three conv2d in a row, batch_to_space
pad_bottom = 0 if height % rate == 0 else rate - height % rate
pad_right = 0 if width % rate == 0 else rate - width % rate
pad = [[0, pad_bottom], [0, pad_right]]
y2 = array_ops.space_to_batch(x, paddings=pad, block_size=rate)
y2 = nn_ops.conv2d(y2, f, strides=[1, 1, 1, 1], padding=padding)
y2 = nn_ops.conv2d(y2, f, strides=[1, 1, 1, 1], padding=padding)
y2 = nn_ops.conv2d(y2, f, strides=[1, 1, 1, 1], padding=padding)
y2 = array_ops.batch_to_space(y2, crops=pad, block_size=rate)
self.assertAllClose(y1.eval(), y2.eval(), rtol=1e-2, atol=1e-2)
def testGradient(self):
with self.test_session(use_gpu=True):
# Input: [batch, height, width, input_depth]
x_shape = [2, 5, 6, 2]
# Filter: [kernel_height, kernel_width, input_depth, output_depth]
f_shape = [3, 3, 2, 2]
# Output: [batch, height, width, output_depth]
y_shape = [2, 5, 6, 2]
np.random.seed(1) # Make it reproducible.
x_val = np.random.random_sample(x_shape).astype(np.float32)
f_val = np.random.random_sample(f_shape).astype(np.float32)
x = constant_op.constant(x_val, name="x", dtype=dtypes.float32)
f = constant_op.constant(f_val, name="f", dtype=dtypes.float32)
for rate in range(1, 4):
output = nn_ops.atrous_conv2d(x, f, rate=rate, padding="SAME")
err = gradient_checker.compute_gradient_error([x, f],
[x_shape, f_shape],
output, y_shape)
print("atrous_conv2d gradient err = %g " % err)
err_tolerance = 1e-3
self.assertLess(err, err_tolerance)
class AtrousConv2DTransposeTest(test.TestCase):
def testAtrousConv2DTransposeForward(self):
with self.test_session(use_gpu=True):
# Input: [batch, height, width, input_depth]
height = 9
for width in [9, 10]: # Test both odd and even width.
x_shape = [2, height, width, 2]
x = np.arange(np.prod(x_shape), dtype=np.float32).reshape(x_shape)
# Filter: [kernel_height, kernel_width, input_depth, output_depth]
for kernel_height in range(1, 4):
for kernel_width in range(1, 4):
f_shape = [kernel_height, kernel_width, 2, 2]
f = np.arange(np.prod(f_shape), dtype=np.float32).reshape(f_shape)
for rate in range(1, 4):
f_up = _upsample_filters(f, rate)
kernel_height_up = (kernel_height + (kernel_height - 1) *
(rate - 1))
kernel_width_up = kernel_width + (kernel_width - 1) * (rate - 1)
for padding in ["SAME", "VALID"]:
if padding == "SAME":
y_shape = [2, height, width, 2]
else:
y_shape = [
2, height + kernel_height_up - 1,
width + kernel_width_up - 1, 2
]
y1 = nn_ops.atrous_conv2d_transpose(x, f, y_shape, rate,
padding)
y2 = nn_ops.conv2d_transpose(
x, f_up, y_shape, strides=[1, 1, 1, 1], padding=padding)
self.assertAllClose(y1.eval(), y2.eval(), rtol=1e-3, atol=1e-3)
class AtrousDepthwiseConv2DTest(test.TestCase):
def testAtrousDepthwiseConv2DForward(self):
strides = [1, 1, 1, 1]
with self.test_session(use_gpu=True):
# Input: [batch, height, width, input_depth]
height = 9
for width in [9, 10]: # Test both odd and even width.
x_shape = [2, height, width, 2]
x = np.arange(np.prod(x_shape), dtype=np.float32).reshape(x_shape)
# Filter: [kernel_height, kernel_width, input_depth, output_depth]
for kernel_height in range(1, 4):
for kernel_width in range(1, 4):
f_shape = [kernel_height, kernel_width, 2, 2]
f = np.arange(np.prod(f_shape), dtype=np.float32).reshape(f_shape)
for rate in range(1, 4):
f_up = _upsample_filters(f, rate)
for padding in ["SAME", "VALID"]:
y1 = nn_impl.depthwise_conv2d(
x, f, strides, padding, rate=[rate, rate])
y2 = nn_impl.depthwise_conv2d(x, f_up, strides, padding)
self.assertAllClose(y1.eval(), y2.eval(), rtol=1e-3, atol=1e-3)
if __name__ == "__main__":
test.main()
|
apache-2.0
|
[
3,
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
17461,
4048,
9330,
315,
3228,
14,
1483,
14,
4411,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
5472,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
1483,
199,
646,
3228,
14,
1548,
14,
1483,
14,
4411,
63,
6017,
221,
327,
4287,
26,
3507,
29,
8618,
13,
646,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
318,
485,
384,
3271,
63,
4273,
8,
4273,
12,
6634,
304,
523,
408,
53,
1190,
1889,
314,
4766,
701,
282,
6535,
402,
6634,
3180,
314,
11469,
7365,
14,
819,
3033,
26,
272,
4766,
26,
359,
72,
12,
336,
12,
315,
63,
4631,
12,
734,
63,
4631,
1055,
12769,
4766,
14,
272,
6634,
26,
1626,
1109,
12,
9176,
314,
1536,
17376,
6634,
14,
819,
1803,
26,
272,
4766,
63,
384,
26,
359,
72,
63,
384,
12,
336,
63,
384,
12,
315,
63,
4631,
12,
734,
63,
4631,
1055,
738,
1190,
865,
68,
4766,
543,
489,
394,
63,
384,
275,
394,
435,
334,
72,
446,
413,
9,
627,
334,
1866,
446,
413,
9,
489,
336,
63,
384,
275,
336,
435,
334,
87,
446,
413,
9,
627,
334,
1866,
446,
413,
9,
489,
3035,
334,
1866,
446,
413,
9,
10136,
3382,
23376,
2457,
1338,
3180,
489,
314,
4766,
7,
11469,
7365,
14,
523,
408,
523,
340,
6634,
508,
413,
26,
272,
372,
4766,
523,
327,
359,
72,
12,
336,
12,
315,
63,
4631,
12,
734,
63,
4631,
61,
1035,
359,
262,
63,
4631,
12,
734,
63,
4631,
12,
394,
12,
336,
61,
523,
4766,
63,
384,
275,
980,
14,
10483,
8,
4273,
12,
359,
18,
12,
650,
12,
378,
12,
413,
566,
523,
4303,
275,
980,
14,
4250,
779,
1866,
12,
6634,
467,
2152,
29,
1590,
14,
1609,
708,
9,
523,
4303,
59,
16,
12,
378,
61,
275,
413,
523,
4766,
63,
384,
275,
980,
14,
75,
2641,
8,
4273,
63,
384,
12,
4303,
24517,
13785,
520,
15426,
1866,
446,
413,
395,
520,
15426,
1866,
446,
413,
1874,
523,
327,
359,
262,
63,
4631,
12,
734,
63,
4631,
12,
394,
63,
384,
12,
336,
63,
384,
61,
1035,
359,
72,
63,
384,
12,
336,
63,
384,
12,
315,
63,
4631,
12,
734,
63,
4631,
61,
523,
4766,
63,
384,
275,
980,
14,
10483,
8,
4273,
63,
384,
12,
359,
18,
12,
650,
12,
378,
12,
413,
566,
523,
372,
4766,
63,
384,
421,
199,
533,
437,
1374,
527,
11596,
18,
36,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
1271,
293,
527,
11596,
18,
36,
12984,
8,
277,
304,
272,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
489,
327,
6924,
26,
359,
2912,
12,
4569,
12,
3462,
12,
1324,
63,
4631,
61,
489,
4569,
275,
1749,
489,
367,
3462,
315,
359,
25,
12,
1616,
2189,
221,
327,
1379,
3865,
16699,
436,
2755,
3462,
14,
267,
671,
63,
1392,
275,
359,
18,
12,
4569,
12,
3462,
12,
499,
61,
267,
671,
275,
980,
14,
5605,
8,
1590,
14,
8788,
8,
88,
63,
1392,
395,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
88,
63,
1392,
9,
398,
327,
9388,
26,
359,
4989,
63,
3333,
12,
5114,
63,
2063,
12,
1324,
63,
4631,
12,
1072,
63,
4631,
61,
267,
367,
5114,
63,
3333,
315,
1425,
8,
17,
12,
841,
304,
881,
367,
5114,
63,
2063,
315,
1425,
8,
17,
12,
841,
304,
288,
289,
63,
1392,
275,
359,
4989,
63,
3333,
12,
5114,
63,
2063,
12,
499,
12,
499,
61,
288,
289,
275,
980,
14,
5605,
8,
1590,
14,
8788,
8,
70,
63,
1392,
395,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
70,
63,
1392,
9,
953,
367,
6634,
315,
1425,
8,
17,
12,
841,
304,
1598,
289,
63,
384,
275,
485,
384,
3271,
63,
4273,
8,
70,
12,
6634,
9,
25841,
367,
6273,
315,
2097,
19935,
401,
298,
5600,
6229,
355,
612,
17,
275,
11542,
63,
1483,
14,
292,
293,
527,
63,
5598,
18,
68,
8,
88,
12,
289,
12,
6634,
12,
6273,
29,
8358,
9,
355,
612,
18,
275,
11542,
63,
1483,
14,
5598,
18,
68,
8,
490,
671,
12,
289,
63,
384,
12,
11883,
1524,
17,
12,
413,
12,
413,
12,
413,
467,
6273,
29,
8358,
9,
355,
291,
14,
7260,
8,
89,
17,
14,
2579,
1062,
612,
18,
14,
2579,
1062,
10561,
29,
17,
69,
13,
19,
12,
9543,
29,
17,
69,
13,
19,
9,
819,
347,
511,
1271,
293,
527,
5826,
8,
277,
304,
272,
408,
2925,
13712,
402,
3414,
402,
737,
293,
527,
406,
5650,
8653,
14,
339,
26114,
626,
282,
3414,
402,
658,
292,
293,
527,
63,
5598,
18,
68,
64,
5331,
543,
13130,
658,
1866,
64,
272,
2633,
12,
283,
19935,
7,
658,
8358,
3559,
436,
658,
4273,
64,
543,
16699,
946,
2492,
15,
28186,
26,
398,
1851,
275,
737,
293,
527,
63,
5598
] |
[
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
17461,
4048,
9330,
315,
3228,
14,
1483,
14,
4411,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
5472,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
1483,
199,
646,
3228,
14,
1548,
14,
1483,
14,
4411,
63,
6017,
221,
327,
4287,
26,
3507,
29,
8618,
13,
646,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
318,
485,
384,
3271,
63,
4273,
8,
4273,
12,
6634,
304,
523,
408,
53,
1190,
1889,
314,
4766,
701,
282,
6535,
402,
6634,
3180,
314,
11469,
7365,
14,
819,
3033,
26,
272,
4766,
26,
359,
72,
12,
336,
12,
315,
63,
4631,
12,
734,
63,
4631,
1055,
12769,
4766,
14,
272,
6634,
26,
1626,
1109,
12,
9176,
314,
1536,
17376,
6634,
14,
819,
1803,
26,
272,
4766,
63,
384,
26,
359,
72,
63,
384,
12,
336,
63,
384,
12,
315,
63,
4631,
12,
734,
63,
4631,
1055,
738,
1190,
865,
68,
4766,
543,
489,
394,
63,
384,
275,
394,
435,
334,
72,
446,
413,
9,
627,
334,
1866,
446,
413,
9,
489,
336,
63,
384,
275,
336,
435,
334,
87,
446,
413,
9,
627,
334,
1866,
446,
413,
9,
489,
3035,
334,
1866,
446,
413,
9,
10136,
3382,
23376,
2457,
1338,
3180,
489,
314,
4766,
7,
11469,
7365,
14,
523,
408,
523,
340,
6634,
508,
413,
26,
272,
372,
4766,
523,
327,
359,
72,
12,
336,
12,
315,
63,
4631,
12,
734,
63,
4631,
61,
1035,
359,
262,
63,
4631,
12,
734,
63,
4631,
12,
394,
12,
336,
61,
523,
4766,
63,
384,
275,
980,
14,
10483,
8,
4273,
12,
359,
18,
12,
650,
12,
378,
12,
413,
566,
523,
4303,
275,
980,
14,
4250,
779,
1866,
12,
6634,
467,
2152,
29,
1590,
14,
1609,
708,
9,
523,
4303,
59,
16,
12,
378,
61,
275,
413,
523,
4766,
63,
384,
275,
980,
14,
75,
2641,
8,
4273,
63,
384,
12,
4303,
24517,
13785,
520,
15426,
1866,
446,
413,
395,
520,
15426,
1866,
446,
413,
1874,
523,
327,
359,
262,
63,
4631,
12,
734,
63,
4631,
12,
394,
63,
384,
12,
336,
63,
384,
61,
1035,
359,
72,
63,
384,
12,
336,
63,
384,
12,
315,
63,
4631,
12,
734,
63,
4631,
61,
523,
4766,
63,
384,
275,
980,
14,
10483,
8,
4273,
63,
384,
12,
359,
18,
12,
650,
12,
378,
12,
413,
566,
523,
372,
4766,
63,
384,
421,
199,
533,
437,
1374,
527,
11596,
18,
36,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
1271,
293,
527,
11596,
18,
36,
12984,
8,
277,
304,
272,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
489,
327,
6924,
26,
359,
2912,
12,
4569,
12,
3462,
12,
1324,
63,
4631,
61,
489,
4569,
275,
1749,
489,
367,
3462,
315,
359,
25,
12,
1616,
2189,
221,
327,
1379,
3865,
16699,
436,
2755,
3462,
14,
267,
671,
63,
1392,
275,
359,
18,
12,
4569,
12,
3462,
12,
499,
61,
267,
671,
275,
980,
14,
5605,
8,
1590,
14,
8788,
8,
88,
63,
1392,
395,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
88,
63,
1392,
9,
398,
327,
9388,
26,
359,
4989,
63,
3333,
12,
5114,
63,
2063,
12,
1324,
63,
4631,
12,
1072,
63,
4631,
61,
267,
367,
5114,
63,
3333,
315,
1425,
8,
17,
12,
841,
304,
881,
367,
5114,
63,
2063,
315,
1425,
8,
17,
12,
841,
304,
288,
289,
63,
1392,
275,
359,
4989,
63,
3333,
12,
5114,
63,
2063,
12,
499,
12,
499,
61,
288,
289,
275,
980,
14,
5605,
8,
1590,
14,
8788,
8,
70,
63,
1392,
395,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
70,
63,
1392,
9,
953,
367,
6634,
315,
1425,
8,
17,
12,
841,
304,
1598,
289,
63,
384,
275,
485,
384,
3271,
63,
4273,
8,
70,
12,
6634,
9,
25841,
367,
6273,
315,
2097,
19935,
401,
298,
5600,
6229,
355,
612,
17,
275,
11542,
63,
1483,
14,
292,
293,
527,
63,
5598,
18,
68,
8,
88,
12,
289,
12,
6634,
12,
6273,
29,
8358,
9,
355,
612,
18,
275,
11542,
63,
1483,
14,
5598,
18,
68,
8,
490,
671,
12,
289,
63,
384,
12,
11883,
1524,
17,
12,
413,
12,
413,
12,
413,
467,
6273,
29,
8358,
9,
355,
291,
14,
7260,
8,
89,
17,
14,
2579,
1062,
612,
18,
14,
2579,
1062,
10561,
29,
17,
69,
13,
19,
12,
9543,
29,
17,
69,
13,
19,
9,
819,
347,
511,
1271,
293,
527,
5826,
8,
277,
304,
272,
408,
2925,
13712,
402,
3414,
402,
737,
293,
527,
406,
5650,
8653,
14,
339,
26114,
626,
282,
3414,
402,
658,
292,
293,
527,
63,
5598,
18,
68,
64,
5331,
543,
13130,
658,
1866,
64,
272,
2633,
12,
283,
19935,
7,
658,
8358,
3559,
436,
658,
4273,
64,
543,
16699,
946,
2492,
15,
28186,
26,
398,
1851,
275,
737,
293,
527,
63,
5598,
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,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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
] |
mbauskar/tele-frappe
|
frappe/core/page/user_permissions/user_permissions.py
|
32
|
3613
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
import frappe.defaults
import frappe.permissions
from frappe.core.doctype.user.user import get_system_users
from frappe.utils.csvutils import UnicodeWriter, read_csv_content_from_uploaded_file
from frappe.defaults import clear_default
@frappe.whitelist()
def get_users_and_links():
return {
"users": get_system_users(),
"link_fields": get_doctypes_for_user_permissions()
}
@frappe.whitelist()
def get_permissions(parent=None, defkey=None, defvalue=None):
if defkey and not frappe.permissions.can_set_user_permissions(defkey, defvalue):
raise frappe.PermissionError
conditions, values = _build_conditions(locals())
permissions = frappe.db.sql("""select name, parent, defkey, defvalue
from tabDefaultValue
where parent not in ('__default', '__global')
and substr(defkey,1,1)!='_'
and parenttype='User Permission'
{conditions}
order by parent, defkey""".format(conditions=conditions), values, as_dict=True)
if not defkey:
out = []
doctypes = get_doctypes_for_user_permissions()
for p in permissions:
if p.defkey in doctypes:
out.append(p)
permissions = out
return permissions
def _build_conditions(filters):
conditions = []
values = {}
for key, value in filters.items():
if filters.get(key):
conditions.append("and `{key}`=%({key})s".format(key=key))
values[key] = value
return "\n".join(conditions), values
@frappe.whitelist()
def remove(user, name, defkey, defvalue):
if not frappe.permissions.can_set_user_permissions(defkey, defvalue):
frappe.throw(_("Cannot remove permission for DocType: {0} and Name: {1}").format(
defkey, defvalue), frappe.PermissionError)
frappe.permissions.remove_user_permission(defkey, defvalue, user, name)
@frappe.whitelist()
def add(user, defkey, defvalue):
if not frappe.permissions.can_set_user_permissions(defkey, defvalue):
frappe.throw(_("Cannot set permission for DocType: {0} and Name: {1}").format(
defkey, defvalue), frappe.PermissionError)
frappe.permissions.add_user_permission(defkey, defvalue, user, with_message=True)
def get_doctypes_for_user_permissions():
user_roles = frappe.get_roles()
condition = ""
values = []
if "System Manager" not in user_roles:
condition = """and exists(select `tabDocPerm`.name from `tabDocPerm`
where `tabDocPerm`.parent=`tabDocType`.name and `tabDocPerm`.`set_user_permissions`=1
and `tabDocPerm`.role in ({roles}))""".format(roles=", ".join(["%s"]*len(user_roles)))
values = user_roles
return frappe.db.sql_list("""select name from tabDocType
where ifnull(issingle,0)=0 and ifnull(istable,0)=0 {condition}""".format(condition=condition),
tuple(values))
@frappe.whitelist()
def get_user_permissions_csv():
out = [["User Permissions"], ["User", "Document Type", "Value"]]
out += [[a.parent, a.defkey, a.defvalue] for a in get_permissions()]
csv = UnicodeWriter()
for row in out:
csv.writerow(row)
frappe.response['result'] = str(csv.getvalue())
frappe.response['type'] = 'csv'
frappe.response['doctype'] = "User Permissions"
@frappe.whitelist()
def import_user_permissions():
frappe.only_for("System Manager")
rows = read_csv_content_from_uploaded_file(ignore_encoding=True)
clear_default(parenttype="User Permission")
if rows[0][0]!="User Permissions" and rows[1][0] != "User":
frappe.throw(frappe._("Please upload using the same template as download."))
for row in rows[2:]:
frappe.permissions.add_user_permission(row[1], row[2], row[0])
|
mit
|
[
3,
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
10697,
844,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
504,
6950,
492,
485,
199,
646,
6950,
14,
4322,
199,
646,
6950,
14,
6060,
199,
504,
6950,
14,
1018,
14,
6356,
14,
751,
14,
751,
492,
664,
63,
2253,
63,
3707,
199,
504,
6950,
14,
1208,
14,
4737,
1208,
492,
6140,
6261,
12,
1586,
63,
4737,
63,
1317,
63,
504,
63,
19044,
63,
493,
199,
504,
6950,
14,
4322,
492,
5436,
63,
885,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
3707,
63,
460,
63,
4614,
837,
199,
198,
1107,
469,
507,
198,
2,
3707,
582,
664,
63,
2253,
63,
3707,
1062,
507,
198,
2,
1073,
63,
955,
582,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
342,
199,
198,
93,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
6060,
8,
1708,
29,
403,
12,
347,
498,
29,
403,
12,
347,
585,
29,
403,
304,
199,
198,
692,
347,
498,
436,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
3730,
6950,
14,
7980,
547,
421,
198,
9855,
12,
1338,
275,
485,
1506,
63,
9855,
8,
9350,
1012,
421,
198,
6060,
275,
6950,
14,
697,
14,
3009,
4852,
2416,
536,
12,
1676,
12,
347,
498,
12,
347,
585,
507,
198,
504,
5174,
2698,
1110,
507,
198,
4509,
1676,
440,
315,
25038,
885,
297,
2560,
2966,
358,
507,
198,
460,
1007,
495,
8,
318,
498,
12,
17,
12,
17,
9,
27909,
8650,
507,
198,
460,
1676,
466,
534,
1899,
8779,
7,
507,
198,
91,
9855,
93,
507,
198,
1648,
701,
1676,
12,
347,
498,
23045,
908,
8,
9855,
29,
9855,
395,
1338,
12,
465,
63,
807,
29,
549,
9,
421,
198,
692,
440,
347,
498,
26,
507,
198,
548,
275,
942,
507,
198,
6356,
83,
275,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
342,
507,
198,
509,
299,
315,
3443,
26,
686,
198,
692,
299,
14,
318,
498,
315,
886,
9798,
26,
1585,
198,
548,
14,
740,
8,
80,
9,
507,
198,
6060,
275,
734,
421,
198,
1107,
3443,
199,
199,
318,
485,
1506,
63,
9855,
8,
4273,
304,
199,
198,
9855,
275,
942,
199,
198,
1459,
275,
1052,
199,
198,
509,
790,
12,
574,
315,
4766,
14,
1744,
837,
507,
198,
692,
4766,
14,
362,
8,
498,
304,
686,
198,
9855,
14,
740,
480,
460,
658,
91,
498,
23485,
2458,
2561,
498,
1552,
83,
1674,
908,
8,
498,
29,
498,
430,
686,
198,
1459,
59,
498,
61,
275,
574,
421,
198,
1107,
1867,
78,
1674,
904,
8,
9855,
395,
1338,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
2813,
8,
751,
12,
536,
12,
347,
498,
12,
347,
585,
304,
199,
198,
692,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
9098,
14,
11964,
6115,
6612,
2813,
4983,
367,
5454,
804,
26,
469,
16,
93,
436,
2812,
26,
469,
17,
30273,
908,
8,
686,
198,
318,
498,
12,
347,
585,
395,
6950,
14,
7980,
547,
9,
421,
198,
9098,
14,
6060,
14,
2168,
63,
751,
63,
5693,
8,
318,
498,
12,
347,
585,
12,
922,
12,
536,
9,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
1050,
8,
751,
12,
347,
498,
12,
347,
585,
304,
199,
198,
692,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
9098,
14,
11964,
6115,
6612,
663,
4983,
367,
5454,
804,
26,
469,
16,
93,
436,
2812,
26,
469,
17,
30273,
908,
8,
686,
198,
318,
498,
12,
347,
585,
395,
6950,
14,
7980,
547,
9,
421,
198,
9098,
14,
6060,
14,
525,
63,
751,
63,
5693,
8,
318,
498,
12,
347,
585,
12,
922,
12,
543,
63,
1188,
29,
549,
9,
199,
199,
318,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
837,
199,
198,
751,
63,
8050,
275,
6950,
14,
362,
63,
8050,
342,
199,
198,
5394,
275,
3087,
199,
198,
1459,
275,
942,
199,
198,
692,
298,
3989,
13537,
2,
440,
315,
922,
63,
8050,
26,
507,
198,
5394,
275,
408,
460,
3495,
8,
2416,
658,
2902,
3768,
23554,
2313,
354,
687,
658,
2902,
3768,
23554,
64,
686,
198,
4509,
658,
2902,
3768,
23554,
2313,
1708,
29,
64,
2902,
3768,
804,
2313,
354,
436,
658,
2902,
3768,
23554,
2313,
64,
409,
63,
751,
63,
6060,
64,
29,
17,
686,
198,
460,
658,
2902,
3768,
23554,
2313,
3756,
315,
11459,
8050,
12466,
23045,
908,
8,
8050,
11107,
3680,
904,
30387,
83,
937,
10,
552,
8,
751,
63,
8050,
1724,
507,
198,
1459,
275,
922,
63,
8050,
421,
198,
1107,
6950,
14,
697,
14,
3009,
63,
513,
4852,
2416,
536,
687,
5174,
3768,
804,
507,
198,
4509,
340,
2307,
8,
374,
4780,
12,
16,
23397,
16,
436,
340,
2307,
8,
631,
461,
12,
16,
23397,
16,
469,
5394,
93,
23045,
908,
8,
5394,
29,
5394,
395,
507,
198,
2960,
8,
1459,
430,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
751,
63,
6060,
63,
4737,
837,
199,
198,
548,
275,
24212,
1899,
28260,
2255,
2097,
1899,
401,
298,
5564,
2434,
401,
298,
1110,
15261,
199,
198,
548,
847,
3474,
65,
14,
1708,
12,
282,
14,
318,
498,
12,
282,
14,
318,
585,
61,
367,
282,
315,
664,
63,
6060,
5106,
421,
198,
4737,
275,
6140,
6261,
342,
199,
198,
509,
1962,
315,
734,
26,
507,
198,
4737,
14,
22686,
8,
1143,
9,
421,
198,
9098,
14,
1310,
459,
1099,
418,
275,
620,
8,
4737,
14,
7150,
1012,
199,
198,
9098,
14,
1310,
459,
466,
418,
275,
283,
4737,
7,
199,
198,
9098,
14,
1310,
459,
6356,
418,
275,
298,
1899,
28260,
2,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
492,
63,
751,
63,
6060,
837,
199,
198,
9098,
14,
2118,
63,
509,
480,
3989,
13537,
531,
199,
198,
3838,
275,
1586,
63,
4737,
63,
1317,
63,
504,
63,
19044,
63
] |
[
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
10697,
844,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
504,
6950,
492,
485,
199,
646,
6950,
14,
4322,
199,
646,
6950,
14,
6060,
199,
504,
6950,
14,
1018,
14,
6356,
14,
751,
14,
751,
492,
664,
63,
2253,
63,
3707,
199,
504,
6950,
14,
1208,
14,
4737,
1208,
492,
6140,
6261,
12,
1586,
63,
4737,
63,
1317,
63,
504,
63,
19044,
63,
493,
199,
504,
6950,
14,
4322,
492,
5436,
63,
885,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
3707,
63,
460,
63,
4614,
837,
199,
198,
1107,
469,
507,
198,
2,
3707,
582,
664,
63,
2253,
63,
3707,
1062,
507,
198,
2,
1073,
63,
955,
582,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
342,
199,
198,
93,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
6060,
8,
1708,
29,
403,
12,
347,
498,
29,
403,
12,
347,
585,
29,
403,
304,
199,
198,
692,
347,
498,
436,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
3730,
6950,
14,
7980,
547,
421,
198,
9855,
12,
1338,
275,
485,
1506,
63,
9855,
8,
9350,
1012,
421,
198,
6060,
275,
6950,
14,
697,
14,
3009,
4852,
2416,
536,
12,
1676,
12,
347,
498,
12,
347,
585,
507,
198,
504,
5174,
2698,
1110,
507,
198,
4509,
1676,
440,
315,
25038,
885,
297,
2560,
2966,
358,
507,
198,
460,
1007,
495,
8,
318,
498,
12,
17,
12,
17,
9,
27909,
8650,
507,
198,
460,
1676,
466,
534,
1899,
8779,
7,
507,
198,
91,
9855,
93,
507,
198,
1648,
701,
1676,
12,
347,
498,
23045,
908,
8,
9855,
29,
9855,
395,
1338,
12,
465,
63,
807,
29,
549,
9,
421,
198,
692,
440,
347,
498,
26,
507,
198,
548,
275,
942,
507,
198,
6356,
83,
275,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
342,
507,
198,
509,
299,
315,
3443,
26,
686,
198,
692,
299,
14,
318,
498,
315,
886,
9798,
26,
1585,
198,
548,
14,
740,
8,
80,
9,
507,
198,
6060,
275,
734,
421,
198,
1107,
3443,
199,
199,
318,
485,
1506,
63,
9855,
8,
4273,
304,
199,
198,
9855,
275,
942,
199,
198,
1459,
275,
1052,
199,
198,
509,
790,
12,
574,
315,
4766,
14,
1744,
837,
507,
198,
692,
4766,
14,
362,
8,
498,
304,
686,
198,
9855,
14,
740,
480,
460,
658,
91,
498,
23485,
2458,
2561,
498,
1552,
83,
1674,
908,
8,
498,
29,
498,
430,
686,
198,
1459,
59,
498,
61,
275,
574,
421,
198,
1107,
1867,
78,
1674,
904,
8,
9855,
395,
1338,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
2813,
8,
751,
12,
536,
12,
347,
498,
12,
347,
585,
304,
199,
198,
692,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
9098,
14,
11964,
6115,
6612,
2813,
4983,
367,
5454,
804,
26,
469,
16,
93,
436,
2812,
26,
469,
17,
30273,
908,
8,
686,
198,
318,
498,
12,
347,
585,
395,
6950,
14,
7980,
547,
9,
421,
198,
9098,
14,
6060,
14,
2168,
63,
751,
63,
5693,
8,
318,
498,
12,
347,
585,
12,
922,
12,
536,
9,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
1050,
8,
751,
12,
347,
498,
12,
347,
585,
304,
199,
198,
692,
440,
6950,
14,
6060,
14,
2425,
63,
409,
63,
751,
63,
6060,
8,
318,
498,
12,
347,
585,
304,
507,
198,
9098,
14,
11964,
6115,
6612,
663,
4983,
367,
5454,
804,
26,
469,
16,
93,
436,
2812,
26,
469,
17,
30273,
908,
8,
686,
198,
318,
498,
12,
347,
585,
395,
6950,
14,
7980,
547,
9,
421,
198,
9098,
14,
6060,
14,
525,
63,
751,
63,
5693,
8,
318,
498,
12,
347,
585,
12,
922,
12,
543,
63,
1188,
29,
549,
9,
199,
199,
318,
664,
63,
6356,
83,
63,
509,
63,
751,
63,
6060,
837,
199,
198,
751,
63,
8050,
275,
6950,
14,
362,
63,
8050,
342,
199,
198,
5394,
275,
3087,
199,
198,
1459,
275,
942,
199,
198,
692,
298,
3989,
13537,
2,
440,
315,
922,
63,
8050,
26,
507,
198,
5394,
275,
408,
460,
3495,
8,
2416,
658,
2902,
3768,
23554,
2313,
354,
687,
658,
2902,
3768,
23554,
64,
686,
198,
4509,
658,
2902,
3768,
23554,
2313,
1708,
29,
64,
2902,
3768,
804,
2313,
354,
436,
658,
2902,
3768,
23554,
2313,
64,
409,
63,
751,
63,
6060,
64,
29,
17,
686,
198,
460,
658,
2902,
3768,
23554,
2313,
3756,
315,
11459,
8050,
12466,
23045,
908,
8,
8050,
11107,
3680,
904,
30387,
83,
937,
10,
552,
8,
751,
63,
8050,
1724,
507,
198,
1459,
275,
922,
63,
8050,
421,
198,
1107,
6950,
14,
697,
14,
3009,
63,
513,
4852,
2416,
536,
687,
5174,
3768,
804,
507,
198,
4509,
340,
2307,
8,
374,
4780,
12,
16,
23397,
16,
436,
340,
2307,
8,
631,
461,
12,
16,
23397,
16,
469,
5394,
93,
23045,
908,
8,
5394,
29,
5394,
395,
507,
198,
2960,
8,
1459,
430,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
664,
63,
751,
63,
6060,
63,
4737,
837,
199,
198,
548,
275,
24212,
1899,
28260,
2255,
2097,
1899,
401,
298,
5564,
2434,
401,
298,
1110,
15261,
199,
198,
548,
847,
3474,
65,
14,
1708,
12,
282,
14,
318,
498,
12,
282,
14,
318,
585,
61,
367,
282,
315,
664,
63,
6060,
5106,
421,
198,
4737,
275,
6140,
6261,
342,
199,
198,
509,
1962,
315,
734,
26,
507,
198,
4737,
14,
22686,
8,
1143,
9,
421,
198,
9098,
14,
1310,
459,
1099,
418,
275,
620,
8,
4737,
14,
7150,
1012,
199,
198,
9098,
14,
1310,
459,
466,
418,
275,
283,
4737,
7,
199,
198,
9098,
14,
1310,
459,
6356,
418,
275,
298,
1899,
28260,
2,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
492,
63,
751,
63,
6060,
837,
199,
198,
9098,
14,
2118,
63,
509,
480,
3989,
13537,
531,
199,
198,
3838,
275,
1586,
63,
4737,
63,
1317,
63,
504,
63,
19044,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
thinkopensolutions/odoo-brazil-banking
|
l10n_br_cnab400_import/models/account_bank_statement.py
|
3
|
2484
|
# -*- coding: utf-8 -*-
##############################################################################
#
# This module copyright (C) 2016 KMEE INFORMATICA LTDA
# (<http://kmee.com.br>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from decimal import Decimal
from openerp import models, api, _
from openerp.tools.float_utils import float_repr
from openerp.exceptions import Warning as UserError
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
@api.model
def get_reconcile_lines_from_cnab_move(self, this, excluded_ids=None):
"""return move.line to reconcile with statement line"""
move_lines = self.env['account.move.line'].search(
[('transaction_ref', '=', this.name),
('name', '=', this.ref)
])
try:
assert len(move_lines) <= 1
except:
raise UserError(_(
"Erro!\n "
"Nosso numero duplicado"
))
return self.env['account.move.line']\
.prepare_move_lines_for_reconciliation_widget(move_lines)
@api.model
def get_reconciliation_proposition(self, this, excluded_ids=None):
"""See if we find a set payment order that matches our line. If yes,
return all unreconciled lines from there"""
reconcile_lines = self.get_reconcile_lines_from_cnab_move(
this, excluded_ids=None)
if reconcile_lines:
return reconcile_lines
elif this.bank_account_id.state == "cnab":
return []
else:
return super(AccountBankStatementLine, self)\
.get_reconciliation_proposition(this, excluded_ids=excluded_ids)
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
7800,
1804,
3635,
37,
1621,
4807,
948,
33,
491,
52,
8980,
199,
3,
3698,
8642,
1014,
921,
75,
278,
69,
14,
957,
14,
3289,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
504,
6107,
492,
6345,
199,
504,
5166,
492,
1709,
12,
2986,
12,
485,
199,
504,
5166,
14,
2537,
14,
1609,
63,
1208,
492,
2069,
63,
2722,
199,
504,
5166,
14,
3924,
492,
15902,
465,
29908,
421,
199,
533,
9973,
14814,
15173,
3049,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2048,
14,
9860,
14,
6242,
14,
604,
7,
339,
768,
1246,
14,
1238,
272,
347,
664,
63,
18403,
63,
1278,
63,
504,
63,
6413,
371,
63,
1185,
8,
277,
12,
642,
12,
8789,
63,
1580,
29,
403,
304,
267,
408,
1107,
4057,
14,
604,
370,
26053,
441,
543,
5164,
1004,
624,
267,
4057,
63,
1278,
275,
291,
14,
1813,
459,
2048,
14,
1185,
14,
604,
2278,
1733,
8,
355,
4274,
5945,
63,
1121,
297,
6291,
642,
14,
354,
395,
326,
661,
354,
297,
6291,
642,
14,
1121,
9,
326,
4794,
267,
862,
26,
288,
702,
822,
8,
1185,
63,
1278,
9,
2695,
413,
267,
871,
26,
288,
746,
29908,
27594,
717,
298,
539,
293,
12525,
78,
298,
717,
298,
1944,
25479,
10330,
293,
366,
4230,
5129,
2,
490,
5082,
267,
372,
291,
14,
1813,
459,
2048,
14,
1185,
14,
604,
418,
60,
288,
1275,
6726,
63,
1185,
63,
1278,
63,
509,
63,
25981,
29685,
63,
3440,
8,
1185,
63,
1278,
9,
339,
768,
1246,
14,
1238,
272,
347,
664,
63,
25981,
29685,
63,
496,
3124,
8,
277,
12,
642,
12,
8789,
63,
1580,
29,
403,
304,
267,
408,
9295,
340,
781,
2342,
282,
663,
11628,
1865,
626,
4450,
4154,
1004,
14,
982,
9456,
12,
267,
372,
1006,
625,
14808,
1672,
2385,
687,
2337,
624,
398,
26053,
441,
63,
1278,
275,
291,
14,
362,
63,
18403,
63,
1278,
63,
504,
63,
6413,
371,
63,
1185,
8,
288,
642,
12,
8789,
63,
1580,
29,
403,
9,
267,
340,
26053,
441,
63,
1278,
26,
288,
372,
26053,
441,
63,
1278,
267,
916,
642,
14,
9860,
63,
2048,
63,
344,
14,
929,
508,
298,
6413,
371,
582,
288,
372,
942,
267,
587,
26,
288,
372,
1613,
8,
6009,
14814,
15173,
3049,
12,
291,
2862,
1598,
1275,
362,
63,
25981,
29685,
63,
496,
3124,
8,
3749,
12,
8789,
63,
1580,
29,
12144,
63,
1580,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
7800,
1804,
3635,
37,
1621,
4807,
948,
33,
491,
52,
8980,
199,
3,
3698,
8642,
1014,
921,
75,
278,
69,
14,
957,
14,
3289,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
504,
6107,
492,
6345,
199,
504,
5166,
492,
1709,
12,
2986,
12,
485,
199,
504,
5166,
14,
2537,
14,
1609,
63,
1208,
492,
2069,
63,
2722,
199,
504,
5166,
14,
3924,
492,
15902,
465,
29908,
421,
199,
533,
9973,
14814,
15173,
3049,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
2048,
14,
9860,
14,
6242,
14,
604,
7,
339,
768,
1246,
14,
1238,
272,
347,
664,
63,
18403,
63,
1278,
63,
504,
63,
6413,
371,
63,
1185,
8,
277,
12,
642,
12,
8789,
63,
1580,
29,
403,
304,
267,
408,
1107,
4057,
14,
604,
370,
26053,
441,
543,
5164,
1004,
624,
267,
4057,
63,
1278,
275,
291,
14,
1813,
459,
2048,
14,
1185,
14,
604,
2278,
1733,
8,
355,
4274,
5945,
63,
1121,
297,
6291,
642,
14,
354,
395,
326,
661,
354,
297,
6291,
642,
14,
1121,
9,
326,
4794,
267,
862,
26,
288,
702,
822,
8,
1185,
63,
1278,
9,
2695,
413,
267,
871,
26,
288,
746,
29908,
27594,
717,
298,
539,
293,
12525,
78,
298,
717,
298,
1944,
25479,
10330,
293,
366,
4230,
5129,
2,
490,
5082,
267,
372,
291,
14,
1813,
459,
2048,
14,
1185,
14,
604,
418,
60,
288,
1275,
6726,
63,
1185,
63,
1278,
63,
509,
63,
25981,
29685,
63,
3440,
8,
1185,
63,
1278,
9,
339,
768,
1246,
14,
1238,
272,
347,
664,
63,
25981,
29685,
63,
496,
3124,
8,
277,
12,
642,
12,
8789,
63,
1580,
29,
403,
304,
267,
408,
9295,
340,
781,
2342,
282,
663,
11628,
1865,
626,
4450,
4154,
1004,
14,
982,
9456,
12,
267,
372,
1006,
625,
14808,
1672,
2385,
687,
2337,
624,
398,
26053,
441,
63,
1278,
275,
291,
14,
362,
63,
18403,
63,
1278,
63,
504,
63,
6413,
371,
63,
1185,
8,
288,
642,
12,
8789,
63,
1580,
29,
403,
9,
267,
340,
26053,
441,
63,
1278,
26,
288,
372,
26053,
441,
63,
1278,
267,
916,
642,
14,
9860,
63,
2048,
63,
344,
14,
929,
508,
298,
6413,
371,
582,
288,
372,
942,
267,
587,
26,
288,
372,
1613,
8,
6009,
14814,
15173,
3049,
12,
291,
2862,
1598,
1275,
362,
63,
25981,
29685,
63,
496,
3124,
8,
3749,
12,
8789,
63,
1580,
29,
12144,
63,
1580,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
zifeishan/deepdive
|
src/test/python/test_ddext/output-1.py
|
15
|
2549
|
DROP TYPE IF EXISTS ret_func_ext_has_spouse_candidates CASCADE;
CREATE TYPE ret_func_ext_has_spouse_candidates AS (person1_id text, person2_id text, sentence_id text, description text, is_true boolean, relation_id text);
CREATE OR REPLACE FUNCTION func_ext_has_spouse_candidates(
sentence_id text, p1_id text, p1_text text, p2_id text, p2_text text) RETURNS SETOF ret_func_ext_has_spouse_candidates AS
$$
if 'csv' in SD:
csv = SD['csv']
else:
import csv
SD['csv'] = csv
if 'os' in SD:
os = SD['os']
else:
import os
SD['os'] = os
if 'defaultdict' in SD:
defaultdict = SD['defaultdict']
else:
from collections import defaultdict
SD['defaultdict'] = defaultdict
####### NOTICE: SHARED MEMORY ########
# If you really need shared memory / global dir, do "from ddext import SD."
# Use SD as the global shared dict.
# Load the spouse dictionary for distant supervision
spouses = defaultdict(lambda: None)
if 'spouses' in SD:
spouses = SD['spouses']
else: # Read data from file once, and share it
SD['spouses'] = spouses
# Read dict from file: MAKE SURE YOUR DATABASE SERVER
# HAVE THE ACCESS TO FILE!
# Please use absolute path!
with open ("/dfs/rulk/0/deepdive/shared/spouses.csv") as csvfile:
reader = csv.reader(csvfile)
for line in reader:
spouses[line[0].strip().lower()] = line[1].strip().lower()
if 'non_spouses' in SD:
non_spouses = SD['non_spouses']
else:
non_spouses = set()
SD['non_spouses'] = non_spouses
lines = open('/dfs/rulk/0/deepdive/shared/non-spouses.tsv').readlines()
for line in lines:
name1, name2, relation = line.strip().split('\t')
non_spouses.add((name1, name2)) # Add a non-spouse relation pair
# NOTICE: PLPY DOES NOT ALLOW overwritting input arguments!!!
# will return "UnboundLocalError".
p1_t = p1_text.strip()
p2_t = p2_text.strip()
p1_text_lower = p1_t.lower()
p2_text_lower = p2_t.lower()
is_true = None
if spouses[p1_text_lower] == p2_text_lower:
is_true = True
elif spouses[p2_text_lower] == p1_text_lower:
is_true = True
# same person
elif (p1_t == p2_t) or (p1_t in p2_t) or (p2_t in p1_t):
is_true = False
elif (p1_text_lower, p2_text_lower) in non_spouses:
is_true = False
elif (p2_text_lower, p1_text_lower) in non_spouses:
is_true = False
# Must return a tuple of arrays.
yield [p1_id, p2_id, sentence_id, "%s-%s" % (p1_t, p2_t), is_true, "%s_%s" % (p1_id, p2_id)]
# return [[p1_id, p2_id, sentence_id, "%s-%s" % (p1_t, p2_t), is_true]]
$$ LANGUAGE plpythonu ;
|
apache-2.0
|
[
14764,
11511,
8036,
23875,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
27751,
9947,
27,
199,
8366,
11511,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
4319,
334,
5484,
17,
63,
344,
1318,
12,
4954,
18,
63,
344,
1318,
12,
14537,
63,
344,
1318,
12,
1369,
1318,
12,
365,
63,
2052,
5046,
12,
5850,
63,
344,
1318,
2736,
199,
8366,
1549,
5363,
23068,
32744,
2562,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
8,
272,
14537,
63,
344,
1318,
12,
299,
17,
63,
344,
1318,
12,
299,
17,
63,
505,
1318,
12,
299,
18,
63,
344,
1318,
12,
299,
18,
63,
505,
1318,
9,
17409,
1230,
2709,
11543,
3359,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
4319,
199,
23174,
199,
199,
692,
283,
4737,
7,
315,
428,
36,
26,
523,
7392,
275,
428,
36,
459,
4737,
418,
199,
2836,
26,
523,
492,
7392,
523,
428,
36,
459,
4737,
418,
275,
7392,
199,
199,
692,
283,
736,
7,
315,
428,
36,
26,
523,
747,
275,
428,
36,
459,
736,
418,
199,
2836,
26,
523,
492,
747,
523,
428,
36,
459,
736,
418,
275,
747,
199,
199,
692,
283,
21501,
7,
315,
428,
36,
26,
523,
10018,
275,
428,
36,
459,
21501,
418,
199,
2836,
26,
523,
687,
5055,
492,
10018,
523,
428,
36,
459,
21501,
418,
275,
10018,
421,
199,
14776,
12840,
26,
4410,
689,
1149,
31424,
5347,
21937,
199,
3,
982,
1265,
7710,
1929,
5709,
4402,
1182,
2288,
2935,
12,
886,
298,
504,
366,
271,
400,
492,
428,
36,
2122,
199,
3,
3645,
428,
36,
465,
314,
2288,
5709,
1211,
14,
199,
199,
3,
7190,
314,
25664,
1180,
2600,
367,
2917,
867,
1613,
2317,
199,
22522,
5589,
275,
10018,
8,
2734,
26,
488,
9,
199,
692,
283,
22522,
5589,
7,
315,
428,
36,
26,
272,
25664,
5589,
275,
428,
36,
459,
22522,
5589,
418,
199,
2836,
26,
259,
327,
5574,
666,
687,
570,
5403,
12,
436,
8663,
652,
272,
428,
36,
459,
22522,
5589,
418,
275,
25664,
5589,
272,
327,
5574,
1211,
687,
570,
26,
4828,
2430,
428,
3942,
1488,
11237,
31705,
23578,
272,
327,
258,
25227,
2334,
437,
10203,
2296,
13024,
1,
272,
327,
7754,
675,
3679,
931,
1,
272,
543,
1551,
1689,
15,
10434,
15,
82,
6368,
15,
16,
15,
16131,
28021,
15,
5555,
15,
22522,
5589,
14,
4737,
531,
465,
7392,
493,
26,
267,
7002,
275,
7392,
14,
5503,
8,
4737,
493,
9,
267,
367,
1004,
315,
7002,
26,
288,
25664,
5589,
59,
604,
59,
16,
1055,
1913,
1252,
2325,
5106,
275,
1004,
59,
17,
1055,
1913,
1252,
2325,
342,
199,
199,
692,
283,
2865,
63,
22522,
5589,
7,
315,
428,
36,
26,
272,
2222,
63,
22522,
5589,
275,
428,
36,
459,
2865,
63,
22522,
5589,
418,
199,
2836,
26,
272,
2222,
63,
22522,
5589,
275,
663,
342,
272,
428,
36,
459,
2865,
63,
22522,
5589,
418,
275,
2222,
63,
22522,
5589,
272,
2385,
275,
1551,
2336,
10434,
15,
82,
6368,
15,
16,
15,
16131,
28021,
15,
5555,
15,
2865,
13,
22522,
5589,
14,
29362,
1959,
9684,
342,
272,
367,
1004,
315,
2385,
26,
267,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
267,
2222,
63,
22522,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
259,
327,
2654,
282,
2222,
13,
22522,
1180,
5850,
4092,
199,
199,
3,
12840,
26,
10092,
4521,
3506,
654,
2845,
27805,
1806,
3392,
84,
1337,
1324,
2368,
21512,
199,
3,
911,
372,
298,
1358,
3556,
5339,
547,
1674,
199,
80,
17,
63,
84,
275,
299,
17,
63,
505,
14,
1913,
342,
199,
80,
18,
63,
84,
275,
299,
18,
63,
505,
14,
1913,
342,
199,
80,
17,
63,
505,
63,
2325,
275,
299,
17,
63,
84,
14,
2325,
342,
199,
80,
18,
63,
505,
63,
2325,
275,
299,
18,
63,
84,
14,
2325,
342,
199,
199,
374,
63,
2052,
275,
488,
199,
692,
25664,
5589,
59,
80,
17,
63,
505,
63,
2325,
61,
508,
299,
18,
63,
505,
63,
2325,
26,
272,
365,
63,
2052,
275,
715,
199,
4164,
25664,
5589,
59,
80,
18,
63,
505,
63,
2325,
61,
508,
299,
17,
63,
505,
63,
2325,
26,
272,
365,
63,
2052,
275,
715,
199,
3,
2011,
4954,
199,
4164,
334,
80,
17,
63,
84,
508,
299,
18,
63,
84,
9,
503,
334,
80,
17,
63,
84,
315,
299,
18,
63,
84,
9,
503,
334,
80,
18,
63,
84,
315,
299,
17,
63,
84,
304,
272,
365,
63,
2052,
275,
756,
199,
4164,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
756,
199,
4164,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
756,
199,
199,
3,
9498,
372,
282,
2008,
402,
6572,
14,
199,
199,
11481,
359,
80,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
2071,
83,
3295,
83,
2,
450,
334,
80,
17,
63,
84,
12,
299,
18,
63,
84,
395,
365,
63,
2052,
12,
2071,
83,
4970,
83,
2,
450,
334,
80,
17,
63,
344,
12,
299,
18,
63,
344,
1874,
199,
3,
372,
3474,
80,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
2071,
83,
3295,
83,
2,
450,
334,
80,
17,
63,
84,
12,
299,
18,
63,
84,
395,
365,
63,
2052,
2677,
199,
23174,
30508,
2962,
1620,
1548,
85,
8700,
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
] |
[
11511,
8036,
23875,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
27751,
9947,
27,
199,
8366,
11511,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
4319,
334,
5484,
17,
63,
344,
1318,
12,
4954,
18,
63,
344,
1318,
12,
14537,
63,
344,
1318,
12,
1369,
1318,
12,
365,
63,
2052,
5046,
12,
5850,
63,
344,
1318,
2736,
199,
8366,
1549,
5363,
23068,
32744,
2562,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
8,
272,
14537,
63,
344,
1318,
12,
299,
17,
63,
344,
1318,
12,
299,
17,
63,
505,
1318,
12,
299,
18,
63,
344,
1318,
12,
299,
18,
63,
505,
1318,
9,
17409,
1230,
2709,
11543,
3359,
2203,
63,
1532,
63,
832,
63,
1989,
63,
22522,
1180,
63,
16389,
4319,
199,
23174,
199,
199,
692,
283,
4737,
7,
315,
428,
36,
26,
523,
7392,
275,
428,
36,
459,
4737,
418,
199,
2836,
26,
523,
492,
7392,
523,
428,
36,
459,
4737,
418,
275,
7392,
199,
199,
692,
283,
736,
7,
315,
428,
36,
26,
523,
747,
275,
428,
36,
459,
736,
418,
199,
2836,
26,
523,
492,
747,
523,
428,
36,
459,
736,
418,
275,
747,
199,
199,
692,
283,
21501,
7,
315,
428,
36,
26,
523,
10018,
275,
428,
36,
459,
21501,
418,
199,
2836,
26,
523,
687,
5055,
492,
10018,
523,
428,
36,
459,
21501,
418,
275,
10018,
421,
199,
14776,
12840,
26,
4410,
689,
1149,
31424,
5347,
21937,
199,
3,
982,
1265,
7710,
1929,
5709,
4402,
1182,
2288,
2935,
12,
886,
298,
504,
366,
271,
400,
492,
428,
36,
2122,
199,
3,
3645,
428,
36,
465,
314,
2288,
5709,
1211,
14,
199,
199,
3,
7190,
314,
25664,
1180,
2600,
367,
2917,
867,
1613,
2317,
199,
22522,
5589,
275,
10018,
8,
2734,
26,
488,
9,
199,
692,
283,
22522,
5589,
7,
315,
428,
36,
26,
272,
25664,
5589,
275,
428,
36,
459,
22522,
5589,
418,
199,
2836,
26,
259,
327,
5574,
666,
687,
570,
5403,
12,
436,
8663,
652,
272,
428,
36,
459,
22522,
5589,
418,
275,
25664,
5589,
272,
327,
5574,
1211,
687,
570,
26,
4828,
2430,
428,
3942,
1488,
11237,
31705,
23578,
272,
327,
258,
25227,
2334,
437,
10203,
2296,
13024,
1,
272,
327,
7754,
675,
3679,
931,
1,
272,
543,
1551,
1689,
15,
10434,
15,
82,
6368,
15,
16,
15,
16131,
28021,
15,
5555,
15,
22522,
5589,
14,
4737,
531,
465,
7392,
493,
26,
267,
7002,
275,
7392,
14,
5503,
8,
4737,
493,
9,
267,
367,
1004,
315,
7002,
26,
288,
25664,
5589,
59,
604,
59,
16,
1055,
1913,
1252,
2325,
5106,
275,
1004,
59,
17,
1055,
1913,
1252,
2325,
342,
199,
199,
692,
283,
2865,
63,
22522,
5589,
7,
315,
428,
36,
26,
272,
2222,
63,
22522,
5589,
275,
428,
36,
459,
2865,
63,
22522,
5589,
418,
199,
2836,
26,
272,
2222,
63,
22522,
5589,
275,
663,
342,
272,
428,
36,
459,
2865,
63,
22522,
5589,
418,
275,
2222,
63,
22522,
5589,
272,
2385,
275,
1551,
2336,
10434,
15,
82,
6368,
15,
16,
15,
16131,
28021,
15,
5555,
15,
2865,
13,
22522,
5589,
14,
29362,
1959,
9684,
342,
272,
367,
1004,
315,
2385,
26,
267,
536,
17,
12,
536,
18,
12,
5850,
275,
1004,
14,
1913,
1252,
1294,
2258,
84,
358,
267,
2222,
63,
22522,
5589,
14,
525,
1332,
354,
17,
12,
536,
18,
430,
259,
327,
2654,
282,
2222,
13,
22522,
1180,
5850,
4092,
199,
199,
3,
12840,
26,
10092,
4521,
3506,
654,
2845,
27805,
1806,
3392,
84,
1337,
1324,
2368,
21512,
199,
3,
911,
372,
298,
1358,
3556,
5339,
547,
1674,
199,
80,
17,
63,
84,
275,
299,
17,
63,
505,
14,
1913,
342,
199,
80,
18,
63,
84,
275,
299,
18,
63,
505,
14,
1913,
342,
199,
80,
17,
63,
505,
63,
2325,
275,
299,
17,
63,
84,
14,
2325,
342,
199,
80,
18,
63,
505,
63,
2325,
275,
299,
18,
63,
84,
14,
2325,
342,
199,
199,
374,
63,
2052,
275,
488,
199,
692,
25664,
5589,
59,
80,
17,
63,
505,
63,
2325,
61,
508,
299,
18,
63,
505,
63,
2325,
26,
272,
365,
63,
2052,
275,
715,
199,
4164,
25664,
5589,
59,
80,
18,
63,
505,
63,
2325,
61,
508,
299,
17,
63,
505,
63,
2325,
26,
272,
365,
63,
2052,
275,
715,
199,
3,
2011,
4954,
199,
4164,
334,
80,
17,
63,
84,
508,
299,
18,
63,
84,
9,
503,
334,
80,
17,
63,
84,
315,
299,
18,
63,
84,
9,
503,
334,
80,
18,
63,
84,
315,
299,
17,
63,
84,
304,
272,
365,
63,
2052,
275,
756,
199,
4164,
334,
80,
17,
63,
505,
63,
2325,
12,
299,
18,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
756,
199,
4164,
334,
80,
18,
63,
505,
63,
2325,
12,
299,
17,
63,
505,
63,
2325,
9,
315,
2222,
63,
22522,
5589,
26,
272,
365,
63,
2052,
275,
756,
199,
199,
3,
9498,
372,
282,
2008,
402,
6572,
14,
199,
199,
11481,
359,
80,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
2071,
83,
3295,
83,
2,
450,
334,
80,
17,
63,
84,
12,
299,
18,
63,
84,
395,
365,
63,
2052,
12,
2071,
83,
4970,
83,
2,
450,
334,
80,
17,
63,
344,
12,
299,
18,
63,
344,
1874,
199,
3,
372,
3474,
80,
17,
63,
344,
12,
299,
18,
63,
344,
12,
14537,
63,
344,
12,
2071,
83,
3295,
83,
2,
450,
334,
80,
17,
63,
84,
12,
299,
18,
63,
84,
395,
365,
63,
2052,
2677,
199,
23174,
30508,
2962,
1620,
1548,
85,
8700,
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,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Jonekee/chromium.src
|
third_party/typ/typ/fakes/tests/test_result_server_fake_test.py
|
81
|
1298
|
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from typ.fakes import test_result_server_fake
from typ import Host
class TestResultServerFakeTest(unittest.TestCase):
def test_basic_upload(self):
host = Host()
server = None
posts = []
try:
server = test_result_server_fake.start()
url = 'http://%s:%d/testfile/upload' % server.server_address
if server:
resp = host.fetch(url, 'foo=bar')
finally:
if server:
posts = server.stop()
self.assertEqual(posts, [('post', '/testfile/upload',
'foo=bar'.encode('utf8'))])
self.assertNotEqual(server.log.getvalue(), '')
|
bsd-3-clause
|
[
3,
1898,
6927,
4475,
3277,
14,
2900,
4481,
4644,
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,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
2882,
199,
199,
504,
6211,
14,
27443,
492,
511,
63,
1099,
63,
1000,
63,
3183,
199,
504,
6211,
492,
10891,
421,
199,
533,
23795,
3120,
8249,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4316,
63,
5064,
8,
277,
304,
267,
1591,
275,
10891,
342,
267,
1654,
275,
488,
267,
22238,
275,
942,
267,
862,
26,
288,
1654,
275,
511,
63,
1099,
63,
1000,
63,
3183,
14,
928,
342,
288,
1166,
275,
283,
1014,
13827,
83,
2689,
68,
15,
21091,
15,
5064,
7,
450,
1654,
14,
1000,
63,
1562,
288,
340,
1654,
26,
355,
3085,
275,
1591,
14,
3535,
8,
633,
12,
283,
1421,
29,
1700,
358,
267,
3753,
26,
288,
340,
1654,
26,
355,
22238,
275,
1654,
14,
2379,
342,
267,
291,
14,
629,
8,
18084,
12,
4274,
1932,
297,
1994,
21091,
15,
5064,
297,
3303,
283,
1421,
29,
1700,
1370,
2143,
360,
1624,
24,
1333,
566,
267,
291,
14,
7418,
8,
1000,
14,
793,
14,
7150,
1062,
4074,
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
] |
[
1898,
6927,
4475,
3277,
14,
2900,
4481,
4644,
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,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
646,
2882,
199,
199,
504,
6211,
14,
27443,
492,
511,
63,
1099,
63,
1000,
63,
3183,
199,
504,
6211,
492,
10891,
421,
199,
533,
23795,
3120,
8249,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4316,
63,
5064,
8,
277,
304,
267,
1591,
275,
10891,
342,
267,
1654,
275,
488,
267,
22238,
275,
942,
267,
862,
26,
288,
1654,
275,
511,
63,
1099,
63,
1000,
63,
3183,
14,
928,
342,
288,
1166,
275,
283,
1014,
13827,
83,
2689,
68,
15,
21091,
15,
5064,
7,
450,
1654,
14,
1000,
63,
1562,
288,
340,
1654,
26,
355,
3085,
275,
1591,
14,
3535,
8,
633,
12,
283,
1421,
29,
1700,
358,
267,
3753,
26,
288,
340,
1654,
26,
355,
22238,
275,
1654,
14,
2379,
342,
267,
291,
14,
629,
8,
18084,
12,
4274,
1932,
297,
1994,
21091,
15,
5064,
297,
3303,
283,
1421,
29,
1700,
1370,
2143,
360,
1624,
24,
1333,
566,
267,
291,
14,
7418,
8,
1000,
14,
793,
14,
7150,
1062,
4074,
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,
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,
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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
] |
phihag/youtube-dl
|
youtube_dl/extractor/gfycat.py
|
11
|
3695
|
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
int_or_none,
float_or_none,
qualities,
ExtractorError,
)
class GfycatIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?gfycat\.com/(?:ifr/|gifs/detail/)?(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'http://gfycat.com/DeadlyDecisiveGermanpinscher',
'info_dict': {
'id': 'DeadlyDecisiveGermanpinscher',
'ext': 'mp4',
'title': 'Ghost in the Shell',
'timestamp': 1410656006,
'upload_date': '20140914',
'uploader': 'anonymous',
'duration': 10.4,
'view_count': int,
'like_count': int,
'dislike_count': int,
'categories': list,
'age_limit': 0,
}
}, {
'url': 'http://gfycat.com/ifr/JauntyTimelyAmazontreeboa',
'info_dict': {
'id': 'JauntyTimelyAmazontreeboa',
'ext': 'mp4',
'title': 'JauntyTimelyAmazontreeboa',
'timestamp': 1411720126,
'upload_date': '20140926',
'uploader': 'anonymous',
'duration': 3.52,
'view_count': int,
'like_count': int,
'dislike_count': int,
'categories': list,
'age_limit': 0,
}
}, {
'url': 'https://gfycat.com/gifs/detail/UnconsciousLankyIvorygull',
'only_matching': True
}]
def _real_extract(self, url):
video_id = self._match_id(url)
gfy = self._download_json(
'http://gfycat.com/cajax/get/%s' % video_id,
video_id, 'Downloading video info')
if 'error' in gfy:
raise ExtractorError('Gfycat said: ' + gfy['error'], expected=True)
gfy = gfy['gfyItem']
title = gfy.get('title') or gfy['gfyName']
description = gfy.get('description')
timestamp = int_or_none(gfy.get('createDate'))
uploader = gfy.get('userName')
view_count = int_or_none(gfy.get('views'))
like_count = int_or_none(gfy.get('likes'))
dislike_count = int_or_none(gfy.get('dislikes'))
age_limit = 18 if gfy.get('nsfw') == '1' else 0
width = int_or_none(gfy.get('width'))
height = int_or_none(gfy.get('height'))
fps = int_or_none(gfy.get('frameRate'))
num_frames = int_or_none(gfy.get('numFrames'))
duration = float_or_none(num_frames, fps) if num_frames and fps else None
categories = gfy.get('tags') or gfy.get('extraLemmas') or []
FORMATS = ('gif', 'webm', 'mp4')
quality = qualities(FORMATS)
formats = []
for format_id in FORMATS:
video_url = gfy.get('%sUrl' % format_id)
if not video_url:
continue
filesize = int_or_none(gfy.get('%sSize' % format_id))
formats.append({
'url': video_url,
'format_id': format_id,
'width': width,
'height': height,
'fps': fps,
'filesize': filesize,
'quality': quality(format_id),
})
self._sort_formats(formats)
return {
'id': video_id,
'title': title,
'description': description,
'timestamp': timestamp,
'uploader': uploader,
'duration': duration,
'view_count': view_count,
'like_count': like_count,
'dislike_count': dislike_count,
'categories': categories,
'age_limit': age_limit,
'formats': formats,
}
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
1109,
63,
269,
63,
3592,
12,
272,
2069,
63,
269,
63,
3592,
12,
272,
6420,
12107,
12,
272,
19783,
12,
199,
9,
421,
199,
533,
598,
1399,
3385,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
71,
1399,
3385,
4537,
957,
32576,
692,
82,
15,
92,
14513,
83,
15,
5506,
15,
5547,
2229,
48,
28,
344,
13489,
10197,
3,
29716,
272,
485,
7569,
275,
8910,
267,
283,
633,
356,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
22147,
590,
872,
559,
3398,
27866,
1237,
21746,
7641,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
22147,
590,
872,
559,
3398,
27866,
1237,
21746,
7641,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
39,
1102,
315,
314,
24599,
297,
288,
283,
3954,
356,
4329,
7357,
1367,
8010,
12,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1079,
297,
288,
283,
13671,
356,
283,
12628,
297,
288,
283,
5553,
356,
1616,
14,
20,
12,
288,
283,
1345,
63,
835,
356,
1109,
12,
288,
283,
2930,
63,
835,
356,
1109,
12,
288,
283,
2297,
2930,
63,
835,
356,
1109,
12,
288,
283,
8906,
356,
769,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
789,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
692,
82,
15,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
288,
283,
3954,
356,
4329,
7362,
1797,
1479,
12,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1479,
297,
288,
283,
13671,
356,
283,
12628,
297,
288,
283,
5553,
356,
650,
14,
2528,
12,
288,
283,
1345,
63,
835,
356,
1109,
12,
288,
283,
2930,
63,
835,
356,
1109,
12,
288,
283,
2297,
2930,
63,
835,
356,
1109,
12,
288,
283,
8906,
356,
769,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
789,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
71,
1399,
3385,
14,
957,
15,
14513,
83,
15,
5506,
15,
1358,
388,
9907,
1785,
44,
3580,
89,
41,
86,
1089,
71,
979,
297,
267,
283,
2118,
63,
9467,
356,
715,
272,
14877,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
486,
1399,
275,
291,
423,
4249,
63,
1001,
8,
288,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
696,
15863,
15,
362,
3149,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
12,
283,
18085,
3991,
2256,
358,
267,
340,
283,
705,
7,
315,
486,
1399,
26,
288,
746,
19783,
360,
39,
1399,
3385,
25097,
26,
283,
435,
486,
1399,
459,
705,
995,
1420,
29,
549,
9,
267,
486,
1399,
275,
486,
1399,
459,
71,
1399,
2081,
418,
398,
2538,
275,
486,
1399,
14,
362,
360,
1213,
358,
503,
486,
1399,
459,
71,
1399,
985,
418,
267,
1369,
275,
486,
1399,
14,
362,
360,
1802,
358,
267,
4913,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
981,
2506,
1333,
267,
25257,
275,
486,
1399,
14,
362,
360,
751,
985,
358,
267,
2455,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
4196,
1333,
267,
2839,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
29572,
1333,
267,
2153,
2930,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
2297,
29572,
1333,
267,
11437,
63,
3097,
275,
6155,
340,
486,
1399,
14,
362,
360,
561,
8835,
358,
508,
283,
17,
7,
587,
378,
398,
3462,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
2063,
1333,
267,
4569,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
3333,
1333,
267,
289,
1190,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
1943,
6621,
1333,
267,
1967,
63,
8444,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
1507,
22024,
1333,
398,
7373,
275,
2069,
63,
269,
63,
3592,
8,
1507,
63,
8444,
12,
289,
1190,
9,
340,
1967,
63,
8444,
436,
289,
1190,
587,
488,
398,
9695,
275,
486,
1399,
14,
362,
360,
2969,
358,
503,
486,
1399,
14,
362,
360,
2911,
2553,
596,
305,
358,
503,
942,
398,
11295,
619,
51,
275,
661,
14513,
297,
283,
30504,
297,
283,
311,
20,
358,
267,
11030,
275,
6420,
12107,
8,
14019,
9,
398,
6752,
275,
942,
267,
367,
1475,
63,
344,
315,
11295,
619,
51,
26,
288,
3991,
63,
633,
275,
486,
1399,
14,
362,
3508,
83,
6417,
7,
450,
1475,
63,
344,
9,
288,
340,
440,
3991,
63,
633,
26,
355,
1980,
288,
23858,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
3508,
83,
2320,
7,
450,
1475,
63,
344,
430,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
3991,
63,
633,
12,
355,
283,
908,
63,
344,
356,
1475,
63,
344,
12,
355,
283,
2063,
356,
3462,
12,
355,
283,
3333,
356,
4569,
12,
355,
283,
24709,
356,
289,
1190,
12,
355,
283,
19233,
356,
23858,
12,
355,
283,
9161,
356,
11030,
8,
908,
63,
344,
395,
288,
3828,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
3954,
356,
4913,
12,
288,
283,
13671,
356,
25257,
12,
288,
283,
5553,
356,
7373,
12,
288,
283,
1345,
63,
835,
356,
2455,
63,
835,
12,
288,
283,
2930,
63,
835,
356,
2839,
63,
835,
12,
288,
283,
2297,
2930,
63
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
1109,
63,
269,
63,
3592,
12,
272,
2069,
63,
269,
63,
3592,
12,
272,
6420,
12107,
12,
272,
19783,
12,
199,
9,
421,
199,
533,
598,
1399,
3385,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
24524,
1544,
20316,
71,
1399,
3385,
4537,
957,
32576,
692,
82,
15,
92,
14513,
83,
15,
5506,
15,
5547,
2229,
48,
28,
344,
13489,
10197,
3,
29716,
272,
485,
7569,
275,
8910,
267,
283,
633,
356,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
22147,
590,
872,
559,
3398,
27866,
1237,
21746,
7641,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
22147,
590,
872,
559,
3398,
27866,
1237,
21746,
7641,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
39,
1102,
315,
314,
24599,
297,
288,
283,
3954,
356,
4329,
7357,
1367,
8010,
12,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1079,
297,
288,
283,
13671,
356,
283,
12628,
297,
288,
283,
5553,
356,
1616,
14,
20,
12,
288,
283,
1345,
63,
835,
356,
1109,
12,
288,
283,
2930,
63,
835,
356,
1109,
12,
288,
283,
2297,
2930,
63,
835,
356,
1109,
12,
288,
283,
8906,
356,
769,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
789,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
692,
82,
15,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
42,
65,
324,
369,
1366,
590,
33,
391,
90,
1888,
850,
656,
65,
297,
288,
283,
3954,
356,
4329,
7362,
1797,
1479,
12,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1479,
297,
288,
283,
13671,
356,
283,
12628,
297,
288,
283,
5553,
356,
650,
14,
2528,
12,
288,
283,
1345,
63,
835,
356,
1109,
12,
288,
283,
2930,
63,
835,
356,
1109,
12,
288,
283,
2297,
2930,
63,
835,
356,
1109,
12,
288,
283,
8906,
356,
769,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
789,
272,
1660,
469,
267,
283,
633,
356,
283,
2859,
921,
71,
1399,
3385,
14,
957,
15,
14513,
83,
15,
5506,
15,
1358,
388,
9907,
1785,
44,
3580,
89,
41,
86,
1089,
71,
979,
297,
267,
283,
2118,
63,
9467,
356,
715,
272,
14877,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
486,
1399,
275,
291,
423,
4249,
63,
1001,
8,
288,
283,
1014,
921,
71,
1399,
3385,
14,
957,
15,
696,
15863,
15,
362,
3149,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
12,
283,
18085,
3991,
2256,
358,
267,
340,
283,
705,
7,
315,
486,
1399,
26,
288,
746,
19783,
360,
39,
1399,
3385,
25097,
26,
283,
435,
486,
1399,
459,
705,
995,
1420,
29,
549,
9,
267,
486,
1399,
275,
486,
1399,
459,
71,
1399,
2081,
418,
398,
2538,
275,
486,
1399,
14,
362,
360,
1213,
358,
503,
486,
1399,
459,
71,
1399,
985,
418,
267,
1369,
275,
486,
1399,
14,
362,
360,
1802,
358,
267,
4913,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
981,
2506,
1333,
267,
25257,
275,
486,
1399,
14,
362,
360,
751,
985,
358,
267,
2455,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
4196,
1333,
267,
2839,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
29572,
1333,
267,
2153,
2930,
63,
835,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
2297,
29572,
1333,
267,
11437,
63,
3097,
275,
6155,
340,
486,
1399,
14,
362,
360,
561,
8835,
358,
508,
283,
17,
7,
587,
378,
398,
3462,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
2063,
1333,
267,
4569,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
3333,
1333,
267,
289,
1190,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
1943,
6621,
1333,
267,
1967,
63,
8444,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
360,
1507,
22024,
1333,
398,
7373,
275,
2069,
63,
269,
63,
3592,
8,
1507,
63,
8444,
12,
289,
1190,
9,
340,
1967,
63,
8444,
436,
289,
1190,
587,
488,
398,
9695,
275,
486,
1399,
14,
362,
360,
2969,
358,
503,
486,
1399,
14,
362,
360,
2911,
2553,
596,
305,
358,
503,
942,
398,
11295,
619,
51,
275,
661,
14513,
297,
283,
30504,
297,
283,
311,
20,
358,
267,
11030,
275,
6420,
12107,
8,
14019,
9,
398,
6752,
275,
942,
267,
367,
1475,
63,
344,
315,
11295,
619,
51,
26,
288,
3991,
63,
633,
275,
486,
1399,
14,
362,
3508,
83,
6417,
7,
450,
1475,
63,
344,
9,
288,
340,
440,
3991,
63,
633,
26,
355,
1980,
288,
23858,
275,
1109,
63,
269,
63,
3592,
8,
71,
1399,
14,
362,
3508,
83,
2320,
7,
450,
1475,
63,
344,
430,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
3991,
63,
633,
12,
355,
283,
908,
63,
344,
356,
1475,
63,
344,
12,
355,
283,
2063,
356,
3462,
12,
355,
283,
3333,
356,
4569,
12,
355,
283,
24709,
356,
289,
1190,
12,
355,
283,
19233,
356,
23858,
12,
355,
283,
9161,
356,
11030,
8,
908,
63,
344,
395,
288,
3828,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
3954,
356,
4913,
12,
288,
283,
13671,
356,
25257,
12,
288,
283,
5553,
356,
7373,
12,
288,
283,
1345,
63,
835,
356,
2455,
63,
835,
12,
288,
283,
2930,
63,
835,
356,
2839,
63,
835,
12,
288,
283,
2297,
2930,
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,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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
] |
defionscode/ansible
|
lib/ansible/modules/windows/win_whoami.py
|
52
|
5530
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# this is a windows documentation stub. actual code lives in the .ps1
# file of the same name
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = r'''
---
module: win_whoami
version_added: "2.5"
short_description: Get information about the current user and process
description:
- Designed to return the same information as the C(whoami /all) command.
- Also includes information missing from C(whoami) such as logon metadata like
logon rights, id, type.
notes:
- If running this module with a non admin user, the logon rights will be an
empty list as Administrator rights are required to query LSA for the
information.
author:
- Jordan Borean (@jborean93)
'''
EXAMPLES = r'''
- name: get whoami information
win_whoami:
'''
RETURN = r'''
authentication_package:
description: The name of the authentication package used to authenticate the
user in the session.
returned: success
type: str
sample: Negotiate
user_flags:
description: The user flags for the logon session, see UserFlags in
U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa380128).
returned: success
type: str
sample: Winlogon
upn:
description: The user principal name of the current user.
returned: success
type: str
sample: Administrator@DOMAIN.COM
logon_type:
description: The logon type that identifies the logon method, see
U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa380129.aspx).
returned: success
type: str
sample: Network
privileges:
description: A dictionary of privileges and their state on the logon token.
returned: success
type: dict
sample: {
"SeChangeNotifyPrivileges": "enabled-by-default",
"SeRemoteShutdownPrivilege": "disabled",
"SeDebugPrivilege": "enabled"
}
label:
description: The mandatory label set to the logon session.
returned: success
type: complex
contains:
domain_name:
description: The domain name of the label SID.
returned: success
type: str
sample: Mandatory Label
sid:
description: The SID in string form.
returned: success
type: str
sample: S-1-16-12288
account_name:
description: The account name of the label SID.
returned: success
type: str
sample: High Mandatory Level
type:
description: The type of SID.
returned: success
type: str
sample: Label
impersonation_level:
description: The impersonation level of the token, only valid if
C(token_type) is C(TokenImpersonation), see
U(https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572.aspx).
returned: success
type: str
sample: SecurityAnonymous
login_time:
description: The logon time in ISO 8601 format
returned: success
type: str
sample: '2017-11-27T06:24:14.3321665+10:00'
groups:
description: A list of groups and attributes that the user is a member of.
returned: success
type: list
sample: [
{
"account_name": "Domain Users",
"domain_name": "DOMAIN",
"attributes": [
"Mandatory",
"Enabled by default",
"Enabled"
],
"sid": "S-1-5-21-1654078763-769949647-2968445802-513",
"type": "Group"
},
{
"account_name": "Administrators",
"domain_name": "BUILTIN",
"attributes": [
"Mandatory",
"Enabled by default",
"Enabled",
"Owner"
],
"sid": "S-1-5-32-544",
"type": "Alias"
}
]
account:
description: The running account SID details.
returned: success
type: complex
contains:
domain_name:
description: The domain name of the account SID.
returned: success
type: str
sample: DOMAIN
sid:
description: The SID in string form.
returned: success
type: str
sample: S-1-5-21-1654078763-769949647-2968445802-500
account_name:
description: The account name of the account SID.
returned: success
type: str
sample: Administrator
type:
description: The type of SID.
returned: success
type: str
sample: User
login_domain:
description: The name of the domain used to authenticate the owner of the
session.
returned: success
type: str
sample: DOMAIN
rights:
description: A list of logon rights assigned to the logon.
returned: success and running user is a member of the local Administrators group
type: list
sample: [
"SeNetworkLogonRight",
"SeInteractiveLogonRight",
"SeBatchLogonRight",
"SeRemoteInteractiveLogonRight"
]
logon_server:
description: The name of the server used to authentcate the owner of the
logon session.
returned: success
type: str
sample: DC01
logon_id:
description: The unique identifier of the logon session.
returned: success
type: int
sample: 20470143
dns_domain_name:
description: The DNS name of the logon session, this is an empty string if
this is not set.
returned: success
type: str
sample: DOMAIN.COM
token_type:
description: The token type to indicate whether it is a primary or
impersonation token.
returned: success
type: str
sample: TokenPrimary
'''
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
2622,
7290,
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,
3,
642,
365,
282,
10061,
3794,
10098,
14,
221,
3503,
1233,
27576,
315,
314,
1275,
1190,
17,
199,
3,
570,
402,
314,
2011,
536,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
4747,
63,
11345,
13496,
199,
1023,
63,
3270,
26,
298,
18,
14,
21,
2,
199,
3612,
63,
1802,
26,
2372,
2556,
3595,
314,
1453,
922,
436,
2112,
199,
1802,
26,
199,
13,
1487,
1737,
370,
372,
314,
2011,
2556,
465,
314,
445,
8,
11345,
13496,
1182,
452,
9,
1414,
14,
199,
13,
6121,
6952,
2556,
4124,
687,
445,
8,
11345,
13496,
9,
4066,
465,
943,
265,
3341,
2839,
523,
943,
265,
4481,
12,
1305,
12,
730,
14,
199,
5983,
26,
199,
13,
982,
3879,
642,
859,
543,
282,
2222,
4628,
922,
12,
314,
943,
265,
4481,
911,
506,
376,
523,
2701,
769,
465,
30660,
4481,
787,
1415,
370,
1827,
491,
4251,
367,
314,
523,
2556,
14,
199,
2502,
26,
199,
13,
1603,
2181,
290,
699,
16293,
8593,
74,
656,
264,
290,
3129,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
664,
3963,
13496,
2556,
523,
4747,
63,
11345,
13496,
26,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
11725,
63,
2491,
26,
523,
1369,
26,
710,
536,
402,
314,
6299,
2559,
1202,
370,
12895,
314,
272,
922,
315,
314,
2351,
14,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
5612,
14727,
323,
199,
751,
63,
2469,
26,
523,
1369,
26,
710,
922,
3285,
367,
314,
943,
265,
2351,
12,
1937,
2876,
6381,
315,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
1703,
614,
1651,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
13036,
793,
265,
199,
384,
78,
26,
523,
1369,
26,
710,
922,
21646,
536,
402,
314,
1453,
922,
14,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
30660,
32,
7378,
14,
11265,
199,
793,
265,
63,
466,
26,
523,
1369,
26,
710,
943,
265,
730,
626,
22975,
314,
943,
265,
1083,
12,
1937,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
1703,
614,
1398,
14,
26146,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
7220,
199,
27852,
26,
523,
1369,
26,
437,
2600,
402,
20001,
436,
3932,
1174,
641,
314,
943,
265,
1526,
14,
523,
2138,
26,
3182,
523,
730,
26,
1211,
523,
2690,
26,
469,
489,
298,
1513,
4001,
8645,
4562,
13886,
582,
298,
3827,
13,
991,
13,
885,
401,
489,
298,
1513,
6713,
20043,
30447,
582,
298,
7011,
401,
489,
298,
1513,
7084,
30447,
582,
298,
3827,
2,
523,
789,
199,
1302,
26,
523,
1369,
26,
710,
15230,
1768,
663,
370,
314,
943,
265,
2351,
14,
523,
2138,
26,
3182,
523,
730,
26,
6114,
523,
3509,
26,
272,
2881,
63,
354,
26,
489,
1369,
26,
710,
2881,
536,
402,
314,
1768,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
603,
13530,
10354,
272,
15764,
26,
489,
1369,
26,
710,
428,
998,
315,
1059,
1824,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
428,
13,
17,
13,
975,
13,
7507,
1299,
272,
2933,
63,
354,
26,
489,
1369,
26,
710,
2933,
536,
402,
314,
1768,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
16332,
603,
13530,
20400,
272,
730,
26,
489,
1369,
26,
710,
730,
402,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
10354,
199,
3236,
31524,
63,
1896,
26,
523,
1369,
26,
710,
1742,
31524,
2166,
402,
314,
1526,
12,
1454,
1686,
340,
272,
445,
8,
1418,
63,
466,
9,
365,
445,
8,
3264,
8499,
31524,
395,
1937,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
12015,
17802,
14,
26146,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
13863,
23902,
199,
2886,
63,
521,
26,
523,
1369,
26,
710,
943,
265,
900,
315,
9055,
10300,
614,
1475,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
283,
10680,
13,
845,
13,
1465,
52,
1690,
26,
1194,
26,
1079,
14,
9526,
975,
2182,
11,
709,
26,
383,
7,
199,
2634,
26,
523,
1369,
26,
437,
769,
402,
4652,
436,
3004,
626,
314,
922,
365,
282,
3653,
402,
14,
523,
2138,
26,
3182,
523,
730,
26,
769,
523,
2690,
26,
359,
489,
469,
881,
298,
2048,
63,
354,
582,
298,
7705,
20123,
401,
881,
298,
2261,
63,
354,
582,
298,
7378,
401,
881,
298,
2987,
582,
359,
1598,
298,
45,
13530,
401,
1598,
298,
6589,
701,
849,
401,
1598,
298,
6589,
2,
881,
2156,
881,
298,
4148,
582,
298,
51,
13,
17,
13,
21,
13,
2025,
13,
975,
1477,
1780,
1555,
2766,
13,
2114,
1020,
1887,
8557,
13,
11700,
16042,
2010,
996,
13,
27452,
401,
881,
298,
466,
582,
298,
2448,
2,
489,
1660,
489,
469,
881,
298,
2048,
63,
354,
582,
298,
4880,
3075,
2750,
401,
881,
298,
2261,
63,
354,
582,
298,
18637,
20012,
401,
881,
298,
2987,
582,
359,
1598,
298,
45,
13530,
401,
1598,
298,
6589,
701,
849,
401,
1598,
298,
6589,
401,
1598,
298,
14919,
2,
881,
2156,
881,
298,
4148,
582,
298,
51,
13,
17,
13,
21,
13,
708,
13,
16298,
401,
881,
298,
466,
582,
298,
14149,
2,
489,
789,
523,
1622,
199,
2048,
26,
523,
1369,
26,
710,
3879,
2933,
428
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
2622,
7290,
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,
3,
642,
365,
282,
10061,
3794,
10098,
14,
221,
3503,
1233,
27576,
315,
314,
1275,
1190,
17,
199,
3,
570,
402,
314,
2011,
536,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
4747,
63,
11345,
13496,
199,
1023,
63,
3270,
26,
298,
18,
14,
21,
2,
199,
3612,
63,
1802,
26,
2372,
2556,
3595,
314,
1453,
922,
436,
2112,
199,
1802,
26,
199,
13,
1487,
1737,
370,
372,
314,
2011,
2556,
465,
314,
445,
8,
11345,
13496,
1182,
452,
9,
1414,
14,
199,
13,
6121,
6952,
2556,
4124,
687,
445,
8,
11345,
13496,
9,
4066,
465,
943,
265,
3341,
2839,
523,
943,
265,
4481,
12,
1305,
12,
730,
14,
199,
5983,
26,
199,
13,
982,
3879,
642,
859,
543,
282,
2222,
4628,
922,
12,
314,
943,
265,
4481,
911,
506,
376,
523,
2701,
769,
465,
30660,
4481,
787,
1415,
370,
1827,
491,
4251,
367,
314,
523,
2556,
14,
199,
2502,
26,
199,
13,
1603,
2181,
290,
699,
16293,
8593,
74,
656,
264,
290,
3129,
9,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
664,
3963,
13496,
2556,
523,
4747,
63,
11345,
13496,
26,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
11725,
63,
2491,
26,
523,
1369,
26,
710,
536,
402,
314,
6299,
2559,
1202,
370,
12895,
314,
272,
922,
315,
314,
2351,
14,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
5612,
14727,
323,
199,
751,
63,
2469,
26,
523,
1369,
26,
710,
922,
3285,
367,
314,
943,
265,
2351,
12,
1937,
2876,
6381,
315,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
1703,
614,
1651,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
13036,
793,
265,
199,
384,
78,
26,
523,
1369,
26,
710,
922,
21646,
536,
402,
314,
1453,
922,
14,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
30660,
32,
7378,
14,
11265,
199,
793,
265,
63,
466,
26,
523,
1369,
26,
710,
943,
265,
730,
626,
22975,
314,
943,
265,
1083,
12,
1937,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
1703,
614,
1398,
14,
26146,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
7220,
199,
27852,
26,
523,
1369,
26,
437,
2600,
402,
20001,
436,
3932,
1174,
641,
314,
943,
265,
1526,
14,
523,
2138,
26,
3182,
523,
730,
26,
1211,
523,
2690,
26,
469,
489,
298,
1513,
4001,
8645,
4562,
13886,
582,
298,
3827,
13,
991,
13,
885,
401,
489,
298,
1513,
6713,
20043,
30447,
582,
298,
7011,
401,
489,
298,
1513,
7084,
30447,
582,
298,
3827,
2,
523,
789,
199,
1302,
26,
523,
1369,
26,
710,
15230,
1768,
663,
370,
314,
943,
265,
2351,
14,
523,
2138,
26,
3182,
523,
730,
26,
6114,
523,
3509,
26,
272,
2881,
63,
354,
26,
489,
1369,
26,
710,
2881,
536,
402,
314,
1768,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
603,
13530,
10354,
272,
15764,
26,
489,
1369,
26,
710,
428,
998,
315,
1059,
1824,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
428,
13,
17,
13,
975,
13,
7507,
1299,
272,
2933,
63,
354,
26,
489,
1369,
26,
710,
2933,
536,
402,
314,
1768,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
16332,
603,
13530,
20400,
272,
730,
26,
489,
1369,
26,
710,
730,
402,
428,
998,
14,
489,
2138,
26,
3182,
489,
730,
26,
620,
489,
2690,
26,
10354,
199,
3236,
31524,
63,
1896,
26,
523,
1369,
26,
710,
1742,
31524,
2166,
402,
314,
1526,
12,
1454,
1686,
340,
272,
445,
8,
1418,
63,
466,
9,
365,
445,
8,
3264,
8499,
31524,
395,
1937,
272,
738,
8,
2859,
921,
706,
4272,
14,
17040,
14,
957,
15,
287,
13,
527,
15,
4342,
15,
8258,
15,
14487,
15,
2158,
12015,
17802,
14,
26146,
680,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
13863,
23902,
199,
2886,
63,
521,
26,
523,
1369,
26,
710,
943,
265,
900,
315,
9055,
10300,
614,
1475,
523,
2138,
26,
3182,
523,
730,
26,
620,
523,
2690,
26,
283,
10680,
13,
845,
13,
1465,
52,
1690,
26,
1194,
26,
1079,
14,
9526,
975,
2182,
11,
709,
26,
383,
7,
199,
2634,
26,
523,
1369,
26,
437,
769,
402,
4652,
436,
3004,
626,
314,
922,
365,
282,
3653,
402,
14,
523,
2138,
26,
3182,
523,
730,
26,
769,
523,
2690,
26,
359,
489,
469,
881,
298,
2048,
63,
354,
582,
298,
7705,
20123,
401,
881,
298,
2261,
63,
354,
582,
298,
7378,
401,
881,
298,
2987,
582,
359,
1598,
298,
45,
13530,
401,
1598,
298,
6589,
701,
849,
401,
1598,
298,
6589,
2,
881,
2156,
881,
298,
4148,
582,
298,
51,
13,
17,
13,
21,
13,
2025,
13,
975,
1477,
1780,
1555,
2766,
13,
2114,
1020,
1887,
8557,
13,
11700,
16042,
2010,
996,
13,
27452,
401,
881,
298,
466,
582,
298,
2448,
2,
489,
1660,
489,
469,
881,
298,
2048,
63,
354,
582,
298,
4880,
3075,
2750,
401,
881,
298,
2261,
63,
354,
582,
298,
18637,
20012,
401,
881,
298,
2987,
582,
359,
1598,
298,
45,
13530,
401,
1598,
298,
6589,
701,
849,
401,
1598,
298,
6589,
401,
1598,
298,
14919,
2,
881,
2156,
881,
298,
4148,
582,
298,
51,
13,
17,
13,
21,
13,
708,
13,
16298,
401,
881,
298,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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
] |
avanzosc/odoo-addons
|
contacts_school/models/res_partner.py
|
2
|
13803
|
# Copyright 2019 Alfredo de la fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
EDU_CATEGORIES = [('federation', 'Federation'),
('association', 'Association'),
('school', 'School'),
('family', 'Family'),
('student', 'Student'),
('progenitor', 'Progenitor'),
('guardian', 'legal guardian'),
('otherchild', 'Other children'),
('pedagogical', 'Pedagogical company'),
('related', 'Related partner'),
('otherrelative', 'Other relative'),
('other', 'Other')]
class ResPartner(models.Model):
_inherit = 'res.partner'
educational_category = fields.Selection(
string='Educational category',
selection=EDU_CATEGORIES, default='other')
assoc_fede_ids = fields.One2many(
comodel_name='res.partner.association.federation',
inverse_name='parent_partner_id', string='Association/Federation')
child2_ids = fields.One2many(
comodel_name='res.partner.family',
inverse_name='child2_id', string='Child Families')
responsible_ids = fields.One2many(
comodel_name='res.partner.family',
inverse_name='responsible_id', string='Responsible Families')
family_ids = fields.One2many(
comodel_name='res.partner.family',
inverse_name='family_id', string='Relatives')
family = fields.Char(string='Family', readonly="1")
old_student = fields.Boolean(string='Old student', default=False)
employee_id = fields.Many2one(
string='Related Employee', comodel_name='hr.employee',
compute='_compute_employee', store=True)
employee = fields.Boolean(compute='_compute_employee', store=True)
student_characteristic_ids = fields.One2many(
comodel_name='res.partner.student.characteristic',
inverse_name='student_id', string='Student Characteristics')
family_progenitor_ids = fields.Many2many(
comodel_name='res.partner', relation='rel_family_progenitor',
column1='family_id', column2='progenitor_id',
compute='_compute_family_progenitor_ids', store=True, copy=False)
student_progenitor_ids = fields.Many2many(
comodel_name='res.partner', relation='rel_student_progenitor',
column1='student_id', column2='progenitor_id',
compute='_compute_student_progenitor_ids', store=True, copy=False,
string="Responsible Relatives")
progenitor_child_ids = fields.Many2many(
comodel_name='res.partner', relation='rel_student_progenitor',
column1='progenitor_id', column2='student_id', readonly=True,
copy=False, string="Relative Students")
bus_passenger = fields.Selection(
selection=[("yes", "Yes"),
("no", "No")], string="Uses Bus")
dinning_hall = fields.Selection(
selection=[("school", "School Meal"),
("home", "Packed Lunch"),
("no", "No")], string="Uses School Dinning Hall")
has_insurance = fields.Boolean(string="Has Insurance?")
insured_partner_ids = fields.Many2many(
comodel_name="res.partner", string="Insured Progenitors",
relation="rel_student_insured",
column1="student_id", column2="progenitor_id")
insured_partner_count = fields.Integer(
string="# Insured Progenitor",
compute="_compute_insured_partner_count", store=True,
compute_sudo=True, group_operator="max")
@api.multi
def name_get(self):
""" name_get() -> [(id, name), ...]
Returns a textual representation for the records in ``self``.
By default this is the value of the ``display_name`` field.
:return: list of pairs ``(id, text_repr)`` for each records
:rtype: list(tuple)
"""
result = []
if not self.env.context.get('hide_progenitors', True):
for record in self:
name = record.name
if record.family_progenitor_ids:
progenitors = ', '.join(
record.mapped('family_progenitor_ids.name'))
name = '{} [{}]'.format(name, progenitors)
result.append((record.id, name))
else:
result = super(ResPartner, self).name_get()
return result
@api.model
def create(self, vals):
if vals.get('educational_category') == 'family':
vals.update({
'family': (self.env['ir.sequence'].next_by_code(
'res.partner.family') or _('New'))
})
return super(ResPartner, self).create(vals)
@api.depends('user_ids', 'user_ids.employee_ids')
def _compute_employee(self):
for record in self.filtered('user_ids'):
record.employee_id = record.mapped('user_ids.employee_ids')[:1]
record.employee = bool(record.employee_id)
@api.depends('family_ids', 'family_ids.relation',
'family_ids.responsible_id', 'educational_category')
def _compute_family_progenitor_ids(self):
for family in self.filtered(
lambda p: p.educational_category == 'family'):
family.family_progenitor_ids = family.family_ids.filtered(
lambda f: f.relation == 'progenitor').mapped('responsible_id')
@api.depends('child2_ids', 'child2_ids.relation',
'child2_ids.responsible_id', 'educational_category')
def _compute_student_progenitor_ids(self):
for student in self.filtered(
lambda p: p.educational_category == 'student'):
student.student_progenitor_ids = student.child2_ids.filtered(
lambda f: f.relation in ['progenitor', 'guardian']
).mapped('responsible_id')
@api.depends("insured_partner_ids")
def _compute_insured_partner_count(self):
for student in self.filtered(
lambda p: p.educational_category == "student" and
p.has_insurance):
student.insured_partner_count = len(student.insured_partner_ids)
@api.constrains('child2_ids')
def _check_payers_percentage(self):
for record in self.filtered('child2_ids'):
if (any(record.child2_ids.filtered('payer')) and sum(
record.child2_ids.filtered('payer').mapped(
'payment_percentage')) != 100.0):
raise ValidationError(
_('The sum of payers percentage must be 100.0'))
@api.multi
def check_payer_is_company(self):
for record in self.filtered(lambda l: l.educational_category in (
'progenitor', 'guardian', 'otherrelative')):
record.is_company = any(record.mapped('responsible_ids.payer'))
@api.multi
def _get_notify_partners(self):
self.ensure_one()
if self.educational_category in ("student", "other_child"):
contact_list = self.student_progenitor_ids
elif self.educational_category in ("family"):
contact_list = self.family_progenitor_ids
else:
contact_list = self
return contact_list.filtered("email") or contact_list
@api.multi
def get_notify_email(self):
self.ensure_one()
contacts = self._get_notify_partners()
return ",".join(contact.email for contact in contacts)
@api.multi
def get_notify_partner_ids(self):
self.ensure_one()
contacts = self._get_notify_partners()
return ",".join(str(contact.id) for contact in contacts)
class ResPartnerAssociationFederation(models.Model):
_name = 'res.partner.association.federation'
_description = 'Partner associations, and federations.'
parent_partner_id = fields.Many2one(
string='Partner parent', comodel_name='res.partner',
required=True)
partner_id = fields.Many2one(
string='Association/Federation', comodel_name='res.partner',
required=True)
education_category = fields.Selection(
string='Educational category', store=True,
related='partner_id.educational_category')
start_date = fields.Date(string='Start date')
end_date = fields.Date(string='End date')
notes = fields.Text(string="Notes")
class ResPartnerFamily(models.Model):
_name = 'res.partner.family'
_description = 'Partner Family'
_rec_name = 'child2_id'
child2_id = fields.Many2one(
string='Student', comodel_name='res.partner', required=True,
domain=[('educational_category', 'in', ('student', 'other'))])
child2_educational_category = fields.Selection(
string='Student Educational Category',
related='child2_id.educational_category', store=True)
responsible_id = fields.Many2one(
string='Responsible', comodel_name='res.partner', required=True,
domain=[('educational_category', 'in',
('progenitor', 'guardian', 'otherrelative'))])
is_company = fields.Boolean(
string='Is a Company', related='responsible_id.is_company',
store=True)
responsible_educational_category = fields.Selection(
string='Responsible educational category',
related='responsible_id.educational_category', store=True)
responsible_old_student = fields.Boolean(
string='Responsible old student', related='responsible_id.old_student',
store=True, readonly=False)
relation = fields.Selection(
string='Relation',
selection=[('progenitor', 'Progenitor'),
('guardian', 'Legal Guardian'),
('otherrelative', 'Other relative')])
family_id = fields.Many2one(
string='Family', comodel_name='res.partner', required=True,
domain=[('educational_category', '=', 'family')])
family_educational_category = fields.Selection(
string='Family educational category',
related='family_id.educational_category', store=True)
family_old_student = fields.Boolean(
string='Family old student', related='family_id.old_student',
store=True)
payer = fields.Boolean(string='Is Payer?')
payment_percentage = fields.Float(string='Percentage', default=100.0)
payment_mode_id = fields.Many2one(
string='Payment Mode', comodel_name='account.payment.mode',
compute="compute_payment_mode", store=True)
bank_id = fields.Many2one(
string='Bank', comodel_name='res.partner.bank',
domain="[('partner_id', '=', responsible_id)]")
_sql_constraints = [
('relation_unique', 'unique(child2_id,responsible_id,family_id)',
'Only one type of relation per student, relative and family!'),
]
@api.model
def create(self, values):
result = super(ResPartnerFamily, self).create(values)
if result.responsible_id:
result.responsible_id.check_payer_is_company()
return result
@api.multi
def write(self, values):
result = super(ResPartnerFamily, self).write(values)
if 'payer' in values or 'responsible_id' in values:
self.mapped('responsible_id').check_payer_is_company()
return result
@api.constrains('payment_percentage')
def _check_payment_percentage(self):
for record in self.filtered('payer'):
if (record.payment_percentage <= 0.0 or
record.payment_percentage > 100.0):
raise ValidationError(
_("Percentage should be between 0.0 and 100.0"))
@api.onchange('responsible_id', 'payer')
def onchange_responsible_id(self):
if self.responsible_id.bank_ids:
self.bank_id = (self.responsible_id.bank_ids.filtered(
lambda c: c.use_default)[:1] or
self.responsible_id.bank_ids[:1])
@api.multi
@api.depends("child2_id", "child2_id.company_id", "responsible_id",
"responsible_id.customer_payment_mode_id")
def compute_payment_mode(self):
for record in self:
record.payment_mode_id = record.responsible_id.with_context(
force_company=record.child2_id.company_id.id
).customer_payment_mode_id
class ResPartnerInformationType(models.Model):
_name = 'res.partner.information.type'
_description = 'Partner information type.'
name = fields.Char(
string='Description', required=True)
class ResPartnerInformation(models.Model):
_name = 'res.partner.information'
_description = 'Partner information.'
name = fields.Char(
string='Description', required=True)
type_id = fields.Many2one(
string='Information type',
comodel_name='res.partner.information.type')
class ResPartnerStudentCharacteristic(models.Model):
_name = 'res.partner.student.characteristic'
_description = 'Student characteristic.'
_rec_name = 'information_id'
student_id = fields.Many2one(
string='Student', comodel_name='res.partner', required=True,
domain=[('educational_category', '=', 'student')])
information_id = fields.Many2one(
string='Information', comodel_name='res.partner.information')
type_id = fields.Many2one(
string='Information type',
comodel_name='res.partner.information.type',
related='information_id.type_id', store=True)
observations = fields.Text(string='Observations')
dop_id = fields.Many2one(
string='DOP', comodel_name='res.partner',
domain=[('employee', '=', True)])
class ResPartnerBank(models.Model):
_inherit = 'res.partner.bank'
use_default = fields.Boolean(string='Use by default', default=False)
|
agpl-3.0
|
[
3,
1898,
20312,
437,
276,
30938,
477,
1127,
15632,
27036,
446,
16599,
290,
90,
31799,
199,
3,
844,
437,
12006,
13,
19,
446,
1666,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
13,
19,
14,
16,
14,
1360,
199,
504,
28811,
492,
5501,
2986,
12,
1504,
12,
1709,
199,
504,
28811,
14,
3924,
492,
8505,
199,
199,
1149,
53,
63,
35,
12649,
28743,
275,
4274,
771,
32643,
297,
283,
3456,
32643,
659,
2116,
661,
20252,
297,
283,
18662,
659,
2116,
661,
23194,
297,
283,
51,
15089,
659,
2116,
661,
6606,
297,
283,
16345,
659,
2116,
661,
5500,
297,
283,
18086,
659,
2116,
661,
496,
2268,
4330,
297,
283,
919,
2268,
4330,
659,
2116,
661,
6051,
31186,
297,
283,
9666,
8129,
31186,
659,
2116,
661,
1848,
1739,
297,
283,
8632,
4978,
659,
2116,
661,
1915,
643,
974,
2652,
297,
283,
48,
379,
643,
974,
2652,
7233,
659,
2116,
661,
2407,
297,
283,
13885,
5854,
659,
2116,
661,
1848,
6188,
297,
283,
8632,
3847,
659,
2116,
661,
1848,
297,
283,
8632,
5440,
421,
199,
533,
3591,
24120,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
3899,
7,
339,
3988,
947,
6279,
63,
3710,
275,
1504,
14,
7713,
8,
267,
1059,
534,
37,
5905,
6279,
4637,
297,
267,
7267,
29,
1149,
53,
63,
35,
12649,
28743,
12,
849,
534,
1848,
358,
272,
22149,
63,
771,
271,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
20252,
14,
771,
32643,
297,
267,
11484,
63,
354,
534,
1708,
63,
3899,
63,
344,
297,
1059,
534,
18662,
15,
3456,
32643,
358,
272,
1982,
18,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
1739,
18,
63,
344,
297,
1059,
534,
3493,
481,
455,
20111,
358,
272,
17845,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
3853,
1164,
63,
344,
297,
1059,
534,
1322,
678,
1164,
481,
455,
20111,
358,
272,
9614,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
6606,
63,
344,
297,
1059,
534,
5640,
10661,
358,
272,
9614,
275,
1504,
14,
1610,
8,
875,
534,
16345,
297,
6863,
628,
17,
531,
272,
2269,
63,
5500,
275,
1504,
14,
4082,
8,
875,
534,
16411,
6474,
297,
849,
29,
797,
9,
272,
15778,
63,
344,
275,
1504,
14,
4089,
18,
368,
8,
267,
1059,
534,
13885,
24089,
297,
512,
1238,
63,
354,
534,
6271,
14,
10103,
297,
267,
4526,
17574,
3357,
63,
10103,
297,
3877,
29,
549,
9,
272,
15778,
275,
1504,
14,
4082,
8,
3357,
17574,
3357,
63,
10103,
297,
3877,
29,
549,
9,
272,
6474,
63,
1560,
14299,
11108,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
5500,
14,
1560,
14299,
11108,
297,
267,
11484,
63,
354,
534,
5500,
63,
344,
297,
1059,
534,
18086,
6659,
29867,
358,
272,
9614,
63,
496,
2268,
4330,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
6606,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
6606,
63,
344,
297,
2763,
18,
534,
496,
2268,
4330,
63,
344,
297,
267,
4526,
17574,
3357,
63,
6606,
63,
496,
2268,
4330,
63,
1580,
297,
3877,
29,
549,
12,
1331,
29,
797,
9,
272,
6474,
63,
496,
2268,
4330,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
5500,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
5500,
63,
344,
297,
2763,
18,
534,
496,
2268,
4330,
63,
344,
297,
267,
4526,
17574,
3357,
63,
5500,
63,
496,
2268,
4330,
63,
1580,
297,
3877,
29,
549,
12,
1331,
29,
797,
12,
267,
1059,
628,
1322,
678,
1164,
9781,
10661,
531,
272,
557,
2268,
4330,
63,
1739,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
5500,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
496,
2268,
4330,
63,
344,
297,
2763,
18,
534,
5500,
63,
344,
297,
6863,
29,
549,
12,
267,
1331,
29,
797,
12,
1059,
628,
15277,
17246,
83,
531,
272,
10414,
63,
15534,
23444,
275,
1504,
14,
7713,
8,
267,
7267,
1524,
480,
5066,
401,
298,
12555,
1288,
673,
1689,
889,
401,
298,
1944,
17857,
1059,
628,
21896,
18573,
531,
272,
366,
262,
1835,
63,
72,
452,
275,
1504,
14,
7713,
8,
267,
7267,
1524,
480,
23194,
401,
298,
51,
15089,
3194,
279,
1288,
673,
1689,
4219,
401,
298,
25301,
491,
4689,
1288,
673,
1689,
889,
401,
298,
1944,
17857,
1059,
628,
21896,
428,
15089,
577,
262,
1835,
869,
452,
531,
272,
965,
63,
3617,
300,
554,
275,
1504,
14,
4082,
8,
875,
628,
6362,
12062,
300,
554,
18582,
272,
5261,
3297,
63,
3899,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
628,
470,
14,
3899,
401,
1059,
628,
13962,
3297,
2165,
2268,
16127,
401,
267,
5850,
628,
3369,
63,
5500,
63,
3617,
3297,
401,
267,
2763,
17,
628,
5500,
63,
344,
401,
2763,
18,
628,
496,
2268,
4330,
63,
344,
531,
272,
5261,
3297,
63,
3899,
63,
835,
275,
1504,
14,
2674,
8,
267,
1059,
13476,
12062,
3297,
2165,
2268,
4330,
401,
267,
4526,
19667,
3357,
63,
3617,
3297,
63,
3899,
63,
835,
401,
3877,
29,
549,
12,
267,
4526,
63,
12095,
29,
549,
12,
1572,
63,
3856,
628,
988,
531,
339,
768,
1246,
14,
3029,
272,
347,
536,
63,
362,
8,
277,
304,
267,
408,
536,
63,
362,
342,
1035,
3842,
344,
12,
536,
395,
21214,
398,
1803,
282,
25884,
6025,
367,
314,
5767,
315,
1124,
277,
4345,
267,
4885,
849,
642,
365,
314,
574,
402,
314,
1124,
2918,
63,
354,
1040,
901,
14,
398,
520,
1107,
26,
769,
402,
6342,
15475,
344,
12,
1318,
63,
2722
] |
[
1898,
20312,
437,
276,
30938,
477,
1127,
15632,
27036,
446,
16599,
290,
90,
31799,
199,
3,
844,
437,
12006,
13,
19,
446,
1666,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
13,
19,
14,
16,
14,
1360,
199,
504,
28811,
492,
5501,
2986,
12,
1504,
12,
1709,
199,
504,
28811,
14,
3924,
492,
8505,
199,
199,
1149,
53,
63,
35,
12649,
28743,
275,
4274,
771,
32643,
297,
283,
3456,
32643,
659,
2116,
661,
20252,
297,
283,
18662,
659,
2116,
661,
23194,
297,
283,
51,
15089,
659,
2116,
661,
6606,
297,
283,
16345,
659,
2116,
661,
5500,
297,
283,
18086,
659,
2116,
661,
496,
2268,
4330,
297,
283,
919,
2268,
4330,
659,
2116,
661,
6051,
31186,
297,
283,
9666,
8129,
31186,
659,
2116,
661,
1848,
1739,
297,
283,
8632,
4978,
659,
2116,
661,
1915,
643,
974,
2652,
297,
283,
48,
379,
643,
974,
2652,
7233,
659,
2116,
661,
2407,
297,
283,
13885,
5854,
659,
2116,
661,
1848,
6188,
297,
283,
8632,
3847,
659,
2116,
661,
1848,
297,
283,
8632,
5440,
421,
199,
533,
3591,
24120,
8,
992,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
3899,
7,
339,
3988,
947,
6279,
63,
3710,
275,
1504,
14,
7713,
8,
267,
1059,
534,
37,
5905,
6279,
4637,
297,
267,
7267,
29,
1149,
53,
63,
35,
12649,
28743,
12,
849,
534,
1848,
358,
272,
22149,
63,
771,
271,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
20252,
14,
771,
32643,
297,
267,
11484,
63,
354,
534,
1708,
63,
3899,
63,
344,
297,
1059,
534,
18662,
15,
3456,
32643,
358,
272,
1982,
18,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
1739,
18,
63,
344,
297,
1059,
534,
3493,
481,
455,
20111,
358,
272,
17845,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
3853,
1164,
63,
344,
297,
1059,
534,
1322,
678,
1164,
481,
455,
20111,
358,
272,
9614,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
6606,
297,
267,
11484,
63,
354,
534,
6606,
63,
344,
297,
1059,
534,
5640,
10661,
358,
272,
9614,
275,
1504,
14,
1610,
8,
875,
534,
16345,
297,
6863,
628,
17,
531,
272,
2269,
63,
5500,
275,
1504,
14,
4082,
8,
875,
534,
16411,
6474,
297,
849,
29,
797,
9,
272,
15778,
63,
344,
275,
1504,
14,
4089,
18,
368,
8,
267,
1059,
534,
13885,
24089,
297,
512,
1238,
63,
354,
534,
6271,
14,
10103,
297,
267,
4526,
17574,
3357,
63,
10103,
297,
3877,
29,
549,
9,
272,
15778,
275,
1504,
14,
4082,
8,
3357,
17574,
3357,
63,
10103,
297,
3877,
29,
549,
9,
272,
6474,
63,
1560,
14299,
11108,
63,
1580,
275,
1504,
14,
4395,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
14,
5500,
14,
1560,
14299,
11108,
297,
267,
11484,
63,
354,
534,
5500,
63,
344,
297,
1059,
534,
18086,
6659,
29867,
358,
272,
9614,
63,
496,
2268,
4330,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
6606,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
6606,
63,
344,
297,
2763,
18,
534,
496,
2268,
4330,
63,
344,
297,
267,
4526,
17574,
3357,
63,
6606,
63,
496,
2268,
4330,
63,
1580,
297,
3877,
29,
549,
12,
1331,
29,
797,
9,
272,
6474,
63,
496,
2268,
4330,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
5500,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
5500,
63,
344,
297,
2763,
18,
534,
496,
2268,
4330,
63,
344,
297,
267,
4526,
17574,
3357,
63,
5500,
63,
496,
2268,
4330,
63,
1580,
297,
3877,
29,
549,
12,
1331,
29,
797,
12,
267,
1059,
628,
1322,
678,
1164,
9781,
10661,
531,
272,
557,
2268,
4330,
63,
1739,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
534,
470,
14,
3899,
297,
5850,
534,
3369,
63,
5500,
63,
496,
2268,
4330,
297,
267,
2763,
17,
534,
496,
2268,
4330,
63,
344,
297,
2763,
18,
534,
5500,
63,
344,
297,
6863,
29,
549,
12,
267,
1331,
29,
797,
12,
1059,
628,
15277,
17246,
83,
531,
272,
10414,
63,
15534,
23444,
275,
1504,
14,
7713,
8,
267,
7267,
1524,
480,
5066,
401,
298,
12555,
1288,
673,
1689,
889,
401,
298,
1944,
17857,
1059,
628,
21896,
18573,
531,
272,
366,
262,
1835,
63,
72,
452,
275,
1504,
14,
7713,
8,
267,
7267,
1524,
480,
23194,
401,
298,
51,
15089,
3194,
279,
1288,
673,
1689,
4219,
401,
298,
25301,
491,
4689,
1288,
673,
1689,
889,
401,
298,
1944,
17857,
1059,
628,
21896,
428,
15089,
577,
262,
1835,
869,
452,
531,
272,
965,
63,
3617,
300,
554,
275,
1504,
14,
4082,
8,
875,
628,
6362,
12062,
300,
554,
18582,
272,
5261,
3297,
63,
3899,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
8,
267,
512,
1238,
63,
354,
628,
470,
14,
3899,
401,
1059,
628,
13962,
3297,
2165,
2268,
16127,
401,
267,
5850,
628,
3369,
63,
5500,
63,
3617,
3297,
401,
267,
2763,
17,
628,
5500,
63,
344,
401,
2763,
18,
628,
496,
2268,
4330,
63,
344,
531,
272,
5261,
3297,
63,
3899,
63,
835,
275,
1504,
14,
2674,
8,
267,
1059,
13476,
12062,
3297,
2165,
2268,
4330,
401,
267,
4526,
19667,
3357,
63,
3617,
3297,
63,
3899,
63,
835,
401,
3877,
29,
549,
12,
267,
4526,
63,
12095,
29,
549,
12,
1572,
63,
3856,
628,
988,
531,
339,
768,
1246,
14,
3029,
272,
347,
536,
63,
362,
8,
277,
304,
267,
408,
536,
63,
362,
342,
1035,
3842,
344,
12,
536,
395,
21214,
398,
1803,
282,
25884,
6025,
367,
314,
5767,
315,
1124,
277,
4345,
267,
4885,
849,
642,
365,
314,
574,
402,
314,
1124,
2918,
63,
354,
1040,
901,
14,
398,
520,
1107,
26,
769,
402,
6342,
15475,
344,
12,
1318,
63,
2722,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rossasa/server-tools
|
server_environment/__openerp__.py
|
17
|
3367
|
# -*- coding: utf-8 -*-
##############################################################################
#
# Adapted by Nicolas Bessi. Copyright Camptocamp SA
# Based on Florent Xicluna original code. Copyright Wingo SA
#
# 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/>.
#
##############################################################################
{
"name": "server configuration environment files",
"version": "8.0.1.1.0",
"depends": ["base", "server_environment_files"],
"author": "Camptocamp,Odoo Community Association (OCA)",
"description": """\
Environment file pattern for OpenERP
====================================
This module provides a classical configuration by environnement file
pattern into OpenERP. Based on code written by WinGo and Camptocamp.
This module allows you to use the classical environment file pattern
by reading a directive call `running_env` in the OpenERP configuration
file::
[options]
running_env=dev / prod / etc.
We intended to add a server command line but there is no correct way
to do it.
This method allows you to keep your settings into a module instead of
using config files that might be mixed with openerprc or altered. It
is an alternative way to the base config file for such configuration
needs . All your configurations will be read only and accessible
under the admin menu. If you are not in the 'dev' environment you
will not be able to see the values contained in keys named 'passw'.
At the current time, the module does not allow to set low level
attributes such as database server, etc. .
The first goal of the module is to ensure that OpenERP will never mess
up the external system. Once installed, profile is mandatory. We do
not want to launch an instance in the dev environment on a production
server.
The configuration files are stored in the `server_environment_files`
module, and user config parser module syntax. Look at the module to
get some examples. The `default` configuration are stored in the
`default/` directory. You can add one directory for each environment
you want to define, named after the environment. All config defined in
non-default environments will override or complement the default
config. If your attibutes contain `passw`, it will only be shown in
the `dev` environment.
Example usage
-------------
::
from server_environment import serv_config
for key, value in serv_config.items('external_service.ftp'):
print (key, value)
serv_config.get('external_service.ftp', 'tls')
""",
"website": "http://www.camptocamp.com",
"license": "GPL-3 or any later version",
"category": "Tools",
"data": [
'serv_config.xml',
],
"installable": True,
"active": False,
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
4431,
18309,
701,
30650,
761,
305,
699,
28601,
14,
1898,
24569,
475,
20290,
13950,
199,
3,
259,
21311,
641,
481,
320,
640,
1323,
73,
429,
31627,
3379,
1233,
14,
1898,
644,
316,
79,
13950,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
91,
272,
298,
354,
582,
298,
1000,
2897,
3734,
1584,
401,
272,
298,
1023,
582,
298,
24,
14,
16,
14,
17,
14,
17,
14,
16,
401,
272,
298,
8912,
582,
2097,
1095,
401,
298,
1000,
63,
5418,
63,
1725,
2255,
272,
298,
2502,
582,
298,
3630,
311,
475,
20290,
12,
47,
16766,
7046,
6639,
24207,
425,
334,
47,
3263,
4186,
272,
298,
1802,
582,
9638,
199,
8263,
570,
3851,
367,
7653,
199,
2486,
532,
199,
199,
2765,
859,
6571,
282,
11534,
915,
2897,
701,
6160,
685,
434,
570,
199,
3401,
1901,
7653,
14,
221,
21311,
641,
1233,
5313,
701,
13036,
7250,
436,
24569,
475,
20290,
14,
199,
199,
2765,
859,
6127,
1265,
370,
675,
314,
11534,
915,
3734,
570,
3851,
199,
991,
7664,
282,
13613,
1240,
658,
5720,
63,
1813,
64,
315,
314,
7653,
2897,
199,
493,
447,
339,
359,
1419,
61,
272,
3879,
63,
1813,
29,
2374,
1182,
12441,
1182,
5423,
14,
199,
199,
6004,
11619,
370,
1050,
282,
1654,
1414,
1004,
1325,
2337,
365,
949,
3211,
4340,
199,
475,
886,
652,
14,
199,
199,
2765,
1083,
6127,
1265,
370,
4215,
2195,
2202,
1901,
282,
859,
3140,
402,
199,
4941,
1101,
1584,
626,
5594,
506,
13492,
543,
5166,
1195,
503,
29815,
14,
221,
2779,
199,
374,
376,
13943,
4340,
370,
314,
1300,
1101,
570,
367,
4066,
2897,
199,
10065,
1275,
221,
2900,
2195,
13422,
911,
506,
1586,
1454,
436,
17909,
199,
7138,
314,
4628,
6269,
14,
221,
982,
1265,
787,
440,
315,
314,
283,
2374,
7,
3734,
1265,
199,
14117,
440,
506,
7688,
370,
1937,
314,
1338,
10470,
315,
2883,
4310,
283,
1529,
87,
1370,
199,
199,
1271,
314,
1453,
900,
12,
314,
859,
1630,
440,
2040,
370,
663,
6465,
2166,
199,
2987,
4066,
465,
3050,
1654,
12,
5423,
14,
1275,
199,
199,
1918,
1642,
14850,
402,
314,
859,
365,
370,
4868,
626,
7653,
911,
7078,
15634,
199,
384,
314,
5957,
2656,
14,
221,
19468,
4903,
12,
4690,
365,
15230,
14,
2136,
886,
199,
1397,
2934,
370,
10623,
376,
1256,
315,
314,
4866,
3734,
641,
282,
9920,
199,
1000,
14,
199,
199,
1918,
2897,
1584,
787,
5489,
315,
314,
658,
1000,
63,
5418,
63,
1725,
64,
199,
578,
12,
436,
922,
1101,
1798,
859,
6302,
14,
221,
12077,
737,
314,
859,
370,
199,
362,
2005,
7251,
14,
221,
710,
658,
885,
64,
2897,
787,
5489,
315,
314,
199,
64,
885,
15,
64,
2082,
14,
2047,
883,
1050,
1373,
2082,
367,
1924,
3734,
199,
13297,
2934,
370,
5627,
12,
4310,
2410,
314,
3734,
14,
2900,
1101,
3247,
315,
199,
2865,
13,
885,
22196,
911,
4278,
503,
2831,
434,
314,
849,
199,
888,
14,
982,
2195,
737,
280,
464,
744,
1395,
658,
1529,
87,
3559,
652,
911,
1454,
506,
9164,
315,
199,
1589,
658,
2374,
64,
3734,
14,
199,
199,
9846,
4503,
199,
8684,
199,
199,
447,
339,
687,
1654,
63,
5418,
492,
27415,
63,
888,
272,
367,
790,
12,
574,
315,
27415,
63,
888,
14,
1744,
360,
5159,
63,
1364,
14,
8915,
735,
2126,
870,
334,
498,
12,
574,
9,
339,
27415,
63,
888,
14,
362,
360,
5159,
63,
1364,
14,
8915,
297,
283,
9945,
358,
272,
10327,
272,
298,
7360,
582,
298,
1014,
921,
1544,
14,
20290,
475,
20290,
14,
957,
401,
272,
298,
1682,
582,
298,
12006,
13,
19,
503,
1263,
2945,
1015,
401,
272,
298,
3710,
582,
298,
11654,
401,
272,
298,
576,
582,
359,
267,
283,
7297,
63,
888,
14,
1652,
297,
272,
2156,
272,
298,
21762,
582,
715,
12,
272,
298,
2682,
582,
756,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
4431,
18309,
701,
30650,
761,
305,
699,
28601,
14,
1898,
24569,
475,
20290,
13950,
199,
3,
259,
21311,
641,
481,
320,
640,
1323,
73,
429,
31627,
3379,
1233,
14,
1898,
644,
316,
79,
13950,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
259,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
259,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
91,
272,
298,
354,
582,
298,
1000,
2897,
3734,
1584,
401,
272,
298,
1023,
582,
298,
24,
14,
16,
14,
17,
14,
17,
14,
16,
401,
272,
298,
8912,
582,
2097,
1095,
401,
298,
1000,
63,
5418,
63,
1725,
2255,
272,
298,
2502,
582,
298,
3630,
311,
475,
20290,
12,
47,
16766,
7046,
6639,
24207,
425,
334,
47,
3263,
4186,
272,
298,
1802,
582,
9638,
199,
8263,
570,
3851,
367,
7653,
199,
2486,
532,
199,
199,
2765,
859,
6571,
282,
11534,
915,
2897,
701,
6160,
685,
434,
570,
199,
3401,
1901,
7653,
14,
221,
21311,
641,
1233,
5313,
701,
13036,
7250,
436,
24569,
475,
20290,
14,
199,
199,
2765,
859,
6127,
1265,
370,
675,
314,
11534,
915,
3734,
570,
3851,
199,
991,
7664,
282,
13613,
1240,
658,
5720,
63,
1813,
64,
315,
314,
7653,
2897,
199,
493,
447,
339,
359,
1419,
61,
272,
3879,
63,
1813,
29,
2374,
1182,
12441,
1182,
5423,
14,
199,
199,
6004,
11619,
370,
1050,
282,
1654,
1414,
1004,
1325,
2337,
365,
949,
3211,
4340,
199,
475,
886,
652,
14,
199,
199,
2765,
1083,
6127,
1265,
370,
4215,
2195,
2202,
1901,
282,
859,
3140,
402,
199,
4941,
1101,
1584,
626,
5594,
506,
13492,
543,
5166,
1195,
503,
29815,
14,
221,
2779,
199,
374,
376,
13943,
4340,
370,
314,
1300,
1101,
570,
367,
4066,
2897,
199,
10065,
1275,
221,
2900,
2195,
13422,
911,
506,
1586,
1454,
436,
17909,
199,
7138,
314,
4628,
6269,
14,
221,
982,
1265,
787,
440,
315,
314,
283,
2374,
7,
3734,
1265,
199,
14117,
440,
506,
7688,
370,
1937,
314,
1338,
10470,
315,
2883,
4310,
283,
1529,
87,
1370,
199,
199,
1271,
314,
1453,
900,
12,
314,
859,
1630,
440,
2040,
370,
663,
6465,
2166,
199,
2987,
4066,
465,
3050,
1654,
12,
5423,
14,
1275,
199,
199,
1918,
1642,
14850,
402,
314,
859,
365,
370,
4868,
626,
7653,
911,
7078,
15634,
199,
384,
314,
5957,
2656,
14,
221,
19468,
4903,
12,
4690,
365,
15230,
14,
2136,
886,
199,
1397,
2934,
370,
10623,
376,
1256,
315,
314,
4866,
3734,
641,
282,
9920,
199,
1000,
14,
199,
199,
1918,
2897,
1584,
787,
5489,
315,
314,
658,
1000,
63,
5418,
63,
1725,
64,
199,
578,
12,
436,
922,
1101,
1798,
859,
6302,
14,
221,
12077,
737,
314,
859,
370,
199,
362,
2005,
7251,
14,
221,
710,
658,
885,
64,
2897,
787,
5489,
315,
314,
199,
64,
885,
15,
64,
2082,
14,
2047,
883,
1050,
1373,
2082,
367,
1924,
3734,
199,
13297,
2934,
370,
5627,
12,
4310,
2410,
314,
3734,
14,
2900,
1101,
3247,
315,
199,
2865,
13,
885,
22196,
911,
4278,
503,
2831,
434,
314,
849,
199,
888,
14,
982,
2195,
737,
280,
464,
744,
1395,
658,
1529,
87,
3559,
652,
911,
1454,
506,
9164,
315,
199,
1589,
658,
2374,
64,
3734,
14,
199,
199,
9846,
4503,
199,
8684,
199,
199,
447,
339,
687,
1654,
63,
5418,
492,
27415,
63,
888,
272,
367,
790,
12,
574,
315,
27415,
63,
888,
14,
1744,
360,
5159,
63,
1364,
14,
8915,
735,
2126,
870,
334,
498,
12,
574,
9,
339,
27415,
63,
888,
14,
362,
360,
5159,
63,
1364,
14,
8915,
297,
283,
9945,
358,
272,
10327,
272,
298,
7360,
582,
298,
1014,
921,
1544,
14,
20290,
475,
20290,
14,
957,
401,
272,
298,
1682,
582,
298,
12006,
13,
19,
503,
1263,
2945,
1015,
401,
272,
298,
3710,
582,
298,
11654,
401,
272,
298,
576,
582,
359,
267,
283,
7297,
63,
888,
14,
1652,
297,
272,
2156,
272,
298,
21762,
582,
715,
12,
272,
298,
2682,
582,
756,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
boutiques/schema
|
tools/python/boutiques/tests/test_logger.py
|
1
|
2801
|
#!/usr/bin/env python
import os
import pytest
import json
import boutiques as bosh
import boutiques.creator as bc
from boutiques import __file__ as bfile
from boutiques.localExec import ExecutorError
from argparse import ArgumentParser
from unittest import TestCase
import mock
from boutiques_mocks import mock_zenodo_search, MockZenodoRecord
def mock_get(*args, **kwargs):
query = args[0].split("=")[1]
query = query[:query.find("&")]
query = query.replace("*", '')
mock_records = []
# Return an arbitrary list of results
for i in range(0, 10):
mock_records.append(MockZenodoRecord(i, "Example Tool %s" % i))
return mock_zenodo_search(mock_records)
class TestLogger(TestCase):
def get_examples_dir(self):
return os.path.join(os.path.dirname(bfile),
"schema", "examples")
def test_raise_error(self):
example1_dir = os.path.join(self.get_examples_dir(), "example1")
invocationStr = open(os.path.join(example1_dir,
"invocation_invalid.json")).read()
with pytest.raises(ExecutorError) as e:
bosh.execute("launch",
os.path.join(example1_dir,
"example1_docker.json"),
invocationStr)
assert("[ ERROR ]" in str(e))
@mock.patch('requests.get', side_effect=mock_get)
def test_print_info(self, mock_get):
bosh.search("-v")
out, err = self.capfd.readouterr()
assert("[ INFO ]" in out)
assert("[ INFO (200) " in out)
def test_print_warning(self):
parser = ArgumentParser(description="my tool description")
parser.add_argument("--myarg", "-m", action="store",
help="my help", dest="==SUPPRESS==")
creatorObj = bc.CreateDescriptor(parser,
execname='/path/to/myscript.py',
verbose=True,
tags={"purpose": "testing-creator",
"foo": "bar"})
out, err = self.capfd.readouterr()
assert("[ WARNING ]" in out)
def test_evaloutput(self):
example1_dir = os.path.join(self.get_examples_dir(), "example1")
desc = os.path.join(example1_dir, "example1_docker.json")
invo = os.path.join(example1_dir, "invocation.json")
query = bosh.evaluate(desc, invo, "invalid-query")
out, err = self.capfd.readouterr()
assert("[ ERROR ]" in out)
# Captures the stdout and stderr during test execution
# and returns them as a tuple in readouterr()
@pytest.fixture(autouse=True)
def capfd(self, capfd):
self.capfd = capfd
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
4613,
199,
646,
2022,
199,
646,
330,
810,
280,
19658,
465,
1234,
609,
199,
646,
330,
810,
280,
19658,
14,
9986,
465,
16604,
199,
504,
330,
810,
280,
19658,
492,
636,
493,
363,
465,
330,
493,
199,
504,
330,
810,
280,
19658,
14,
1832,
4858,
492,
9434,
4139,
547,
199,
504,
7534,
492,
27615,
199,
504,
2882,
492,
7640,
199,
646,
1683,
199,
504,
330,
810,
280,
19658,
63,
25191,
492,
1683,
63,
5193,
19657,
63,
1733,
12,
4420,
58,
287,
19657,
5433,
421,
199,
318,
1683,
63,
362,
2031,
589,
12,
1011,
958,
304,
272,
1827,
275,
1249,
59,
16,
1055,
1294,
480,
29,
9981,
17,
61,
272,
1827,
275,
1827,
1491,
1131,
14,
1623,
22077,
11323,
272,
1827,
275,
1827,
14,
1814,
480,
14421,
4074,
339,
1683,
63,
6502,
275,
942,
272,
327,
1432,
376,
9697,
769,
402,
2058,
272,
367,
284,
315,
1425,
8,
16,
12,
1616,
304,
267,
1683,
63,
6502,
14,
740,
8,
3346,
58,
287,
19657,
5433,
8,
73,
12,
298,
9846,
15650,
450,
83,
2,
450,
284,
430,
272,
372,
1683,
63,
5193,
19657,
63,
1733,
8,
1805,
63,
6502,
9,
421,
199,
533,
1379,
4455,
8,
1746,
304,
339,
347,
664,
63,
8589,
63,
694,
8,
277,
304,
267,
372,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
66,
493,
395,
1169,
298,
3629,
401,
298,
8589,
531,
339,
347,
511,
63,
3730,
63,
705,
8,
277,
304,
267,
2893,
17,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
8589,
63,
694,
1062,
298,
2694,
17,
531,
267,
19569,
2848,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
5101,
298,
30158,
63,
3197,
14,
1001,
21688,
739,
342,
267,
543,
4613,
14,
3536,
8,
16752,
547,
9,
465,
325,
26,
288,
1234,
609,
14,
2526,
480,
9850,
401,
586,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
4228,
298,
2694,
17,
63,
9991,
14,
1001,
1288,
586,
19569,
2848,
9,
267,
702,
10994,
12539,
1622,
2,
315,
620,
8,
69,
430,
339,
768,
1805,
14,
2068,
360,
6615,
14,
362,
297,
5366,
63,
5881,
29,
1805,
63,
362,
9,
272,
347,
511,
63,
1361,
63,
815,
8,
277,
12,
1683,
63,
362,
304,
267,
1234,
609,
14,
1733,
6096,
86,
531,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
24008,
1622,
2,
315,
734,
9,
267,
702,
10994,
24008,
334,
1840,
9,
298,
315,
734,
9,
339,
347,
511,
63,
1361,
63,
3764,
8,
277,
304,
267,
1798,
275,
27615,
8,
1802,
628,
1662,
4744,
1369,
531,
267,
1798,
14,
525,
63,
2094,
6739,
1662,
1273,
401,
3905,
77,
401,
1595,
628,
1617,
401,
1169,
1720,
628,
1662,
1720,
401,
2053,
628,
389,
24023,
389,
531,
267,
14875,
5665,
275,
16604,
14,
2499,
4311,
8,
2087,
12,
1460,
2146,
354,
8805,
515,
15,
475,
15,
1662,
1579,
14,
647,
297,
1460,
3376,
29,
549,
12,
1460,
3762,
8871,
22615,
582,
298,
4776,
13,
9986,
401,
6901,
298,
1421,
582,
298,
1700,
5984,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
14750,
1622,
2,
315,
734,
9,
339,
347,
511,
63,
2579,
1199,
8,
277,
304,
267,
2893,
17,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
8589,
63,
694,
1062,
298,
2694,
17,
531,
267,
4328,
275,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
298,
2694,
17,
63,
9991,
14,
1001,
531,
267,
315,
2392,
275,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
298,
30158,
14,
1001,
531,
267,
1827,
275,
1234,
609,
14,
7383,
8,
3257,
12,
315,
2392,
12,
298,
3197,
13,
1131,
531,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
12539,
1622,
2,
315,
734,
9,
339,
327,
25534,
1482,
314,
3839,
436,
4635,
5309,
511,
6451,
272,
327,
436,
2529,
3062,
465,
282,
2008,
315,
1586,
7837,
82,
342,
272,
768,
4462,
14,
5997,
8,
6898,
7130,
29,
549,
9,
272,
347,
4021,
2592,
8,
277,
12,
4021,
2592,
304,
267,
291,
14,
2874,
2592,
275,
4021,
2592,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
4613,
199,
646,
2022,
199,
646,
330,
810,
280,
19658,
465,
1234,
609,
199,
646,
330,
810,
280,
19658,
14,
9986,
465,
16604,
199,
504,
330,
810,
280,
19658,
492,
636,
493,
363,
465,
330,
493,
199,
504,
330,
810,
280,
19658,
14,
1832,
4858,
492,
9434,
4139,
547,
199,
504,
7534,
492,
27615,
199,
504,
2882,
492,
7640,
199,
646,
1683,
199,
504,
330,
810,
280,
19658,
63,
25191,
492,
1683,
63,
5193,
19657,
63,
1733,
12,
4420,
58,
287,
19657,
5433,
421,
199,
318,
1683,
63,
362,
2031,
589,
12,
1011,
958,
304,
272,
1827,
275,
1249,
59,
16,
1055,
1294,
480,
29,
9981,
17,
61,
272,
1827,
275,
1827,
1491,
1131,
14,
1623,
22077,
11323,
272,
1827,
275,
1827,
14,
1814,
480,
14421,
4074,
339,
1683,
63,
6502,
275,
942,
272,
327,
1432,
376,
9697,
769,
402,
2058,
272,
367,
284,
315,
1425,
8,
16,
12,
1616,
304,
267,
1683,
63,
6502,
14,
740,
8,
3346,
58,
287,
19657,
5433,
8,
73,
12,
298,
9846,
15650,
450,
83,
2,
450,
284,
430,
272,
372,
1683,
63,
5193,
19657,
63,
1733,
8,
1805,
63,
6502,
9,
421,
199,
533,
1379,
4455,
8,
1746,
304,
339,
347,
664,
63,
8589,
63,
694,
8,
277,
304,
267,
372,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
66,
493,
395,
1169,
298,
3629,
401,
298,
8589,
531,
339,
347,
511,
63,
3730,
63,
705,
8,
277,
304,
267,
2893,
17,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
8589,
63,
694,
1062,
298,
2694,
17,
531,
267,
19569,
2848,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
5101,
298,
30158,
63,
3197,
14,
1001,
21688,
739,
342,
267,
543,
4613,
14,
3536,
8,
16752,
547,
9,
465,
325,
26,
288,
1234,
609,
14,
2526,
480,
9850,
401,
586,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
4228,
298,
2694,
17,
63,
9991,
14,
1001,
1288,
586,
19569,
2848,
9,
267,
702,
10994,
12539,
1622,
2,
315,
620,
8,
69,
430,
339,
768,
1805,
14,
2068,
360,
6615,
14,
362,
297,
5366,
63,
5881,
29,
1805,
63,
362,
9,
272,
347,
511,
63,
1361,
63,
815,
8,
277,
12,
1683,
63,
362,
304,
267,
1234,
609,
14,
1733,
6096,
86,
531,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
24008,
1622,
2,
315,
734,
9,
267,
702,
10994,
24008,
334,
1840,
9,
298,
315,
734,
9,
339,
347,
511,
63,
1361,
63,
3764,
8,
277,
304,
267,
1798,
275,
27615,
8,
1802,
628,
1662,
4744,
1369,
531,
267,
1798,
14,
525,
63,
2094,
6739,
1662,
1273,
401,
3905,
77,
401,
1595,
628,
1617,
401,
1169,
1720,
628,
1662,
1720,
401,
2053,
628,
389,
24023,
389,
531,
267,
14875,
5665,
275,
16604,
14,
2499,
4311,
8,
2087,
12,
1460,
2146,
354,
8805,
515,
15,
475,
15,
1662,
1579,
14,
647,
297,
1460,
3376,
29,
549,
12,
1460,
3762,
8871,
22615,
582,
298,
4776,
13,
9986,
401,
6901,
298,
1421,
582,
298,
1700,
5984,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
14750,
1622,
2,
315,
734,
9,
339,
347,
511,
63,
2579,
1199,
8,
277,
304,
267,
2893,
17,
63,
694,
275,
747,
14,
515,
14,
904,
8,
277,
14,
362,
63,
8589,
63,
694,
1062,
298,
2694,
17,
531,
267,
4328,
275,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
298,
2694,
17,
63,
9991,
14,
1001,
531,
267,
315,
2392,
275,
747,
14,
515,
14,
904,
8,
2694,
17,
63,
694,
12,
298,
30158,
14,
1001,
531,
267,
1827,
275,
1234,
609,
14,
7383,
8,
3257,
12,
315,
2392,
12,
298,
3197,
13,
1131,
531,
267,
734,
12,
2329,
275,
291,
14,
2874,
2592,
14,
739,
7837,
82,
342,
267,
702,
10994,
12539,
1622,
2,
315,
734,
9,
339,
327,
25534,
1482,
314,
3839,
436,
4635,
5309,
511,
6451,
272,
327,
436,
2529,
3062,
465,
282,
2008,
315,
1586,
7837,
82,
342,
272,
768,
4462,
14,
5997,
8,
6898,
7130,
29,
549,
9,
272,
347,
4021,
2592,
8,
277,
12,
4021,
2592,
304,
267,
291,
14,
2874,
2592,
275,
4021,
2592,
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,
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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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
] |
jgeskens/django
|
django/contrib/gis/tests/geoadmin/tests.py
|
5
|
2490
|
from __future__ import absolute_import
from django.test import TestCase
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from django.utils.unittest import skipUnless
if HAS_GEOS and HAS_SPATIAL_DB:
from django.contrib.gis import admin
from django.contrib.gis.geos import Point
from .models import City
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoAdminTest(TestCase):
urls = 'django.contrib.gis.tests.geoadmin.urls'
def test_ensure_geographic_media(self):
geoadmin = admin.site._registry[City]
admin_js = geoadmin.media.render_js()
self.assertTrue(any([geoadmin.openlayers_url in js for js in admin_js]))
def test_olmap_OSM_rendering(self):
geoadmin = admin.site._registry[City]
result = geoadmin.get_map_widget(City._meta.get_field('point'))(
).render('point', Point(-79.460734, 40.18476))
self.assertIn(
"""geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""",
result)
def test_olmap_WMS_rendering(self):
geoadmin = admin.GeoModelAdmin(City, admin.site)
result = geoadmin.get_map_widget(City._meta.get_field('point'))(
).render('point', Point(-79.460734, 40.18476))
self.assertIn(
"""geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: \'basic\', format: 'image/jpeg'});""",
result)
def test_olwidget_has_changed(self):
""" Check that changes are accurately noticed by OpenLayersWidget. """
geoadmin = admin.site._registry[City]
form = geoadmin.get_changelist_form(None)()
has_changed = form.fields['point']._has_changed
initial = Point(13.4197458572965953, 52.5194108501149799, srid=4326)
data_same = "SRID=3857;POINT(1493879.2754093995 6894592.019687599)"
data_almost_same = "SRID=3857;POINT(1493879.2754093990 6894592.019687590)"
data_changed = "SRID=3857;POINT(1493884.0527237 6894593.8111804)"
self.assertTrue(has_changed(None, data_changed))
self.assertTrue(has_changed(initial, ""))
self.assertFalse(has_changed(None, ""))
self.assertFalse(has_changed(initial, data_same))
self.assertFalse(has_changed(initial, data_almost_same))
self.assertTrue(has_changed(initial, data_changed))
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
7509,
63,
14151,
199,
504,
1639,
14,
2828,
14,
5668,
14,
2219,
14,
1208,
492,
7509,
63,
51,
2805,
4938,
63,
2846,
199,
504,
1639,
14,
1208,
14,
2796,
492,
3372,
5524,
199,
199,
692,
7509,
63,
14151,
436,
7509,
63,
51,
2805,
4938,
63,
2846,
26,
272,
687,
1639,
14,
2828,
14,
5668,
492,
4628,
272,
687,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
7584,
339,
687,
1275,
992,
492,
14753,
421,
199,
32,
11278,
8,
13533,
63,
14151,
436,
7509,
63,
51,
2805,
4938,
63,
2846,
12,
298,
4240,
736,
436,
11469,
1592,
787,
1415,
2685,
199,
533,
8875,
4880,
774,
8,
1746,
304,
272,
8187,
275,
283,
1176,
14,
2828,
14,
5668,
14,
2219,
14,
6721,
2113,
14,
3603,
7,
339,
347,
511,
63,
7505,
63,
6721,
9770,
63,
4603,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
4628,
63,
3596,
275,
8509,
2113,
14,
4603,
14,
3352,
63,
3596,
342,
267,
291,
14,
1815,
8,
1629,
779,
6721,
2113,
14,
1490,
4359,
63,
633,
315,
8586,
367,
8586,
315,
4628,
63,
3596,
2459,
339,
347,
511,
63,
393,
1130,
63,
3100,
45,
63,
28228,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
754,
275,
8509,
2113,
14,
362,
63,
1130,
63,
3440,
8,
17024,
423,
2024,
14,
362,
63,
698,
360,
1403,
1333,
8,
288,
7092,
3352,
360,
1403,
297,
7584,
2801,
1965,
14,
2466,
1780,
1082,
12,
6335,
14,
10078,
2114,
430,
267,
291,
14,
4080,
8,
288,
408,
303,
364,
858,
63,
1403,
14,
4359,
14,
1095,
275,
892,
3232,
16862,
14,
5003,
14,
3100,
45,
480,
4299,
933,
7936,
2956,
334,
2956,
22998,
9,
3547,
7208,
288,
754,
9,
339,
347,
511,
63,
393,
1130,
63,
55,
3053,
63,
28228,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
10748,
12976,
8,
17024,
12,
4628,
14,
2124,
9,
267,
754,
275,
8509,
2113,
14,
362,
63,
1130,
63,
3440,
8,
17024,
423,
2024,
14,
362,
63,
698,
360,
1403,
1333,
8,
288,
7092,
3352,
360,
1403,
297,
7584,
2801,
1965,
14,
2466,
1780,
1082,
12,
6335,
14,
10078,
2114,
430,
267,
291,
14,
4080,
8,
288,
408,
303,
364,
858,
63,
1403,
14,
4359,
14,
1095,
275,
892,
3232,
16862,
14,
5003,
14,
55,
3053,
480,
4299,
16862,
644,
3053,
401,
298,
1014,
921,
86,
1130,
16,
14,
18819,
14,
736,
6721,
14,
1308,
15,
30297,
15,
86,
1130,
16,
401,
469,
4359,
26,
8891,
4316,
22458,
1475,
26,
283,
1569,
15,
14230,
936,
2736,
7208,
288,
754,
9,
339,
347,
511,
63,
393,
3440,
63,
1989,
63,
2489,
8,
277,
304,
267,
408,
2670,
626,
4493,
787,
1066,
895,
13824,
4245,
68,
701,
3232,
16862,
3339,
14,
408,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
1824,
275,
8509,
2113,
14,
362,
63,
19043,
63,
964,
8,
403,
16315,
267,
965,
63,
2489,
275,
1824,
14,
955,
459,
1403,
26099,
1989,
63,
2489,
398,
2536,
275,
7584,
8,
969,
14,
25230,
1342,
2010,
1641,
11700,
1427,
2481,
12,
14589,
14,
21,
10860,
709,
2426,
614,
1079,
2576,
1020,
12,
15627,
29,
17948,
9,
267,
666,
63,
7191,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
13657,
14,
1465,
26385,
10936,
21,
1227,
12128,
14098,
14,
26978,
13357,
1020,
2924,
267,
666,
63,
4398,
63,
7191,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
13657,
14,
1465,
26385,
10936,
16,
1227,
12128,
14098,
14,
26978,
1555,
15458,
2924,
267,
666,
63,
2489,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
16303,
14,
1717,
1465,
10638,
1227,
12128,
17380,
14,
26623,
1085,
966,
2924,
398,
291,
14,
1815,
8,
1989,
63,
2489,
8,
403,
12,
666,
63,
2489,
430,
267,
291,
14,
1815,
8,
1989,
63,
2489,
8,
2747,
12,
25491,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
403,
12,
25491,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
7191,
430,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
4398,
63,
7191,
430,
267,
291,
14,
1815,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
2489,
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
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
7509,
63,
14151,
199,
504,
1639,
14,
2828,
14,
5668,
14,
2219,
14,
1208,
492,
7509,
63,
51,
2805,
4938,
63,
2846,
199,
504,
1639,
14,
1208,
14,
2796,
492,
3372,
5524,
199,
199,
692,
7509,
63,
14151,
436,
7509,
63,
51,
2805,
4938,
63,
2846,
26,
272,
687,
1639,
14,
2828,
14,
5668,
492,
4628,
272,
687,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
7584,
339,
687,
1275,
992,
492,
14753,
421,
199,
32,
11278,
8,
13533,
63,
14151,
436,
7509,
63,
51,
2805,
4938,
63,
2846,
12,
298,
4240,
736,
436,
11469,
1592,
787,
1415,
2685,
199,
533,
8875,
4880,
774,
8,
1746,
304,
272,
8187,
275,
283,
1176,
14,
2828,
14,
5668,
14,
2219,
14,
6721,
2113,
14,
3603,
7,
339,
347,
511,
63,
7505,
63,
6721,
9770,
63,
4603,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
4628,
63,
3596,
275,
8509,
2113,
14,
4603,
14,
3352,
63,
3596,
342,
267,
291,
14,
1815,
8,
1629,
779,
6721,
2113,
14,
1490,
4359,
63,
633,
315,
8586,
367,
8586,
315,
4628,
63,
3596,
2459,
339,
347,
511,
63,
393,
1130,
63,
3100,
45,
63,
28228,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
754,
275,
8509,
2113,
14,
362,
63,
1130,
63,
3440,
8,
17024,
423,
2024,
14,
362,
63,
698,
360,
1403,
1333,
8,
288,
7092,
3352,
360,
1403,
297,
7584,
2801,
1965,
14,
2466,
1780,
1082,
12,
6335,
14,
10078,
2114,
430,
267,
291,
14,
4080,
8,
288,
408,
303,
364,
858,
63,
1403,
14,
4359,
14,
1095,
275,
892,
3232,
16862,
14,
5003,
14,
3100,
45,
480,
4299,
933,
7936,
2956,
334,
2956,
22998,
9,
3547,
7208,
288,
754,
9,
339,
347,
511,
63,
393,
1130,
63,
55,
3053,
63,
28228,
8,
277,
304,
267,
8509,
2113,
275,
4628,
14,
10748,
12976,
8,
17024,
12,
4628,
14,
2124,
9,
267,
754,
275,
8509,
2113,
14,
362,
63,
1130,
63,
3440,
8,
17024,
423,
2024,
14,
362,
63,
698,
360,
1403,
1333,
8,
288,
7092,
3352,
360,
1403,
297,
7584,
2801,
1965,
14,
2466,
1780,
1082,
12,
6335,
14,
10078,
2114,
430,
267,
291,
14,
4080,
8,
288,
408,
303,
364,
858,
63,
1403,
14,
4359,
14,
1095,
275,
892,
3232,
16862,
14,
5003,
14,
55,
3053,
480,
4299,
16862,
644,
3053,
401,
298,
1014,
921,
86,
1130,
16,
14,
18819,
14,
736,
6721,
14,
1308,
15,
30297,
15,
86,
1130,
16,
401,
469,
4359,
26,
8891,
4316,
22458,
1475,
26,
283,
1569,
15,
14230,
936,
2736,
7208,
288,
754,
9,
339,
347,
511,
63,
393,
3440,
63,
1989,
63,
2489,
8,
277,
304,
267,
408,
2670,
626,
4493,
787,
1066,
895,
13824,
4245,
68,
701,
3232,
16862,
3339,
14,
408,
267,
8509,
2113,
275,
4628,
14,
2124,
423,
5189,
59,
17024,
61,
267,
1824,
275,
8509,
2113,
14,
362,
63,
19043,
63,
964,
8,
403,
16315,
267,
965,
63,
2489,
275,
1824,
14,
955,
459,
1403,
26099,
1989,
63,
2489,
398,
2536,
275,
7584,
8,
969,
14,
25230,
1342,
2010,
1641,
11700,
1427,
2481,
12,
14589,
14,
21,
10860,
709,
2426,
614,
1079,
2576,
1020,
12,
15627,
29,
17948,
9,
267,
666,
63,
7191,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
13657,
14,
1465,
26385,
10936,
21,
1227,
12128,
14098,
14,
26978,
13357,
1020,
2924,
267,
666,
63,
4398,
63,
7191,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
13657,
14,
1465,
26385,
10936,
16,
1227,
12128,
14098,
14,
26978,
1555,
15458,
2924,
267,
666,
63,
2489,
275,
298,
5943,
998,
29,
1703,
1641,
27,
7217,
8,
1079,
3129,
16303,
14,
1717,
1465,
10638,
1227,
12128,
17380,
14,
26623,
1085,
966,
2924,
398,
291,
14,
1815,
8,
1989,
63,
2489,
8,
403,
12,
666,
63,
2489,
430,
267,
291,
14,
1815,
8,
1989,
63,
2489,
8,
2747,
12,
25491,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
403,
12,
25491,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
7191,
430,
267,
291,
14,
3334,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
4398,
63,
7191,
430,
267,
291,
14,
1815,
8,
1989,
63,
2489,
8,
2747,
12,
666,
63,
2489,
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,
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,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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
] |
pradyunsg/dotfiles
|
lib/checker.py
|
1
|
5820
|
import os
import sys
import shutil
import platform
from .logging import Logger, log
from .utils import run_output
import click
import yaml
class SystemChecker(object):
"""A super-fancy helper for checking the system configuration
"""
def __init__(self, verbose):
super().__init__()
self._logger = Logger()
self.verbose = verbose
def _log_happy(self, msg):
self._logger.spaced_status("pass", msg, fit_width=4)
def _log_angry(self, msg, is_warning):
if is_warning:
self._logger.spaced_status("warn", msg, fit_width=4)
else:
self._logger.spaced_status("fail", msg, fit_width=4)
def platform(self):
return platform.system()
def equal(self, expected, *, should_warn=False, **kwargs):
"""Check if a given value for something is equal to the expected value.
checker.equal(value, name=from_system)
"""
assert len(kwargs) == 1, "expected 1 keyword argument"
name, value = next(iter(kwargs.items()))
if value == expected:
self._log_happy(name + " is correct")
else:
self._log_angry(
f"{name} is not {expected!r}, it is {value!r}",
is_warning=should_warn,
)
# The actual logic is below
def run(self, fname):
data = self._load_yaml(fname)
self._check_username(data["identity"]["username"])
self._check_ssh(data["identity"]["ssh-key"])
self._check_gpg(data["identity"]["gpg-key"])
for category, contents in data["things"].items():
self._check_category(category, contents, data)
def _load_yaml(self, fname):
with open(fname) as f:
try:
return yaml.safe_load(f)
except Exception as e:
click.secho("ERROR: Could not parse file.", fg="red")
click.secho(str(e), fg="red")
sys.exit(1)
def _check_username(self, expected):
self.equal(expected, Username=os.environ["USER"])
def _check_ssh(self, expected):
# FIXME: Is this fragile?
output = run_output("ssh-keygen -E md5 -lf {}".format(
os.path.expanduser("~/.ssh/id_rsa.pub")
))
if output is None:
ssh_key = "not found"
else:
ssh_key = output.split()[1]
if ssh_key.startswith("MD5:"):
ssh_key = ssh_key[4:]
self.equal(expected, **{"SSH key": ssh_key})
def _check_gpg(self, expected):
# This checks that the GPG key exists in the dB
output = run_output("gpg --list-keys {}".format(expected))
if output is not None:
self.equal(expected, **{"GPG key": expected})
else:
self.equal(expected, **{"GPG key": "not found"})
def _check_category(self, category, contents, data):
if "if" in contents:
if list(contents["if"]) != ["platform"]:
raise ValueError(
"Needed condition of category {} to be 'platform'"
.format(category)
)
if contents["if"]["platform"] != self.platform():
log.spaced_status("skip", category)
return
log.spaced_status("topic", category, fit_width=5)
with log:
self._check_executables(
category, contents.get("executables", None)
)
self._check_run_items(
category, contents.get("run_check", None), data
)
def _check_executables(self, category, executables):
if not executables:
return
# Convert the string to a list.
executables = list(map(lambda x: x.strip(), executables.split(",")))
missing = set()
for fname in executables:
if shutil.which(fname) is None:
missing.add(fname)
verb = lambda x: "executable" if len(x) == 1 else "executables"
if missing:
desc = "missing {}: {}".format(
verb(missing), ", ".join(map(repr, missing))
)
log.spaced_status("fail", desc, fit_width=4)
else:
log.spaced_status(
"pass",
"{} {} available".format(len(executables), verb(executables)),
fit_width=4,
)
def _check_run_items(self, category, run_items, data):
if not run_items:
return
for name, cmd_dict in run_items.items():
if not isinstance(cmd_dict, dict) or "cmd" not in cmd_dict:
log.spaced_status(
"warn", f"!!! invalid !!! {category} {name}",
fit_width=4
)
continue
got = run_output(cmd_dict["cmd"])
if got is None:
# Did not exit cleanly
ok = False
reason = "command did not succeed"
elif "equal" in cmd_dict:
# Match the output against an expected value...
expected = cmd_dict["equal"]
# Perform substitution (from values earlier in the dict)
if expected.startswith("$"):
expected = _dotted_access(data, expected[1:])
ok = expected == got.rstrip()
reason = f"{expected!r} != {got!r}"
if ok:
log.spaced_status("pass", name, fit_width=4)
else:
log.spaced_status("fail", name, fit_width=4)
if self.verbose:
with log:
log.info(reason)
def _dotted_access(data, spec):
item = data
for part in spec.split("."):
item = item[part]
return item
|
mit
|
[
646,
747,
199,
646,
984,
199,
646,
5145,
199,
646,
4298,
199,
199,
504,
1275,
4806,
492,
15996,
12,
943,
199,
504,
1275,
1208,
492,
1255,
63,
1199,
199,
199,
646,
8968,
199,
646,
8864,
421,
199,
533,
6187,
3048,
8,
785,
304,
272,
408,
33,
1613,
13,
25352,
5922,
367,
7907,
314,
2656,
2897,
272,
408,
339,
347,
636,
826,
721,
277,
12,
3376,
304,
267,
1613,
11027,
826,
4533,
267,
291,
423,
2921,
275,
15996,
342,
267,
291,
14,
3832,
275,
3376,
339,
347,
485,
793,
63,
72,
18869,
8,
277,
12,
1499,
304,
267,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
1529,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
339,
347,
485,
793,
63,
621,
651,
8,
277,
12,
1499,
12,
365,
63,
3764,
304,
267,
340,
365,
63,
3764,
26,
288,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
4050,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
267,
587,
26,
288,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
1633,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
339,
347,
4298,
8,
277,
304,
267,
372,
4298,
14,
2253,
342,
339,
347,
4472,
8,
277,
12,
1420,
12,
9889,
1077,
63,
4050,
29,
797,
12,
1011,
958,
304,
267,
408,
1799,
340,
282,
1627,
574,
367,
6020,
365,
4472,
370,
314,
1420,
574,
14,
398,
7739,
14,
1452,
8,
585,
12,
536,
29,
504,
63,
2253,
9,
267,
408,
267,
702,
822,
8,
958,
9,
508,
413,
12,
298,
2062,
413,
4252,
1423,
2,
398,
536,
12,
574,
275,
2163,
8,
1661,
8,
958,
14,
1744,
4059,
267,
340,
574,
508,
1420,
26,
288,
291,
423,
793,
63,
72,
18869,
8,
354,
435,
298,
365,
3211,
531,
267,
587,
26,
288,
291,
423,
793,
63,
621,
651,
8,
355,
289,
14381,
354,
93,
365,
440,
469,
2062,
1,
82,
1386,
652,
365,
469,
585,
1,
82,
10750,
355,
365,
63,
3764,
29,
5626,
63,
4050,
12,
288,
776,
339,
327,
710,
3503,
9661,
365,
5084,
272,
347,
1255,
8,
277,
12,
6748,
304,
267,
666,
275,
291,
423,
912,
63,
5963,
8,
5252,
9,
398,
291,
423,
1074,
63,
2473,
8,
576,
905,
5582,
6611,
2473,
3135,
267,
291,
423,
1074,
63,
5510,
8,
576,
905,
5582,
6611,
5510,
13,
498,
3135,
267,
291,
423,
1074,
63,
21284,
8,
576,
905,
5582,
6611,
21284,
13,
498,
3135,
398,
367,
4637,
12,
4072,
315,
666,
905,
25970,
4140,
1744,
837,
288,
291,
423,
1074,
63,
3710,
8,
3710,
12,
4072,
12,
666,
9,
339,
347,
485,
912,
63,
5963,
8,
277,
12,
6748,
304,
267,
543,
1551,
8,
5252,
9,
465,
289,
26,
288,
862,
26,
355,
372,
8864,
14,
3489,
63,
912,
8,
70,
9,
288,
871,
2186,
465,
325,
26,
355,
8968,
14,
261,
2239,
480,
3170,
26,
18615,
440,
2198,
570,
4765,
16587,
628,
581,
531,
355,
8968,
14,
261,
2239,
8,
495,
8,
69,
395,
16587,
628,
581,
531,
355,
984,
14,
2224,
8,
17,
9,
339,
347,
485,
1074,
63,
2473,
8,
277,
12,
1420,
304,
267,
291,
14,
1452,
8,
2062,
12,
29739,
29,
736,
14,
2314,
905,
3791,
3135,
339,
347,
485,
1074,
63,
5510,
8,
277,
12,
1420,
304,
267,
327,
7600,
26,
6596,
642,
11101,
441,
31,
267,
1072,
275,
1255,
63,
1199,
480,
5510,
13,
498,
2268,
446,
37,
6128,
21,
446,
276,
8352,
908,
8,
288,
747,
14,
515,
14,
12131,
20793,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
531,
267,
5082,
267,
340,
1072,
365,
488,
26,
288,
8635,
63,
498,
275,
298,
1397,
1911,
2,
267,
587,
26,
288,
8635,
63,
498,
275,
1072,
14,
1294,
3430,
17,
61,
288,
340,
8635,
63,
498,
14,
2460,
480,
5127,
21,
26,
2349,
355,
8635,
63,
498,
275,
8635,
63,
498,
59,
20,
2938,
398,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
13716,
790,
582,
8635,
63,
498,
1552,
339,
347,
485,
1074,
63,
21284,
8,
277,
12,
1420,
304,
267,
327,
961,
5920,
626,
314,
598,
11115,
790,
3495,
315,
314,
366,
34,
267,
1072,
275,
1255,
63,
1199,
480,
21284,
1553,
513,
13,
1612,
8352,
908,
8,
2062,
430,
267,
340,
1072,
365,
440,
488,
26,
288,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
8225,
39,
790,
582,
1420,
1552,
267,
587,
26,
288,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
8225,
39,
790,
582,
298,
1397,
1911,
5984,
339,
347,
485,
1074,
63,
3710,
8,
277,
12,
4637,
12,
4072,
12,
666,
304,
267,
340,
298,
692,
2,
315,
4072,
26,
288,
340,
769,
8,
4407,
905,
692,
3135,
1137,
2097,
3246,
6229,
355,
746,
1722,
8,
490,
298,
21549,
5558,
402,
4637,
1052,
370,
506,
283,
3246,
4065,
490,
1275,
908,
8,
3710,
9,
355,
776,
288,
340,
4072,
905,
692,
6611,
3246,
937,
1137,
291,
14,
3246,
837,
355,
943,
14,
2638,
68,
63,
1205,
480,
2759,
401,
4637,
9,
355,
372,
398,
943,
14,
2638,
68,
63,
1205,
480,
5746,
401,
4637,
12,
5542,
63,
2063,
29,
21,
9,
267,
543,
943,
26,
288,
291,
423,
1074,
63,
5904,
83,
8,
355,
4637,
12,
4072,
14,
362,
480,
5904,
83,
401,
488,
9,
288,
776,
288,
291,
423,
1074,
63,
1065,
63,
1744,
8,
355,
4637,
12,
4072,
14,
362,
480,
1065,
63,
1074,
401,
488,
395,
666,
288,
776,
339,
347,
485,
1074,
63,
5904,
83,
8,
277,
12,
4637,
12,
31172,
304,
267,
340,
440,
31172,
26,
288,
372,
267,
327,
7905,
314,
1059,
370,
282,
769,
14,
267,
31172,
275,
769,
8,
1130,
8,
2734,
671,
26,
671,
14,
1913,
1062,
31172,
14,
1294,
8,
2266,
1724,
398,
4124,
275,
663,
342,
267,
367,
6748,
315,
31172,
26,
288,
340,
5145,
14,
6777,
8,
5252,
9,
365,
488,
26,
355,
4124,
14,
525,
8,
5252,
9,
398,
16041,
275,
2400,
671,
26,
298,
5904,
2,
340,
822,
8,
88,
9,
508,
413,
587,
298,
5904,
83,
2,
267,
340,
4124,
26,
288,
4328,
275,
298,
4752,
24702,
8352,
908,
8,
355,
16041,
8,
4752,
395,
3872,
3680,
904,
8,
1130,
8,
2722,
12,
4124,
430,
288,
776,
953
] |
[
747,
199,
646,
984,
199,
646,
5145,
199,
646,
4298,
199,
199,
504,
1275,
4806,
492,
15996,
12,
943,
199,
504,
1275,
1208,
492,
1255,
63,
1199,
199,
199,
646,
8968,
199,
646,
8864,
421,
199,
533,
6187,
3048,
8,
785,
304,
272,
408,
33,
1613,
13,
25352,
5922,
367,
7907,
314,
2656,
2897,
272,
408,
339,
347,
636,
826,
721,
277,
12,
3376,
304,
267,
1613,
11027,
826,
4533,
267,
291,
423,
2921,
275,
15996,
342,
267,
291,
14,
3832,
275,
3376,
339,
347,
485,
793,
63,
72,
18869,
8,
277,
12,
1499,
304,
267,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
1529,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
339,
347,
485,
793,
63,
621,
651,
8,
277,
12,
1499,
12,
365,
63,
3764,
304,
267,
340,
365,
63,
3764,
26,
288,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
4050,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
267,
587,
26,
288,
291,
423,
2921,
14,
2638,
68,
63,
1205,
480,
1633,
401,
1499,
12,
5542,
63,
2063,
29,
20,
9,
339,
347,
4298,
8,
277,
304,
267,
372,
4298,
14,
2253,
342,
339,
347,
4472,
8,
277,
12,
1420,
12,
9889,
1077,
63,
4050,
29,
797,
12,
1011,
958,
304,
267,
408,
1799,
340,
282,
1627,
574,
367,
6020,
365,
4472,
370,
314,
1420,
574,
14,
398,
7739,
14,
1452,
8,
585,
12,
536,
29,
504,
63,
2253,
9,
267,
408,
267,
702,
822,
8,
958,
9,
508,
413,
12,
298,
2062,
413,
4252,
1423,
2,
398,
536,
12,
574,
275,
2163,
8,
1661,
8,
958,
14,
1744,
4059,
267,
340,
574,
508,
1420,
26,
288,
291,
423,
793,
63,
72,
18869,
8,
354,
435,
298,
365,
3211,
531,
267,
587,
26,
288,
291,
423,
793,
63,
621,
651,
8,
355,
289,
14381,
354,
93,
365,
440,
469,
2062,
1,
82,
1386,
652,
365,
469,
585,
1,
82,
10750,
355,
365,
63,
3764,
29,
5626,
63,
4050,
12,
288,
776,
339,
327,
710,
3503,
9661,
365,
5084,
272,
347,
1255,
8,
277,
12,
6748,
304,
267,
666,
275,
291,
423,
912,
63,
5963,
8,
5252,
9,
398,
291,
423,
1074,
63,
2473,
8,
576,
905,
5582,
6611,
2473,
3135,
267,
291,
423,
1074,
63,
5510,
8,
576,
905,
5582,
6611,
5510,
13,
498,
3135,
267,
291,
423,
1074,
63,
21284,
8,
576,
905,
5582,
6611,
21284,
13,
498,
3135,
398,
367,
4637,
12,
4072,
315,
666,
905,
25970,
4140,
1744,
837,
288,
291,
423,
1074,
63,
3710,
8,
3710,
12,
4072,
12,
666,
9,
339,
347,
485,
912,
63,
5963,
8,
277,
12,
6748,
304,
267,
543,
1551,
8,
5252,
9,
465,
289,
26,
288,
862,
26,
355,
372,
8864,
14,
3489,
63,
912,
8,
70,
9,
288,
871,
2186,
465,
325,
26,
355,
8968,
14,
261,
2239,
480,
3170,
26,
18615,
440,
2198,
570,
4765,
16587,
628,
581,
531,
355,
8968,
14,
261,
2239,
8,
495,
8,
69,
395,
16587,
628,
581,
531,
355,
984,
14,
2224,
8,
17,
9,
339,
347,
485,
1074,
63,
2473,
8,
277,
12,
1420,
304,
267,
291,
14,
1452,
8,
2062,
12,
29739,
29,
736,
14,
2314,
905,
3791,
3135,
339,
347,
485,
1074,
63,
5510,
8,
277,
12,
1420,
304,
267,
327,
7600,
26,
6596,
642,
11101,
441,
31,
267,
1072,
275,
1255,
63,
1199,
480,
5510,
13,
498,
2268,
446,
37,
6128,
21,
446,
276,
8352,
908,
8,
288,
747,
14,
515,
14,
12131,
20793,
8083,
5510,
15,
344,
63,
13487,
14,
5645,
531,
267,
5082,
267,
340,
1072,
365,
488,
26,
288,
8635,
63,
498,
275,
298,
1397,
1911,
2,
267,
587,
26,
288,
8635,
63,
498,
275,
1072,
14,
1294,
3430,
17,
61,
288,
340,
8635,
63,
498,
14,
2460,
480,
5127,
21,
26,
2349,
355,
8635,
63,
498,
275,
8635,
63,
498,
59,
20,
2938,
398,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
13716,
790,
582,
8635,
63,
498,
1552,
339,
347,
485,
1074,
63,
21284,
8,
277,
12,
1420,
304,
267,
327,
961,
5920,
626,
314,
598,
11115,
790,
3495,
315,
314,
366,
34,
267,
1072,
275,
1255,
63,
1199,
480,
21284,
1553,
513,
13,
1612,
8352,
908,
8,
2062,
430,
267,
340,
1072,
365,
440,
488,
26,
288,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
8225,
39,
790,
582,
1420,
1552,
267,
587,
26,
288,
291,
14,
1452,
8,
2062,
12,
1011,
6641,
8225,
39,
790,
582,
298,
1397,
1911,
5984,
339,
347,
485,
1074,
63,
3710,
8,
277,
12,
4637,
12,
4072,
12,
666,
304,
267,
340,
298,
692,
2,
315,
4072,
26,
288,
340,
769,
8,
4407,
905,
692,
3135,
1137,
2097,
3246,
6229,
355,
746,
1722,
8,
490,
298,
21549,
5558,
402,
4637,
1052,
370,
506,
283,
3246,
4065,
490,
1275,
908,
8,
3710,
9,
355,
776,
288,
340,
4072,
905,
692,
6611,
3246,
937,
1137,
291,
14,
3246,
837,
355,
943,
14,
2638,
68,
63,
1205,
480,
2759,
401,
4637,
9,
355,
372,
398,
943,
14,
2638,
68,
63,
1205,
480,
5746,
401,
4637,
12,
5542,
63,
2063,
29,
21,
9,
267,
543,
943,
26,
288,
291,
423,
1074,
63,
5904,
83,
8,
355,
4637,
12,
4072,
14,
362,
480,
5904,
83,
401,
488,
9,
288,
776,
288,
291,
423,
1074,
63,
1065,
63,
1744,
8,
355,
4637,
12,
4072,
14,
362,
480,
1065,
63,
1074,
401,
488,
395,
666,
288,
776,
339,
347,
485,
1074,
63,
5904,
83,
8,
277,
12,
4637,
12,
31172,
304,
267,
340,
440,
31172,
26,
288,
372,
267,
327,
7905,
314,
1059,
370,
282,
769,
14,
267,
31172,
275,
769,
8,
1130,
8,
2734,
671,
26,
671,
14,
1913,
1062,
31172,
14,
1294,
8,
2266,
1724,
398,
4124,
275,
663,
342,
267,
367,
6748,
315,
31172,
26,
288,
340,
5145,
14,
6777,
8,
5252,
9,
365,
488,
26,
355,
4124,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
loveyoupeng/rt
|
modules/web/src/main/native/Tools/Scripts/webkitpy/common/checksvnconfigfile.py
|
135
|
2718
|
# Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This file is used by:
# webkitpy/tool/steps/addsvnmimetypeforpng.py
# webkitpy/style/checkers/png.py
import os
import re
def check(host, fs):
"""
check the svn config file
return with three logical value:
is svn config file missing, is auto-props missing, is the svn:mime-type for png missing
"""
cfg_file_path = config_file_path(host, fs)
try:
config_file = fs.read_text_file(cfg_file_path)
except IOError:
return (True, True, True)
errorcode_autoprop = not re.search("^\s*enable-auto-props\s*=\s*yes", config_file, re.MULTILINE)
errorcode_png = not re.search("^\s*\*\.png\s*=\s*svn:mime-type=image/png", config_file, re.MULTILINE)
return (False, errorcode_autoprop, errorcode_png)
def config_file_path(host, fs):
if host.platform.is_win():
config_file_path = fs.join(os.environ['APPDATA'], "Subversion", "config")
else:
config_file_path = fs.join(fs.expanduser("~"), ".subversion", "config")
return config_file_path
def errorstr_autoprop(config_file_path):
return 'Have to enable auto props in the subversion config file (%s "enable-auto-props = yes"). ' % config_file_path
def errorstr_png(config_file_path):
return 'Have to set the svn:mime-type in the subversion config file (%s "*.png = svn:mime-type=image/png").' % config_file_path
|
gpl-2.0
|
[
3,
1898,
334,
35,
9,
6029,
23928,
4651,
83,
1626,
9246,
334,
9860,
32,
4904,
14,
85,
13,
83,
806,
3046,
14,
10616,
9,
15904,
402,
428,
806,
3046,
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,
199,
3,
787,
7647,
26,
199,
3,
413,
14,
221,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
499,
14,
221,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
258,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
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,
3,
961,
570,
365,
1202,
701,
26,
199,
3,
18007,
15,
3557,
15,
5895,
15,
525,
6836,
17450,
509,
4524,
14,
647,
199,
3,
18007,
15,
2487,
15,
32514,
15,
4524,
14,
647,
199,
199,
646,
747,
199,
646,
295,
421,
199,
318,
1104,
8,
1102,
12,
7449,
304,
272,
408,
272,
1104,
314,
11327,
1101,
570,
272,
372,
543,
7795,
11461,
574,
26,
272,
365,
11327,
1101,
570,
4124,
12,
365,
2599,
13,
6750,
4124,
12,
365,
314,
11327,
26,
7626,
13,
466,
367,
25296,
4124,
272,
408,
339,
4810,
63,
493,
63,
515,
275,
1101,
63,
493,
63,
515,
8,
1102,
12,
7449,
9,
339,
862,
26,
267,
1101,
63,
493,
275,
7449,
14,
739,
63,
505,
63,
493,
8,
4128,
63,
493,
63,
515,
9,
272,
871,
5925,
26,
267,
372,
334,
549,
12,
715,
12,
715,
9,
339,
1125,
600,
63,
29582,
2675,
275,
440,
295,
14,
1733,
480,
12773,
83,
10,
4296,
13,
2495,
13,
6750,
60,
83,
23440,
83,
10,
5066,
401,
1101,
63,
493,
12,
295,
14,
16661,
9,
272,
1125,
600,
63,
4524,
275,
440,
295,
14,
1733,
480,
12773,
83,
27804,
4537,
4524,
60,
83,
23440,
83,
10,
6836,
26,
7626,
13,
466,
29,
1569,
15,
4524,
401,
1101,
63,
493,
12,
295,
14,
16661,
9,
339,
372,
334,
797,
12,
1125,
600,
63,
29582,
2675,
12,
1125,
600,
63,
4524,
9,
421,
199,
318,
1101,
63,
493,
63,
515,
8,
1102,
12,
7449,
304,
272,
340,
1591,
14,
3246,
14,
374,
63,
2676,
837,
267,
1101,
63,
493,
63,
515,
275,
7449,
14,
904,
8,
736,
14,
2314,
459,
28057,
995,
298,
2610,
1023,
401,
298,
888,
531,
272,
587,
26,
267,
1101,
63,
493,
63,
515,
275,
7449,
14,
904,
8,
2319,
14,
12131,
20793,
1288,
3680,
954,
1023,
401,
298,
888,
531,
272,
372,
1101,
63,
493,
63,
515,
421,
199,
318,
1125,
495,
63,
29582,
2675,
8,
888,
63,
493,
63,
515,
304,
272,
372,
283,
40,
811,
370,
4756,
2599,
10792,
315,
314,
1007,
1023,
1101,
570,
4366,
83,
298,
4296,
13,
2495,
13,
6750,
275,
9456,
3471,
283,
450,
1101,
63,
493,
63,
515,
421,
199,
318,
1125,
495,
63,
4524,
8,
888,
63,
493,
63,
515,
304,
272,
372,
283,
40,
811,
370,
663,
314,
11327,
26,
7626,
13,
466,
315,
314,
1007,
1023,
1101,
570,
4366,
83,
298,
4856,
4524,
275,
11327,
26,
7626,
13,
466,
29,
1569,
15,
4524,
3471,
7,
450,
1101,
63,
493,
63,
515,
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
] |
[
1898,
334,
35,
9,
6029,
23928,
4651,
83,
1626,
9246,
334,
9860,
32,
4904,
14,
85,
13,
83,
806,
3046,
14,
10616,
9,
15904,
402,
428,
806,
3046,
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,
199,
3,
787,
7647,
26,
199,
3,
413,
14,
221,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
499,
14,
221,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
258,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
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,
3,
961,
570,
365,
1202,
701,
26,
199,
3,
18007,
15,
3557,
15,
5895,
15,
525,
6836,
17450,
509,
4524,
14,
647,
199,
3,
18007,
15,
2487,
15,
32514,
15,
4524,
14,
647,
199,
199,
646,
747,
199,
646,
295,
421,
199,
318,
1104,
8,
1102,
12,
7449,
304,
272,
408,
272,
1104,
314,
11327,
1101,
570,
272,
372,
543,
7795,
11461,
574,
26,
272,
365,
11327,
1101,
570,
4124,
12,
365,
2599,
13,
6750,
4124,
12,
365,
314,
11327,
26,
7626,
13,
466,
367,
25296,
4124,
272,
408,
339,
4810,
63,
493,
63,
515,
275,
1101,
63,
493,
63,
515,
8,
1102,
12,
7449,
9,
339,
862,
26,
267,
1101,
63,
493,
275,
7449,
14,
739,
63,
505,
63,
493,
8,
4128,
63,
493,
63,
515,
9,
272,
871,
5925,
26,
267,
372,
334,
549,
12,
715,
12,
715,
9,
339,
1125,
600,
63,
29582,
2675,
275,
440,
295,
14,
1733,
480,
12773,
83,
10,
4296,
13,
2495,
13,
6750,
60,
83,
23440,
83,
10,
5066,
401,
1101,
63,
493,
12,
295,
14,
16661,
9,
272,
1125,
600,
63,
4524,
275,
440,
295,
14,
1733,
480,
12773,
83,
27804,
4537,
4524,
60,
83,
23440,
83,
10,
6836,
26,
7626,
13,
466,
29,
1569,
15,
4524,
401,
1101,
63,
493,
12,
295,
14,
16661,
9,
339,
372,
334,
797,
12,
1125,
600,
63,
29582,
2675,
12,
1125,
600,
63,
4524,
9,
421,
199,
318,
1101,
63,
493,
63,
515,
8,
1102,
12,
7449,
304,
272,
340,
1591,
14,
3246,
14,
374,
63,
2676,
837,
267,
1101,
63,
493,
63,
515,
275,
7449,
14,
904,
8,
736,
14,
2314,
459,
28057,
995,
298,
2610,
1023,
401,
298,
888,
531,
272,
587,
26,
267,
1101,
63,
493,
63,
515,
275,
7449,
14,
904,
8,
2319,
14,
12131,
20793,
1288,
3680,
954,
1023,
401,
298,
888,
531,
272,
372,
1101,
63,
493,
63,
515,
421,
199,
318,
1125,
495,
63,
29582,
2675,
8,
888,
63,
493,
63,
515,
304,
272,
372,
283,
40,
811,
370,
4756,
2599,
10792,
315,
314,
1007,
1023,
1101,
570,
4366,
83,
298,
4296,
13,
2495,
13,
6750,
275,
9456,
3471,
283,
450,
1101,
63,
493,
63,
515,
421,
199,
318,
1125,
495,
63,
4524,
8,
888,
63,
493,
63,
515,
304,
272,
372,
283,
40,
811,
370,
663,
314,
11327,
26,
7626,
13,
466,
315,
314,
1007,
1023,
1101,
570,
4366,
83,
298,
4856,
4524,
275,
11327,
26,
7626,
13,
466,
29,
1569,
15,
4524,
3471,
7,
450,
1101,
63,
493,
63,
515,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
tuhangdi/django
|
tests/runtests.py
|
44
|
16943
|
#!/usr/bin/env python
import atexit
import copy
import logging
import os
import shutil
import subprocess
import sys
import tempfile
import warnings
from argparse import ArgumentParser
import django
from django.apps import apps
from django.conf import settings
from django.db import connection, connections
from django.test import TestCase, TransactionTestCase
from django.test.runner import default_test_processes
from django.test.utils import get_runner
from django.utils import six
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.log import DEFAULT_LOGGING
warnings.simplefilter("error", RemovedInDjango20Warning)
RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
TEMPLATE_DIR = os.path.join(RUNTESTS_DIR, 'templates')
# Create a specific subdirectory for the duration of the test suite.
TMPDIR = tempfile.mkdtemp(prefix='django_')
# Set the TMPDIR environment variable in addition to tempfile.tempdir
# so that children processes inherit it.
tempfile.tempdir = os.environ['TMPDIR'] = TMPDIR
# Removing the temporary TMPDIR. Ensure we pass in unicode so that it will
# successfully remove temp trees containing non-ASCII filenames on Windows.
# (We're assuming the temp dir name itself only contains ASCII characters.)
atexit.register(shutil.rmtree, six.text_type(TMPDIR))
SUBDIRS_TO_SKIP = [
'data',
'import_error_package',
'test_discovery_sample',
'test_discovery_sample2',
'test_runner_deprecation_app',
]
ALWAYS_INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.staticfiles',
]
ALWAYS_MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
# Need to add the associated contrib app to INSTALLED_APPS in some cases to
# avoid "RuntimeError: Model class X doesn't declare an explicit app_label
# and either isn't in an application in INSTALLED_APPS or else was imported
# before its application was loaded."
CONTRIB_TESTS_TO_APPS = {
'flatpages_tests': 'django.contrib.flatpages',
'redirects_tests': 'django.contrib.redirects',
}
def get_test_modules():
modules = []
discovery_paths = [
(None, RUNTESTS_DIR),
# GIS tests are in nested apps
('gis_tests', os.path.join(RUNTESTS_DIR, 'gis_tests')),
]
for modpath, dirpath in discovery_paths:
for f in os.listdir(dirpath):
if ('.' in f or
os.path.basename(f) in SUBDIRS_TO_SKIP or
os.path.isfile(f) or
not os.path.exists(os.path.join(dirpath, f, '__init__.py'))):
continue
modules.append((modpath, f))
return modules
def get_installed():
return [app_config.name for app_config in apps.get_app_configs()]
def setup(verbosity, test_labels, parallel):
if verbosity >= 1:
msg = "Testing against Django installed in '%s'" % os.path.dirname(django.__file__)
max_parallel = default_test_processes() if parallel == 0 else parallel
if max_parallel > 1:
msg += " with up to %d processes" % max_parallel
print(msg)
# Force declaring available_apps in TransactionTestCase for faster tests.
def no_available_apps(self):
raise Exception("Please define available_apps in TransactionTestCase "
"and its subclasses.")
TransactionTestCase.available_apps = property(no_available_apps)
TestCase.available_apps = None
state = {
'INSTALLED_APPS': settings.INSTALLED_APPS,
'ROOT_URLCONF': getattr(settings, "ROOT_URLCONF", ""),
'TEMPLATES': settings.TEMPLATES,
'LANGUAGE_CODE': settings.LANGUAGE_CODE,
'STATIC_URL': settings.STATIC_URL,
'STATIC_ROOT': settings.STATIC_ROOT,
'MIDDLEWARE_CLASSES': settings.MIDDLEWARE_CLASSES,
}
# Redirect some settings for the duration of these tests.
settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
settings.ROOT_URLCONF = 'urls'
settings.STATIC_URL = '/static/'
settings.STATIC_ROOT = os.path.join(TMPDIR, 'static')
settings.TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
}]
settings.LANGUAGE_CODE = 'en'
settings.SITE_ID = 1
settings.MIDDLEWARE_CLASSES = ALWAYS_MIDDLEWARE_CLASSES
settings.MIGRATION_MODULES = {
# these 'tests.migrations' modules don't actually exist, but this lets
# us skip creating migrations for the test models.
'auth': 'django.contrib.auth.tests.migrations',
'contenttypes': 'contenttypes_tests.migrations',
'sessions': 'sessions_tests.migrations',
}
log_config = copy.deepcopy(DEFAULT_LOGGING)
# Filter out non-error logging so we don't have to capture it in lots of
# tests.
log_config['loggers']['django']['level'] = 'ERROR'
settings.LOGGING = log_config
if verbosity > 0:
# Ensure any warnings captured to logging are piped through a verbose
# logging handler. If any -W options were passed explicitly on command
# line, warnings are not captured, and this has no effect.
logger = logging.getLogger('py.warnings')
handler = logging.StreamHandler()
logger.addHandler(handler)
warnings.filterwarnings(
'ignore',
'The GeoManager class is deprecated.',
RemovedInDjango20Warning
)
# Load all the ALWAYS_INSTALLED_APPS.
django.setup()
# Load all the test model apps.
test_modules = get_test_modules()
# Reduce given test labels to just the app module path
test_labels_set = set()
for label in test_labels:
bits = label.split('.')[:1]
test_labels_set.add('.'.join(bits))
installed_app_names = set(get_installed())
for modpath, module_name in test_modules:
if modpath:
module_label = '.'.join([modpath, module_name])
else:
module_label = module_name
# if the module (or an ancestor) was named on the command line, or
# no modules were named (i.e., run all), import
# this module and add it to INSTALLED_APPS.
if not test_labels:
module_found_in_labels = True
else:
module_found_in_labels = any(
# exact match or ancestor match
module_label == label or module_label.startswith(label + '.')
for label in test_labels_set)
if module_name in CONTRIB_TESTS_TO_APPS and module_found_in_labels:
settings.INSTALLED_APPS.append(CONTRIB_TESTS_TO_APPS[module_name])
if module_found_in_labels and module_label not in installed_app_names:
if verbosity >= 2:
print("Importing application %s" % module_name)
settings.INSTALLED_APPS.append(module_label)
# Add contrib.gis to INSTALLED_APPS if needed (rather than requiring
# @override_settings(INSTALLED_APPS=...) on all test cases.
gis = 'django.contrib.gis'
if connection.features.gis_enabled and gis not in settings.INSTALLED_APPS:
if verbosity >= 2:
print("Importing application %s" % gis)
settings.INSTALLED_APPS.append(gis)
apps.set_installed_apps(settings.INSTALLED_APPS)
return state
def teardown(state):
# Restore the old settings.
for key, value in state.items():
setattr(settings, key, value)
def actual_test_processes(parallel):
if parallel == 0:
# This doesn't work before django.setup() on some databases.
if all(conn.features.can_clone_databases for conn in connections.all()):
return default_test_processes()
else:
return 1
else:
return parallel
def django_tests(verbosity, interactive, failfast, keepdb, reverse,
test_labels, debug_sql, parallel):
state = setup(verbosity, test_labels, parallel)
extra_tests = []
# Run the test suite, including the extra validation tests.
if not hasattr(settings, 'TEST_RUNNER'):
settings.TEST_RUNNER = 'django.test.runner.DiscoverRunner'
TestRunner = get_runner(settings)
test_runner = TestRunner(
verbosity=verbosity,
interactive=interactive,
failfast=failfast,
keepdb=keepdb,
reverse=reverse,
debug_sql=debug_sql,
parallel=actual_test_processes(parallel),
)
failures = test_runner.run_tests(
test_labels or get_installed(),
extra_tests=extra_tests,
)
teardown(state)
return failures
def bisect_tests(bisection_label, options, test_labels):
state = setup(options.verbosity, test_labels)
test_labels = test_labels or get_installed()
print('***** Bisecting test suite: %s' % ' '.join(test_labels))
# Make sure the bisection point isn't in the test list
# Also remove tests that need to be run in specific combinations
for label in [bisection_label, 'model_inheritance_same_model_name']:
try:
test_labels.remove(label)
except ValueError:
pass
subprocess_args = [
sys.executable, upath(__file__), '--settings=%s' % options.settings]
if options.failfast:
subprocess_args.append('--failfast')
if options.verbosity:
subprocess_args.append('--verbosity=%s' % options.verbosity)
if not options.interactive:
subprocess_args.append('--noinput')
iteration = 1
while len(test_labels) > 1:
midpoint = len(test_labels) // 2
test_labels_a = test_labels[:midpoint] + [bisection_label]
test_labels_b = test_labels[midpoint:] + [bisection_label]
print('***** Pass %da: Running the first half of the test suite' % iteration)
print('***** Test labels: %s' % ' '.join(test_labels_a))
failures_a = subprocess.call(subprocess_args + test_labels_a)
print('***** Pass %db: Running the second half of the test suite' % iteration)
print('***** Test labels: %s' % ' '.join(test_labels_b))
print('')
failures_b = subprocess.call(subprocess_args + test_labels_b)
if failures_a and not failures_b:
print("***** Problem found in first half. Bisecting again...")
iteration = iteration + 1
test_labels = test_labels_a[:-1]
elif failures_b and not failures_a:
print("***** Problem found in second half. Bisecting again...")
iteration = iteration + 1
test_labels = test_labels_b[:-1]
elif failures_a and failures_b:
print("***** Multiple sources of failure found")
break
else:
print("***** No source of failure found... try pair execution (--pair)")
break
if len(test_labels) == 1:
print("***** Source of error: %s" % test_labels[0])
teardown(state)
def paired_tests(paired_test, options, test_labels):
state = setup(options.verbosity, test_labels)
test_labels = test_labels or get_installed()
print('***** Trying paired execution')
# Make sure the constant member of the pair isn't in the test list
# Also remove tests that need to be run in specific combinations
for label in [paired_test, 'model_inheritance_same_model_name']:
try:
test_labels.remove(label)
except ValueError:
pass
subprocess_args = [
sys.executable, upath(__file__), '--settings=%s' % options.settings]
if options.failfast:
subprocess_args.append('--failfast')
if options.verbosity:
subprocess_args.append('--verbosity=%s' % options.verbosity)
if not options.interactive:
subprocess_args.append('--noinput')
for i, label in enumerate(test_labels):
print('***** %d of %d: Check test pairing with %s' % (
i + 1, len(test_labels), label))
failures = subprocess.call(subprocess_args + [label, paired_test])
if failures:
print('***** Found problem pair with %s' % label)
return
print('***** No problem pair found')
teardown(state)
if __name__ == "__main__":
parser = ArgumentParser(description="Run the Django test suite.")
parser.add_argument('modules', nargs='*', metavar='module',
help='Optional path(s) to test modules; e.g. "i18n" or '
'"i18n.tests.TranslationTests.test_lazy_objects".')
parser.add_argument(
'-v', '--verbosity', default=1, type=int, choices=[0, 1, 2, 3],
help='Verbosity level; 0=minimal output, 1=normal output, 2=all output')
parser.add_argument(
'--noinput', action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind.')
parser.add_argument(
'--failfast', action='store_true', dest='failfast', default=False,
help='Tells Django to stop running the test suite after first failed '
'test.')
parser.add_argument(
'-k', '--keepdb', action='store_true', dest='keepdb', default=False,
help='Tells Django to preserve the test database between runs.')
parser.add_argument(
'--settings',
help='Python path to settings module, e.g. "myproject.settings". If '
'this isn\'t provided, either the DJANGO_SETTINGS_MODULE '
'environment variable or "test_sqlite" will be used.')
parser.add_argument('--bisect',
help='Bisect the test suite to discover a test that causes a test '
'failure when combined with the named test.')
parser.add_argument('--pair',
help='Run the test suite in pairs with the named test to find problem '
'pairs.')
parser.add_argument('--reverse', action='store_true', default=False,
help='Sort test suites and test cases in opposite order to debug '
'test side effects not apparent with normal execution lineup.')
parser.add_argument('--liveserver',
help='Overrides the default address where the live server (used with '
'LiveServerTestCase) is expected to run from. The default value '
'is localhost:8081-8179.')
parser.add_argument(
'--selenium', action='store_true', dest='selenium', default=False,
help='Run the Selenium tests as well (if Selenium is installed).')
parser.add_argument(
'--debug-sql', action='store_true', dest='debug_sql', default=False,
help='Turn on the SQL query logger within tests.')
parser.add_argument(
'--parallel', dest='parallel', nargs='?', default=0, type=int,
const=default_test_processes(),
help='Run tests in parallel processes.')
options = parser.parse_args()
# mock is a required dependency
try:
from django.test import mock # NOQA
except ImportError:
print(
"Please install test dependencies first: \n"
"$ pip install -r requirements/py%s.txt" % sys.version_info.major
)
sys.exit(1)
# Allow including a trailing slash on app_labels for tab completion convenience
options.modules = [os.path.normpath(labels) for labels in options.modules]
if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
else:
if "DJANGO_SETTINGS_MODULE" not in os.environ:
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_sqlite'
options.settings = os.environ['DJANGO_SETTINGS_MODULE']
if options.liveserver is not None:
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver
if options.selenium:
os.environ['DJANGO_SELENIUM_TESTS'] = '1'
if options.bisect:
bisect_tests(options.bisect, options, options.modules)
elif options.pair:
paired_tests(options.pair, options, options.modules)
else:
failures = django_tests(options.verbosity, options.interactive,
options.failfast, options.keepdb,
options.reverse, options.modules,
options.debug_sql, options.parallel)
if failures:
sys.exit(bool(failures))
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
646,
19840,
199,
646,
1331,
199,
646,
2050,
199,
646,
747,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
646,
3598,
199,
504,
7534,
492,
27615,
199,
199,
646,
1639,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1950,
12,
6947,
199,
504,
1639,
14,
396,
492,
7640,
12,
18244,
1746,
199,
504,
1639,
14,
396,
14,
5933,
492,
849,
63,
396,
63,
11816,
199,
504,
1639,
14,
396,
14,
1208,
492,
664,
63,
5933,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
1165,
3849,
199,
504,
1639,
14,
1208,
14,
793,
492,
6186,
63,
27896,
199,
199,
5451,
14,
18815,
480,
705,
401,
23687,
1165,
3849,
9,
199,
199,
9390,
7569,
63,
3022,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
384,
1619,
3460,
493,
29658,
199,
199,
7433,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
9390,
7569,
63,
3022,
12,
283,
5876,
358,
199,
199,
3,
2790,
282,
2488,
25094,
367,
314,
7373,
402,
314,
511,
5241,
14,
199,
17983,
3022,
275,
5549,
14,
11983,
8,
1861,
534,
1176,
15452,
199,
3,
2494,
314,
377,
1658,
3022,
3734,
1750,
315,
10234,
370,
5549,
14,
11567,
199,
3,
880,
626,
4978,
10358,
8287,
652,
14,
199,
17336,
14,
11567,
275,
747,
14,
2314,
459,
17983,
3022,
418,
275,
377,
1658,
3022,
199,
199,
3,
29343,
314,
7937,
377,
1658,
3022,
14,
7523,
781,
986,
315,
2649,
880,
626,
652,
911,
199,
3,
8792,
2813,
2388,
14416,
3035,
2222,
13,
12292,
6203,
641,
5417,
14,
199,
3,
334,
6004,
3984,
18002,
314,
2388,
2935,
536,
6337,
1454,
3509,
10485,
4110,
4959,
199,
24026,
390,
14,
2683,
8,
20938,
14,
9242,
12,
3816,
14,
505,
63,
466,
8,
17983,
3022,
430,
421,
199,
6348,
14455,
63,
2566,
63,
13525,
275,
359,
272,
283,
576,
297,
272,
283,
646,
63,
705,
63,
2491,
297,
272,
283,
396,
63,
14859,
63,
3271,
297,
272,
283,
396,
63,
14859,
63,
3271,
18,
297,
272,
283,
396,
63,
5933,
63,
15383,
63,
571,
297,
199,
61,
199,
199,
32509,
63,
15942,
63,
14219,
275,
359,
272,
283,
1176,
14,
2828,
14,
10778,
297,
272,
283,
1176,
14,
2828,
14,
1178,
297,
272,
283,
1176,
14,
2828,
14,
8619,
297,
272,
283,
1176,
14,
2828,
14,
11676,
297,
272,
283,
1176,
14,
2828,
14,
3431,
297,
272,
283,
1176,
14,
2828,
14,
2113,
14,
5181,
14,
3184,
4880,
2028,
297,
272,
283,
1176,
14,
2828,
14,
18373,
297,
199,
61,
199,
199,
32509,
63,
19987,
63,
13748,
275,
359,
272,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
297,
272,
283,
1176,
14,
5754,
14,
2330,
14,
7844,
6608,
297,
272,
283,
1176,
14,
5754,
14,
10088,
14,
13912,
25322,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
297,
199,
61,
199,
199,
3,
14012,
370,
1050,
314,
4568,
5914,
1145,
370,
31061,
63,
14219,
315,
2005,
5560,
370,
199,
3,
5126,
298,
13281,
26,
5822,
1021,
1323,
3181,
1133,
20771,
376,
5027,
1145,
63,
1302,
199,
3,
436,
1902,
5712,
1133,
315,
376,
4223,
315,
31061,
63,
14219,
503,
587,
1990,
8439,
199,
3,
2544,
2399,
4223,
1990,
6511,
2122,
199,
1864,
1766,
2100,
63,
7569,
63,
2566,
63,
14219,
275,
469,
272,
283,
29974,
63,
2219,
356,
283,
1176,
14,
2828,
14,
29974,
297,
272,
283,
13607,
63,
2219,
356,
283,
1176,
14,
2828,
14,
13607,
297,
199,
93,
421,
199,
318,
664,
63,
396,
63,
3112,
837,
272,
4621,
275,
942,
272,
13172,
63,
3771,
275,
359,
267,
334,
403,
12,
21277,
7569,
63,
3022,
395,
267,
327,
598,
1311,
2295,
787,
315,
6032,
8686,
267,
661,
5668,
63,
2219,
297,
747,
14,
515,
14,
904,
8,
9390,
7569,
63,
3022,
12,
283,
5668,
63,
2219,
3855,
272,
1622,
339,
367,
3413,
515,
12,
20648,
315,
13172,
63,
3771,
26,
267,
367,
289,
315,
747,
14,
7374,
8,
17254,
304,
288,
340,
661,
3530,
315,
289,
503,
490,
747,
14,
515,
14,
4846,
8,
70,
9,
315,
7605,
14455,
63,
2566,
63,
13525,
503,
490,
747,
14,
515,
14,
6292,
8,
70,
9,
503,
490,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
904,
8,
17254,
12,
289,
12,
2560,
826,
4343,
647,
1333,
304,
355,
1980,
288,
4621,
14,
740,
1332,
1494,
515,
12,
289,
430,
272,
372,
4621,
421,
199,
318,
664,
63,
7657,
837,
272,
372,
359,
571,
63,
888,
14,
354,
367,
1145,
63,
888,
315,
8686,
14,
362,
63,
571,
63,
7532,
5106,
421,
199,
318,
3272,
8,
9833,
12,
511,
63,
3512,
12,
9861,
304,
272,
340,
8661,
2356,
413,
26,
267,
1499,
275,
298,
9029,
6169,
5634,
4903,
315,
1543,
83,
4065,
450,
747,
14,
515,
14,
3475,
8,
1176,
855,
493,
3368,
267,
1390,
63,
11887,
275,
849,
63,
396,
63,
11816,
342,
340,
9861,
508,
378,
587,
9861,
267,
340,
1390,
63,
11887,
690,
413,
26,
288,
1499,
847,
298,
543,
1536,
370,
450,
68,
10358,
2,
450,
1390,
63,
11887,
267,
870,
8,
1328,
9,
339,
327,
18771,
13507,
316,
2808,
63,
5181,
315,
18244,
1746,
367,
12930,
2295,
14,
272,
347,
949,
63,
4561,
63,
5181,
8,
277,
304,
267,
746,
2186,
480,
8254,
5627,
2808,
63,
5181,
315,
18244,
1746,
298,
717,
298,
460,
2399,
9180,
2685,
272,
18244,
1746,
14,
4561,
63,
5181,
275,
3324,
8,
889,
63,
4561,
63,
5181,
9,
272,
7640,
14,
4561,
63,
5181,
275,
488,
339,
1174,
275,
469,
267,
283,
15942,
63,
14219,
356,
2202,
14,
15942,
63,
14219,
12,
267,
283,
5441,
63,
18125,
356,
2519,
8,
1751,
12,
298,
5441,
63,
18125,
401,
16241,
267,
283,
25437,
356,
2202,
14,
25437,
12,
267,
283,
13947,
63,
6012,
356,
2202,
14,
13947,
63,
6012,
12,
267,
283,
10449,
63,
2632,
356,
2202,
14
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
646,
19840,
199,
646,
1331,
199,
646,
2050,
199,
646,
747,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
646,
3598,
199,
504,
7534,
492,
27615,
199,
199,
646,
1639,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1950,
12,
6947,
199,
504,
1639,
14,
396,
492,
7640,
12,
18244,
1746,
199,
504,
1639,
14,
396,
14,
5933,
492,
849,
63,
396,
63,
11816,
199,
504,
1639,
14,
396,
14,
1208,
492,
664,
63,
5933,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
1165,
3849,
199,
504,
1639,
14,
1208,
14,
793,
492,
6186,
63,
27896,
199,
199,
5451,
14,
18815,
480,
705,
401,
23687,
1165,
3849,
9,
199,
199,
9390,
7569,
63,
3022,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
384,
1619,
3460,
493,
29658,
199,
199,
7433,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
9390,
7569,
63,
3022,
12,
283,
5876,
358,
199,
199,
3,
2790,
282,
2488,
25094,
367,
314,
7373,
402,
314,
511,
5241,
14,
199,
17983,
3022,
275,
5549,
14,
11983,
8,
1861,
534,
1176,
15452,
199,
3,
2494,
314,
377,
1658,
3022,
3734,
1750,
315,
10234,
370,
5549,
14,
11567,
199,
3,
880,
626,
4978,
10358,
8287,
652,
14,
199,
17336,
14,
11567,
275,
747,
14,
2314,
459,
17983,
3022,
418,
275,
377,
1658,
3022,
199,
199,
3,
29343,
314,
7937,
377,
1658,
3022,
14,
7523,
781,
986,
315,
2649,
880,
626,
652,
911,
199,
3,
8792,
2813,
2388,
14416,
3035,
2222,
13,
12292,
6203,
641,
5417,
14,
199,
3,
334,
6004,
3984,
18002,
314,
2388,
2935,
536,
6337,
1454,
3509,
10485,
4110,
4959,
199,
24026,
390,
14,
2683,
8,
20938,
14,
9242,
12,
3816,
14,
505,
63,
466,
8,
17983,
3022,
430,
421,
199,
6348,
14455,
63,
2566,
63,
13525,
275,
359,
272,
283,
576,
297,
272,
283,
646,
63,
705,
63,
2491,
297,
272,
283,
396,
63,
14859,
63,
3271,
297,
272,
283,
396,
63,
14859,
63,
3271,
18,
297,
272,
283,
396,
63,
5933,
63,
15383,
63,
571,
297,
199,
61,
199,
199,
32509,
63,
15942,
63,
14219,
275,
359,
272,
283,
1176,
14,
2828,
14,
10778,
297,
272,
283,
1176,
14,
2828,
14,
1178,
297,
272,
283,
1176,
14,
2828,
14,
8619,
297,
272,
283,
1176,
14,
2828,
14,
11676,
297,
272,
283,
1176,
14,
2828,
14,
3431,
297,
272,
283,
1176,
14,
2828,
14,
2113,
14,
5181,
14,
3184,
4880,
2028,
297,
272,
283,
1176,
14,
2828,
14,
18373,
297,
199,
61,
199,
199,
32509,
63,
19987,
63,
13748,
275,
359,
272,
283,
1176,
14,
2828,
14,
11676,
14,
5754,
14,
4434,
6608,
297,
272,
283,
1176,
14,
5754,
14,
2330,
14,
7844,
6608,
297,
272,
283,
1176,
14,
5754,
14,
10088,
14,
13912,
25322,
297,
272,
283,
1176,
14,
2828,
14,
1178,
14,
5754,
14,
10348,
6608,
297,
272,
283,
1176,
14,
2828,
14,
3431,
14,
5754,
14,
2209,
6608,
297,
199,
61,
199,
199,
3,
14012,
370,
1050,
314,
4568,
5914,
1145,
370,
31061,
63,
14219,
315,
2005,
5560,
370,
199,
3,
5126,
298,
13281,
26,
5822,
1021,
1323,
3181,
1133,
20771,
376,
5027,
1145,
63,
1302,
199,
3,
436,
1902,
5712,
1133,
315,
376,
4223,
315,
31061,
63,
14219,
503,
587,
1990,
8439,
199,
3,
2544,
2399,
4223,
1990,
6511,
2122,
199,
1864,
1766,
2100,
63,
7569,
63,
2566,
63,
14219,
275,
469,
272,
283,
29974,
63,
2219,
356,
283,
1176,
14,
2828,
14,
29974,
297,
272,
283,
13607,
63,
2219,
356,
283,
1176,
14,
2828,
14,
13607,
297,
199,
93,
421,
199,
318,
664,
63,
396,
63,
3112,
837,
272,
4621,
275,
942,
272,
13172,
63,
3771,
275,
359,
267,
334,
403,
12,
21277,
7569,
63,
3022,
395,
267,
327,
598,
1311,
2295,
787,
315,
6032,
8686,
267,
661,
5668,
63,
2219,
297,
747,
14,
515,
14,
904,
8,
9390,
7569,
63,
3022,
12,
283,
5668,
63,
2219,
3855,
272,
1622,
339,
367,
3413,
515,
12,
20648,
315,
13172,
63,
3771,
26,
267,
367,
289,
315,
747,
14,
7374,
8,
17254,
304,
288,
340,
661,
3530,
315,
289,
503,
490,
747,
14,
515,
14,
4846,
8,
70,
9,
315,
7605,
14455,
63,
2566,
63,
13525,
503,
490,
747,
14,
515,
14,
6292,
8,
70,
9,
503,
490,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
904,
8,
17254,
12,
289,
12,
2560,
826,
4343,
647,
1333,
304,
355,
1980,
288,
4621,
14,
740,
1332,
1494,
515,
12,
289,
430,
272,
372,
4621,
421,
199,
318,
664,
63,
7657,
837,
272,
372,
359,
571,
63,
888,
14,
354,
367,
1145,
63,
888,
315,
8686,
14,
362,
63,
571,
63,
7532,
5106,
421,
199,
318,
3272,
8,
9833,
12,
511,
63,
3512,
12,
9861,
304,
272,
340,
8661,
2356,
413,
26,
267,
1499,
275,
298,
9029,
6169,
5634,
4903,
315,
1543,
83,
4065,
450,
747,
14,
515,
14,
3475,
8,
1176,
855,
493,
3368,
267,
1390,
63,
11887,
275,
849,
63,
396,
63,
11816,
342,
340,
9861,
508,
378,
587,
9861,
267,
340,
1390,
63,
11887,
690,
413,
26,
288,
1499,
847,
298,
543,
1536,
370,
450,
68,
10358,
2,
450,
1390,
63,
11887,
267,
870,
8,
1328,
9,
339,
327,
18771,
13507,
316,
2808,
63,
5181,
315,
18244,
1746,
367,
12930,
2295,
14,
272,
347,
949,
63,
4561,
63,
5181,
8,
277,
304,
267,
746,
2186,
480,
8254,
5627,
2808,
63,
5181,
315,
18244,
1746,
298,
717,
298,
460,
2399,
9180,
2685,
272,
18244,
1746,
14,
4561,
63,
5181,
275,
3324,
8,
889,
63,
4561,
63,
5181,
9,
272,
7640,
14,
4561,
63,
5181,
275,
488,
339,
1174,
275,
469,
267,
283,
15942,
63,
14219,
356,
2202,
14,
15942,
63,
14219,
12,
267,
283,
5441,
63,
18125,
356,
2519,
8,
1751,
12,
298,
5441,
63,
18125,
401,
16241,
267,
283,
25437,
356,
2202,
14,
25437,
12,
267,
283,
13947,
63,
6012,
356,
2202,
14,
13947,
63,
6012,
12,
267,
283,
10449,
63,
2632,
356,
2202,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
vvv1559/intellij-community
|
python/helpers/pydev/_pydev_bundle/_pydev_calltip_util.py
|
33
|
4916
|
'''
License: Apache 2.0
Author: Yuli Fitterman
'''
# noinspection PyBroadException
import types
from _pydevd_bundle.pydevd_constants import IS_JYTHON, IS_PY3K
try:
import inspect
except:
try:
from _pydev_imps import _pydev_inspect as inspect
except:
import traceback;
traceback.print_exc() # Ok, no inspect available (search will not work)from _pydevd_bundle.pydevd_constants import IS_JYTHON, IS_PY3K
from _pydev_bundle._pydev_imports_tipper import signature_from_docstring
def is_bound_method(obj):
if isinstance(obj, types.MethodType):
return getattr(obj, '__self__', getattr(obj, 'im_self', None)) is not None
else:
return False
def get_class_name(instance):
return getattr(getattr(instance, "__class__", None), "__name__", None)
def get_bound_class_name(obj):
my_self = getattr(obj, '__self__', getattr(obj, 'im_self', None))
if my_self is None:
return None
return get_class_name(my_self)
def get_description(obj):
try:
ob_call = obj.__call__
except:
ob_call = None
if isinstance(obj, type) or type(obj).__name__ == 'classobj':
fob = getattr(obj, '__init__', lambda: None)
if not isinstance(fob, (types.FunctionType, types.MethodType)):
fob = obj
elif is_bound_method(ob_call):
fob = ob_call
else:
fob = obj
argspec = ""
fn_name = None
fn_class = None
if isinstance(fob, (types.FunctionType, types.MethodType)):
spec_info = inspect.getfullargspec(fob) if IS_PY3K else inspect.getargspec(fob)
argspec = inspect.formatargspec(*spec_info)
fn_name = getattr(fob, '__name__', None)
if isinstance(obj, type) or type(obj).__name__ == 'classobj':
fn_name = "__init__"
fn_class = getattr(obj, "__name__", "UnknownClass")
elif is_bound_method(obj) or is_bound_method(ob_call):
fn_class = get_bound_class_name(obj) or "UnknownClass"
else:
fn_name = getattr(fob, '__name__', None)
fn_self = getattr(fob, '__self__', None)
if fn_self is not None and not isinstance(fn_self, types.ModuleType):
fn_class = get_class_name(fn_self)
doc_string = get_docstring(ob_call) if is_bound_method(ob_call) else get_docstring(obj)
return create_method_stub(fn_name, fn_class, argspec, doc_string)
def create_method_stub(fn_name, fn_class, argspec, doc_string):
if fn_name and argspec:
doc_string = "" if doc_string is None else doc_string
fn_stub = create_function_stub(fn_name, argspec, doc_string, indent=1 if fn_class else 0)
if fn_class:
expr = fn_class if fn_name == '__init__' else fn_class + '().' + fn_name
return create_class_stub(fn_class, fn_stub) + "\n" + expr
else:
expr = fn_name
return fn_stub + "\n" + expr
elif doc_string:
if fn_name:
restored_signature, _ = signature_from_docstring(doc_string, fn_name)
if restored_signature:
return create_method_stub(fn_name, fn_class, restored_signature, doc_string)
return create_function_stub('unknown', '(*args, **kwargs)', doc_string) + '\nunknown'
else:
return ''
def get_docstring(obj):
if obj is not None:
try:
if IS_JYTHON:
# Jython
doc = obj.__doc__
if doc is not None:
return doc
from _pydev_bundle import _pydev_jy_imports_tipper
is_method, infos = _pydev_jy_imports_tipper.ismethod(obj)
ret = ''
if is_method:
for info in infos:
ret += info.get_as_doc()
return ret
else:
doc = inspect.getdoc(obj)
if doc is not None:
return doc
except:
pass
else:
return ''
try:
# if no attempt succeeded, try to return repr()...
return repr(obj)
except:
try:
# otherwise the class
return str(obj.__class__)
except:
# if all fails, go to an empty string
return ''
def create_class_stub(class_name, contents):
return "class %s(object):\n%s" % (class_name, contents)
def create_function_stub(fn_name, fn_argspec, fn_docstring, indent=0):
def shift_right(string, prefix):
return ''.join(prefix + line for line in string.splitlines(True))
fn_docstring = shift_right(inspect.cleandoc(fn_docstring), " " * (indent + 1))
ret = '''
def %s%s:
"""%s"""
pass
''' % (fn_name, fn_argspec, fn_docstring)
ret = ret[1:] # remove first /n
ret = ret.replace('\t', " ")
if indent:
prefix = " " * indent
ret = shift_right(ret, prefix)
return ret
|
apache-2.0
|
[
2344,
199,
3761,
26,
3668,
499,
14,
16,
199,
5949,
26,
1488,
13987,
25971,
351,
1237,
199,
2344,
199,
3,
30870,
1611,
34,
5063,
1726,
199,
646,
2943,
199,
199,
504,
485,
23996,
68,
63,
6469,
14,
23996,
68,
63,
5559,
492,
2281,
63,
42,
57,
8472,
12,
2281,
63,
4521,
19,
43,
199,
199,
893,
26,
272,
492,
6485,
199,
2590,
26,
272,
862,
26,
267,
687,
485,
23996,
63,
3236,
83,
492,
485,
23996,
63,
10955,
465,
6485,
272,
871,
26,
267,
492,
5190,
27,
398,
5190,
14,
1361,
63,
2804,
342,
221,
327,
20049,
12,
949,
6485,
2808,
334,
1733,
911,
440,
1736,
9,
504,
485,
23996,
68,
63,
6469,
14,
23996,
68,
63,
5559,
492,
2281,
63,
42,
57,
8472,
12,
2281,
63,
4521,
19,
43,
199,
199,
504,
485,
23996,
63,
6469,
423,
23996,
63,
12775,
63,
8996,
529,
492,
4955,
63,
504,
63,
12485,
421,
199,
318,
365,
63,
3556,
63,
765,
8,
1113,
304,
272,
340,
1228,
8,
1113,
12,
2943,
14,
24674,
304,
267,
372,
2519,
8,
1113,
12,
2560,
277,
7500,
2519,
8,
1113,
12,
283,
1017,
63,
277,
297,
488,
430,
365,
440,
488,
272,
587,
26,
267,
372,
756,
421,
199,
318,
664,
63,
533,
63,
354,
8,
842,
304,
272,
372,
2519,
8,
5675,
8,
842,
12,
4396,
533,
13915,
488,
395,
4396,
354,
13915,
488,
9,
421,
199,
318,
664,
63,
3556,
63,
533,
63,
354,
8,
1113,
304,
272,
3002,
63,
277,
275,
2519,
8,
1113,
12,
2560,
277,
7500,
2519,
8,
1113,
12,
283,
1017,
63,
277,
297,
488,
430,
272,
340,
3002,
63,
277,
365,
488,
26,
267,
372,
488,
272,
372,
664,
63,
533,
63,
354,
8,
1662,
63,
277,
9,
421,
199,
318,
664,
63,
1802,
8,
1113,
304,
272,
862,
26,
267,
2607,
63,
1250,
275,
1559,
855,
1250,
363,
272,
871,
26,
267,
2607,
63,
1250,
275,
488,
339,
340,
1228,
8,
1113,
12,
730,
9,
503,
730,
8,
1113,
2843,
354,
363,
508,
283,
533,
1113,
356,
267,
289,
2873,
275,
2519,
8,
1113,
12,
2560,
826,
7500,
2400,
26,
488,
9,
267,
340,
440,
1228,
8,
545,
66,
12,
334,
1313,
14,
26371,
12,
2943,
14,
24674,
2298,
288,
289,
2873,
275,
1559,
272,
916,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
304,
267,
289,
2873,
275,
2607,
63,
1250,
272,
587,
26,
267,
289,
2873,
275,
1559,
339,
26632,
275,
3087,
272,
4325,
63,
354,
275,
488,
272,
4325,
63,
533,
275,
488,
272,
340,
1228,
8,
545,
66,
12,
334,
1313,
14,
26371,
12,
2943,
14,
24674,
2298,
267,
3158,
63,
815,
275,
6485,
14,
362,
2861,
15644,
8,
545,
66,
9,
340,
2281,
63,
4521,
19,
43,
587,
6485,
14,
29836,
8,
545,
66,
9,
267,
26632,
275,
6485,
14,
908,
15644,
2031,
1650,
63,
815,
9,
267,
4325,
63,
354,
275,
2519,
8,
545,
66,
12,
2560,
354,
7500,
488,
9,
267,
340,
1228,
8,
1113,
12,
730,
9,
503,
730,
8,
1113,
2843,
354,
363,
508,
283,
533,
1113,
356,
288,
4325,
63,
354,
275,
4396,
826,
16526,
288,
4325,
63,
533,
275,
2519,
8,
1113,
12,
4396,
354,
13915,
298,
5912,
2543,
531,
267,
916,
365,
63,
3556,
63,
765,
8,
1113,
9,
503,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
304,
288,
4325,
63,
533,
275,
664,
63,
3556,
63,
533,
63,
354,
8,
1113,
9,
503,
298,
5912,
2543,
2,
339,
587,
26,
267,
4325,
63,
354,
275,
2519,
8,
545,
66,
12,
2560,
354,
7500,
488,
9,
267,
4325,
63,
277,
275,
2519,
8,
545,
66,
12,
2560,
277,
7500,
488,
9,
267,
340,
4325,
63,
277,
365,
440,
488,
436,
440,
1228,
8,
2324,
63,
277,
12,
2943,
14,
21820,
304,
288,
4325,
63,
533,
275,
664,
63,
533,
63,
354,
8,
2324,
63,
277,
9,
339,
1382,
63,
875,
275,
664,
63,
12485,
8,
2873,
63,
1250,
9,
340,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
9,
587,
664,
63,
12485,
8,
1113,
9,
272,
372,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
26632,
12,
1382,
63,
875,
9,
421,
199,
318,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
26632,
12,
1382,
63,
875,
304,
272,
340,
4325,
63,
354,
436,
26632,
26,
267,
1382,
63,
875,
275,
3087,
340,
1382,
63,
875,
365,
488,
587,
1382,
63,
875,
267,
4325,
63,
5811,
275,
1218,
63,
1593,
63,
5811,
8,
2324,
63,
354,
12,
26632,
12,
1382,
63,
875,
12,
4363,
29,
17,
340,
4325,
63,
533,
587,
378,
9,
267,
340,
4325,
63,
533,
26,
288,
5348,
275,
4325,
63,
533,
340,
4325,
63,
354,
508,
2560,
826,
12217,
587,
4325,
63,
533,
435,
283,
1252,
7,
435,
4325,
63,
354,
288,
372,
1218,
63,
533,
63,
5811,
8,
2324,
63,
533,
12,
4325,
63,
5811,
9,
435,
1867,
78,
2,
435,
5348,
267,
587,
26,
288,
5348,
275,
4325,
63,
354,
288,
372,
4325,
63,
5811,
435,
1867,
78,
2,
435,
5348,
272,
916,
1382,
63,
875,
26,
267,
340,
4325,
63,
354,
26,
288,
14429,
63,
5233,
12,
485,
275,
4955,
63,
504,
63,
12485,
8,
1301,
63,
875,
12,
4325,
63,
354,
9,
288,
340,
14429,
63,
5233,
26,
355,
372,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
14429,
63,
5233,
12,
1382,
63,
875,
9,
267,
372,
1218,
63,
1593,
63,
5811,
360,
5187,
297,
283,
2031,
589,
12,
1011,
958,
3196,
1382,
63,
875,
9,
435,
1557,
78,
5187,
7,
339,
587,
26,
267,
372,
2125,
421,
199,
318,
664,
63,
12485,
8,
1113,
304,
272,
340,
1559,
365,
440,
488,
26,
267,
862,
26,
288,
340,
2281,
63,
42,
57,
8472,
26,
355,
327,
25333,
355,
1382,
275,
1559,
855,
1301,
363,
355,
340,
1382,
365,
440,
488,
26,
490,
372,
1382,
2234,
687,
485,
23996,
63,
6469,
492,
485,
23996,
63,
24589,
63,
12775,
63,
8996,
529,
2234,
365,
63,
765,
12,
24485,
275,
485,
23996,
63,
24589,
63,
12775,
63,
8996,
529,
14,
374,
765
] |
[
199,
3761,
26,
3668,
499,
14,
16,
199,
5949,
26,
1488,
13987,
25971,
351,
1237,
199,
2344,
199,
3,
30870,
1611,
34,
5063,
1726,
199,
646,
2943,
199,
199,
504,
485,
23996,
68,
63,
6469,
14,
23996,
68,
63,
5559,
492,
2281,
63,
42,
57,
8472,
12,
2281,
63,
4521,
19,
43,
199,
199,
893,
26,
272,
492,
6485,
199,
2590,
26,
272,
862,
26,
267,
687,
485,
23996,
63,
3236,
83,
492,
485,
23996,
63,
10955,
465,
6485,
272,
871,
26,
267,
492,
5190,
27,
398,
5190,
14,
1361,
63,
2804,
342,
221,
327,
20049,
12,
949,
6485,
2808,
334,
1733,
911,
440,
1736,
9,
504,
485,
23996,
68,
63,
6469,
14,
23996,
68,
63,
5559,
492,
2281,
63,
42,
57,
8472,
12,
2281,
63,
4521,
19,
43,
199,
199,
504,
485,
23996,
63,
6469,
423,
23996,
63,
12775,
63,
8996,
529,
492,
4955,
63,
504,
63,
12485,
421,
199,
318,
365,
63,
3556,
63,
765,
8,
1113,
304,
272,
340,
1228,
8,
1113,
12,
2943,
14,
24674,
304,
267,
372,
2519,
8,
1113,
12,
2560,
277,
7500,
2519,
8,
1113,
12,
283,
1017,
63,
277,
297,
488,
430,
365,
440,
488,
272,
587,
26,
267,
372,
756,
421,
199,
318,
664,
63,
533,
63,
354,
8,
842,
304,
272,
372,
2519,
8,
5675,
8,
842,
12,
4396,
533,
13915,
488,
395,
4396,
354,
13915,
488,
9,
421,
199,
318,
664,
63,
3556,
63,
533,
63,
354,
8,
1113,
304,
272,
3002,
63,
277,
275,
2519,
8,
1113,
12,
2560,
277,
7500,
2519,
8,
1113,
12,
283,
1017,
63,
277,
297,
488,
430,
272,
340,
3002,
63,
277,
365,
488,
26,
267,
372,
488,
272,
372,
664,
63,
533,
63,
354,
8,
1662,
63,
277,
9,
421,
199,
318,
664,
63,
1802,
8,
1113,
304,
272,
862,
26,
267,
2607,
63,
1250,
275,
1559,
855,
1250,
363,
272,
871,
26,
267,
2607,
63,
1250,
275,
488,
339,
340,
1228,
8,
1113,
12,
730,
9,
503,
730,
8,
1113,
2843,
354,
363,
508,
283,
533,
1113,
356,
267,
289,
2873,
275,
2519,
8,
1113,
12,
2560,
826,
7500,
2400,
26,
488,
9,
267,
340,
440,
1228,
8,
545,
66,
12,
334,
1313,
14,
26371,
12,
2943,
14,
24674,
2298,
288,
289,
2873,
275,
1559,
272,
916,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
304,
267,
289,
2873,
275,
2607,
63,
1250,
272,
587,
26,
267,
289,
2873,
275,
1559,
339,
26632,
275,
3087,
272,
4325,
63,
354,
275,
488,
272,
4325,
63,
533,
275,
488,
272,
340,
1228,
8,
545,
66,
12,
334,
1313,
14,
26371,
12,
2943,
14,
24674,
2298,
267,
3158,
63,
815,
275,
6485,
14,
362,
2861,
15644,
8,
545,
66,
9,
340,
2281,
63,
4521,
19,
43,
587,
6485,
14,
29836,
8,
545,
66,
9,
267,
26632,
275,
6485,
14,
908,
15644,
2031,
1650,
63,
815,
9,
267,
4325,
63,
354,
275,
2519,
8,
545,
66,
12,
2560,
354,
7500,
488,
9,
267,
340,
1228,
8,
1113,
12,
730,
9,
503,
730,
8,
1113,
2843,
354,
363,
508,
283,
533,
1113,
356,
288,
4325,
63,
354,
275,
4396,
826,
16526,
288,
4325,
63,
533,
275,
2519,
8,
1113,
12,
4396,
354,
13915,
298,
5912,
2543,
531,
267,
916,
365,
63,
3556,
63,
765,
8,
1113,
9,
503,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
304,
288,
4325,
63,
533,
275,
664,
63,
3556,
63,
533,
63,
354,
8,
1113,
9,
503,
298,
5912,
2543,
2,
339,
587,
26,
267,
4325,
63,
354,
275,
2519,
8,
545,
66,
12,
2560,
354,
7500,
488,
9,
267,
4325,
63,
277,
275,
2519,
8,
545,
66,
12,
2560,
277,
7500,
488,
9,
267,
340,
4325,
63,
277,
365,
440,
488,
436,
440,
1228,
8,
2324,
63,
277,
12,
2943,
14,
21820,
304,
288,
4325,
63,
533,
275,
664,
63,
533,
63,
354,
8,
2324,
63,
277,
9,
339,
1382,
63,
875,
275,
664,
63,
12485,
8,
2873,
63,
1250,
9,
340,
365,
63,
3556,
63,
765,
8,
2873,
63,
1250,
9,
587,
664,
63,
12485,
8,
1113,
9,
272,
372,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
26632,
12,
1382,
63,
875,
9,
421,
199,
318,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
26632,
12,
1382,
63,
875,
304,
272,
340,
4325,
63,
354,
436,
26632,
26,
267,
1382,
63,
875,
275,
3087,
340,
1382,
63,
875,
365,
488,
587,
1382,
63,
875,
267,
4325,
63,
5811,
275,
1218,
63,
1593,
63,
5811,
8,
2324,
63,
354,
12,
26632,
12,
1382,
63,
875,
12,
4363,
29,
17,
340,
4325,
63,
533,
587,
378,
9,
267,
340,
4325,
63,
533,
26,
288,
5348,
275,
4325,
63,
533,
340,
4325,
63,
354,
508,
2560,
826,
12217,
587,
4325,
63,
533,
435,
283,
1252,
7,
435,
4325,
63,
354,
288,
372,
1218,
63,
533,
63,
5811,
8,
2324,
63,
533,
12,
4325,
63,
5811,
9,
435,
1867,
78,
2,
435,
5348,
267,
587,
26,
288,
5348,
275,
4325,
63,
354,
288,
372,
4325,
63,
5811,
435,
1867,
78,
2,
435,
5348,
272,
916,
1382,
63,
875,
26,
267,
340,
4325,
63,
354,
26,
288,
14429,
63,
5233,
12,
485,
275,
4955,
63,
504,
63,
12485,
8,
1301,
63,
875,
12,
4325,
63,
354,
9,
288,
340,
14429,
63,
5233,
26,
355,
372,
1218,
63,
765,
63,
5811,
8,
2324,
63,
354,
12,
4325,
63,
533,
12,
14429,
63,
5233,
12,
1382,
63,
875,
9,
267,
372,
1218,
63,
1593,
63,
5811,
360,
5187,
297,
283,
2031,
589,
12,
1011,
958,
3196,
1382,
63,
875,
9,
435,
1557,
78,
5187,
7,
339,
587,
26,
267,
372,
2125,
421,
199,
318,
664,
63,
12485,
8,
1113,
304,
272,
340,
1559,
365,
440,
488,
26,
267,
862,
26,
288,
340,
2281,
63,
42,
57,
8472,
26,
355,
327,
25333,
355,
1382,
275,
1559,
855,
1301,
363,
355,
340,
1382,
365,
440,
488,
26,
490,
372,
1382,
2234,
687,
485,
23996,
63,
6469,
492,
485,
23996,
63,
24589,
63,
12775,
63,
8996,
529,
2234,
365,
63,
765,
12,
24485,
275,
485,
23996,
63,
24589,
63,
12775,
63,
8996,
529,
14,
374,
765,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Jgarcia-IAS/ReporsitorioVacioOdoo
|
openerp/addons/point_of_sale/wizard/__init__.py
|
382
|
1200
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pos_box
import pos_confirm
import pos_details
import pos_discount
import pos_open_statement
import pos_payment
import pos_session_opening
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
646,
2086,
63,
1977,
199,
646,
2086,
63,
9548,
199,
646,
2086,
63,
5087,
199,
646,
2086,
63,
15446,
199,
646,
2086,
63,
1490,
63,
6242,
199,
646,
2086,
63,
7948,
199,
646,
2086,
63,
1730,
63,
21849,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
646,
2086,
63,
1977,
199,
646,
2086,
63,
9548,
199,
646,
2086,
63,
5087,
199,
646,
2086,
63,
15446,
199,
646,
2086,
63,
1490,
63,
6242,
199,
646,
2086,
63,
7948,
199,
646,
2086,
63,
1730,
63,
21849,
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,
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,
0,
0,
0
] |
Djabbz/wakatime
|
wakatime/packages/requests/packages/chardet/utf8prober.py
|
2919
|
2652
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from . import constants
from .charsetprober import CharSetProber
from .codingstatemachine import CodingStateMachine
from .mbcssm import UTF8SMModel
ONE_CHAR_PROB = 0.5
class UTF8Prober(CharSetProber):
def __init__(self):
CharSetProber.__init__(self)
self._mCodingSM = CodingStateMachine(UTF8SMModel)
self.reset()
def reset(self):
CharSetProber.reset(self)
self._mCodingSM.reset()
self._mNumOfMBChar = 0
def get_charset_name(self):
return "utf-8"
def feed(self, aBuf):
for c in aBuf:
codingState = self._mCodingSM.next_state(c)
if codingState == constants.eError:
self._mState = constants.eNotMe
break
elif codingState == constants.eItsMe:
self._mState = constants.eFoundIt
break
elif codingState == constants.eStart:
if self._mCodingSM.get_current_charlen() >= 2:
self._mNumOfMBChar += 1
if self.get_state() == constants.eDetecting:
if self.get_confidence() > constants.SHORTCUT_THRESHOLD:
self._mState = constants.eFoundIt
return self.get_state()
def get_confidence(self):
unlike = 0.99
if self._mNumOfMBChar < 6:
for i in range(0, self._mNumOfMBChar):
unlike = unlike * ONE_CHAR_PROB
return 1.0 - unlike
else:
return unlike
|
bsd-3-clause
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
887,
3919,
77,
492,
9094,
24,
25335,
199,
199,
4817,
63,
5901,
63,
30533,
275,
378,
14,
21,
421,
199,
533,
9094,
24,
8029,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
6610,
24,
25335,
9,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
291,
423,
29633,
14,
3958,
342,
267,
291,
423,
77,
5667,
3466,
4567,
1610,
275,
378,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
1624,
13,
24,
2,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
367,
286,
315,
17407,
26,
288,
2803,
2223,
275,
291,
423,
29633,
14,
2184,
63,
929,
8,
67,
9,
288,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
11724,
26,
355,
340,
291,
423,
29633,
14,
362,
63,
1818,
63,
1560,
552,
342,
2356,
499,
26,
490,
291,
423,
77,
5667,
3466,
4567,
1610,
847,
413,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
291,
14,
362,
63,
13969,
342,
690,
5262,
14,
13003,
24678,
63,
19307,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
29750,
275,
378,
14,
1020,
267,
340,
291,
423,
77,
5667,
3466,
4567,
1610,
665,
1227,
26,
288,
367,
284,
315,
1425,
8,
16,
12,
291,
423,
77,
5667,
3466,
4567,
1610,
304,
355,
29750,
275,
29750,
627,
13051,
63,
5901,
63,
30533,
288,
372,
413,
14,
16,
446,
29750,
267,
587,
26,
288,
372,
29750,
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
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
504,
1275,
6043,
19903,
492,
31727,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
887,
3919,
77,
492,
9094,
24,
25335,
199,
199,
4817,
63,
5901,
63,
30533,
275,
378,
14,
21,
421,
199,
533,
9094,
24,
8029,
8,
15159,
304,
272,
347,
636,
826,
721,
277,
304,
267,
31727,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
6610,
24,
25335,
9,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
31727,
14,
3958,
8,
277,
9,
267,
291,
423,
29633,
14,
3958,
342,
267,
291,
423,
77,
5667,
3466,
4567,
1610,
275,
378,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
1624,
13,
24,
2,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
367,
286,
315,
17407,
26,
288,
2803,
2223,
275,
291,
423,
29633,
14,
2184,
63,
929,
8,
67,
9,
288,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
11724,
26,
355,
340,
291,
423,
29633,
14,
362,
63,
1818,
63,
1560,
552,
342,
2356,
499,
26,
490,
291,
423,
77,
5667,
3466,
4567,
1610,
847,
413,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
291,
14,
362,
63,
13969,
342,
690,
5262,
14,
13003,
24678,
63,
19307,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
29750,
275,
378,
14,
1020,
267,
340,
291,
423,
77,
5667,
3466,
4567,
1610,
665,
1227,
26,
288,
367,
284,
315,
1425,
8,
16,
12,
291,
423,
77,
5667,
3466,
4567,
1610,
304,
355,
29750,
275,
29750,
627,
13051,
63,
5901,
63,
30533,
288,
372,
413,
14,
16,
446,
29750,
267,
587,
26,
288,
372,
29750,
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,
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,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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
] |
monash-merc/cvl-fabric-launcher
|
IconPys/MASSIVElogoTransparent144x144.py
|
4
|
27769
|
#----------------------------------------------------------------------
# This file was generated by /usr/local/bin/img2py
#
from wx.lib.embeddedimage import PyEmbeddedImage
MASSIVElogoTransparent144x144 = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAD9GlDQ1BJQ0MgUHJvZmlsZQAA"
"eNqNlM9vFGUYxz+7886sCTgHUwGLwYk/gJBCtmCQBkF3u8u2UMtm22LbmJjt7NvdsdPZ8Z3Z"
"8iM9cdEbqH+Aihw8mHgywV8RLsBBAwlBQ2xITDiU+CNEEi6G1MNMdwdoxff0zPN+n+/3+zzv"
"k4HM51Xfd9MWzHqhqpTy1vjEpJW5QZpnWEM3a6p24OfK5SGAqu+7PHLu/UwK4Nr2le//86yp"
"ycCG1BNAsxbYs5A6Brpr+yoE4xaw52joh5B5FuhS4xOTkMkCXfUoLgBdU1E8DnSp0Uo/ZFzA"
"tBvVGmTmgZ6pRL6eiCMPAHSVpCeVY1uVUt4qq+a048qE3cdc/88z67aW9TYBa4OZkUPAVkgd"
"a6iBShx/YleLI8CLkLrsh/kKsBlSf7RmxnLANkg/Na0OjEX49KsnGqNvAusgXXPCwdE4f8Kb"
"Gj4c1abPzDQPVWLMZTvonwSeh/TNhhwcivxo1GShCPSAtqnRGoj5tYPB3EhxmedEo3844tHU"
"O9WDZaAbtPdVs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9Al9VScClqlhc6HC42WTX+69h6lzhCOjCerR3iVAkePlgC3vNbXXPIefe9U0+Nb/Ab42u"
"Ris4I7cMiyEYTYVFtUkVsfZuSC1l6BRdPYFOOPJykeNH9/Ho297BF/wIOy9CZxSKl26nAw/0"
"Wlq7drklKK59L/+62OWZostQ1kTwSW+1FEIJIZSUfeC6A7zgreCjJ+ssIUsQOj06+Tj/dsEI"
"//FG6Ewhes+05HuQTBE7aOd4ja4//pw03/1H+Afu5316gE+vOYcLok2wzr7PiCZlWq72QMu+"
"xBC0xK0dJxQLPLzpJm6/GB5Om57UpxyndrBwcJTxKq7bbxf/1FOUe8+jeNd7ufeHd7NucT9X"
"+AYOh4lKJYIxDmMEEwOqSrQGj1JVBSGr6B59luzq6/jamfA0aNi5SdymVH86IYV9Cgthg+tV"
"g4iegHtu24FbBnjWSit31PBOdJsBFVpql3+qus1KvlnJefzKbFKxGzfiEpgUAf5fYJ6DLWyw"
"BkH0YA0MaLBO0/Vfxn1mvuTe8FMAAAAASUVORK5CYII=")
getMASSIVElogoTransparent144x144Data = MASSIVElogoTransparent144x144.GetData
getMASSIVElogoTransparent144x144Image = MASSIVElogoTransparent144x144.GetImage
getMASSIVElogoTransparent144x144Bitmap = MASSIVElogoTransparent144x144.GetBitmap
|
gpl-3.0
|
[
7656,
8648,
199,
3,
961,
570,
1990,
4046,
701,
1182,
2647,
15,
1832,
15,
1393,
15,
4060,
18,
647,
199,
3,
199,
504,
4818,
14,
773,
14,
6427,
271,
23335,
492,
1611,
27395,
3491,
199,
199,
45,
26953,
9733,
3188,
1708,
9862,
88,
9862,
275,
1611,
27395,
3491,
8,
272,
298,
73,
27966,
726,
87,
16,
14634,
1939,
10985,
5622,
53,
72,
23539,
71,
10985,
42,
10985,
1348,
49,
3263,
57,
2276,
1554,
78,
50,
85,
43,
20,
2276,
1554,
25,
17541,
11888,
17,
16262,
49,
16,
45,
71,
53,
22313,
86,
26467,
478,
58,
49,
2276,
2,
272,
298,
69,
46,
81,
25940,
45,
25,
86,
38,
17188,
57,
19196,
11,
2277,
1184,
83,
1028,
71,
28327,
87,
2226,
87,
57,
75,
15,
71,
42,
6265,
7574,
25370,
34,
75,
38,
19,
85,
24,
85,
18,
2639,
7574,
1081,
44,
12648,
42,
26002,
23,
46,
86,
795,
68,
48,
58,
24,
58,
19,
58,
2,
272,
298,
24,
73,
45,
25,
2866,
37,
23907,
40,
11,
28960,
8090,
24,
77,
40,
4312,
87,
54,
24,
2431,
83,
34,
4134,
20159,
27383,
18,
88,
649,
1341,
53,
11,
35,
6388,
37,
73,
22,
39,
17,
16237,
45,
10772,
1117,
3581,
16,
90,
9060,
11,
78,
19616,
19,
11,
4348,
86,
2,
272,
298,
75,
20,
27699,
2869,
56,
2592,
25,
32726,
90,
40,
81,
72,
15202,
32603,
17,
86,
74,
14057,
42,
55,
21,
49,
58,
4812,
55,
2769,
19,
65,
22,
80,
1194,
3466,
43,
21,
4254,
33,
392,
11,
23,
9791,
18176,
15,
53,
87,
43,
20,
46,
82,
18,
274,
501,
1184,
2279,
2,
272,
298,
29874,
4064,
17,
18273,
2822,
1774,
57,
83,
21,
33,
22,
12771,
2700,
11,
16540,
37,
20,
1800,
87,
2528,
31073,
21,
34,
21,
19590,
72,
51,
20,
88,
1387,
75,
31506,
26001,
70,
53,
79,
44,
71,
34,
68,
53,
17,
37,
24,
36,
78,
5058,
16,
53,
79,
15,
23643,
6353,
2,
272,
298,
84,
34,
86,
29355,
77,
52,
6649,
58,
22,
80,
2431,
22,
24708,
23181,
20755,
4985,
80,
24417,
54,
57,
17,
85,
54,
53,
84,
20,
16672,
11,
65,
9941,
81,
37,
19,
25193,
15,
1299,
90,
1822,
19098,
25,
2099,
13864,
20,
47,
58,
75,
2160,
6087,
75,
7136,
2,
272,
298,
65,
22,
17587,
2662,
88,
15,
57,
274,
2673,
24,
1981,
75,
44,
82,
609,
15,
75,
43,
83,
24613,
51,
70,
23,
31330,
5032,
10825,
9761,
15,
8565,
16,
47,
74,
1438,
1887,
43,
5167,
39,
81,
46,
86,
33,
527,
71,
2483,
4222,
2989,
37,
20,
70,
24,
43,
66,
2,
272,
298,
39,
74,
20,
67,
17,
371,
48,
90,
11888,
24553,
55,
25526,
58,
52,
86,
265,
87,
1513,
72,
15,
52,
46,
72,
8090,
559,
86,
15987,
17,
39,
2662,
2890,
51,
1271,
15156,
50,
7250,
74,
21,
84,
7431,
34,
19,
37,
26757,
3594,
37,
79,
8188,
20,
84,
28327,
2,
272,
298,
47,
25,
16698,
13163,
5583,
84,
48,
68,
20343,
19,
41,
2006,
81,
89,
6341,
55,
22,
80,
28104,
13848,
38,
15,
18,
87,
10213,
86,
49,
38,
74,
969,
69,
35,
8047,
21490,
57,
45,
5908,
2749,
11,
66,
28000,
47,
72,
6741,
390,
18,
72,
7250,
17,
82,
1845,
51,
16,
2,
272,
298,
67,
18,
33,
6323,
83,
15,
23,
10472,
7697,
24,
1892,
47,
1710,
58,
76,
25526,
58,
67,
345,
1038,
1136,
3927,
70,
16,
6993,
1484,
66,
1734,
25,
24614,
72,
2160,
1554,
84,
36,
19,
1480,
50,
20271,
68,
42,
75,
4373,
46,
88,
1216,
83,
43,
80,
13247,
2,
272,
298,
57,
11,
39,
3387,
10892,
46,
71,
16,
83,
16911,
57,
68,
37,
20,
65,
1513,
58,
17613,
78,
24600,
87,
22534,
57,
82,
74,
36,
81,
24839,
88,
39,
22153,
72,
57,
47,
25,
28665,
26697,
85,
34,
17,
74,
596,
43,
25,
89,
6583,
68,
41,
1003,
18,
5908,
39,
88,
52,
11,
87,
50,
2,
272,
298,
70,
54,
8047,
46,
70,
39,
2789,
35,
24,
16944,
1003,
22,
31985,
2528,
66,
52,
77,
16168,
17,
40,
977,
1381,
78,
56,
54,
80,
1193,
35,
679,
3867,
11,
22,
85,
23,
55,
17,
79,
19,
68,
51,
432,
19,
57,
54,
1780,
25395,
35,
22,
11,
57,
6164,
310,
3501,
2,
272,
298,
47,
49,
4220,
58,
454,
41,
23,
6413,
11,
44,
2835,
15,
84,
22,
14903,
67,
54,
18,
301,
11,
3042,
18,
11475,
90,
10213,
23,
2177,
24553,
66,
11,
81,
42,
11,
56,
66,
11,
76,
1355,
9839,
47,
71,
74,
25,
54,
2192,
7575,
25,
34,
21405,
1658,
38,
80,
57,
21,
75,
2,
272,
298,
38,
676,
36,
3577,
50,
2090,
37,
74,
18,
67,
1254,
56,
75,
35,
810,
86,
11,
14784,
2566,
33,
69,
53,
25620,
18,
52,
977,
19,
464,
87,
4599,
11,
23,
41,
2635,
23064,
19596,
47,
2279,
21,
9060,
15,
80,
44,
25,
45,
19,
83,
25,
11,
18,
78,
18,
66,
48,
66,
19,
2,
272,
298,
72,
22,
65,
1349,
80,
51,
16,
74,
23,
51,
5941,
47,
11,
17,
82,
23,
54,
5941,
34,
11,
400,
48,
4232,
3655,
16,
40,
23,
65,
44,
18,
9928,
58,
84,
20,
81,
17,
55,
1082,
15,
10932,
14176,
68,
35,
18843,
54,
647,
17,
8313,
21400,
21,
7862,
90,
30814,
46,
71,
2,
272,
298,
48,
278,
11,
21959,
2869,
11,
23332,
17,
58,
81,
2426,
57,
39,
20,
8163,
11,
66,
39,
25,
2393,
76,
25,
58,
43,
25,
27588,
90,
3308,
81,
69,
22,
83,
416,
4680,
24,
11435,
20,
51,
71,
5943,
53,
6087,
38,
20,
15,
74,
36,
11,
17,
15,
20770,
996,
73,
54,
20,
88,
2,
272,
7210,
8711,
55,
23,
72,
38,
23,
50,
68,
348,
934,
49,
23063,
71,
23,
44,
18,
30271,
16,
30271,
19,
39,
49,
5763,
56,
24,
55,
795,
14449,
80,
39,
78,
23,
25500,
13368,
22,
87,
1587,
57,
81,
40,
12595,
11959,
5889,
977,
7096,
49,
15225,
5016,
67,
42,
72,
36,
2,
272,
298,
20,
72,
27061,
49,
19,
6080,
3973,
22926,
11,
261,
54,
53,
18,
11,
37,
17,
83,
21,
83,
25,
21035,
82,
21
] |
[
8648,
199,
3,
961,
570,
1990,
4046,
701,
1182,
2647,
15,
1832,
15,
1393,
15,
4060,
18,
647,
199,
3,
199,
504,
4818,
14,
773,
14,
6427,
271,
23335,
492,
1611,
27395,
3491,
199,
199,
45,
26953,
9733,
3188,
1708,
9862,
88,
9862,
275,
1611,
27395,
3491,
8,
272,
298,
73,
27966,
726,
87,
16,
14634,
1939,
10985,
5622,
53,
72,
23539,
71,
10985,
42,
10985,
1348,
49,
3263,
57,
2276,
1554,
78,
50,
85,
43,
20,
2276,
1554,
25,
17541,
11888,
17,
16262,
49,
16,
45,
71,
53,
22313,
86,
26467,
478,
58,
49,
2276,
2,
272,
298,
69,
46,
81,
25940,
45,
25,
86,
38,
17188,
57,
19196,
11,
2277,
1184,
83,
1028,
71,
28327,
87,
2226,
87,
57,
75,
15,
71,
42,
6265,
7574,
25370,
34,
75,
38,
19,
85,
24,
85,
18,
2639,
7574,
1081,
44,
12648,
42,
26002,
23,
46,
86,
795,
68,
48,
58,
24,
58,
19,
58,
2,
272,
298,
24,
73,
45,
25,
2866,
37,
23907,
40,
11,
28960,
8090,
24,
77,
40,
4312,
87,
54,
24,
2431,
83,
34,
4134,
20159,
27383,
18,
88,
649,
1341,
53,
11,
35,
6388,
37,
73,
22,
39,
17,
16237,
45,
10772,
1117,
3581,
16,
90,
9060,
11,
78,
19616,
19,
11,
4348,
86,
2,
272,
298,
75,
20,
27699,
2869,
56,
2592,
25,
32726,
90,
40,
81,
72,
15202,
32603,
17,
86,
74,
14057,
42,
55,
21,
49,
58,
4812,
55,
2769,
19,
65,
22,
80,
1194,
3466,
43,
21,
4254,
33,
392,
11,
23,
9791,
18176,
15,
53,
87,
43,
20,
46,
82,
18,
274,
501,
1184,
2279,
2,
272,
298,
29874,
4064,
17,
18273,
2822,
1774,
57,
83,
21,
33,
22,
12771,
2700,
11,
16540,
37,
20,
1800,
87,
2528,
31073,
21,
34,
21,
19590,
72,
51,
20,
88,
1387,
75,
31506,
26001,
70,
53,
79,
44,
71,
34,
68,
53,
17,
37,
24,
36,
78,
5058,
16,
53,
79,
15,
23643,
6353,
2,
272,
298,
84,
34,
86,
29355,
77,
52,
6649,
58,
22,
80,
2431,
22,
24708,
23181,
20755,
4985,
80,
24417,
54,
57,
17,
85,
54,
53,
84,
20,
16672,
11,
65,
9941,
81,
37,
19,
25193,
15,
1299,
90,
1822,
19098,
25,
2099,
13864,
20,
47,
58,
75,
2160,
6087,
75,
7136,
2,
272,
298,
65,
22,
17587,
2662,
88,
15,
57,
274,
2673,
24,
1981,
75,
44,
82,
609,
15,
75,
43,
83,
24613,
51,
70,
23,
31330,
5032,
10825,
9761,
15,
8565,
16,
47,
74,
1438,
1887,
43,
5167,
39,
81,
46,
86,
33,
527,
71,
2483,
4222,
2989,
37,
20,
70,
24,
43,
66,
2,
272,
298,
39,
74,
20,
67,
17,
371,
48,
90,
11888,
24553,
55,
25526,
58,
52,
86,
265,
87,
1513,
72,
15,
52,
46,
72,
8090,
559,
86,
15987,
17,
39,
2662,
2890,
51,
1271,
15156,
50,
7250,
74,
21,
84,
7431,
34,
19,
37,
26757,
3594,
37,
79,
8188,
20,
84,
28327,
2,
272,
298,
47,
25,
16698,
13163,
5583,
84,
48,
68,
20343,
19,
41,
2006,
81,
89,
6341,
55,
22,
80,
28104,
13848,
38,
15,
18,
87,
10213,
86,
49,
38,
74,
969,
69,
35,
8047,
21490,
57,
45,
5908,
2749,
11,
66,
28000,
47,
72,
6741,
390,
18,
72,
7250,
17,
82,
1845,
51,
16,
2,
272,
298,
67,
18,
33,
6323,
83,
15,
23,
10472,
7697,
24,
1892,
47,
1710,
58,
76,
25526,
58,
67,
345,
1038,
1136,
3927,
70,
16,
6993,
1484,
66,
1734,
25,
24614,
72,
2160,
1554,
84,
36,
19,
1480,
50,
20271,
68,
42,
75,
4373,
46,
88,
1216,
83,
43,
80,
13247,
2,
272,
298,
57,
11,
39,
3387,
10892,
46,
71,
16,
83,
16911,
57,
68,
37,
20,
65,
1513,
58,
17613,
78,
24600,
87,
22534,
57,
82,
74,
36,
81,
24839,
88,
39,
22153,
72,
57,
47,
25,
28665,
26697,
85,
34,
17,
74,
596,
43,
25,
89,
6583,
68,
41,
1003,
18,
5908,
39,
88,
52,
11,
87,
50,
2,
272,
298,
70,
54,
8047,
46,
70,
39,
2789,
35,
24,
16944,
1003,
22,
31985,
2528,
66,
52,
77,
16168,
17,
40,
977,
1381,
78,
56,
54,
80,
1193,
35,
679,
3867,
11,
22,
85,
23,
55,
17,
79,
19,
68,
51,
432,
19,
57,
54,
1780,
25395,
35,
22,
11,
57,
6164,
310,
3501,
2,
272,
298,
47,
49,
4220,
58,
454,
41,
23,
6413,
11,
44,
2835,
15,
84,
22,
14903,
67,
54,
18,
301,
11,
3042,
18,
11475,
90,
10213,
23,
2177,
24553,
66,
11,
81,
42,
11,
56,
66,
11,
76,
1355,
9839,
47,
71,
74,
25,
54,
2192,
7575,
25,
34,
21405,
1658,
38,
80,
57,
21,
75,
2,
272,
298,
38,
676,
36,
3577,
50,
2090,
37,
74,
18,
67,
1254,
56,
75,
35,
810,
86,
11,
14784,
2566,
33,
69,
53,
25620,
18,
52,
977,
19,
464,
87,
4599,
11,
23,
41,
2635,
23064,
19596,
47,
2279,
21,
9060,
15,
80,
44,
25,
45,
19,
83,
25,
11,
18,
78,
18,
66,
48,
66,
19,
2,
272,
298,
72,
22,
65,
1349,
80,
51,
16,
74,
23,
51,
5941,
47,
11,
17,
82,
23,
54,
5941,
34,
11,
400,
48,
4232,
3655,
16,
40,
23,
65,
44,
18,
9928,
58,
84,
20,
81,
17,
55,
1082,
15,
10932,
14176,
68,
35,
18843,
54,
647,
17,
8313,
21400,
21,
7862,
90,
30814,
46,
71,
2,
272,
298,
48,
278,
11,
21959,
2869,
11,
23332,
17,
58,
81,
2426,
57,
39,
20,
8163,
11,
66,
39,
25,
2393,
76,
25,
58,
43,
25,
27588,
90,
3308,
81,
69,
22,
83,
416,
4680,
24,
11435,
20,
51,
71,
5943,
53,
6087,
38,
20,
15,
74,
36,
11,
17,
15,
20770,
996,
73,
54,
20,
88,
2,
272,
7210,
8711,
55,
23,
72,
38,
23,
50,
68,
348,
934,
49,
23063,
71,
23,
44,
18,
30271,
16,
30271,
19,
39,
49,
5763,
56,
24,
55,
795,
14449,
80,
39,
78,
23,
25500,
13368,
22,
87,
1587,
57,
81,
40,
12595,
11959,
5889,
977,
7096,
49,
15225,
5016,
67,
42,
72,
36,
2,
272,
298,
20,
72,
27061,
49,
19,
6080,
3973,
22926,
11,
261,
54,
53,
18,
11,
37,
17,
83,
21,
83,
25,
21035,
82,
21,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kyroskoh/phantomjs
|
src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/steps/haslanded_unittest.py
|
124
|
8125
|
# Copyright (C) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import unittest2 as unittest
import subprocess
from webkitpy.tool.steps.haslanded import HasLanded
class HasLandedTest(unittest.TestCase):
maxDiff = None
@unittest.skipUnless(subprocess.call('which interdiff', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0, "requires interdiff")
def test_run(self):
# These patches require trailing whitespace to remain valid patches.
diff1 = """\
Index: a.py
===================================================================
--- a.py
+++ a.py
@@ -1,3 +1,5 @@
A
B
C
+D
+E
Index: b.py
===================================================================
--- b.py 2013-01-21 15:20:59.693887185 +1100
+++ b.py 2013-01-21 15:22:24.382555711 +1100
@@ -1,3 +1,5 @@
1
2
3
+4
+5
"""
diff1_add_line = """\
Index: a.py
===================================================================
--- a.py
+++ a.py
@@ -1,3 +1,6 @@
A
B
C
+D
+E
+F
Index: b.py
===================================================================
--- b.py
+++ b.py
@@ -1,3 +1,5 @@
1
2
3
+4
+5
"""
diff1_remove_line = """\
Index: a.py
===================================================================
--- a.py
+++ a.py
@@ -1,3 +1,4 @@
A
B
C
+D
Index: b.py
===================================================================
--- b.py
+++ b.py
@@ -1,3 +1,5 @@
1
2
3
+4
+5
"""
diff1_add_file = diff1 + """\
Index: c.py
===================================================================
--- c.py
+++ c.py
@@ -1,3 +1,5 @@
1
2
3
+4
+5
"""
diff1_remove_file = """\
Index: a.py
===================================================================
--- a.py
+++ a.py
@@ -1,3 +1,5 @@
A
B
C
+D
+E
"""
self.assertMultiLineEqual(
HasLanded.diff_diff(diff1, diff1_add_line, '', 'add-line'),
"""\
diff -u a.py a.py
--- a.py
+++ a.py
@@ -5,0 +6 @@
+F
""")
self.assertMultiLineEqual(
HasLanded.diff_diff(diff1, diff1_remove_line, '', 'remove-line'),
"""\
diff -u a.py a.py
--- a.py
+++ a.py
@@ -5 +4,0 @@
-E
""")
self.assertMultiLineEqual(
HasLanded.diff_diff(diff1, diff1_add_file, '', 'add-file'),
"""\
only in patch2:
unchanged:
--- c.py
+++ c.py
@@ -1,3 +1,5 @@
1
2
3
+4
+5
""")
self.assertMultiLineEqual(
HasLanded.diff_diff(diff1, diff1_remove_file, '', 'remove-file'),
"""\
reverted:
--- b.py 2013-01-21 15:22:24.382555711 +1100
+++ b.py 2013-01-21 15:20:59.693887185 +1100
@@ -1,5 +1,3 @@
1
2
3
-4
-5
""")
def test_convert_to_svn_and_strip_change_log(self):
# These patches require trailing whitespace to remain valid patches.
testbefore1 = HasLanded.convert_to_svn("""\
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 219ba72..0390b73 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,32 @@
+2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
+
+ Adding "has-landed" command to webkit-patch which allows a person to
+ Reviewed by NOBODY (OOPS!).
+
2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
Extend diff_parser to support the --full-index output.
diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
index 4bf8ec6..3a128cb 100644
--- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
+++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
""")
testafter1 = HasLanded.convert_to_svn("""\
diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
index 4bf8ec6..3a128cb 100644
--- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
+++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 219ba72..0390b73 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,32 @@
+2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
+
+ Adding "has-landed" command to webkit-patch which allows a person to
+ Reviewed by NOBODY (OOPS!).
+
2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
Extend diff_parser to support the --full-index output.
""")
testexpected1 = """\
Index: Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
===================================================================
--- Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
+++ Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
"""
testmiddle1 = HasLanded.convert_to_svn("""\
diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
index 4bf8ec6..3a128cb 100644
--- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
+++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
diff --git a/ChangeLog b/ChangeLog
index 219ba72..0390b73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
+
+ Adding "has-landed" command to webkit-patch which allows a person to
+ Reviewed by NOBODY (OOPS!).
+
2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
Extend diff_parser to support the --full-index output.
diff --git a/Tools/Scripts/webkitpy/common/other.py b/Tools/Scripts/webkitpy/common/other.py
index 4bf8ec6..3a128cb 100644
--- a/Tools/Scripts/webkitpy/common/other.py
+++ b/Tools/Scripts/webkitpy/common/other.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
""")
testexpected2 = """\
Index: Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
===================================================================
--- Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
+++ Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
Index: Tools/Scripts/webkitpy/common/other.py
===================================================================
--- Tools/Scripts/webkitpy/common/other.py
+++ Tools/Scripts/webkitpy/common/other.py
@@ -28,6 +28,8 @@
+import re
+
from .attachment import Attachment
"""
self.assertMultiLineEqual(testexpected1, HasLanded.strip_change_log(testbefore1))
self.assertMultiLineEqual(testexpected1, HasLanded.strip_change_log(testafter1))
self.assertMultiLineEqual(testexpected2, HasLanded.strip_change_log(testmiddle1))
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
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,
259,
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,
259,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2882,
18,
465,
2882,
199,
646,
3873,
199,
199,
504,
18007,
14,
3557,
14,
5895,
14,
1989,
1502,
770,
492,
13481,
44,
7028,
421,
199,
533,
13481,
44,
7028,
774,
8,
2796,
14,
1746,
304,
272,
1390,
10746,
275,
488,
339,
768,
2796,
14,
11278,
8,
5781,
14,
1250,
360,
6777,
1640,
3028,
297,
5218,
29,
549,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
9,
508,
378,
12,
298,
6537,
1640,
3028,
531,
272,
347,
511,
63,
1065,
8,
277,
304,
267,
327,
5723,
12385,
4409,
8520,
8139,
370,
5706,
1686,
12385,
14,
267,
3915,
17,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
420,
6171,
13,
614,
13,
2025,
4114,
26,
1165,
26,
1427,
14,
1876,
11403,
23,
10233,
435,
26451,
199,
4176,
11,
330,
14,
647,
420,
6171,
13,
614,
13,
2025,
4114,
26,
1081,
26,
1194,
14,
1703,
821,
18725,
845,
435,
26451,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
525,
63,
604,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
22,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
11,
38,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
199,
4176,
11,
330,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
2168,
63,
604,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
20,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
199,
4176,
11,
330,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
525,
63,
493,
275,
3915,
17,
435,
9638,
199,
2681,
26,
286,
14,
647,
199,
5695,
5918,
199,
2595,
286,
14,
647,
199,
4176,
11,
286,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
2168,
63,
493,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
624,
267,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
525,
63,
604,
12,
3260,
283,
525,
13,
604,
659,
288,
9638,
199,
3028,
446,
85,
282,
14,
647,
282,
14,
647,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
21,
12,
16,
435,
22,
13365,
199,
11,
38,
199,
6141,
398,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
2168,
63,
604,
12,
3260,
283,
2168,
13,
604,
659,
288,
9638,
199,
3028,
446,
85,
282,
14,
647,
282,
14,
647,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
21,
435,
20,
12,
16,
13365,
199,
13,
37,
199,
6141,
267,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
525,
63,
493,
12,
3260,
283
] |
[
1898,
334,
35,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
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,
259,
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,
259,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2882,
18,
465,
2882,
199,
646,
3873,
199,
199,
504,
18007,
14,
3557,
14,
5895,
14,
1989,
1502,
770,
492,
13481,
44,
7028,
421,
199,
533,
13481,
44,
7028,
774,
8,
2796,
14,
1746,
304,
272,
1390,
10746,
275,
488,
339,
768,
2796,
14,
11278,
8,
5781,
14,
1250,
360,
6777,
1640,
3028,
297,
5218,
29,
549,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
9,
508,
378,
12,
298,
6537,
1640,
3028,
531,
272,
347,
511,
63,
1065,
8,
277,
304,
267,
327,
5723,
12385,
4409,
8520,
8139,
370,
5706,
1686,
12385,
14,
267,
3915,
17,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
420,
6171,
13,
614,
13,
2025,
4114,
26,
1165,
26,
1427,
14,
1876,
11403,
23,
10233,
435,
26451,
199,
4176,
11,
330,
14,
647,
420,
6171,
13,
614,
13,
2025,
4114,
26,
1081,
26,
1194,
14,
1703,
821,
18725,
845,
435,
26451,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
525,
63,
604,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
22,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
11,
38,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
199,
4176,
11,
330,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
2168,
63,
604,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
20,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
2681,
26,
330,
14,
647,
199,
5695,
5918,
199,
2595,
330,
14,
647,
199,
4176,
11,
330,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
525,
63,
493,
275,
3915,
17,
435,
9638,
199,
2681,
26,
286,
14,
647,
199,
5695,
5918,
199,
2595,
286,
14,
647,
199,
4176,
11,
286,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
413,
199,
499,
199,
650,
199,
11,
20,
199,
11,
21,
199,
624,
398,
3915,
17,
63,
2168,
63,
493,
275,
9638,
199,
2681,
26,
282,
14,
647,
199,
5695,
5918,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
17,
12,
19,
435,
17,
12,
21,
13365,
199,
437,
199,
699,
199,
445,
199,
11,
36,
199,
11,
37,
199,
624,
267,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
525,
63,
604,
12,
3260,
283,
525,
13,
604,
659,
288,
9638,
199,
3028,
446,
85,
282,
14,
647,
282,
14,
647,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
21,
12,
16,
435,
22,
13365,
199,
11,
38,
199,
6141,
398,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
2168,
63,
604,
12,
3260,
283,
2168,
13,
604,
659,
288,
9638,
199,
3028,
446,
85,
282,
14,
647,
282,
14,
647,
199,
2595,
282,
14,
647,
199,
4176,
11,
282,
14,
647,
199,
7492,
446,
21,
435,
20,
12,
16,
13365,
199,
13,
37,
199,
6141,
267,
291,
14,
479,
3947,
3049,
591,
8,
288,
13481,
44,
7028,
14,
3028,
63,
3028,
8,
3028,
17,
12,
3915,
17,
63,
525,
63,
493,
12,
3260,
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,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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
] |
alex/sqlalchemy
|
test/dialect/postgresql/test_reflection.py
|
2
|
18054
|
# coding: utf-8
from sqlalchemy.testing.assertions import eq_, assert_raises, \
assert_raises_message, is_, AssertsExecutionResults, \
AssertsCompiledSQL, ComparesTables
from sqlalchemy.testing import engines, fixtures
from sqlalchemy import testing
from sqlalchemy import Table, Column, select, MetaData, text, Integer, \
String, Sequence, ForeignKey, join, Numeric, \
PrimaryKeyConstraint, DateTime, tuple_, Float, BigInteger, \
func, literal_column, literal, bindparam, cast, extract, \
SmallInteger, Enum, REAL, update, insert, Index, delete, \
and_, Date, TypeDecorator, Time, Unicode, Interval, or_, Text
from sqlalchemy import exc
from sqlalchemy.dialects.postgresql import base as postgresql
import logging
class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
"""Test PostgreSQL domains"""
__only_on__ = 'postgresql'
@classmethod
def setup_class(cls):
con = testing.db.connect()
for ddl in \
'CREATE DOMAIN testdomain INTEGER NOT NULL DEFAULT 42', \
'CREATE DOMAIN test_schema.testdomain INTEGER DEFAULT 0', \
"CREATE TYPE testtype AS ENUM ('test')", \
'CREATE DOMAIN enumdomain AS testtype'\
:
try:
con.execute(ddl)
except exc.DBAPIError as e:
if not 'already exists' in str(e):
raise e
con.execute('CREATE TABLE testtable (question integer, answer '
'testdomain)')
con.execute('CREATE TABLE test_schema.testtable(question '
'integer, answer test_schema.testdomain, anything '
'integer)')
con.execute('CREATE TABLE crosschema (question integer, answer '
'test_schema.testdomain)')
con.execute('CREATE TABLE enum_test (id integer, data enumdomain)')
@classmethod
def teardown_class(cls):
con = testing.db.connect()
con.execute('DROP TABLE testtable')
con.execute('DROP TABLE test_schema.testtable')
con.execute('DROP TABLE crosschema')
con.execute('DROP DOMAIN testdomain')
con.execute('DROP DOMAIN test_schema.testdomain')
con.execute("DROP TABLE enum_test")
con.execute("DROP DOMAIN enumdomain")
con.execute("DROP TYPE testtype")
def test_table_is_reflected(self):
metadata = MetaData(testing.db)
table = Table('testtable', metadata, autoload=True)
eq_(set(table.columns.keys()), set(['question', 'answer']),
"Columns of reflected table didn't equal expected columns")
assert isinstance(table.c.answer.type, Integer)
def test_domain_is_reflected(self):
metadata = MetaData(testing.db)
table = Table('testtable', metadata, autoload=True)
eq_(str(table.columns.answer.server_default.arg), '42',
"Reflected default value didn't equal expected value")
assert not table.columns.answer.nullable, \
'Expected reflected column to not be nullable.'
def test_enum_domain_is_reflected(self):
metadata = MetaData(testing.db)
table = Table('enum_test', metadata, autoload=True)
eq_(
table.c.data.type.enums,
('test', )
)
def test_table_is_reflected_test_schema(self):
metadata = MetaData(testing.db)
table = Table('testtable', metadata, autoload=True,
schema='test_schema')
eq_(set(table.columns.keys()), set(['question', 'answer',
'anything']),
"Columns of reflected table didn't equal expected columns")
assert isinstance(table.c.anything.type, Integer)
def test_schema_domain_is_reflected(self):
metadata = MetaData(testing.db)
table = Table('testtable', metadata, autoload=True,
schema='test_schema')
eq_(str(table.columns.answer.server_default.arg), '0',
"Reflected default value didn't equal expected value")
assert table.columns.answer.nullable, \
'Expected reflected column to be nullable.'
def test_crosschema_domain_is_reflected(self):
metadata = MetaData(testing.db)
table = Table('crosschema', metadata, autoload=True)
eq_(str(table.columns.answer.server_default.arg), '0',
"Reflected default value didn't equal expected value")
assert table.columns.answer.nullable, \
'Expected reflected column to be nullable.'
def test_unknown_types(self):
from sqlalchemy.databases import postgresql
ischema_names = postgresql.PGDialect.ischema_names
postgresql.PGDialect.ischema_names = {}
try:
m2 = MetaData(testing.db)
assert_raises(exc.SAWarning, Table, 'testtable', m2,
autoload=True)
@testing.emits_warning('Did not recognize type')
def warns():
m3 = MetaData(testing.db)
t3 = Table('testtable', m3, autoload=True)
assert t3.c.answer.type.__class__ == sa.types.NullType
finally:
postgresql.PGDialect.ischema_names = ischema_names
class ReflectionTest(fixtures.TestBase):
__only_on__ = 'postgresql'
@testing.fails_if(('postgresql', '<', (8, 4)),
"newer query is bypassed due to unsupported SQL functions")
@testing.provide_metadata
def test_reflected_primary_key_order(self):
meta1 = self.metadata
subject = Table('subject', meta1,
Column('p1', Integer, primary_key=True),
Column('p2', Integer, primary_key=True),
PrimaryKeyConstraint('p2', 'p1')
)
meta1.create_all()
meta2 = MetaData(testing.db)
subject = Table('subject', meta2, autoload=True)
eq_(subject.primary_key.columns.keys(), ['p2', 'p1'])
@testing.provide_metadata
def test_pg_weirdchar_reflection(self):
meta1 = self.metadata
subject = Table('subject', meta1, Column('id$', Integer,
primary_key=True))
referer = Table('referer', meta1, Column('id', Integer,
primary_key=True), Column('ref', Integer,
ForeignKey('subject.id$')))
meta1.create_all()
meta2 = MetaData(testing.db)
subject = Table('subject', meta2, autoload=True)
referer = Table('referer', meta2, autoload=True)
self.assert_((subject.c['id$']
== referer.c.ref).compare(
subject.join(referer).onclause))
@testing.provide_metadata
def test_renamed_sequence_reflection(self):
metadata = self.metadata
t = Table('t', metadata, Column('id', Integer, primary_key=True))
metadata.create_all()
m2 = MetaData(testing.db)
t2 = Table('t', m2, autoload=True, implicit_returning=False)
eq_(t2.c.id.server_default.arg.text,
"nextval('t_id_seq'::regclass)")
r = t2.insert().execute()
eq_(r.inserted_primary_key, [1])
testing.db.connect().execution_options(autocommit=True).\
execute('alter table t_id_seq rename to foobar_id_seq'
)
m3 = MetaData(testing.db)
t3 = Table('t', m3, autoload=True, implicit_returning=False)
eq_(t3.c.id.server_default.arg.text,
"nextval('foobar_id_seq'::regclass)")
r = t3.insert().execute()
eq_(r.inserted_primary_key, [2])
@testing.provide_metadata
def test_renamed_pk_reflection(self):
metadata = self.metadata
t = Table('t', metadata, Column('id', Integer, primary_key=True))
metadata.create_all()
testing.db.connect().execution_options(autocommit=True).\
execute('alter table t rename id to t_id')
m2 = MetaData(testing.db)
t2 = Table('t', m2, autoload=True)
eq_([c.name for c in t2.primary_key], ['t_id'])
@testing.provide_metadata
def test_schema_reflection(self):
"""note: this test requires that the 'test_schema' schema be
separate and accessible by the test user"""
meta1 = self.metadata
users = Table('users', meta1, Column('user_id', Integer,
primary_key=True), Column('user_name',
String(30), nullable=False), schema='test_schema')
addresses = Table(
'email_addresses',
meta1,
Column('address_id', Integer, primary_key=True),
Column('remote_user_id', Integer,
ForeignKey(users.c.user_id)),
Column('email_address', String(20)),
schema='test_schema',
)
meta1.create_all()
meta2 = MetaData(testing.db)
addresses = Table('email_addresses', meta2, autoload=True,
schema='test_schema')
users = Table('users', meta2, mustexist=True,
schema='test_schema')
j = join(users, addresses)
self.assert_((users.c.user_id
== addresses.c.remote_user_id).compare(j.onclause))
@testing.provide_metadata
def test_schema_reflection_2(self):
meta1 = self.metadata
subject = Table('subject', meta1, Column('id', Integer,
primary_key=True))
referer = Table('referer', meta1, Column('id', Integer,
primary_key=True), Column('ref', Integer,
ForeignKey('subject.id')), schema='test_schema')
meta1.create_all()
meta2 = MetaData(testing.db)
subject = Table('subject', meta2, autoload=True)
referer = Table('referer', meta2, schema='test_schema',
autoload=True)
self.assert_((subject.c.id
== referer.c.ref).compare(
subject.join(referer).onclause))
@testing.provide_metadata
def test_schema_reflection_3(self):
meta1 = self.metadata
subject = Table('subject', meta1, Column('id', Integer,
primary_key=True), schema='test_schema_2')
referer = Table('referer', meta1, Column('id', Integer,
primary_key=True), Column('ref', Integer,
ForeignKey('test_schema_2.subject.id')),
schema='test_schema')
meta1.create_all()
meta2 = MetaData(testing.db)
subject = Table('subject', meta2, autoload=True,
schema='test_schema_2')
referer = Table('referer', meta2, schema='test_schema',
autoload=True)
self.assert_((subject.c.id
== referer.c.ref).compare(
subject.join(referer).onclause))
@testing.provide_metadata
def test_uppercase_lowercase_table(self):
metadata = self.metadata
a_table = Table('a', metadata, Column('x', Integer))
A_table = Table('A', metadata, Column('x', Integer))
a_table.create()
assert testing.db.has_table("a")
assert not testing.db.has_table("A")
A_table.create(checkfirst=True)
assert testing.db.has_table("A")
def test_uppercase_lowercase_sequence(self):
a_seq = Sequence('a')
A_seq = Sequence('A')
a_seq.create(testing.db)
assert testing.db.dialect.has_sequence(testing.db, "a")
assert not testing.db.dialect.has_sequence(testing.db, "A")
A_seq.create(testing.db, checkfirst=True)
assert testing.db.dialect.has_sequence(testing.db, "A")
a_seq.drop(testing.db)
A_seq.drop(testing.db)
def test_schema_reflection_multi_search_path(self):
"""test the 'set the same schema' rule when
multiple schemas/search paths are in effect."""
db = engines.testing_engine()
conn = db.connect()
trans = conn.begin()
try:
conn.execute("set search_path to test_schema_2, "
"test_schema, public")
conn.dialect.default_schema_name = "test_schema_2"
conn.execute("""
CREATE TABLE test_schema.some_table (
id SERIAL not null primary key
)
""")
conn.execute("""
CREATE TABLE test_schema_2.some_other_table (
id SERIAL not null primary key,
sid INTEGER REFERENCES test_schema.some_table(id)
)
""")
m1 = MetaData()
t2_schema = Table('some_other_table',
m1,
schema="test_schema_2",
autoload=True,
autoload_with=conn)
t1_schema = Table('some_table',
m1,
schema="test_schema",
autoload=True,
autoload_with=conn)
t2_no_schema = Table('some_other_table',
m1,
autoload=True,
autoload_with=conn)
t1_no_schema = Table('some_table',
m1,
autoload=True,
autoload_with=conn)
# OK, this because, "test_schema" is
# in the search path, and might as well be
# the default too. why would we assign
# a "schema" to the Table ?
assert t2_schema.c.sid.references(
t1_no_schema.c.id)
assert t2_no_schema.c.sid.references(
t1_no_schema.c.id)
finally:
trans.rollback()
conn.close()
db.dispose()
@testing.provide_metadata
def test_index_reflection(self):
""" Reflecting partial & expression-based indexes should warn
"""
metadata = self.metadata
t1 = Table('party', metadata, Column('id', String(10),
nullable=False), Column('name', String(20),
index=True), Column('aname', String(20)))
metadata.create_all()
testing.db.execute("""
create index idx1 on party ((id || name))
""")
testing.db.execute("""
create unique index idx2 on party (id) where name = 'test'
""")
testing.db.execute("""
create index idx3 on party using btree
(lower(name::text), lower(aname::text))
""")
def go():
m2 = MetaData(testing.db)
t2 = Table('party', m2, autoload=True)
assert len(t2.indexes) == 2
# Make sure indexes are in the order we expect them in
tmp = [(idx.name, idx) for idx in t2.indexes]
tmp.sort()
r1, r2 = [idx[1] for idx in tmp]
assert r1.name == 'idx2'
assert r1.unique == True
assert r2.unique == False
assert [t2.c.id] == r1.columns
assert [t2.c.name] == r2.columns
testing.assert_warnings(go,
[
'Skipped unsupported reflection of '
'expression-based index idx1',
'Predicate of partial index idx2 ignored during '
'reflection',
'Skipped unsupported reflection of '
'expression-based index idx3'
])
@testing.provide_metadata
def test_index_reflection_modified(self):
"""reflect indexes when a column name has changed - PG 9
does not update the name of the column in the index def.
[ticket:2141]
"""
metadata = self.metadata
t1 = Table('t', metadata,
Column('id', Integer, primary_key=True),
Column('x', Integer)
)
metadata.create_all()
conn = testing.db.connect().execution_options(autocommit=True)
conn.execute("CREATE INDEX idx1 ON t (x)")
conn.execute("ALTER TABLE t RENAME COLUMN x to y")
ind = testing.db.dialect.get_indexes(conn, "t", None)
eq_(ind, [{'unique': False, 'column_names': ['y'], 'name': 'idx1'}])
conn.close()
class CustomTypeReflectionTest(fixtures.TestBase):
class CustomType(object):
def __init__(self, arg1=None, arg2=None):
self.arg1 = arg1
self.arg2 = arg2
ischema_names = None
def setup(self):
ischema_names = postgresql.PGDialect.ischema_names
postgresql.PGDialect.ischema_names = ischema_names.copy()
self.ischema_names = ischema_names
def teardown(self):
postgresql.PGDialect.ischema_names = self.ischema_names
self.ischema_names = None
def _assert_reflected(self, dialect):
for sch, args in [
('my_custom_type', (None, None)),
('my_custom_type()', (None, None)),
('my_custom_type(ARG1)', ('ARG1', None)),
('my_custom_type(ARG1, ARG2)', ('ARG1', 'ARG2')),
]:
column_info = dialect._get_column_info(
'colname', sch, None, False,
{}, {}, 'public')
assert isinstance(column_info['type'], self.CustomType)
eq_(column_info['type'].arg1, args[0])
eq_(column_info['type'].arg2, args[1])
def test_clslevel(self):
postgresql.PGDialect.ischema_names['my_custom_type'] = self.CustomType
dialect = postgresql.PGDialect()
self._assert_reflected(dialect)
def test_instancelevel(self):
dialect = postgresql.PGDialect()
dialect.ischema_names = dialect.ischema_names.copy()
dialect.ischema_names['my_custom_type'] = self.CustomType
self._assert_reflected(dialect)
|
mit
|
[
3,
2803,
26,
2774,
13,
24,
199,
199,
504,
8335,
14,
4776,
14,
305,
13049,
492,
3850,
3131,
702,
63,
3536,
12,
971,
355,
702,
63,
3536,
63,
1188,
12,
365,
3131,
10716,
83,
11310,
6579,
12,
971,
355,
10716,
83,
32521,
4657,
12,
3599,
11044,
18845,
199,
504,
8335,
14,
4776,
492,
28156,
12,
15188,
199,
504,
8335,
492,
5343,
199,
504,
8335,
492,
6957,
12,
4996,
12,
3504,
12,
24905,
12,
1318,
12,
7225,
12,
971,
288,
2624,
12,
10975,
12,
12718,
12,
4263,
12,
19378,
12,
971,
288,
26710,
1197,
8463,
12,
13686,
12,
2008,
3131,
11140,
12,
13123,
2674,
12,
971,
288,
2562,
12,
8785,
63,
2301,
12,
8785,
12,
5398,
635,
12,
9106,
12,
5536,
12,
971,
288,
23704,
2674,
12,
11305,
12,
5363,
748,
12,
1678,
12,
5518,
12,
5499,
12,
3145,
12,
971,
288,
436,
3131,
6148,
12,
2434,
14946,
12,
4703,
12,
6140,
12,
18766,
12,
503,
3131,
4516,
199,
504,
8335,
492,
3178,
199,
504,
8335,
14,
11072,
83,
14,
15437,
492,
1300,
465,
25951,
199,
646,
2050,
199,
199,
533,
14061,
2891,
1486,
774,
8,
8769,
14,
14440,
12,
10716,
83,
11310,
6579,
304,
339,
408,
774,
20175,
14006,
624,
339,
636,
2118,
63,
265,
363,
275,
283,
15437,
7,
339,
768,
3744,
272,
347,
3272,
63,
533,
8,
1886,
304,
267,
406,
275,
5343,
14,
697,
14,
2242,
342,
267,
367,
366,
5030,
315,
971,
288,
283,
8366,
15265,
511,
2261,
17086,
2845,
5962,
6186,
5685,
297,
971,
288,
283,
8366,
15265,
511,
63,
3629,
14,
396,
2261,
17086,
6186,
378,
297,
971,
288,
298,
8366,
11511,
511,
466,
4319,
662,
7125,
661,
396,
18106,
971,
288,
283,
8366,
15265,
4952,
2261,
4319,
511,
466,
1154,
288,
520,
288,
862,
26,
355,
406,
14,
2526,
8,
17102,
9,
288,
871,
3178,
14,
2846,
3735,
547,
465,
325,
26,
355,
340,
440,
283,
14039,
3495,
7,
315,
620,
8,
69,
304,
490,
746,
325,
267,
406,
14,
2526,
360,
8366,
9934,
511,
1224,
334,
4790,
3000,
12,
6385,
283,
490,
283,
396,
2261,
5942,
267,
406,
14,
2526,
360,
8366,
9934,
511,
63,
3629,
14,
396,
1224,
8,
4790,
283,
490,
283,
4115,
12,
6385,
511,
63,
3629,
14,
396,
2261,
12,
7003,
283,
490,
283,
4115,
5942,
267,
406,
14,
2526,
360,
8366,
9934,
8059,
2095,
334,
4790,
3000,
12,
6385,
283,
490,
283,
396,
63,
3629,
14,
396,
2261,
5942,
398,
406,
14,
2526,
360,
8366,
9934,
4952,
63,
396,
334,
344,
3000,
12,
666,
4952,
2261,
5942,
339,
768,
3744,
272,
347,
17558,
63,
533,
8,
1886,
304,
267,
406,
275,
5343,
14,
697,
14,
2242,
342,
267,
406,
14,
2526,
360,
14764,
9934,
511,
1224,
358,
267,
406,
14,
2526,
360,
14764,
9934,
511,
63,
3629,
14,
396,
1224,
358,
267,
406,
14,
2526,
360,
14764,
9934,
8059,
2095,
358,
267,
406,
14,
2526,
360,
14764,
15265,
511,
2261,
358,
267,
406,
14,
2526,
360,
14764,
15265,
511,
63,
3629,
14,
396,
2261,
358,
267,
406,
14,
2526,
480,
14764,
9934,
4952,
63,
396,
531,
267,
406,
14,
2526,
480,
14764,
15265,
4952,
2261,
531,
267,
406,
14,
2526,
480,
14764,
11511,
511,
466,
531,
339,
347,
511,
63,
1224,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
409,
8,
1224,
14,
3406,
14,
1612,
4000,
663,
2941,
4790,
297,
283,
5934,
3815,
288,
298,
15086,
402,
31948,
1817,
9980,
1133,
4472,
1420,
4362,
531,
267,
702,
1228,
8,
1224,
14,
67,
14,
5934,
14,
466,
12,
7225,
9,
339,
347,
511,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
2260,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133,
4472,
1420,
574,
531,
267,
702,
440,
1817,
14,
3406,
14,
5934,
14,
16375,
12,
971,
288,
283,
6964,
31948,
2763,
370,
440,
506,
7854,
3530,
339,
347,
511,
63,
4869,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
4869,
63,
396,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
288,
1817,
14,
67,
14,
576,
14,
466,
14,
19921,
12,
288,
661,
396,
297,
776,
267,
776,
339,
347,
511,
63,
1224,
63,
374,
63,
1121,
2820,
63,
396,
63,
3629,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
12,
1993,
4177,
534,
396,
63,
3629,
358,
267,
3850,
2531,
409,
8,
1224,
14,
3406,
14,
1612,
4000,
663,
2941,
4790,
297,
283,
5934,
297,
288,
283,
25058,
3815,
288,
298,
15086,
402,
31948,
1817,
9980,
1133,
4472,
1420,
4362,
531,
267,
702,
1228,
8,
1224,
14,
67,
14,
25058,
14,
466,
12,
7225,
9,
339,
347,
511,
63,
3629,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
12,
1993,
4177,
534,
396,
63,
3629,
358,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
16,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133,
4472,
1420,
574,
531,
267,
702,
1817,
14,
3406,
14,
5934,
14,
16375,
12,
971,
288,
283,
6964,
31948,
2763,
370,
506,
7854,
3530,
339,
347,
511,
63,
7925,
2095,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
7925,
2095,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
16,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133
] |
[
2803,
26,
2774,
13,
24,
199,
199,
504,
8335,
14,
4776,
14,
305,
13049,
492,
3850,
3131,
702,
63,
3536,
12,
971,
355,
702,
63,
3536,
63,
1188,
12,
365,
3131,
10716,
83,
11310,
6579,
12,
971,
355,
10716,
83,
32521,
4657,
12,
3599,
11044,
18845,
199,
504,
8335,
14,
4776,
492,
28156,
12,
15188,
199,
504,
8335,
492,
5343,
199,
504,
8335,
492,
6957,
12,
4996,
12,
3504,
12,
24905,
12,
1318,
12,
7225,
12,
971,
288,
2624,
12,
10975,
12,
12718,
12,
4263,
12,
19378,
12,
971,
288,
26710,
1197,
8463,
12,
13686,
12,
2008,
3131,
11140,
12,
13123,
2674,
12,
971,
288,
2562,
12,
8785,
63,
2301,
12,
8785,
12,
5398,
635,
12,
9106,
12,
5536,
12,
971,
288,
23704,
2674,
12,
11305,
12,
5363,
748,
12,
1678,
12,
5518,
12,
5499,
12,
3145,
12,
971,
288,
436,
3131,
6148,
12,
2434,
14946,
12,
4703,
12,
6140,
12,
18766,
12,
503,
3131,
4516,
199,
504,
8335,
492,
3178,
199,
504,
8335,
14,
11072,
83,
14,
15437,
492,
1300,
465,
25951,
199,
646,
2050,
199,
199,
533,
14061,
2891,
1486,
774,
8,
8769,
14,
14440,
12,
10716,
83,
11310,
6579,
304,
339,
408,
774,
20175,
14006,
624,
339,
636,
2118,
63,
265,
363,
275,
283,
15437,
7,
339,
768,
3744,
272,
347,
3272,
63,
533,
8,
1886,
304,
267,
406,
275,
5343,
14,
697,
14,
2242,
342,
267,
367,
366,
5030,
315,
971,
288,
283,
8366,
15265,
511,
2261,
17086,
2845,
5962,
6186,
5685,
297,
971,
288,
283,
8366,
15265,
511,
63,
3629,
14,
396,
2261,
17086,
6186,
378,
297,
971,
288,
298,
8366,
11511,
511,
466,
4319,
662,
7125,
661,
396,
18106,
971,
288,
283,
8366,
15265,
4952,
2261,
4319,
511,
466,
1154,
288,
520,
288,
862,
26,
355,
406,
14,
2526,
8,
17102,
9,
288,
871,
3178,
14,
2846,
3735,
547,
465,
325,
26,
355,
340,
440,
283,
14039,
3495,
7,
315,
620,
8,
69,
304,
490,
746,
325,
267,
406,
14,
2526,
360,
8366,
9934,
511,
1224,
334,
4790,
3000,
12,
6385,
283,
490,
283,
396,
2261,
5942,
267,
406,
14,
2526,
360,
8366,
9934,
511,
63,
3629,
14,
396,
1224,
8,
4790,
283,
490,
283,
4115,
12,
6385,
511,
63,
3629,
14,
396,
2261,
12,
7003,
283,
490,
283,
4115,
5942,
267,
406,
14,
2526,
360,
8366,
9934,
8059,
2095,
334,
4790,
3000,
12,
6385,
283,
490,
283,
396,
63,
3629,
14,
396,
2261,
5942,
398,
406,
14,
2526,
360,
8366,
9934,
4952,
63,
396,
334,
344,
3000,
12,
666,
4952,
2261,
5942,
339,
768,
3744,
272,
347,
17558,
63,
533,
8,
1886,
304,
267,
406,
275,
5343,
14,
697,
14,
2242,
342,
267,
406,
14,
2526,
360,
14764,
9934,
511,
1224,
358,
267,
406,
14,
2526,
360,
14764,
9934,
511,
63,
3629,
14,
396,
1224,
358,
267,
406,
14,
2526,
360,
14764,
9934,
8059,
2095,
358,
267,
406,
14,
2526,
360,
14764,
15265,
511,
2261,
358,
267,
406,
14,
2526,
360,
14764,
15265,
511,
63,
3629,
14,
396,
2261,
358,
267,
406,
14,
2526,
480,
14764,
9934,
4952,
63,
396,
531,
267,
406,
14,
2526,
480,
14764,
15265,
4952,
2261,
531,
267,
406,
14,
2526,
480,
14764,
11511,
511,
466,
531,
339,
347,
511,
63,
1224,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
409,
8,
1224,
14,
3406,
14,
1612,
4000,
663,
2941,
4790,
297,
283,
5934,
3815,
288,
298,
15086,
402,
31948,
1817,
9980,
1133,
4472,
1420,
4362,
531,
267,
702,
1228,
8,
1224,
14,
67,
14,
5934,
14,
466,
12,
7225,
9,
339,
347,
511,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
2260,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133,
4472,
1420,
574,
531,
267,
702,
440,
1817,
14,
3406,
14,
5934,
14,
16375,
12,
971,
288,
283,
6964,
31948,
2763,
370,
440,
506,
7854,
3530,
339,
347,
511,
63,
4869,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
4869,
63,
396,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
288,
1817,
14,
67,
14,
576,
14,
466,
14,
19921,
12,
288,
661,
396,
297,
776,
267,
776,
339,
347,
511,
63,
1224,
63,
374,
63,
1121,
2820,
63,
396,
63,
3629,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
12,
1993,
4177,
534,
396,
63,
3629,
358,
267,
3850,
2531,
409,
8,
1224,
14,
3406,
14,
1612,
4000,
663,
2941,
4790,
297,
283,
5934,
297,
288,
283,
25058,
3815,
288,
298,
15086,
402,
31948,
1817,
9980,
1133,
4472,
1420,
4362,
531,
267,
702,
1228,
8,
1224,
14,
67,
14,
25058,
14,
466,
12,
7225,
9,
339,
347,
511,
63,
3629,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
396,
1224,
297,
3341,
12,
2599,
912,
29,
549,
12,
1993,
4177,
534,
396,
63,
3629,
358,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
16,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133,
4472,
1420,
574,
531,
267,
702,
1817,
14,
3406,
14,
5934,
14,
16375,
12,
971,
288,
283,
6964,
31948,
2763,
370,
506,
7854,
3530,
339,
347,
511,
63,
7925,
2095,
63,
2261,
63,
374,
63,
1121,
2820,
8,
277,
304,
267,
3341,
275,
24905,
8,
4776,
14,
697,
9,
267,
1817,
275,
6957,
360,
7925,
2095,
297,
3341,
12,
2599,
912,
29,
549,
9,
267,
3850,
2531,
495,
8,
1224,
14,
3406,
14,
5934,
14,
1000,
63,
885,
14,
1273,
395,
283,
16,
297,
288,
298,
2891,
2820,
849,
574,
9980,
1133,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
peterrenshaw/socsim
|
setup.py
|
1
|
1400
|
#!/usr/bin/env python
# ~*~ encoding: utf-8 ~*~
"""
This file is part of SOCSIM.
SOCSIM 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.
SOCSIM 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 SOCSIM. If not, see <http://www.gnu.org/licenses/>.
"""
import os
from setuptools import setup
from setuptools import find_packages
from socsim import __version__
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(name = "socsim",
version = __version__,
description = 'social media simulation tools',
long_description=read('README'),
license = 'GNU GPL 3.0',
author = "Peter Renshaw",
author_email = "goonmail@netspace.net.au",
url = 'https://github.com/peterrenshaw/socsim',
packages = find_packages(),
keywords = ['message','testing','human','response'],
zip_safe = True)
# vim: ff=unix:ts=4:sw=4:tw=78:noai:expandtab
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
6146,
10,
94,
2644,
26,
2774,
13,
24,
6146,
10,
94,
199,
199,
624,
272,
961,
570,
365,
1777,
402,
3562,
3298,
1469,
14,
339,
3562,
3298,
1469,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
3562,
3298,
1469,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
3562,
3298,
1469,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
646,
747,
199,
504,
9116,
492,
3272,
199,
504,
9116,
492,
2342,
63,
5154,
421,
199,
504,
308,
679,
5206,
492,
636,
1023,
363,
421,
199,
318,
1586,
8,
5252,
304,
272,
372,
1551,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
6748,
4992,
739,
342,
421,
199,
2758,
8,
354,
275,
298,
83,
679,
5206,
401,
489,
1015,
275,
636,
1023,
3108,
489,
1369,
275,
283,
13574,
5898,
17625,
7249,
297,
489,
1846,
63,
1802,
29,
739,
360,
18195,
659,
489,
4190,
275,
283,
17732,
14629,
650,
14,
16,
297,
489,
4132,
275,
298,
8070,
351,
10055,
4835,
87,
401,
489,
4132,
63,
2123,
275,
298,
1939,
265,
1198,
32,
846,
2638,
14,
846,
14,
3844,
401,
489,
1166,
275,
283,
2859,
921,
5031,
14,
957,
15,
321,
351,
27667,
2411,
87,
15,
83,
679,
5206,
297,
489,
6117,
275,
2342,
63,
5154,
1062,
489,
7681,
275,
788,
1188,
1673,
4776,
1673,
14864,
1673,
1310,
995,
489,
3482,
63,
3489,
275,
715,
9,
199,
199,
3,
6695,
26,
16328,
29,
11864,
26,
1086,
29,
20,
26,
3519,
29,
20,
26,
8122,
29,
2277,
26,
889,
5789,
26,
10379,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
6146,
10,
94,
2644,
26,
2774,
13,
24,
6146,
10,
94,
199,
199,
624,
272,
961,
570,
365,
1777,
402,
3562,
3298,
1469,
14,
339,
3562,
3298,
1469,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
3562,
3298,
1469,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
3562,
3298,
1469,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
199,
199,
646,
747,
199,
504,
9116,
492,
3272,
199,
504,
9116,
492,
2342,
63,
5154,
421,
199,
504,
308,
679,
5206,
492,
636,
1023,
363,
421,
199,
318,
1586,
8,
5252,
304,
272,
372,
1551,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
6748,
4992,
739,
342,
421,
199,
2758,
8,
354,
275,
298,
83,
679,
5206,
401,
489,
1015,
275,
636,
1023,
3108,
489,
1369,
275,
283,
13574,
5898,
17625,
7249,
297,
489,
1846,
63,
1802,
29,
739,
360,
18195,
659,
489,
4190,
275,
283,
17732,
14629,
650,
14,
16,
297,
489,
4132,
275,
298,
8070,
351,
10055,
4835,
87,
401,
489,
4132,
63,
2123,
275,
298,
1939,
265,
1198,
32,
846,
2638,
14,
846,
14,
3844,
401,
489,
1166,
275,
283,
2859,
921,
5031,
14,
957,
15,
321,
351,
27667,
2411,
87,
15,
83,
679,
5206,
297,
489,
6117,
275,
2342,
63,
5154,
1062,
489,
7681,
275,
788,
1188,
1673,
4776,
1673,
14864,
1673,
1310,
995,
489,
3482,
63,
3489,
275,
715,
9,
199,
199,
3,
6695,
26,
16328,
29,
11864,
26,
1086,
29,
20,
26,
3519,
29,
20,
26,
8122,
29,
2277,
26,
889,
5789,
26,
10379,
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,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
yashu-seth/BinPy
|
BinPy/analog/source.py
|
5
|
2824
|
from math import *
from BinPy import *
class Source:
"This class represents a base class for the signal source"
def __init__(self, equation, params):
self.params = params
self.equation = equation
def setParam(self, param, value):
if not isinstance(self.params[param], type(value)):
raise Exception("Invalid Value")
self.params[param] = value
self.trigger()
def setParams(self, params):
for i in params:
self.setParam(i, params[i])
def getParams(self):
self.trigger()
return self.params
def setEquation(self, equation):
self.equation = equation
self.trigger()
def evaluate(self):
for i in self.params:
exec("%s=%f" % (i, self.params[i]))
self.val = eval(self.equation)
return self.val
def setoutput(self, param, value):
if not isinstance(value, Connector):
raise Exception("Expecting a Connector Class Object")
self.params[param] = value
class VoltageSource(Source):
def __init__(self, equation, params):
Source.__init__(self, equation, params)
self.params.update({'H': Connector(0), 'L': Connector(0)})
self.trigger()
def trigger(self):
self.params['H'].state = self.evaluate() + self.params['L'].state
class CurrentSource(Source):
def __init__(self, equation, params):
Source.__init__(self, equation, params)
self.params.update({'H': Connector(0), 'L': Connector(0)})
self.trigger()
def trigger(self):
self.params['i'] = self.evaluate()
class SinWaveVoltageSource(VoltageSource):
def __init__(self, amplitude=0, frequency=0, time=0, epoch=0):
equation = 'V*round(sin(radians((w*t)+e)), 2)'
params = {'V': amplitude, 'w': frequency, 't': time, 'e': epoch}
VoltageSource.__init__(self, equation, params)
class CosWaveVoltageSource(VoltageSource):
def __init__(self, amplitude=0, frequency=0, time=0, epoch=0):
equation = 'V*round(cos(radians((w*t)+e)), 2)'
params = {'V': amplitude, 'w': frequency, 't': time, 'e': epoch}
VoltageSource.__init__(self, equation, params)
class SinWaveCurrentSource(CurrentSource):
def __init__(self, amplitude=0, frequency=0, time=0, epoch=0):
equation = 'I*round(sin(radians((w*t)+e)), 2)'
params = {'I': amplitude, 'w': frequency, 't': time, 'e': epoch}
CurrentSource.__init__(self, equation, params)
class CosWaveCurrentSource(CurrentSource):
def __init__(self, amplitude=0, frequency=0, time=0, epoch=0):
equation = 'I*round(cos(radians((w*t)+e)), 2)'
params = {'I': amplitude, 'w': frequency, 't': time, 'e': epoch}
CurrentSource.__init__(self, equation, params)
|
bsd-3-clause
|
[
504,
3473,
492,
627,
199,
504,
32613,
2713,
492,
627,
421,
199,
533,
5800,
26,
339,
298,
2765,
1021,
8469,
282,
1300,
1021,
367,
314,
4673,
1350,
2,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
291,
14,
1162,
275,
1862,
267,
291,
14,
27247,
275,
18649,
339,
347,
663,
4098,
8,
277,
12,
1215,
12,
574,
304,
267,
340,
440,
1228,
8,
277,
14,
1162,
59,
635,
467,
730,
8,
585,
2298,
288,
746,
2186,
480,
3364,
1594,
531,
267,
291,
14,
1162,
59,
635,
61,
275,
574,
267,
291,
14,
7631,
342,
339,
347,
663,
6007,
8,
277,
12,
1862,
304,
267,
367,
284,
315,
1862,
26,
288,
291,
14,
409,
4098,
8,
73,
12,
1862,
59,
73,
566,
339,
347,
664,
6007,
8,
277,
304,
267,
291,
14,
7631,
342,
267,
372,
291,
14,
1162,
339,
347,
663,
27933,
425,
8,
277,
12,
18649,
304,
267,
291,
14,
27247,
275,
18649,
267,
291,
14,
7631,
342,
339,
347,
9352,
8,
277,
304,
267,
367,
284,
315,
291,
14,
1162,
26,
288,
2146,
3647,
83,
2458,
70,
2,
450,
334,
73,
12,
291,
14,
1162,
59,
73,
2459,
267,
291,
14,
637,
275,
3468,
8,
277,
14,
27247,
9,
267,
372,
291,
14,
637,
339,
347,
663,
1199,
8,
277,
12,
1215,
12,
574,
304,
267,
340,
440,
1228,
8,
585,
12,
13482,
2406,
304,
288,
746,
2186,
480,
28864,
282,
13482,
2406,
8089,
6935,
531,
267,
291,
14,
1162,
59,
635,
61,
275,
574,
421,
199,
533,
16171,
15028,
2980,
8,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
5800,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
267,
291,
14,
1162,
14,
873,
3252,
40,
356,
13482,
2406,
8,
16,
395,
283,
44,
356,
13482,
2406,
8,
16,
11466,
267,
291,
14,
7631,
342,
339,
347,
6804,
8,
277,
304,
267,
291,
14,
1162,
459,
40,
2278,
929,
275,
291,
14,
7383,
342,
435,
291,
14,
1162,
459,
44,
2278,
929,
421,
199,
533,
9338,
2980,
8,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
5800,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
267,
291,
14,
1162,
14,
873,
3252,
40,
356,
13482,
2406,
8,
16,
395,
283,
44,
356,
13482,
2406,
8,
16,
11466,
267,
291,
14,
7631,
342,
339,
347,
6804,
8,
277,
304,
267,
291,
14,
1162,
459,
73,
418,
275,
291,
14,
7383,
342,
421,
199,
533,
428,
262,
21393,
16969,
15028,
2980,
8,
16969,
15028,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
54,
10,
2363,
8,
5911,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
54,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
16171,
15028,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
445,
736,
21393,
16969,
15028,
2980,
8,
16969,
15028,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
54,
10,
2363,
8,
5197,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
54,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
16171,
15028,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
428,
262,
21393,
5639,
2980,
8,
5639,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
41,
10,
2363,
8,
5911,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
41,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
9338,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
445,
736,
21393,
5639,
2980,
8,
5639,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
41,
10,
2363,
8,
5197,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
41,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
9338,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
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
] |
[
3473,
492,
627,
199,
504,
32613,
2713,
492,
627,
421,
199,
533,
5800,
26,
339,
298,
2765,
1021,
8469,
282,
1300,
1021,
367,
314,
4673,
1350,
2,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
291,
14,
1162,
275,
1862,
267,
291,
14,
27247,
275,
18649,
339,
347,
663,
4098,
8,
277,
12,
1215,
12,
574,
304,
267,
340,
440,
1228,
8,
277,
14,
1162,
59,
635,
467,
730,
8,
585,
2298,
288,
746,
2186,
480,
3364,
1594,
531,
267,
291,
14,
1162,
59,
635,
61,
275,
574,
267,
291,
14,
7631,
342,
339,
347,
663,
6007,
8,
277,
12,
1862,
304,
267,
367,
284,
315,
1862,
26,
288,
291,
14,
409,
4098,
8,
73,
12,
1862,
59,
73,
566,
339,
347,
664,
6007,
8,
277,
304,
267,
291,
14,
7631,
342,
267,
372,
291,
14,
1162,
339,
347,
663,
27933,
425,
8,
277,
12,
18649,
304,
267,
291,
14,
27247,
275,
18649,
267,
291,
14,
7631,
342,
339,
347,
9352,
8,
277,
304,
267,
367,
284,
315,
291,
14,
1162,
26,
288,
2146,
3647,
83,
2458,
70,
2,
450,
334,
73,
12,
291,
14,
1162,
59,
73,
2459,
267,
291,
14,
637,
275,
3468,
8,
277,
14,
27247,
9,
267,
372,
291,
14,
637,
339,
347,
663,
1199,
8,
277,
12,
1215,
12,
574,
304,
267,
340,
440,
1228,
8,
585,
12,
13482,
2406,
304,
288,
746,
2186,
480,
28864,
282,
13482,
2406,
8089,
6935,
531,
267,
291,
14,
1162,
59,
635,
61,
275,
574,
421,
199,
533,
16171,
15028,
2980,
8,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
5800,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
267,
291,
14,
1162,
14,
873,
3252,
40,
356,
13482,
2406,
8,
16,
395,
283,
44,
356,
13482,
2406,
8,
16,
11466,
267,
291,
14,
7631,
342,
339,
347,
6804,
8,
277,
304,
267,
291,
14,
1162,
459,
40,
2278,
929,
275,
291,
14,
7383,
342,
435,
291,
14,
1162,
459,
44,
2278,
929,
421,
199,
533,
9338,
2980,
8,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
18649,
12,
1862,
304,
267,
5800,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
267,
291,
14,
1162,
14,
873,
3252,
40,
356,
13482,
2406,
8,
16,
395,
283,
44,
356,
13482,
2406,
8,
16,
11466,
267,
291,
14,
7631,
342,
339,
347,
6804,
8,
277,
304,
267,
291,
14,
1162,
459,
73,
418,
275,
291,
14,
7383,
342,
421,
199,
533,
428,
262,
21393,
16969,
15028,
2980,
8,
16969,
15028,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
54,
10,
2363,
8,
5911,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
54,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
16171,
15028,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
445,
736,
21393,
16969,
15028,
2980,
8,
16969,
15028,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
54,
10,
2363,
8,
5197,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
54,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
16171,
15028,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
428,
262,
21393,
5639,
2980,
8,
5639,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
41,
10,
2363,
8,
5911,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
41,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
9338,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
9,
421,
199,
533,
445,
736,
21393,
5639,
2980,
8,
5639,
2980,
304,
339,
347,
636,
826,
721,
277,
12,
30727,
29,
16,
12,
9857,
29,
16,
12,
900,
29,
16,
12,
9463,
29,
16,
304,
398,
18649,
275,
283,
41,
10,
2363,
8,
5197,
8,
22946,
1332,
87,
10,
84,
6393,
69,
1826,
499,
3171,
267,
1862,
275,
791,
41,
356,
30727,
12,
283,
87,
356,
9857,
12,
283,
84,
356,
900,
12,
283,
69,
356,
9463,
93,
267,
9338,
2980,
855,
826,
721,
277,
12,
18649,
12,
1862,
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,
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,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
judaba13/GenrePredictor
|
hdf5_utils.py
|
1
|
28730
|
"""
Thierry Bertin-Mahieux (2010) Columbia University
tb2332@columbia.edu
This code contains a set of routines to create HDF5 files containing
features and metadata of a song.
This is part of the Million Song Dataset project from
LabROSA (Columbia University) and The Echo Nest.
Copyright 2010, Thierry Bertin-Mahieux
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/>.
"""
import os
import sys
import numpy as np
# code relies on pytables, see http://www.pytables.org
import tables
import hdf5_descriptors as DESC
from hdf5_getters import *
# musicbrainz related stuff
try:
from MBrainzDB import query as QUERYMB
except ImportError:
print 'need pg module and MBrainzDB folder of Python source code if you'
print 'want to use musicbrainz related functions, e.g. fill_hdf5_from_musicbrainz'
# description of the different arrays in the song file
ARRAY_DESC_SIMILAR_ARTISTS = 'array of similar artists Echo Nest id'
ARRAY_DESC_ARTIST_TERMS = 'array of terms (Echo Nest tags) for an artist'
ARRAY_DESC_ARTIST_TERMS_FREQ = 'array of term (Echo Nest tags) frequencies for an artist'
ARRAY_DESC_ARTIST_TERMS_WEIGHT = 'array of term (Echo Nest tags) weights for an artist'
ARRAY_DESC_SEGMENTS_START = 'array of start times of segments'
ARRAY_DESC_SEGMENTS_CONFIDENCE = 'array of confidence of segments'
ARRAY_DESC_SEGMENTS_PITCHES = 'array of pitches of segments (chromas)'
ARRAY_DESC_SEGMENTS_TIMBRE = 'array of timbre of segments (MFCC-like)'
ARRAY_DESC_SEGMENTS_LOUDNESS_MAX = 'array of max loudness of segments'
ARRAY_DESC_SEGMENTS_LOUDNESS_MAX_TIME = 'array of max loudness time of segments'
ARRAY_DESC_SEGMENTS_LOUDNESS_START = 'array of loudness of segments at start time'
ARRAY_DESC_SECTIONS_START = 'array of start times of sections'
ARRAY_DESC_SECTIONS_CONFIDENCE = 'array of confidence of sections'
ARRAY_DESC_BEATS_START = 'array of start times of beats'
ARRAY_DESC_BEATS_CONFIDENCE = 'array of confidence of sections'
ARRAY_DESC_BARS_START = 'array of start times of bars'
ARRAY_DESC_BARS_CONFIDENCE = 'array of confidence of bars'
ARRAY_DESC_TATUMS_START = 'array of start times of tatums'
ARRAY_DESC_TATUMS_CONFIDENCE = 'array of confidence of tatums'
ARRAY_DESC_ARTIST_MBTAGS = 'array of tags from MusicBrainz for an artist'
ARRAY_DESC_ARTIST_MBTAGS_COUNT = 'array of tag counts from MusicBrainz for an artist'
def fill_hdf5_from_artist(h5,artist):
"""
Fill an open hdf5 using all content in a artist object
from the Echo Nest python API
There could be overlap with fill_from_song and fill_from_track,
we assume the data is consistent!
"""
# get the metadata table, fill it
metadata = h5.root.metadata.songs
metadata.cols.artist_id[0] = artist.id
idsplitter = lambda x,y: x.split(':')[2] if x else y
metadata.cols.artist_mbid[0] = idsplitter(artist.get_foreign_id(idspace='musicbrainz'),'')
metadata.cols.artist_playmeid[0] = int(idsplitter(artist.get_foreign_id(idspace='playme'),-1))
metadata.cols.artist_7digitalid[0] = int(idsplitter(artist.get_foreign_id(idspace='7digital'),-1))
# fill the metadata arrays
group = h5.root.metadata
metadata.cols.idx_similar_artists[0] = 0
group.similar_artists.append( np.array(map(lambda x : x.id,artist.get_similar(results=100)),dtype='string') )
metadata.cols.idx_artist_terms[0] = 0
group.artist_terms.append( np.array(map(lambda x : x.name,artist.get_terms()),dtype='string') )
group.artist_terms_freq.append( np.array(map(lambda x : x.frequency,artist.get_terms()),dtype='float64') )
group.artist_terms_weight.append( np.array(map(lambda x : x.weight,artist.get_terms()),dtype='float64') )
# done, flush
metadata.flush()
def fill_hdf5_from_song(h5,song):
"""
Fill an open hdf5 using all the content in a song object
from the Echo Nest python API.
Usually, fill_hdf5_from_track() will have been called first.
"""
# get the metadata table, fill it
metadata = h5.root.metadata.songs
metadata.cols.artist_familiarity[0] = song.get_artist_familiarity()
metadata.cols.artist_hotttnesss[0] = song.get_artist_hotttnesss()
metadata.cols.artist_id[0] = song.artist_id
metadata.cols.artist_latitude[0] = song.get_artist_location().latitude
metadata.cols.artist_location[0] = song.get_artist_location().location.encode('utf-8') if song.get_artist_location().location else ''
metadata.cols.artist_longitude[0] = song.get_artist_location().longitude
metadata.cols.artist_name[0] = song.artist_name.encode('utf-8') if song.artist_name else ''
metadata.cols.song_id[0] = song.id
metadata.cols.song_hotttnesss[0] = song.get_song_hotttnesss()
metadata.cols.title[0] = song.title.encode('utf-8') if song.title else ''
metadata.flush()
# get the analysis table
analysis = h5.root.analysis.songs
analysis.danceability = song.get_audio_summary().danceability
analysis.energy = song.get_audio_summary().energy
analysis.flush()
def fill_hdf5_from_track(h5,track):
"""
Fill an open hdf5 using all the content in a track object
from the Echo Nest python API
"""
# get the metadata table, fill it
metadata = h5.root.metadata.songs
#metadata.cols.analyzer_version[0] = track.analyzer_version
metadata.cols.artist_name[0] = getattr(track, 'artist', u'').encode('utf-8')
metadata.cols.release[0] = getattr(track, 'release', u'').encode('utf-8')
metadata.cols.title[0] = getattr(track, 'title', u'').encode('utf-8')
idsplitter_7digital = lambda x: int(x.split(':')[2]) if x and x.split(':')[0]=='7digital' else -1
metadata.cols.release_7digitalid[0] = idsplitter_7digital(track.foreign_release_id)
metadata.cols.track_7digitalid[0] = idsplitter_7digital(track.foreign_id)
metadata.flush()
# get the analysis table, fill it
analysis = h5.root.analysis.songs
analysis.cols.analysis_sample_rate[0] = track.analysis_sample_rate
analysis.cols.audio_md5[0] = track.audio_md5
analysis.cols.duration[0] = track.duration
analysis.cols.end_of_fade_in[0] = track.end_of_fade_in
analysis.cols.key[0] = track.key
analysis.cols.key_confidence[0] = track.key_confidence
analysis.cols.loudness[0] = track.loudness
analysis.cols.mode[0] = track.mode
analysis.cols.mode_confidence[0] = track.mode_confidence
analysis.cols.start_of_fade_out[0] = track.start_of_fade_out
analysis.cols.tempo[0] = track.tempo
analysis.cols.time_signature[0] = track.time_signature
analysis.cols.time_signature_confidence[0] = track.time_signature_confidence
analysis.cols.track_id[0] = track.id
analysis.flush()
group = h5.root.analysis
# analysis arrays (segments)
analysis.cols.idx_segments_start[0] = 0
group.segments_start.append( np.array(map(lambda x : x['start'],track.segments),dtype='float64') )
analysis.cols.idx_segments_confidence[0] = 0
group.segments_confidence.append( np.array(map(lambda x : x['confidence'],track.segments),dtype='float64') )
analysis.cols.idx_segments_pitches[0] = 0
group.segments_pitches.append( np.array(map(lambda x : x['pitches'],track.segments),dtype='float64') )
analysis.cols.idx_segments_timbre[0] = 0
group.segments_timbre.append( np.array(map(lambda x : x['timbre'],track.segments),dtype='float64') )
analysis.cols.idx_segments_loudness_max[0] = 0
group.segments_loudness_max.append( np.array(map(lambda x : x['loudness_max'],track.segments),dtype='float64') )
analysis.cols.idx_segments_loudness_max_time[0] = 0
group.segments_loudness_max_time.append( np.array(map(lambda x : x['loudness_max_time'],track.segments),dtype='float64') )
analysis.cols.idx_segments_loudness_start[0] = 0
group.segments_loudness_start.append( np.array(map(lambda x : x['loudness_start'],track.segments),dtype='float64') )
# analysis arrays (sections)
analysis.cols.idx_sections_start[0] = 0
group.sections_start.append( np.array(map(lambda x : x['start'],track.sections),dtype='float64') )
analysis.cols.idx_sections_confidence[0] = 0
group.sections_confidence.append( np.array(map(lambda x : x['confidence'],track.sections),dtype='float64') )
# analysis arrays (beats
analysis.cols.idx_beats_start[0] = 0
group.beats_start.append( np.array(map(lambda x : x['start'],track.beats),dtype='float64') )
analysis.cols.idx_beats_confidence[0] = 0
group.beats_confidence.append( np.array(map(lambda x : x['confidence'],track.beats),dtype='float64') )
# analysis arrays (bars)
analysis.cols.idx_bars_start[0] = 0
group.bars_start.append( np.array(map(lambda x : x['start'],track.bars),dtype='float64') )
analysis.cols.idx_bars_confidence[0] = 0
group.bars_confidence.append( np.array(map(lambda x : x['confidence'],track.bars),dtype='float64') )
# analysis arrays (tatums)
analysis.cols.idx_tatums_start[0] = 0
group.tatums_start.append( np.array(map(lambda x : x['start'],track.tatums),dtype='float64') )
analysis.cols.idx_tatums_confidence[0] = 0
group.tatums_confidence.append( np.array(map(lambda x : x['confidence'],track.tatums),dtype='float64') )
analysis.flush()
# DONE
def fill_hdf5_from_musicbrainz(h5,connect):
"""
Fill an open hdf5 using the musicbrainz server and data.
We assume this code is run after fill_hdf5_from_artist/song
because we need artist_mbid, artist_name, release and title
INPUT
h5 - open song file (append mode)
connect - open pg connection to musicbrainz_db
"""
# get info from h5 song file
ambid = h5.root.metadata.songs.cols.artist_mbid[0]
artist_name = h5.root.metadata.songs.cols.artist_name[0]
release = h5.root.metadata.songs.cols.release[0]
title = h5.root.metadata.songs.cols.title[0]
# get the musicbrainz table, fill it
musicbrainz = h5.root.musicbrainz.songs
musicbrainz.cols.year[0] = QUERYMB.find_year_safemode(connect,ambid,title,release,artist_name)
# fill the musicbrainz arrays
group = h5.root.musicbrainz
musicbrainz.cols.idx_artist_mbtags[0] = 0
tags,tagcount = QUERYMB.get_artist_tags(connect, ambid, maxtags=20)
group.artist_mbtags.append( np.array(tags,dtype='string') )
group.artist_mbtags_count.append( np.array(tagcount,dtype='float64') )
# done, flush
musicbrainz.flush()
def fill_hdf5_aggregate_file(h5,h5_filenames,summaryfile=False):
"""
Fill an open hdf5 aggregate file using all the content from all the HDF5 files
listed as filenames. These HDF5 files are supposed to be filled already.
Usefull to create one big HDF5 file from many, thus improving IO speed.
For most of the info, we simply use one row per song.
For the arrays (e.g. segment_start) we need the indecies (e.g. idx_segment_start)
to know which part of the array belongs to one particular song.
If summaryfile=True, we skip arrays (indices all 0)
"""
# counter
counter = 0
# iterate over filenames
for h5idx,h5filename in enumerate(h5_filenames):
# open h5 file
h5tocopy = open_h5_file_read(h5filename)
# get number of songs in new file
nSongs = get_num_songs(h5tocopy)
# iterate over songs in one HDF5 (1 if regular file, more if aggregate file)
for songidx in xrange(nSongs):
# METADATA
row = h5.root.metadata.songs.row
row["artist_familiarity"] = get_artist_familiarity(h5tocopy,songidx)
row["artist_hotttnesss"] = get_artist_hotttnesss(h5tocopy,songidx)
row["artist_id"] = get_artist_id(h5tocopy,songidx)
row["artist_mbid"] = get_artist_mbid(h5tocopy,songidx)
row["artist_playmeid"] = get_artist_playmeid(h5tocopy,songidx)
row["artist_7digitalid"] = get_artist_7digitalid(h5tocopy,songidx)
row["artist_latitude"] = get_artist_latitude(h5tocopy,songidx)
row["artist_location"] = get_artist_location(h5tocopy,songidx)
row["artist_longitude"] = get_artist_longitude(h5tocopy,songidx)
row["artist_name"] = get_artist_name(h5tocopy,songidx)
row["release"] = get_release(h5tocopy,songidx)
row["release_7digitalid"] = get_release_7digitalid(h5tocopy,songidx)
row["song_id"] = get_song_id(h5tocopy,songidx)
row["song_hotttnesss"] = get_song_hotttnesss(h5tocopy,songidx)
row["title"] = get_title(h5tocopy,songidx)
row["track_7digitalid"] = get_track_7digitalid(h5tocopy,songidx)
# INDICES
if not summaryfile:
if counter == 0 : # we're first row
row["idx_similar_artists"] = 0
row["idx_artist_terms"] = 0
else:
row["idx_similar_artists"] = h5.root.metadata.similar_artists.shape[0]
row["idx_artist_terms"] = h5.root.metadata.artist_terms.shape[0]
row.append()
h5.root.metadata.songs.flush()
# ARRAYS
if not summaryfile:
h5.root.metadata.similar_artists.append( get_similar_artists(h5tocopy,songidx) )
h5.root.metadata.artist_terms.append( get_artist_terms(h5tocopy,songidx) )
h5.root.metadata.artist_terms_freq.append( get_artist_terms_freq(h5tocopy,songidx) )
h5.root.metadata.artist_terms_weight.append( get_artist_terms_weight(h5tocopy,songidx) )
# ANALYSIS
row = h5.root.analysis.songs.row
row["analysis_sample_rate"] = get_analysis_sample_rate(h5tocopy,songidx)
row["audio_md5"] = get_audio_md5(h5tocopy,songidx)
row["danceability"] = get_danceability(h5tocopy,songidx)
row["duration"] = get_duration(h5tocopy,songidx)
row["end_of_fade_in"] = get_end_of_fade_in(h5tocopy,songidx)
row["energy"] = get_energy(h5tocopy,songidx)
row["key"] = get_key(h5tocopy,songidx)
row["key_confidence"] = get_key_confidence(h5tocopy,songidx)
row["loudness"] = get_loudness(h5tocopy,songidx)
row["mode"] = get_mode(h5tocopy,songidx)
row["mode_confidence"] = get_mode_confidence(h5tocopy,songidx)
row["start_of_fade_out"] = get_start_of_fade_out(h5tocopy,songidx)
row["tempo"] = get_tempo(h5tocopy,songidx)
row["time_signature"] = get_time_signature(h5tocopy,songidx)
row["time_signature_confidence"] = get_time_signature_confidence(h5tocopy,songidx)
row["track_id"] = get_track_id(h5tocopy,songidx)
# INDICES
if not summaryfile:
if counter == 0 : # we're first row
row["idx_segments_start"] = 0
row["idx_segments_confidence"] = 0
row["idx_segments_pitches"] = 0
row["idx_segments_timbre"] = 0
row["idx_segments_loudness_max"] = 0
row["idx_segments_loudness_max_time"] = 0
row["idx_segments_loudness_start"] = 0
row["idx_sections_start"] = 0
row["idx_sections_confidence"] = 0
row["idx_beats_start"] = 0
row["idx_beats_confidence"] = 0
row["idx_bars_start"] = 0
row["idx_bars_confidence"] = 0
row["idx_tatums_start"] = 0
row["idx_tatums_confidence"] = 0
else : # check the current shape of the arrays
row["idx_segments_start"] = h5.root.analysis.segments_start.shape[0]
row["idx_segments_confidence"] = h5.root.analysis.segments_confidence.shape[0]
row["idx_segments_pitches"] = h5.root.analysis.segments_pitches.shape[0]
row["idx_segments_timbre"] = h5.root.analysis.segments_timbre.shape[0]
row["idx_segments_loudness_max"] = h5.root.analysis.segments_loudness_max.shape[0]
row["idx_segments_loudness_max_time"] = h5.root.analysis.segments_loudness_max_time.shape[0]
row["idx_segments_loudness_start"] = h5.root.analysis.segments_loudness_start.shape[0]
row["idx_sections_start"] = h5.root.analysis.sections_start.shape[0]
row["idx_sections_confidence"] = h5.root.analysis.sections_confidence.shape[0]
row["idx_beats_start"] = h5.root.analysis.beats_start.shape[0]
row["idx_beats_confidence"] = h5.root.analysis.beats_confidence.shape[0]
row["idx_bars_start"] = h5.root.analysis.bars_start.shape[0]
row["idx_bars_confidence"] = h5.root.analysis.bars_confidence.shape[0]
row["idx_tatums_start"] = h5.root.analysis.tatums_start.shape[0]
row["idx_tatums_confidence"] = h5.root.analysis.tatums_confidence.shape[0]
row.append()
h5.root.analysis.songs.flush()
# ARRAYS
if not summaryfile:
h5.root.analysis.segments_start.append( get_segments_start(h5tocopy,songidx) )
h5.root.analysis.segments_confidence.append( get_segments_confidence(h5tocopy,songidx) )
h5.root.analysis.segments_pitches.append( get_segments_pitches(h5tocopy,songidx) )
h5.root.analysis.segments_timbre.append( get_segments_timbre(h5tocopy,songidx) )
h5.root.analysis.segments_loudness_max.append( get_segments_loudness_max(h5tocopy,songidx) )
h5.root.analysis.segments_loudness_max_time.append( get_segments_loudness_max_time(h5tocopy,songidx) )
h5.root.analysis.segments_loudness_start.append( get_segments_loudness_start(h5tocopy,songidx) )
h5.root.analysis.sections_start.append( get_sections_start(h5tocopy,songidx) )
h5.root.analysis.sections_confidence.append( get_sections_confidence(h5tocopy,songidx) )
h5.root.analysis.beats_start.append( get_beats_start(h5tocopy,songidx) )
h5.root.analysis.beats_confidence.append( get_beats_confidence(h5tocopy,songidx) )
h5.root.analysis.bars_start.append( get_bars_start(h5tocopy,songidx) )
h5.root.analysis.bars_confidence.append( get_bars_confidence(h5tocopy,songidx) )
h5.root.analysis.tatums_start.append( get_tatums_start(h5tocopy,songidx) )
h5.root.analysis.tatums_confidence.append( get_tatums_confidence(h5tocopy,songidx) )
# MUSICBRAINZ
row = h5.root.musicbrainz.songs.row
row["year"] = get_year(h5tocopy,songidx)
# INDICES
if not summaryfile:
if counter == 0 : # we're first row
row["idx_artist_mbtags"] = 0
else:
row["idx_artist_mbtags"] = h5.root.musicbrainz.artist_mbtags.shape[0]
row.append()
h5.root.musicbrainz.songs.flush()
# ARRAYS
if not summaryfile:
h5.root.musicbrainz.artist_mbtags.append( get_artist_mbtags(h5tocopy,songidx) )
h5.root.musicbrainz.artist_mbtags_count.append( get_artist_mbtags_count(h5tocopy,songidx) )
# counter
counter += 1
# close h5 file
h5tocopy.close()
def create_song_file(h5filename,title='H5 Song File',force=False,complevel=1):
"""
Create a new HDF5 file for a new song.
If force=False, refuse to overwrite an existing file
Raise a ValueError if it's the case.
Other optional param is the H5 file.
Setups the groups, each containing a table 'songs' with one row:
- metadata
- analysis
DETAIL
- we set the compression level to 1 by default, it uses the ZLIB library
to disable compression, set it to 0
"""
# check if file exists
if not force:
if os.path.exists(h5filename):
raise ValueError('file exists, can not create HDF5 song file')
# create the H5 file
h5 = tables.openFile(h5filename, mode='w', title='H5 Song File')
# set filter level
h5.filters = tables.Filters(complevel=complevel,complib='zlib')
# setup the groups and tables
# group metadata
group = h5.createGroup("/",'metadata','metadata about the song')
table = h5.createTable(group,'songs',DESC.SongMetaData,'table of metadata for one song')
r = table.row
r.append() # filled with default values 0 or '' (depending on type)
table.flush()
# group analysis
group = h5.createGroup("/",'analysis','Echo Nest analysis of the song')
table = h5.createTable(group,'songs',DESC.SongAnalysis,'table of Echo Nest analysis for one song')
r = table.row
r.append() # filled with default values 0 or '' (depending on type)
table.flush()
# group musicbrainz
group = h5.createGroup("/",'musicbrainz','data about the song coming from MusicBrainz')
table = h5.createTable(group,'songs',DESC.SongMusicBrainz,'table of data coming from MusicBrainz')
r = table.row
r.append() # filled with default values 0 or '' (depending on type)
table.flush()
# create arrays
create_all_arrays(h5,expectedrows=3)
# close it, done
h5.close()
def create_aggregate_file(h5filename,title='H5 Aggregate File',force=False,expectedrows=1000,complevel=1,
summaryfile=False):
"""
Create a new HDF5 file for all songs.
It will contains everything that are in regular song files.
Tables created empty.
If force=False, refuse to overwrite an existing file
Raise a ValueError if it's the case.
If summaryfile=True, creates a sumary file, i.e. no arrays
Other optional param is the H5 file.
DETAILS
- if you create a very large file, try to approximate correctly
the number of data points (songs), it speeds things up with arrays (by
setting the chunking correctly).
- we set the compression level to 1 by default, it uses the ZLIB library
to disable compression, set it to 0
Setups the groups, each containing a table 'songs' with one row:
- metadata
- analysis
"""
# check if file exists
if not force:
if os.path.exists(h5filename):
raise ValueError('file exists, can not create HDF5 song file')
# summary file? change title
if summaryfile:
title = 'H5 Summary File'
# create the H5 file
h5 = tables.openFile(h5filename, mode='w', title='H5 Song File')
# set filter level
h5.filters = tables.Filters(complevel=complevel,complib='zlib')
# setup the groups and tables
# group metadata
group = h5.createGroup("/",'metadata','metadata about the song')
table = h5.createTable(group,'songs',DESC.SongMetaData,'table of metadata for one song',
expectedrows=expectedrows)
# group analysis
group = h5.createGroup("/",'analysis','Echo Nest analysis of the song')
table = h5.createTable(group,'songs',DESC.SongAnalysis,'table of Echo Nest analysis for one song',
expectedrows=expectedrows)
# group musicbrainz
group = h5.createGroup("/",'musicbrainz','data about the song coming from MusicBrainz')
table = h5.createTable(group,'songs',DESC.SongMusicBrainz,'table of data coming from MusicBrainz',
expectedrows=expectedrows)
# create arrays
if not summaryfile:
create_all_arrays(h5,expectedrows=expectedrows)
# close it, done
h5.close()
def create_all_arrays(h5,expectedrows=1000):
"""
Utility functions used by both create_song_file and create_aggregate_files,
creates all the EArrays (empty).
INPUT
h5 - hdf5 file, open with write or append permissions
metadata and analysis groups already exist!
"""
# group metadata arrays
group = h5.root.metadata
h5.createEArray(where=group,name='similar_artists',atom=tables.StringAtom(20,shape=()),shape=(0,),title=ARRAY_DESC_SIMILAR_ARTISTS)
h5.createEArray(group,'artist_terms',tables.StringAtom(256,shape=()),(0,),ARRAY_DESC_ARTIST_TERMS,
expectedrows=expectedrows*40)
h5.createEArray(group,'artist_terms_freq',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_ARTIST_TERMS_FREQ,
expectedrows=expectedrows*40)
h5.createEArray(group,'artist_terms_weight',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_ARTIST_TERMS_WEIGHT,
expectedrows=expectedrows*40)
# group analysis arrays
group = h5.root.analysis
h5.createEArray(where=group,name='segments_start',atom=tables.Float64Atom(shape=()),shape=(0,),title=ARRAY_DESC_SEGMENTS_START)
h5.createEArray(group,'segments_confidence',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SEGMENTS_CONFIDENCE,
expectedrows=expectedrows*300)
h5.createEArray(group,'segments_pitches',tables.Float64Atom(shape=()),(0,12),ARRAY_DESC_SEGMENTS_PITCHES,
expectedrows=expectedrows*300)
h5.createEArray(group,'segments_timbre',tables.Float64Atom(shape=()),(0,12),ARRAY_DESC_SEGMENTS_TIMBRE,
expectedrows=expectedrows*300)
h5.createEArray(group,'segments_loudness_max',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SEGMENTS_LOUDNESS_MAX,
expectedrows=expectedrows*300)
h5.createEArray(group,'segments_loudness_max_time',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SEGMENTS_LOUDNESS_MAX_TIME,
expectedrows=expectedrows*300)
h5.createEArray(group,'segments_loudness_start',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SEGMENTS_LOUDNESS_START,
expectedrows=expectedrows*300)
h5.createEArray(group,'sections_start',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SECTIONS_START,
expectedrows=expectedrows*300)
h5.createEArray(group,'sections_confidence',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_SECTIONS_CONFIDENCE,
expectedrows=expectedrows*300)
h5.createEArray(group,'beats_start',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_BEATS_START,
expectedrows=expectedrows*300)
h5.createEArray(group,'beats_confidence',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_BEATS_CONFIDENCE,
expectedrows=expectedrows*300)
h5.createEArray(group,'bars_start',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_BARS_START,
expectedrows=expectedrows*300)
h5.createEArray(group,'bars_confidence',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_BARS_CONFIDENCE,
expectedrows=expectedrows*300)
h5.createEArray(group,'tatums_start',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_TATUMS_START,
expectedrows=expectedrows*300)
h5.createEArray(group,'tatums_confidence',tables.Float64Atom(shape=()),(0,),ARRAY_DESC_TATUMS_CONFIDENCE,
expectedrows=expectedrows*300)
# group musicbrainz arrays
group = h5.root.musicbrainz
h5.createEArray(where=group,name='artist_mbtags',atom=tables.StringAtom(256,shape=()),shape=(0,),title=ARRAY_DESC_ARTIST_MBTAGS,
expectedrows=expectedrows*5)
h5.createEArray(group,'artist_mbtags_count',tables.IntAtom(shape=()),(0,),ARRAY_DESC_ARTIST_MBTAGS_COUNT,
expectedrows=expectedrows*5)
def open_h5_file_read(h5filename):
"""
Open an existing H5 in read mode.
"""
return tables.openFile(h5filename, mode='r')
def open_h5_file_append(h5filename):
"""
Open an existing H5 in append mode.
"""
return tables.openFile(h5filename, mode='a')
################################################ MAIN #####################################
def die_with_usage():
""" HELP MENU """
print 'hdf5_utils.py'
print 'by T. Bertin-Mahieux (2010) Columbia University'
print ''
print 'should be used as a library, contains functions to create'
print 'HDF5 files for the Million Song Dataset project'
sys.exit(0)
if __name__ == '__main__':
# help menu
die_with_usage()
|
apache-2.0
|
[
624,
199,
2719,
4446,
651,
23207,
1346,
13,
45,
11326,
1873,
2521,
334,
6542,
9,
3626,
4295,
4674,
15904,
199,
5842,
1789,
708,
32,
761,
4295,
4674,
14,
8654,
199,
2765,
1233,
3509,
282,
663,
402,
14975,
370,
1218,
24521,
21,
1584,
3035,
199,
3179,
436,
3341,
402,
282,
20178,
14,
199,
2765,
365,
1777,
402,
314,
603,
8148,
265,
29405,
20284,
2199,
687,
199,
22511,
1092,
4251,
334,
2001,
4295,
4674,
15904,
9,
436,
710,
24980,
653,
597,
14,
199,
7384,
7129,
12,
3868,
4446,
651,
23207,
1346,
13,
45,
11326,
1873,
2521,
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,
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,
221,
1666,
314,
199,
17732,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
421,
199,
646,
747,
199,
646,
984,
199,
646,
2680,
465,
980,
199,
3,
1233,
25749,
641,
1134,
5987,
12,
1937,
1455,
921,
1544,
14,
647,
5987,
14,
1308,
199,
646,
6716,
199,
646,
394,
1587,
21,
63,
17752,
465,
23915,
199,
504,
394,
1587,
21,
63,
362,
878,
492,
627,
199,
3,
8504,
338,
2894,
6322,
90,
4048,
8292,
199,
893,
26,
272,
687,
19487,
6322,
90,
2846,
492,
1827,
465,
7813,
9418,
4567,
199,
2590,
3545,
26,
272,
870,
283,
9321,
10275,
859,
436,
19487,
6322,
90,
2846,
4922,
402,
2018,
1350,
1233,
340,
1265,
7,
272,
870,
283,
7051,
370,
675,
8504,
338,
2894,
6322,
90,
4048,
3423,
12,
325,
14,
71,
14,
5554,
63,
19912,
21,
63,
504,
63,
6553,
338,
2894,
6322,
90,
7,
421,
199,
3,
1369,
402,
314,
3365,
6572,
315,
314,
20178,
570,
199,
12322,
63,
15119,
63,
16590,
1193,
689,
63,
2294,
6225,
51,
275,
283,
1144,
402,
8545,
16459,
83,
24980,
653,
597,
1305,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
275,
283,
1144,
402,
2895,
334,
18690,
653,
597,
3762,
9,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
63,
38,
14583,
275,
283,
1144,
402,
6707,
334,
18690,
653,
597,
3762,
9,
22411,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
63,
25100,
275,
283,
1144,
402,
6707,
334,
18690,
653,
597,
3762,
9,
4931,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
48,
15894,
654,
275,
283,
1144,
402,
20031,
397,
402,
11998,
334,
23473,
305,
3171,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
11342,
9194,
275,
283,
1144,
402,
3367,
887,
264,
402,
11998,
334,
13463,
2571,
13,
2930,
3171,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
4283,
275,
283,
1144,
402,
1390,
560,
1181,
4171,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
4283,
63,
4961,
275,
283,
1144,
402,
1390,
560,
1181,
4171,
900,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
7363,
275,
283,
1144,
402,
560,
1181,
4171,
402,
11998,
737,
1343,
900,
7,
199,
12322,
63,
15119,
63,
899,
19560,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
10189,
7,
199,
12322,
63,
15119,
63,
899,
19560,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
10189,
7,
199,
12322,
63,
15119,
63,
6773,
619,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
506,
1956,
7,
199,
12322,
63,
15119,
63,
6773,
619,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
10189,
7,
199,
12322,
63,
15119,
63,
13895,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
29130,
7,
199,
12322,
63,
15119,
63,
13895,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
29130,
7,
199,
12322,
63,
15119,
63,
52,
619,
2639,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
307,
5729,
83,
7,
199,
12322,
63,
15119,
63,
52,
619,
2639,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
307,
5729,
83,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
4567,
17626,
275,
283,
1144,
402,
3762,
687,
28919,
9916,
34,
6322,
90,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
4567,
17626,
63,
8760,
275,
283,
1144,
402,
1947,
8242,
687,
28919,
9916,
34,
6322,
90,
367,
376,
16459,
7,
421,
199,
318,
5554,
63,
19912,
21,
63,
504,
63,
11215,
8,
72,
21,
12,
11215,
304,
272,
408,
272,
24797,
376,
1551,
394,
1587,
21,
1808,
1006,
1564,
315,
282,
16459,
909,
272,
687,
314,
24980,
653,
597,
2366,
3261,
272,
6006,
4293,
506,
15145,
543,
5554,
63,
504,
63,
19351,
436,
5554,
63,
504,
63,
3885,
12,
272,
781,
5534,
314,
666,
365,
12137,
1,
272,
408,
272,
327,
664,
314,
3341,
1817,
12,
5554,
652,
272,
3341,
275,
394,
21,
14,
1231,
14,
2343,
14,
834,
458,
272,
3341,
14,
4574,
14,
11215,
63,
344,
59,
16,
61,
275,
16459,
14,
344,
272,
1305,
25234,
275,
2400,
671,
12,
89,
26,
671,
14,
1294,
24050,
18,
61,
340,
671,
587,
612,
272,
3341,
14,
4574,
14,
11215,
63,
887,
344,
59,
16,
61,
275,
1305,
25234,
8,
11215,
14,
362,
63,
6846,
63,
344,
8,
1580,
1142,
534,
6553,
338,
2894,
6322,
90,
659,
17483,
272,
3341,
14,
4574,
14,
11215,
63,
2802,
278,
344,
59,
16,
61,
275
] |
[
199,
2719,
4446,
651,
23207,
1346,
13,
45,
11326,
1873,
2521,
334,
6542,
9,
3626,
4295,
4674,
15904,
199,
5842,
1789,
708,
32,
761,
4295,
4674,
14,
8654,
199,
2765,
1233,
3509,
282,
663,
402,
14975,
370,
1218,
24521,
21,
1584,
3035,
199,
3179,
436,
3341,
402,
282,
20178,
14,
199,
2765,
365,
1777,
402,
314,
603,
8148,
265,
29405,
20284,
2199,
687,
199,
22511,
1092,
4251,
334,
2001,
4295,
4674,
15904,
9,
436,
710,
24980,
653,
597,
14,
199,
7384,
7129,
12,
3868,
4446,
651,
23207,
1346,
13,
45,
11326,
1873,
2521,
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,
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,
221,
1666,
314,
199,
17732,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
5556,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
21632,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
624,
421,
199,
646,
747,
199,
646,
984,
199,
646,
2680,
465,
980,
199,
3,
1233,
25749,
641,
1134,
5987,
12,
1937,
1455,
921,
1544,
14,
647,
5987,
14,
1308,
199,
646,
6716,
199,
646,
394,
1587,
21,
63,
17752,
465,
23915,
199,
504,
394,
1587,
21,
63,
362,
878,
492,
627,
199,
3,
8504,
338,
2894,
6322,
90,
4048,
8292,
199,
893,
26,
272,
687,
19487,
6322,
90,
2846,
492,
1827,
465,
7813,
9418,
4567,
199,
2590,
3545,
26,
272,
870,
283,
9321,
10275,
859,
436,
19487,
6322,
90,
2846,
4922,
402,
2018,
1350,
1233,
340,
1265,
7,
272,
870,
283,
7051,
370,
675,
8504,
338,
2894,
6322,
90,
4048,
3423,
12,
325,
14,
71,
14,
5554,
63,
19912,
21,
63,
504,
63,
6553,
338,
2894,
6322,
90,
7,
421,
199,
3,
1369,
402,
314,
3365,
6572,
315,
314,
20178,
570,
199,
12322,
63,
15119,
63,
16590,
1193,
689,
63,
2294,
6225,
51,
275,
283,
1144,
402,
8545,
16459,
83,
24980,
653,
597,
1305,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
275,
283,
1144,
402,
2895,
334,
18690,
653,
597,
3762,
9,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
63,
38,
14583,
275,
283,
1144,
402,
6707,
334,
18690,
653,
597,
3762,
9,
22411,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
1157,
3053,
63,
25100,
275,
283,
1144,
402,
6707,
334,
18690,
653,
597,
3762,
9,
4931,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
48,
15894,
654,
275,
283,
1144,
402,
20031,
397,
402,
11998,
334,
23473,
305,
3171,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
11342,
9194,
275,
283,
1144,
402,
3367,
887,
264,
402,
11998,
334,
13463,
2571,
13,
2930,
3171,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
4283,
275,
283,
1144,
402,
1390,
560,
1181,
4171,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
4283,
63,
4961,
275,
283,
1144,
402,
1390,
560,
1181,
4171,
900,
402,
11998,
7,
199,
12322,
63,
15119,
63,
21981,
20967,
63,
1484,
3383,
3025,
63,
7363,
275,
283,
1144,
402,
560,
1181,
4171,
402,
11998,
737,
1343,
900,
7,
199,
12322,
63,
15119,
63,
899,
19560,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
10189,
7,
199,
12322,
63,
15119,
63,
899,
19560,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
10189,
7,
199,
12322,
63,
15119,
63,
6773,
619,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
506,
1956,
7,
199,
12322,
63,
15119,
63,
6773,
619,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
10189,
7,
199,
12322,
63,
15119,
63,
13895,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
29130,
7,
199,
12322,
63,
15119,
63,
13895,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
29130,
7,
199,
12322,
63,
15119,
63,
52,
619,
2639,
51,
63,
7363,
275,
283,
1144,
402,
1343,
5431,
402,
307,
5729,
83,
7,
199,
12322,
63,
15119,
63,
52,
619,
2639,
51,
63,
3103,
998,
6013,
275,
283,
1144,
402,
15197,
402,
307,
5729,
83,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
4567,
17626,
275,
283,
1144,
402,
3762,
687,
28919,
9916,
34,
6322,
90,
367,
376,
16459,
7,
199,
12322,
63,
15119,
63,
2294,
6225,
63,
4567,
17626,
63,
8760,
275,
283,
1144,
402,
1947,
8242,
687,
28919,
9916,
34,
6322,
90,
367,
376,
16459,
7,
421,
199,
318,
5554,
63,
19912,
21,
63,
504,
63,
11215,
8,
72,
21,
12,
11215,
304,
272,
408,
272,
24797,
376,
1551,
394,
1587,
21,
1808,
1006,
1564,
315,
282,
16459,
909,
272,
687,
314,
24980,
653,
597,
2366,
3261,
272,
6006,
4293,
506,
15145,
543,
5554,
63,
504,
63,
19351,
436,
5554,
63,
504,
63,
3885,
12,
272,
781,
5534,
314,
666,
365,
12137,
1,
272,
408,
272,
327,
664,
314,
3341,
1817,
12,
5554,
652,
272,
3341,
275,
394,
21,
14,
1231,
14,
2343,
14,
834,
458,
272,
3341,
14,
4574,
14,
11215,
63,
344,
59,
16,
61,
275,
16459,
14,
344,
272,
1305,
25234,
275,
2400,
671,
12,
89,
26,
671,
14,
1294,
24050,
18,
61,
340,
671,
587,
612,
272,
3341,
14,
4574,
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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
] |
asedunov/intellij-community
|
python/lib/Lib/codecs.py
|
116
|
33297
|
""" codecs -- Python Codec Registry, API and helpers.
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
import __builtin__, sys
### Registry and builtin stateless codec functions
try:
from _codecs import *
except ImportError, why:
raise SystemError('Failed to load the builtin codecs: %s' % why)
__all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE",
"BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE",
"BOM_UTF8", "BOM_UTF16", "BOM_UTF16_LE", "BOM_UTF16_BE",
"BOM_UTF32", "BOM_UTF32_LE", "BOM_UTF32_BE",
"strict_errors", "ignore_errors", "replace_errors",
"xmlcharrefreplace_errors",
"register_error", "lookup_error"]
### Constants
#
# Byte Order Mark (BOM = ZERO WIDTH NO-BREAK SPACE = U+FEFF)
# and its possible byte string values
# for UTF8/UTF16/UTF32 output and little/big endian machines
#
# UTF-8
BOM_UTF8 = '\xef\xbb\xbf'
# UTF-16, little endian
BOM_LE = BOM_UTF16_LE = '\xff\xfe'
# UTF-16, big endian
BOM_BE = BOM_UTF16_BE = '\xfe\xff'
# UTF-32, little endian
BOM_UTF32_LE = '\xff\xfe\x00\x00'
# UTF-32, big endian
BOM_UTF32_BE = '\x00\x00\xfe\xff'
if sys.byteorder == 'little':
# UTF-16, native endianness
BOM = BOM_UTF16 = BOM_UTF16_LE
# UTF-32, native endianness
BOM_UTF32 = BOM_UTF32_LE
else:
# UTF-16, native endianness
BOM = BOM_UTF16 = BOM_UTF16_BE
# UTF-32, native endianness
BOM_UTF32 = BOM_UTF32_BE
# Old broken names (don't use in new code)
BOM32_LE = BOM_UTF16_LE
BOM32_BE = BOM_UTF16_BE
BOM64_LE = BOM_UTF32_LE
BOM64_BE = BOM_UTF32_BE
### Codec base classes (defining the API)
class CodecInfo(tuple):
def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
incrementalencoder=None, incrementaldecoder=None, name=None):
self = tuple.__new__(cls, (encode, decode, streamreader, streamwriter))
self.name = name
self.encode = encode
self.decode = decode
self.incrementalencoder = incrementalencoder
self.incrementaldecoder = incrementaldecoder
self.streamwriter = streamwriter
self.streamreader = streamreader
return self
def __repr__(self):
return "<%s.%s object for encoding %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
class Codec:
""" Defines the interface for stateless encoders/decoders.
The .encode()/.decode() methods may use different error
handling schemes by providing the errors argument. These
string values are predefined:
'strict' - raise a ValueError error (or a subclass)
'ignore' - ignore the character and continue with the next
'replace' - replace with a suitable replacement character;
Python will use the official U+FFFD REPLACEMENT
CHARACTER for the builtin Unicode codecs on
decoding and '?' on encoding.
'xmlcharrefreplace' - Replace with the appropriate XML
character reference (only for encoding).
'backslashreplace' - Replace with backslashed escape sequences
(only for encoding).
The set of allowed values can be extended via register_error.
"""
def encode(self, input, errors='strict'):
""" Encodes the object input and returns a tuple (output
object, length consumed).
errors defines the error handling to apply. It defaults to
'strict' handling.
The method may not store state in the Codec instance. Use
StreamCodec for codecs which have to keep state in order to
make encoding/decoding efficient.
The encoder must be able to handle zero length input and
return an empty object of the output object type in this
situation.
"""
raise NotImplementedError
def decode(self, input, errors='strict'):
""" Decodes the object input and returns a tuple (output
object, length consumed).
input must be an object which provides the bf_getreadbuf
buffer slot. Python strings, buffer objects and memory
mapped files are examples of objects providing this slot.
errors defines the error handling to apply. It defaults to
'strict' handling.
The method may not store state in the Codec instance. Use
StreamCodec for codecs which have to keep state in order to
make encoding/decoding efficient.
The decoder must be able to handle zero length input and
return an empty object of the output object type in this
situation.
"""
raise NotImplementedError
class IncrementalEncoder(object):
"""
An IncrementalEncoder encodes an input in multiple steps. The input can be
passed piece by piece to the encode() method. The IncrementalEncoder remembers
the state of the Encoding process between calls to encode().
"""
def __init__(self, errors='strict'):
"""
Creates an IncrementalEncoder instance.
The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
"""
self.errors = errors
self.buffer = ""
def encode(self, input, final=False):
"""
Encodes input and returns the resulting object.
"""
raise NotImplementedError
def reset(self):
"""
Resets the encoder to the initial state.
"""
class BufferedIncrementalEncoder(IncrementalEncoder):
"""
This subclass of IncrementalEncoder can be used as the baseclass for an
incremental encoder if the encoder must keep some of the output in a
buffer between calls to encode().
"""
def __init__(self, errors='strict'):
IncrementalEncoder.__init__(self, errors)
self.buffer = "" # unencoded input that is kept between calls to encode()
def _buffer_encode(self, input, errors, final):
# Overwrite this method in subclasses: It must encode input
# and return an (output, length consumed) tuple
raise NotImplementedError
def encode(self, input, final=False):
# encode input (taking the buffer into account)
data = self.buffer + input
(result, consumed) = self._buffer_encode(data, self.errors, final)
# keep unencoded input until the next call
self.buffer = data[consumed:]
return result
def reset(self):
IncrementalEncoder.reset(self)
self.buffer = ""
class IncrementalDecoder(object):
"""
An IncrementalDecoder decodes an input in multiple steps. The input can be
passed piece by piece to the decode() method. The IncrementalDecoder
remembers the state of the decoding process between calls to decode().
"""
def __init__(self, errors='strict'):
"""
Creates a IncrementalDecoder instance.
The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.
"""
self.errors = errors
def decode(self, input, final=False):
"""
Decodes input and returns the resulting object.
"""
raise NotImplementedError
def reset(self):
"""
Resets the decoder to the initial state.
"""
class BufferedIncrementalDecoder(IncrementalDecoder):
"""
This subclass of IncrementalDecoder can be used as the baseclass for an
incremental decoder if the decoder must be able to handle incomplete byte
sequences.
"""
def __init__(self, errors='strict'):
IncrementalDecoder.__init__(self, errors)
self.buffer = "" # undecoded input that is kept between calls to decode()
def _buffer_decode(self, input, errors, final):
# Overwrite this method in subclasses: It must decode input
# and return an (output, length consumed) tuple
raise NotImplementedError
def decode(self, input, final=False):
# decode input (taking the buffer into account)
data = self.buffer + input
(result, consumed) = self._buffer_decode(data, self.errors, final)
# keep undecoded input until the next call
self.buffer = data[consumed:]
return result
def reset(self):
IncrementalDecoder.reset(self)
self.buffer = ""
#
# The StreamWriter and StreamReader class provide generic working
# interfaces which can be used to implement new encoding submodules
# very easily. See encodings/utf_8.py for an example on how this is
# done.
#
class StreamWriter(Codec):
def __init__(self, stream, errors='strict'):
""" Creates a StreamWriter instance.
stream must be a file-like object open for writing
(binary) data.
The StreamWriter may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - raise a ValueError (or a subclass)
'ignore' - ignore the character and continue with the next
'replace'- replace with a suitable replacement character
'xmlcharrefreplace' - Replace with the appropriate XML
character reference.
'backslashreplace' - Replace with backslashed escape
sequences (only for encoding).
The set of allowed parameter values can be extended via
register_error.
"""
self.stream = stream
self.errors = errors
def write(self, object):
""" Writes the object's contents encoded to self.stream.
"""
data, consumed = self.encode(object, self.errors)
self.stream.write(data)
def writelines(self, list):
""" Writes the concatenated list of strings to the stream
using .write().
"""
self.write(''.join(list))
def reset(self):
""" Flushes and resets the codec buffers used for keeping state.
Calling this method should ensure that the data on the
output is put into a clean state, that allows appending
of new fresh data without having to rescan the whole
stream to recover state.
"""
pass
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name)
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.stream.close()
###
class StreamReader(Codec):
def __init__(self, stream, errors='strict'):
""" Creates a StreamReader instance.
stream must be a file-like object open for reading
(binary) data.
The StreamReader may use different error handling
schemes by providing the errors keyword argument. These
parameters are predefined:
'strict' - raise a ValueError (or a subclass)
'ignore' - ignore the character and continue with the next
'replace'- replace with a suitable replacement character;
The set of allowed parameter values can be extended via
register_error.
"""
self.stream = stream
self.errors = errors
self.bytebuffer = ""
# For str->str decoding this will stay a str
# For str->unicode decoding the first read will promote it to unicode
self.charbuffer = ""
self.linebuffer = None
def decode(self, input, errors='strict'):
raise NotImplementedError
def read(self, size=-1, chars=-1, firstline=False):
""" Decodes data from the stream self.stream and returns the
resulting object.
chars indicates the number of characters to read from the
stream. read() will never return more than chars
characters, but it might return less, if there are not enough
characters available.
size indicates the approximate maximum number of bytes to
read from the stream for decoding purposes. The decoder
can modify this setting as appropriate. The default value
-1 indicates to read and decode as much as possible. size
is intended to prevent having to decode huge files in one
step.
If firstline is true, and a UnicodeDecodeError happens
after the first line terminator in the input only the first line
will be returned, the rest of the input will be kept until the
next call to read().
The method should use a greedy read strategy meaning that
it should read as much data as is allowed within the
definition of the encoding and the given size, e.g. if
optional encoding endings or state markers are available
on the stream, these should be read too.
"""
# If we have lines cached, first merge them back into characters
if self.linebuffer:
self.charbuffer = "".join(self.linebuffer)
self.linebuffer = None
# read until we get the required number of characters (if available)
while True:
# can the request can be satisfied from the character buffer?
if chars < 0:
if size < 0:
if self.charbuffer:
break
elif len(self.charbuffer) >= size:
break
else:
if len(self.charbuffer) >= chars:
break
# we need more data
if size < 0:
newdata = self.stream.read()
else:
newdata = self.stream.read(size)
# decode bytes (those remaining from the last call included)
data = self.bytebuffer + newdata
try:
newchars, decodedbytes = self.decode(data, self.errors)
except UnicodeDecodeError, exc:
if firstline:
newchars, decodedbytes = self.decode(data[:exc.start], self.errors)
lines = newchars.splitlines(True)
if len(lines)<=1:
raise
else:
raise
# keep undecoded bytes until the next call
self.bytebuffer = data[decodedbytes:]
# put new characters in the character buffer
self.charbuffer += newchars
# there was no data available
if not newdata:
break
if chars < 0:
# Return everything we've got
result = self.charbuffer
self.charbuffer = ""
else:
# Return the first chars characters
result = self.charbuffer[:chars]
self.charbuffer = self.charbuffer[chars:]
return result
def readline(self, size=None, keepends=True):
""" Read one line from the input stream and return the
decoded data.
size, if given, is passed as size argument to the
read() method.
"""
# If we have lines cached from an earlier read, return
# them unconditionally
if self.linebuffer:
line = self.linebuffer[0]
del self.linebuffer[0]
if len(self.linebuffer) == 1:
# revert to charbuffer mode; we might need more data
# next time
self.charbuffer = self.linebuffer[0]
self.linebuffer = None
if not keepends:
line = line.splitlines(False)[0]
return line
readsize = size or 72
line = ""
# If size is given, we call read() only once
while True:
data = self.read(readsize, firstline=True)
if data:
# If we're at a "\r" read one extra character (which might
# be a "\n") to get a proper line ending. If the stream is
# temporarily exhausted we return the wrong line ending.
if data.endswith("\r"):
data += self.read(size=1, chars=1)
line += data
lines = line.splitlines(True)
if lines:
if len(lines) > 1:
# More than one line result; the first line is a full line
# to return
line = lines[0]
del lines[0]
if len(lines) > 1:
# cache the remaining lines
lines[-1] += self.charbuffer
self.linebuffer = lines
self.charbuffer = None
else:
# only one remaining line, put it back into charbuffer
self.charbuffer = lines[0] + self.charbuffer
if not keepends:
line = line.splitlines(False)[0]
break
line0withend = lines[0]
line0withoutend = lines[0].splitlines(False)[0]
if line0withend != line0withoutend: # We really have a line end
# Put the rest back together and keep it until the next call
self.charbuffer = "".join(lines[1:]) + self.charbuffer
if keepends:
line = line0withend
else:
line = line0withoutend
break
# we didn't get anything or this was our only try
if not data or size is not None:
if line and not keepends:
line = line.splitlines(False)[0]
break
if readsize<8000:
readsize *= 2
return line
def readlines(self, sizehint=None, keepends=True):
""" Read all lines available on the input stream
and return them as list of lines.
Line breaks are implemented using the codec's decoder
method and are included in the list entries.
sizehint, if given, is ignored since there is no efficient
way to finding the true end-of-line.
"""
data = self.read()
return data.splitlines(keepends)
def reset(self):
""" Resets the codec buffers used for keeping state.
Note that no stream repositioning should take place.
This method is primarily intended to be able to recover
from decoding errors.
"""
self.bytebuffer = ""
self.charbuffer = u""
self.linebuffer = None
def seek(self, offset, whence=0):
""" Set the input stream's current position.
Resets the codec buffers used for keeping state.
"""
self.reset()
self.stream.seek(offset, whence)
def next(self):
""" Return the next decoded line from the input stream."""
line = self.readline()
if line:
return line
raise StopIteration
def __iter__(self):
return self
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name)
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.stream.close()
###
class StreamReaderWriter:
""" StreamReaderWriter instances allow wrapping streams which
work in both read and write modes.
The design is such that one can use the factory functions
returned by the codec.lookup() function to construct the
instance.
"""
# Optional attributes set by the file wrappers below
encoding = 'unknown'
def __init__(self, stream, Reader, Writer, errors='strict'):
""" Creates a StreamReaderWriter instance.
stream must be a Stream-like object.
Reader, Writer must be factory functions or classes
providing the StreamReader, StreamWriter interface resp.
Error handling is done in the same way as defined for the
StreamWriter/Readers.
"""
self.stream = stream
self.reader = Reader(stream, errors)
self.writer = Writer(stream, errors)
self.errors = errors
def read(self, size=-1):
return self.reader.read(size)
def readline(self, size=None):
return self.reader.readline(size)
def readlines(self, sizehint=None):
return self.reader.readlines(sizehint)
def next(self):
""" Return the next decoded line from the input stream."""
return self.reader.next()
def __iter__(self):
return self
def write(self, data):
return self.writer.write(data)
def writelines(self, list):
return self.writer.writelines(list)
def reset(self):
self.reader.reset()
self.writer.reset()
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name)
# these are needed to make "with codecs.open(...)" work properly
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.stream.close()
###
class StreamRecoder:
""" StreamRecoder instances provide a frontend - backend
view of encoding data.
They use the complete set of APIs returned by the
codecs.lookup() function to implement their task.
Data written to the stream is first decoded into an
intermediate format (which is dependent on the given codec
combination) and then written to the stream using an instance
of the provided Writer class.
In the other direction, data is read from the stream using a
Reader instance and then return encoded data to the caller.
"""
# Optional attributes set by the file wrappers below
data_encoding = 'unknown'
file_encoding = 'unknown'
def __init__(self, stream, encode, decode, Reader, Writer,
errors='strict'):
""" Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
input to .read() and output of .write()) while
Reader and Writer work on the backend (reading and
writing to the stream).
You can use these objects to do transparent direct
recodings from e.g. latin-1 to utf-8 and back.
stream must be a file-like object.
encode, decode must adhere to the Codec interface, Reader,
Writer must be factory functions or classes providing the
StreamReader, StreamWriter interface resp.
encode and decode are needed for the frontend translation,
Reader and Writer for the backend translation. Unicode is
used as intermediate encoding.
Error handling is done in the same way as defined for the
StreamWriter/Readers.
"""
self.stream = stream
self.encode = encode
self.decode = decode
self.reader = Reader(stream, errors)
self.writer = Writer(stream, errors)
self.errors = errors
def read(self, size=-1):
data = self.reader.read(size)
data, bytesencoded = self.encode(data, self.errors)
return data
def readline(self, size=None):
if size is None:
data = self.reader.readline()
else:
data = self.reader.readline(size)
data, bytesencoded = self.encode(data, self.errors)
return data
def readlines(self, sizehint=None):
data = self.reader.read()
data, bytesencoded = self.encode(data, self.errors)
return data.splitlines(1)
def next(self):
""" Return the next decoded line from the input stream."""
data = self.reader.next()
data, bytesencoded = self.encode(data, self.errors)
return data
def __iter__(self):
return self
def write(self, data):
data, bytesdecoded = self.decode(data, self.errors)
return self.writer.write(data)
def writelines(self, list):
data = ''.join(list)
data, bytesdecoded = self.decode(data, self.errors)
return self.writer.write(data)
def reset(self):
self.reader.reset()
self.writer.reset()
def __getattr__(self, name,
getattr=getattr):
""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name)
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.stream.close()
### Shortcuts
def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
""" Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.
Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode objects for most builtin
codecs. Output is also codec dependent and will usually be
Unicode as well.
Files are always opened in binary mode, even if no binary mode
was specified. This is done to avoid data loss due to encodings
using 8-bit values. The default file mode is 'rb' meaning to
open the file in binary read mode.
encoding specifies the encoding which is to be used for the
file.
errors may be given to define the error handling. It defaults
to 'strict' which causes ValueErrors to be raised in case an
encoding error occurs.
buffering has the same meaning as for the builtin open() API.
It defaults to line buffered.
The returned wrapped file object provides an extra attribute
.encoding which allows querying the used encoding. This
attribute is only available if an encoding was specified as
parameter.
"""
if encoding is not None and \
'b' not in mode:
# Force opening of the file in binary mode
mode = mode + 'b'
file = __builtin__.open(filename, mode, buffering)
if encoding is None:
return file
info = lookup(encoding)
srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
# Add attributes to simplify introspection
srw.encoding = encoding
return srw
def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
""" Return a wrapped version of file which provides transparent
encoding translation.
Strings written to the wrapped file are interpreted according
to the given data_encoding and then written to the original
file as string using file_encoding. The intermediate encoding
will usually be Unicode but depends on the specified codecs.
Strings are read from the file using file_encoding and then
passed back to the caller as string using data_encoding.
If file_encoding is not given, it defaults to data_encoding.
errors may be given to define the error handling. It defaults
to 'strict' which causes ValueErrors to be raised in case an
encoding error occurs.
The returned wrapped file object provides two extra attributes
.data_encoding and .file_encoding which reflect the given
parameters of the same name. The attributes can be used for
introspection by Python programs.
"""
if file_encoding is None:
file_encoding = data_encoding
data_info = lookup(data_encoding)
file_info = lookup(file_encoding)
sr = StreamRecoder(file, data_info.encode, data_info.decode,
file_info.streamreader, file_info.streamwriter, errors)
# Add attributes to simplify introspection
sr.data_encoding = data_encoding
sr.file_encoding = file_encoding
return sr
### Helpers for codec lookup
def getencoder(encoding):
""" Lookup up the codec for the given encoding and return
its encoder function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).encode
def getdecoder(encoding):
""" Lookup up the codec for the given encoding and return
its decoder function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).decode
def getincrementalencoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalEncoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental encoder.
"""
encoder = lookup(encoding).incrementalencoder
if encoder is None:
raise LookupError(encoding)
return encoder
def getincrementaldecoder(encoding):
""" Lookup up the codec for the given encoding and return
its IncrementalDecoder class or factory function.
Raises a LookupError in case the encoding cannot be found
or the codecs doesn't provide an incremental decoder.
"""
decoder = lookup(encoding).incrementaldecoder
if decoder is None:
raise LookupError(encoding)
return decoder
def getreader(encoding):
""" Lookup up the codec for the given encoding and return
its StreamReader class or factory function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).streamreader
def getwriter(encoding):
""" Lookup up the codec for the given encoding and return
its StreamWriter class or factory function.
Raises a LookupError in case the encoding cannot be found.
"""
return lookup(encoding).streamwriter
def iterencode(iterator, encoding, errors='strict', **kwargs):
"""
Encoding iterator.
Encodes the input strings from the iterator using a IncrementalEncoder.
errors and kwargs are passed through to the IncrementalEncoder
constructor.
"""
encoder = getincrementalencoder(encoding)(errors, **kwargs)
for input in iterator:
output = encoder.encode(input)
if output:
yield output
output = encoder.encode("", True)
if output:
yield output
def iterdecode(iterator, encoding, errors='strict', **kwargs):
"""
Decoding iterator.
Decodes the input strings from the iterator using a IncrementalDecoder.
errors and kwargs are passed through to the IncrementalDecoder
constructor.
"""
decoder = getincrementaldecoder(encoding)(errors, **kwargs)
for input in iterator:
output = decoder.decode(input)
if output:
yield output
output = decoder.decode("", True)
if output:
yield output
### Helpers for charmap-based codecs
def make_identity_dict(rng):
""" make_identity_dict(rng) -> dict
Return a dictionary where elements of the rng sequence are
mapped to themselves.
"""
res = {}
for i in rng:
res[i]=i
return res
def make_encoding_map(decoding_map):
""" Creates an encoding map from a decoding map.
If a target mapping in the decoding map occurs multiple
times, then that target is mapped to None (undefined mapping),
causing an exception when encountered by the charmap codec
during translation.
One example where this happens is cp875.py which decodes
multiple character to \u001a.
"""
m = {}
for k,v in decoding_map.items():
if not v in m:
m[v] = k
else:
m[v] = None
return m
### error handlers
try:
strict_errors = lookup_error("strict")
ignore_errors = lookup_error("ignore")
replace_errors = lookup_error("replace")
xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace")
backslashreplace_errors = lookup_error("backslashreplace")
except LookupError:
# In --disable-unicode builds, these error handler are missing
strict_errors = None
ignore_errors = None
replace_errors = None
xmlcharrefreplace_errors = None
backslashreplace_errors = None
# Tell modulefinder that using codecs probably needs the encodings
# package
_false = 0
if _false:
import encodings
### Tests
if __name__ == '__main__':
# Make stdout translate Latin-1 output into UTF-8 output
sys.stdout = EncodedFile(sys.stdout, 'latin-1', 'utf-8')
# Have stdin translate Latin-1 input into UTF-8 input
sys.stdin = EncodedFile(sys.stdin, 'utf-8', 'latin-1')
|
apache-2.0
|
[
624,
6010,
1553,
2018,
13732,
20738,
12,
3261,
436,
10897,
14,
421,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
23662,
199,
199,
646,
636,
5351,
3108,
984,
199,
199,
5680,
20738,
436,
6762,
1174,
2003,
9076,
3423,
199,
199,
893,
26,
272,
687,
485,
8933,
492,
627,
199,
2590,
3545,
12,
10842,
26,
272,
746,
6187,
547,
360,
4276,
370,
2248,
314,
6762,
6010,
26,
450,
83,
7,
450,
10842,
9,
199,
199,
363,
452,
363,
275,
2097,
2683,
401,
298,
3892,
401,
298,
1490,
401,
298,
32149,
1173,
401,
298,
19550,
401,
298,
19550,
63,
6773,
401,
1779,
298,
19550,
63,
906,
401,
298,
19550,
708,
63,
6773,
401,
298,
19550,
708,
63,
906,
401,
298,
19550,
772,
63,
6773,
401,
298,
19550,
772,
63,
906,
401,
1779,
298,
19550,
63,
6610,
24,
401,
298,
19550,
63,
6610,
975,
401,
298,
19550,
63,
6610,
975,
63,
906,
401,
298,
19550,
63,
6610,
975,
63,
6773,
401,
1779,
298,
19550,
63,
6610,
708,
401,
298,
19550,
63,
6610,
708,
63,
906,
401,
298,
19550,
63,
6610,
708,
63,
6773,
401,
1779,
298,
4768,
63,
2550,
401,
298,
4247,
63,
2550,
401,
298,
1814,
63,
2550,
401,
1779,
298,
1652,
24253,
1814,
63,
2550,
401,
1779,
298,
2683,
63,
705,
401,
298,
3892,
63,
705,
937,
199,
199,
5680,
22296,
199,
199,
3,
199,
3,
20301,
9240,
7173,
334,
19550,
275,
20348,
644,
998,
2080,
4825,
13,
14731,
16796,
275,
738,
11,
5100,
1665,
9,
199,
3,
436,
2399,
3962,
3696,
1059,
1338,
199,
3,
367,
9094,
24,
15,
6610,
975,
15,
6610,
708,
1072,
436,
12050,
15,
5076,
17638,
20601,
199,
3,
199,
199,
3,
9094,
13,
24,
199,
19550,
63,
6610,
24,
275,
1557,
9532,
60,
9932,
60,
9566,
7,
199,
199,
3,
9094,
13,
975,
12,
12050,
17638,
199,
19550,
63,
906,
275,
17720,
63,
6610,
975,
63,
906,
275,
1557,
3581,
60,
8371,
7,
199,
199,
3,
9094,
13,
975,
12,
7282,
17638,
199,
19550,
63,
6773,
275,
17720,
63,
6610,
975,
63,
6773,
275,
1557,
8371,
60,
3581,
7,
199,
199,
3,
9094,
13,
708,
12,
12050,
17638,
199,
19550,
63,
6610,
708,
63,
906,
275,
1557,
3581,
60,
8371,
60,
88,
383,
60,
88,
383,
7,
199,
199,
3,
9094,
13,
708,
12,
7282,
17638,
199,
19550,
63,
6610,
708,
63,
6773,
275,
1557,
88,
383,
60,
88,
383,
60,
8371,
60,
3581,
7,
199,
199,
692,
984,
14,
19415,
508,
283,
10182,
356,
339,
327,
9094,
13,
975,
12,
5438,
17638,
4171,
272,
17720,
275,
17720,
63,
6610,
975,
275,
17720,
63,
6610,
975,
63,
906,
339,
327,
9094,
13,
708,
12,
5438,
17638,
4171,
272,
17720,
63,
6610,
708,
275,
17720,
63,
6610,
708,
63,
906,
199,
199,
2836,
26,
339,
327,
9094,
13,
975,
12,
5438,
17638,
4171,
272,
17720,
275,
17720,
63,
6610,
975,
275,
17720,
63,
6610,
975,
63,
6773,
339,
327,
9094,
13,
708,
12,
5438,
17638,
4171,
272,
17720,
63,
6610,
708,
275,
17720,
63,
6610,
708,
63,
6773,
199,
199,
3,
21238,
10529,
1561,
334,
13196,
1133,
675,
315,
892,
1233,
9,
199,
19550,
708,
63,
906,
275,
17720,
63,
6610,
975,
63,
906,
199,
19550,
708,
63,
6773,
275,
17720,
63,
6610,
975,
63,
6773,
199,
19550,
772,
63,
906,
275,
17720,
63,
6610,
708,
63,
906,
199,
19550,
772,
63,
6773,
275,
17720,
63,
6610,
708,
63,
6773,
421,
199,
5680,
13732,
1300,
3992,
334,
318,
7969,
314,
3261,
9,
199,
199,
533,
13732,
2354,
8,
2960,
304,
339,
347,
636,
1222,
721,
1886,
12,
3752,
12,
4849,
12,
26101,
29,
403,
12,
26112,
29,
403,
12,
267,
26329,
29,
403,
12,
26317,
29,
403,
12,
536,
29,
403,
304,
267,
291,
275,
2008,
855,
1222,
721,
1886,
12,
334,
2143,
12,
4849,
12,
26101,
12,
26112,
430,
267,
291,
14,
354,
275,
536,
267,
291,
14,
2143,
275,
3752,
267,
291,
14,
2708,
275,
4849,
267,
291,
14,
9728,
24080,
275,
26329,
267,
291,
14,
23760,
8813,
275,
26317,
267,
291,
14,
1745,
5491,
275,
26112,
267,
291,
14,
1745,
5503,
275,
26101,
267,
372,
291,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
23054,
83,
4111,
83,
909,
367,
2644,
450,
83,
737,
378,
88,
5,
88,
4335,
450,
334,
277,
855,
533,
4914,
578,
3108,
291,
855,
533,
4914,
354,
3108,
291,
14,
354,
12,
1305,
8,
277,
430,
199,
199,
533,
13732,
26,
339,
408,
25022,
314,
3217,
367,
1174,
2003,
10295,
83,
15,
8813,
83,
14,
398,
710,
1275,
2143,
342,
8083,
2708,
342,
3102,
1443,
675,
3365,
1125,
267,
7252,
21149,
701,
13070,
314,
2552,
1423,
14,
5723,
267,
1059,
1338,
787,
27684,
26,
13359,
283,
4768,
7,
446,
746,
282,
1722,
1125,
334,
269,
282,
5516,
9,
268,
283,
4247,
7,
446,
3686,
314,
4528,
436,
1980,
543,
314,
2163,
268,
283,
1814,
7,
446,
3350,
543,
282,
11233,
8343,
4528,
27,
490,
2018,
911,
675,
314,
25410,
738,
11,
28050,
5363,
2749,
22194,
490,
9502,
367,
314,
6762,
6140,
6010,
641,
490,
15952,
436,
15539,
641,
2644,
14,
268,
283,
1652,
24253,
1814,
7,
446,
14402,
543,
314,
5827,
4692,
3044,
4528,
3659,
334,
2118,
367,
2644,
680,
268,
283,
21509,
1814,
7,
221,
446,
14402,
543,
13831,
379,
4772,
8013,
3044,
334,
2118,
367,
2644,
680,
398,
710,
663,
402,
4370,
1338,
883,
506,
9243,
4799,
2274,
63,
705,
14,
339,
408,
272,
347,
3752,
8,
277,
12,
1324,
12,
2552,
534,
4768,
735,
398,
408,
3447,
6021,
314,
909,
1324,
436,
2529,
282,
2008,
334,
1199,
288,
909,
12,
2582,
16949,
680,
953,
2552,
7890,
314,
1125,
7252,
370,
4838,
14,
2779,
4243,
370,
288,
283,
4768,
7,
7252,
14,
953,
710,
1083,
1443,
440,
3877,
1174,
315,
314,
13732,
1256,
14,
3645,
288,
8271,
8818,
367,
6010,
1314,
1172,
370,
4215,
1174,
315,
1865,
370,
288,
1852,
2644,
15,
12796,
13402,
14,
953,
710,
10295,
1471,
506,
7688,
370,
2429,
4697,
2582,
1324,
436,
288,
372
] |
[
6010,
1553,
2018,
13732,
20738,
12,
3261,
436,
10897,
14,
421,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
23662,
199,
199,
646,
636,
5351,
3108,
984,
199,
199,
5680,
20738,
436,
6762,
1174,
2003,
9076,
3423,
199,
199,
893,
26,
272,
687,
485,
8933,
492,
627,
199,
2590,
3545,
12,
10842,
26,
272,
746,
6187,
547,
360,
4276,
370,
2248,
314,
6762,
6010,
26,
450,
83,
7,
450,
10842,
9,
199,
199,
363,
452,
363,
275,
2097,
2683,
401,
298,
3892,
401,
298,
1490,
401,
298,
32149,
1173,
401,
298,
19550,
401,
298,
19550,
63,
6773,
401,
1779,
298,
19550,
63,
906,
401,
298,
19550,
708,
63,
6773,
401,
298,
19550,
708,
63,
906,
401,
298,
19550,
772,
63,
6773,
401,
298,
19550,
772,
63,
906,
401,
1779,
298,
19550,
63,
6610,
24,
401,
298,
19550,
63,
6610,
975,
401,
298,
19550,
63,
6610,
975,
63,
906,
401,
298,
19550,
63,
6610,
975,
63,
6773,
401,
1779,
298,
19550,
63,
6610,
708,
401,
298,
19550,
63,
6610,
708,
63,
906,
401,
298,
19550,
63,
6610,
708,
63,
6773,
401,
1779,
298,
4768,
63,
2550,
401,
298,
4247,
63,
2550,
401,
298,
1814,
63,
2550,
401,
1779,
298,
1652,
24253,
1814,
63,
2550,
401,
1779,
298,
2683,
63,
705,
401,
298,
3892,
63,
705,
937,
199,
199,
5680,
22296,
199,
199,
3,
199,
3,
20301,
9240,
7173,
334,
19550,
275,
20348,
644,
998,
2080,
4825,
13,
14731,
16796,
275,
738,
11,
5100,
1665,
9,
199,
3,
436,
2399,
3962,
3696,
1059,
1338,
199,
3,
367,
9094,
24,
15,
6610,
975,
15,
6610,
708,
1072,
436,
12050,
15,
5076,
17638,
20601,
199,
3,
199,
199,
3,
9094,
13,
24,
199,
19550,
63,
6610,
24,
275,
1557,
9532,
60,
9932,
60,
9566,
7,
199,
199,
3,
9094,
13,
975,
12,
12050,
17638,
199,
19550,
63,
906,
275,
17720,
63,
6610,
975,
63,
906,
275,
1557,
3581,
60,
8371,
7,
199,
199,
3,
9094,
13,
975,
12,
7282,
17638,
199,
19550,
63,
6773,
275,
17720,
63,
6610,
975,
63,
6773,
275,
1557,
8371,
60,
3581,
7,
199,
199,
3,
9094,
13,
708,
12,
12050,
17638,
199,
19550,
63,
6610,
708,
63,
906,
275,
1557,
3581,
60,
8371,
60,
88,
383,
60,
88,
383,
7,
199,
199,
3,
9094,
13,
708,
12,
7282,
17638,
199,
19550,
63,
6610,
708,
63,
6773,
275,
1557,
88,
383,
60,
88,
383,
60,
8371,
60,
3581,
7,
199,
199,
692,
984,
14,
19415,
508,
283,
10182,
356,
339,
327,
9094,
13,
975,
12,
5438,
17638,
4171,
272,
17720,
275,
17720,
63,
6610,
975,
275,
17720,
63,
6610,
975,
63,
906,
339,
327,
9094,
13,
708,
12,
5438,
17638,
4171,
272,
17720,
63,
6610,
708,
275,
17720,
63,
6610,
708,
63,
906,
199,
199,
2836,
26,
339,
327,
9094,
13,
975,
12,
5438,
17638,
4171,
272,
17720,
275,
17720,
63,
6610,
975,
275,
17720,
63,
6610,
975,
63,
6773,
339,
327,
9094,
13,
708,
12,
5438,
17638,
4171,
272,
17720,
63,
6610,
708,
275,
17720,
63,
6610,
708,
63,
6773,
199,
199,
3,
21238,
10529,
1561,
334,
13196,
1133,
675,
315,
892,
1233,
9,
199,
19550,
708,
63,
906,
275,
17720,
63,
6610,
975,
63,
906,
199,
19550,
708,
63,
6773,
275,
17720,
63,
6610,
975,
63,
6773,
199,
19550,
772,
63,
906,
275,
17720,
63,
6610,
708,
63,
906,
199,
19550,
772,
63,
6773,
275,
17720,
63,
6610,
708,
63,
6773,
421,
199,
5680,
13732,
1300,
3992,
334,
318,
7969,
314,
3261,
9,
199,
199,
533,
13732,
2354,
8,
2960,
304,
339,
347,
636,
1222,
721,
1886,
12,
3752,
12,
4849,
12,
26101,
29,
403,
12,
26112,
29,
403,
12,
267,
26329,
29,
403,
12,
26317,
29,
403,
12,
536,
29,
403,
304,
267,
291,
275,
2008,
855,
1222,
721,
1886,
12,
334,
2143,
12,
4849,
12,
26101,
12,
26112,
430,
267,
291,
14,
354,
275,
536,
267,
291,
14,
2143,
275,
3752,
267,
291,
14,
2708,
275,
4849,
267,
291,
14,
9728,
24080,
275,
26329,
267,
291,
14,
23760,
8813,
275,
26317,
267,
291,
14,
1745,
5491,
275,
26112,
267,
291,
14,
1745,
5503,
275,
26101,
267,
372,
291,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
23054,
83,
4111,
83,
909,
367,
2644,
450,
83,
737,
378,
88,
5,
88,
4335,
450,
334,
277,
855,
533,
4914,
578,
3108,
291,
855,
533,
4914,
354,
3108,
291,
14,
354,
12,
1305,
8,
277,
430,
199,
199,
533,
13732,
26,
339,
408,
25022,
314,
3217,
367,
1174,
2003,
10295,
83,
15,
8813,
83,
14,
398,
710,
1275,
2143,
342,
8083,
2708,
342,
3102,
1443,
675,
3365,
1125,
267,
7252,
21149,
701,
13070,
314,
2552,
1423,
14,
5723,
267,
1059,
1338,
787,
27684,
26,
13359,
283,
4768,
7,
446,
746,
282,
1722,
1125,
334,
269,
282,
5516,
9,
268,
283,
4247,
7,
446,
3686,
314,
4528,
436,
1980,
543,
314,
2163,
268,
283,
1814,
7,
446,
3350,
543,
282,
11233,
8343,
4528,
27,
490,
2018,
911,
675,
314,
25410,
738,
11,
28050,
5363,
2749,
22194,
490,
9502,
367,
314,
6762,
6140,
6010,
641,
490,
15952,
436,
15539,
641,
2644,
14,
268,
283,
1652,
24253,
1814,
7,
446,
14402,
543,
314,
5827,
4692,
3044,
4528,
3659,
334,
2118,
367,
2644,
680,
268,
283,
21509,
1814,
7,
221,
446,
14402,
543,
13831,
379,
4772,
8013,
3044,
334,
2118,
367,
2644,
680,
398,
710,
663,
402,
4370,
1338,
883,
506,
9243,
4799,
2274,
63,
705,
14,
339,
408,
272,
347,
3752,
8,
277,
12,
1324,
12,
2552,
534,
4768,
735,
398,
408,
3447,
6021,
314,
909,
1324,
436,
2529,
282,
2008,
334,
1199,
288,
909,
12,
2582,
16949,
680,
953,
2552,
7890,
314,
1125,
7252,
370,
4838,
14,
2779,
4243,
370,
288,
283,
4768,
7,
7252,
14,
953,
710,
1083,
1443,
440,
3877,
1174,
315,
314,
13732,
1256,
14,
3645,
288,
8271,
8818,
367,
6010,
1314,
1172,
370,
4215,
1174,
315,
1865,
370,
288,
1852,
2644,
15,
12796,
13402,
14,
953,
710,
10295,
1471,
506,
7688,
370,
2429,
4697,
2582,
1324,
436,
288,
372,
0
] |
[
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 -*-
from enigma import eTimer
from Components.Language import language
# Dict languageCode -> array of strings
MAP_SEARCH = (
u"%_0",
u" 1",
u"abc2",
u"def3",
u"ghi4",
u"jkl5",
u"mno6",
u"pqrs7",
u"tuv8",
u"wxyz9",
)
MAP_SEARCH_UPCASE = (
U"0%_",
U"1 ",
U"ABC2",
U"DEF3",
U"GHI4",
U"JKL5",
U"MNO6",
U"PQRS7",
U"TUV8",
U"WXYZ9",
)
MAP_DEFAULT = (
u"0,?!&@=*'+\"()$~%#",
u" 1.:;/-_",
u"abc2ABC",
u"def3DEF",
u"ghi4GHI",
u"jkl5JKL",
u"mno6MNO",
u"pqrs7PQRS",
u"tuv8TUV",
u"wxyz9WXYZ",
)
MAP_DE = (
u"0,?!&@=*'+\"()$~%#",
u" 1.:;/-_",
u"abcä2ABCÄ",
u"def3DEF",
u"ghi4GHI",
u"jkl5JKL",
u"mnoö6MNOÖ",
u"pqrsß7PQRSß",
u"tuvü8TUVÜ",
u"wxyz9WXYZ",
)
MAP_ES = (
u"0,?!&@=*'+\"()$~%#",
u" 1.:;/-_",
u"abcáà2ABCÁÀ",
u"deéèf3DEFÉÈ",
u"ghiíì4GHIÍÌ",
u"jkl5JKL",
u"mnñoóò6MNÑOÓÒ",
u"pqrs7PQRS",
u"tuvúù8TUVÚÙ",
u"wxyz9WXYZ",
)
MAP_SE = (
u"0,?!&@=*'+\"()$~%#",
u" 1.:;/-_",
u"abcåä2ABCÅÄ",
u"defé3DEFÉ",
u"ghi4GHI",
u"jkl5JKL",
u"mnoö6MNOÖ",
u"pqrs7PQRS",
u"tuv8TUV",
u"wxyz9WXYZ",
)
MAP_CZ = (
u"0,?'+\"()@$!=&*%#",
u" 1.:;/-_",
u"abc2áäčABCÁÄČ",
u"def3ďéěDEFĎÉĚ",
u"ghi4íGHIÍ",
u"jkl5ľĺJKLĽĹ",
u"mno6ňóöôMNOŇÓÖÔ",
u"pqrs7řŕšPQRSŘŔŠ",
u"tuv8ťúůüTUVŤÚŮÜ",
u"wxyz9ýžWXYZÝŽ",
)
MAP_PL = (
u"0,?'+\"()@$!=&*%#",
u" 1.:;/-_",
u"abcąć2ABCĄĆ",
u"defę3DEFĘ",
u"ghi4GHI",
u"jklł5JKLŁ",
u"mnońó6MNOŃÓ",
u"pqrsś7PQRSŚ",
u"tuv8TUV",
u"wxyzźż9WXYZŹŻ",
)
MAP_RU = (
u"0,?'+\"()@$!=&*%#",
u" 1.:;/-_",
u"abcабвг2ABCАБВГ",
u"defдежз3DEFДЕЖЗ",
u"ghiийкл4GHIИЙКЛ",
u"jklмноп5JKLМНОП",
u"mnoрсту6MNOРСТУ",
u"pqrsфхцч7PQRSФХЦЧ",
u"tuvшщь8TUVШЩЬ",
u"wxyzъэюя9WXYZЪЭЮЯ",
)
MAP_NL = (
u"0,?!&@=*'+\"()$~%#",
u" 1.:;/-_",
u"abc2ABC",
u"deëf3DEËF",
u"ghiï4GHIÏ",
u"jkl5JKL",
u"mno6MNO",
u"pqrs7PQRS",
u"tuv8TUV",
u"wxyz9WXYZ",
)
MAPPINGS = {
'de_DE': MAP_DE,
'es_ES': MAP_ES,
'sv_SE': MAP_SE,
'fi_FI': MAP_SE,
'cs_CZ': MAP_CZ,
'sk_SK': MAP_CZ,
'pl_PL': MAP_PL,
'ru_RU': MAP_RU,
'nl_NL': MAP_NL,
}
class NumericalTextInput:
def __init__(self, nextFunc=None, handleTimeout = True, search = False, mapping = None):
self.useableChars=None
self.nextFunction=nextFunc
if handleTimeout:
self.timer = eTimer()
self.timer.callback.append(self.timeout)
else:
self.timer = None
self.lastKey = -1
self.pos = -1
if mapping is not None:
self.mapping = mapping
elif search:
self.mapping = MAP_SEARCH
else:
self.mapping = MAPPINGS.get(language.getLanguage(), MAP_DEFAULT)
def setUseableChars(self, useable):
self.useableChars = unicode(useable)
def getKey(self, num):
cnt=0
if self.lastKey != num:
if self.lastKey != -1:
self.nextChar()
self.lastKey = num
self.pos = -1
if self.timer is not None:
self.timer.start(1000, True)
while True:
self.pos += 1
if len(self.mapping[num]) <= self.pos:
self.pos = 0
if self.useableChars:
pos = self.useableChars.find(self.mapping[num][self.pos])
if pos == -1:
cnt += 1
if cnt < len(self.mapping[num]):
continue
else:
return None
break
return self.mapping[num][self.pos]
def nextKey(self):
if self.timer is not None:
self.timer.stop()
self.lastKey = -1
def nextChar(self):
self.nextKey()
if self.nextFunction:
self.nextFunction()
def timeout(self):
if self.lastKey != -1:
self.nextChar()
|
gpl-2.0
|
[
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
504,
655,
27021,
492,
325,
7929,
199,
504,
17823,
14,
8493,
492,
2637,
199,
199,
3,
7448,
2637,
3034,
1035,
1625,
402,
3326,
199,
5443,
63,
15962,
275,
334,
199,
198,
85,
6808,
63,
16,
401,
199,
198,
85,
2,
413,
401,
199,
198,
85,
2,
3175,
18,
401,
199,
198,
85,
2,
318,
19,
401,
199,
198,
85,
2,
3561,
73,
20,
401,
199,
198,
85,
2,
74,
9503,
21,
401,
199,
198,
85,
2,
77,
889,
22,
401,
199,
198,
85,
2,
26295,
2393,
23,
401,
199,
198,
85,
2,
84,
9154,
24,
401,
199,
198,
85,
2,
19400,
25,
401,
199,
198,
9,
199,
5443,
63,
15962,
63,
2160,
11320,
275,
334,
199,
198,
53,
2,
16,
5,
29808,
199,
198,
53,
2,
17,
3872,
199,
198,
53,
2,
8390,
18,
401,
199,
198,
53,
2,
5638,
19,
401,
199,
198,
53,
2,
39,
11183,
20,
401,
199,
198,
53,
2,
24100,
21,
401,
199,
198,
53,
2,
45,
2826,
22,
401,
199,
198,
53,
2,
48,
49,
15062,
23,
401,
199,
198,
53,
2,
52,
15110,
24,
401,
199,
198,
53,
2,
24648,
25,
401,
199,
198,
9,
199,
5443,
63,
3472,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
18,
8390,
401,
199,
198,
85,
2,
318,
19,
5638,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
22,
45,
2826,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
1093,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
13733,
18,
8390,
128,
227,
401,
199,
198,
85,
2,
318,
19,
5638,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
14614,
22,
45,
2826,
128,
245,
401,
199,
198,
85,
2,
26295,
2393,
128,
254,
23,
48,
49,
15062,
128,
254,
401,
199,
198,
85,
2,
84,
9154,
17709,
24,
52,
15110,
128,
251,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
654,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
11302,
26482,
18,
8390,
128,
224,
128,
223,
401,
199,
198,
85,
2,
271,
5741,
18631,
70,
19,
5638,
128,
232,
128,
231,
401,
199,
198,
85,
2,
3561,
73,
13676,
128,
106,
20,
39,
11183,
128,
236,
128,
235,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
10344,
22692,
79,
11980,
128,
111,
22,
16237,
128,
240,
47,
128,
242,
128,
241,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24602,
128,
118,
24,
52,
15110,
128,
249,
128,
248,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
899,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
30234,
13733,
18,
8390,
128,
228,
128,
227,
401,
199,
198,
85,
2,
318,
5741,
19,
5638,
128,
232,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
14614,
22,
45,
2826,
128,
245,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
27808,
275,
334,
199,
198,
85,
2,
16,
12,
31,
6828,
4451,
342,
32,
4,
1111,
6,
32639,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
18,
11302,
13733,
31493,
8390,
128,
224,
128,
227,
129,
235,
401,
199,
198,
85,
2,
318,
19,
129,
238,
5741,
129,
250,
5638,
129,
237,
128,
232,
129,
249,
401,
199,
198,
85,
2,
3561,
73,
20,
13676,
39,
11183,
128,
236,
401,
199,
198,
85,
2,
74,
9503,
21,
129,
123,
129,
119,
24100,
129,
122,
129,
118,
401,
199,
198,
85,
2,
77,
889,
22,
130,
231,
11980,
14614,
128,
113,
45,
2826,
130,
230,
128,
242,
128,
245,
128,
243,
401,
199,
198,
85,
2,
26295,
2393,
23,
130,
248,
130,
244,
27273,
48,
49,
15062,
130,
247,
130,
243,
130,
255,
401,
199,
198,
85,
2,
84,
9154,
24,
130,
99,
24602,
130,
108,
17709,
52,
15110,
130,
98,
128,
249,
130,
107,
128,
251,
401,
199,
198,
85,
2,
19400,
25,
128,
122,
29529,
24648,
128,
252,
130,
122,
401,
199,
198,
9,
199,
5443,
63,
2749,
275,
334,
199,
198,
85,
2,
16,
12,
31,
6828,
4451,
342,
32,
4,
1111,
6,
32639,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
129,
228,
129,
230,
18,
8390,
129,
227,
129,
229,
401,
199,
198,
85,
2,
318,
129,
248,
19,
5638,
129,
247,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
130,
225,
21,
24100,
130,
224,
401,
199,
198,
85,
2,
77,
889,
130,
227,
11980,
22,
45,
2826,
130,
226,
128,
242,
401,
199,
198,
85,
2,
26295,
2393,
130,
250,
23,
48,
49,
15062,
130,
249,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
199,
198
] |
[
1882,
2803,
26,
9094,
13,
24,
1882,
199,
504,
655,
27021,
492,
325,
7929,
199,
504,
17823,
14,
8493,
492,
2637,
199,
199,
3,
7448,
2637,
3034,
1035,
1625,
402,
3326,
199,
5443,
63,
15962,
275,
334,
199,
198,
85,
6808,
63,
16,
401,
199,
198,
85,
2,
413,
401,
199,
198,
85,
2,
3175,
18,
401,
199,
198,
85,
2,
318,
19,
401,
199,
198,
85,
2,
3561,
73,
20,
401,
199,
198,
85,
2,
74,
9503,
21,
401,
199,
198,
85,
2,
77,
889,
22,
401,
199,
198,
85,
2,
26295,
2393,
23,
401,
199,
198,
85,
2,
84,
9154,
24,
401,
199,
198,
85,
2,
19400,
25,
401,
199,
198,
9,
199,
5443,
63,
15962,
63,
2160,
11320,
275,
334,
199,
198,
53,
2,
16,
5,
29808,
199,
198,
53,
2,
17,
3872,
199,
198,
53,
2,
8390,
18,
401,
199,
198,
53,
2,
5638,
19,
401,
199,
198,
53,
2,
39,
11183,
20,
401,
199,
198,
53,
2,
24100,
21,
401,
199,
198,
53,
2,
45,
2826,
22,
401,
199,
198,
53,
2,
48,
49,
15062,
23,
401,
199,
198,
53,
2,
52,
15110,
24,
401,
199,
198,
53,
2,
24648,
25,
401,
199,
198,
9,
199,
5443,
63,
3472,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
18,
8390,
401,
199,
198,
85,
2,
318,
19,
5638,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
22,
45,
2826,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
1093,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
13733,
18,
8390,
128,
227,
401,
199,
198,
85,
2,
318,
19,
5638,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
14614,
22,
45,
2826,
128,
245,
401,
199,
198,
85,
2,
26295,
2393,
128,
254,
23,
48,
49,
15062,
128,
254,
401,
199,
198,
85,
2,
84,
9154,
17709,
24,
52,
15110,
128,
251,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
654,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
11302,
26482,
18,
8390,
128,
224,
128,
223,
401,
199,
198,
85,
2,
271,
5741,
18631,
70,
19,
5638,
128,
232,
128,
231,
401,
199,
198,
85,
2,
3561,
73,
13676,
128,
106,
20,
39,
11183,
128,
236,
128,
235,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
10344,
22692,
79,
11980,
128,
111,
22,
16237,
128,
240,
47,
128,
242,
128,
241,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24602,
128,
118,
24,
52,
15110,
128,
249,
128,
248,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
899,
275,
334,
199,
198,
85,
2,
16,
12,
31,
1,
6,
32,
29,
10,
6828,
4451,
342,
4,
94,
5,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
30234,
13733,
18,
8390,
128,
228,
128,
227,
401,
199,
198,
85,
2,
318,
5741,
19,
5638,
128,
232,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
21,
24100,
401,
199,
198,
85,
2,
77,
889,
14614,
22,
45,
2826,
128,
245,
401,
199,
198,
85,
2,
26295,
2393,
23,
48,
49,
15062,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
199,
198,
85,
2,
19400,
25,
24648,
401,
199,
198,
9,
199,
5443,
63,
27808,
275,
334,
199,
198,
85,
2,
16,
12,
31,
6828,
4451,
342,
32,
4,
1111,
6,
32639,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
18,
11302,
13733,
31493,
8390,
128,
224,
128,
227,
129,
235,
401,
199,
198,
85,
2,
318,
19,
129,
238,
5741,
129,
250,
5638,
129,
237,
128,
232,
129,
249,
401,
199,
198,
85,
2,
3561,
73,
20,
13676,
39,
11183,
128,
236,
401,
199,
198,
85,
2,
74,
9503,
21,
129,
123,
129,
119,
24100,
129,
122,
129,
118,
401,
199,
198,
85,
2,
77,
889,
22,
130,
231,
11980,
14614,
128,
113,
45,
2826,
130,
230,
128,
242,
128,
245,
128,
243,
401,
199,
198,
85,
2,
26295,
2393,
23,
130,
248,
130,
244,
27273,
48,
49,
15062,
130,
247,
130,
243,
130,
255,
401,
199,
198,
85,
2,
84,
9154,
24,
130,
99,
24602,
130,
108,
17709,
52,
15110,
130,
98,
128,
249,
130,
107,
128,
251,
401,
199,
198,
85,
2,
19400,
25,
128,
122,
29529,
24648,
128,
252,
130,
122,
401,
199,
198,
9,
199,
5443,
63,
2749,
275,
334,
199,
198,
85,
2,
16,
12,
31,
6828,
4451,
342,
32,
4,
1111,
6,
32639,
3,
401,
199,
198,
85,
2,
413,
16781,
22352,
13,
29808,
199,
198,
85,
2,
3175,
129,
228,
129,
230,
18,
8390,
129,
227,
129,
229,
401,
199,
198,
85,
2,
318,
129,
248,
19,
5638,
129,
247,
401,
199,
198,
85,
2,
3561,
73,
20,
39,
11183,
401,
199,
198,
85,
2,
74,
9503,
130,
225,
21,
24100,
130,
224,
401,
199,
198,
85,
2,
77,
889,
130,
227,
11980,
22,
45,
2826,
130,
226,
128,
242,
401,
199,
198,
85,
2,
26295,
2393,
130,
250,
23,
48,
49,
15062,
130,
249,
401,
199,
198,
85,
2,
84,
9154,
24,
52,
15110,
401,
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,
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
] |
ibrahimgunduz34/SpiffWorkflow
|
SpiffWorkflow/specs/SubWorkflow.py
|
2
|
5660
|
# -*- coding: utf-8 -*-
from __future__ import division
# Copyright (C) 2007 Samuel Abels
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
from SpiffWorkflow.Task import Task
from SpiffWorkflow.exceptions import WorkflowException
from SpiffWorkflow.operators import valueof
from SpiffWorkflow.specs.TaskSpec import TaskSpec
import SpiffWorkflow
class SubWorkflow(TaskSpec):
"""
A SubWorkflow is a task that wraps a WorkflowSpec, such that you can
re-use it in multiple places as if it were a task.
If more than one input is connected, the task performs an implicit
multi merge.
If more than one output is connected, the task performs an implicit
parallel split.
"""
def __init__(self,
parent,
name,
file,
in_assign = None,
out_assign = None,
**kwargs):
"""
Constructor.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type file: str
:param file: The name of a file containing a workflow.
:type in_assign: list(str)
:param in_assign: The names of data fields to carry over.
:type out_assign: list(str)
:param out_assign: The names of data fields to carry back.
:type kwargs: dict
:param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
assert parent is not None
assert name is not None
super(SubWorkflow, self).__init__(parent, name, **kwargs)
self.file = None
self.in_assign = in_assign is not None and in_assign or []
self.out_assign = out_assign is not None and out_assign or []
if file is not None:
dirname = os.path.dirname(parent.file)
self.file = os.path.join(dirname, file)
def test(self):
TaskSpec.test(self)
if self.file is not None and not os.path.exists(self.file):
raise WorkflowException(self, 'File does not exist: %s' % self.file)
def _predict_hook(self, my_task):
outputs = [task.task_spec for task in my_task.children]
for output in self.outputs:
if output not in outputs:
outputs.insert(0, output)
if my_task._is_definite():
my_task._sync_children(outputs, Task.FUTURE)
else:
my_task._sync_children(outputs, my_task.state)
def _create_subworkflow(self, my_task):
from SpiffWorkflow.storage import XmlSerializer
from SpiffWorkflow.specs import WorkflowSpec
file = valueof(my_task, self.file)
serializer = XmlSerializer()
xml = open(file).read()
wf_spec = WorkflowSpec.deserialize(serializer, xml, filename = file)
outer_workflow = my_task.workflow.outer_workflow
return SpiffWorkflow.Workflow(wf_spec, parent = outer_workflow)
def _on_ready_before_hook(self, my_task):
subworkflow = self._create_subworkflow(my_task)
subworkflow.completed_event.connect(self._on_subworkflow_completed, my_task)
# Integrate the tree of the subworkflow into the tree of this workflow.
my_task._sync_children(self.outputs, Task.FUTURE)
for child in my_task.children:
child.task_spec._update_state(child)
child._inherit_data()
for child in subworkflow.task_tree.children:
my_task.children.insert(0, child)
child.parent = my_task
my_task._set_internal_data(subworkflow = subworkflow)
def _on_ready_hook(self, my_task):
# Assign variables, if so requested.
subworkflow = my_task._get_internal_data('subworkflow')
for child in subworkflow.task_tree.children:
for assignment in self.in_assign:
assignment.assign(my_task, child)
self._predict(my_task)
for child in subworkflow.task_tree.children:
child.task_spec._update_state(child)
def _on_subworkflow_completed(self, subworkflow, my_task):
# Assign variables, if so requested.
for child in my_task.children:
if child.task_spec in self.outputs:
for assignment in self.out_assign:
assignment.assign(subworkflow, child)
# Alright, abusing that hook is just evil but it works.
child.task_spec._update_state_hook(child)
def _on_complete_hook(self, my_task):
for child in my_task.children:
if child.task_spec in self.outputs:
continue
child.task_spec._update_state(child)
def serialize(self, serializer):
return serializer._serialize_sub_workflow(self)
@classmethod
def deserialize(self, serializer, wf_spec, s_state):
return serializer._deserialize_sub_workflow(wf_spec, s_state)
|
lgpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
4629,
199,
3,
1898,
334,
35,
9,
10219,
428,
455,
13086,
8351,
18099,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
646,
747,
199,
504,
428,
1038,
556,
17527,
14,
4476,
492,
8495,
199,
504,
428,
1038,
556,
17527,
14,
3924,
492,
27282,
1726,
199,
504,
428,
1038,
556,
17527,
14,
12688,
492,
574,
1618,
199,
504,
428,
1038,
556,
17527,
14,
7273,
14,
4476,
5307,
492,
8495,
5307,
199,
646,
428,
1038,
556,
17527,
199,
199,
533,
4804,
17527,
8,
4476,
5307,
304,
272,
408,
272,
437,
4804,
17527,
365,
282,
2120,
626,
14018,
282,
27282,
5307,
12,
4066,
626,
1265,
883,
272,
295,
13,
1180,
652,
315,
3663,
9825,
465,
340,
652,
4898,
282,
2120,
14,
272,
982,
1655,
2419,
1373,
1324,
365,
8539,
12,
314,
2120,
18628,
376,
9227,
272,
3510,
5389,
14,
272,
982,
1655,
2419,
1373,
1072,
365,
8539,
12,
314,
2120,
18628,
376,
9227,
272,
9861,
3715,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
1676,
12,
326,
536,
12,
326,
570,
12,
326,
315,
63,
5038,
275,
488,
12,
326,
734,
63,
5038,
275,
488,
12,
326,
1011,
958,
304,
267,
408,
267,
20297,
14,
398,
520,
466,
221,
1676,
26,
8495,
5307,
267,
520,
635,
1676,
26,
437,
3659,
370,
314,
1676,
2120,
3158,
14,
267,
520,
466,
221,
536,
26,
620,
267,
520,
635,
536,
26,
710,
536,
402,
314,
2120,
3158,
14,
267,
520,
466,
221,
570,
26,
620,
267,
520,
635,
570,
26,
710,
536,
402,
282,
570,
3035,
282,
10431,
14,
267,
520,
466,
221,
315,
63,
5038,
26,
769,
8,
495,
9,
267,
520,
635,
315,
63,
5038,
26,
710,
1561,
402,
666,
1504,
370,
25176,
1806,
14,
267,
520,
466,
221,
734,
63,
5038,
26,
769,
8,
495,
9,
267,
520,
635,
734,
63,
5038,
26,
710,
1561,
402,
666,
1504,
370,
25176,
1771,
14,
267,
520,
466,
221,
2074,
26,
1211,
267,
520,
635,
2074,
26,
1666,
491,
91,
51,
1038,
556,
17527,
14,
7273,
14,
4476,
5307,
5565,
267,
408,
267,
702,
1676,
365,
440,
488,
267,
702,
536,
365,
440,
488,
267,
1613,
8,
2610,
17527,
12,
291,
2843,
826,
721,
1708,
12,
536,
12,
1011,
958,
9,
267,
291,
14,
493,
755,
275,
488,
267,
291,
14,
262,
63,
5038,
221,
275,
315,
63,
5038,
365,
440,
488,
436,
315,
63,
5038,
503,
942,
267,
291,
14,
548,
63,
5038,
275,
734,
63,
5038,
365,
440,
488,
436,
734,
63,
5038,
503,
942,
267,
340,
570,
365,
440,
488,
26,
288,
9017,
257,
275,
747,
14,
515,
14,
3475,
8,
1708,
14,
493,
9,
288,
291,
14,
493,
275,
747,
14,
515,
14,
904,
8,
3475,
12,
570,
9,
339,
347,
511,
8,
277,
304,
267,
8495,
5307,
14,
396,
8,
277,
9,
267,
340,
291,
14,
493,
365,
440,
488,
436,
440,
747,
14,
515,
14,
2444,
8,
277,
14,
493,
304,
288,
746,
27282,
1726,
8,
277,
12,
283,
1173,
1630,
440,
2187,
26,
450,
83,
7,
450,
291,
14,
493,
9,
339,
347,
485,
6892,
63,
3664,
8,
277,
12,
3002,
63,
1765,
304,
267,
4704,
275,
359,
1765,
14,
1765,
63,
1650,
367,
2120,
315,
3002,
63,
1765,
14,
3223,
61,
267,
367,
1072,
315,
291,
14,
4467,
26,
288,
340,
1072,
440,
315,
4704,
26,
355,
4704,
14,
3176,
8,
16,
12,
1072,
9,
267,
340,
3002,
63,
1765,
423,
374,
63,
23442,
837,
288,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
4467,
12,
8495,
14,
20254,
3942,
9,
267,
587,
26,
288,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
4467,
12,
3002,
63,
1765,
14,
929,
9,
339,
347,
485,
981,
63,
954,
8856,
8,
277,
12,
3002,
63,
1765,
304,
267,
687,
428,
1038,
556,
17527,
14,
3494,
492,
24881,
7299,
267,
687,
428,
1038,
556,
17527,
14,
7273,
492,
27282,
5307,
267,
570,
3698,
275,
574,
1618,
8,
1662,
63,
1765,
12,
291,
14,
493,
9,
267,
9146,
258,
275,
24881,
7299,
342,
267,
2748,
3322,
275,
1551,
8,
493,
680,
739,
342,
267,
17328,
63,
1650,
263,
275,
27282,
5307,
14,
11143,
8,
8349,
12,
2748,
12,
1788,
275,
570,
9,
267,
6890,
63,
8856,
275,
3002,
63,
1765,
14,
8856,
14,
7837,
63,
8856,
267,
372,
428,
1038,
556,
17527,
14,
17527,
8,
14114,
63,
1650,
12,
1676,
275,
6890,
63,
8856,
9,
339,
347,
485,
265,
63,
2179,
63,
5182,
63,
3664,
8,
277,
12,
3002,
63,
1765,
304,
267,
1007,
8856,
259,
275,
291,
423,
981,
63,
954,
8856,
8,
1662,
63,
1765,
9,
267,
1007,
8856,
14,
12634,
63,
1430,
14,
2242,
8,
277,
423,
265,
63,
954,
8856,
63,
12634,
12,
3002,
63,
1765,
9,
398,
327,
8883,
14841,
314,
3123,
402,
314,
1007,
8856,
1901,
314,
3123,
402,
642,
10431,
14,
267,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
277,
14,
4467,
12,
8495,
14,
20254,
3942,
9,
267,
367,
1982,
315,
3002,
63,
1765,
14,
3223,
26,
288,
1982,
14,
1765,
63,
1650,
423,
873,
63,
929,
8,
1739,
9,
288,
1982,
423,
6486,
63
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
4629,
199,
3,
1898,
334,
35,
9,
10219,
428,
455,
13086,
8351,
18099,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
221,
8217,
199,
646,
747,
199,
504,
428,
1038,
556,
17527,
14,
4476,
492,
8495,
199,
504,
428,
1038,
556,
17527,
14,
3924,
492,
27282,
1726,
199,
504,
428,
1038,
556,
17527,
14,
12688,
492,
574,
1618,
199,
504,
428,
1038,
556,
17527,
14,
7273,
14,
4476,
5307,
492,
8495,
5307,
199,
646,
428,
1038,
556,
17527,
199,
199,
533,
4804,
17527,
8,
4476,
5307,
304,
272,
408,
272,
437,
4804,
17527,
365,
282,
2120,
626,
14018,
282,
27282,
5307,
12,
4066,
626,
1265,
883,
272,
295,
13,
1180,
652,
315,
3663,
9825,
465,
340,
652,
4898,
282,
2120,
14,
272,
982,
1655,
2419,
1373,
1324,
365,
8539,
12,
314,
2120,
18628,
376,
9227,
272,
3510,
5389,
14,
272,
982,
1655,
2419,
1373,
1072,
365,
8539,
12,
314,
2120,
18628,
376,
9227,
272,
9861,
3715,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
1676,
12,
326,
536,
12,
326,
570,
12,
326,
315,
63,
5038,
275,
488,
12,
326,
734,
63,
5038,
275,
488,
12,
326,
1011,
958,
304,
267,
408,
267,
20297,
14,
398,
520,
466,
221,
1676,
26,
8495,
5307,
267,
520,
635,
1676,
26,
437,
3659,
370,
314,
1676,
2120,
3158,
14,
267,
520,
466,
221,
536,
26,
620,
267,
520,
635,
536,
26,
710,
536,
402,
314,
2120,
3158,
14,
267,
520,
466,
221,
570,
26,
620,
267,
520,
635,
570,
26,
710,
536,
402,
282,
570,
3035,
282,
10431,
14,
267,
520,
466,
221,
315,
63,
5038,
26,
769,
8,
495,
9,
267,
520,
635,
315,
63,
5038,
26,
710,
1561,
402,
666,
1504,
370,
25176,
1806,
14,
267,
520,
466,
221,
734,
63,
5038,
26,
769,
8,
495,
9,
267,
520,
635,
734,
63,
5038,
26,
710,
1561,
402,
666,
1504,
370,
25176,
1771,
14,
267,
520,
466,
221,
2074,
26,
1211,
267,
520,
635,
2074,
26,
1666,
491,
91,
51,
1038,
556,
17527,
14,
7273,
14,
4476,
5307,
5565,
267,
408,
267,
702,
1676,
365,
440,
488,
267,
702,
536,
365,
440,
488,
267,
1613,
8,
2610,
17527,
12,
291,
2843,
826,
721,
1708,
12,
536,
12,
1011,
958,
9,
267,
291,
14,
493,
755,
275,
488,
267,
291,
14,
262,
63,
5038,
221,
275,
315,
63,
5038,
365,
440,
488,
436,
315,
63,
5038,
503,
942,
267,
291,
14,
548,
63,
5038,
275,
734,
63,
5038,
365,
440,
488,
436,
734,
63,
5038,
503,
942,
267,
340,
570,
365,
440,
488,
26,
288,
9017,
257,
275,
747,
14,
515,
14,
3475,
8,
1708,
14,
493,
9,
288,
291,
14,
493,
275,
747,
14,
515,
14,
904,
8,
3475,
12,
570,
9,
339,
347,
511,
8,
277,
304,
267,
8495,
5307,
14,
396,
8,
277,
9,
267,
340,
291,
14,
493,
365,
440,
488,
436,
440,
747,
14,
515,
14,
2444,
8,
277,
14,
493,
304,
288,
746,
27282,
1726,
8,
277,
12,
283,
1173,
1630,
440,
2187,
26,
450,
83,
7,
450,
291,
14,
493,
9,
339,
347,
485,
6892,
63,
3664,
8,
277,
12,
3002,
63,
1765,
304,
267,
4704,
275,
359,
1765,
14,
1765,
63,
1650,
367,
2120,
315,
3002,
63,
1765,
14,
3223,
61,
267,
367,
1072,
315,
291,
14,
4467,
26,
288,
340,
1072,
440,
315,
4704,
26,
355,
4704,
14,
3176,
8,
16,
12,
1072,
9,
267,
340,
3002,
63,
1765,
423,
374,
63,
23442,
837,
288,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
4467,
12,
8495,
14,
20254,
3942,
9,
267,
587,
26,
288,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
4467,
12,
3002,
63,
1765,
14,
929,
9,
339,
347,
485,
981,
63,
954,
8856,
8,
277,
12,
3002,
63,
1765,
304,
267,
687,
428,
1038,
556,
17527,
14,
3494,
492,
24881,
7299,
267,
687,
428,
1038,
556,
17527,
14,
7273,
492,
27282,
5307,
267,
570,
3698,
275,
574,
1618,
8,
1662,
63,
1765,
12,
291,
14,
493,
9,
267,
9146,
258,
275,
24881,
7299,
342,
267,
2748,
3322,
275,
1551,
8,
493,
680,
739,
342,
267,
17328,
63,
1650,
263,
275,
27282,
5307,
14,
11143,
8,
8349,
12,
2748,
12,
1788,
275,
570,
9,
267,
6890,
63,
8856,
275,
3002,
63,
1765,
14,
8856,
14,
7837,
63,
8856,
267,
372,
428,
1038,
556,
17527,
14,
17527,
8,
14114,
63,
1650,
12,
1676,
275,
6890,
63,
8856,
9,
339,
347,
485,
265,
63,
2179,
63,
5182,
63,
3664,
8,
277,
12,
3002,
63,
1765,
304,
267,
1007,
8856,
259,
275,
291,
423,
981,
63,
954,
8856,
8,
1662,
63,
1765,
9,
267,
1007,
8856,
14,
12634,
63,
1430,
14,
2242,
8,
277,
423,
265,
63,
954,
8856,
63,
12634,
12,
3002,
63,
1765,
9,
398,
327,
8883,
14841,
314,
3123,
402,
314,
1007,
8856,
1901,
314,
3123,
402,
642,
10431,
14,
267,
3002,
63,
1765,
423,
5186,
63,
3223,
8,
277,
14,
4467,
12,
8495,
14,
20254,
3942,
9,
267,
367,
1982,
315,
3002,
63,
1765,
14,
3223,
26,
288,
1982,
14,
1765,
63,
1650,
423,
873,
63,
929,
8,
1739,
9,
288,
1982,
423,
6486,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
openstack/python-magnumclient
|
magnumclient/tests/osc/unit/v1/test_clusters.py
|
1
|
17895
|
# Copyright 2016 Easystack. 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 copy
import os
import sys
import tempfile
from unittest import mock
from contextlib import contextmanager
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from unittest.mock import call
from magnumclient import exceptions
from magnumclient.osc.v1 import clusters as osc_clusters
from magnumclient.tests.osc.unit.v1 import fakes as magnum_fakes
class TestCluster(magnum_fakes.TestMagnumClientOSCV1):
def setUp(self):
super(TestCluster, self).setUp()
self.clusters_mock = self.app.client_manager.container_infra.clusters
self.certificates_mock = \
self.app.client_manager.container_infra.certificates
class TestClusterCreate(TestCluster):
def setUp(self):
super(TestClusterCreate, self).setUp()
attr = dict()
attr['name'] = 'fake-cluster-1'
self._cluster = magnum_fakes.FakeCluster.create_one_cluster(attr)
self._default_args = {
'cluster_template_id': 'fake-ct',
'create_timeout': 60,
'discovery_url': None,
'keypair': None,
'master_count': 1,
'name': 'fake-cluster-1',
'node_count': 1,
}
self.clusters_mock.create = mock.Mock()
self.clusters_mock.create.return_value = self._cluster
self.clusters_mock.get = mock.Mock()
self.clusters_mock.get.return_value = copy.deepcopy(self._cluster)
self.clusters_mock.update = mock.Mock()
self.clusters_mock.update.return_value = self._cluster
# Get the command object to test
self.cmd = osc_clusters.CreateCluster(self.app, None)
self.data = tuple(map(lambda x: getattr(self._cluster, x),
osc_clusters.CLUSTER_ATTRIBUTES))
def test_cluster_create_required_args_pass(self):
"""Verifies required arguments."""
arglist = [
'--cluster-template', self._cluster.cluster_template_id,
self._cluster.name
]
verifylist = [
('cluster_template', self._cluster.cluster_template_id),
('name', self._cluster.name)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.create.assert_called_with(**self._default_args)
def test_cluster_create_missing_required_arg(self):
"""Verifies missing required arguments."""
arglist = [
self._cluster.name
]
verifylist = [
('name', self._cluster.name)
]
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
def test_cluster_create_with_labels(self):
"""Verifies labels are properly parsed when given as argument."""
expected_args = self._default_args
expected_args['labels'] = {
'arg1': 'value1', 'arg2': 'value2'
}
arglist = [
'--cluster-template', self._cluster.cluster_template_id,
'--labels', 'arg1=value1',
'--labels', 'arg2=value2',
self._cluster.name
]
verifylist = [
('cluster_template', self._cluster.cluster_template_id),
('labels', ['arg1=value1', 'arg2=value2']),
('name', self._cluster.name)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.create.assert_called_with(**expected_args)
def test_cluster_create_with_lb_disabled(self):
"""Verifies master lb disabled properly parsed."""
expected_args = self._default_args
expected_args['master_lb_enabled'] = False
arglist = [
'--cluster-template', self._cluster.cluster_template_id,
'--master-lb-disabled',
self._cluster.name
]
verifylist = [
('cluster_template', self._cluster.cluster_template_id),
('master_lb_enabled', [False]),
('name', self._cluster.name)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.create.assert_called_with(**expected_args)
class TestClusterDelete(TestCluster):
def setUp(self):
super(TestClusterDelete, self).setUp()
self.clusters_mock.delete = mock.Mock()
self.clusters_mock.delete.return_value = None
# Get the command object to test
self.cmd = osc_clusters.DeleteCluster(self.app, None)
def test_cluster_delete_one(self):
arglist = ['foo']
verifylist = [('cluster', ['foo'])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.delete.assert_called_with('foo')
def test_cluster_delete_multiple(self):
arglist = ['foo', 'bar']
verifylist = [('cluster', ['foo', 'bar'])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.delete.assert_has_calls([call('foo'), call('bar')])
def test_cluster_delete_bad_uuid(self):
arglist = ['foo']
verifylist = [('cluster', ['foo'])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
returns = self.cmd.take_action(parsed_args)
self.assertEqual(returns, None)
def test_cluster_delete_no_uuid(self):
arglist = []
verifylist = [('cluster', [])]
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
class TestClusterList(TestCluster):
attr = dict()
attr['name'] = 'fake-cluster-1'
_cluster = magnum_fakes.FakeCluster.create_one_cluster(attr)
columns = [
'uuid',
'name',
'keypair',
'node_count',
'master_count',
'status',
'health_status'
]
datalist = (
(
_cluster.uuid,
_cluster.name,
_cluster.keypair,
_cluster.node_count,
_cluster.master_count,
_cluster.status,
_cluster.health_status,
),
)
def setUp(self):
super(TestClusterList, self).setUp()
self.clusters_mock.list = mock.Mock()
self.clusters_mock.list.return_value = [self._cluster]
# Get the command object to test
self.cmd = osc_clusters.ListCluster(self.app, None)
def test_cluster_list_no_options(self):
arglist = []
verifylist = [
('limit', None),
('sort_key', None),
('sort_dir', None),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.clusters_mock.list.assert_called_with(
limit=None,
sort_dir=None,
sort_key=None,
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
def test_cluster_list_options(self):
arglist = [
'--limit', '1',
'--sort-key', 'key',
'--sort-dir', 'asc'
]
verifylist = [
('limit', 1),
('sort_key', 'key'),
('sort_dir', 'asc')
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.list.assert_called_with(
limit=1,
sort_dir='asc',
sort_key='key',
)
def test_cluster_list_bad_sort_dir_fail(self):
arglist = [
'--sort-dir', 'foo'
]
verifylist = [
('limit', None),
('sort_key', None),
('sort_dir', 'foo'),
('fields', None),
]
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
class TestClusterUpdate(TestCluster):
def setUp(self):
super(TestClusterUpdate, self).setUp()
self.clusters_mock.update = mock.Mock()
self.clusters_mock.update.return_value = None
# Get the command object to test
self.cmd = osc_clusters.UpdateCluster(self.app, None)
def test_cluster_update_pass(self):
arglist = ['foo', 'remove', 'bar']
verifylist = [
('cluster', 'foo'),
('op', 'remove'),
('attributes', [['bar']]),
('rollback', False)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.update.assert_called_with(
'foo',
[{'op': 'remove', 'path': '/bar'}]
)
def test_cluster_update_bad_op(self):
arglist = ['foo', 'bar', 'snafu']
verifylist = [
('cluster', 'foo'),
('op', 'bar'),
('attributes', ['snafu']),
('rollback', False)
]
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
class TestClusterShow(TestCluster):
def setUp(self):
super(TestClusterShow, self).setUp()
attr = dict()
attr['name'] = 'fake-cluster-1'
self._cluster = magnum_fakes.FakeCluster.create_one_cluster(attr)
self.clusters_mock.get = mock.Mock()
self.clusters_mock.get.return_value = self._cluster
# Get the command object to test
self.cmd = osc_clusters.ShowCluster(self.app, None)
self.data = tuple(map(lambda x: getattr(self._cluster, x),
osc_clusters.CLUSTER_ATTRIBUTES))
def test_cluster_show_pass(self):
arglist = ['fake-cluster']
verifylist = [
('cluster', 'fake-cluster')
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.clusters_mock.get.assert_called_with('fake-cluster')
self.assertEqual(osc_clusters.CLUSTER_ATTRIBUTES, columns)
self.assertEqual(self.data, data)
def test_cluster_show_no_cluster_fail(self):
arglist = []
verifylist = []
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
@contextmanager
def capture(command, *args, **kwargs):
out, sys.stdout = sys.stdout, StringIO()
try:
command(*args, **kwargs)
sys.stdout.seek(0)
yield sys.stdout.read()
finally:
sys.stdout = out
class TestClusterConfig(TestCluster):
def setUp(self):
super(TestClusterConfig, self).setUp()
attr = dict()
attr['name'] = 'fake-cluster-1'
attr['status'] = 'CREATE_COMPLETE'
self._cluster = magnum_fakes.FakeCluster.create_one_cluster(attr)
self.clusters_mock.get = mock.Mock()
self.clusters_mock.get.return_value = self._cluster
cert = magnum_fakes.FakeCert(pem='foo bar')
self.certificates_mock.create = mock.Mock()
self.certificates_mock.create.return_value = cert
self.certificates_mock.get = mock.Mock()
self.certificates_mock.get.return_value = cert
# Fake the cluster_template
attr = dict()
attr['name'] = 'fake-ct'
self._cluster_template = \
magnum_fakes.FakeClusterTemplate.create_one_cluster_template(attr)
self.cluster_templates_mock = \
self.app.client_manager.container_infra.cluster_templates
self.cluster_templates_mock.get = mock.Mock()
self.cluster_templates_mock.get.return_value = self._cluster_template
# Get the command object to test
self.cmd = osc_clusters.ConfigCluster(self.app, None)
def test_cluster_config_no_cluster_fail(self):
arglist = []
verifylist = []
self.assertRaises(magnum_fakes.MagnumParseException,
self.check_parser, self.cmd, arglist, verifylist)
@mock.patch.dict(os.environ, {'SHELL': '/bin/bash'})
def test_cluster_config_custom_dir_with_config_only_works_if_force(self):
tmp_dir = tempfile.mkdtemp()
open(os.path.join(tmp_dir, 'config'), 'a').close() # touch config
arglist = ['fake-cluster', '--dir', tmp_dir]
verifylist = [
('cluster', 'fake-cluster'),
('force', False),
('dir', tmp_dir),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.CommandError,
self.cmd.take_action, parsed_args)
self.clusters_mock.get.assert_called_with('fake-cluster')
arglist = ['fake-cluster', '--force', '--dir', tmp_dir]
verifylist = [
('cluster', 'fake-cluster'),
('force', True),
('dir', tmp_dir),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
expected_value = '''\
export KUBECONFIG={}/config
'''.format(tmp_dir)
with capture(self.cmd.take_action, parsed_args) as output:
self.assertEqual(expected_value, output)
self.clusters_mock.get.assert_called_with('fake-cluster')
@mock.patch.dict(os.environ, {'SHELL': '/bin/bash'})
def test_cluster_config_with_custom_dir(self):
tmp_dir = tempfile.mkdtemp()
arglist = ['fake-cluster', '--dir', tmp_dir]
verifylist = [
('cluster', 'fake-cluster'),
('dir', tmp_dir),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
expected_value = '''\
export KUBECONFIG={}/config
'''.format(tmp_dir)
with capture(self.cmd.take_action, parsed_args) as output:
self.assertEqual(expected_value, output)
self.clusters_mock.get.assert_called_with('fake-cluster')
@mock.patch.dict(os.environ, {'SHELL': '/bin/bash'})
def test_cluster_config_creates_config_in_cwd_if_not_dir_specified(self):
tmp_dir = tempfile.mkdtemp()
os.chdir(tmp_dir)
arglist = ['fake-cluster']
verifylist = [
('cluster', 'fake-cluster'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
expected_value = '''\
export KUBECONFIG={}/config
'''.format(os.getcwd())
with capture(self.cmd.take_action, parsed_args) as output:
self.assertEqual(expected_value, output)
self.clusters_mock.get.assert_called_with('fake-cluster')
class TestClusterResize(TestCluster):
def setUp(self):
super(TestClusterResize, self).setUp()
self.cluster = mock.Mock()
self.cluster.uuid = "UUID1"
self.clusters_mock.resize = mock.Mock()
self.clusters_mock.resize.return_value = None
self.clusters_mock.get = mock.Mock()
self.clusters_mock.get.return_value = self.cluster
# Get the command object to test
self.cmd = osc_clusters.ResizeCluster(self.app, None)
def test_cluster_resize_pass(self):
arglist = ['foo', '2']
verifylist = [
('cluster', 'foo'),
('node_count', 2),
('nodes_to_remove', None),
('nodegroup', None)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.resize.assert_called_with(
"UUID1", 2, None, None
)
def test_cluster_resize_to_zero_pass(self):
arglist = ['foo', '0']
verifylist = [
('cluster', 'foo'),
('node_count', 0),
('nodes_to_remove', None),
('nodegroup', None)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.resize.assert_called_with(
"UUID1", 0, None, None
)
class TestClusterUpgrade(TestCluster):
def setUp(self):
super(TestClusterUpgrade, self).setUp()
self.cluster = mock.Mock()
self.cluster.uuid = "UUID1"
self.clusters_mock.upgrade = mock.Mock()
self.clusters_mock.upgrade.return_value = None
self.clusters_mock.get = mock.Mock()
self.clusters_mock.get.return_value = self.cluster
# Get the command object to test
self.cmd = osc_clusters.UpgradeCluster(self.app, None)
def test_cluster_upgrade_pass(self):
cluster_template_id = 'TEMPLATE_ID'
arglist = ['foo', cluster_template_id]
verifylist = [
('cluster', 'foo'),
('cluster_template', cluster_template_id),
('max_batch_size', 1),
('nodegroup', None)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.clusters_mock.upgrade.assert_called_with(
"UUID1", cluster_template_id, 1, None
)
|
apache-2.0
|
[
3,
257,
1898,
7800,
18951,
2340,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
257,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
257,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
263,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
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,
2428,
199,
3,
257,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
257,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
257,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
1331,
199,
646,
747,
199,
646,
984,
199,
646,
5549,
199,
504,
2882,
492,
1683,
199,
199,
504,
15502,
492,
27608,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
504,
2882,
14,
1805,
492,
1240,
199,
199,
504,
15916,
453,
1258,
492,
4967,
199,
504,
15916,
453,
1258,
14,
26737,
14,
86,
17,
492,
13865,
465,
31920,
63,
9170,
199,
504,
15916,
453,
1258,
14,
2219,
14,
26737,
14,
3248,
14,
86,
17,
492,
14063,
465,
15916,
453,
63,
27443,
421,
199,
533,
1379,
9581,
8,
19902,
453,
63,
27443,
14,
774,
22745,
1507,
3041,
3100,
12847,
17,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
9581,
12,
291,
680,
5996,
342,
398,
291,
14,
9170,
63,
1805,
275,
291,
14,
571,
14,
1258,
63,
2609,
14,
3600,
63,
19505,
14,
9170,
267,
291,
14,
16159,
63,
1805,
275,
971,
288,
291,
14,
571,
14,
1258,
63,
2609,
14,
3600,
63,
19505,
14,
16159,
421,
199,
533,
1379,
9581,
2499,
8,
774,
9581,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
9581,
2499,
12,
291,
680,
5996,
342,
398,
1921,
275,
1211,
342,
267,
1921,
459,
354,
418,
275,
283,
3183,
13,
4201,
13,
17,
7,
267,
291,
423,
4201,
275,
15916,
453,
63,
27443,
14,
8249,
9581,
14,
981,
63,
368,
63,
4201,
8,
962,
9,
398,
291,
423,
885,
63,
589,
275,
469,
288,
283,
4201,
63,
1160,
63,
344,
356,
283,
3183,
13,
319,
297,
288,
283,
981,
63,
2593,
356,
5212,
12,
288,
283,
14859,
63,
633,
356,
488,
12,
288,
283,
19263,
356,
488,
12,
288,
283,
4133,
63,
835,
356,
413,
12,
288,
283,
354,
356,
283,
3183,
13,
4201,
13,
17,
297,
288,
283,
932,
63,
835,
356,
413,
12,
267,
789,
398,
291,
14,
9170,
63,
1805,
14,
981,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
981,
14,
1107,
63,
585,
275,
291,
423,
4201,
398,
291,
14,
9170,
63,
1805,
14,
362,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
362,
14,
1107,
63,
585,
275,
1331,
14,
8293,
8,
277,
423,
4201,
9,
398,
291,
14,
9170,
63,
1805,
14,
873,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
873,
14,
1107,
63,
585,
275,
291,
423,
4201,
398,
327,
2372,
314,
1414,
909,
370,
511,
267,
291,
14,
1760,
275,
31920,
63,
9170,
14,
2499,
9581,
8,
277,
14,
571,
12,
488,
9,
398,
291,
14,
576,
275,
2008,
8,
1130,
8,
2734,
671,
26,
2519,
8,
277,
423,
4201,
12,
671,
395,
2892,
31920,
63,
9170,
14,
26340,
63,
18166,
430,
339,
347,
511,
63,
4201,
63,
981,
63,
2427,
63,
589,
63,
1529,
8,
277,
304,
267,
408,
21168,
1415,
2368,
1041,
398,
24660,
275,
359,
288,
2850,
4201,
13,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
12,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
4201,
63,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
395,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
4565,
63,
589,
275,
291,
14,
1074,
63,
2087,
8,
277,
14,
1760,
12,
24660,
12,
4911,
513,
9,
267,
291,
14,
1760,
14,
11066,
63,
1287,
8,
6751,
63,
589,
9,
267,
291,
14,
9170,
63,
1805,
14,
981,
14,
479,
63,
3527,
63,
1045,
3682,
277,
423,
885,
63,
589,
9,
339,
347,
511,
63,
4201,
63,
981,
63,
4752,
63,
2427,
63,
1273,
8,
277,
304,
267,
408,
21168,
4124,
1415,
2368,
1041,
398,
24660,
275,
359,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
291,
14,
1855,
8,
19902,
453,
63,
27443,
14,
22745,
1507,
4003,
1726,
12,
2079,
291,
14,
1074,
63,
2087,
12,
291,
14,
1760,
12,
24660,
12,
4911,
513,
9,
339,
347,
511,
63,
4201,
63,
981,
63,
1045,
63,
3512,
8,
277,
304,
267,
408,
21168,
3628,
787,
7684,
4565,
1380,
1627,
465,
1423,
1041,
398,
1420,
63,
589,
275,
291,
423,
885,
63,
589,
267,
1420,
63,
589,
459,
3512,
418,
275,
469,
288,
283,
1273,
17,
356,
283,
585,
17,
297,
283,
1273,
18,
356,
283,
585,
18,
7,
267,
789,
398,
24660,
275,
359,
288,
2850,
4201,
13,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
12,
288,
2850,
3512,
297,
283,
1273,
17,
29,
585,
17,
297,
288,
2850,
3512,
297,
283,
1273,
18,
29,
585,
18,
297,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
4201,
63,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
395,
288,
661,
3512,
297,
788,
1273,
17,
29,
585,
17,
297,
283,
1273,
18,
29,
585,
18,
3815,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
4565,
63,
589,
275,
291,
14,
1074,
63,
2087,
8,
277,
14,
1760,
12,
24660,
12,
4911,
513,
9,
267,
291,
14,
1760,
14,
11066,
63,
1287,
8,
6751,
63,
589
] |
[
257,
1898,
7800,
18951,
2340,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
257,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
257,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
263,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
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,
2428,
199,
3,
257,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
257,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
257,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
1331,
199,
646,
747,
199,
646,
984,
199,
646,
5549,
199,
504,
2882,
492,
1683,
199,
199,
504,
15502,
492,
27608,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
504,
2882,
14,
1805,
492,
1240,
199,
199,
504,
15916,
453,
1258,
492,
4967,
199,
504,
15916,
453,
1258,
14,
26737,
14,
86,
17,
492,
13865,
465,
31920,
63,
9170,
199,
504,
15916,
453,
1258,
14,
2219,
14,
26737,
14,
3248,
14,
86,
17,
492,
14063,
465,
15916,
453,
63,
27443,
421,
199,
533,
1379,
9581,
8,
19902,
453,
63,
27443,
14,
774,
22745,
1507,
3041,
3100,
12847,
17,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
9581,
12,
291,
680,
5996,
342,
398,
291,
14,
9170,
63,
1805,
275,
291,
14,
571,
14,
1258,
63,
2609,
14,
3600,
63,
19505,
14,
9170,
267,
291,
14,
16159,
63,
1805,
275,
971,
288,
291,
14,
571,
14,
1258,
63,
2609,
14,
3600,
63,
19505,
14,
16159,
421,
199,
533,
1379,
9581,
2499,
8,
774,
9581,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
9581,
2499,
12,
291,
680,
5996,
342,
398,
1921,
275,
1211,
342,
267,
1921,
459,
354,
418,
275,
283,
3183,
13,
4201,
13,
17,
7,
267,
291,
423,
4201,
275,
15916,
453,
63,
27443,
14,
8249,
9581,
14,
981,
63,
368,
63,
4201,
8,
962,
9,
398,
291,
423,
885,
63,
589,
275,
469,
288,
283,
4201,
63,
1160,
63,
344,
356,
283,
3183,
13,
319,
297,
288,
283,
981,
63,
2593,
356,
5212,
12,
288,
283,
14859,
63,
633,
356,
488,
12,
288,
283,
19263,
356,
488,
12,
288,
283,
4133,
63,
835,
356,
413,
12,
288,
283,
354,
356,
283,
3183,
13,
4201,
13,
17,
297,
288,
283,
932,
63,
835,
356,
413,
12,
267,
789,
398,
291,
14,
9170,
63,
1805,
14,
981,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
981,
14,
1107,
63,
585,
275,
291,
423,
4201,
398,
291,
14,
9170,
63,
1805,
14,
362,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
362,
14,
1107,
63,
585,
275,
1331,
14,
8293,
8,
277,
423,
4201,
9,
398,
291,
14,
9170,
63,
1805,
14,
873,
275,
1683,
14,
3346,
342,
267,
291,
14,
9170,
63,
1805,
14,
873,
14,
1107,
63,
585,
275,
291,
423,
4201,
398,
327,
2372,
314,
1414,
909,
370,
511,
267,
291,
14,
1760,
275,
31920,
63,
9170,
14,
2499,
9581,
8,
277,
14,
571,
12,
488,
9,
398,
291,
14,
576,
275,
2008,
8,
1130,
8,
2734,
671,
26,
2519,
8,
277,
423,
4201,
12,
671,
395,
2892,
31920,
63,
9170,
14,
26340,
63,
18166,
430,
339,
347,
511,
63,
4201,
63,
981,
63,
2427,
63,
589,
63,
1529,
8,
277,
304,
267,
408,
21168,
1415,
2368,
1041,
398,
24660,
275,
359,
288,
2850,
4201,
13,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
12,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
4201,
63,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
395,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
4565,
63,
589,
275,
291,
14,
1074,
63,
2087,
8,
277,
14,
1760,
12,
24660,
12,
4911,
513,
9,
267,
291,
14,
1760,
14,
11066,
63,
1287,
8,
6751,
63,
589,
9,
267,
291,
14,
9170,
63,
1805,
14,
981,
14,
479,
63,
3527,
63,
1045,
3682,
277,
423,
885,
63,
589,
9,
339,
347,
511,
63,
4201,
63,
981,
63,
4752,
63,
2427,
63,
1273,
8,
277,
304,
267,
408,
21168,
4124,
1415,
2368,
1041,
398,
24660,
275,
359,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
291,
14,
1855,
8,
19902,
453,
63,
27443,
14,
22745,
1507,
4003,
1726,
12,
2079,
291,
14,
1074,
63,
2087,
12,
291,
14,
1760,
12,
24660,
12,
4911,
513,
9,
339,
347,
511,
63,
4201,
63,
981,
63,
1045,
63,
3512,
8,
277,
304,
267,
408,
21168,
3628,
787,
7684,
4565,
1380,
1627,
465,
1423,
1041,
398,
1420,
63,
589,
275,
291,
423,
885,
63,
589,
267,
1420,
63,
589,
459,
3512,
418,
275,
469,
288,
283,
1273,
17,
356,
283,
585,
17,
297,
283,
1273,
18,
356,
283,
585,
18,
7,
267,
789,
398,
24660,
275,
359,
288,
2850,
4201,
13,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
12,
288,
2850,
3512,
297,
283,
1273,
17,
29,
585,
17,
297,
288,
2850,
3512,
297,
283,
1273,
18,
29,
585,
18,
297,
288,
291,
423,
4201,
14,
354,
267,
1622,
267,
4911,
513,
275,
359,
288,
661,
4201,
63,
1160,
297,
291,
423,
4201,
14,
4201,
63,
1160,
63,
344,
395,
288,
661,
3512,
297,
788,
1273,
17,
29,
585,
17,
297,
283,
1273,
18,
29,
585,
18,
3815,
288,
661,
354,
297,
291,
423,
4201,
14,
354,
9,
267,
1622,
267,
4565,
63,
589,
275,
291,
14,
1074,
63,
2087,
8,
277,
14,
1760,
12,
24660,
12,
4911,
513,
9,
267,
291,
14,
1760,
14,
11066,
63,
1287,
8,
6751,
63,
589,
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,
1
] |
leekchan/django_test
|
django/core/mail/backends/console.py
|
696
|
1477
|
"""
Email backend that writes messages to console instead of sending them.
"""
import sys
import threading
from django.core.mail.backends.base import BaseEmailBackend
from django.utils import six
class EmailBackend(BaseEmailBackend):
def __init__(self, *args, **kwargs):
self.stream = kwargs.pop('stream', sys.stdout)
self._lock = threading.RLock()
super(EmailBackend, self).__init__(*args, **kwargs)
def write_message(self, message):
msg = message.message()
msg_data = msg.as_bytes()
if six.PY3:
charset = msg.get_charset().get_output_charset() if msg.get_charset() else 'utf-8'
msg_data = msg_data.decode(charset)
self.stream.write('%s\n' % msg_data)
self.stream.write('-' * 79)
self.stream.write('\n')
def send_messages(self, email_messages):
"""Write all messages to the stream in a thread-safe way."""
if not email_messages:
return
msg_count = 0
with self._lock:
try:
stream_created = self.open()
for message in email_messages:
self.write_message(message)
self.stream.flush() # flush after each message
msg_count += 1
if stream_created:
self.close()
except Exception:
if not self.fail_silently:
raise
return msg_count
|
bsd-3-clause
|
[
624,
199,
7035,
4865,
626,
14511,
3788,
370,
8559,
3140,
402,
10209,
3062,
14,
199,
624,
199,
646,
984,
199,
646,
5796,
199,
199,
504,
1639,
14,
1018,
14,
1198,
14,
7765,
14,
1095,
492,
3523,
7035,
8447,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
11426,
8447,
8,
1563,
7035,
8447,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
1745,
275,
2074,
14,
1935,
360,
1745,
297,
984,
14,
2703,
9,
267,
291,
423,
831,
275,
5796,
14,
30550,
342,
267,
1613,
8,
7035,
8447,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
2218,
63,
1188,
8,
277,
12,
1245,
304,
267,
1499,
275,
1245,
14,
1188,
342,
267,
1499,
63,
576,
275,
1499,
14,
305,
63,
2394,
342,
267,
340,
3816,
14,
4521,
19,
26,
288,
5960,
275,
1499,
14,
362,
63,
6043,
1252,
362,
63,
1199,
63,
6043,
342,
340,
1499,
14,
362,
63,
6043,
342,
587,
283,
1624,
13,
24,
7,
288,
1499,
63,
576,
275,
1499,
63,
576,
14,
2708,
8,
6043,
9,
267,
291,
14,
1745,
14,
952,
3508,
83,
60,
78,
7,
450,
1499,
63,
576,
9,
267,
291,
14,
1745,
14,
952,
3654,
7,
627,
13734,
9,
267,
291,
14,
1745,
14,
952,
2258,
78,
358,
339,
347,
3222,
63,
3431,
8,
277,
12,
3031,
63,
3431,
304,
267,
408,
3534,
1006,
3788,
370,
314,
2547,
315,
282,
2462,
13,
3489,
4340,
1041,
267,
340,
440,
3031,
63,
3431,
26,
288,
372,
267,
1499,
63,
835,
275,
378,
267,
543,
291,
423,
831,
26,
288,
862,
26,
355,
2547,
63,
3966,
275,
291,
14,
1490,
342,
355,
367,
1245,
315,
3031,
63,
3431,
26,
490,
291,
14,
952,
63,
1188,
8,
1188,
9,
490,
291,
14,
1745,
14,
4939,
342,
221,
327,
8976,
2410,
1924,
1245,
490,
1499,
63,
835,
847,
413,
355,
340,
2547,
63,
3966,
26,
490,
291,
14,
1600,
342,
288,
871,
2186,
26,
355,
340,
440,
291,
14,
1633,
63,
25163,
26,
490,
746,
267,
372,
1499,
63,
835,
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
] |
[
199,
7035,
4865,
626,
14511,
3788,
370,
8559,
3140,
402,
10209,
3062,
14,
199,
624,
199,
646,
984,
199,
646,
5796,
199,
199,
504,
1639,
14,
1018,
14,
1198,
14,
7765,
14,
1095,
492,
3523,
7035,
8447,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
11426,
8447,
8,
1563,
7035,
8447,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
1745,
275,
2074,
14,
1935,
360,
1745,
297,
984,
14,
2703,
9,
267,
291,
423,
831,
275,
5796,
14,
30550,
342,
267,
1613,
8,
7035,
8447,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
2218,
63,
1188,
8,
277,
12,
1245,
304,
267,
1499,
275,
1245,
14,
1188,
342,
267,
1499,
63,
576,
275,
1499,
14,
305,
63,
2394,
342,
267,
340,
3816,
14,
4521,
19,
26,
288,
5960,
275,
1499,
14,
362,
63,
6043,
1252,
362,
63,
1199,
63,
6043,
342,
340,
1499,
14,
362,
63,
6043,
342,
587,
283,
1624,
13,
24,
7,
288,
1499,
63,
576,
275,
1499,
63,
576,
14,
2708,
8,
6043,
9,
267,
291,
14,
1745,
14,
952,
3508,
83,
60,
78,
7,
450,
1499,
63,
576,
9,
267,
291,
14,
1745,
14,
952,
3654,
7,
627,
13734,
9,
267,
291,
14,
1745,
14,
952,
2258,
78,
358,
339,
347,
3222,
63,
3431,
8,
277,
12,
3031,
63,
3431,
304,
267,
408,
3534,
1006,
3788,
370,
314,
2547,
315,
282,
2462,
13,
3489,
4340,
1041,
267,
340,
440,
3031,
63,
3431,
26,
288,
372,
267,
1499,
63,
835,
275,
378,
267,
543,
291,
423,
831,
26,
288,
862,
26,
355,
2547,
63,
3966,
275,
291,
14,
1490,
342,
355,
367,
1245,
315,
3031,
63,
3431,
26,
490,
291,
14,
952,
63,
1188,
8,
1188,
9,
490,
291,
14,
1745,
14,
4939,
342,
221,
327,
8976,
2410,
1924,
1245,
490,
1499,
63,
835,
847,
413,
355,
340,
2547,
63,
3966,
26,
490,
291,
14,
1600,
342,
288,
871,
2186,
26,
355,
340,
440,
291,
14,
1633,
63,
25163,
26,
490,
746,
267,
372,
1499,
63,
835,
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,
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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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
] |
blab/antibody-response-pulse
|
bcell-array/code/Virus_Bcell_IgM_IgG_Infection_OAS_new.py
|
1
|
13195
|
# coding: utf-8
# # Antibody Response Pulse
# https://github.com/blab/antibody-response-pulse
#
# ### B-cells evolution --- cross-reactive antibody response after influenza virus infection or vaccination
# ### Adaptive immune response for repeated infection
# In[3]:
'''
author: Alvason Zhenhua Li
date: 04/09/2015
'''
get_ipython().magic(u'matplotlib inline')
import numpy as np
import matplotlib.pyplot as plt
import os
from matplotlib.ticker import FuncFormatter
import alva_machinery_event_OAS_new as alva
AlvaFontSize = 23
AlvaFigSize = (15, 5)
numberingFig = 0
# plotting
dir_path = '/Users/al/Desktop/GitHub/antibody-response-pulse/bcell-array/figure'
file_name = 'Virus-Bcell-IgM-IgG'
figure_name = '-equation'
file_suffix = '.png'
save_figure = os.path.join(dir_path, file_name + figure_name + file_suffix)
numberingFig = numberingFig + 1
plt.figure(numberingFig, figsize=(12, 5))
plt.axis('off')
plt.title(r'$ Virus-Bcell-IgM-IgG \ equations \ (antibody-response \ for \ repeated-infection) $'
, fontsize = AlvaFontSize)
plt.text(0, 7.0/9, r'$ \frac{\partial V_n(t)}{\partial t} = +\mu_{v}V_{n}(t)(1 - \frac{V_n(t)}{V_{max}}) - \phi_{m} M_{n}(t) V_{n}(t) - \phi_{g} G_{n}(t) V_{n}(t) $'
, fontsize = 1.2*AlvaFontSize)
plt.text(0, 5.0/9, r'$ \frac{\partial B_n(t)}{\partial t} = +\mu_{b}V_{n}(t)(1 - \frac{V_n(t)}{V_{max}}) + (\beta_{m} + \beta_{g}) V_{n}(t) B_{n}(t) - \mu_{b} B_{n}(t) + m_b V_{n}(t)\frac{B_{i-1}(t) - 2B_i(t) + B_{i+1}(t)}{(\Delta i)^2} $'
, fontsize = 1.2*AlvaFontSize)
plt.text(0, 3.0/9,r'$ \frac{\partial M_n(t)}{\partial t} = +\xi_{m} B_{n}(t) - \phi_{m} M_{n}(t) V_{n}(t) - \mu_{m} M_{n}(t) $'
, fontsize = 1.2*AlvaFontSize)
plt.text(0, 1.0/9,r'$ \frac{\partial G_n(t)}{\partial t} = +\xi_{g} B_{n}(t) - \phi_{g} G_{n}(t) V_{n}(t) - \mu_{g} G_{n}(t) + m_a V_{n}(t)\frac{G_{i-1}(t) - 2G_i(t) + G_{i+1}(t)}{(\Delta i)^2} $'
, fontsize = 1.2*AlvaFontSize)
plt.savefig(save_figure, dpi = 100)
plt.show()
# define the V-M-G partial differential equations
def dVdt_array(VBMGxt = [], *args):
# naming
V = VBMGxt[0]
B = VBMGxt[1]
M = VBMGxt[2]
G = VBMGxt[3]
x_totalPoint = VBMGxt.shape[1]
# there are n dSdt
dV_dt_array = np.zeros(x_totalPoint)
# each dSdt with the same equation form
dV_dt_array[:] = +inRateV*V[:]*(1 - V[:]/maxV) - killRateVm*M[:]*V[:] - killRateVg*G[:]*V[:]
return(dV_dt_array)
def dBdt_array(VBMGxt = [], *args):
# naming
V = VBMGxt[0]
B = VBMGxt[1]
M = VBMGxt[2]
G = VBMGxt[3]
x_totalPoint = VBMGxt.shape[1]
# there are n dSdt
dB_dt_array = np.zeros(x_totalPoint)
# each dSdt with the same equation form
Bcopy = np.copy(B)
centerX = Bcopy[:]
leftX = np.roll(Bcopy[:], 1)
rightX = np.roll(Bcopy[:], -1)
leftX[0] = centerX[0]
rightX[-1] = centerX[-1]
dB_dt_array[:] = +inRateB*V[:]*(1 - V[:]/maxV) + (actRateBm + alva.event_active + alva.event_OAS_B)*V[:]*B[:] - outRateB*B[:] + mutatRateB*V[:]*(leftX[:] - 2*centerX[:] + rightX[:])/(dx**2)
return(dB_dt_array)
def dMdt_array(VBMGxt = [], *args):
# naming
V = VBMGxt[0]
B = VBMGxt[1]
M = VBMGxt[2]
G = VBMGxt[3]
x_totalPoint = VBMGxt.shape[1]
# there are n dSdt
dM_dt_array = np.zeros(x_totalPoint)
# each dSdt with the same equation form
dM_dt_array[:] = +inRateM*B[:] - consumeRateM*M[:]*V[:] - outRateM*M[:]
return(dM_dt_array)
def dGdt_array(VBMGxt = [], *args):
# naming
V = VBMGxt[0]
B = VBMGxt[1]
M = VBMGxt[2]
G = VBMGxt[3]
x_totalPoint = VBMGxt.shape[1]
# there are n dSdt
dG_dt_array = np.zeros(x_totalPoint)
# each dSdt with the same equation form
Gcopy = np.copy(G)
centerX = Gcopy[:]
leftX = np.roll(Gcopy[:], 1)
rightX = np.roll(Gcopy[:], -1)
leftX[0] = centerX[0]
rightX[-1] = centerX[-1]
dG_dt_array[:] = +(inRateG + alva.event_OAS)*B[:] - consumeRateG*G[:]*V[:] - outRateG*G[:] + mutatRateA*(leftX[:] - 2*centerX[:] + rightX[:])/(dx**2)
return(dG_dt_array)
# In[7]:
# setting parameter
timeUnit = 'day'
if timeUnit == 'hour':
hour = float(1)
day = float(24)
elif timeUnit == 'day':
day = float(1)
hour = float(1)/24
elif timeUnit == 'year':
year = float(1)
day = float(1)/365
hour = float(1)/24/365
maxV = float(50) # max virus/micro-liter
inRateV = 0.2/hour # in-rate of virus
killRateVm = 0.0003/hour # kill-rate of virus by antibody-IgM
killRateVg = killRateVm # kill-rate of virus by antibody-IgG
inRateB = 0.06/hour # in-rate of B-cell
outRateB = inRateB/8 # out-rate of B-cell
actRateBm = killRateVm # activation rate of naive B-cell
inRateM = 0.16/hour # in-rate of antibody-IgM from naive B-cell
outRateM = inRateM/1 # out-rate of antibody-IgM from naive B-cell
consumeRateM = killRateVm # consume-rate of antibody-IgM by cleaning virus
inRateG = inRateM/10 # in-rate of antibody-IgG from memory B-cell
outRateG = outRateM/250 # out-rate of antibody-IgG from memory B-cell
consumeRateG = killRateVg # consume-rate of antibody-IgG by cleaning virus
mutatRateB = 0.00003/hour # B-cell mutation rate
mutatRateA = 0.0001/hour # antibody mutation rate
mutatRateB = 0.0000/hour # B-cell mutation rate
mutatRateA = 0.000/hour # antibody mutation rate
# time boundary and griding condition
minT = float(0)
maxT = float(6*28*day)
totalPoint_T = int(1*10**3 + 1)
gT = np.linspace(minT, maxT, totalPoint_T)
spacingT = np.linspace(minT, maxT, num = totalPoint_T, retstep = True)
gT = spacingT[0]
dt = spacingT[1]
# space boundary and griding condition
minX = float(0)
maxX = float(3)
totalPoint_X = int(maxX - minX + 1)
gX = np.linspace(minX, maxX, totalPoint_X)
gridingX = np.linspace(minX, maxX, num = totalPoint_X, retstep = True)
gX = gridingX[0]
dx = gridingX[1]
gV_array = np.zeros([totalPoint_X, totalPoint_T])
gB_array = np.zeros([totalPoint_X, totalPoint_T])
gM_array = np.zeros([totalPoint_X, totalPoint_T])
gG_array = np.zeros([totalPoint_X, totalPoint_T])
# initial output condition
#gV_array[1, 0] = float(2)
#[pre-parameter, post-parameter, recovered-day, OAS+, OSA-]
actRateBg_1st = 0.0002/hour # activation rate of memory B-cell at 1st time (pre-)
actRateBg_2nd = actRateBg_1st*10 # activation rate of memory B-cell at 2nd time (post-)
origin_virus = int(1)
current_virus = int(2)
event_parameter = np.array([[actRateBg_1st,
actRateBg_2nd,
14*day,
+5/hour,
-actRateBm - actRateBg_1st + (actRateBm + actRateBg_1st)/3,
origin_virus,
current_virus]])
# [viral population, starting time, first]
# [viral population, starting time] ---first
infection_period = 1*28*day
viral_population = np.zeros(int(maxX + 1))
viral_population[origin_virus:current_virus + 1] = 3
infection_starting_time = np.arange(int(maxX + 1))*infection_period
event_1st = np.zeros([int(maxX + 1), 2])
event_1st[:, 0] = viral_population
event_1st[:, 1] = infection_starting_time
print ('event_1st = {:}'.format(event_1st))
# [viral population, starting time] ---2nd]
viral_population = np.zeros(int(maxX + 1))
viral_population[origin_virus:current_virus + 1] = 0
infection_starting_time = np.arange(int(maxX + 1))*0
event_2nd = np.zeros([int(maxX + 1), 2])
event_2nd[:, 0] = viral_population
event_2nd[:, 1] = infection_starting_time
print ('event_2nd = {:}'.format(event_2nd))
event_table = np.array([event_parameter, event_1st, event_2nd])
# Runge Kutta numerical solution
pde_array = np.array([dVdt_array, dBdt_array, dMdt_array, dGdt_array])
initial_Out = np.array([gV_array, gB_array, gM_array, gG_array])
gOut_array = alva.AlvaRungeKutta4XT(pde_array, initial_Out, minX, maxX, totalPoint_X, minT, maxT, totalPoint_T, event_table)
# plotting
gV = gOut_array[0]
gB = gOut_array[1]
gM = gOut_array[2]
gG = gOut_array[3]
numberingFig = numberingFig + 1
for i in range(totalPoint_X):
figure_name = '-response-%i'%(i)
figure_suffix = '.png'
save_figure = os.path.join(dir_path, file_name + figure_name + file_suffix)
plt.figure(numberingFig, figsize = AlvaFigSize)
plt.plot(gT, gV[i], color = 'red', label = r'$ V_{%i}(t) $'%(i), linewidth = 3.0, alpha = 0.5)
plt.plot(gT, gM[i], color = 'blue', label = r'$ IgM_{%i}(t) $'%(i), linewidth = 3.0, alpha = 0.5)
plt.plot(gT, gG[i], color = 'green', label = r'$ IgG_{%i}(t) $'%(i), linewidth = 3.0, alpha = 0.5)
plt.plot(gT, gM[i] + gG[i], color = 'gray', linewidth = 5.0, alpha = 0.5, linestyle = 'dashed'
, label = r'$ IgM_{%i}(t) + IgG_{%i}(t) $'%(i, i))
plt.grid(True, which = 'both')
plt.title(r'$ Antibody \ from \ Virus-{%i} $'%(i), fontsize = AlvaFontSize)
plt.xlabel(r'$time \ (%s)$'%(timeUnit), fontsize = AlvaFontSize)
plt.ylabel(r'$ Neutralization \ \ titer $', fontsize = AlvaFontSize)
plt.xlim([minT, maxT])
plt.xticks(fontsize = AlvaFontSize*0.6)
plt.yticks(fontsize = AlvaFontSize*0.6)
plt.ylim([2**0, 2**14])
plt.yscale('log', basey = 2)
plt.legend(loc = (1,0), fontsize = AlvaFontSize)
plt.savefig(save_figure, dpi = 100)
plt.show()
# In[5]:
# Experimental lab data from OAS paper
gT_lab = np.array([28, 28 + 7, 28 + 14, 28 + 28]) + 28
gPR8_lab = np.array([2**(9 + 1.0/10), 2**(13 - 1.0/5), 2**(13 + 1.0/3), 2**(13 - 1.0/4)])
standard_PR8 = gPR8_lab**(3.0/4)
gFM1_lab = np.array([0, 2**(6 - 1.0/5), 2**(7 - 1.0/4), 2**(8 + 1.0/4)])
standard_FM1 = gFM1_lab**(3.0/4)
bar_width = 2.0
# Sequential immunization graph
numberingFig = numberingFig + 1
plt.figure(numberingFig, figsize = (12, 6))
plt.subplot(111)
plt.plot(gT, (gM[origin_virus] + gG[origin_virus]), linewidth = 5.0, alpha = 0.5, color = 'gray'
, label = r'$ Origin-virus $')
plt.plot(gT, (gM[origin_virus + 1] + gG[origin_virus + 1]), linewidth = 5.0, alpha = 0.5, color = 'red'
, label = r'$ Subsequence-virus $')
plt.bar(gT_lab - bar_width/2, gPR8_lab, bar_width, alpha = 0.6, color = 'gray', yerr = standard_PR8
, error_kw = dict(elinewidth = 1, ecolor = 'black'), label = r'$ PR8-virus $')
plt.bar(gT_lab + bar_width/2, gFM1_lab, bar_width, alpha = 0.6, color = 'red', yerr = standard_FM1
, error_kw = dict(elinewidth = 1, ecolor = 'black'), label = r'$ FM1-virus $')
plt.grid(True, which = 'both')
plt.title(r'$ Original \ Antigenic \ Sin \ (sequential-infection)$', fontsize = AlvaFontSize)
plt.xlabel(r'$time \ (%s)$'%(timeUnit), fontsize = AlvaFontSize)
plt.ylabel(r'$ Neutralization \ \ titer $', fontsize = AlvaFontSize)
plt.xticks(fontsize = AlvaFontSize*0.6)
plt.yticks(fontsize = AlvaFontSize*0.6)
plt.xlim([minT, 6*30*day])
plt.ylim([2**5, 2**14])
plt.yscale('log', basey = 2)
# gca()---GetCurrentAxis and Format the ticklabel to be 2**x
plt.gca().yaxis.set_major_formatter(FuncFormatter(lambda x, pos: int(2**(np.log(x)/np.log(2)))))
#plt.gca().xaxis.set_major_locator(plt.MultipleLocator(7))
plt.legend(loc = (1, 0), fontsize = AlvaFontSize)
plt.show()
# In[6]:
# Experimental lab data from OAS paper
gT_lab = np.array([28, 28 + 7, 28 + 14, 28 + 28]) + 28
gPR8_lab = np.array([2**(9 + 1.0/10), 2**(13 - 1.0/5), 2**(13 + 1.0/3), 2**(13 - 1.0/4)])
standard_PR8 = gPR8_lab**(3.0/4)
gFM1_lab = np.array([0, 2**(6 - 1.0/5), 2**(7 - 1.0/4), 2**(8 + 1.0/4)])
standard_FM1 = gFM1_lab**(3.0/4)
bar_width = 1.0
# Sequential immunization graph
figure_name = '-Original-Antigenic-Sin-infection'
figure_suffix = '.png'
save_figure = os.path.join(dir_path, file_name + figure_name + file_suffix)
numberingFig = numberingFig + 1
plt.figure(numberingFig, figsize = (12, 6))
plt.subplot(111)
plt.plot(gT, (gM[origin_virus] + gG[origin_virus]), linewidth = 5.0, alpha = 0.5, color = 'gray'
, label = r'$ Origin-virus $')
plt.plot(gT, (gM[origin_virus + 1] + gG[origin_virus + 1]), linewidth = 5.0, alpha = 0.5, color = 'red'
, label = r'$ Subsequence-virus $')
plt.bar(gT_lab - bar_width/2, gPR8_lab, bar_width, alpha = 0.6, color = 'gray', yerr = standard_PR8
, error_kw = dict(elinewidth = 1, ecolor = 'black'), label = r'$ PR8-virus $')
plt.bar(gT_lab + bar_width/2, gFM1_lab, bar_width, alpha = 0.6, color = 'red', yerr = standard_FM1
, error_kw = dict(elinewidth = 1, ecolor = 'black'), label = r'$ FM1-virus $')
plt.grid(True, which = 'both')
plt.title(r'$ Original \ Antigenic \ Sin \ (sequential-infection)$', fontsize = AlvaFontSize)
plt.xlabel(r'$time \ (%s)$'%(timeUnit), fontsize = AlvaFontSize)
plt.ylabel(r'$ Neutralization \ \ titer $', fontsize = AlvaFontSize)
plt.xticks(fontsize = AlvaFontSize*0.6)
plt.yticks(fontsize = AlvaFontSize*0.6)
plt.xlim([minT, 3*30*day])
plt.ylim([2**5, 2**14])
plt.yscale('log', basey = 2)
# gca()---GetCurrentAxis and Format the ticklabel to be 2**x
plt.gca().yaxis.set_major_formatter(FuncFormatter(lambda x, pos: int(2**(np.log(x)/np.log(2)))))
plt.gca().xaxis.set_major_locator(plt.MultipleLocator(7))
plt.legend(loc = (1, 0), fontsize = AlvaFontSize)
plt.savefig(save_figure, dpi = 100, bbox_inches='tight')
plt.show()
# In[ ]:
|
gpl-2.0
|
[
199,
3,
2803,
26,
2774,
13,
24,
199,
199,
3,
327,
1626,
280,
2030,
7232,
510,
13055,
199,
3,
4178,
921,
5031,
14,
957,
15,
3345,
371,
15,
4466,
2030,
13,
1310,
13,
19538,
199,
3,
221,
199,
3,
6754,
699,
13,
9041,
8145,
3347,
10894,
8059,
13,
264,
2682,
24141,
2030,
1177,
2410,
315,
17761,
287,
8076,
18291,
527,
315,
771,
414,
503,
373,
5470,
3155,
199,
3,
6754,
4431,
22430,
25531,
11474,
1177,
367,
10877,
315,
771,
414,
199,
199,
3,
1010,
59,
19,
2189,
199,
199,
2344,
199,
2502,
26,
4580,
86,
2660,
3107,
16800,
27002,
24157,
199,
602,
26,
257,
28527,
15,
1643,
15,
7806,
199,
2344,
199,
362,
63,
22691,
1252,
11523,
8,
85,
6704,
292,
6711,
8308,
358,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
747,
199,
504,
8027,
14,
28572,
492,
28794,
7772,
199,
199,
646,
741,
3042,
63,
14121,
20067,
63,
1430,
63,
47,
1179,
63,
1222,
465,
741,
3042,
199,
199,
2439,
3042,
6986,
2320,
275,
6546,
199,
2439,
3042,
38,
528,
2320,
275,
334,
1046,
12,
959,
9,
199,
1955,
316,
38,
528,
275,
378,
199,
199,
3,
25174,
199,
694,
63,
515,
275,
1994,
12117,
15,
279,
15,
20436,
15,
14686,
15338,
15,
4466,
2030,
13,
1310,
13,
19538,
15,
66,
3890,
13,
1144,
15,
8941,
7,
199,
493,
63,
354,
275,
283,
54,
723,
527,
13,
34,
3890,
13,
27061,
45,
13,
27061,
39,
7,
199,
8941,
63,
354,
275,
2475,
27247,
7,
199,
493,
63,
4511,
275,
1987,
4524,
7,
199,
2117,
63,
8941,
275,
747,
14,
515,
14,
904,
8,
694,
63,
515,
12,
570,
63,
354,
435,
9658,
63,
354,
435,
570,
63,
4511,
9,
199,
199,
1955,
316,
38,
528,
275,
1329,
316,
38,
528,
435,
413,
199,
6003,
14,
8941,
8,
1955,
316,
38,
528,
12,
6085,
890,
2687,
713,
12,
959,
430,
199,
6003,
14,
3127,
360,
1997,
358,
199,
6003,
14,
1213,
8,
82,
7,
4,
812,
723,
527,
13,
34,
3890,
13,
27061,
45,
13,
27061,
39,
971,
26426,
971,
334,
4466,
2030,
13,
1310,
971,
367,
971,
10877,
13,
262,
771,
414,
9,
2672,
7,
881,
2360,
19740,
275,
4580,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
1520,
14,
16,
15,
25,
12,
519,
7,
4,
971,
10865,
12911,
6672,
812,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6553,
7348,
86,
93,
54,
7348,
78,
22999,
84,
5130,
17,
446,
971,
10865,
91,
54,
63,
78,
8,
84,
6769,
91,
54,
7348,
988,
19575,
446,
971,
10909,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
959,
14,
16,
15,
25,
12,
519,
7,
4,
971,
10865,
12911,
6672,
699,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6553,
7348,
66,
93,
54,
7348,
78,
22999,
84,
5130,
17,
446,
971,
10865,
91,
54,
63,
78,
8,
84,
6769,
91,
54,
7348,
988,
19575,
435,
14749,
5683,
7348,
77,
93,
435,
971,
5683,
7348,
71,
1552,
812,
7348,
78,
22999,
84,
9,
699,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
66,
93,
699,
7348,
78,
22999,
84,
9,
3515,
435,
333,
63,
66,
812,
7348,
78,
22999,
84,
2862,
10865,
91,
34,
7348,
73,
13,
17,
22999,
84,
9,
446,
499,
34,
63,
73,
8,
84,
9,
435,
699,
7348,
73,
11,
17,
22999,
84,
6769,
91,
2961,
13411,
284,
18979,
18,
93,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
650,
14,
16,
15,
25,
12,
82,
7,
4,
971,
10865,
12911,
6672,
603,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6865,
7348,
77,
93,
699,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
413,
14,
16,
15,
25,
12,
82,
7,
4,
971,
10865,
12911,
6672,
598,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6865,
7348,
71,
93,
699,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
3515,
435,
333,
63,
65,
812,
7348,
78,
22999,
84,
2862,
10865,
91,
39,
7348,
73,
13,
17,
22999,
84,
9,
446,
499,
39,
63,
73,
8,
84,
9,
435,
598,
7348,
73,
11,
17,
22999,
84,
6769,
91,
2961,
13411,
284,
18979,
18,
93,
2672,
7,
3515,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
199,
6003,
14,
19556,
8,
2117,
63,
8941,
12,
26910,
275,
2948,
9,
199,
6003,
14,
2384,
342,
421,
199,
3,
5627,
314,
812,
13,
45,
13,
39,
7417,
31605,
26426,
199,
318,
366,
54,
3583,
63,
1144,
8,
54,
15225,
39,
400,
275,
990,
627,
589,
304,
272,
327,
19720,
272,
812,
275,
812,
15225,
39,
400,
59,
16,
61,
272,
699,
275,
812,
15225,
39,
400,
59,
17,
61,
272,
603,
275,
812,
15225,
39,
400,
59,
18,
61,
272,
598,
275,
812,
15225,
39,
400,
59,
19,
61,
272,
671,
63,
2923,
3428,
275,
812,
15225,
39,
400,
14,
1392,
59,
17,
61,
272,
327,
2337,
787,
302,
366,
51,
3583,
272,
366,
54,
63,
3583,
63,
1144,
275,
980,
14,
4250,
8,
88,
63,
2923,
3428,
9,
272,
327,
1924,
366,
51,
3583,
543,
314,
2011,
18649,
1824,
272,
366,
54,
63,
3583,
63,
1144,
5873,
275,
435,
262,
6621,
54,
10,
54,
1491,
3672,
8,
17,
446,
812
] |
[
3,
2803,
26,
2774,
13,
24,
199,
199,
3,
327,
1626,
280,
2030,
7232,
510,
13055,
199,
3,
4178,
921,
5031,
14,
957,
15,
3345,
371,
15,
4466,
2030,
13,
1310,
13,
19538,
199,
3,
221,
199,
3,
6754,
699,
13,
9041,
8145,
3347,
10894,
8059,
13,
264,
2682,
24141,
2030,
1177,
2410,
315,
17761,
287,
8076,
18291,
527,
315,
771,
414,
503,
373,
5470,
3155,
199,
3,
6754,
4431,
22430,
25531,
11474,
1177,
367,
10877,
315,
771,
414,
199,
199,
3,
1010,
59,
19,
2189,
199,
199,
2344,
199,
2502,
26,
4580,
86,
2660,
3107,
16800,
27002,
24157,
199,
602,
26,
257,
28527,
15,
1643,
15,
7806,
199,
2344,
199,
362,
63,
22691,
1252,
11523,
8,
85,
6704,
292,
6711,
8308,
358,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
646,
747,
199,
504,
8027,
14,
28572,
492,
28794,
7772,
199,
199,
646,
741,
3042,
63,
14121,
20067,
63,
1430,
63,
47,
1179,
63,
1222,
465,
741,
3042,
199,
199,
2439,
3042,
6986,
2320,
275,
6546,
199,
2439,
3042,
38,
528,
2320,
275,
334,
1046,
12,
959,
9,
199,
1955,
316,
38,
528,
275,
378,
199,
199,
3,
25174,
199,
694,
63,
515,
275,
1994,
12117,
15,
279,
15,
20436,
15,
14686,
15338,
15,
4466,
2030,
13,
1310,
13,
19538,
15,
66,
3890,
13,
1144,
15,
8941,
7,
199,
493,
63,
354,
275,
283,
54,
723,
527,
13,
34,
3890,
13,
27061,
45,
13,
27061,
39,
7,
199,
8941,
63,
354,
275,
2475,
27247,
7,
199,
493,
63,
4511,
275,
1987,
4524,
7,
199,
2117,
63,
8941,
275,
747,
14,
515,
14,
904,
8,
694,
63,
515,
12,
570,
63,
354,
435,
9658,
63,
354,
435,
570,
63,
4511,
9,
199,
199,
1955,
316,
38,
528,
275,
1329,
316,
38,
528,
435,
413,
199,
6003,
14,
8941,
8,
1955,
316,
38,
528,
12,
6085,
890,
2687,
713,
12,
959,
430,
199,
6003,
14,
3127,
360,
1997,
358,
199,
6003,
14,
1213,
8,
82,
7,
4,
812,
723,
527,
13,
34,
3890,
13,
27061,
45,
13,
27061,
39,
971,
26426,
971,
334,
4466,
2030,
13,
1310,
971,
367,
971,
10877,
13,
262,
771,
414,
9,
2672,
7,
881,
2360,
19740,
275,
4580,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
1520,
14,
16,
15,
25,
12,
519,
7,
4,
971,
10865,
12911,
6672,
812,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6553,
7348,
86,
93,
54,
7348,
78,
22999,
84,
5130,
17,
446,
971,
10865,
91,
54,
63,
78,
8,
84,
6769,
91,
54,
7348,
988,
19575,
446,
971,
10909,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
959,
14,
16,
15,
25,
12,
519,
7,
4,
971,
10865,
12911,
6672,
699,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6553,
7348,
66,
93,
54,
7348,
78,
22999,
84,
5130,
17,
446,
971,
10865,
91,
54,
63,
78,
8,
84,
6769,
91,
54,
7348,
988,
19575,
435,
14749,
5683,
7348,
77,
93,
435,
971,
5683,
7348,
71,
1552,
812,
7348,
78,
22999,
84,
9,
699,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
66,
93,
699,
7348,
78,
22999,
84,
9,
3515,
435,
333,
63,
66,
812,
7348,
78,
22999,
84,
2862,
10865,
91,
34,
7348,
73,
13,
17,
22999,
84,
9,
446,
499,
34,
63,
73,
8,
84,
9,
435,
699,
7348,
73,
11,
17,
22999,
84,
6769,
91,
2961,
13411,
284,
18979,
18,
93,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
650,
14,
16,
15,
25,
12,
82,
7,
4,
971,
10865,
12911,
6672,
603,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6865,
7348,
77,
93,
699,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
77,
93,
603,
7348,
78,
22999,
84,
9,
2672,
7,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
6003,
14,
505,
8,
16,
12,
413,
14,
16,
15,
25,
12,
82,
7,
4,
971,
10865,
12911,
6672,
598,
63,
78,
8,
84,
6769,
12911,
6672,
307,
93,
275,
3515,
17992,
6865,
7348,
71,
93,
699,
7348,
78,
22999,
84,
9,
446,
971,
10909,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
812,
7348,
78,
22999,
84,
9,
446,
971,
6553,
7348,
71,
93,
598,
7348,
78,
22999,
84,
9,
3515,
435,
333,
63,
65,
812,
7348,
78,
22999,
84,
2862,
10865,
91,
39,
7348,
73,
13,
17,
22999,
84,
9,
446,
499,
39,
63,
73,
8,
84,
9,
435,
598,
7348,
73,
11,
17,
22999,
84,
6769,
91,
2961,
13411,
284,
18979,
18,
93,
2672,
7,
3515,
268,
2360,
19740,
275,
413,
14,
18,
10,
2439,
3042,
6986,
2320,
9,
199,
199,
6003,
14,
19556,
8,
2117,
63,
8941,
12,
26910,
275,
2948,
9,
199,
6003,
14,
2384,
342,
421,
199,
3,
5627,
314,
812,
13,
45,
13,
39,
7417,
31605,
26426,
199,
318,
366,
54,
3583,
63,
1144,
8,
54,
15225,
39,
400,
275,
990,
627,
589,
304,
272,
327,
19720,
272,
812,
275,
812,
15225,
39,
400,
59,
16,
61,
272,
699,
275,
812,
15225,
39,
400,
59,
17,
61,
272,
603,
275,
812,
15225,
39,
400,
59,
18,
61,
272,
598,
275,
812,
15225,
39,
400,
59,
19,
61,
272,
671,
63,
2923,
3428,
275,
812,
15225,
39,
400,
14,
1392,
59,
17,
61,
272,
327,
2337,
787,
302,
366,
51,
3583,
272,
366,
54,
63,
3583,
63,
1144,
275,
980,
14,
4250,
8,
88,
63,
2923,
3428,
9,
272,
327,
1924,
366,
51,
3583,
543,
314,
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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
] |
cloudera/hue
|
desktop/core/ext-py/eventlet-0.24.1/eventlet/websocket.py
|
5
|
32462
|
import base64
import codecs
import collections
import errno
from random import Random
from socket import error as SocketError
import string
import struct
import sys
import time
import zlib
try:
from hashlib import md5, sha1
except ImportError: # pragma NO COVER
from md5 import md5
from sha import sha as sha1
from eventlet import semaphore
from eventlet import wsgi
from eventlet.green import socket
from eventlet.support import get_errno
import six
# Python 2's utf8 decoding is more lenient than we'd like
# In order to pass autobahn's testsuite we need stricter validation
# if available...
for _mod in ('wsaccel.utf8validator', 'autobahn.utf8validator'):
# autobahn has it's own python-based validator. in newest versions
# this prefers to use wsaccel, a cython based implementation, if available.
# wsaccel may also be installed w/out autobahn, or with a earlier version.
try:
utf8validator = __import__(_mod, {}, {}, [''])
except ImportError:
utf8validator = None
else:
break
ACCEPTABLE_CLIENT_ERRORS = set((errno.ECONNRESET, errno.EPIPE))
__all__ = ["WebSocketWSGI", "WebSocket"]
PROTOCOL_GUID = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
VALID_CLOSE_STATUS = set(
list(range(1000, 1004)) +
list(range(1007, 1012)) +
# 3000-3999: reserved for use by libraries, frameworks,
# and applications
list(range(3000, 4000)) +
# 4000-4999: reserved for private use and thus can't
# be registered
list(range(4000, 5000))
)
class BadRequest(Exception):
def __init__(self, status='400 Bad Request', body=None, headers=None):
super(Exception, self).__init__()
self.status = status
self.body = body
self.headers = headers
class WebSocketWSGI(object):
"""Wraps a websocket handler function in a WSGI application.
Use it like this::
@websocket.WebSocketWSGI
def my_handler(ws):
from_browser = ws.wait()
ws.send("from server")
The single argument to the function will be an instance of
:class:`WebSocket`. To close the socket, simply return from the
function. Note that the server will log the websocket request at
the time of closure.
"""
def __init__(self, handler):
self.handler = handler
self.protocol_version = None
self.support_legacy_versions = True
self.supported_protocols = []
self.origin_checker = None
@classmethod
def configured(cls,
handler=None,
supported_protocols=None,
origin_checker=None,
support_legacy_versions=False):
def decorator(handler):
inst = cls(handler)
inst.support_legacy_versions = support_legacy_versions
inst.origin_checker = origin_checker
if supported_protocols:
inst.supported_protocols = supported_protocols
return inst
if handler is None:
return decorator
return decorator(handler)
def __call__(self, environ, start_response):
http_connection_parts = [
part.strip()
for part in environ.get('HTTP_CONNECTION', '').lower().split(',')]
if not ('upgrade' in http_connection_parts and
environ.get('HTTP_UPGRADE', '').lower() == 'websocket'):
# need to check a few more things here for true compliance
start_response('400 Bad Request', [('Connection', 'close')])
return []
try:
if 'HTTP_SEC_WEBSOCKET_VERSION' in environ:
ws = self._handle_hybi_request(environ)
elif self.support_legacy_versions:
ws = self._handle_legacy_request(environ)
else:
raise BadRequest()
except BadRequest as e:
status = e.status
body = e.body or b''
headers = e.headers or []
start_response(status,
[('Connection', 'close'), ] + headers)
return [body]
try:
self.handler(ws)
except socket.error as e:
if get_errno(e) not in ACCEPTABLE_CLIENT_ERRORS:
raise
# Make sure we send the closing frame
ws._send_closing_frame(True)
# use this undocumented feature of eventlet.wsgi to ensure that it
# doesn't barf on the fact that we didn't call start_response
return wsgi.ALREADY_HANDLED
def _handle_legacy_request(self, environ):
if 'eventlet.input' in environ:
sock = environ['eventlet.input'].get_socket()
elif 'gunicorn.socket' in environ:
sock = environ['gunicorn.socket']
else:
raise Exception('No eventlet.input or gunicorn.socket present in environ.')
if 'HTTP_SEC_WEBSOCKET_KEY1' in environ:
self.protocol_version = 76
if 'HTTP_SEC_WEBSOCKET_KEY2' not in environ:
raise BadRequest()
else:
self.protocol_version = 75
if self.protocol_version == 76:
key1 = self._extract_number(environ['HTTP_SEC_WEBSOCKET_KEY1'])
key2 = self._extract_number(environ['HTTP_SEC_WEBSOCKET_KEY2'])
# There's no content-length header in the request, but it has 8
# bytes of data.
environ['wsgi.input'].content_length = 8
key3 = environ['wsgi.input'].read(8)
key = struct.pack(">II", key1, key2) + key3
response = md5(key).digest()
# Start building the response
scheme = 'ws'
if environ.get('wsgi.url_scheme') == 'https':
scheme = 'wss'
location = '%s://%s%s%s' % (
scheme,
environ.get('HTTP_HOST'),
environ.get('SCRIPT_NAME'),
environ.get('PATH_INFO')
)
qs = environ.get('QUERY_STRING')
if qs is not None:
location += '?' + qs
if self.protocol_version == 75:
handshake_reply = (
b"HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
b"Upgrade: WebSocket\r\n"
b"Connection: Upgrade\r\n"
b"WebSocket-Origin: " + six.b(environ.get('HTTP_ORIGIN')) + b"\r\n"
b"WebSocket-Location: " + six.b(location) + b"\r\n\r\n"
)
elif self.protocol_version == 76:
handshake_reply = (
b"HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
b"Upgrade: WebSocket\r\n"
b"Connection: Upgrade\r\n"
b"Sec-WebSocket-Origin: " + six.b(environ.get('HTTP_ORIGIN')) + b"\r\n"
b"Sec-WebSocket-Protocol: " +
six.b(environ.get('HTTP_SEC_WEBSOCKET_PROTOCOL', 'default')) + b"\r\n"
b"Sec-WebSocket-Location: " + six.b(location) + b"\r\n"
b"\r\n" + response
)
else: # pragma NO COVER
raise ValueError("Unknown WebSocket protocol version.")
sock.sendall(handshake_reply)
return WebSocket(sock, environ, self.protocol_version)
def _parse_extension_header(self, header):
if header is None:
return None
res = {}
for ext in header.split(","):
parts = ext.split(";")
config = {}
for part in parts[1:]:
key_val = part.split("=")
if len(key_val) == 1:
config[key_val[0].strip().lower()] = True
else:
config[key_val[0].strip().lower()] = key_val[1].strip().strip('"').lower()
res.setdefault(parts[0].strip().lower(), []).append(config)
return res
def _negotiate_permessage_deflate(self, extensions):
if not extensions:
return None
deflate = extensions.get("permessage-deflate")
if deflate is None:
return None
for config in deflate:
# We'll evaluate each config in the client's preferred order and pick
# the first that we can support.
want_config = {
# These are bool options, we can support both
"server_no_context_takeover": config.get("server_no_context_takeover", False),
"client_no_context_takeover": config.get("client_no_context_takeover", False)
}
# These are either bool OR int options. True means the client can accept a value
# for the option, a number means the client wants that specific value.
max_wbits = min(zlib.MAX_WBITS, 15)
mwb = config.get("server_max_window_bits")
if mwb is not None:
if mwb is True:
want_config["server_max_window_bits"] = max_wbits
else:
want_config["server_max_window_bits"] = \
int(config.get("server_max_window_bits", max_wbits))
if not (8 <= want_config["server_max_window_bits"] <= 15):
continue
mwb = config.get("client_max_window_bits")
if mwb is not None:
if mwb is True:
want_config["client_max_window_bits"] = max_wbits
else:
want_config["client_max_window_bits"] = \
int(config.get("client_max_window_bits", max_wbits))
if not (8 <= want_config["client_max_window_bits"] <= 15):
continue
return want_config
return None
def _format_extension_header(self, parsed_extensions):
if not parsed_extensions:
return None
parts = []
for name, config in parsed_extensions.items():
ext_parts = [six.b(name)]
for key, value in config.items():
if value is False:
pass
elif value is True:
ext_parts.append(six.b(key))
else:
ext_parts.append(six.b("%s=%s" % (key, str(value))))
parts.append(b"; ".join(ext_parts))
return b", ".join(parts)
def _handle_hybi_request(self, environ):
if 'eventlet.input' in environ:
sock = environ['eventlet.input'].get_socket()
elif 'gunicorn.socket' in environ:
sock = environ['gunicorn.socket']
else:
raise Exception('No eventlet.input or gunicorn.socket present in environ.')
hybi_version = environ['HTTP_SEC_WEBSOCKET_VERSION']
if hybi_version not in ('8', '13', ):
raise BadRequest(status='426 Upgrade Required',
headers=[('Sec-WebSocket-Version', '8, 13')])
self.protocol_version = int(hybi_version)
if 'HTTP_SEC_WEBSOCKET_KEY' not in environ:
# That's bad.
raise BadRequest()
origin = environ.get(
'HTTP_ORIGIN',
(environ.get('HTTP_SEC_WEBSOCKET_ORIGIN', '')
if self.protocol_version <= 8 else ''))
if self.origin_checker is not None:
if not self.origin_checker(environ.get('HTTP_HOST'), origin):
raise BadRequest(status='403 Forbidden')
protocols = environ.get('HTTP_SEC_WEBSOCKET_PROTOCOL', None)
negotiated_protocol = None
if protocols:
for p in (i.strip() for i in protocols.split(',')):
if p in self.supported_protocols:
negotiated_protocol = p
break
key = environ['HTTP_SEC_WEBSOCKET_KEY']
response = base64.b64encode(sha1(six.b(key) + PROTOCOL_GUID).digest())
handshake_reply = [b"HTTP/1.1 101 Switching Protocols",
b"Upgrade: websocket",
b"Connection: Upgrade",
b"Sec-WebSocket-Accept: " + response]
if negotiated_protocol:
handshake_reply.append(b"Sec-WebSocket-Protocol: " + six.b(negotiated_protocol))
parsed_extensions = {}
extensions = self._parse_extension_header(environ.get("HTTP_SEC_WEBSOCKET_EXTENSIONS"))
deflate = self._negotiate_permessage_deflate(extensions)
if deflate is not None:
parsed_extensions["permessage-deflate"] = deflate
formatted_ext = self._format_extension_header(parsed_extensions)
if formatted_ext is not None:
handshake_reply.append(b"Sec-WebSocket-Extensions: " + formatted_ext)
sock.sendall(b'\r\n'.join(handshake_reply) + b'\r\n\r\n')
return RFC6455WebSocket(sock, environ, self.protocol_version,
protocol=negotiated_protocol,
extensions=parsed_extensions)
def _extract_number(self, value):
"""
Utility function which, given a string like 'g98sd 5[]221@1', will
return 9852211. Used to parse the Sec-WebSocket-Key headers.
"""
out = ""
spaces = 0
for char in value:
if char in string.digits:
out += char
elif char == " ":
spaces += 1
return int(out) // spaces
class WebSocket(object):
"""A websocket object that handles the details of
serialization/deserialization to the socket.
The primary way to interact with a :class:`WebSocket` object is to
call :meth:`send` and :meth:`wait` in order to pass messages back
and forth with the browser. Also available are the following
properties:
path
The path value of the request. This is the same as the WSGI PATH_INFO variable,
but more convenient.
protocol
The value of the Websocket-Protocol header.
origin
The value of the 'Origin' header.
environ
The full WSGI environment for this request.
"""
def __init__(self, sock, environ, version=76):
"""
:param socket: The eventlet socket
:type socket: :class:`eventlet.greenio.GreenSocket`
:param environ: The wsgi environment
:param version: The WebSocket spec version to follow (default is 76)
"""
self.log = environ.get('wsgi.errors', sys.stderr)
self.log_context = 'server={shost}/{spath} client={caddr}:{cport}'.format(
shost=environ.get('HTTP_HOST'),
spath=environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', ''),
caddr=environ.get('REMOTE_ADDR'), cport=environ.get('REMOTE_PORT'),
)
self.socket = sock
self.origin = environ.get('HTTP_ORIGIN')
self.protocol = environ.get('HTTP_WEBSOCKET_PROTOCOL')
self.path = environ.get('PATH_INFO')
self.environ = environ
self.version = version
self.websocket_closed = False
self._buf = b""
self._msgs = collections.deque()
self._sendlock = semaphore.Semaphore()
def _pack_message(self, message):
"""Pack the message inside ``00`` and ``FF``
As per the dataframing section (5.3) for the websocket spec
"""
if isinstance(message, six.text_type):
message = message.encode('utf-8')
elif not isinstance(message, six.binary_type):
message = six.b(str(message))
packed = b"\x00" + message + b"\xFF"
return packed
def _parse_messages(self):
""" Parses for messages in the buffer *buf*. It is assumed that
the buffer contains the start character for a message, but that it
may contain only part of the rest of the message.
Returns an array of messages, and the buffer remainder that
didn't contain any full messages."""
msgs = []
end_idx = 0
buf = self._buf
while buf:
frame_type = six.indexbytes(buf, 0)
if frame_type == 0:
# Normal message.
end_idx = buf.find(b"\xFF")
if end_idx == -1: # pragma NO COVER
break
msgs.append(buf[1:end_idx].decode('utf-8', 'replace'))
buf = buf[end_idx + 1:]
elif frame_type == 255:
# Closing handshake.
assert six.indexbytes(buf, 1) == 0, "Unexpected closing handshake: %r" % buf
self.websocket_closed = True
break
else:
raise ValueError("Don't understand how to parse this type of message: %r" % buf)
self._buf = buf
return msgs
def send(self, message):
"""Send a message to the browser.
*message* should be convertable to a string; unicode objects should be
encodable as utf-8. Raises socket.error with errno of 32
(broken pipe) if the socket has already been closed by the client."""
packed = self._pack_message(message)
# if two greenthreads are trying to send at the same time
# on the same socket, sendlock prevents interleaving and corruption
self._sendlock.acquire()
try:
self.socket.sendall(packed)
finally:
self._sendlock.release()
def wait(self):
"""Waits for and deserializes messages.
Returns a single message; the oldest not yet processed. If the client
has already closed the connection, returns None. This is different
from normal socket behavior because the empty string is a valid
websocket message."""
while not self._msgs:
# Websocket might be closed already.
if self.websocket_closed:
return None
# no parsed messages, must mean buf needs more data
delta = self.socket.recv(8096)
if delta == b'':
return None
self._buf += delta
msgs = self._parse_messages()
self._msgs.extend(msgs)
return self._msgs.popleft()
def _send_closing_frame(self, ignore_send_errors=False):
"""Sends the closing frame to the client, if required."""
if self.version == 76 and not self.websocket_closed:
try:
self.socket.sendall(b"\xff\x00")
except SocketError:
# Sometimes, like when the remote side cuts off the connection,
# we don't care about this.
if not ignore_send_errors: # pragma NO COVER
raise
self.websocket_closed = True
def close(self):
"""Forcibly close the websocket; generally it is preferable to
return from the handler method."""
try:
self._send_closing_frame(True)
self.socket.shutdown(True)
except SocketError as e:
if e.errno != errno.ENOTCONN:
self.log.write('{ctx} socket shutdown error: {e}'.format(ctx=self.log_context, e=e))
finally:
self.socket.close()
class ConnectionClosedError(Exception):
pass
class FailedConnectionError(Exception):
def __init__(self, status, message):
super(FailedConnectionError, self).__init__(status, message)
self.message = message
self.status = status
class ProtocolError(ValueError):
pass
class RFC6455WebSocket(WebSocket):
def __init__(self, sock, environ, version=13, protocol=None, client=False, extensions=None):
super(RFC6455WebSocket, self).__init__(sock, environ, version)
self.iterator = self._iter_frames()
self.client = client
self.protocol = protocol
self.extensions = extensions or {}
self._deflate_enc = None
self._deflate_dec = None
class UTF8Decoder(object):
def __init__(self):
if utf8validator:
self.validator = utf8validator.Utf8Validator()
else:
self.validator = None
decoderclass = codecs.getincrementaldecoder('utf8')
self.decoder = decoderclass()
def reset(self):
if self.validator:
self.validator.reset()
self.decoder.reset()
def decode(self, data, final=False):
if self.validator:
valid, eocp, c_i, t_i = self.validator.validate(data)
if not valid:
raise ValueError('Data is not valid unicode')
return self.decoder.decode(data, final)
def _get_permessage_deflate_enc(self):
options = self.extensions.get("permessage-deflate")
if options is None:
return None
def _make():
return zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED,
-options.get("client_max_window_bits" if self.client
else "server_max_window_bits",
zlib.MAX_WBITS))
if options.get("client_no_context_takeover" if self.client
else "server_no_context_takeover"):
# This option means we have to make a new one every time
return _make()
else:
if self._deflate_enc is None:
self._deflate_enc = _make()
return self._deflate_enc
def _get_permessage_deflate_dec(self, rsv1):
options = self.extensions.get("permessage-deflate")
if options is None or not rsv1:
return None
def _make():
return zlib.decompressobj(-options.get("server_max_window_bits" if self.client
else "client_max_window_bits",
zlib.MAX_WBITS))
if options.get("server_no_context_takeover" if self.client
else "client_no_context_takeover"):
# This option means we have to make a new one every time
return _make()
else:
if self._deflate_dec is None:
self._deflate_dec = _make()
return self._deflate_dec
def _get_bytes(self, numbytes):
data = b''
while len(data) < numbytes:
d = self.socket.recv(numbytes - len(data))
if not d:
raise ConnectionClosedError()
data = data + d
return data
class Message(object):
def __init__(self, opcode, decoder=None, decompressor=None):
self.decoder = decoder
self.data = []
self.finished = False
self.opcode = opcode
self.decompressor = decompressor
def push(self, data, final=False):
self.finished = final
self.data.append(data)
def getvalue(self):
data = b"".join(self.data)
if not self.opcode & 8 and self.decompressor:
data = self.decompressor.decompress(data + b'\x00\x00\xff\xff')
if self.decoder:
data = self.decoder.decode(data, self.finished)
return data
@staticmethod
def _apply_mask(data, mask, length=None, offset=0):
if length is None:
length = len(data)
cnt = range(length)
return b''.join(six.int2byte(six.indexbytes(data, i) ^ mask[(offset + i) % 4]) for i in cnt)
def _handle_control_frame(self, opcode, data):
if opcode == 8: # connection close
if not data:
status = 1000
elif len(data) > 1:
status = struct.unpack_from('!H', data)[0]
if not status or status not in VALID_CLOSE_STATUS:
raise FailedConnectionError(
1002,
"Unexpected close status code.")
try:
data = self.UTF8Decoder().decode(data[2:], True)
except (UnicodeDecodeError, ValueError):
raise FailedConnectionError(
1002,
"Close message data should be valid UTF-8.")
else:
status = 1002
self.close(close_data=(status, ''))
raise ConnectionClosedError()
elif opcode == 9: # ping
self.send(data, control_code=0xA)
elif opcode == 0xA: # pong
pass
else:
raise FailedConnectionError(
1002, "Unknown control frame received.")
def _iter_frames(self):
fragmented_message = None
try:
while True:
message = self._recv_frame(message=fragmented_message)
if message.opcode & 8:
self._handle_control_frame(
message.opcode, message.getvalue())
continue
if fragmented_message and message is not fragmented_message:
raise RuntimeError('Unexpected message change.')
fragmented_message = message
if message.finished:
data = fragmented_message.getvalue()
fragmented_message = None
yield data
except FailedConnectionError:
exc_typ, exc_val, exc_tb = sys.exc_info()
self.close(close_data=(exc_val.status, exc_val.message))
except ConnectionClosedError:
return
except Exception:
self.close(close_data=(1011, 'Internal Server Error'))
raise
def _recv_frame(self, message=None):
recv = self._get_bytes
# Unpacking the frame described in Section 5.2 of RFC6455
# (https://tools.ietf.org/html/rfc6455#section-5.2)
header = recv(2)
a, b = struct.unpack('!BB', header)
finished = a >> 7 == 1
rsv123 = a >> 4 & 7
rsv1 = rsv123 & 4
if rsv123:
if rsv1 and "permessage-deflate" not in self.extensions:
# must be zero - unless it's compressed then rsv1 is true
raise FailedConnectionError(
1002,
"RSV1, RSV2, RSV3: MUST be 0 unless an extension is"
" negotiated that defines meanings for non-zero values.")
opcode = a & 15
if opcode not in (0, 1, 2, 8, 9, 0xA):
raise FailedConnectionError(1002, "Unknown opcode received.")
masked = b & 128 == 128
if not masked and not self.client:
raise FailedConnectionError(1002, "A client MUST mask all frames"
" that it sends to the server")
length = b & 127
if opcode & 8:
if not finished:
raise FailedConnectionError(1002, "Control frames must not"
" be fragmented.")
if length > 125:
raise FailedConnectionError(
1002,
"All control frames MUST have a payload length of 125"
" bytes or less")
elif opcode and message:
raise FailedConnectionError(
1002,
"Received a non-continuation opcode within"
" fragmented message.")
elif not opcode and not message:
raise FailedConnectionError(
1002,
"Received continuation opcode with no previous"
" fragments received.")
if length == 126:
length = struct.unpack('!H', recv(2))[0]
elif length == 127:
length = struct.unpack('!Q', recv(8))[0]
if masked:
mask = struct.unpack('!BBBB', recv(4))
received = 0
if not message or opcode & 8:
decoder = self.UTF8Decoder() if opcode == 1 else None
decompressor = self._get_permessage_deflate_dec(rsv1)
message = self.Message(opcode, decoder=decoder, decompressor=decompressor)
if not length:
message.push(b'', final=finished)
else:
while received < length:
d = self.socket.recv(length - received)
if not d:
raise ConnectionClosedError()
dlen = len(d)
if masked:
d = self._apply_mask(d, mask, length=dlen, offset=received)
received = received + dlen
try:
message.push(d, final=finished)
except (UnicodeDecodeError, ValueError):
raise FailedConnectionError(
1007, "Text data must be valid utf-8")
return message
def _pack_message(self, message, masked=False,
continuation=False, final=True, control_code=None):
is_text = False
if isinstance(message, six.text_type):
message = message.encode('utf-8')
is_text = True
compress_bit = 0
compressor = self._get_permessage_deflate_enc()
if message and compressor:
message = compressor.compress(message)
message += compressor.flush(zlib.Z_SYNC_FLUSH)
assert message[-4:] == b"\x00\x00\xff\xff"
message = message[:-4]
compress_bit = 1 << 6
length = len(message)
if not length:
# no point masking empty data
masked = False
if control_code:
if control_code not in (8, 9, 0xA):
raise ProtocolError('Unknown control opcode.')
if continuation or not final:
raise ProtocolError('Control frame cannot be a fragment.')
if length > 125:
raise ProtocolError('Control frame data too large (>125).')
header = struct.pack('!B', control_code | 1 << 7)
else:
opcode = 0 if continuation else ((1 if is_text else 2) | compress_bit)
header = struct.pack('!B', opcode | (1 << 7 if final else 0))
lengthdata = 1 << 7 if masked else 0
if length > 65535:
lengthdata = struct.pack('!BQ', lengthdata | 127, length)
elif length > 125:
lengthdata = struct.pack('!BH', lengthdata | 126, length)
else:
lengthdata = struct.pack('!B', lengthdata | length)
if masked:
# NOTE: RFC6455 states:
# A server MUST NOT mask any frames that it sends to the client
rand = Random(time.time())
mask = [rand.getrandbits(8) for _ in six.moves.xrange(4)]
message = RFC6455WebSocket._apply_mask(message, mask, length)
maskdata = struct.pack('!BBBB', *mask)
else:
maskdata = b''
return b''.join((header, lengthdata, maskdata, message))
def wait(self):
for i in self.iterator:
return i
def _send(self, frame):
self._sendlock.acquire()
try:
self.socket.sendall(frame)
finally:
self._sendlock.release()
def send(self, message, **kw):
kw['masked'] = self.client
payload = self._pack_message(message, **kw)
self._send(payload)
def _send_closing_frame(self, ignore_send_errors=False, close_data=None):
if self.version in (8, 13) and not self.websocket_closed:
if close_data is not None:
status, msg = close_data
if isinstance(msg, six.text_type):
msg = msg.encode('utf-8')
data = struct.pack('!H', status) + msg
else:
data = ''
try:
self.send(data, control_code=8)
except SocketError:
# Sometimes, like when the remote side cuts off the connection,
# we don't care about this.
if not ignore_send_errors: # pragma NO COVER
raise
self.websocket_closed = True
def close(self, close_data=None):
"""Forcibly close the websocket; generally it is preferable to
return from the handler method."""
try:
self._send_closing_frame(close_data=close_data, ignore_send_errors=True)
self.socket.shutdown(socket.SHUT_WR)
except SocketError as e:
if e.errno != errno.ENOTCONN:
self.log.write('{ctx} socket shutdown error: {e}'.format(ctx=self.log_context, e=e))
finally:
self.socket.close()
|
apache-2.0
|
[
646,
1300,
772,
199,
646,
6010,
199,
646,
5055,
199,
646,
7554,
199,
504,
2196,
492,
9571,
199,
504,
2838,
492,
1125,
465,
17766,
547,
199,
646,
1059,
199,
646,
2702,
199,
646,
984,
199,
646,
900,
199,
199,
646,
12472,
199,
199,
893,
26,
272,
687,
8337,
492,
6128,
21,
12,
7793,
17,
199,
2590,
3545,
26,
221,
327,
11942,
4825,
5099,
2111,
272,
687,
6128,
21,
492,
6128,
21,
272,
687,
7793,
492,
7793,
465,
7793,
17,
199,
199,
504,
21819,
492,
542,
17185,
199,
504,
21819,
492,
12464,
199,
504,
21819,
14,
7731,
492,
2838,
199,
504,
21819,
14,
4058,
492,
664,
63,
7931,
199,
646,
3816,
199,
199,
3,
2018,
499,
1159,
2774,
24,
15952,
365,
1655,
822,
6792,
2419,
781,
5121,
2839,
199,
3,
1010,
1865,
370,
986,
2599,
2470,
6164,
1159,
2295,
2577,
781,
1929,
410,
1567,
351,
6411,
199,
3,
340,
2808,
1396,
199,
509,
485,
1494,
315,
661,
3569,
645,
6067,
14,
1624,
24,
11034,
297,
283,
2495,
2470,
6164,
14,
1624,
24,
11034,
735,
272,
327,
2599,
2470,
6164,
965,
652,
1159,
5705,
2366,
13,
6788,
11822,
14,
315,
29608,
5459,
272,
327,
642,
20491,
1192,
370,
675,
10900,
645,
6067,
12,
282,
29348,
4079,
4514,
12,
340,
2808,
14,
272,
327,
10900,
645,
6067,
1443,
2597,
506,
4903,
336,
15,
548,
2599,
2470,
6164,
12,
503,
543,
282,
14119,
1015,
14,
272,
862,
26,
267,
2774,
24,
11034,
275,
636,
646,
721,
63,
1494,
12,
5479,
5479,
788,
1105,
272,
871,
3545,
26,
267,
2774,
24,
11034,
275,
488,
272,
587,
26,
267,
2059,
199,
199,
13089,
2617,
63,
9901,
63,
21477,
275,
663,
1332,
7931,
14,
37,
17489,
18066,
12,
7554,
14,
37,
6089,
430,
199,
199,
363,
452,
363,
275,
2097,
18477,
16828,
401,
298,
18477,
937,
199,
9583,
63,
17856,
275,
330,
7,
12234,
11765,
2078,
21,
13,
37,
28646,
13,
2417,
8980,
13,
2720,
3263,
13,
35,
21,
1217,
16,
5196,
2426,
34,
845,
7,
199,
5600,
63,
18219,
63,
6305,
275,
663,
8,
272,
769,
8,
1842,
8,
5279,
12,
2948,
20,
430,
435,
272,
769,
8,
1842,
8,
1960,
23,
12,
413,
11533,
430,
435,
272,
327,
29664,
13,
19,
5637,
26,
4644,
367,
675,
701,
8363,
12,
10059,
83,
12,
272,
327,
436,
13103,
272,
769,
8,
1842,
8,
19962,
12,
31092,
430,
435,
272,
327,
31092,
13,
20,
5637,
26,
4644,
367,
5726,
675,
436,
12850,
883,
1133,
272,
327,
506,
7264,
272,
769,
8,
1842,
8,
23641,
12,
22369,
430,
199,
9,
421,
199,
533,
8857,
2017,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
2004,
534,
5303,
8857,
4784,
297,
2396,
29,
403,
12,
2323,
29,
403,
304,
267,
1613,
8,
1726,
12,
291,
2843,
826,
4533,
267,
291,
14,
1205,
275,
2004,
267,
291,
14,
2030,
275,
2396,
267,
291,
14,
2139,
275,
2323,
421,
199,
533,
18846,
16828,
8,
785,
304,
272,
408,
55,
8146,
282,
24897,
3016,
805,
315,
282,
9279,
4223,
14,
339,
3645,
652,
2839,
642,
447,
2541,
768,
13508,
14,
18477,
16828,
489,
347,
3002,
63,
2232,
8,
3569,
304,
881,
687,
63,
5750,
275,
10900,
14,
2573,
342,
881,
10900,
14,
2254,
480,
504,
1654,
531,
339,
710,
2849,
1423,
370,
314,
805,
911,
506,
376,
1256,
402,
272,
520,
533,
1705,
18477,
2313,
221,
4005,
4002,
314,
2838,
12,
9329,
372,
687,
314,
272,
805,
14,
221,
3390,
626,
314,
1654,
911,
943,
314,
24897,
1056,
737,
272,
314,
900,
402,
17903,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
3016,
304,
267,
291,
14,
2232,
275,
3016,
267,
291,
14,
3922,
63,
1023,
275,
488,
267,
291,
14,
4058,
63,
10000,
63,
6234,
275,
715,
267,
291,
14,
4946,
63,
16541,
275,
942,
267,
291,
14,
6493,
63,
6743,
275,
488,
339,
768,
3744,
272,
347,
7526,
8,
1886,
12,
673,
3016,
29,
403,
12,
673,
3748,
63,
16541,
29,
403,
12,
673,
6330,
63,
6743,
29,
403,
12,
673,
2291,
63,
10000,
63,
6234,
29,
797,
304,
267,
347,
7531,
8,
2232,
304,
288,
2727,
275,
843,
8,
2232,
9,
288,
2727,
14,
4058,
63,
10000,
63,
6234,
275,
2291,
63,
10000,
63,
6234,
288,
2727,
14,
6493,
63,
6743,
275,
6330,
63,
6743,
288,
340,
3748,
63,
16541,
26,
355,
2727,
14,
4946,
63,
16541,
275,
3748,
63,
16541,
288,
372,
2727,
267,
340,
3016,
365,
488,
26,
288,
372,
7531,
267,
372,
7531,
8,
2232,
9,
339,
347,
636,
1250,
721,
277,
12,
6160,
12,
1343,
63,
1310,
304,
267,
1455,
63,
2105,
63,
4181,
275,
359,
288,
1777,
14,
1913,
342,
288,
367,
1777,
315,
6160,
14,
362,
360,
2856,
63,
18389,
297,
12548,
2325,
1252,
1294,
29972,
267,
340,
440,
661,
9375,
7,
315,
1455,
63,
2105,
63,
4181,
436,
355,
6160,
14,
362,
360,
2856,
63,
2160,
28594,
297,
12548,
2325,
342,
508,
283,
13508,
735,
288,
327,
1929,
370,
1104,
282,
9284,
1655,
7645,
2348,
367,
2549,
4151,
288,
1343,
63,
1310,
360,
5303,
8857,
4784,
297,
4274,
3225,
297,
283,
1600,
2023,
288,
372,
942,
398,
862,
26,
288,
340,
283,
2856,
63,
15048,
63,
13166,
17462,
63,
4612,
7,
315,
6160,
26,
355,
10900,
275,
291,
423,
2479,
63,
3577,
4492,
63,
1069,
8,
2314,
9,
288,
916,
291,
14,
4058,
63,
10000,
63,
6234,
26,
355,
10900,
275,
291,
423,
2479,
63,
10000,
63,
1069,
8,
2314,
9,
288,
587,
26,
355,
746,
8857,
2017,
342,
267,
871,
8857,
2017,
465,
325,
26,
288,
2004,
275,
325,
14,
1205,
288,
2396,
275,
325,
14,
2030,
503,
330,
891,
288,
2323,
275,
325,
14,
2139,
503,
942,
288,
1343,
63,
1310,
8,
1205,
12,
2574,
4274,
3225,
297,
283,
1600,
659,
1622,
435,
2323,
9,
288,
372,
359,
2030,
61,
398,
862,
26,
288,
291,
14,
2232,
8,
3569,
9,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
340,
664,
63,
7931,
8,
69,
9,
440,
315,
28538,
2617,
63,
9901,
63,
21477,
26,
355,
746,
267,
327,
4155,
3238,
781,
3222,
314,
11261,
2787,
267,
10900,
423,
2254,
63,
11707,
63,
1943,
8,
549,
9,
267,
327,
675,
642,
625
] |
[
1300,
772,
199,
646,
6010,
199,
646,
5055,
199,
646,
7554,
199,
504,
2196,
492,
9571,
199,
504,
2838,
492,
1125,
465,
17766,
547,
199,
646,
1059,
199,
646,
2702,
199,
646,
984,
199,
646,
900,
199,
199,
646,
12472,
199,
199,
893,
26,
272,
687,
8337,
492,
6128,
21,
12,
7793,
17,
199,
2590,
3545,
26,
221,
327,
11942,
4825,
5099,
2111,
272,
687,
6128,
21,
492,
6128,
21,
272,
687,
7793,
492,
7793,
465,
7793,
17,
199,
199,
504,
21819,
492,
542,
17185,
199,
504,
21819,
492,
12464,
199,
504,
21819,
14,
7731,
492,
2838,
199,
504,
21819,
14,
4058,
492,
664,
63,
7931,
199,
646,
3816,
199,
199,
3,
2018,
499,
1159,
2774,
24,
15952,
365,
1655,
822,
6792,
2419,
781,
5121,
2839,
199,
3,
1010,
1865,
370,
986,
2599,
2470,
6164,
1159,
2295,
2577,
781,
1929,
410,
1567,
351,
6411,
199,
3,
340,
2808,
1396,
199,
509,
485,
1494,
315,
661,
3569,
645,
6067,
14,
1624,
24,
11034,
297,
283,
2495,
2470,
6164,
14,
1624,
24,
11034,
735,
272,
327,
2599,
2470,
6164,
965,
652,
1159,
5705,
2366,
13,
6788,
11822,
14,
315,
29608,
5459,
272,
327,
642,
20491,
1192,
370,
675,
10900,
645,
6067,
12,
282,
29348,
4079,
4514,
12,
340,
2808,
14,
272,
327,
10900,
645,
6067,
1443,
2597,
506,
4903,
336,
15,
548,
2599,
2470,
6164,
12,
503,
543,
282,
14119,
1015,
14,
272,
862,
26,
267,
2774,
24,
11034,
275,
636,
646,
721,
63,
1494,
12,
5479,
5479,
788,
1105,
272,
871,
3545,
26,
267,
2774,
24,
11034,
275,
488,
272,
587,
26,
267,
2059,
199,
199,
13089,
2617,
63,
9901,
63,
21477,
275,
663,
1332,
7931,
14,
37,
17489,
18066,
12,
7554,
14,
37,
6089,
430,
199,
199,
363,
452,
363,
275,
2097,
18477,
16828,
401,
298,
18477,
937,
199,
9583,
63,
17856,
275,
330,
7,
12234,
11765,
2078,
21,
13,
37,
28646,
13,
2417,
8980,
13,
2720,
3263,
13,
35,
21,
1217,
16,
5196,
2426,
34,
845,
7,
199,
5600,
63,
18219,
63,
6305,
275,
663,
8,
272,
769,
8,
1842,
8,
5279,
12,
2948,
20,
430,
435,
272,
769,
8,
1842,
8,
1960,
23,
12,
413,
11533,
430,
435,
272,
327,
29664,
13,
19,
5637,
26,
4644,
367,
675,
701,
8363,
12,
10059,
83,
12,
272,
327,
436,
13103,
272,
769,
8,
1842,
8,
19962,
12,
31092,
430,
435,
272,
327,
31092,
13,
20,
5637,
26,
4644,
367,
5726,
675,
436,
12850,
883,
1133,
272,
327,
506,
7264,
272,
769,
8,
1842,
8,
23641,
12,
22369,
430,
199,
9,
421,
199,
533,
8857,
2017,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
2004,
534,
5303,
8857,
4784,
297,
2396,
29,
403,
12,
2323,
29,
403,
304,
267,
1613,
8,
1726,
12,
291,
2843,
826,
4533,
267,
291,
14,
1205,
275,
2004,
267,
291,
14,
2030,
275,
2396,
267,
291,
14,
2139,
275,
2323,
421,
199,
533,
18846,
16828,
8,
785,
304,
272,
408,
55,
8146,
282,
24897,
3016,
805,
315,
282,
9279,
4223,
14,
339,
3645,
652,
2839,
642,
447,
2541,
768,
13508,
14,
18477,
16828,
489,
347,
3002,
63,
2232,
8,
3569,
304,
881,
687,
63,
5750,
275,
10900,
14,
2573,
342,
881,
10900,
14,
2254,
480,
504,
1654,
531,
339,
710,
2849,
1423,
370,
314,
805,
911,
506,
376,
1256,
402,
272,
520,
533,
1705,
18477,
2313,
221,
4005,
4002,
314,
2838,
12,
9329,
372,
687,
314,
272,
805,
14,
221,
3390,
626,
314,
1654,
911,
943,
314,
24897,
1056,
737,
272,
314,
900,
402,
17903,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
3016,
304,
267,
291,
14,
2232,
275,
3016,
267,
291,
14,
3922,
63,
1023,
275,
488,
267,
291,
14,
4058,
63,
10000,
63,
6234,
275,
715,
267,
291,
14,
4946,
63,
16541,
275,
942,
267,
291,
14,
6493,
63,
6743,
275,
488,
339,
768,
3744,
272,
347,
7526,
8,
1886,
12,
673,
3016,
29,
403,
12,
673,
3748,
63,
16541,
29,
403,
12,
673,
6330,
63,
6743,
29,
403,
12,
673,
2291,
63,
10000,
63,
6234,
29,
797,
304,
267,
347,
7531,
8,
2232,
304,
288,
2727,
275,
843,
8,
2232,
9,
288,
2727,
14,
4058,
63,
10000,
63,
6234,
275,
2291,
63,
10000,
63,
6234,
288,
2727,
14,
6493,
63,
6743,
275,
6330,
63,
6743,
288,
340,
3748,
63,
16541,
26,
355,
2727,
14,
4946,
63,
16541,
275,
3748,
63,
16541,
288,
372,
2727,
267,
340,
3016,
365,
488,
26,
288,
372,
7531,
267,
372,
7531,
8,
2232,
9,
339,
347,
636,
1250,
721,
277,
12,
6160,
12,
1343,
63,
1310,
304,
267,
1455,
63,
2105,
63,
4181,
275,
359,
288,
1777,
14,
1913,
342,
288,
367,
1777,
315,
6160,
14,
362,
360,
2856,
63,
18389,
297,
12548,
2325,
1252,
1294,
29972,
267,
340,
440,
661,
9375,
7,
315,
1455,
63,
2105,
63,
4181,
436,
355,
6160,
14,
362,
360,
2856,
63,
2160,
28594,
297,
12548,
2325,
342,
508,
283,
13508,
735,
288,
327,
1929,
370,
1104,
282,
9284,
1655,
7645,
2348,
367,
2549,
4151,
288,
1343,
63,
1310,
360,
5303,
8857,
4784,
297,
4274,
3225,
297,
283,
1600,
2023,
288,
372,
942,
398,
862,
26,
288,
340,
283,
2856,
63,
15048,
63,
13166,
17462,
63,
4612,
7,
315,
6160,
26,
355,
10900,
275,
291,
423,
2479,
63,
3577,
4492,
63,
1069,
8,
2314,
9,
288,
916,
291,
14,
4058,
63,
10000,
63,
6234,
26,
355,
10900,
275,
291,
423,
2479,
63,
10000,
63,
1069,
8,
2314,
9,
288,
587,
26,
355,
746,
8857,
2017,
342,
267,
871,
8857,
2017,
465,
325,
26,
288,
2004,
275,
325,
14,
1205,
288,
2396,
275,
325,
14,
2030,
503,
330,
891,
288,
2323,
275,
325,
14,
2139,
503,
942,
288,
1343,
63,
1310,
8,
1205,
12,
2574,
4274,
3225,
297,
283,
1600,
659,
1622,
435,
2323,
9,
288,
372,
359,
2030,
61,
398,
862,
26,
288,
291,
14,
2232,
8,
3569,
9,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
340,
664,
63,
7931,
8,
69,
9,
440,
315,
28538,
2617,
63,
9901,
63,
21477,
26,
355,
746,
267,
327,
4155,
3238,
781,
3222,
314,
11261,
2787,
267,
10900,
423,
2254,
63,
11707,
63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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
lucifurtun/myquotes
|
apps/search/bible/management/commands/zefania_xml_generator.py
|
1
|
2231
|
import json
from itertools import groupby
import xmltodict
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Generates zefania xml from different formats'
def handle(self, *args, **options):
with open('NTR.json') as f:
data = json.load(f)
current_b_number = 0
for item in data:
if item['chapter'] == 1 and item['verse'] == 1:
current_b_number += 1
item['b_number'] = current_b_number
grouped_books = groupby(data, lambda item: item['b_number'])
books_list = []
for book_grouper, chapters in grouped_books:
chapters_list = []
grouped_chapters = groupby(chapters, lambda item: item['chapter'])
for chapter_grouper, verses in grouped_chapters:
chapters_list.append({
'number': chapter_grouper,
'items': list(verses)
})
books_list.append({
'title': chapters_list[0]['items'][0]['long_name'],
'number': int(book_grouper),
'items': chapters_list
})
with open('NTR.xml', 'w+') as f:
d = {
'XMLBIBLE': {
'BIBLEBOOK': [
{
'@bnumber': book['number'],
'@bname': book['title'],
'CHAPTER': [
{
'@cnumber': chapter['number'],
'VERS': [
{
'@vnumber': verse['verse'],
'#text': verse['text']
} for verse in chapter['items']
]
} for chapter in book['items']
]
} for book in books_list
]
}
}
f.write(xmltodict.unparse(d, pretty=True))
self.stdout.write(self.style.SUCCESS('Imported!'))
|
bsd-3-clause
|
[
646,
2022,
199,
504,
7975,
492,
20371,
199,
199,
646,
2748,
475,
807,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
20551,
29986,
12269,
4674,
2748,
687,
3365,
6752,
7,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
267,
543,
1551,
360,
46,
1766,
14,
1001,
358,
465,
289,
26,
288,
666,
275,
2022,
14,
912,
8,
70,
9,
398,
1453,
63,
66,
63,
1955,
275,
378,
398,
367,
1242,
315,
666,
26,
288,
340,
1242,
459,
11316,
418,
508,
413,
436,
1242,
459,
2077,
418,
508,
413,
26,
355,
1453,
63,
66,
63,
1955,
847,
413,
953,
1242,
459,
66,
63,
1955,
418,
275,
1453,
63,
66,
63,
1955,
398,
16251,
63,
8858,
275,
20371,
8,
576,
12,
2400,
1242,
26,
1242,
459,
66,
63,
1955,
1105,
267,
19040,
63,
513,
275,
942,
398,
367,
6719,
63,
923,
281,
12,
26041,
315,
16251,
63,
8858,
26,
288,
26041,
63,
513,
275,
942,
288,
16251,
63,
335,
12552,
275,
20371,
8,
335,
12552,
12,
2400,
1242,
26,
1242,
459,
11316,
1105,
288,
367,
17044,
63,
923,
281,
12,
809,
874,
315,
16251,
63,
335,
12552,
26,
355,
26041,
63,
513,
14,
740,
2561,
490,
283,
1955,
356,
17044,
63,
923,
281,
12,
490,
283,
1744,
356,
769,
8,
422,
874,
9,
355,
3828,
953,
19040,
63,
513,
14,
740,
2561,
355,
283,
1213,
356,
26041,
63,
513,
59,
16,
2733,
1744,
3488,
16,
2733,
2809,
63,
354,
995,
355,
283,
1955,
356,
1109,
8,
2706,
63,
923,
281,
395,
355,
283,
1744,
356,
26041,
63,
513,
288,
3828,
398,
543,
1551,
360,
46,
1766,
14,
1652,
297,
283,
87,
13854,
465,
289,
26,
288,
366,
275,
469,
355,
283,
4317,
34,
7187,
356,
469,
490,
283,
34,
7187,
21155,
356,
359,
717,
469,
1169,
10267,
66,
1955,
356,
6719,
459,
1955,
995,
1169,
10267,
66,
354,
356,
6719,
459,
1213,
995,
1169,
283,
1244,
1282,
1157,
356,
359,
1816,
469,
2511,
10267,
67,
1955,
356,
17044,
459,
1955,
995,
2511,
283,
17223,
356,
359,
3147,
469,
4490,
10267,
86,
1955,
356,
809,
261,
459,
2077,
995,
4490,
3943,
505,
356,
809,
261,
459,
505,
418,
3147,
789,
367,
809,
261,
315,
17044,
459,
1744,
418,
2511,
1622,
1816,
789,
367,
17044,
315,
6719,
459,
1744,
418,
1169,
1622,
9453,
789,
367,
6719,
315,
19040,
63,
513,
490,
1622,
355,
789,
288,
789,
953,
289,
14,
952,
8,
1652,
475,
807,
14,
18185,
8,
68,
12,
7268,
29,
549,
430,
398,
291,
14,
2703,
14,
952,
8,
277,
14,
2487,
14,
12779,
360,
8499,
1376,
1,
1333,
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
] |
[
2022,
199,
504,
7975,
492,
20371,
199,
199,
646,
2748,
475,
807,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
20551,
29986,
12269,
4674,
2748,
687,
3365,
6752,
7,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
267,
543,
1551,
360,
46,
1766,
14,
1001,
358,
465,
289,
26,
288,
666,
275,
2022,
14,
912,
8,
70,
9,
398,
1453,
63,
66,
63,
1955,
275,
378,
398,
367,
1242,
315,
666,
26,
288,
340,
1242,
459,
11316,
418,
508,
413,
436,
1242,
459,
2077,
418,
508,
413,
26,
355,
1453,
63,
66,
63,
1955,
847,
413,
953,
1242,
459,
66,
63,
1955,
418,
275,
1453,
63,
66,
63,
1955,
398,
16251,
63,
8858,
275,
20371,
8,
576,
12,
2400,
1242,
26,
1242,
459,
66,
63,
1955,
1105,
267,
19040,
63,
513,
275,
942,
398,
367,
6719,
63,
923,
281,
12,
26041,
315,
16251,
63,
8858,
26,
288,
26041,
63,
513,
275,
942,
288,
16251,
63,
335,
12552,
275,
20371,
8,
335,
12552,
12,
2400,
1242,
26,
1242,
459,
11316,
1105,
288,
367,
17044,
63,
923,
281,
12,
809,
874,
315,
16251,
63,
335,
12552,
26,
355,
26041,
63,
513,
14,
740,
2561,
490,
283,
1955,
356,
17044,
63,
923,
281,
12,
490,
283,
1744,
356,
769,
8,
422,
874,
9,
355,
3828,
953,
19040,
63,
513,
14,
740,
2561,
355,
283,
1213,
356,
26041,
63,
513,
59,
16,
2733,
1744,
3488,
16,
2733,
2809,
63,
354,
995,
355,
283,
1955,
356,
1109,
8,
2706,
63,
923,
281,
395,
355,
283,
1744,
356,
26041,
63,
513,
288,
3828,
398,
543,
1551,
360,
46,
1766,
14,
1652,
297,
283,
87,
13854,
465,
289,
26,
288,
366,
275,
469,
355,
283,
4317,
34,
7187,
356,
469,
490,
283,
34,
7187,
21155,
356,
359,
717,
469,
1169,
10267,
66,
1955,
356,
6719,
459,
1955,
995,
1169,
10267,
66,
354,
356,
6719,
459,
1213,
995,
1169,
283,
1244,
1282,
1157,
356,
359,
1816,
469,
2511,
10267,
67,
1955,
356,
17044,
459,
1955,
995,
2511,
283,
17223,
356,
359,
3147,
469,
4490,
10267,
86,
1955,
356,
809,
261,
459,
2077,
995,
4490,
3943,
505,
356,
809,
261,
459,
505,
418,
3147,
789,
367,
809,
261,
315,
17044,
459,
1744,
418,
2511,
1622,
1816,
789,
367,
17044,
315,
6719,
459,
1744,
418,
1169,
1622,
9453,
789,
367,
6719,
315,
19040,
63,
513,
490,
1622,
355,
789,
288,
789,
953,
289,
14,
952,
8,
1652,
475,
807,
14,
18185,
8,
68,
12,
7268,
29,
549,
430,
398,
291,
14,
2703,
14,
952,
8,
277,
14,
2487,
14,
12779,
360,
8499,
1376,
1,
1333,
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,
32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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
miguelinux/vbox
|
src/VBox/Additions/common/crOpenGL/cr_gl.py
|
5
|
1632
|
print """
/** @file
* VBox OpenGL chromium functions header
*/
/*
* Copyright (C) 2008-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
"""
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.
import sys
import apiutil
apiutil.CopyrightC()
print """
/* DO NOT EDIT - THIS FILE GENERATED BY THE cr_gl.py SCRIPT */
#ifndef __CR_GL_H__
#define __CR_GL_H__
#include "chromium.h"
#include "cr_string.h"
#include "cr_version.h"
#include "stub.h"
#ifdef WINDOWS
#pragma warning( disable: 4055 )
#endif
"""
# Extern-like declarations
keys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
for func_name in keys:
if "Chromium" == apiutil.Category(func_name):
continue
if "VBox" == apiutil.Category(func_name):
continue
if func_name == "BoundsInfoCR":
continue
if "GL_chromium" == apiutil.Category(func_name):
pass #continue
return_type = apiutil.ReturnType(func_name)
params = apiutil.Parameters(func_name)
print "extern %s cr_gl%s( %s );" % (return_type, func_name,
apiutil.MakeDeclarationString( params ))
print "#endif /* __CR_GL_H__ */"
|
gpl-2.0
|
[
1361,
408,
199,
15,
538,
768,
493,
199,
627,
812,
3532,
24374,
682,
7419,
3423,
1406,
199,
11589,
199,
199,
6331,
199,
627,
1898,
334,
35,
9,
9079,
13,
7806,
15309,
11098,
199,
627,
199,
627,
961,
570,
365,
1777,
402,
13311,
3532,
3232,
5800,
662,
1671,
334,
47,
899,
395,
465,
199,
627,
2808,
687,
1455,
921,
1544,
14,
2065,
1977,
14,
1308,
14,
961,
570,
365,
2867,
2032,
27,
199,
627,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
199,
627,
1696,
1684,
844,
334,
12006,
9,
465,
3267,
701,
314,
2868,
2290,
199,
627,
2752,
12,
315,
1015,
499,
465,
652,
12477,
315,
314,
298,
16188,
1206,
2,
570,
402,
314,
199,
627,
13311,
3532,
593,
899,
4084,
14,
13311,
3532,
593,
899,
365,
1854,
315,
314,
199,
627,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
3408,
402,
1263,
4928,
14,
199,
11589,
199,
624,
199,
3,
1898,
334,
67,
9,
12521,
12,
1933,
290,
18090,
15904,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
1666,
314,
570,
5113,
14,
2424,
367,
2556,
641,
295,
20231,
4655,
642,
2032,
14,
199,
199,
646,
984,
199,
199,
646,
2986,
1974,
199,
199,
1246,
1974,
14,
7384,
35,
342,
199,
199,
1361,
408,
199,
6331,
3506,
2845,
24981,
446,
5749,
13024,
29087,
6989,
6515,
2334,
2467,
63,
3528,
14,
647,
30203,
11589,
199,
3,
27708,
636,
2944,
63,
2226,
63,
40,
363,
199,
3,
4640,
636,
2944,
63,
2226,
63,
40,
363,
199,
199,
3,
2613,
298,
13211,
14,
72,
2,
199,
3,
2613,
298,
1556,
63,
875,
14,
72,
2,
199,
3,
2613,
298,
1556,
63,
1023,
14,
72,
2,
199,
3,
2613,
298,
5811,
14,
72,
2,
199,
199,
3,
27737,
20896,
1649,
5035,
199,
3,
25852,
5721,
8,
3507,
26,
6335,
1229,
776,
199,
3,
13739,
199,
199,
624,
421,
199,
3,
1316,
1203,
13,
2930,
18707,
199,
1612,
275,
2986,
1974,
14,
24578,
13967,
8,
1274,
14,
3020,
59,
17,
2807,
15313,
3735,
1650,
14,
2424,
531,
199,
509,
2562,
63,
354,
315,
2883,
26,
199,
198,
692,
298,
29381,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
6958,
199,
198,
692,
298,
54,
3532,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
6958,
199,
198,
692,
2562,
63,
354,
508,
298,
23557,
2354,
2944,
582,
507,
198,
6958,
199,
198,
692,
298,
2226,
63,
13211,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
1529,
327,
6958,
421,
198,
1107,
63,
466,
275,
2986,
1974,
14,
1767,
804,
8,
1532,
63,
354,
9,
199,
198,
1162,
275,
2986,
1974,
14,
5976,
8,
1532,
63,
354,
9,
421,
198,
1361,
298,
18587,
450,
83,
2467,
63,
3528,
5,
83,
8,
450,
83,
776,
9426,
450,
334,
1107,
63,
466,
12,
2562,
63,
354,
12,
22680,
221,
2986,
1974,
14,
5483,
17737,
1558,
8,
1862,
5082,
199,
199,
1361,
5426,
13739,
13505,
636,
2944,
63,
2226,
63,
40,
363,
627,
6687,
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
] |
[
408,
199,
15,
538,
768,
493,
199,
627,
812,
3532,
24374,
682,
7419,
3423,
1406,
199,
11589,
199,
199,
6331,
199,
627,
1898,
334,
35,
9,
9079,
13,
7806,
15309,
11098,
199,
627,
199,
627,
961,
570,
365,
1777,
402,
13311,
3532,
3232,
5800,
662,
1671,
334,
47,
899,
395,
465,
199,
627,
2808,
687,
1455,
921,
1544,
14,
2065,
1977,
14,
1308,
14,
961,
570,
365,
2867,
2032,
27,
199,
627,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
199,
627,
1696,
1684,
844,
334,
12006,
9,
465,
3267,
701,
314,
2868,
2290,
199,
627,
2752,
12,
315,
1015,
499,
465,
652,
12477,
315,
314,
298,
16188,
1206,
2,
570,
402,
314,
199,
627,
13311,
3532,
593,
899,
4084,
14,
13311,
3532,
593,
899,
365,
1854,
315,
314,
199,
627,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
3408,
402,
1263,
4928,
14,
199,
11589,
199,
624,
199,
3,
1898,
334,
67,
9,
12521,
12,
1933,
290,
18090,
15904,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
1666,
314,
570,
5113,
14,
2424,
367,
2556,
641,
295,
20231,
4655,
642,
2032,
14,
199,
199,
646,
984,
199,
199,
646,
2986,
1974,
199,
199,
1246,
1974,
14,
7384,
35,
342,
199,
199,
1361,
408,
199,
6331,
3506,
2845,
24981,
446,
5749,
13024,
29087,
6989,
6515,
2334,
2467,
63,
3528,
14,
647,
30203,
11589,
199,
3,
27708,
636,
2944,
63,
2226,
63,
40,
363,
199,
3,
4640,
636,
2944,
63,
2226,
63,
40,
363,
199,
199,
3,
2613,
298,
13211,
14,
72,
2,
199,
3,
2613,
298,
1556,
63,
875,
14,
72,
2,
199,
3,
2613,
298,
1556,
63,
1023,
14,
72,
2,
199,
3,
2613,
298,
5811,
14,
72,
2,
199,
199,
3,
27737,
20896,
1649,
5035,
199,
3,
25852,
5721,
8,
3507,
26,
6335,
1229,
776,
199,
3,
13739,
199,
199,
624,
421,
199,
3,
1316,
1203,
13,
2930,
18707,
199,
1612,
275,
2986,
1974,
14,
24578,
13967,
8,
1274,
14,
3020,
59,
17,
2807,
15313,
3735,
1650,
14,
2424,
531,
199,
509,
2562,
63,
354,
315,
2883,
26,
199,
198,
692,
298,
29381,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
6958,
199,
198,
692,
298,
54,
3532,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
6958,
199,
198,
692,
2562,
63,
354,
508,
298,
23557,
2354,
2944,
582,
507,
198,
6958,
199,
198,
692,
298,
2226,
63,
13211,
2,
508,
2986,
1974,
14,
7841,
8,
1532,
63,
354,
304,
507,
198,
1529,
327,
6958,
421,
198,
1107,
63,
466,
275,
2986,
1974,
14,
1767,
804,
8,
1532,
63,
354,
9,
199,
198,
1162,
275,
2986,
1974,
14,
5976,
8,
1532,
63,
354,
9,
421,
198,
1361,
298,
18587,
450,
83,
2467,
63,
3528,
5,
83,
8,
450,
83,
776,
9426,
450,
334,
1107,
63,
466,
12,
2562,
63,
354,
12,
22680,
221,
2986,
1974,
14,
5483,
17737,
1558,
8,
1862,
5082,
199,
199,
1361,
5426,
13739,
13505,
636,
2944,
63,
2226,
63,
40,
363,
627,
6687,
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,
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,
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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
] |
IRI-Research/django
|
django/contrib/gis/maps/google/zoom.py
|
12
|
6683
|
from __future__ import unicode_literals
from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point
from django.contrib.gis.maps.google.gmap import GoogleMapException
from django.utils.six.moves import xrange
from math import pi, sin, log, exp, atan
# Constants used for degree to radian conversion, and vice-versa.
DTOR = pi / 180.
RTOD = 180. / pi
class GoogleZoom(object):
"""
GoogleZoom is a utility for performing operations related to the zoom
levels on Google Maps.
This class is inspired by the OpenStreetMap Mapnik tile generation routine
`generate_tiles.py`, and the article "How Big Is the World" (Hack #16) in
"Google Maps Hacks" by Rich Gibson and Schuyler Erle.
`generate_tiles.py` may be found at:
http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py
"Google Maps Hacks" may be found at http://safari.oreilly.com/0596101619
"""
def __init__(self, num_zoom=19, tilesize=256):
"Initializes the Google Zoom object."
# Google's tilesize is 256x256, square tiles are assumed.
self._tilesize = tilesize
# The number of zoom levels
self._nzoom = num_zoom
# Initializing arrays to hold the parameters for each one of the
# zoom levels.
self._degpp = [] # Degrees per pixel
self._radpp = [] # Radians per pixel
self._npix = [] # 1/2 the number of pixels for a tile at the given zoom level
# Incrementing through the zoom levels and populating the parameter arrays.
z = tilesize # The number of pixels per zoom level.
for i in xrange(num_zoom):
# Getting the degrees and radians per pixel, and the 1/2 the number of
# for every zoom level.
self._degpp.append(z / 360.) # degrees per pixel
self._radpp.append(z / (2 * pi)) # radians per pixel
self._npix.append(z / 2) # number of pixels to center of tile
# Multiplying `z` by 2 for the next iteration.
z *= 2
def __len__(self):
"Returns the number of zoom levels."
return self._nzoom
def get_lon_lat(self, lonlat):
"Unpacks longitude, latitude from GEOS Points and 2-tuples."
if isinstance(lonlat, Point):
lon, lat = lonlat.coords
else:
lon, lat = lonlat
return lon, lat
def lonlat_to_pixel(self, lonlat, zoom):
"Converts a longitude, latitude coordinate pair for the given zoom level."
# Setting up, unpacking the longitude, latitude values and getting the
# number of pixels for the given zoom level.
lon, lat = self.get_lon_lat(lonlat)
npix = self._npix[zoom]
# Calculating the pixel x coordinate by multiplying the longitude value
# with with the number of degrees/pixel at the given zoom level.
px_x = round(npix + (lon * self._degpp[zoom]))
# Creating the factor, and ensuring that 1 or -1 is not passed in as the
# base to the logarithm. Here's why:
# if fac = -1, we'll get log(0) which is undefined;
# if fac = 1, our logarithm base will be divided by 0, also undefined.
fac = min(max(sin(DTOR * lat), -0.9999), 0.9999)
# Calculating the pixel y coordinate.
px_y = round(npix + (0.5 * log((1 + fac) / (1 - fac)) * (-1.0 * self._radpp[zoom])))
# Returning the pixel x, y to the caller of the function.
return (px_x, px_y)
def pixel_to_lonlat(self, px, zoom):
"Converts a pixel to a longitude, latitude pair at the given zoom level."
if len(px) != 2:
raise TypeError('Pixel should be a sequence of two elements.')
# Getting the number of pixels for the given zoom level.
npix = self._npix[zoom]
# Calculating the longitude value, using the degrees per pixel.
lon = (px[0] - npix) / self._degpp[zoom]
# Calculating the latitude value.
lat = RTOD * (2 * atan(exp((px[1] - npix) / (-1.0 * self._radpp[zoom]))) - 0.5 * pi)
# Returning the longitude, latitude coordinate pair.
return (lon, lat)
def tile(self, lonlat, zoom):
"""
Returns a Polygon corresponding to the region represented by a fictional
Google Tile for the given longitude/latitude pair and zoom level. This
tile is used to determine the size of a tile at the given point.
"""
# The given lonlat is the center of the tile.
delta = self._tilesize / 2
# Getting the pixel coordinates corresponding to the
# the longitude/latitude.
px = self.lonlat_to_pixel(lonlat, zoom)
# Getting the lower-left and upper-right lat/lon coordinates
# for the bounding box of the tile.
ll = self.pixel_to_lonlat((px[0] - delta, px[1] - delta), zoom)
ur = self.pixel_to_lonlat((px[0] + delta, px[1] + delta), zoom)
# Constructing the Polygon, representing the tile and returning.
return Polygon(LinearRing(ll, (ll[0], ur[1]), ur, (ur[0], ll[1]), ll), srid=4326)
def get_zoom(self, geom):
"Returns the optimal Zoom level for the given geometry."
# Checking the input type.
if not isinstance(geom, GEOSGeometry) or geom.srid != 4326:
raise TypeError('get_zoom() expects a GEOS Geometry with an SRID of 4326.')
# Getting the envelope for the geometry, and its associated width, height
# and centroid.
env = geom.envelope
env_w, env_h = self.get_width_height(env.extent)
center = env.centroid
for z in xrange(self._nzoom):
# Getting the tile at the zoom level.
tile_w, tile_h = self.get_width_height(self.tile(center, z).extent)
# When we span more than one tile, this is an approximately good
# zoom level.
if (env_w > tile_w) or (env_h > tile_h):
if z == 0:
raise GoogleMapException('Geometry width and height should not exceed that of the Earth.')
return z - 1
# Otherwise, we've zoomed in to the max.
return self._nzoom - 1
def get_width_height(self, extent):
"""
Returns the width and height for the given extent.
"""
# Getting the lower-left, upper-left, and upper-right
# coordinates from the extent.
ll = Point(extent[:2])
ul = Point(extent[0], extent[3])
ur = Point(extent[2:])
# Calculating the width and height.
height = ll.distance(ul)
width = ul.distance(ur)
return width, height
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
21479,
12,
12489,
15420,
12,
17560,
12,
7584,
199,
504,
1639,
14,
2828,
14,
5668,
14,
8919,
14,
3098,
14,
71,
1130,
492,
4475,
2956,
1726,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
4945,
199,
504,
3473,
492,
6682,
12,
9829,
12,
943,
12,
1437,
12,
31393,
199,
199,
3,
22296,
1202,
367,
13666,
370,
660,
6268,
8603,
12,
436,
1321,
301,
13,
422,
2231,
14,
199,
7438,
726,
275,
6682,
1182,
13576,
14,
199,
50,
2566,
36,
275,
13576,
14,
1182,
6682,
421,
199,
533,
4475,
26798,
8,
785,
304,
272,
408,
272,
4475,
26798,
365,
282,
11420,
367,
19203,
5331,
4048,
370,
314,
16935,
272,
11106,
641,
4475,
23673,
14,
339,
961,
1021,
365,
315,
8721,
581,
701,
314,
3232,
933,
7936,
2956,
9672,
22998,
12835,
10152,
12981,
272,
658,
4208,
63,
18819,
14,
647,
3559,
436,
314,
9772,
298,
18335,
13123,
6596,
314,
13064,
2,
334,
40,
564,
327,
975,
9,
315,
272,
298,
13266,
23673,
30802,
83,
2,
701,
30846,
598,
1892,
834,
436,
22985,
29514,
1435,
221,
539,
274,
14,
339,
658,
4208,
63,
18819,
14,
647,
64,
1443,
506,
1911,
737,
26,
489,
1455,
921,
23047,
14,
1490,
20451,
1130,
14,
1308,
15,
5750,
15,
15853,
15,
28228,
15,
1130,
22998,
15,
4208,
63,
18819,
14,
647,
339,
298,
13266,
23673,
30802,
83,
2,
1443,
506,
1911,
737,
1455,
921,
2231,
70,
759,
14,
720,
382,
590,
14,
957,
15,
27479,
2976,
10882,
1167,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1967,
63,
10598,
29,
1167,
12,
12835,
890,
29,
3912,
304,
267,
298,
23489,
314,
4475,
3107,
7501,
909,
2122,
267,
327,
4475,
1159,
12835,
890,
365,
7633,
88,
3912,
12,
12386,
30419,
787,
10826,
14,
267,
291,
423,
7172,
890,
275,
12835,
890,
398,
327,
710,
1329,
402,
16935,
11106,
267,
291,
423,
78,
10598,
275,
1967,
63,
10598,
398,
327,
6026,
9147,
6572,
370,
10266,
314,
2633,
367,
1924,
1373,
402,
314,
267,
327,
16935,
11106,
14,
267,
291,
423,
6458,
802,
275,
942,
221,
327,
1487,
71,
5710,
1126,
7148,
267,
291,
423,
9525,
802,
275,
942,
221,
327,
3898,
328,
796,
1126,
7148,
267,
291,
423,
78,
6644,
275,
942,
221,
327,
413,
15,
18,
314,
1329,
402,
11094,
367,
282,
12835,
737,
314,
1627,
16935,
2166,
398,
327,
1010,
4062,
316,
4012,
314,
16935,
11106,
436,
4560,
20529,
314,
2725,
6572,
14,
267,
1315,
275,
12835,
890,
221,
327,
710,
1329,
402,
11094,
1126,
16935,
2166,
14,
267,
367,
284,
315,
4945,
8,
1507,
63,
10598,
304,
288,
327,
20703,
314,
14358,
436,
26874,
1126,
7148,
12,
436,
314,
413,
15,
18,
314,
1329,
402,
288,
327,
367,
4036,
16935,
2166,
14,
288,
291,
423,
6458,
802,
14,
740,
8,
90,
1182,
19434,
4959,
221,
327,
14358,
1126,
7148,
288,
291,
423,
9525,
802,
14,
740,
8,
90,
1182,
334,
18,
627,
6682,
430,
221,
327,
26874,
1126,
7148,
288,
291,
423,
78,
6644,
14,
740,
8,
90,
1182,
499,
9,
221,
327,
1329,
402,
11094,
370,
8126,
402,
12835,
953,
327,
603,
2092,
6670,
658,
90,
64,
701,
499,
367,
314,
2163,
8494,
14,
288,
1315,
9000,
499,
339,
347,
636,
552,
721,
277,
304,
267,
298,
3407,
314,
1329,
402,
16935,
11106,
2122,
267,
372,
291,
423,
78,
10598,
339,
347,
664,
63,
5298,
63,
4452,
8,
277,
12,
6132,
4452,
304,
267,
298,
26472,
83,
18154,
12,
18896,
687,
11920,
32598,
436,
499,
13,
11760,
2122,
267,
340,
1228,
8,
5298,
4452,
12,
7584,
304,
288,
6132,
12,
8396,
275,
6132,
4452,
14,
8032,
267,
587,
26,
288,
6132,
12,
8396,
275,
6132,
4452,
267,
372,
6132,
12,
8396,
339,
347,
6132,
4452,
63,
475,
63,
8435,
8,
277,
12,
6132,
4452,
12,
16935,
304,
267,
298,
17729,
282,
18154,
12,
18896,
10021,
4092,
367,
314,
1627,
16935,
2166,
2122,
267,
327,
13510,
1536,
12,
7787,
316,
314,
18154,
12,
18896,
1338,
436,
10232,
314,
267,
327,
1329,
402,
11094,
367,
314,
1627,
16935,
2166,
14,
267,
6132,
12,
8396,
275,
291,
14,
362,
63,
5298,
63,
4452,
8,
5298,
4452,
9,
267,
980,
1148,
275,
291,
423,
78,
6644,
59,
10598,
61,
398,
327,
19821,
1958,
314,
7148,
671,
10021,
701,
8897,
6670,
314,
18154,
574,
267,
327,
543,
543,
314,
1329,
402,
14358,
15,
8435,
737,
314,
1627,
16935,
2166,
14,
267,
21162,
63,
88,
275,
6168,
8,
78,
6644,
435,
334,
5298,
627,
291,
423,
6458,
802,
59,
10598,
2459,
398,
327,
20507,
314,
6535,
12,
436,
12889,
4039,
626,
413,
503,
446,
17,
365,
440,
3032,
315,
465,
314,
267,
327,
1300,
370,
314,
943,
18327,
77,
14,
221,
11842,
1159,
10842,
26,
267,
327,
221,
340,
21625,
275,
446,
17,
12,
781,
7171,
664,
943,
8,
16,
9,
1314,
365,
10942,
27,
267,
327,
221,
340,
21625,
275,
221,
413,
12,
4154,
943,
18327,
77,
1300,
911,
506,
29378,
701,
378,
12,
2597,
10942,
14,
267,
21625,
275,
1748,
8,
988,
8,
5911,
8,
7438,
726,
627,
8396,
395,
446,
16,
14,
5008,
395,
378,
14,
5008,
9,
398,
327,
19821,
1958,
314,
7148,
612,
10021,
14,
267,
21162,
63,
89,
275,
6168,
8,
78,
6644,
435,
334,
16,
14,
21,
627,
943,
1332,
17,
435,
21625,
9,
1182,
334,
17,
446,
21625,
430,
627,
5868,
17,
14,
16,
627,
291,
423,
9525,
802,
59,
10598,
11845,
398,
327,
1432,
316,
314,
7148,
671,
12,
612,
370,
314,
8025,
402,
314,
805,
14,
267,
372,
334,
5326,
63,
88,
12,
21162,
63,
89,
9,
339,
347,
7148,
63,
475,
63,
5298,
4452,
8,
277,
12,
21162,
12,
16935,
304,
267,
298,
17729,
282,
7148,
370,
282,
18154,
12,
18896,
4092,
737,
314,
1627,
16935,
2166,
2122,
267,
340,
822,
8,
5326,
9,
1137,
499,
26,
288,
746,
3146,
360,
14383,
1077,
506,
282,
3414,
402,
2877,
4008,
2659,
398,
327,
20703,
314,
1329,
402,
11094,
367,
314,
1627,
16935,
2166,
14,
267,
980,
1148,
275,
291,
423,
78,
6644,
59,
10598,
61,
398,
327,
19821,
1958,
314,
18154,
574,
12
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
492,
21479,
12,
12489,
15420,
12,
17560,
12,
7584,
199,
504,
1639,
14,
2828,
14,
5668,
14,
8919,
14,
3098,
14,
71,
1130,
492,
4475,
2956,
1726,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
4945,
199,
504,
3473,
492,
6682,
12,
9829,
12,
943,
12,
1437,
12,
31393,
199,
199,
3,
22296,
1202,
367,
13666,
370,
660,
6268,
8603,
12,
436,
1321,
301,
13,
422,
2231,
14,
199,
7438,
726,
275,
6682,
1182,
13576,
14,
199,
50,
2566,
36,
275,
13576,
14,
1182,
6682,
421,
199,
533,
4475,
26798,
8,
785,
304,
272,
408,
272,
4475,
26798,
365,
282,
11420,
367,
19203,
5331,
4048,
370,
314,
16935,
272,
11106,
641,
4475,
23673,
14,
339,
961,
1021,
365,
315,
8721,
581,
701,
314,
3232,
933,
7936,
2956,
9672,
22998,
12835,
10152,
12981,
272,
658,
4208,
63,
18819,
14,
647,
3559,
436,
314,
9772,
298,
18335,
13123,
6596,
314,
13064,
2,
334,
40,
564,
327,
975,
9,
315,
272,
298,
13266,
23673,
30802,
83,
2,
701,
30846,
598,
1892,
834,
436,
22985,
29514,
1435,
221,
539,
274,
14,
339,
658,
4208,
63,
18819,
14,
647,
64,
1443,
506,
1911,
737,
26,
489,
1455,
921,
23047,
14,
1490,
20451,
1130,
14,
1308,
15,
5750,
15,
15853,
15,
28228,
15,
1130,
22998,
15,
4208,
63,
18819,
14,
647,
339,
298,
13266,
23673,
30802,
83,
2,
1443,
506,
1911,
737,
1455,
921,
2231,
70,
759,
14,
720,
382,
590,
14,
957,
15,
27479,
2976,
10882,
1167,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1967,
63,
10598,
29,
1167,
12,
12835,
890,
29,
3912,
304,
267,
298,
23489,
314,
4475,
3107,
7501,
909,
2122,
267,
327,
4475,
1159,
12835,
890,
365,
7633,
88,
3912,
12,
12386,
30419,
787,
10826,
14,
267,
291,
423,
7172,
890,
275,
12835,
890,
398,
327,
710,
1329,
402,
16935,
11106,
267,
291,
423,
78,
10598,
275,
1967,
63,
10598,
398,
327,
6026,
9147,
6572,
370,
10266,
314,
2633,
367,
1924,
1373,
402,
314,
267,
327,
16935,
11106,
14,
267,
291,
423,
6458,
802,
275,
942,
221,
327,
1487,
71,
5710,
1126,
7148,
267,
291,
423,
9525,
802,
275,
942,
221,
327,
3898,
328,
796,
1126,
7148,
267,
291,
423,
78,
6644,
275,
942,
221,
327,
413,
15,
18,
314,
1329,
402,
11094,
367,
282,
12835,
737,
314,
1627,
16935,
2166,
398,
327,
1010,
4062,
316,
4012,
314,
16935,
11106,
436,
4560,
20529,
314,
2725,
6572,
14,
267,
1315,
275,
12835,
890,
221,
327,
710,
1329,
402,
11094,
1126,
16935,
2166,
14,
267,
367,
284,
315,
4945,
8,
1507,
63,
10598,
304,
288,
327,
20703,
314,
14358,
436,
26874,
1126,
7148,
12,
436,
314,
413,
15,
18,
314,
1329,
402,
288,
327,
367,
4036,
16935,
2166,
14,
288,
291,
423,
6458,
802,
14,
740,
8,
90,
1182,
19434,
4959,
221,
327,
14358,
1126,
7148,
288,
291,
423,
9525,
802,
14,
740,
8,
90,
1182,
334,
18,
627,
6682,
430,
221,
327,
26874,
1126,
7148,
288,
291,
423,
78,
6644,
14,
740,
8,
90,
1182,
499,
9,
221,
327,
1329,
402,
11094,
370,
8126,
402,
12835,
953,
327,
603,
2092,
6670,
658,
90,
64,
701,
499,
367,
314,
2163,
8494,
14,
288,
1315,
9000,
499,
339,
347,
636,
552,
721,
277,
304,
267,
298,
3407,
314,
1329,
402,
16935,
11106,
2122,
267,
372,
291,
423,
78,
10598,
339,
347,
664,
63,
5298,
63,
4452,
8,
277,
12,
6132,
4452,
304,
267,
298,
26472,
83,
18154,
12,
18896,
687,
11920,
32598,
436,
499,
13,
11760,
2122,
267,
340,
1228,
8,
5298,
4452,
12,
7584,
304,
288,
6132,
12,
8396,
275,
6132,
4452,
14,
8032,
267,
587,
26,
288,
6132,
12,
8396,
275,
6132,
4452,
267,
372,
6132,
12,
8396,
339,
347,
6132,
4452,
63,
475,
63,
8435,
8,
277,
12,
6132,
4452,
12,
16935,
304,
267,
298,
17729,
282,
18154,
12,
18896,
10021,
4092,
367,
314,
1627,
16935,
2166,
2122,
267,
327,
13510,
1536,
12,
7787,
316,
314,
18154,
12,
18896,
1338,
436,
10232,
314,
267,
327,
1329,
402,
11094,
367,
314,
1627,
16935,
2166,
14,
267,
6132,
12,
8396,
275,
291,
14,
362,
63,
5298,
63,
4452,
8,
5298,
4452,
9,
267,
980,
1148,
275,
291,
423,
78,
6644,
59,
10598,
61,
398,
327,
19821,
1958,
314,
7148,
671,
10021,
701,
8897,
6670,
314,
18154,
574,
267,
327,
543,
543,
314,
1329,
402,
14358,
15,
8435,
737,
314,
1627,
16935,
2166,
14,
267,
21162,
63,
88,
275,
6168,
8,
78,
6644,
435,
334,
5298,
627,
291,
423,
6458,
802,
59,
10598,
2459,
398,
327,
20507,
314,
6535,
12,
436,
12889,
4039,
626,
413,
503,
446,
17,
365,
440,
3032,
315,
465,
314,
267,
327,
1300,
370,
314,
943,
18327,
77,
14,
221,
11842,
1159,
10842,
26,
267,
327,
221,
340,
21625,
275,
446,
17,
12,
781,
7171,
664,
943,
8,
16,
9,
1314,
365,
10942,
27,
267,
327,
221,
340,
21625,
275,
221,
413,
12,
4154,
943,
18327,
77,
1300,
911,
506,
29378,
701,
378,
12,
2597,
10942,
14,
267,
21625,
275,
1748,
8,
988,
8,
5911,
8,
7438,
726,
627,
8396,
395,
446,
16,
14,
5008,
395,
378,
14,
5008,
9,
398,
327,
19821,
1958,
314,
7148,
612,
10021,
14,
267,
21162,
63,
89,
275,
6168,
8,
78,
6644,
435,
334,
16,
14,
21,
627,
943,
1332,
17,
435,
21625,
9,
1182,
334,
17,
446,
21625,
430,
627,
5868,
17,
14,
16,
627,
291,
423,
9525,
802,
59,
10598,
11845,
398,
327,
1432,
316,
314,
7148,
671,
12,
612,
370,
314,
8025,
402,
314,
805,
14,
267,
372,
334,
5326,
63,
88,
12,
21162,
63,
89,
9,
339,
347,
7148,
63,
475,
63,
5298,
4452,
8,
277,
12,
21162,
12,
16935,
304,
267,
298,
17729,
282,
7148,
370,
282,
18154,
12,
18896,
4092,
737,
314,
1627,
16935,
2166,
2122,
267,
340,
822,
8,
5326,
9,
1137,
499,
26,
288,
746,
3146,
360,
14383,
1077,
506,
282,
3414,
402,
2877,
4008,
2659,
398,
327,
20703,
314,
1329,
402,
11094,
367,
314,
1627,
16935,
2166,
14,
267,
980,
1148,
275,
291,
423,
78,
6644,
59,
10598,
61,
398,
327,
19821,
1958,
314,
18154,
574,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
winndows/cinder
|
cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py
|
13
|
2224
|
# (c) Copyright 2014 Brocade Communications Systems Inc.
# All Rights Reserved.
#
# Copyright 2014 OpenStack Foundation
#
# 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 oslo_log import log as logging
from cinder.volume import configuration
brcd_zone_opts = [
cfg.StrOpt('fc_fabric_address',
default='',
help='Management IP of fabric'),
cfg.StrOpt('fc_fabric_user',
default='',
help='Fabric user ID'),
cfg.StrOpt('fc_fabric_password',
default='',
help='Password for user',
secret=True),
cfg.IntOpt('fc_fabric_port',
default=22,
min=1, max=65535,
help='Connecting port'),
cfg.StrOpt('zoning_policy',
default='initiator-target',
help='overridden zoning policy'),
cfg.BoolOpt('zone_activate',
default=True,
help='overridden zoning activation state'),
cfg.StrOpt('zone_name_prefix',
default=None,
help='overridden zone name prefix'),
cfg.StrOpt('principal_switch_wwn',
default=None,
help='Principal switch WWN of the fabric'),
]
CONF = cfg.CONF
CONF.register_opts(brcd_zone_opts, 'BRCD_FABRIC_EXAMPLE')
LOG = logging.getLogger(__name__)
def load_fabric_configurations(fabric_names):
fabric_configs = {}
for fabric_name in fabric_names:
config = configuration.Configuration(brcd_zone_opts, fabric_name)
LOG.debug("Loaded FC fabric config %s", fabric_name)
fabric_configs[fabric_name] = config
return fabric_configs
|
apache-2.0
|
[
3,
259,
334,
67,
9,
1898,
6927,
699,
293,
9490,
18686,
15285,
3277,
14,
199,
3,
259,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
1898,
6927,
14260,
2752,
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,
3,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
199,
504,
13069,
14,
2405,
492,
2897,
199,
199,
66,
1195,
68,
63,
2619,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
1562,
297,
2049,
849,
4581,
2049,
1720,
534,
14552,
3531,
402,
2630,
659,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
751,
297,
2049,
849,
4581,
2049,
1720,
534,
38,
2129,
922,
2870,
659,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
2060,
297,
2049,
849,
4581,
2049,
1720,
534,
6139,
367,
922,
297,
2049,
7565,
29,
549,
395,
272,
4810,
14,
3241,
9985,
360,
3003,
63,
4991,
63,
719,
297,
2049,
849,
29,
1081,
12,
2049,
1748,
29,
17,
12,
1390,
29,
26439,
12,
2049,
1720,
534,
32000,
1844,
659,
272,
4810,
14,
19340,
360,
8384,
316,
63,
3185,
297,
2049,
849,
534,
17974,
13,
1375,
297,
2049,
1720,
534,
30769,
1315,
19718,
4592,
659,
272,
4810,
14,
10349,
9985,
360,
2619,
63,
8222,
297,
355,
849,
29,
549,
12,
355,
1720,
534,
30769,
1315,
19718,
10361,
1174,
659,
272,
4810,
14,
19340,
360,
2619,
63,
354,
63,
1861,
297,
2049,
849,
29,
403,
12,
2049,
1720,
534,
30769,
5718,
536,
2403,
659,
272,
4810,
14,
19340,
360,
19200,
63,
5656,
63,
10988,
297,
2049,
849,
29,
403,
12,
2049,
1720,
534,
31729,
6258,
644,
3705,
402,
314,
2630,
659,
199,
61,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
66,
1195,
68,
63,
2619,
63,
3291,
12,
283,
7184,
7695,
63,
38,
1217,
14673,
63,
26900,
358,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
2248,
63,
4991,
63,
10057,
8,
4991,
63,
1247,
304,
272,
2630,
63,
7532,
275,
1052,
272,
367,
2630,
63,
354,
315,
2630,
63,
1247,
26,
267,
1101,
275,
2897,
14,
5688,
8,
66,
1195,
68,
63,
2619,
63,
3291,
12,
2630,
63,
354,
9,
267,
5051,
14,
1757,
480,
19757,
20934,
2630,
1101,
450,
83,
401,
2630,
63,
354,
9,
267,
2630,
63,
7532,
59,
4991,
63,
354,
61,
275,
1101,
339,
372,
2630,
63,
7532,
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
] |
[
259,
334,
67,
9,
1898,
6927,
699,
293,
9490,
18686,
15285,
3277,
14,
199,
3,
259,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
1898,
6927,
14260,
2752,
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,
3,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
199,
504,
13069,
14,
2405,
492,
2897,
199,
199,
66,
1195,
68,
63,
2619,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
1562,
297,
2049,
849,
4581,
2049,
1720,
534,
14552,
3531,
402,
2630,
659,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
751,
297,
2049,
849,
4581,
2049,
1720,
534,
38,
2129,
922,
2870,
659,
272,
4810,
14,
19340,
360,
3003,
63,
4991,
63,
2060,
297,
2049,
849,
4581,
2049,
1720,
534,
6139,
367,
922,
297,
2049,
7565,
29,
549,
395,
272,
4810,
14,
3241,
9985,
360,
3003,
63,
4991,
63,
719,
297,
2049,
849,
29,
1081,
12,
2049,
1748,
29,
17,
12,
1390,
29,
26439,
12,
2049,
1720,
534,
32000,
1844,
659,
272,
4810,
14,
19340,
360,
8384,
316,
63,
3185,
297,
2049,
849,
534,
17974,
13,
1375,
297,
2049,
1720,
534,
30769,
1315,
19718,
4592,
659,
272,
4810,
14,
10349,
9985,
360,
2619,
63,
8222,
297,
355,
849,
29,
549,
12,
355,
1720,
534,
30769,
1315,
19718,
10361,
1174,
659,
272,
4810,
14,
19340,
360,
2619,
63,
354,
63,
1861,
297,
2049,
849,
29,
403,
12,
2049,
1720,
534,
30769,
5718,
536,
2403,
659,
272,
4810,
14,
19340,
360,
19200,
63,
5656,
63,
10988,
297,
2049,
849,
29,
403,
12,
2049,
1720,
534,
31729,
6258,
644,
3705,
402,
314,
2630,
659,
199,
61,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
66,
1195,
68,
63,
2619,
63,
3291,
12,
283,
7184,
7695,
63,
38,
1217,
14673,
63,
26900,
358,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
2248,
63,
4991,
63,
10057,
8,
4991,
63,
1247,
304,
272,
2630,
63,
7532,
275,
1052,
272,
367,
2630,
63,
354,
315,
2630,
63,
1247,
26,
267,
1101,
275,
2897,
14,
5688,
8,
66,
1195,
68,
63,
2619,
63,
3291,
12,
2630,
63,
354,
9,
267,
5051,
14,
1757,
480,
19757,
20934,
2630,
1101,
450,
83,
401,
2630,
63,
354,
9,
267,
2630,
63,
7532,
59,
4991,
63,
354,
61,
275,
1101,
339,
372,
2630,
63,
7532,
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,
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,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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
] |
yuanzhao/gpdb
|
gpMgmt/sbin/gppersistent_backup.py
|
7
|
5737
|
#!/usr/bin/env python
#
# Copyright (c) 2014-Present Pivotal Software, Inc.
#
"""
Internal Use Function.
"""
from gppylib.mainUtils import simple_main, addStandardLoggingAndHelpOptions, addMasterDirectoryOptionForSingleClusterProgram
import base64
import os
import pickle
from gppylib import gplog
from gppylib.operations.persistent_rebuild import BackupPersistentTableFiles, ValidatePersistentBackup, DEFAULT_BATCH_SIZE
from gppylib.gpparseopts import OptParser, OptChecker, OptionGroup
logger = gplog.get_default_logger()
class PersistentBackupRestore:
def __init__(self, options, args):
self.backup = options.backup
self.restore = options.restore
self.validate_backups = options.validate_backups
self.validate_backup_dir = options.validate_backup_dir
self.timestamp = options.timestamp
self.batch_size = options.batch_size
self.backup_dir = options.backup_dir
self.perdbpt = options.perdbpt
self.globalpt = options.globalpt
self.validate_source_file_only = options.validate_source_file_only
def run(self):
if not self.perdbpt or not self.globalpt:
raise Exception('Please specify perdbpt filenames and globalpt filenames')
if not self.batch_size:
self.batch_size = DEFAULT_BATCH_SIZE
if not self.timestamp:
raise Exception('Please specify --timestamp option')
if (self.backup and self.restore) or (self.validate_backups and self.backup) or (self.restore and self.validate_backups):
raise Exception('Please specify either --backup or --restore or --validate')
if self.backup:
dbid_info = pickle.loads(base64.urlsafe_b64decode(self.backup))
perdb_pt_filenames = pickle.loads(base64.urlsafe_b64decode(self.perdbpt))
global_pt_filenames = pickle.loads(base64.urlsafe_b64decode(self.globalpt))
BackupPersistentTableFiles(dbid_info, self.timestamp, perdb_pt_filenames, global_pt_filenames, self.batch_size, self.backup_dir, self.validate_source_file_only).backup()
elif self.restore:
dbid_info = pickle.loads(base64.urlsafe_b64decode(self.restore))
perdb_pt_filenames = pickle.loads(base64.urlsafe_b64decode(self.perdbpt))
global_pt_filenames = pickle.loads(base64.urlsafe_b64decode(self.globalpt))
BackupPersistentTableFiles(dbid_info, self.timestamp, perdb_pt_filenames, global_pt_filenames, self.batch_size, self.backup_dir, self.validate_source_file_only).restore()
elif self.validate_backups:
dbid_info = pickle.loads(base64.urlsafe_b64decode(self.validate_backups))
ValidatePersistentBackup(dbid_info, self.timestamp, self.batch_size, self.backup_dir).validate_backups()
elif self.validate_backup_dir:
dbid_info = pickle.loads(base64.urlsafe_b64decode(self.validate_backup_dir))
ValidatePersistentBackup(dbid_info, self.timestamp, self.batch_size, self.backup_dir).validate_backup_dir()
return 0
def cleanup(self):
pass
def create_parser():
parser = OptParser(option_class=OptChecker,
version='%prog version $Revision: #1 $',
description='Persistent tables backp and restore')
addStandardLoggingAndHelpOptions(parser, includeNonInteractiveOption=True)
addTo = OptionGroup(parser, 'Connection opts')
parser.add_option_group(addTo)
addMasterDirectoryOptionForSingleClusterProgram(addTo)
addTo = OptionGroup(parser, 'Persistent tables backup and restore options')
addTo.add_option('--backup', metavar="<pickled dbid info>", type="string",
help="A list of dbid info where backups need to be done in pickled format")
addTo.add_option('--restore', metavar="<pickled dbid info>", type="string",
help="A list of dbid info where restore needs to be done in pickled format")
addTo.add_option('--validate-backups', metavar="<pickled dbid info>", type="string",
help="A list of dbid info where validation needs to be done in pickled format")
addTo.add_option('--validate-backup-dir', metavar="<pickled dbid info>", type="string",
help="A list of dbid info where validation needs to be done in pickled format")
addTo.add_option('--timestamp', metavar="<timestamp of backup>", type="string",
help="A timestamp for the backup that needs to be validated")
addTo.add_option('--batch-size', metavar="<batch size for the worker pool>", type="int",
help="Batch size for parallelism in worker pool")
addTo.add_option('--backup-dir', metavar="<backup directory>", type="string",
help="Backup directory for persistent tables and transaction logs")
addTo.add_option('--perdbpt', metavar="<per database pt filename>", type="string",
help="Filenames for per database persistent files")
addTo.add_option('--globalpt', metavar="<global pt filenames>", type="string",
help="Filenames for global persistent files")
addTo.add_option('--validate-source-file-only', action='store_true', default=False,
help="validate that required source files existed for backup and restore")
parser.setHelp([
"""
This tool is used to backup persistent table files.
"""
])
return parser
#-------------------------------------------------------------------------
if __name__ == '__main__':
mainOptions = { 'setNonuserOnToolLogger':True, 'suppressStartupLogMessage': True}
simple_main(create_parser, PersistentBackupRestore, mainOptions )
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
6927,
13,
19794,
510,
1003,
1735,
2290,
12,
3277,
14,
199,
3,
199,
199,
624,
199,
8405,
3645,
6801,
14,
199,
624,
199,
199,
504,
15852,
24111,
14,
973,
7535,
492,
3486,
63,
973,
12,
1050,
9232,
14054,
3325,
8673,
4558,
12,
1050,
12288,
6231,
2602,
1858,
7200,
9581,
9184,
199,
199,
646,
1300,
772,
199,
646,
747,
199,
646,
5927,
199,
199,
504,
15852,
24111,
492,
15852,
793,
199,
504,
15852,
24111,
14,
8170,
14,
18539,
63,
19278,
492,
10257,
384,
31966,
3186,
5535,
12,
12134,
31966,
16559,
12,
6186,
63,
20813,
63,
4305,
199,
504,
15852,
24111,
14,
4927,
1122,
3291,
492,
593,
541,
2842,
12,
593,
541,
3048,
12,
3207,
2448,
199,
199,
2921,
275,
15852,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
199,
533,
3492,
6082,
16559,
21012,
26,
272,
347,
636,
826,
721,
277,
12,
1511,
12,
1249,
304,
267,
291,
14,
5751,
275,
1511,
14,
5751,
267,
291,
14,
8011,
275,
1511,
14,
8011,
267,
291,
14,
3502,
63,
27376,
275,
1511,
14,
3502,
63,
27376,
267,
291,
14,
3502,
63,
5751,
63,
694,
275,
1511,
14,
3502,
63,
5751,
63,
694,
267,
291,
14,
3954,
275,
1511,
14,
3954,
267,
291,
14,
2912,
63,
890,
275,
1511,
14,
2912,
63,
890,
267,
291,
14,
5751,
63,
694,
275,
1511,
14,
5751,
63,
694,
267,
291,
14,
529,
697,
541,
275,
1511,
14,
529,
697,
541,
267,
291,
14,
2966,
541,
275,
1511,
14,
2966,
541,
267,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
275,
1511,
14,
3502,
63,
1365,
63,
493,
63,
2118,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
291,
14,
529,
697,
541,
503,
440,
291,
14,
2966,
541,
26,
288,
746,
2186,
360,
8254,
4165,
1126,
697,
541,
6203,
436,
2288,
541,
6203,
358,
398,
340,
440,
291,
14,
2912,
63,
890,
26,
288,
291,
14,
2912,
63,
890,
275,
6186,
63,
20813,
63,
4305,
398,
340,
440,
291,
14,
3954,
26,
288,
746,
2186,
360,
8254,
4165,
1553,
3954,
945,
358,
398,
340,
334,
277,
14,
5751,
436,
291,
14,
8011,
9,
503,
334,
277,
14,
3502,
63,
27376,
436,
291,
14,
5751,
9,
503,
334,
277,
14,
8011,
436,
291,
14,
3502,
63,
27376,
304,
288,
746,
2186,
360,
8254,
4165,
1902,
1553,
5751,
503,
1553,
8011,
503,
1553,
3502,
358,
398,
340,
291,
14,
5751,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
5751,
430,
288,
1126,
697,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
529,
697,
541,
430,
288,
2288,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
2966,
541,
430,
288,
10257,
384,
31966,
3186,
5535,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
1126,
697,
63,
541,
63,
10309,
12,
2288,
63,
541,
63,
10309,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
12,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
680,
5751,
342,
267,
916,
291,
14,
8011,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
8011,
430,
288,
1126,
697,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
529,
697,
541,
430,
288,
2288,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
2966,
541,
430,
288,
10257,
384,
31966,
3186,
5535,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
1126,
697,
63,
541,
63,
10309,
12,
2288,
63,
541,
63,
10309,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
12,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
680,
8011,
342,
267,
916,
291,
14,
3502,
63,
27376,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
3502,
63,
27376,
430,
288,
12134,
31966,
16559,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
680,
3502,
63,
27376,
342,
267,
916,
291,
14,
3502,
63,
5751,
63,
694,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
3502,
63,
5751,
63,
694,
430,
288,
12134,
31966,
16559,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
680,
3502,
63,
5751,
63,
694,
342,
398,
372,
378,
339,
347,
9058,
8,
277,
304,
267,
986,
199,
199,
318,
1218,
63,
2087,
837,
272,
1798,
275,
593,
541,
2842,
8,
1422,
63,
533,
29,
9985,
3048,
12,
221,
2432,
1015,
9569,
6595,
1015,
2672,
12714,
26,
327,
17,
2672,
297,
2432,
1369,
534,
31966,
6716,
1771,
80,
436,
9066,
358,
339,
1050,
9232,
14054,
3325,
8673,
4558,
8,
2087,
12,
2387,
6932,
23879,
2602,
29,
549,
9,
339,
1050,
1378,
275,
3207,
2448,
8,
2087,
12,
283,
3225,
3999,
358,
272,
1798,
14,
525,
63,
1422,
63,
923,
8,
525,
1378,
9,
272,
1050,
12288,
6231,
2602,
1858,
7200,
9581,
9184,
8,
525,
1378,
9,
339,
1050,
1378,
275,
3207,
2448,
8,
2087,
12,
283,
31966,
6716,
6902,
436,
9066,
1511,
358,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
5751,
297,
8214,
28066,
20428,
1592,
344,
2256,
7166,
730,
628,
875,
401,
2151,
1720,
628,
33,
769,
402,
1592,
344,
2256,
2382,
6902,
83,
1929,
370,
506,
4224,
315,
18731,
1475,
531,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
8011,
297,
8214,
28066,
20428,
1592,
344,
2256,
7166,
730,
628,
875,
401,
2151,
1720,
628,
33,
769,
402,
1592,
344,
2256,
2382,
9066,
4839,
370,
506,
4224,
315,
18731,
1475,
531,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
3502,
13,
27376,
297
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
6927,
13,
19794,
510,
1003,
1735,
2290,
12,
3277,
14,
199,
3,
199,
199,
624,
199,
8405,
3645,
6801,
14,
199,
624,
199,
199,
504,
15852,
24111,
14,
973,
7535,
492,
3486,
63,
973,
12,
1050,
9232,
14054,
3325,
8673,
4558,
12,
1050,
12288,
6231,
2602,
1858,
7200,
9581,
9184,
199,
199,
646,
1300,
772,
199,
646,
747,
199,
646,
5927,
199,
199,
504,
15852,
24111,
492,
15852,
793,
199,
504,
15852,
24111,
14,
8170,
14,
18539,
63,
19278,
492,
10257,
384,
31966,
3186,
5535,
12,
12134,
31966,
16559,
12,
6186,
63,
20813,
63,
4305,
199,
504,
15852,
24111,
14,
4927,
1122,
3291,
492,
593,
541,
2842,
12,
593,
541,
3048,
12,
3207,
2448,
199,
199,
2921,
275,
15852,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
199,
533,
3492,
6082,
16559,
21012,
26,
272,
347,
636,
826,
721,
277,
12,
1511,
12,
1249,
304,
267,
291,
14,
5751,
275,
1511,
14,
5751,
267,
291,
14,
8011,
275,
1511,
14,
8011,
267,
291,
14,
3502,
63,
27376,
275,
1511,
14,
3502,
63,
27376,
267,
291,
14,
3502,
63,
5751,
63,
694,
275,
1511,
14,
3502,
63,
5751,
63,
694,
267,
291,
14,
3954,
275,
1511,
14,
3954,
267,
291,
14,
2912,
63,
890,
275,
1511,
14,
2912,
63,
890,
267,
291,
14,
5751,
63,
694,
275,
1511,
14,
5751,
63,
694,
267,
291,
14,
529,
697,
541,
275,
1511,
14,
529,
697,
541,
267,
291,
14,
2966,
541,
275,
1511,
14,
2966,
541,
267,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
275,
1511,
14,
3502,
63,
1365,
63,
493,
63,
2118,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
291,
14,
529,
697,
541,
503,
440,
291,
14,
2966,
541,
26,
288,
746,
2186,
360,
8254,
4165,
1126,
697,
541,
6203,
436,
2288,
541,
6203,
358,
398,
340,
440,
291,
14,
2912,
63,
890,
26,
288,
291,
14,
2912,
63,
890,
275,
6186,
63,
20813,
63,
4305,
398,
340,
440,
291,
14,
3954,
26,
288,
746,
2186,
360,
8254,
4165,
1553,
3954,
945,
358,
398,
340,
334,
277,
14,
5751,
436,
291,
14,
8011,
9,
503,
334,
277,
14,
3502,
63,
27376,
436,
291,
14,
5751,
9,
503,
334,
277,
14,
8011,
436,
291,
14,
3502,
63,
27376,
304,
288,
746,
2186,
360,
8254,
4165,
1902,
1553,
5751,
503,
1553,
8011,
503,
1553,
3502,
358,
398,
340,
291,
14,
5751,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
5751,
430,
288,
1126,
697,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
529,
697,
541,
430,
288,
2288,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
2966,
541,
430,
288,
10257,
384,
31966,
3186,
5535,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
1126,
697,
63,
541,
63,
10309,
12,
2288,
63,
541,
63,
10309,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
12,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
680,
5751,
342,
267,
916,
291,
14,
8011,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
8011,
430,
288,
1126,
697,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
529,
697,
541,
430,
288,
2288,
63,
541,
63,
10309,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
2966,
541,
430,
288,
10257,
384,
31966,
3186,
5535,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
1126,
697,
63,
541,
63,
10309,
12,
2288,
63,
541,
63,
10309,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
12,
291,
14,
3502,
63,
1365,
63,
493,
63,
2118,
680,
8011,
342,
267,
916,
291,
14,
3502,
63,
27376,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
3502,
63,
27376,
430,
288,
12134,
31966,
16559,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
680,
3502,
63,
27376,
342,
267,
916,
291,
14,
3502,
63,
5751,
63,
694,
26,
288,
1592,
344,
63,
815,
275,
5927,
14,
3640,
8,
1095,
772,
14,
28201,
63,
66,
772,
2708,
8,
277,
14,
3502,
63,
5751,
63,
694,
430,
288,
12134,
31966,
16559,
8,
697,
344,
63,
815,
12,
291,
14,
3954,
12,
291,
14,
2912,
63,
890,
12,
291,
14,
5751,
63,
694,
680,
3502,
63,
5751,
63,
694,
342,
398,
372,
378,
339,
347,
9058,
8,
277,
304,
267,
986,
199,
199,
318,
1218,
63,
2087,
837,
272,
1798,
275,
593,
541,
2842,
8,
1422,
63,
533,
29,
9985,
3048,
12,
221,
2432,
1015,
9569,
6595,
1015,
2672,
12714,
26,
327,
17,
2672,
297,
2432,
1369,
534,
31966,
6716,
1771,
80,
436,
9066,
358,
339,
1050,
9232,
14054,
3325,
8673,
4558,
8,
2087,
12,
2387,
6932,
23879,
2602,
29,
549,
9,
339,
1050,
1378,
275,
3207,
2448,
8,
2087,
12,
283,
3225,
3999,
358,
272,
1798,
14,
525,
63,
1422,
63,
923,
8,
525,
1378,
9,
272,
1050,
12288,
6231,
2602,
1858,
7200,
9581,
9184,
8,
525,
1378,
9,
339,
1050,
1378,
275,
3207,
2448,
8,
2087,
12,
283,
31966,
6716,
6902,
436,
9066,
1511,
358,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
5751,
297,
8214,
28066,
20428,
1592,
344,
2256,
7166,
730,
628,
875,
401,
2151,
1720,
628,
33,
769,
402,
1592,
344,
2256,
2382,
6902,
83,
1929,
370,
506,
4224,
315,
18731,
1475,
531,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
8011,
297,
8214,
28066,
20428,
1592,
344,
2256,
7166,
730,
628,
875,
401,
2151,
1720,
628,
33,
769,
402,
1592,
344,
2256,
2382,
9066,
4839,
370,
506,
4224,
315,
18731,
1475,
531,
272,
1050,
1378,
14,
525,
63,
1422,
4517,
3502,
13,
27376,
297,
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
] |
adhix11/pmtk3
|
python/demos/linregDemo1.py
|
26
|
1104
|
#!/usr/bin/python2.4
import numpy
import scipy.stats
import matplotlib.pyplot as plt
def main():
# true parameters
w = 2
w0 = 3
sigma = 2
# make data
numpy.random.seed(1)
Ntrain = 20
xtrain = numpy.linspace(0,10,Ntrain)
ytrain = w*xtrain + w0 + numpy.random.random(Ntrain)*sigma
Ntest = 100
xtest = numpy.linspace(0,10,Ntest)
ytest = w*xtest + w0 + numpy.random.random(Ntest)*sigma
# from http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/python/lin_reg/
# fit
west, w0est, r_value, p_value, std_err = scipy.stats.linregress(xtrain, ytrain)
# display
print "Param \t True \t Est"
print "w0 \t %5.3f \t %5.3f" % (w0, w0est)
print "w \t %5.3f \t %5.3f" % (w, west)
# plot
plt.close()
plt.plot(xtrain, ytrain, 'ro')
plt.hold(True)
#plt.plot(xtest, ytest, 'ka-')
ytestPred = west*xtest + w0est
#ndx = range(0, Ntest, 10)
#h = plt.plot(xtest[ndx], ytestPred[ndx], 'b*')
h = plt.plot(xtest, ytestPred, 'b-')
plt.setp(h, 'markersize', 12)
if __name__ == '__main__':
main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
646,
2680,
199,
646,
7026,
14,
3200,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
2446,
837,
272,
327,
2549,
2633,
272,
336,
221,
275,
499,
272,
336,
16,
275,
650,
272,
10819,
275,
499,
339,
327,
1852,
666,
272,
2680,
14,
2355,
14,
5176,
8,
17,
9,
272,
653,
2834,
275,
3388,
272,
25158,
6322,
275,
2680,
14,
11649,
8,
16,
12,
709,
12,
46,
2834,
9,
272,
612,
2834,
275,
336,
10,
400,
6322,
435,
336,
16,
435,
2680,
14,
2355,
14,
2355,
8,
46,
2834,
3342,
9412,
272,
653,
396,
275,
2948,
272,
671,
396,
275,
2680,
14,
11649,
8,
16,
12,
709,
12,
46,
396,
9,
272,
612,
396,
275,
336,
10,
88,
396,
435,
336,
16,
435,
2680,
14,
2355,
14,
2355,
8,
46,
396,
3342,
9412,
2286,
327,
221,
687,
1455,
921,
1544,
18,
14,
3281,
87,
2000,
14,
645,
14,
3210,
15,
12668,
15,
9907,
15,
573,
645,
15,
17921,
15,
321,
351,
63,
331,
346,
15,
1548,
15,
472,
63,
1135,
15,
272,
327,
5542,
272,
336,
597,
12,
336,
16,
597,
12,
519,
63,
585,
12,
299,
63,
585,
12,
2418,
63,
1508,
275,
7026,
14,
3200,
14,
472,
25883,
8,
400,
6322,
12,
612,
2834,
9,
339,
327,
2929,
272,
870,
298,
4098,
971,
84,
715,
971,
84,
15896,
2,
272,
870,
298,
87,
16,
971,
84,
450,
21,
14,
19,
70,
971,
84,
450,
21,
14,
19,
70,
2,
450,
334,
87,
16,
12,
336,
16,
597,
9,
272,
870,
298,
87,
971,
84,
450,
21,
14,
19,
70,
971,
84,
450,
21,
14,
19,
70,
2,
450,
334,
87,
12,
336,
597,
9,
339,
327,
5137,
272,
4488,
14,
1600,
342,
272,
4488,
14,
2798,
8,
400,
6322,
12,
612,
2834,
12,
283,
293,
358,
272,
4488,
14,
12239,
8,
549,
9,
272,
327,
6003,
14,
2798,
8,
88,
396,
12,
612,
396,
12,
283,
7351,
25815,
272,
612,
396,
48,
581,
275,
336,
597,
10,
88,
396,
435,
336,
16,
597,
272,
327,
31818,
275,
1425,
8,
16,
12,
653,
396,
12,
1616,
9,
272,
327,
72,
275,
4488,
14,
2798,
8,
88,
396,
59,
31818,
467,
612,
396,
48,
581,
59,
31818,
467,
283,
66,
13418,
272,
394,
275,
4488,
14,
2798,
8,
88,
396,
12,
612,
396,
48,
581,
12,
283,
66,
25815,
272,
4488,
14,
409,
80,
8,
72,
12,
283,
4211,
890,
297,
3144,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
198,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
646,
2680,
199,
646,
7026,
14,
3200,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
2446,
837,
272,
327,
2549,
2633,
272,
336,
221,
275,
499,
272,
336,
16,
275,
650,
272,
10819,
275,
499,
339,
327,
1852,
666,
272,
2680,
14,
2355,
14,
5176,
8,
17,
9,
272,
653,
2834,
275,
3388,
272,
25158,
6322,
275,
2680,
14,
11649,
8,
16,
12,
709,
12,
46,
2834,
9,
272,
612,
2834,
275,
336,
10,
400,
6322,
435,
336,
16,
435,
2680,
14,
2355,
14,
2355,
8,
46,
2834,
3342,
9412,
272,
653,
396,
275,
2948,
272,
671,
396,
275,
2680,
14,
11649,
8,
16,
12,
709,
12,
46,
396,
9,
272,
612,
396,
275,
336,
10,
88,
396,
435,
336,
16,
435,
2680,
14,
2355,
14,
2355,
8,
46,
396,
3342,
9412,
2286,
327,
221,
687,
1455,
921,
1544,
18,
14,
3281,
87,
2000,
14,
645,
14,
3210,
15,
12668,
15,
9907,
15,
573,
645,
15,
17921,
15,
321,
351,
63,
331,
346,
15,
1548,
15,
472,
63,
1135,
15,
272,
327,
5542,
272,
336,
597,
12,
336,
16,
597,
12,
519,
63,
585,
12,
299,
63,
585,
12,
2418,
63,
1508,
275,
7026,
14,
3200,
14,
472,
25883,
8,
400,
6322,
12,
612,
2834,
9,
339,
327,
2929,
272,
870,
298,
4098,
971,
84,
715,
971,
84,
15896,
2,
272,
870,
298,
87,
16,
971,
84,
450,
21,
14,
19,
70,
971,
84,
450,
21,
14,
19,
70,
2,
450,
334,
87,
16,
12,
336,
16,
597,
9,
272,
870,
298,
87,
971,
84,
450,
21,
14,
19,
70,
971,
84,
450,
21,
14,
19,
70,
2,
450,
334,
87,
12,
336,
597,
9,
339,
327,
5137,
272,
4488,
14,
1600,
342,
272,
4488,
14,
2798,
8,
400,
6322,
12,
612,
2834,
12,
283,
293,
358,
272,
4488,
14,
12239,
8,
549,
9,
272,
327,
6003,
14,
2798,
8,
88,
396,
12,
612,
396,
12,
283,
7351,
25815,
272,
612,
396,
48,
581,
275,
336,
597,
10,
88,
396,
435,
336,
16,
597,
272,
327,
31818,
275,
1425,
8,
16,
12,
653,
396,
12,
1616,
9,
272,
327,
72,
275,
4488,
14,
2798,
8,
88,
396,
59,
31818,
467,
612,
396,
48,
581,
59,
31818,
467,
283,
66,
13418,
272,
394,
275,
4488,
14,
2798,
8,
88,
396,
12,
612,
396,
48,
581,
12,
283,
66,
25815,
272,
4488,
14,
409,
80,
8,
72,
12,
283,
4211,
890,
297,
3144,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
199,
198,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
yank555-lu/N3-CM11
|
tools/perf/scripts/python/futex-contention.py
|
11261
|
1486
|
# futex contention
# (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com>
# Licensed under the terms of the GNU GPL License version 2
#
# Translation of:
#
# http://sourceware.org/systemtap/wiki/WSFutexContention
#
# to perf python scripting.
#
# Measures futex contention
import os, sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from Util import *
process_names = {}
thread_thislock = {}
thread_blocktime = {}
lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
process_names = {} # long-lived pid-to-execname mapping
def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, uaddr, op, val, utime, uaddr2, val3):
cmd = op & FUTEX_CMD_MASK
if cmd != FUTEX_WAIT:
return # we don't care about originators of WAKE events
process_names[tid] = comm
thread_thislock[tid] = uaddr
thread_blocktime[tid] = nsecs(s, ns)
def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, ret):
if thread_blocktime.has_key(tid):
elapsed = nsecs(s, ns) - thread_blocktime[tid]
add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
del thread_blocktime[tid]
del thread_thislock[tid]
def trace_begin():
print "Press control+C to stop and show the summary"
def trace_end():
for (tid, lock) in lock_waits:
min, max, avg, count = lock_waits[tid, lock]
print "%s[%d] lock %x contended %d times, %d avg ns" % \
(process_names[tid], tid, lock, count, avg)
|
gpl-2.0
|
[
3,
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
rushiagr/keystone
|
keystone/contrib/federation/routers.py
|
2
|
9192
|
# 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 functools
from keystone.common import json_home
from keystone.common import wsgi
from keystone.contrib.federation import controllers
build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-FEDERATION', extension_version='1.0')
build_parameter_relation = functools.partial(
json_home.build_v3_extension_parameter_relation,
extension_name='OS-FEDERATION', extension_version='1.0')
IDP_ID_PARAMETER_RELATION = build_parameter_relation(parameter_name='idp_id')
PROTOCOL_ID_PARAMETER_RELATION = build_parameter_relation(
parameter_name='protocol_id')
SP_ID_PARAMETER_RELATION = build_parameter_relation(parameter_name='sp_id')
class FederationExtension(wsgi.V3ExtensionRouter):
"""API Endpoints for the Federation extension.
The API looks like::
PUT /OS-FEDERATION/identity_providers/$identity_provider
GET /OS-FEDERATION/identity_providers
GET /OS-FEDERATION/identity_providers/$identity_provider
DELETE /OS-FEDERATION/identity_providers/$identity_provider
PATCH /OS-FEDERATION/identity_providers/$identity_provider
PUT /OS-FEDERATION/identity_providers/
$identity_provider/protocols/$protocol
GET /OS-FEDERATION/identity_providers/
$identity_provider/protocols
GET /OS-FEDERATION/identity_providers/
$identity_provider/protocols/$protocol
PATCH /OS-FEDERATION/identity_providers/
$identity_provider/protocols/$protocol
DELETE /OS-FEDERATION/identity_providers/
$identity_provider/protocols/$protocol
PUT /OS-FEDERATION/mappings
GET /OS-FEDERATION/mappings
PATCH /OS-FEDERATION/mappings/$mapping_id
GET /OS-FEDERATION/mappings/$mapping_id
DELETE /OS-FEDERATION/mappings/$mapping_id
GET /OS-FEDERATION/projects
GET /OS-FEDERATION/domains
PUT /OS-FEDERATION/service_providers/$service_provider
GET /OS-FEDERATION/service_providers
GET /OS-FEDERATION/service_providers/$service_provider
DELETE /OS-FEDERATION/service_providers/$service_provider
PATCH /OS-FEDERATION/service_providers/$service_provider
GET /OS-FEDERATION/identity_providers/$identity_provider/
protocols/$protocol/auth
POST /OS-FEDERATION/identity_providers/$identity_provider/
protocols/$protocol/auth
POST /auth/OS-FEDERATION/saml2
GET /OS-FEDERATION/saml2/metadata
GET /auth/OS-FEDERATION/websso/{protocol_id}
?origin=https%3A//horizon.example.com
POST /auth/OS-FEDERATION/websso/{protocol_id}
?origin=https%3A//horizon.example.com
"""
def _construct_url(self, suffix):
return "/OS-FEDERATION/%s" % suffix
def add_routes(self, mapper):
auth_controller = controllers.Auth()
idp_controller = controllers.IdentityProvider()
protocol_controller = controllers.FederationProtocol()
mapping_controller = controllers.MappingController()
project_controller = controllers.ProjectAssignmentV3()
domain_controller = controllers.DomainV3()
saml_metadata_controller = controllers.SAMLMetadataV3()
sp_controller = controllers.ServiceProvider()
# Identity Provider CRUD operations
self._add_resource(
mapper, idp_controller,
path=self._construct_url('identity_providers/{idp_id}'),
get_action='get_identity_provider',
put_action='create_identity_provider',
patch_action='update_identity_provider',
delete_action='delete_identity_provider',
rel=build_resource_relation(resource_name='identity_provider'),
path_vars={
'idp_id': IDP_ID_PARAMETER_RELATION,
})
self._add_resource(
mapper, idp_controller,
path=self._construct_url('identity_providers'),
get_action='list_identity_providers',
rel=build_resource_relation(resource_name='identity_providers'))
# Protocol CRUD operations
self._add_resource(
mapper, protocol_controller,
path=self._construct_url('identity_providers/{idp_id}/protocols/'
'{protocol_id}'),
get_action='get_protocol',
put_action='create_protocol',
patch_action='update_protocol',
delete_action='delete_protocol',
rel=build_resource_relation(
resource_name='identity_provider_protocol'),
path_vars={
'idp_id': IDP_ID_PARAMETER_RELATION,
'protocol_id': PROTOCOL_ID_PARAMETER_RELATION,
})
self._add_resource(
mapper, protocol_controller,
path=self._construct_url('identity_providers/{idp_id}/protocols'),
get_action='list_protocols',
rel=build_resource_relation(
resource_name='identity_provider_protocols'),
path_vars={
'idp_id': IDP_ID_PARAMETER_RELATION,
})
# Mapping CRUD operations
self._add_resource(
mapper, mapping_controller,
path=self._construct_url('mappings/{mapping_id}'),
get_action='get_mapping',
put_action='create_mapping',
patch_action='update_mapping',
delete_action='delete_mapping',
rel=build_resource_relation(resource_name='mapping'),
path_vars={
'mapping_id': build_parameter_relation(
parameter_name='mapping_id'),
})
self._add_resource(
mapper, mapping_controller,
path=self._construct_url('mappings'),
get_action='list_mappings',
rel=build_resource_relation(resource_name='mappings'))
# Service Providers CRUD operations
self._add_resource(
mapper, sp_controller,
path=self._construct_url('service_providers/{sp_id}'),
get_action='get_service_provider',
put_action='create_service_provider',
patch_action='update_service_provider',
delete_action='delete_service_provider',
rel=build_resource_relation(resource_name='service_provider'),
path_vars={
'sp_id': SP_ID_PARAMETER_RELATION,
})
self._add_resource(
mapper, sp_controller,
path=self._construct_url('service_providers'),
get_action='list_service_providers',
rel=build_resource_relation(resource_name='service_providers'))
self._add_resource(
mapper, domain_controller,
path=self._construct_url('domains'),
get_action='list_domains_for_groups',
rel=build_resource_relation(resource_name='domains'))
self._add_resource(
mapper, project_controller,
path=self._construct_url('projects'),
get_action='list_projects_for_groups',
rel=build_resource_relation(resource_name='projects'))
self._add_resource(
mapper, auth_controller,
path=self._construct_url('identity_providers/{identity_provider}/'
'protocols/{protocol}/auth'),
get_post_action='federated_authentication',
rel=build_resource_relation(
resource_name='identity_provider_protocol_auth'),
path_vars={
'identity_provider': IDP_ID_PARAMETER_RELATION,
'protocol': PROTOCOL_ID_PARAMETER_RELATION,
})
# Auth operations
self._add_resource(
mapper, auth_controller,
path='/auth' + self._construct_url('saml2'),
post_action='create_saml_assertion',
rel=build_resource_relation(resource_name='saml2'))
self._add_resource(
mapper, auth_controller,
path='/auth' + self._construct_url('websso/{protocol_id}'),
get_post_action='federated_sso_auth',
rel=build_resource_relation(resource_name='websso'),
path_vars={
'protocol_id': PROTOCOL_ID_PARAMETER_RELATION,
})
# Keystone-Identity-Provider metadata endpoint
self._add_resource(
mapper, saml_metadata_controller,
path=self._construct_url('saml2/metadata'),
get_action='get_metadata',
rel=build_resource_relation(resource_name='metadata'))
|
apache-2.0
|
[
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,
9143,
199,
199,
504,
19395,
14,
2330,
492,
2022,
63,
4219,
199,
504,
19395,
14,
2330,
492,
12464,
199,
504,
19395,
14,
2828,
14,
771,
32643,
492,
27325,
421,
199,
1506,
63,
1927,
63,
5690,
275,
9143,
14,
6672,
8,
272,
2022,
63,
4219,
14,
1506,
63,
86,
19,
63,
3435,
63,
1927,
63,
5690,
12,
272,
3329,
63,
354,
534,
3100,
13,
38,
1149,
540,
2594,
297,
3329,
63,
1023,
534,
17,
14,
16,
358,
199,
199,
1506,
63,
5329,
63,
5690,
275,
9143,
14,
6672,
8,
272,
2022,
63,
4219,
14,
1506,
63,
86,
19,
63,
3435,
63,
5329,
63,
5690,
12,
272,
3329,
63,
354,
534,
3100,
13,
38,
1149,
540,
2594,
297,
3329,
63,
1023,
534,
17,
14,
16,
358,
199,
199,
998,
48,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
5329,
63,
354,
534,
29444,
63,
344,
358,
199,
9583,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
272,
2725,
63,
354,
534,
3922,
63,
344,
358,
199,
5763,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
5329,
63,
354,
534,
681,
63,
344,
358,
421,
199,
533,
7949,
32643,
6382,
8,
6508,
14,
54,
19,
6382,
11691,
304,
272,
408,
3735,
9599,
3438,
367,
314,
7949,
32643,
3329,
14,
339,
710,
3261,
10734,
2839,
447,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
398,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
6776,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
9756,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
398,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
15,
288,
19230,
21792,
3922,
15,
1178,
267,
8761,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
15,
288,
19230,
21792,
3922,
15,
1178,
398,
8761,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
29338,
18,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
29338,
18,
15,
2343,
398,
9576,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
2520,
25479,
5321,
3922,
63,
344,
93,
288,
5805,
6493,
29,
2859,
5,
19,
33,
501,
16561,
14,
2694,
14,
957,
398,
8761,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
2520,
25479,
5321,
3922,
63,
344,
93,
1467,
5805,
6493,
29,
2859,
5,
19,
33,
501,
16561,
14,
2694,
14,
957,
339,
408,
272,
347,
485,
8514,
63,
633,
8,
277,
12,
4739,
304,
267,
372,
3286,
3100,
13,
38,
1149,
540,
2594,
3149,
83,
2,
450,
4739,
339,
347,
1050,
63,
13243,
8,
277,
12,
7796,
304,
267,
1790,
63,
5538,
275,
27325,
14,
2817,
342,
267,
1305,
80,
63,
5538,
275,
27325,
14,
10193,
6663,
342,
267,
4113,
63,
5538,
275,
27325,
14,
3456,
32643,
3658,
342,
267,
4412,
63,
5538,
275,
27325,
14,
7674,
7506,
342,
267,
2199,
63,
5538,
275,
27325,
14,
4761,
19321,
54,
19,
342,
267,
2881,
63,
5538,
275,
27325,
14,
7705,
54,
19,
342,
267,
25607,
63,
2343,
63,
5538,
275,
27325,
14,
26986,
5142,
54,
19,
342,
267,
2249,
63,
5538,
275,
27325,
14,
3167,
6663,
342,
398,
327,
22034,
18489,
17101,
3383,
5331,
398,
291,
423,
525,
63,
1927,
8,
288,
7796,
12,
1305,
80,
63,
5538,
12,
288,
931,
29,
277,
423,
8514
] |
[
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,
9143,
199,
199,
504,
19395,
14,
2330,
492,
2022,
63,
4219,
199,
504,
19395,
14,
2330,
492,
12464,
199,
504,
19395,
14,
2828,
14,
771,
32643,
492,
27325,
421,
199,
1506,
63,
1927,
63,
5690,
275,
9143,
14,
6672,
8,
272,
2022,
63,
4219,
14,
1506,
63,
86,
19,
63,
3435,
63,
1927,
63,
5690,
12,
272,
3329,
63,
354,
534,
3100,
13,
38,
1149,
540,
2594,
297,
3329,
63,
1023,
534,
17,
14,
16,
358,
199,
199,
1506,
63,
5329,
63,
5690,
275,
9143,
14,
6672,
8,
272,
2022,
63,
4219,
14,
1506,
63,
86,
19,
63,
3435,
63,
5329,
63,
5690,
12,
272,
3329,
63,
354,
534,
3100,
13,
38,
1149,
540,
2594,
297,
3329,
63,
1023,
534,
17,
14,
16,
358,
199,
199,
998,
48,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
5329,
63,
354,
534,
29444,
63,
344,
358,
199,
9583,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
272,
2725,
63,
354,
534,
3922,
63,
344,
358,
199,
5763,
63,
998,
63,
14472,
63,
13604,
2594,
275,
1900,
63,
5329,
63,
5690,
8,
5329,
63,
354,
534,
681,
63,
344,
358,
421,
199,
533,
7949,
32643,
6382,
8,
6508,
14,
54,
19,
6382,
11691,
304,
272,
408,
3735,
9599,
3438,
367,
314,
7949,
32643,
3329,
14,
339,
710,
3261,
10734,
2839,
447,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
15,
288,
2672,
5582,
63,
3780,
15,
16541,
21792,
3922,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
14632,
21792,
4745,
63,
344,
398,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
6776,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
9756,
398,
18337,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
15137,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
267,
510,
8078,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
1364,
63,
9710,
21792,
1364,
63,
3780,
398,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
15,
288,
19230,
21792,
3922,
15,
1178,
267,
8761,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
5582,
63,
9710,
21792,
5582,
63,
3780,
15,
288,
19230,
21792,
3922,
15,
1178,
398,
8761,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
29338,
18,
267,
9576,
1182,
3100,
13,
38,
1149,
540,
2594,
15,
29338,
18,
15,
2343,
398,
9576,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
2520,
25479,
5321,
3922,
63,
344,
93,
288,
5805,
6493,
29,
2859,
5,
19,
33,
501,
16561,
14,
2694,
14,
957,
398,
8761,
1182,
1178,
15,
3100,
13,
38,
1149,
540,
2594,
15,
2520,
25479,
5321,
3922,
63,
344,
93,
1467,
5805,
6493,
29,
2859,
5,
19,
33,
501,
16561,
14,
2694,
14,
957,
339,
408,
272,
347,
485,
8514,
63,
633,
8,
277,
12,
4739,
304,
267,
372,
3286,
3100,
13,
38,
1149,
540,
2594,
3149,
83,
2,
450,
4739,
339,
347,
1050,
63,
13243,
8,
277,
12,
7796,
304,
267,
1790,
63,
5538,
275,
27325,
14,
2817,
342,
267,
1305,
80,
63,
5538,
275,
27325,
14,
10193,
6663,
342,
267,
4113,
63,
5538,
275,
27325,
14,
3456,
32643,
3658,
342,
267,
4412,
63,
5538,
275,
27325,
14,
7674,
7506,
342,
267,
2199,
63,
5538,
275,
27325,
14,
4761,
19321,
54,
19,
342,
267,
2881,
63,
5538,
275,
27325,
14,
7705,
54,
19,
342,
267,
25607,
63,
2343,
63,
5538,
275,
27325,
14,
26986,
5142,
54,
19,
342,
267,
2249,
63,
5538,
275,
27325,
14,
3167,
6663,
342,
398,
327,
22034,
18489,
17101,
3383,
5331,
398,
291,
423,
525,
63,
1927,
8,
288,
7796,
12,
1305,
80,
63,
5538,
12,
288,
931,
29,
277,
423,
8514,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
lthurlow/Network-Grapher
|
proj/external/numpy-1.7.0/numpy/core/tests/test_arrayprint.py
|
8
|
6757
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import numpy as np
from numpy.testing import *
class TestArrayRepr(object):
def test_nan_inf(self):
x = np.array([np.nan, np.inf])
assert_equal(repr(x), 'array([ nan, inf])')
class TestComplexArray(TestCase):
def test_str(self):
rvals = [0, 1, -1, np.inf, -np.inf, np.nan]
cvals = [complex(rp, ip) for rp in rvals for ip in rvals]
dtypes = [np.complex64, np.cdouble, np.clongdouble]
actual = [str(np.array([c], dt)) for c in cvals for dt in dtypes]
wanted = [
'[ 0.+0.j]', '[ 0.+0.j]', '[ 0.0+0.0j]',
'[ 0.+1.j]', '[ 0.+1.j]', '[ 0.0+1.0j]',
'[ 0.-1.j]', '[ 0.-1.j]', '[ 0.0-1.0j]',
'[ 0.+infj]', '[ 0.+infj]', '[ 0.0+infj]',
'[ 0.-infj]', '[ 0.-infj]', '[ 0.0-infj]',
'[ 0.+nanj]', '[ 0.+nanj]', '[ 0.0+nanj]',
'[ 1.+0.j]', '[ 1.+0.j]', '[ 1.0+0.0j]',
'[ 1.+1.j]', '[ 1.+1.j]', '[ 1.0+1.0j]',
'[ 1.-1.j]', '[ 1.-1.j]', '[ 1.0-1.0j]',
'[ 1.+infj]', '[ 1.+infj]', '[ 1.0+infj]',
'[ 1.-infj]', '[ 1.-infj]', '[ 1.0-infj]',
'[ 1.+nanj]', '[ 1.+nanj]', '[ 1.0+nanj]',
'[-1.+0.j]', '[-1.+0.j]', '[-1.0+0.0j]',
'[-1.+1.j]', '[-1.+1.j]', '[-1.0+1.0j]',
'[-1.-1.j]', '[-1.-1.j]', '[-1.0-1.0j]',
'[-1.+infj]', '[-1.+infj]', '[-1.0+infj]',
'[-1.-infj]', '[-1.-infj]', '[-1.0-infj]',
'[-1.+nanj]', '[-1.+nanj]', '[-1.0+nanj]',
'[ inf+0.j]', '[ inf+0.j]', '[ inf+0.0j]',
'[ inf+1.j]', '[ inf+1.j]', '[ inf+1.0j]',
'[ inf-1.j]', '[ inf-1.j]', '[ inf-1.0j]',
'[ inf+infj]', '[ inf+infj]', '[ inf+infj]',
'[ inf-infj]', '[ inf-infj]', '[ inf-infj]',
'[ inf+nanj]', '[ inf+nanj]', '[ inf+nanj]',
'[-inf+0.j]', '[-inf+0.j]', '[-inf+0.0j]',
'[-inf+1.j]', '[-inf+1.j]', '[-inf+1.0j]',
'[-inf-1.j]', '[-inf-1.j]', '[-inf-1.0j]',
'[-inf+infj]', '[-inf+infj]', '[-inf+infj]',
'[-inf-infj]', '[-inf-infj]', '[-inf-infj]',
'[-inf+nanj]', '[-inf+nanj]', '[-inf+nanj]',
'[ nan+0.j]', '[ nan+0.j]', '[ nan+0.0j]',
'[ nan+1.j]', '[ nan+1.j]', '[ nan+1.0j]',
'[ nan-1.j]', '[ nan-1.j]', '[ nan-1.0j]',
'[ nan+infj]', '[ nan+infj]', '[ nan+infj]',
'[ nan-infj]', '[ nan-infj]', '[ nan-infj]',
'[ nan+nanj]', '[ nan+nanj]', '[ nan+nanj]']
for res, val in zip(actual, wanted):
assert_(res == val)
class TestArray2String(TestCase):
def test_basic(self):
"""Basic test of array2string."""
a = np.arange(3)
assert_(np.array2string(a) == '[0 1 2]')
assert_(np.array2string(a, max_line_width=4) == '[0 1\n 2]')
def test_style_keyword(self):
"""This should only apply to 0-D arrays. See #1218."""
stylestr = np.array2string(np.array(1.5),
style=lambda x: "Value in 0-D array: " + str(x))
assert_(stylestr == 'Value in 0-D array: 1.5')
def test_format_function(self):
"""Test custom format function for each element in array."""
def _format_function(x):
if np.abs(x) < 1:
return '.'
elif np.abs(x) < 2:
return 'o'
else:
return 'O'
x = np.arange(3)
if sys.version_info[0] >= 3:
x_hex = "[0x0 0x1 0x2]"
x_oct = "[0o0 0o1 0o2]"
else:
x_hex = "[0x0L 0x1L 0x2L]"
x_oct = "[0L 01L 02L]"
assert_(np.array2string(x, formatter={'all':_format_function}) == \
"[. o O]")
assert_(np.array2string(x, formatter={'int_kind':_format_function}) ==\
"[. o O]")
assert_(np.array2string(x, formatter={'all':lambda x: "%.4f" % x}) == \
"[0.0000 1.0000 2.0000]")
assert_equal(np.array2string(x, formatter={'int':lambda x: hex(x)}), \
x_hex)
assert_equal(np.array2string(x, formatter={'int':lambda x: oct(x)}), \
x_oct)
x = np.arange(3.)
assert_(np.array2string(x, formatter={'float_kind':lambda x: "%.2f" % x}) == \
"[0.00 1.00 2.00]")
assert_(np.array2string(x, formatter={'float':lambda x: "%.2f" % x}) == \
"[0.00 1.00 2.00]")
s = np.array(['abc', 'def'])
assert_(np.array2string(s, formatter={'numpystr':lambda s: s*2}) == \
'[abcabc defdef]')
class TestPrintOptions:
"""Test getting and setting global print options."""
def setUp(self):
self.oldopts = np.get_printoptions()
def tearDown(self):
np.set_printoptions(**self.oldopts)
def test_basic(self):
x = np.array([1.5, 0, 1.234567890])
assert_equal(repr(x), "array([ 1.5 , 0. , 1.23456789])")
np.set_printoptions(precision=4)
assert_equal(repr(x), "array([ 1.5 , 0. , 1.2346])")
def test_formatter(self):
x = np.arange(3)
np.set_printoptions(formatter={'all':lambda x: str(x-1)})
assert_equal(repr(x), "array([-1, 0, 1])")
def test_formatter_reset(self):
x = np.arange(3)
np.set_printoptions(formatter={'all':lambda x: str(x-1)})
assert_equal(repr(x), "array([-1, 0, 1])")
np.set_printoptions(formatter={'int':None})
assert_equal(repr(x), "array([0, 1, 2])")
np.set_printoptions(formatter={'all':lambda x: str(x-1)})
assert_equal(repr(x), "array([-1, 0, 1])")
np.set_printoptions(formatter={'all':None})
assert_equal(repr(x), "array([0, 1, 2])")
np.set_printoptions(formatter={'int':lambda x: str(x-1)})
assert_equal(repr(x), "array([-1, 0, 1])")
np.set_printoptions(formatter={'int_kind':None})
assert_equal(repr(x), "array([0, 1, 2])")
x = np.arange(3.)
np.set_printoptions(formatter={'float':lambda x: str(x-1)})
assert_equal(repr(x), "array([-1.0, 0.0, 1.0])")
np.set_printoptions(formatter={'float_kind':None})
assert_equal(repr(x), "array([ 0., 1., 2.])")
def test_unicode_object_array():
import sys
if sys.version_info[0] >= 3:
expected = "array(['é'], dtype=object)"
else:
expected = "array([u'\\xe9'], dtype=object)"
x = np.array([u'\xe9'], dtype=object)
assert_equal(repr(x), expected)
if __name__ == "__main__":
run_module_suite()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
984,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
627,
199,
199,
533,
1379,
3836,
15713,
8,
785,
304,
272,
347,
511,
63,
4304,
63,
4904,
8,
277,
304,
267,
671,
275,
980,
14,
1144,
779,
1590,
14,
4304,
12,
980,
14,
4904,
566,
267,
702,
63,
1452,
8,
2722,
8,
88,
395,
283,
1144,
779,
12055,
12,
221,
10739,
566,
358,
199,
199,
533,
1379,
14500,
3836,
8,
1746,
304,
272,
347,
511,
63,
495,
8,
277,
304,
267,
519,
3643,
275,
359,
16,
12,
413,
12,
446,
17,
12,
980,
14,
4904,
12,
446,
1590,
14,
4904,
12,
980,
14,
4304,
61,
267,
286,
3643,
275,
359,
5254,
8,
4599,
12,
3384,
9,
367,
15099,
315,
519,
3643,
367,
3384,
315,
519,
3643,
61,
267,
6674,
275,
359,
1590,
14,
5254,
772,
12,
980,
14,
67,
3157,
12,
980,
14,
429,
951,
3157,
61,
267,
3503,
275,
359,
495,
8,
1590,
14,
1144,
779,
67,
467,
4487,
430,
367,
286,
315,
286,
3643,
367,
4487,
315,
6674,
61,
267,
13632,
275,
359,
288,
6730,
378,
6977,
16,
14,
74,
4300,
259,
6730,
378,
6977,
16,
14,
74,
4300,
259,
6730,
378,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
6730,
378,
6977,
17,
14,
74,
4300,
259,
6730,
378,
6977,
17,
14,
74,
4300,
259,
6730,
378,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
6730,
378,
23683,
17,
14,
74,
4300,
259,
6730,
378,
23683,
17,
14,
74,
4300,
259,
6730,
378,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
6730,
378,
6977,
4904,
74,
4300,
257,
6730,
378,
6977,
4904,
74,
4300,
257,
6730,
378,
14,
16,
11,
4904,
74,
4300,
288,
6730,
378,
23683,
4904,
74,
4300,
257,
6730,
378,
23683,
4904,
74,
4300,
257,
6730,
378,
14,
16,
13,
4904,
74,
4300,
288,
6730,
378,
6977,
4304,
74,
4300,
257,
6730,
378,
6977,
4304,
74,
4300,
257,
6730,
378,
14,
16,
11,
4304,
74,
4300,
288,
6730,
413,
6977,
16,
14,
74,
4300,
259,
6730,
413,
6977,
16,
14,
74,
4300,
259,
6730,
413,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
6730,
413,
6977,
17,
14,
74,
4300,
259,
6730,
413,
6977,
17,
14,
74,
4300,
259,
6730,
413,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
6730,
413,
23683,
17,
14,
74,
4300,
259,
6730,
413,
23683,
17,
14,
74,
4300,
259,
6730,
413,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
6730,
413,
6977,
4904,
74,
4300,
257,
6730,
413,
6977,
4904,
74,
4300,
257,
6730,
413,
14,
16,
11,
4904,
74,
4300,
288,
6730,
413,
23683,
4904,
74,
4300,
257,
6730,
413,
23683,
4904,
74,
4300,
257,
6730,
413,
14,
16,
13,
4904,
74,
4300,
288,
6730,
413,
6977,
4304,
74,
4300,
257,
6730,
413,
6977,
4304,
74,
4300,
257,
6730,
413,
14,
16,
11,
4304,
74,
4300,
288,
283,
1988,
17,
6977,
16,
14,
74,
4300,
259,
283,
1988,
17,
6977,
16,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
283,
1988,
17,
6977,
17,
14,
74,
4300,
259,
283,
1988,
17,
6977,
17,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
283,
1988,
17,
23683,
17,
14,
74,
4300,
259,
283,
1988,
17,
23683,
17,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
283,
1988,
17,
6977,
4904,
74,
4300,
257,
283,
1988,
17,
6977,
4904,
74,
4300,
257,
283,
1988,
17,
14,
16,
11,
4904,
74,
4300,
288,
283,
1988,
17,
23683,
4904,
74,
4300,
257,
283,
1988,
17,
23683,
4904,
74,
4300,
257,
283,
1988,
17,
14,
16,
13,
4904,
74,
4300,
288,
283,
1988,
17,
6977,
4304,
74,
4300,
257,
283,
1988,
17,
6977,
4304,
74,
4300,
257,
283,
1988,
17,
14,
16,
11,
4304,
74,
4300,
288,
6730,
10739,
11,
16,
14,
74,
4300,
257,
6730,
10739,
11,
16,
14,
74,
4300,
257,
6730,
10739,
11,
16,
14,
16,
74,
4300,
288,
6730,
10739,
11,
17,
14,
74,
4300,
257,
6730,
10739,
11,
17,
14,
74,
4300,
257,
6730,
10739,
11,
17,
14,
16,
74,
4300,
288,
6730,
10739,
13,
17,
14,
74,
4300,
257,
6730,
10739,
13,
17,
14,
74,
4300,
257,
6730,
10739,
13,
17,
14,
16,
74,
4300,
288,
6730,
10739,
11,
4904,
74,
4300,
221,
6730,
10739,
11,
4904,
74,
4300,
221,
6730,
10739,
11,
4904,
74,
4300,
288,
6730,
10739,
13,
4904,
74,
4300,
221,
6730,
10739,
13,
4904,
74,
4300,
221,
6730,
10739,
13,
4904,
74,
4300,
288,
6730,
10739,
11,
4304,
74,
4300,
221,
6730,
10739,
11,
4304,
74,
4300,
221,
6730,
10739,
11,
4304,
74,
4300,
288,
283,
1988,
4904,
11,
16,
14,
74,
4300,
257,
283,
1988,
4904,
11,
16,
14,
74,
4300,
257,
283,
1988,
4904,
11,
16,
14,
16,
74,
4300,
288,
283,
1988,
4904,
11,
17,
14,
74,
4300,
257,
283,
1988,
4904,
11,
17,
14,
74,
4300,
257,
283,
1988,
4904,
11,
17,
14,
16,
74,
4300,
288,
283,
1988,
4904,
13,
17,
14,
74,
4300,
257,
283,
1988,
4904,
13,
17,
14,
74,
4300,
257,
283,
1988,
4904,
13,
17,
14,
16,
74,
4300,
288,
283,
1988,
4904,
11,
4904,
74,
4300,
221,
283,
1988,
4904,
11,
4904,
74,
4300,
221,
283,
1988,
4904,
11,
4904,
74,
4300,
288,
283,
1988,
4904,
13,
4904,
74,
4300,
221,
283,
1988,
4904,
13,
4904,
74,
4300,
221,
283,
1988,
4904,
13,
4904,
74,
4300,
288,
283,
1988,
4904,
11,
4304,
74,
4300,
221,
283,
1988,
4904,
11,
4304,
74,
4300,
221,
283,
1988,
4904,
11,
4304,
74,
4300,
288,
6730,
12055,
11,
16,
14,
74,
4300,
257,
6730,
12055,
11,
16,
14,
74,
4300,
257,
6730,
12055,
11,
16,
14,
16,
74,
4300,
288,
6730,
12055,
11,
17,
14,
74,
4300,
257,
6730,
12055,
11,
17,
14,
74,
4300,
257,
6730,
12055,
11,
17,
14,
16,
74,
4300,
288,
6730,
12055,
13,
17,
14,
74,
4300,
257,
6730,
12055,
13,
17,
14,
74,
4300,
257,
6730
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
984,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
627,
199,
199,
533,
1379,
3836,
15713,
8,
785,
304,
272,
347,
511,
63,
4304,
63,
4904,
8,
277,
304,
267,
671,
275,
980,
14,
1144,
779,
1590,
14,
4304,
12,
980,
14,
4904,
566,
267,
702,
63,
1452,
8,
2722,
8,
88,
395,
283,
1144,
779,
12055,
12,
221,
10739,
566,
358,
199,
199,
533,
1379,
14500,
3836,
8,
1746,
304,
272,
347,
511,
63,
495,
8,
277,
304,
267,
519,
3643,
275,
359,
16,
12,
413,
12,
446,
17,
12,
980,
14,
4904,
12,
446,
1590,
14,
4904,
12,
980,
14,
4304,
61,
267,
286,
3643,
275,
359,
5254,
8,
4599,
12,
3384,
9,
367,
15099,
315,
519,
3643,
367,
3384,
315,
519,
3643,
61,
267,
6674,
275,
359,
1590,
14,
5254,
772,
12,
980,
14,
67,
3157,
12,
980,
14,
429,
951,
3157,
61,
267,
3503,
275,
359,
495,
8,
1590,
14,
1144,
779,
67,
467,
4487,
430,
367,
286,
315,
286,
3643,
367,
4487,
315,
6674,
61,
267,
13632,
275,
359,
288,
6730,
378,
6977,
16,
14,
74,
4300,
259,
6730,
378,
6977,
16,
14,
74,
4300,
259,
6730,
378,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
6730,
378,
6977,
17,
14,
74,
4300,
259,
6730,
378,
6977,
17,
14,
74,
4300,
259,
6730,
378,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
6730,
378,
23683,
17,
14,
74,
4300,
259,
6730,
378,
23683,
17,
14,
74,
4300,
259,
6730,
378,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
6730,
378,
6977,
4904,
74,
4300,
257,
6730,
378,
6977,
4904,
74,
4300,
257,
6730,
378,
14,
16,
11,
4904,
74,
4300,
288,
6730,
378,
23683,
4904,
74,
4300,
257,
6730,
378,
23683,
4904,
74,
4300,
257,
6730,
378,
14,
16,
13,
4904,
74,
4300,
288,
6730,
378,
6977,
4304,
74,
4300,
257,
6730,
378,
6977,
4304,
74,
4300,
257,
6730,
378,
14,
16,
11,
4304,
74,
4300,
288,
6730,
413,
6977,
16,
14,
74,
4300,
259,
6730,
413,
6977,
16,
14,
74,
4300,
259,
6730,
413,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
6730,
413,
6977,
17,
14,
74,
4300,
259,
6730,
413,
6977,
17,
14,
74,
4300,
259,
6730,
413,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
6730,
413,
23683,
17,
14,
74,
4300,
259,
6730,
413,
23683,
17,
14,
74,
4300,
259,
6730,
413,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
6730,
413,
6977,
4904,
74,
4300,
257,
6730,
413,
6977,
4904,
74,
4300,
257,
6730,
413,
14,
16,
11,
4904,
74,
4300,
288,
6730,
413,
23683,
4904,
74,
4300,
257,
6730,
413,
23683,
4904,
74,
4300,
257,
6730,
413,
14,
16,
13,
4904,
74,
4300,
288,
6730,
413,
6977,
4304,
74,
4300,
257,
6730,
413,
6977,
4304,
74,
4300,
257,
6730,
413,
14,
16,
11,
4304,
74,
4300,
288,
283,
1988,
17,
6977,
16,
14,
74,
4300,
259,
283,
1988,
17,
6977,
16,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
11,
16,
14,
16,
74,
4300,
288,
283,
1988,
17,
6977,
17,
14,
74,
4300,
259,
283,
1988,
17,
6977,
17,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
11,
17,
14,
16,
74,
4300,
288,
283,
1988,
17,
23683,
17,
14,
74,
4300,
259,
283,
1988,
17,
23683,
17,
14,
74,
4300,
259,
283,
1988,
17,
14,
16,
13,
17,
14,
16,
74,
4300,
288,
283,
1988,
17,
6977,
4904,
74,
4300,
257,
283,
1988,
17,
6977,
4904,
74,
4300,
257,
283,
1988,
17,
14,
16,
11,
4904,
74,
4300,
288,
283,
1988,
17,
23683,
4904,
74,
4300,
257,
283,
1988,
17,
23683,
4904,
74,
4300,
257,
283,
1988,
17,
14,
16,
13,
4904,
74,
4300,
288,
283,
1988,
17,
6977,
4304,
74,
4300,
257,
283,
1988,
17,
6977,
4304,
74,
4300,
257,
283,
1988,
17,
14,
16,
11,
4304,
74,
4300,
288,
6730,
10739,
11,
16,
14,
74,
4300,
257,
6730,
10739,
11,
16,
14,
74,
4300,
257,
6730,
10739,
11,
16,
14,
16,
74,
4300,
288,
6730,
10739,
11,
17,
14,
74,
4300,
257,
6730,
10739,
11,
17,
14,
74,
4300,
257,
6730,
10739,
11,
17,
14,
16,
74,
4300,
288,
6730,
10739,
13,
17,
14,
74,
4300,
257,
6730,
10739,
13,
17,
14,
74,
4300,
257,
6730,
10739,
13,
17,
14,
16,
74,
4300,
288,
6730,
10739,
11,
4904,
74,
4300,
221,
6730,
10739,
11,
4904,
74,
4300,
221,
6730,
10739,
11,
4904,
74,
4300,
288,
6730,
10739,
13,
4904,
74,
4300,
221,
6730,
10739,
13,
4904,
74,
4300,
221,
6730,
10739,
13,
4904,
74,
4300,
288,
6730,
10739,
11,
4304,
74,
4300,
221,
6730,
10739,
11,
4304,
74,
4300,
221,
6730,
10739,
11,
4304,
74,
4300,
288,
283,
1988,
4904,
11,
16,
14,
74,
4300,
257,
283,
1988,
4904,
11,
16,
14,
74,
4300,
257,
283,
1988,
4904,
11,
16,
14,
16,
74,
4300,
288,
283,
1988,
4904,
11,
17,
14,
74,
4300,
257,
283,
1988,
4904,
11,
17,
14,
74,
4300,
257,
283,
1988,
4904,
11,
17,
14,
16,
74,
4300,
288,
283,
1988,
4904,
13,
17,
14,
74,
4300,
257,
283,
1988,
4904,
13,
17,
14,
74,
4300,
257,
283,
1988,
4904,
13,
17,
14,
16,
74,
4300,
288,
283,
1988,
4904,
11,
4904,
74,
4300,
221,
283,
1988,
4904,
11,
4904,
74,
4300,
221,
283,
1988,
4904,
11,
4904,
74,
4300,
288,
283,
1988,
4904,
13,
4904,
74,
4300,
221,
283,
1988,
4904,
13,
4904,
74,
4300,
221,
283,
1988,
4904,
13,
4904,
74,
4300,
288,
283,
1988,
4904,
11,
4304,
74,
4300,
221,
283,
1988,
4904,
11,
4304,
74,
4300,
221,
283,
1988,
4904,
11,
4304,
74,
4300,
288,
6730,
12055,
11,
16,
14,
74,
4300,
257,
6730,
12055,
11,
16,
14,
74,
4300,
257,
6730,
12055,
11,
16,
14,
16,
74,
4300,
288,
6730,
12055,
11,
17,
14,
74,
4300,
257,
6730,
12055,
11,
17,
14,
74,
4300,
257,
6730,
12055,
11,
17,
14,
16,
74,
4300,
288,
6730,
12055,
13,
17,
14,
74,
4300,
257,
6730,
12055,
13,
17,
14,
74,
4300,
257,
6730,
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,
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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
] |
arank/mxnet
|
tests/python/unittest/test_model_parallel.py
|
13
|
1545
|
import numpy as np
import mxnet as mx
def reldiff(a, b):
diff = np.sum(np.abs(a - b))
norm = np.sum(np.abs(a))
if diff == 0:
return 0
reldiff = diff / norm
return reldiff
def test_chain():
n = 2
data1 = mx.sym.Variable('data1')
data2 = mx.sym.Variable('data2')
with mx.AttrScope(ctx_group='dev1'):
net = data1 + data2
net = net * 3
with mx.AttrScope(ctx_group='dev2'):
net = net + data1
with mx.Context(mx.cpu(0)):
shape = (4, 5)
arr = [mx.nd.empty(shape) for i in range(n)]
arr_grad = [mx.nd.empty(shape) for i in range(n)]
exec1 = net.bind(mx.cpu(),
args=arr,
args_grad=arr_grad,
group2ctx={'dev1': mx.cpu(0), 'dev2': mx.cpu(1)})
arr[0][:] = 1.0
arr[1][:] = 2.0
arr2 = [a.copyto(mx.cpu()) for a in arr]
arr_grad2 = [a.copyto(mx.cpu()) for a in arr_grad]
exec2 = net.bind(mx.cpu(),
args=arr2,
args_grad=arr_grad2)
# Show the execution plan that involves copynode
print(exec1.debug_str())
exec1.forward()
exec2.forward()
assert reldiff(exec1.outputs[0].asnumpy(), exec2.outputs[0].asnumpy()) < 1e-6
out_grad = mx.nd.empty(shape, mx.cpu(1))
out_grad[:] = 1.0
exec1.backward([out_grad])
exec2.backward([out_grad.copyto(mx.cpu())])
for a, b in zip(arr_grad, arr_grad2):
assert reldiff(a.asnumpy(), b.asnumpy()) < 1e-6
if __name__ == '__main__':
test_chain()
|
apache-2.0
|
[
646,
2680,
465,
980,
199,
646,
8728,
846,
465,
8728,
199,
199,
318,
4668,
3028,
8,
65,
12,
330,
304,
272,
3915,
275,
980,
14,
1838,
8,
1590,
14,
2101,
8,
65,
446,
330,
430,
272,
6316,
275,
980,
14,
1838,
8,
1590,
14,
2101,
8,
65,
430,
272,
340,
3915,
508,
378,
26,
267,
372,
378,
272,
4668,
3028,
275,
3915,
221,
1182,
6316,
272,
372,
4668,
3028,
199,
199,
318,
511,
63,
4429,
837,
272,
302,
275,
499,
272,
666,
17,
275,
8728,
14,
3840,
14,
2773,
360,
576,
17,
358,
272,
666,
18,
275,
8728,
14,
3840,
14,
2773,
360,
576,
18,
358,
272,
543,
8728,
14,
7144,
7812,
8,
3799,
63,
923,
534,
2374,
17,
735,
267,
1851,
275,
666,
17,
435,
666,
18,
267,
1851,
275,
1851,
627,
650,
339,
543,
8728,
14,
7144,
7812,
8,
3799,
63,
923,
534,
2374,
18,
735,
267,
1851,
275,
1851,
435,
666,
17,
339,
543,
8728,
14,
2998,
8,
9457,
14,
3541,
8,
16,
2298,
267,
2215,
275,
334,
20,
12,
959,
9,
267,
7953,
275,
359,
9457,
14,
977,
14,
1667,
8,
1392,
9,
367,
284,
315,
1425,
8,
78,
1874,
267,
7953,
63,
6017,
275,
359,
9457,
14,
977,
14,
1667,
8,
1392,
9,
367,
284,
315,
1425,
8,
78,
1874,
339,
2146,
17,
275,
1851,
14,
3409,
8,
9457,
14,
3541,
1062,
2151,
1249,
29,
5250,
12,
2151,
1249,
63,
6017,
29,
5250,
63,
6017,
12,
2151,
1572,
18,
3799,
3713,
2374,
17,
356,
8728,
14,
3541,
8,
16,
395,
283,
2374,
18,
356,
8728,
14,
3541,
8,
17,
11466,
272,
7953,
59,
16,
61,
5873,
275,
413,
14,
16,
272,
7953,
59,
17,
61,
5873,
275,
499,
14,
16,
272,
7953,
18,
275,
359,
65,
14,
1574,
475,
8,
9457,
14,
3541,
1012,
367,
282,
315,
7953,
61,
272,
7953,
63,
6017,
18,
275,
359,
65,
14,
1574,
475,
8,
9457,
14,
3541,
1012,
367,
282,
315,
7953,
63,
6017,
61,
272,
2146,
18,
275,
1851,
14,
3409,
8,
9457,
14,
3541,
1062,
2151,
1249,
29,
5250,
18,
12,
2151,
1249,
63,
6017,
29,
5250,
63,
6017,
18,
9,
339,
327,
12968,
314,
6451,
8683,
626,
25613,
2310,
1331,
932,
272,
870,
8,
1628,
17,
14,
1757,
63,
495,
1012,
272,
2146,
17,
14,
6688,
342,
272,
2146,
18,
14,
6688,
342,
272,
702,
4668,
3028,
8,
1628,
17,
14,
4467,
59,
16,
1055,
32204,
1062,
2146,
18,
14,
4467,
59,
16,
1055,
32204,
1012,
665,
413,
69,
13,
22,
272,
734,
63,
6017,
275,
8728,
14,
977,
14,
1667,
8,
1392,
12,
8728,
14,
3541,
8,
17,
430,
272,
734,
63,
6017,
5873,
275,
413,
14,
16,
272,
2146,
17,
14,
15457,
779,
548,
63,
6017,
566,
272,
2146,
18,
14,
15457,
779,
548,
63,
6017,
14,
1574,
475,
8,
9457,
14,
3541,
30719,
272,
367,
282,
12,
330,
315,
3482,
8,
5250,
63,
6017,
12,
7953,
63,
6017,
18,
304,
267,
702,
4668,
3028,
8,
65,
14,
32204,
1062,
330,
14,
32204,
1012,
665,
413,
69,
13,
22,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
4429,
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
] |
[
2680,
465,
980,
199,
646,
8728,
846,
465,
8728,
199,
199,
318,
4668,
3028,
8,
65,
12,
330,
304,
272,
3915,
275,
980,
14,
1838,
8,
1590,
14,
2101,
8,
65,
446,
330,
430,
272,
6316,
275,
980,
14,
1838,
8,
1590,
14,
2101,
8,
65,
430,
272,
340,
3915,
508,
378,
26,
267,
372,
378,
272,
4668,
3028,
275,
3915,
221,
1182,
6316,
272,
372,
4668,
3028,
199,
199,
318,
511,
63,
4429,
837,
272,
302,
275,
499,
272,
666,
17,
275,
8728,
14,
3840,
14,
2773,
360,
576,
17,
358,
272,
666,
18,
275,
8728,
14,
3840,
14,
2773,
360,
576,
18,
358,
272,
543,
8728,
14,
7144,
7812,
8,
3799,
63,
923,
534,
2374,
17,
735,
267,
1851,
275,
666,
17,
435,
666,
18,
267,
1851,
275,
1851,
627,
650,
339,
543,
8728,
14,
7144,
7812,
8,
3799,
63,
923,
534,
2374,
18,
735,
267,
1851,
275,
1851,
435,
666,
17,
339,
543,
8728,
14,
2998,
8,
9457,
14,
3541,
8,
16,
2298,
267,
2215,
275,
334,
20,
12,
959,
9,
267,
7953,
275,
359,
9457,
14,
977,
14,
1667,
8,
1392,
9,
367,
284,
315,
1425,
8,
78,
1874,
267,
7953,
63,
6017,
275,
359,
9457,
14,
977,
14,
1667,
8,
1392,
9,
367,
284,
315,
1425,
8,
78,
1874,
339,
2146,
17,
275,
1851,
14,
3409,
8,
9457,
14,
3541,
1062,
2151,
1249,
29,
5250,
12,
2151,
1249,
63,
6017,
29,
5250,
63,
6017,
12,
2151,
1572,
18,
3799,
3713,
2374,
17,
356,
8728,
14,
3541,
8,
16,
395,
283,
2374,
18,
356,
8728,
14,
3541,
8,
17,
11466,
272,
7953,
59,
16,
61,
5873,
275,
413,
14,
16,
272,
7953,
59,
17,
61,
5873,
275,
499,
14,
16,
272,
7953,
18,
275,
359,
65,
14,
1574,
475,
8,
9457,
14,
3541,
1012,
367,
282,
315,
7953,
61,
272,
7953,
63,
6017,
18,
275,
359,
65,
14,
1574,
475,
8,
9457,
14,
3541,
1012,
367,
282,
315,
7953,
63,
6017,
61,
272,
2146,
18,
275,
1851,
14,
3409,
8,
9457,
14,
3541,
1062,
2151,
1249,
29,
5250,
18,
12,
2151,
1249,
63,
6017,
29,
5250,
63,
6017,
18,
9,
339,
327,
12968,
314,
6451,
8683,
626,
25613,
2310,
1331,
932,
272,
870,
8,
1628,
17,
14,
1757,
63,
495,
1012,
272,
2146,
17,
14,
6688,
342,
272,
2146,
18,
14,
6688,
342,
272,
702,
4668,
3028,
8,
1628,
17,
14,
4467,
59,
16,
1055,
32204,
1062,
2146,
18,
14,
4467,
59,
16,
1055,
32204,
1012,
665,
413,
69,
13,
22,
272,
734,
63,
6017,
275,
8728,
14,
977,
14,
1667,
8,
1392,
12,
8728,
14,
3541,
8,
17,
430,
272,
734,
63,
6017,
5873,
275,
413,
14,
16,
272,
2146,
17,
14,
15457,
779,
548,
63,
6017,
566,
272,
2146,
18,
14,
15457,
779,
548,
63,
6017,
14,
1574,
475,
8,
9457,
14,
3541,
30719,
272,
367,
282,
12,
330,
315,
3482,
8,
5250,
63,
6017,
12,
7953,
63,
6017,
18,
304,
267,
702,
4668,
3028,
8,
65,
14,
32204,
1062,
330,
14,
32204,
1012,
665,
413,
69,
13,
22,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
4429,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rlizana/l10n-spain
|
l10n_es_aeat_mod349/models/account_invoice.py
|
6
|
7275
|
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models, fields, api, exceptions, _
from datetime import datetime, date
import calendar
OPERATION_KEYS = [
('E', 'E - Intra-Community supplies'),
('A', 'A - Intra-Community acquisition'),
('T', 'T - Triangular operations'),
('S', 'S - Intra-Community services'),
('I', 'I - Intra-Community services acquisitions'),
('M', 'M - Intra-Community supplies without taxes'),
('H', 'H - Intra-Community supplies without taxes '
'delivered by legal representative')
]
class AccountInvoice(models.Model):
"""Inheritance of account invoce to add some fields:
- operation_key: Operation key of invoice
"""
_inherit = 'account.invoice'
def _get_operation_key(self, fp, invoice_type):
if not fp.intracommunity_operations:
return False
else:
# TODO: Ver cómo discernir si son prestación de servicios
if invoice_type in ('out_invoice', 'out_refund'):
# Establecer a entrega si es de venta
return 'E'
else:
# Establecer a adquisición si es de compra
return 'A'
def _get_year_from_fy_month(self, fy, month):
fy_start = fields.Date.from_string(fy.date_start)
fy_stop = fields.Date.from_string(fy.date_stop)
if fy_start.month < month:
year = fy_start.year
elif fy_stop.month > month:
year = fy_stop.year
else:
raise exceptions.Warning(
_('Cannot get invoices.\nProvided month is not included on '
'selected fiscal year'))
return year
@api.model
def _get_invoices_by_type(
self, partner, operation_key, fiscalyear=None,
period_id=None, month=None, period_selection=None):
"""
Returns invoices ids by type (supplier/customer) for a fiscal
year, period or month.
"""
assert period_selection, 'There is no period selected'
# Set type of invoice
invoice_type = ('in_invoice', 'out_invoice', 'in_refund', 'out_refund')
domain = [('partner_id', 'child_of', partner.id),
('state', 'in', ['open', 'paid']),
('type', 'in', invoice_type),
('operation_key', '=', operation_key)]
# Invoices by fiscalyear (Annual)
if period_selection == '0A':
if not fiscalyear:
raise exceptions.Warning(
_('Cannot get invoices.\nThere is no fiscal year '
'selected'))
domain.append(('period_id', 'in',
[period.id for period in fiscalyear.period_ids
if not period.special]))
# Invoices by period
elif period_selection in ['1T', '2T', '3T', '4T']:
if not period_id:
raise exceptions.Warning(
_('Cannot get invoices.\nThere is no period selected'))
domain.append(('period_id', 'in', period_id))
# Invoices by month
else:
if not month and not fiscalyear:
raise exceptions.Warning(
_('Cannot get invoices.\nThere is no month and/or fiscal '
'year selected'))
month = int(month)
year = self._get_year_from_fy_month(fiscalyear, month)
month_last_day = calendar.monthrange(year, month)[1]
date_start = datetime(year=year, month=month, day=1)
date_stop = datetime(year=year, month=month, day=month_last_day)
domain.append(
('date_invoice', '>=', fields.Date.to_string(date_start)))
domain.append(
('date_invoice', '<=', fields.Date.to_string(date_stop)))
return self.search(domain)
@api.multi
def clean_refund_invoices(
self, partner, fiscalyear=None, periods=None, month=None,
period_selection=None):
"""Separate refunds from invoices"""
invoices = self.env['account.invoice']
refunds = self.env['account.invoice']
for inv in self:
if inv.type in ('in_refund', 'out_refund'):
if not inv.origin_invoices_ids:
invoices += inv
continue
for origin_line in inv.origin_invoices_ids:
if (origin_line.state in ('open', 'paid') and
origin_line.partner_id.commercial_partner_id ==
partner):
if period_selection == '0A':
if (origin_line.period_id.id not in
[period.id for period in
fiscalyear.period_ids if not
period.special]):
refunds += inv
else:
invoices += inv
elif period_selection in ['1T', '2T', '3T', '4T']:
if origin_line.period_id not in periods:
refunds += inv
else:
invoices += inv
else:
month = int(month)
year = self._get_year_from_fy_month(fiscalyear,
month)
if (fields.Date.from_string(
origin_line.date_invoice) <
date(year=year, month=month, day=1)):
refunds += inv
else:
invoices += inv
break
else:
invoices += inv
return invoices, refunds
@api.multi
def on_change_fiscal_position(self, fiscal_position, invoice_type):
"""Suggest an operation key when fiscal position changes."""
res = {'operation_key': False}
if fiscal_position and invoice_type:
fp = self.env['account.fiscal.position'].browse(fiscal_position)
res['operation_key'] = self._get_operation_key(fp, invoice_type)
return {'value': res}
@api.model
def create(self, vals):
"""Writes operation key value, if invoice is created in
backgroud with intracommunity fiscal position defined"""
if vals.get('fiscal_position') and \
vals.get('type') and not vals.get('operation_key'):
fp_obj = self.env['account.fiscal.position']
fp = fp_obj.browse(vals['fiscal_position'])
vals['operation_key'] = self._get_operation_key(fp, vals['type'])
return super(AccountInvoice, self).create(vals)
operation_key = fields.Selection(selection=OPERATION_KEYS,
string='Operation key')
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
2104,
4248,
436,
4190,
949,
7724,
12,
1937,
636,
11267,
4343,
647,
570,
315,
1738,
2082,
199,
4605,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
4967,
12,
485,
199,
504,
2197,
492,
2197,
12,
1434,
199,
646,
11234,
199,
199,
31324,
63,
17434,
275,
359,
272,
661,
37,
297,
283,
37,
446,
9805,
345,
13,
29799,
4973,
6528,
659,
272,
661,
33,
297,
283,
33,
446,
9805,
345,
13,
29799,
1066,
21523,
659,
272,
661,
52,
297,
283,
52,
446,
12480,
11572,
5331,
659,
272,
661,
51,
297,
283,
51,
446,
9805,
345,
13,
29799,
8500,
659,
272,
661,
41,
297,
283,
41,
446,
9805,
345,
13,
29799,
8500,
1066,
783,
6150,
659,
272,
661,
45,
297,
283,
45,
446,
9805,
345,
13,
29799,
4973,
6528,
1928,
21139,
659,
272,
661,
40,
297,
283,
40,
446,
9805,
345,
13,
29799,
4973,
6528,
1928,
21139,
283,
1362,
283,
30480,
701,
18393,
2954,
1905,
358,
199,
61,
421,
199,
533,
9973,
21092,
8,
992,
14,
1685,
304,
272,
408,
23542,
554,
402,
2933,
315,
2392,
301,
370,
1050,
2005,
1504,
26,
272,
446,
3439,
63,
498,
26,
17954,
790,
402,
8485,
272,
408,
272,
485,
6486,
275,
283,
2048,
14,
5404,
7,
339,
347,
485,
362,
63,
5735,
63,
498,
8,
277,
12,
4090,
12,
8485,
63,
466,
304,
267,
340,
440,
4090,
14,
442,
345,
9387,
63,
8170,
26,
288,
372,
756,
267,
587,
26,
288,
327,
3254,
26,
5444,
286,
11980,
573,
4339,
27569,
723,
13877,
27970,
876,
1207,
27064,
477,
8926,
433,
559,
736,
288,
340,
8485,
63,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
735,
355,
327,
662,
11989,
2247,
282,
15992,
1135,
65,
13877,
9455,
477,
373,
21335,
355,
372,
283,
37,
7,
288,
587,
26,
355,
327,
662,
11989,
2247,
282,
1503,
783,
338,
27064,
13877,
9455,
477,
1013,
345,
355,
372,
283,
33,
7,
339,
347,
485,
362,
63,
3403,
63,
504,
63,
1399,
63,
4482,
8,
277,
12,
289,
89,
12,
5794,
304,
267,
289,
89,
63,
928,
275,
1504,
14,
2506,
14,
504,
63,
875,
8,
1399,
14,
602,
63,
928,
9,
267,
289,
89,
63,
2379,
275,
1504,
14,
2506,
14,
504,
63,
875,
8,
1399,
14,
602,
63,
2379,
9,
267,
340,
289,
89,
63,
928,
14,
4482,
665,
5794,
26,
288,
5361,
275,
289,
89,
63,
928,
14,
3403,
267,
916,
289,
89,
63,
2379,
14,
4482,
690,
5794,
26,
288,
5361,
275,
289,
89,
63,
2379,
14,
3403,
267,
587,
26,
288,
746,
4967,
14,
3849,
8,
355,
4018,
6612,
664,
26175,
3134,
78,
919,
11923,
5794,
365,
440,
5120,
641,
283,
2116,
283,
5511,
18672,
5361,
1333,
267,
372,
5361,
339,
768,
1246,
14,
1238,
272,
347,
485,
362,
63,
28809,
63,
991,
63,
466,
8,
288,
291,
12,
5854,
12,
3439,
63,
498,
12,
18672,
3403,
29,
403,
12,
288,
6247,
63,
344,
29,
403,
12,
5794,
29,
403,
12,
6247,
63,
5592,
29,
403,
304,
267,
408,
267,
1803,
26175,
2762,
701,
730,
334,
17294,
15,
10178,
9,
367,
282,
18672,
267,
5361,
12,
6247,
503,
5794,
14,
267,
408,
267,
702,
6247,
63,
5592,
12,
283,
10924,
365,
949,
6247,
4895,
7,
267,
327,
2494,
730,
402,
8485,
267,
8485,
63,
466,
275,
661,
262,
63,
5404,
297,
283,
548,
63,
5404,
297,
283,
262,
63,
18440,
297,
283,
548,
63,
18440,
358,
267,
2881,
275,
4274,
3899,
63,
344,
297,
283,
1739,
63,
1618,
297,
5854,
14,
344,
395,
2116,
661,
929,
297,
283,
262,
297,
788,
1490,
297,
283,
16555,
3815,
2116,
661,
466,
297,
283,
262,
297,
8485,
63,
466,
395,
2116,
661,
5735,
63,
498,
297,
6291,
3439,
63,
498,
1874,
267,
327,
1010,
16687,
701,
18672,
3403,
334,
2493,
78,
1061,
9,
267,
340,
6247,
63,
5592,
508,
283,
16,
33,
356,
288,
340,
440,
18672,
3403,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
18672,
5361,
283,
1993,
283,
5511,
1333,
288,
2881,
14,
740,
4725,
5191,
63,
344,
297,
283,
262,
297,
2574,
359,
5191,
14,
344,
367,
6247,
315,
18672,
3403,
14,
5191,
63,
1580,
1169,
340,
440,
6247,
14,
6664,
2459,
267,
327,
1010,
16687,
701,
6247,
267,
916,
6247,
63,
5592,
315,
788,
17,
52,
297,
283,
18,
52,
297,
283,
19,
52,
297,
283,
20,
52,
2565,
288,
340,
440,
6247,
63,
344,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
6247,
4895,
1333,
288,
2881,
14,
740,
4725,
5191,
63,
344,
297,
283,
262,
297,
6247,
63,
344,
430,
267,
327,
1010,
16687,
701,
5794,
267,
587,
26,
288,
340,
440,
5794,
436,
440,
18672,
3403,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
5794,
436,
15,
269,
18672,
283,
1993,
283,
3403,
4895,
1333,
288,
5794,
275,
1109,
8,
4482,
9,
288,
5361,
275,
291,
423,
362,
63,
3403,
63,
504,
63,
1399,
63,
4482,
8,
21260,
12,
5794,
9,
288,
5794,
63,
2019,
63,
2977,
275,
11234,
14,
4482,
1842,
8,
3403,
12,
5794,
2788,
17,
61,
288,
1434,
63,
928,
275,
2197,
8,
3403,
29,
3403,
12,
5794,
29,
4482,
12,
5382,
29,
17,
9,
288,
1434,
63,
2379,
275,
2197,
8,
3403,
29,
3403,
12,
5794,
29,
4482,
12,
5382,
29,
4482,
63,
2019,
63,
2977,
9,
288,
2881,
14,
740,
8,
355,
661,
602,
63,
5404,
297,
12696,
4009,
1504,
14,
2506,
14,
475,
63,
875,
8,
602,
63,
928,
1724,
288,
2881,
14,
740,
8,
355,
661,
602,
63,
5404,
297,
2650,
4009,
1504,
14,
2506,
14,
475,
63,
875,
8,
602,
63,
2379,
1724,
267,
372,
291,
14,
1733,
8,
2261,
9,
339,
768,
1246,
14,
3029,
272,
347,
3633,
63,
18440,
63,
28809,
8,
288,
291,
12,
5854,
12,
18672,
3403,
29,
403,
12,
17382,
29,
403,
12,
5794,
29,
403,
12,
288,
6247,
63,
5592,
29,
403,
304,
267,
408,
12653,
323,
32219,
83,
687,
26175,
624,
267,
26175,
275,
291,
14
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
2104,
4248,
436,
4190,
949,
7724,
12,
1937,
636,
11267,
4343,
647,
570,
315,
1738,
2082,
199,
4605,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
4967,
12,
485,
199,
504,
2197,
492,
2197,
12,
1434,
199,
646,
11234,
199,
199,
31324,
63,
17434,
275,
359,
272,
661,
37,
297,
283,
37,
446,
9805,
345,
13,
29799,
4973,
6528,
659,
272,
661,
33,
297,
283,
33,
446,
9805,
345,
13,
29799,
1066,
21523,
659,
272,
661,
52,
297,
283,
52,
446,
12480,
11572,
5331,
659,
272,
661,
51,
297,
283,
51,
446,
9805,
345,
13,
29799,
8500,
659,
272,
661,
41,
297,
283,
41,
446,
9805,
345,
13,
29799,
8500,
1066,
783,
6150,
659,
272,
661,
45,
297,
283,
45,
446,
9805,
345,
13,
29799,
4973,
6528,
1928,
21139,
659,
272,
661,
40,
297,
283,
40,
446,
9805,
345,
13,
29799,
4973,
6528,
1928,
21139,
283,
1362,
283,
30480,
701,
18393,
2954,
1905,
358,
199,
61,
421,
199,
533,
9973,
21092,
8,
992,
14,
1685,
304,
272,
408,
23542,
554,
402,
2933,
315,
2392,
301,
370,
1050,
2005,
1504,
26,
272,
446,
3439,
63,
498,
26,
17954,
790,
402,
8485,
272,
408,
272,
485,
6486,
275,
283,
2048,
14,
5404,
7,
339,
347,
485,
362,
63,
5735,
63,
498,
8,
277,
12,
4090,
12,
8485,
63,
466,
304,
267,
340,
440,
4090,
14,
442,
345,
9387,
63,
8170,
26,
288,
372,
756,
267,
587,
26,
288,
327,
3254,
26,
5444,
286,
11980,
573,
4339,
27569,
723,
13877,
27970,
876,
1207,
27064,
477,
8926,
433,
559,
736,
288,
340,
8485,
63,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
735,
355,
327,
662,
11989,
2247,
282,
15992,
1135,
65,
13877,
9455,
477,
373,
21335,
355,
372,
283,
37,
7,
288,
587,
26,
355,
327,
662,
11989,
2247,
282,
1503,
783,
338,
27064,
13877,
9455,
477,
1013,
345,
355,
372,
283,
33,
7,
339,
347,
485,
362,
63,
3403,
63,
504,
63,
1399,
63,
4482,
8,
277,
12,
289,
89,
12,
5794,
304,
267,
289,
89,
63,
928,
275,
1504,
14,
2506,
14,
504,
63,
875,
8,
1399,
14,
602,
63,
928,
9,
267,
289,
89,
63,
2379,
275,
1504,
14,
2506,
14,
504,
63,
875,
8,
1399,
14,
602,
63,
2379,
9,
267,
340,
289,
89,
63,
928,
14,
4482,
665,
5794,
26,
288,
5361,
275,
289,
89,
63,
928,
14,
3403,
267,
916,
289,
89,
63,
2379,
14,
4482,
690,
5794,
26,
288,
5361,
275,
289,
89,
63,
2379,
14,
3403,
267,
587,
26,
288,
746,
4967,
14,
3849,
8,
355,
4018,
6612,
664,
26175,
3134,
78,
919,
11923,
5794,
365,
440,
5120,
641,
283,
2116,
283,
5511,
18672,
5361,
1333,
267,
372,
5361,
339,
768,
1246,
14,
1238,
272,
347,
485,
362,
63,
28809,
63,
991,
63,
466,
8,
288,
291,
12,
5854,
12,
3439,
63,
498,
12,
18672,
3403,
29,
403,
12,
288,
6247,
63,
344,
29,
403,
12,
5794,
29,
403,
12,
6247,
63,
5592,
29,
403,
304,
267,
408,
267,
1803,
26175,
2762,
701,
730,
334,
17294,
15,
10178,
9,
367,
282,
18672,
267,
5361,
12,
6247,
503,
5794,
14,
267,
408,
267,
702,
6247,
63,
5592,
12,
283,
10924,
365,
949,
6247,
4895,
7,
267,
327,
2494,
730,
402,
8485,
267,
8485,
63,
466,
275,
661,
262,
63,
5404,
297,
283,
548,
63,
5404,
297,
283,
262,
63,
18440,
297,
283,
548,
63,
18440,
358,
267,
2881,
275,
4274,
3899,
63,
344,
297,
283,
1739,
63,
1618,
297,
5854,
14,
344,
395,
2116,
661,
929,
297,
283,
262,
297,
788,
1490,
297,
283,
16555,
3815,
2116,
661,
466,
297,
283,
262,
297,
8485,
63,
466,
395,
2116,
661,
5735,
63,
498,
297,
6291,
3439,
63,
498,
1874,
267,
327,
1010,
16687,
701,
18672,
3403,
334,
2493,
78,
1061,
9,
267,
340,
6247,
63,
5592,
508,
283,
16,
33,
356,
288,
340,
440,
18672,
3403,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
18672,
5361,
283,
1993,
283,
5511,
1333,
288,
2881,
14,
740,
4725,
5191,
63,
344,
297,
283,
262,
297,
2574,
359,
5191,
14,
344,
367,
6247,
315,
18672,
3403,
14,
5191,
63,
1580,
1169,
340,
440,
6247,
14,
6664,
2459,
267,
327,
1010,
16687,
701,
6247,
267,
916,
6247,
63,
5592,
315,
788,
17,
52,
297,
283,
18,
52,
297,
283,
19,
52,
297,
283,
20,
52,
2565,
288,
340,
440,
6247,
63,
344,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
6247,
4895,
1333,
288,
2881,
14,
740,
4725,
5191,
63,
344,
297,
283,
262,
297,
6247,
63,
344,
430,
267,
327,
1010,
16687,
701,
5794,
267,
587,
26,
288,
340,
440,
5794,
436,
440,
18672,
3403,
26,
355,
746,
4967,
14,
3849,
8,
490,
4018,
6612,
664,
26175,
3134,
78,
10924,
365,
949,
5794,
436,
15,
269,
18672,
283,
1993,
283,
3403,
4895,
1333,
288,
5794,
275,
1109,
8,
4482,
9,
288,
5361,
275,
291,
423,
362,
63,
3403,
63,
504,
63,
1399,
63,
4482,
8,
21260,
12,
5794,
9,
288,
5794,
63,
2019,
63,
2977,
275,
11234,
14,
4482,
1842,
8,
3403,
12,
5794,
2788,
17,
61,
288,
1434,
63,
928,
275,
2197,
8,
3403,
29,
3403,
12,
5794,
29,
4482,
12,
5382,
29,
17,
9,
288,
1434,
63,
2379,
275,
2197,
8,
3403,
29,
3403,
12,
5794,
29,
4482,
12,
5382,
29,
4482,
63,
2019,
63,
2977,
9,
288,
2881,
14,
740,
8,
355,
661,
602,
63,
5404,
297,
12696,
4009,
1504,
14,
2506,
14,
475,
63,
875,
8,
602,
63,
928,
1724,
288,
2881,
14,
740,
8,
355,
661,
602,
63,
5404,
297,
2650,
4009,
1504,
14,
2506,
14,
475,
63,
875,
8,
602,
63,
2379,
1724,
267,
372,
291,
14,
1733,
8,
2261,
9,
339,
768,
1246,
14,
3029,
272,
347,
3633,
63,
18440,
63,
28809,
8,
288,
291,
12,
5854,
12,
18672,
3403,
29,
403,
12,
17382,
29,
403,
12,
5794,
29,
403,
12,
288,
6247,
63,
5592,
29,
403,
304,
267,
408,
12653,
323,
32219,
83,
687,
26175,
624,
267,
26175,
275,
291,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
TobbeTripitaka/bruges
|
bruges/attribute/test/similarity_test.py
|
3
|
2688
|
import unittest
import numpy
from bruges.attribute import similarity
class SimilarityTest( unittest.TestCase ):
def test_same_data( self ):
"""
Simple test to check if the algorithm works for the
trivial case.
"""
data = numpy.zeros( [100, 100] )
check_data = data + 1.0
data +=10.
window_size = 20
output = similarity( data, window_size )
same = numpy.allclose( check_data[:,1:],
output[:,1:], .001 )
self.assertTrue( same )
def test_stepout( self ):
data = numpy.zeros( [ 100,100 ] )
check_data = data + 1.0
# Make adjacent traces dissimilar, next nearest trace
# similar
data += 11.
data[ :,::2] = -11.0
window_size = 20
step_out = 2
# Check with a step out of 2
output = similarity( data, window_size,
step_out = step_out )
same = numpy.allclose( check_data[:,step_out:],
output[:,step_out:], .001 )
self.assertTrue( same )
# Check with a step out of 1
step_out = 1
output = similarity( data, window_size,
step_out = step_out )
# Everything should be zero
check_data -= 1
same = numpy.allclose( check_data[:,step_out:],
output[:,step_out:], .001 )
self.assertTrue( same )
def test_lag( self ):
data = numpy.zeros( [ 100,100 ] )
check_data = data + 1.0
# Make an off by 1 similarity that can be corrected
# with lag
data+=11
data[::2,::2] = -11.
data[1::2,1::2]=-11
lag = 2
window_size = 20
output = similarity( data, window_size,
lag=lag )
same = numpy.allclose( check_data[window_size/2 :,1:],
output[window_size/2 :,1:], atol=.01 )
self.assertTrue( same )
# Should be zero with no lag
lag = 0
window_size = 20
output = similarity( data, window_size,
lag=lag )
check_data[:,1:] -= 1.
same = numpy.allclose( check_data[:,1:],
output[:,1:], .001 )
self.assertTrue( same )
if __name__ == '__main__':
suite = \
unittest.TestLoader().loadTestsFromTestCase(SimilarityTest)
unittest.TextTestRunner(verbosity=2).run(suite)
|
apache-2.0
|
[
646,
2882,
199,
646,
2680,
199,
199,
504,
330,
6558,
3389,
14,
3215,
492,
22838,
421,
199,
533,
10751,
13093,
774,
8,
2882,
14,
1746,
3461,
339,
347,
511,
63,
7191,
63,
576,
8,
291,
3461,
267,
408,
267,
5870,
511,
370,
1104,
340,
314,
5563,
5419,
367,
314,
267,
28586,
1930,
14,
267,
408,
267,
666,
275,
2680,
14,
4250,
8,
359,
1960,
12,
2948,
61,
776,
4960,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
2728,
666,
847,
709,
14,
267,
4353,
63,
890,
275,
3388,
10813,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
776,
398,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
17,
8429,
221,
3044,
1072,
3981,
17,
8429,
1275,
4587,
776,
2728,
291,
14,
1815,
8,
2011,
776,
339,
347,
511,
63,
2926,
548,
8,
291,
3461,
398,
666,
275,
2680,
14,
4250,
8,
359,
2948,
12,
1960,
1622,
776,
267,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
398,
327,
4155,
24113,
26365,
2153,
23079,
12,
2163,
17173,
3307,
267,
327,
8545,
267,
666,
847,
4119,
14,
267,
666,
59,
13785,
447,
18,
61,
275,
446,
845,
14,
16,
398,
4353,
63,
890,
275,
3388,
267,
3650,
63,
548,
275,
499,
7318,
327,
2670,
543,
282,
3650,
734,
402,
499,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
3650,
63,
548,
275,
3650,
63,
548,
776,
31106,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
2926,
63,
548,
8429,
221,
3044,
1072,
3981,
2926,
63,
548,
8429,
1275,
4587,
776,
10631,
291,
14,
1815,
8,
2011,
776,
398,
327,
2670,
543,
282,
3650,
734,
402,
413,
267,
3650,
63,
548,
275,
413,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
3650,
63,
548,
275,
3650,
63,
548,
776,
31106,
327,
18414,
2127,
1077,
506,
4697,
267,
1104,
63,
576,
4862,
413,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
2926,
63,
548,
8429,
221,
3044,
1072,
3981,
2926,
63,
548,
8429,
1275,
4587,
776,
10631,
291,
14,
1815,
8,
2011,
776,
2378,
347,
511,
63,
1823,
8,
291,
3461,
398,
666,
275,
2680,
14,
4250,
8,
359,
2948,
12,
1960,
1622,
776,
267,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
398,
327,
4155,
376,
2331,
701,
413,
22838,
626,
883,
506,
30156,
267,
327,
543,
17891,
267,
666,
10365,
845,
267,
666,
10345,
18,
12,
447,
18,
61,
275,
446,
845,
14,
267,
666,
59,
17,
447,
18,
12,
17,
447,
18,
61,
4022,
845,
398,
17891,
275,
499,
267,
4353,
63,
890,
275,
3388,
2728,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
17891,
29,
1823,
776,
10817,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
59,
3806,
63,
890,
15,
18,
13785,
17,
8429,
221,
3044,
1072,
59,
3806,
63,
890,
15,
18,
13785,
17,
8429,
9543,
15856,
614,
776,
398,
267,
291,
14,
1815,
8,
2011,
776,
2728,
327,
7719,
506,
4697,
543,
949,
17891,
267,
17891,
275,
378,
267,
4353,
63,
890,
275,
3388,
2728,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
2490,
17891,
29,
1823,
776,
819,
267,
1104,
63,
576,
3981,
17,
2938,
4862,
413,
14,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
17,
8429,
221,
3044,
1072,
3981,
17,
8429,
1275,
4587,
776,
398,
291,
14,
1815,
8,
2011,
776,
268,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
5241,
275,
971,
489,
2882,
14,
15824,
1252,
26946,
8,
7467,
13093,
774,
9,
272,
2882,
14,
24285,
8,
9833,
29,
18,
680,
1065,
8,
5768,
9,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
646,
2680,
199,
199,
504,
330,
6558,
3389,
14,
3215,
492,
22838,
421,
199,
533,
10751,
13093,
774,
8,
2882,
14,
1746,
3461,
339,
347,
511,
63,
7191,
63,
576,
8,
291,
3461,
267,
408,
267,
5870,
511,
370,
1104,
340,
314,
5563,
5419,
367,
314,
267,
28586,
1930,
14,
267,
408,
267,
666,
275,
2680,
14,
4250,
8,
359,
1960,
12,
2948,
61,
776,
4960,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
2728,
666,
847,
709,
14,
267,
4353,
63,
890,
275,
3388,
10813,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
776,
398,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
17,
8429,
221,
3044,
1072,
3981,
17,
8429,
1275,
4587,
776,
2728,
291,
14,
1815,
8,
2011,
776,
339,
347,
511,
63,
2926,
548,
8,
291,
3461,
398,
666,
275,
2680,
14,
4250,
8,
359,
2948,
12,
1960,
1622,
776,
267,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
398,
327,
4155,
24113,
26365,
2153,
23079,
12,
2163,
17173,
3307,
267,
327,
8545,
267,
666,
847,
4119,
14,
267,
666,
59,
13785,
447,
18,
61,
275,
446,
845,
14,
16,
398,
4353,
63,
890,
275,
3388,
267,
3650,
63,
548,
275,
499,
7318,
327,
2670,
543,
282,
3650,
734,
402,
499,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
3650,
63,
548,
275,
3650,
63,
548,
776,
31106,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
2926,
63,
548,
8429,
221,
3044,
1072,
3981,
2926,
63,
548,
8429,
1275,
4587,
776,
10631,
291,
14,
1815,
8,
2011,
776,
398,
327,
2670,
543,
282,
3650,
734,
402,
413,
267,
3650,
63,
548,
275,
413,
267,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
3650,
63,
548,
275,
3650,
63,
548,
776,
31106,
327,
18414,
2127,
1077,
506,
4697,
267,
1104,
63,
576,
4862,
413,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
2926,
63,
548,
8429,
221,
3044,
1072,
3981,
2926,
63,
548,
8429,
1275,
4587,
776,
10631,
291,
14,
1815,
8,
2011,
776,
2378,
347,
511,
63,
1823,
8,
291,
3461,
398,
666,
275,
2680,
14,
4250,
8,
359,
2948,
12,
1960,
1622,
776,
267,
1104,
63,
576,
275,
666,
435,
413,
14,
16,
398,
327,
4155,
376,
2331,
701,
413,
22838,
626,
883,
506,
30156,
267,
327,
543,
17891,
267,
666,
10365,
845,
267,
666,
10345,
18,
12,
447,
18,
61,
275,
446,
845,
14,
267,
666,
59,
17,
447,
18,
12,
17,
447,
18,
61,
4022,
845,
398,
17891,
275,
499,
267,
4353,
63,
890,
275,
3388,
2728,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
3660,
17891,
29,
1823,
776,
10817,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
59,
3806,
63,
890,
15,
18,
13785,
17,
8429,
221,
3044,
1072,
59,
3806,
63,
890,
15,
18,
13785,
17,
8429,
9543,
15856,
614,
776,
398,
267,
291,
14,
1815,
8,
2011,
776,
2728,
327,
7719,
506,
4697,
543,
949,
17891,
267,
17891,
275,
378,
267,
4353,
63,
890,
275,
3388,
2728,
1072,
275,
22838,
8,
666,
12,
4353,
63,
890,
12,
2490,
17891,
29,
1823,
776,
819,
267,
1104,
63,
576,
3981,
17,
2938,
4862,
413,
14,
267,
2011,
275,
2680,
14,
7520,
8,
1104,
63,
576,
3981,
17,
8429,
221,
3044,
1072,
3981,
17,
8429,
1275,
4587,
776,
398,
291,
14,
1815,
8,
2011,
776,
268,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
5241,
275,
971,
489,
2882,
14,
15824,
1252,
26946,
8,
7467,
13093,
774,
9,
272,
2882,
14,
24285,
8,
9833,
29,
18,
680,
1065,
8,
5768,
9,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
bclau/nova
|
nova/tests/api/openstack/compute/test_urlmap.py
|
7
|
5225
|
# Copyright 2011 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.
import webob
from nova.openstack.common import jsonutils
from nova import test
from nova.tests.api.openstack import fakes
import nova.tests.image.fake
class UrlmapTest(test.NoDBTestCase):
def setUp(self):
super(UrlmapTest, self).setUp()
fakes.stub_out_rate_limiting(self.stubs)
nova.tests.image.fake.stub_out_image_service(self.stubs)
def tearDown(self):
super(UrlmapTest, self).tearDown()
nova.tests.image.fake.FakeImageService_reset()
def test_path_version_v1_1(self):
# Test URL path specifying v1.1 returns v2 content.
req = webob.Request.blank('/v1.1/')
req.accept = "application/json"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_content_type_version_v1_1(self):
# Test Content-Type specifying v1.1 returns v2 content.
req = webob.Request.blank('/')
req.content_type = "application/json;version=1.1"
req.accept = "application/json"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_accept_version_v1_1(self):
# Test Accept header specifying v1.1 returns v2 content.
req = webob.Request.blank('/')
req.accept = "application/json;version=1.1"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_path_version_v2(self):
# Test URL path specifying v2 returns v2 content.
req = webob.Request.blank('/v2/')
req.accept = "application/json"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_content_type_version_v2(self):
# Test Content-Type specifying v2 returns v2 content.
req = webob.Request.blank('/')
req.content_type = "application/json;version=2"
req.accept = "application/json"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_accept_version_v2(self):
# Test Accept header specifying v2 returns v2 content.
req = webob.Request.blank('/')
req.accept = "application/json;version=2"
res = req.get_response(fakes.wsgi_app(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.0')
def test_path_content_type(self):
# Test URL path specifying JSON returns JSON content.
url = '/v2/fake/images/cedef40a-ed67-4d10-800e-17455edce175.json'
req = webob.Request.blank(url)
req.accept = "application/xml"
res = req.get_response(fakes.wsgi_app(init_only=('images',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['image']['id'],
'cedef40a-ed67-4d10-800e-17455edce175')
def test_accept_content_type(self):
# Test Accept header specifying JSON returns JSON content.
url = '/v2/fake/images/cedef40a-ed67-4d10-800e-17455edce175'
req = webob.Request.blank(url)
req.accept = "application/xml;q=0.8, application/json"
res = req.get_response(fakes.wsgi_app(init_only=('images',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['image']['id'],
'cedef40a-ed67-4d10-800e-17455edce175')
|
apache-2.0
|
[
3,
1898,
7760,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
14568,
199,
199,
504,
5913,
14,
8512,
14,
2330,
492,
18705,
199,
504,
5913,
492,
511,
199,
504,
5913,
14,
2219,
14,
1246,
14,
8512,
492,
14063,
199,
646,
5913,
14,
2219,
14,
1569,
14,
3183,
421,
199,
533,
20503,
1130,
774,
8,
396,
14,
32437,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
6417,
1130,
774,
12,
291,
680,
5996,
342,
267,
14063,
14,
5811,
63,
548,
63,
1866,
63,
3097,
316,
8,
277,
14,
8957,
9,
267,
5913,
14,
2219,
14,
1569,
14,
3183,
14,
5811,
63,
548,
63,
1569,
63,
1364,
8,
277,
14,
8957,
9,
339,
347,
6766,
8,
277,
304,
267,
1613,
8,
6417,
1130,
774,
12,
291,
680,
12336,
342,
267,
5913,
14,
2219,
14,
1569,
14,
3183,
14,
8249,
3491,
3167,
63,
3958,
342,
339,
347,
511,
63,
515,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
2851,
931,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
2336,
86,
17,
14,
17,
6217,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
1317,
63,
466,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
6646,
13,
804,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
1317,
63,
466,
275,
298,
3578,
15,
1001,
27,
1023,
29,
17,
14,
17,
2,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
5694,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
15506,
1406,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
27,
1023,
29,
17,
14,
17,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
515,
63,
1023,
63,
86,
18,
8,
277,
304,
267,
327,
1379,
2851,
931,
9176,
373,
18,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
2336,
86,
18,
6217,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
1317,
63,
466,
63,
1023,
63,
86,
18,
8,
277,
304,
267,
327,
1379,
6646,
13,
804,
9176,
373,
18,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
1317,
63,
466,
275,
298,
3578,
15,
1001,
27,
1023,
29,
18,
2,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
5694,
63,
1023,
63,
86,
18,
8,
277,
304,
267,
327,
1379,
15506,
1406,
9176,
373,
18,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
27,
1023,
29,
18,
2,
267,
522,
275
] |
[
1898,
7760,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
14568,
199,
199,
504,
5913,
14,
8512,
14,
2330,
492,
18705,
199,
504,
5913,
492,
511,
199,
504,
5913,
14,
2219,
14,
1246,
14,
8512,
492,
14063,
199,
646,
5913,
14,
2219,
14,
1569,
14,
3183,
421,
199,
533,
20503,
1130,
774,
8,
396,
14,
32437,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
6417,
1130,
774,
12,
291,
680,
5996,
342,
267,
14063,
14,
5811,
63,
548,
63,
1866,
63,
3097,
316,
8,
277,
14,
8957,
9,
267,
5913,
14,
2219,
14,
1569,
14,
3183,
14,
5811,
63,
548,
63,
1569,
63,
1364,
8,
277,
14,
8957,
9,
339,
347,
6766,
8,
277,
304,
267,
1613,
8,
6417,
1130,
774,
12,
291,
680,
12336,
342,
267,
5913,
14,
2219,
14,
1569,
14,
3183,
14,
8249,
3491,
3167,
63,
3958,
342,
339,
347,
511,
63,
515,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
2851,
931,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
2336,
86,
17,
14,
17,
6217,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
1317,
63,
466,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
6646,
13,
804,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
1317,
63,
466,
275,
298,
3578,
15,
1001,
27,
1023,
29,
17,
14,
17,
2,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
5694,
63,
1023,
63,
86,
17,
63,
17,
8,
277,
304,
267,
327,
1379,
15506,
1406,
9176,
373,
17,
14,
17,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
27,
1023,
29,
17,
14,
17,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
515,
63,
1023,
63,
86,
18,
8,
277,
304,
267,
327,
1379,
2851,
931,
9176,
373,
18,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
2336,
86,
18,
6217,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
1317,
63,
466,
63,
1023,
63,
86,
18,
8,
277,
304,
267,
327,
1379,
6646,
13,
804,
9176,
373,
18,
2529,
373,
18,
1564,
14,
267,
2648,
275,
14568,
14,
2017,
14,
2500,
7825,
267,
2648,
14,
1317,
63,
466,
275,
298,
3578,
15,
1001,
27,
1023,
29,
18,
2,
267,
2648,
14,
5694,
275,
298,
3578,
15,
1001,
2,
267,
522,
275,
2648,
14,
362,
63,
1310,
8,
27443,
14,
6508,
63,
571,
8,
826,
63,
2118,
7782,
6234,
297,
1724,
267,
291,
14,
629,
8,
470,
14,
1205,
63,
442,
12,
1926,
9,
267,
291,
14,
629,
8,
470,
14,
1317,
63,
466,
12,
298,
3578,
15,
1001,
531,
267,
2396,
275,
18705,
14,
3640,
8,
470,
14,
2030,
9,
267,
291,
14,
629,
8,
2030,
459,
1023,
2545,
344,
995,
283,
86,
18,
14,
16,
358,
339,
347,
511,
63,
5694,
63,
1023,
63,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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
] |
40223201/40223201
|
wsgi.py
|
2
|
47682
|
#@+leo-ver=5-thin
#@+node:2014fall.20141212095015.1775: * @file wsgi.py
# coding=utf-8
# 上面的程式內容編碼必須在程式的第一或者第二行才會有作用
################# (1) 模組導入區
# 導入 cherrypy 模組, 為了在 OpenShift 平台上使用 cherrypy 模組, 必須透過 setup.py 安裝
#@@language python
#@@tabwidth -4
#@+<<declarations>>
#@+node:2014fall.20141212095015.1776: ** <<declarations>> (wsgi)
import cherrypy
# 導入 Python 內建的 os 模組, 因為 os 模組為 Python 內建, 所以無需透過 setup.py 安裝
import os
# 導入 random 模組
import random
# 導入 gear 模組
import gear
import man
################# (2) 廣域變數設定區
# 確定程式檔案所在目錄, 在 Windows 下有最後的反斜線
_curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
# 設定在雲端與近端的資料儲存目錄
if 'OPENSHIFT_REPO_DIR' in os.environ.keys():
# 表示程式在雲端執行
download_root_dir = os.environ['OPENSHIFT_DATA_DIR']
data_dir = os.environ['OPENSHIFT_DATA_DIR']
else:
# 表示程式在近端執行
download_root_dir = _curdir + "/local_data/"
data_dir = _curdir + "/local_data/"
'''以下為近端 input() 與 for 迴圈應用的程式碼, 若要將程式送到 OpenShift 執行, 除了採用 CherryPy 網際框架外, 還要轉為 html 列印
# 利用 input() 取得的資料型別為字串
toprint = input("要印甚麼內容?")
# 若要將 input() 取得的字串轉為整數使用, 必須利用 int() 轉換
repeat_no = int(input("重複列印幾次?"))
for i in range(repeat_no):
print(toprint)
'''
#@-<<declarations>>
#@+others
#@+node:2014fall.20141212095015.1777: ** class Hello
################# (3) 程式類別定義區
# 以下改用 CherryPy 網際框架程式架構
# 以下為 Hello 類別的設計內容, 其中的 object 使用, 表示 Hello 類別繼承 object 的所有特性, 包括方法與屬性設計
class Hello(object):
# Hello 類別的啟動設定
_cp_config = {
'tools.encode.encoding': 'utf-8',
'tools.sessions.on' : True,
'tools.sessions.storage_type' : 'file',
#'tools.sessions.locking' : 'explicit',
# session 以檔案儲存, 而且位於 data_dir 下的 tmp 目錄
'tools.sessions.storage_path' : data_dir+'/tmp',
# session 有效時間設為 60 分鐘
'tools.sessions.timeout' : 60
}
#@+others
#@+node:2014fall.20141212095015.2004: *3* __init__
def __init__(self):
# 配合透過案例啟始建立所需的目錄
if not os.path.isdir(data_dir+'/tmp'):
os.mkdir(data_dir+'/tmp')
if not os.path.isdir(data_dir+"/downloads"):
os.mkdir(data_dir+"/downloads")
if not os.path.isdir(data_dir+"/images"):
os.mkdir(data_dir+"/images")
#@+node:2014fall.20141212095015.1778: *3* index_orig
# 以 @ 開頭的 cherrypy.expose 為 decorator, 用來表示隨後的成員方法, 可以直接讓使用者以 URL 連結執行
@cherrypy.expose
# index 方法為 CherryPy 各類別成員方法中的內建(default)方法, 當使用者執行時未指定方法, 系統將會優先執行 index 方法
# 有 self 的方法為類別中的成員方法, Python 程式透過此一 self 在各成員方法間傳遞物件內容
def index_orig(self, toprint="Hello World!"):
return toprint
#@+node:2014fall.20141212095015.1779: *3* hello
@cherrypy.expose
def hello(self, toprint="Hello World!"):
return toprint
#@+node:2014fall.20141215194146.1791: *3* index
@cherrypy.expose
def index(self):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<h1>期末考練習1<br />
<br />40223201<br />
<br />吳佩盈<br />
<a href="drawspur">期末2nd個人齒輪嚙合</a> <br />
<a href="drawspur2">期末2nd協同齒輪嚙合</a> <br />
'''
return outstring
#@+node:2015.20150330144929.1713: *3* twoDgear
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def twoDgear(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<form method=POST action=do2Dgear>
齒數:<input type=text name=N><br />
模數:<input type=text name=M><br />
壓力角:<input type=text name=P><br />
<input type=submit value=send>
</form>
</body>
</html>
'''
return outstring
#@+node:2015.20150331094055.1733: *3* threeDgear
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def threeDgear(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<form method=POST action=do3Dgear>
齒數:<input type=text name=N><br />
模數:<input type=text name=M><br />
壓力角:<input type=text name=P><br />
<input type=submit value=send>
</form>
</body>
</html>
'''
return outstring
#@+node:2015.20150330144929.1762: *3* do2Dgear
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def do2Dgear(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
import math
# 畫布指定在名稱為 plotarea 的 canvas 上
canvas = document["plotarea"]
ctx = canvas.getContext("2d")
# 用紅色畫一條直線
ctx.beginPath()
ctx.lineWidth = 3
'''
outstring += '''
ctx.moveTo('''+str(N)+","+str(M)+")"
outstring += '''
ctx.lineTo(0, 500)
ctx.strokeStyle = "red"
ctx.stroke()
# 用藍色再畫一條直線
ctx.beginPath()
ctx.lineWidth = 3
ctx.moveTo(0, 0)
ctx.lineTo(500, 0)
ctx.strokeStyle = "blue"
ctx.stroke()
# 用綠色再畫一條直線
ctx.beginPath()
ctx.lineWidth = 3
ctx.moveTo(0, 0)
ctx.lineTo(500, 500)
ctx.strokeStyle = "green"
ctx.stroke()
# 用黑色畫一個圓
ctx.beginPath()
ctx.lineWidth = 3
ctx.strokeStyle = "black"
ctx.arc(250,250,50,0,2*math.pi)
ctx.stroke()
</script>
<canvas id="plotarea" width="800" height="600"></canvas>
</body>
</html>
'''
return outstring
#@+node:2015.20150331094055.1735: *3* do3Dgear
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def do3Dgear(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script type="text/javascript" src="/static/weblink/pfcUtils.js"></script>
<script type="text/javascript" src="/static/weblink/wl_header.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
# 從 javascript 導入 JSConstructor
from javascript import JSConstructor
import math
cango = JSConstructor(window.Cango2D)
if (!JSConstructor(window.pfcIsWindows())):
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
session = JSConstructor(window.pfcGetProESession())
# 設定 config option
session.SetConfigOption("comp_placement_assumptions","no")
# 建立擺放零件的位置矩陣
identityMatrix = JSConstructor(window.pfcCreate ("pfcMatrix3D"))
for x in range(4):
for y in range(4):
if (x == y):
JSConstructor(window.identityMatrix.Set (x, y, 1.0))
else:
JSConstructor(window.identityMatrix.Set (x, y, 0.0))
transf = JSConstructor(window.pfcCreate ("pfcTransform3D").Create (identityMatrix))
# 取得目前的工作目錄
currentDir = session.getCurrentDirectory()
# 以目前已開檔, 作為 model
model = session.CurrentModel
# 查驗有無 model, 或 model 類別是否為組立件
if (model == None or model.Type != JSConstructor(window.pfcCreate("pfcModelType").MDL_ASSEMBLY)):
raise ValueError("Current model is not an assembly.")
assembly = model
'''----------------------------------------------- link0 -------------------------------------------------------------'''
# 檔案目錄,建議將圖檔放置工作目錄下較方便使用
descr = rJSConstructor(window.pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link0.prt"))
#若 link1.prt 在 session 則直接取用
componentModel = session.GetModelFromDescr (descr)
# 若 link1.prt 不在 session 則從工作目錄中載入 session
componentModel = session.RetrieveModel(descr)
# 若 link1.prt 已經在 session 則放入組立檔中
if (componentModel != None):
# 注意這個 asmcomp 即為設定約束條件的本體
# asmcomp 為特徵物件,直接將零件, 以 transf 座標轉換放入組立檔案中
asmcomp = assembly.AssembleComponent (componentModel, transf)
# 建立約束條件變數
constrs = JSConstructor(window.pfcCreate ("pfcComponentConstraints"))
# 設定組立檔中的三個定位面, 注意內定名稱與 Pro/E WF 中的 ASM_D_FRONT 不同, 而是 ASM_FRONT
asmDatums = ["ASM_FRONT", "ASM_TOP", "ASM_RIGHT"]
# 設定零件檔中的三個定位面, 名稱與 Pro/E WF 中相同
compDatums = ["FRONT", "TOP", "RIGHT"]
# 建立 ids 變數, intseq 為 sequence of integers 為資料類別, 使用者可以經由整數索引擷取此資料類別的元件, 第一個索引為 0
ids = JSConstructor(window.pfcCreate ("intseq"))
# 建立路徑變數
path = JSConstructor(window.pfcCreate ("MpfcAssembly").CreateComponentPath (assembly, ids))
# 採用互動式設定相關的變數
MpfcSelect = JSConstructor(window.pfcCreate ("MpfcSelect"))
# 利用迴圈分別約束組立與零件檔中的三個定位平面
for i in range(3):
# 設定組立參考面
asmItem = assembly.GetItemByName (JSConstructor(window.pfcCreate ("pfcModelItemType").ITEM_SURFACE, asmDatums [i]))
# 若無對應的組立參考面, 則啟用互動式平面選擇表單 flag
if (asmItem == None):
interactFlag = true
continue
# 設定零件參考面
compItem = componentModel.GetItemByName (JSConstructor(window.pfcCreate ("pfcModelItemType").ITEM_SURFACE, compDatums [i])
# 若無對應的零件參考面, 則啟用互動式平面選擇表單 flag
if (compItem == None):
interactFlag = true
continue;
asmSel = JSConstructor(window.MpfcSelect.CreateModelItemSelection (asmItem, path))
compSel = JSConstructor(window.MpfcSelect.CreateModelItemSelection (compItem, None))
constr = JSConstructor(window.pfcCreate ("pfcComponentConstraint").Create (JSConstructor(window.pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN))
constr.AssemblyReference = asmSel
constr.ComponentReference = compSel
constr.Attributes = JSConstructor(window.pfcCreate ("pfcConstraintAttributes")).Create (false, false)
# 將互動選擇相關資料, 附加在程式約束變數之後
constrs.Append (constr)
# 設定組立約束條件
asmcomp.SetConstraints (constrs, None)
'''-------------------------------------------------------------------------------------------------------------------'''
'''----------------------------------------------- link1 -------------------------------------------------------------'''
descr = JSConstructor(window.pfcCreate ("pfcModelDescriptor")).CreateFromFileName ("v:/home/fourbar/link1.prt")
componentModel = session.GetModelFromDescr (descr)
componentModel = session.RetrieveModel(descr)
if (componentModel != None):
asmcomp = JSConstructor(window.assembly.AssembleComponent (componentModel, transf)
components = assembly.ListFeaturesByType(true, JSConstructor(window.pfcCreate ("pfcFeatureType")).FEATTYPE_COMPONENT);
featID = components.Item(0).Id
ids.append(featID)
subPath = JSConstructor(window.pfcCreate ("MpfcAssembly")).CreateComponentPath( assembly, ids )
subassembly = subPath.Leaf
asmDatums = ["A_1", "TOP", "ASM_TOP"]
compDatums = ["A_1", "TOP", "TOP"]
relation = (JSConstructor(window.pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN), JSConstructor(window.pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE);
relationItem = JSConstructor(window.pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE))
constrs = JSConstructor(window.pfcCreate ("pfcComponentConstraints"))
for i in range(2):
asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i])
if (asmItem == None):
interactFlag = True
continue
JSConstructor(window.compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]);
if (compItem == None):
interactFlag = true
continue
MpfcSelect = JSConstructor(window.pfcCreate ("MpfcSelect"))
asmSel = JSConstructor(window.MpfcSelect.CreateModelItemSelection (asmItem, subPath))
compSel = JSConstructor(window.MpfcSelect.CreateModelItemSelection (compItem, None))
constr = JSConstructor(window.pfcCreate("pfcComponentConstraint").Create (relation[i]))
constr.AssemblyReference = asmSel
constr.ComponentReference = compSel
constr.Attributes = JSConstructor(window.pfcCreate ("pfcConstraintAttributes").Create (true, false))
constrs.append (constr):
asmcomp.SetConstraints (constrs, None)
/**-------------------------------------------------------------------------------------------------------------------**/
/**----------------------------------------------- link2 -------------------------------------------------------------**/
var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link2.prt");
var componentModel = session.GetModelFromDescr (descr);
var componentModel = session.RetrieveModel(descr);
if (componentModel != void null)
{
var asmcomp = assembly.AssembleComponent (componentModel, transf);
}
var ids = pfcCreate ("intseq");
ids.Append(featID+1);
var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids );
subassembly = subPath.Leaf;
var asmDatums = new Array ("A_2", "TOP", "ASM_TOP");
var compDatums = new Array ("A_1", "TOP", "TOP");
var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE);
var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE);
var constrs = pfcCreate ("pfcComponentConstraints");
for (var i = 0; i < 2; i++)
{
var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]);
if (asmItem == void null)
{
interactFlag = true;
continue;
}
var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]);
if (compItem == void null)
{
interactFlag = true;
continue;
}
var MpfcSelect = pfcCreate ("MpfcSelect");
var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath);
var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null);
var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]);
constr.AssemblyReference = asmSel;
constr.ComponentReference = compSel;
constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, false);
constrs.Append (constr);
}
asmcomp.SetConstraints (constrs, void null);
/**-------------------------------------------------------------------------------------------------------------------**/
/**----------------------------------------------- link3 -------------------------------------------------------------**/
var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link3.prt");
var componentModel = session.GetModelFromDescr (descr);
var componentModel = session.RetrieveModel(descr);
if (componentModel != void null)
{
var asmcomp = assembly.AssembleComponent (componentModel, transf);
}
var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE);
var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE);
var constrs = pfcCreate ("pfcComponentConstraints");
var ids = pfcCreate ("intseq");
ids.Append(featID+2);
var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids );
subassembly = subPath.Leaf;
var asmDatums = new Array ("A_2");
var compDatums = new Array ("A_1");
for (var i = 0; i < 1; i++)
{
var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]);
if (asmItem == void null)
{
interactFlag = true;
continue;
}
var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]);
if (compItem == void null)
{
interactFlag = true;
continue;
}
var MpfcSelect = pfcCreate ("MpfcSelect");
var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath);
var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null);
var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]);
constr.AssemblyReference = asmSel;
constr.ComponentReference = compSel;
constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, false);
constrs.Append (constr);
}
asmcomp.SetConstraints (constrs, void null);
var ids = pfcCreate ("intseq");
ids.Append(featID);
var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids );
subassembly = subPath.Leaf;
var asmDatums = new Array ("A_2", "TOP");
var compDatums = new Array ("A_2", "BOTTON");
for (var i = 0; i < 2; i++)
{
var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]);
if (asmItem == void null)
{
interactFlag = true;
continue;
}
var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]);
if (compItem == void null)
{
interactFlag = true;
continue;
}
var MpfcSelect = pfcCreate ("MpfcSelect");
var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath);
var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null);
var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]);
constr.AssemblyReference = asmSel;
constr.ComponentReference = compSel;
constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, true);
constrs.Append (constr);
}
asmcomp.SetConstraints (constrs, void null);
/**-------------------------------------------------------------------------------------------------------------------**/
var session = pfcGetProESession ();
var solid = session.CurrentModel;
properties = solid.GetMassProperty(void null);
var COG = properties.GravityCenter;
document.write("MassProperty:<br />");
document.write("Mass:"+(properties.Mass.toFixed(2))+" pound<br />");
document.write("Average Density:"+(properties.Density.toFixed(2))+" pound/inch^3<br />");
document.write("Surface area:"+(properties.SurfaceArea.toFixed(2))+" inch^2<br />");
document.write("Volume:"+(properties.Volume.toFixed(2))+" inch^3<br />");
document.write("COG_X:"+COG.Item(0).toFixed(2)+"<br />");
document.write("COG_Y:"+COG.Item(1).toFixed(2)+"<br />");
document.write("COG_Z:"+COG.Item(2).toFixed(2)+"<br />");
try
{
document.write("Current Directory:<br />"+currentDir);
}
catch (err)
{
alert ("Exception occurred: "+pfcGetExceptionType (err));
}
assembly.Regenerate (void null);
session.GetModelWindow (assembly).Repaint();
</script>
<canvas id="plotarea" width="800" height="600"></canvas>
</body>
</html>
'''
return outstring
#@+node:2015.20150330144929.1765: *3* mygeartest
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def mygeartest(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
from math import *
# 準備在 id="plotarea" 的 canvas 中繪圖
canvas = document["plotarea"]
ctx = canvas.getContext("2d")
def create_line(x1, y1, x2, y2, width=3, fill="red"):
ctx.beginPath()
ctx.lineWidth = width
ctx.moveTo(x1, y1)
ctx.lineTo(x2, y2)
ctx.strokeStyle = fill
ctx.stroke()
# 導入數學函式後, 圓周率為 pi
# deg 為角度轉為徑度的轉換因子
deg = pi/180.
#
# 以下分別為正齒輪繪圖與主 tkinter 畫布繪圖
#
# 定義一個繪正齒輪的繪圖函式
# midx 為齒輪圓心 x 座標
# midy 為齒輪圓心 y 座標
# rp 為節圓半徑, n 為齒數
def 齒輪(midx, midy, rp, n, 顏色):
# 將角度轉換因子設為全域變數
global deg
# 齒輪漸開線分成 15 線段繪製
imax = 15
# 在輸入的畫布上繪製直線, 由圓心到節圓 y 軸頂點畫一直線
create_line(midx, midy, midx, midy-rp)
# 畫出 rp 圓, 畫圓函式尚未定義
#create_oval(midx-rp, midy-rp, midx+rp, midy+rp, width=2)
# a 為模數 (代表公制中齒的大小), 模數為節圓直徑(稱為節徑)除以齒數
# 模數也就是齒冠大小
a=2*rp/n
# d 為齒根大小, 為模數的 1.157 或 1.25倍, 這裡採 1.25 倍
d=2.5*rp/n
# ra 為齒輪的外圍半徑
ra=rp+a
print("ra:", ra)
# 畫出 ra 圓, 畫圓函式尚未定義
#create_oval(midx-ra, midy-ra, midx+ra, midy+ra, width=1)
# rb 則為齒輪的基圓半徑
# 基圓為漸開線長齒之基準圓
rb=rp*cos(20*deg)
print("rp:", rp)
print("rb:", rb)
# 畫出 rb 圓 (基圓), 畫圓函式尚未定義
#create_oval(midx-rb, midy-rb, midx+rb, midy+rb, width=1)
# rd 為齒根圓半徑
rd=rp-d
# 當 rd 大於 rb 時
print("rd:", rd)
# 畫出 rd 圓 (齒根圓), 畫圓函式尚未定義
#create_oval(midx-rd, midy-rd, midx+rd, midy+rd, width=1)
# dr 則為基圓到齒頂圓半徑分成 imax 段後的每段半徑增量大小
# 將圓弧分成 imax 段來繪製漸開線
dr=(ra-rb)/imax
# tan(20*deg)-20*deg 為漸開線函數
sigma=pi/(2*n)+tan(20*deg)-20*deg
for j in range(n):
ang=-2.*j*pi/n+sigma
ang2=2.*j*pi/n+sigma
lxd=midx+rd*sin(ang2-2.*pi/n)
lyd=midy-rd*cos(ang2-2.*pi/n)
#for(i=0;i<=imax;i++):
for i in range(imax+1):
r=rb+i*dr
theta=sqrt((r*r)/(rb*rb)-1.)
alpha=theta-atan(theta)
xpt=r*sin(alpha-ang)
ypt=r*cos(alpha-ang)
xd=rd*sin(-ang)
yd=rd*cos(-ang)
# i=0 時, 繪線起點由齒根圓上的點, 作為起點
if(i==0):
last_x = midx+xd
last_y = midy-yd
# 由左側齒根圓作為起點, 除第一點 (xd,yd) 齒根圓上的起點外, 其餘的 (xpt,ypt)則為漸開線上的分段點
create_line((midx+xpt),(midy-ypt),(last_x),(last_y),fill=顏色)
# 最後一點, 則為齒頂圓
if(i==imax):
lfx=midx+xpt
lfy=midy-ypt
last_x = midx+xpt
last_y = midy-ypt
# the line from last end of dedendum point to the recent
# end of dedendum point
# lxd 為齒根圓上的左側 x 座標, lyd 則為 y 座標
# 下列為齒根圓上用來近似圓弧的直線
create_line((lxd),(lyd),(midx+xd),(midy-yd),fill=顏色)
#for(i=0;i<=imax;i++):
for i in range(imax+1):
r=rb+i*dr
theta=sqrt((r*r)/(rb*rb)-1.)
alpha=theta-atan(theta)
xpt=r*sin(ang2-alpha)
ypt=r*cos(ang2-alpha)
xd=rd*sin(ang2)
yd=rd*cos(ang2)
# i=0 時, 繪線起點由齒根圓上的點, 作為起點
if(i==0):
last_x = midx+xd
last_y = midy-yd
# 由右側齒根圓作為起點, 除第一點 (xd,yd) 齒根圓上的起點外, 其餘的 (xpt,ypt)則為漸開線上的分段點
create_line((midx+xpt),(midy-ypt),(last_x),(last_y),fill=顏色)
# 最後一點, 則為齒頂圓
if(i==imax):
rfx=midx+xpt
rfy=midy-ypt
last_x = midx+xpt
last_y = midy-ypt
# lfx 為齒頂圓上的左側 x 座標, lfy 則為 y 座標
# 下列為齒頂圓上用來近似圓弧的直線
create_line(lfx,lfy,rfx,rfy,fill=顏色)
齒輪(400,400,300,41,"blue")
</script>
<canvas id="plotarea" width="800" height="800"></canvas>
</body>
</html>
'''
return outstring
#@+node:2015.20150621222226.1: *3* drawspur
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def drawspur(self, N=15,O=24, M=10, P=20):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<form method=POST action=mygeartest>
<p>齒數1:
<select name=N1>
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>24
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
<option>32
<option>33
<option>34
<option>35
<option>36
<option>37
<option>38
<option>39
<option>40
<option>41
<option>42
<option>43
<option>44
<option>45
<option>46
<option>47
<option>48
<option>49
<option>50
<option>51
<option>52
<option>53
<option>54
<option>55
<option>56
<option>57
<option>58
<option>59
<option>60
<option>61
<option>62
<option>63
<option>64
<option>65
<option>66
<option>67
<option>68
<option>69
<option>70
<option>71
<option>72
<option>73
<option>74
<option>75
<option>76
<option>77
<option>78
<option>79
<option>80
</select>
<p>齒數2:
<select name=N2>
<option>24
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
<option>32
<option>33
<option>34
<option>35
<option>36
<option>37
<option>38
<option>39
<option>40
<option>41
<option>42
<option>43
<option>44
<option>45
<option>46
<option>47
<option>48
<option>49
<option>50
<option>51
<option>52
<option>53
<option>54
<option>55
<option>56
<option>57
<option>58
<option>59
<option>60
<option>61
<option>62
<option>63
<option>64
<option>65
<option>66
<option>67
<option>68
<option>69
<option>70
<option>71
<option>72
<option>73
<option>74
<option>75
<option>76
<option>77
<option>78
<option>79
<option>80
</select>
<br />
<br />
<input type=submit value=畫出正齒輪輪廓>
</form>
<br /><a href="index">返回</a><br />
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script>
window.onload=function(){
brython();
}
</script>
</body>
</html>
'''
return outstring
#@+node:2015.20150628195251.1: *3* drawspur2
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def drawspur2(self, N=15,O=24, M=10, P=20):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<form method=POST action=mygeartest2>
<p>齒數1:
<select name=N1>
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>24
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
<option>32
<option>33
<option>34
<option>35
<option>36
<option>37
<option>38
<option>39
<option>40
<option>41
<option>42
<option>43
<option>44
<option>45
<option>46
<option>47
<option>48
<option>49
<option>50
<option>51
<option>52
<option>53
<option>54
<option>55
<option>56
<option>57
<option>58
<option>59
<option>60
<option>61
<option>62
<option>63
<option>64
<option>65
<option>66
<option>67
<option>68
<option>69
<option>70
<option>71
<option>72
<option>73
<option>74
<option>75
<option>76
<option>77
<option>78
<option>79
<option>80
</select>
<p>齒數2:
<select name=N2>
<option>24
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
<option>32
<option>33
<option>34
<option>35
<option>36
<option>37
<option>38
<option>39
<option>40
<option>41
<option>42
<option>43
<option>44
<option>45
<option>46
<option>47
<option>48
<option>49
<option>50
<option>51
<option>52
<option>53
<option>54
<option>55
<option>56
<option>57
<option>58
<option>59
<option>60
<option>61
<option>62
<option>63
<option>64
<option>65
<option>66
<option>67
<option>68
<option>69
<option>70
<option>71
<option>72
<option>73
<option>74
<option>75
<option>76
<option>77
<option>78
<option>79
<option>80
</select>
<br />
<br />
<input type=submit value=畫出正齒輪輪廓>
</form>
<br /><a href="index">返回</a><br />
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script>
window.onload=function(){
brython();
}
</script>
</body>
</html>
'''
return outstring
#@+node:amd.20150415215023.1: *3* mygeartest
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def mygeartest(self, N1=15,N2=24 ,M=10, P=20):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<a href="index">返回</a><br />
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
from math import *
# 請注意, 這裡導入位於 Lib/site-packages 目錄下的 spur.py 檔案
import spur
# 準備在 id="plotarea" 的 canvas 中繪圖
canvas = document["plotarea"]
ctx = canvas.getContext("2d")
# 以下利用 spur.py 程式進行繪圖
# N 為齒數
# 第1齒輪齒數
n_g1 = '''+str(N1)+'''
# 第2齒輪齒數
n_g2='''+str(N2)+'''
# M 為模數
m = 10
# 壓力角 P 單位為角度
pa = 20
# 計算兩齒輪的節圓半徑
rp_g1 = m*n_g1/2
rp_g2 = m*n_g2/2
# 繪圖第1齒輪的圓心座標
x_g1 = 450
y_g1 = 400
# 第2齒輪的圓心座標, 假設排列成水平, 表示各齒輪圓心 y 座標相同
x_g2 = x_g1
y_g2 = y_g1 + rp_g1 + rp_g2
tran1 = pi
tran2 = -pi/n_g2
# 將第1齒輪順時鐘轉 180 度
# 使用 ctx.save() 與 ctx.restore() 以確保各齒輪以相對座標進行旋轉繪圖
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g1, y_g1)
# rotate to engage
ctx.rotate(tran1)
# put it back
ctx.translate(-x_g1, -y_g1)
spur.Spur(ctx).Gear(x_g1, y_g1, rp_g1, n_g1, pa, "blue")
ctx.restore()
ctx.font = "20px Verdana";
# 將第2齒輪逆時鐘多轉一齒, 以便與第1齒輪進行囓合
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g2, y_g2)
# rotate to engage
ctx.rotate(tran2)
# put it back
ctx.translate(-x_g2, -y_g2)
spur.Spur(ctx).Gear(x_g2, y_g2, rp_g2, n_g2, pa, "black")
ctx.restore()
ctx.font = "20px Verdana";
</script>
<canvas id="plotarea" width="3500" height="3500"></canvas>
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script>
window.onload=function(){
brython();
}
</script>
</body>
</html>
'''
return outstring
#@+node:2015.20150628193459.1: *3* mygeartest2
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def mygeartest2(self, N1=15,N2=24 ,M=10, P=20):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<a href="index">index</a><br />
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
from math import *
# 請注意, 這裡導入位於 Lib/site-packages 目錄下的 spur.py 檔案
import spur
# 準備在 id="plotarea" 的 canvas 中繪圖
canvas = document["plotarea"]
ctx = canvas.getContext("2d")
# 以下利用 spur.py 程式進行繪圖
# N 為齒數
# 第1齒輪齒數
n_g1 = '''+str(N1)+'''
# 第2齒輪齒數
n_g2='''+str(N2)+'''
# 第3齒輪齒數
n_g3 = '''+str(N1)+'''
# 第4齒輪齒數
n_g4='''+str(N2)+'''
# M 為模數
m = 10
# 壓力角 P 單位為角度
pa = 20
# 計算兩齒輪的節圓半徑
rp_g1 = m*n_g1/2
rp_g2 = m*n_g2/2
rp_g3 = m*n_g3/2
rp_g4 = m*n_g4/2
# 繪圖第1齒輪的圓心座標
x_g1 = 400
y_g1 = 400
# 第2齒輪的圓心座標, 假設排列成水平, 表示各齒輪圓心 y 座標相同
x_g2 = x_g1
y_g2 = y_g1 + rp_g1 + rp_g2
# 第3齒輪的圓心座標
x_g3 = x_g2 + rp_g2+ rp_g3
y_g3 = y_g2
# 第4齒輪的圓心座標
x_g4 = x_g3
y_g4 = y_g3+ rp_g3+ rp_g4
tran1 = pi
tran2 = -pi/n_g2
tran3 = -pi/2-pi/n_g3+(pi/2+pi/n_g2)*n_g2/n_g3
tran4 = -pi/n_g4+(-pi/2+pi/n_g3)*n_g3/n_g4-(pi/2+pi/n_g2)*n_g2/n_g4
# 將第1齒輪順時鐘轉 180 度
# 使用 ctx.save() 與 ctx.restore() 以確保各齒輪以相對座標進行旋轉繪圖
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g1, y_g1)
# rotate to engage
ctx.rotate(tran1)
# put it back
ctx.translate(-x_g1, -y_g1)
spur.Spur(ctx).Gear(x_g1, y_g1, rp_g1, n_g1, pa, "blue")
ctx.restore()
# 將第2齒輪逆時鐘多轉一齒, 以便與第1齒輪進行囓合
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g2, y_g2)
# rotate to engage
ctx.rotate(tran2)
# put it back
ctx.translate(-x_g2, -y_g2)
spur.Spur(ctx).Gear(x_g2, y_g2, rp_g2, n_g2, pa, "red")
ctx.restore()
# 將第3齒輪
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g3, y_g3)
# rotate to engage
ctx.rotate(tran3)
# put it back
ctx.translate(-x_g3, -y_g3)
spur.Spur(ctx).Gear(x_g3, y_g3, rp_g3, n_g3, pa, "blue")
ctx.restore()
# 將第4齒輪
ctx.save()
# translate to the origin of second gear
ctx.translate(x_g4, y_g4)
# rotate to engage
ctx.rotate(tran4)
# put it back
ctx.translate(-x_g4, -y_g4)
spur.Spur(ctx).Gear(x_g4, y_g4, rp_g4, n_g4, pa, "red")
ctx.restore()
</script>
<canvas id="plotarea" width="3000" height="3000"></canvas>
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script>
window.onload=function(){
brython();
}
</script>
</body>
</html>
'''
return outstring
#@+node:2015.20150331094055.1737: *3* my3Dgeartest
@cherrypy.expose
# N 為齒數, M 為模數, P 為壓力角
def my3Dgeartest(self, N=20, M=5, P=15):
outstring = '''
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!-- 載入 brython.js -->
<script type="text/javascript" src="/static/Brython3.1.1-20150328-091302/brython.js"></script>
<script src="/static/Cango2D.js" type="text/javascript"></script>
<script src="/static/gearUtils-04.js" type="text/javascript"></script>
</head>
<!-- 啟動 brython() -->
<body onload="brython()">
<!-- 以下為 canvas 畫圖程式 -->
<script type="text/python">
# 從 browser 導入 document
from browser import document
from math import *
# 準備在 id="plotarea" 的 canvas 中繪圖
canvas = document["plotarea"]
ctx = canvas.getContext("2d")
def create_line(x1, y1, x2, y2, width=3, fill="red"):
ctx.beginPath()
ctx.lineWidth = width
ctx.moveTo(x1, y1)
ctx.lineTo(x2, y2)
ctx.strokeStyle = fill
ctx.stroke()
# 導入數學函式後, 圓周率為 pi
# deg 為角度轉為徑度的轉換因子
deg = pi/180.
#
# 以下分別為正齒輪繪圖與主 tkinter 畫布繪圖
#
# 定義一個繪正齒輪的繪圖函式
# midx 為齒輪圓心 x 座標
# midy 為齒輪圓心 y 座標
# rp 為節圓半徑, n 為齒數
def gear(midx, midy, rp, n, 顏色):
# 將角度轉換因子設為全域變數
global deg
# 齒輪漸開線分成 15 線段繪製
imax = 15
# 在輸入的畫布上繪製直線, 由圓心到節圓 y 軸頂點畫一直線
create_line(midx, midy, midx, midy-rp)
# 畫出 rp 圓, 畫圓函式尚未定義
#create_oval(midx-rp, midy-rp, midx+rp, midy+rp, width=2)
# a 為模數 (代表公制中齒的大小), 模數為節圓直徑(稱為節徑)除以齒數
# 模數也就是齒冠大小
a=2*rp/n
# d 為齒根大小, 為模數的 1.157 或 1.25倍, 這裡採 1.25 倍
d=2.5*rp/n
# ra 為齒輪的外圍半徑
ra=rp+a
print("ra:", ra)
# 畫出 ra 圓, 畫圓函式尚未定義
#create_oval(midx-ra, midy-ra, midx+ra, midy+ra, width=1)
# rb 則為齒輪的基圓半徑
# 基圓為漸開線長齒之基準圓
rb=rp*cos(20*deg)
print("rp:", rp)
print("rb:", rb)
# 畫出 rb 圓 (基圓), 畫圓函式尚未定義
#create_oval(midx-rb, midy-rb, midx+rb, midy+rb, width=1)
# rd 為齒根圓半徑
rd=rp-d
# 當 rd 大於 rb 時
print("rd:", rd)
# 畫出 rd 圓 (齒根圓), 畫圓函式尚未定義
#create_oval(midx-rd, midy-rd, midx+rd, midy+rd, width=1)
# dr 則為基圓到齒頂圓半徑分成 imax 段後的每段半徑增量大小
# 將圓弧分成 imax 段來繪製漸開線
dr=(ra-rb)/imax
# tan(20*deg)-20*deg 為漸開線函數
sigma=pi/(2*n)+tan(20*deg)-20*deg
for j in range(n):
ang=-2.*j*pi/n+sigma
ang2=2.*j*pi/n+sigma
lxd=midx+rd*sin(ang2-2.*pi/n)
lyd=midy-rd*cos(ang2-2.*pi/n)
#for(i=0;i<=imax;i++):
for i in range(imax+1):
r=rb+i*dr
theta=sqrt((r*r)/(rb*rb)-1.)
alpha=theta-atan(theta)
xpt=r*sin(alpha-ang)
ypt=r*cos(alpha-ang)
xd=rd*sin(-ang)
yd=rd*cos(-ang)
# i=0 時, 繪線起點由齒根圓上的點, 作為起點
if(i==0):
last_x = midx+xd
last_y = midy-yd
# 由左側齒根圓作為起點, 除第一點 (xd,yd) 齒根圓上的起點外, 其餘的 (xpt,ypt)則為漸開線上的分段點
create_line((midx+xpt),(midy-ypt),(last_x),(last_y),fill=顏色)
# 最後一點, 則為齒頂圓
if(i==imax):
lfx=midx+xpt
lfy=midy-ypt
last_x = midx+xpt
last_y = midy-ypt
# the line from last end of dedendum point to the recent
# end of dedendum point
# lxd 為齒根圓上的左側 x 座標, lyd 則為 y 座標
# 下列為齒根圓上用來近似圓弧的直線
create_line((lxd),(lyd),(midx+xd),(midy-yd),fill=顏色)
#for(i=0;i<=imax;i++):
for i in range(imax+1):
r=rb+i*dr
theta=sqrt((r*r)/(rb*rb)-1.)
alpha=theta-atan(theta)
xpt=r*sin(ang2-alpha)
ypt=r*cos(ang2-alpha)
xd=rd*sin(ang2)
yd=rd*cos(ang2)
# i=0 時, 繪線起點由齒根圓上的點, 作為起點
if(i==0):
last_x = midx+xd
last_y = midy-yd
# 由右側齒根圓作為起點, 除第一點 (xd,yd) 齒根圓上的起點外, 其餘的 (xpt,ypt)則為漸開線上的分段點
create_line((midx+xpt),(midy-ypt),(last_x),(last_y),fill=顏色)
# 最後一點, 則為齒頂圓
if(i==imax):
rfx=midx+xpt
rfy=midy-ypt
last_x = midx+xpt
last_y = midy-ypt
# lfx 為齒頂圓上的左側 x 座標, lfy 則為 y 座標
# 下列為齒頂圓上用來近似圓弧的直線
create_line(lfx,lfy,rfx,rfy,fill=顏色)
gear(400,400,300,41,"blue")
</script>
<canvas id="plotarea" width="800" height="800"></canvas>
</body>
</html>
'''
return outstring
#@+node:2014fall.20141215194146.1793: *3* doCheck
@cherrypy.expose
def doCheck(self, guess=None):
# 假如使用者直接執行 doCheck, 則設法轉回根方法
if guess is None:
raise cherrypy.HTTPRedirect("/")
# 從 session 取出 answer 對應資料, 且處理直接執行 doCheck 時無法取 session 值情況
try:
theanswer = int(cherrypy.session.get('answer'))
except:
raise cherrypy.HTTPRedirect("/")
# 經由表單所取得的 guess 資料型別為 string
try:
theguess = int(guess)
except:
return "error " + self.guessform()
# 每執行 doCheck 一次,次數增量一次
cherrypy.session['count'] += 1
# 答案與所猜數字進行比對
if theanswer < theguess:
return "big " + self.guessform()
elif theanswer > theguess:
return "small " + self.guessform()
else:
# 已經猜對, 從 session 取出累計猜測次數
thecount = cherrypy.session.get('count')
return "exact: <a href=''>再猜</a>"
#@+node:2014fall.20141215194146.1789: *3* guessform
def guessform(self):
# 印出讓使用者輸入的超文件表單
outstring = str(cherrypy.session.get('answer')) + "/" + str(cherrypy.session.get('count')) + '''<form method=POST action=doCheck>
請輸入您所猜的整數:<input type=text name=guess><br />
<input type=submit value=send>
</form>'''
return outstring
#@-others
#@-others
################# (4) 程式啟動區
# 配合程式檔案所在目錄設定靜態目錄或靜態檔案
application_conf = {'/static':{
'tools.staticdir.on': True,
# 程式執行目錄下, 必須自行建立 static 目錄
'tools.staticdir.dir': _curdir+"/static"},
'/downloads':{
'tools.staticdir.on': True,
'tools.staticdir.dir': data_dir+"/downloads"},
'/images':{
'tools.staticdir.on': True,
'tools.staticdir.dir': data_dir+"/images"}
}
root = Hello()
root.gear = gear.Gear()
root.man = man.MAN()
cherrypy.server.socket_port = 8088
cherrypy.server.socket_host = '127.0.0.1'
if 'OPENSHIFT_REPO_DIR' in os.environ.keys():
# 表示在 OpenSfhit 執行
application = cherrypy.Application(root, config=application_conf)
else:
# 表示在近端執行
cherrypy.quickstart(root, config=application_conf)
#@-leo
|
gpl-3.0
|
[
17577,
11,
274,
79,
13,
422,
29,
21,
13,
24474,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
21,
26,
627,
768,
493,
12464,
14,
647,
199,
3,
2803,
29,
1624,
13,
24,
199,
3,
221,
22661,
26398,
96,
8106,
30664,
21041,
8379,
101,
10270,
118,
27035,
102,
164,
96,
121,
16989,
228,
166,
255,
231,
21448,
30664,
21041,
8106,
25238,
106,
9372,
9077,
245,
18497,
25238,
106,
6923,
235,
12609,
10862,
236,
6587,
226,
20916,
21927,
11428,
199,
199,
749,
3,
334,
17,
9,
8853,
102,
95,
23767,
227,
15348,
237,
18236,
10450,
223,
199,
3,
7094,
109,
237,
18236,
13397,
8853,
102,
95,
23767,
227,
12,
9112,
18760,
30998,
21448,
3232,
14379,
7094,
118,
112,
6075,
109,
22661,
30026,
13397,
8853,
102,
95,
23767,
227,
12,
7094,
124,
228,
166,
255,
231,
14333,
238,
24744,
237,
3272,
14,
647,
7094,
107,
232,
29655,
252,
421,
199,
3,
7492,
3671,
2366,
199,
3,
7492,
2902,
2063,
446,
20,
199,
199,
17577,
11,
8999,
21200,
1140,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
22,
26,
1011,
5213,
21200,
1140,
334,
6508,
9,
199,
646,
13397,
199,
3,
7094,
109,
237,
18236,
2018,
7094,
228,
101,
29427,
119,
8106,
747,
8853,
102,
95,
23767,
227,
12,
7094,
250,
255,
24889,
747,
8853,
102,
95,
23767,
227,
24889,
2018,
7094,
228,
101,
29427,
119,
12,
8853,
232,
223,
23681,
164,
227,
95,
166,
251,
223,
14333,
238,
24744,
237,
3272,
14,
647,
7094,
107,
232,
29655,
252,
199,
646,
747,
199,
3,
7094,
109,
237,
18236,
2196,
8853,
102,
95,
23767,
227,
199,
646,
2196,
199,
3,
7094,
109,
237,
18236,
2312,
285,
8853,
102,
95,
23767,
227,
199,
646,
2312,
285,
199,
646,
2169,
199,
199,
749,
3,
334,
18,
9,
7094,
120,
97,
25056,
254,
14082,
233,
24814,
20278,
256,
20766,
10450,
223,
199,
3,
9112,
96,
119,
20766,
30664,
21041,
163,
104,
243,
31333,
231,
16570,
21448,
31869,
166,
235,
227,
12,
7094,
251,
102,
5417,
221,
24233,
20916,
23112,
19073,
235,
8106,
6075,
236,
10310,
251,
27035,
249,
199,
63,
15594,
275,
747,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
747,
14,
515,
14,
3475,
3460,
493,
8964,
199,
3,
9065,
102,
256,
20766,
21448,
22982,
111,
21341,
108,
165,
231,
230,
13201,
240,
21341,
108,
8106,
29273,
230,
10310,
248,
162,
227,
111,
29846,
31869,
166,
235,
227,
199,
692,
283,
9935,
18013,
63,
20424,
63,
3022,
7,
315,
747,
14,
2314,
14,
1612,
837,
272,
327,
9065,
95,
102,
29875,
119,
30664,
21041,
21448,
22982,
111,
21341,
108,
25056,
116,
12609,
272,
5235,
63,
1231,
63,
694,
275,
747,
14,
2314,
459,
9935,
18013,
63,
3998,
63,
3022,
418,
272,
666,
63,
694,
275,
747,
14,
2314,
459,
9935,
18013,
63,
3998,
63,
3022,
418,
199,
2836,
26,
272,
327,
9065,
95,
102,
29875,
119,
30664,
21041,
21448,
13201,
240,
21341,
108,
25056,
116,
12609,
272,
5235,
63,
1231,
63,
694,
275,
485,
15594,
435,
3286,
1832,
63,
576,
6687,
272,
666,
63,
694,
275,
485,
15594,
435,
3286,
1832,
63,
576,
6687,
199,
199,
2344,
23681,
24233,
24889,
13201,
240,
21341,
108,
1324,
342,
9065,
231,
230,
367,
9065,
124,
113,
11987,
231,
163,
230,
232,
11428,
8106,
30664,
21041,
164,
96,
121,
12,
9065,
234,
99,
22274,
15348,
230,
30664,
21041,
14333,
224,
29507,
3232,
14379,
7094,
254,
116,
12609,
12,
10469,
248,
98,
30998,
17797,
95,
11428,
30992,
27794,
9112,
115,
111,
166,
249,
250,
31333,
229,
19349,
115,
11546,
245,
12,
10469,
225,
227,
22274,
19182,
232,
24889,
3517,
7094,
231,
246,
10450,
109,
199,
3,
7094,
231,
103,
11428,
1324,
342,
221,
22924,
19073,
246,
8106,
29273,
230,
10310,
248,
162,
9809,
9051,
99,
24889,
26032,
4344,
111,
199,
2119,
672,
275,
1324,
480,
22274,
10450,
109,
8383,
249,
166,
119,
121,
8379,
101,
10270,
118,
18582,
199,
3,
9065,
234,
99,
22274,
15348,
230,
1324,
342,
221,
22924,
19073,
246,
8106,
26032,
4344,
111,
19182,
232,
24889,
9221,
113,
24814,
30026,
12,
7094,
124,
228,
166,
255,
231,
9051,
103,
11428,
1109,
342,
9065,
122,
232,
22843,
250,
199,
8755,
63,
889,
275,
1109,
8,
1210,
480,
10770,
236,
165,
98,
230,
32551,
10450,
109,
16322,
123,
30493,
31,
2237,
199,
509,
284,
315,
1425,
8,
8755,
63,
889,
304,
272,
870,
8,
2119,
672,
9,
199,
2344,
199,
17577,
13,
8999,
21200,
1140,
199,
17577,
11,
21714,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
23,
26,
1011,
1021,
23833,
199,
749,
3,
334,
19,
9,
9112,
102,
234,
21041,
27513,
253,
9051,
99,
20766,
164,
123,
103,
10450,
223,
199,
3,
221,
23681,
24233,
17130,
118,
11428,
30992,
27794,
9112,
115,
111,
166,
249,
250,
31333,
229,
19349,
115,
30664,
21041,
19349,
115,
163,
101,
234,
199,
3,
221,
23681,
24233,
24889,
23833,
10469,
95,
253,
9051,
99,
8106,
20278,
256,
20278,
231,
8379,
101,
10270,
118,
12,
7094,
228,
115,
17088,
8106,
909,
221,
30026,
12,
9065,
95,
102,
29875,
119,
23833,
10469,
95,
253,
9051,
99,
164,
118,
121,
10862,
124,
909,
221,
8106,
16570,
20916,
19431,
118,
17182,
101,
12,
7094,
235,
228,
163,
234,
106,
24302,
27397,
165,
231,
230,
27289,
106,
17182,
101,
20278,
256,
20278,
231,
199,
533,
23833,
8,
785,
304,
339,
327,
23833,
10469,
95,
253,
9051,
99,
8106,
29548,
254,
162,
234,
244,
20278,
256,
20766,
272,
485,
1850,
63,
888,
275,
469,
272,
283,
2537,
14,
2143,
14,
2991,
356,
283,
1624,
13,
24,
297,
272,
283,
2537,
14,
11676,
14,
265,
7,
520,
715,
12,
272,
283,
2537,
14,
11676,
14,
3494,
63,
466,
7,
520,
283,
493,
297,
272,
17384,
2537,
14,
11676,
14,
24056,
7,
520,
283,
10306,
297,
272,
327,
2351,
221,
23681,
163,
104,
243,
31333,
231,
162,
227,
111,
29846,
12,
9065,
223,
235,
4344,
243,
30555,
10310,
121,
666,
63,
694,
221,
24233,
8106,
3529,
9112,
250,
107,
166,
235,
227,
272,
283,
2537,
14,
11676,
14,
3494,
63,
515,
7,
520,
666,
63,
694,
23164,
2791,
297
] |
[
11,
274,
79,
13,
422,
29,
21,
13,
24474,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
21,
26,
627,
768,
493,
12464,
14,
647,
199,
3,
2803,
29,
1624,
13,
24,
199,
3,
221,
22661,
26398,
96,
8106,
30664,
21041,
8379,
101,
10270,
118,
27035,
102,
164,
96,
121,
16989,
228,
166,
255,
231,
21448,
30664,
21041,
8106,
25238,
106,
9372,
9077,
245,
18497,
25238,
106,
6923,
235,
12609,
10862,
236,
6587,
226,
20916,
21927,
11428,
199,
199,
749,
3,
334,
17,
9,
8853,
102,
95,
23767,
227,
15348,
237,
18236,
10450,
223,
199,
3,
7094,
109,
237,
18236,
13397,
8853,
102,
95,
23767,
227,
12,
9112,
18760,
30998,
21448,
3232,
14379,
7094,
118,
112,
6075,
109,
22661,
30026,
13397,
8853,
102,
95,
23767,
227,
12,
7094,
124,
228,
166,
255,
231,
14333,
238,
24744,
237,
3272,
14,
647,
7094,
107,
232,
29655,
252,
421,
199,
3,
7492,
3671,
2366,
199,
3,
7492,
2902,
2063,
446,
20,
199,
199,
17577,
11,
8999,
21200,
1140,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
22,
26,
1011,
5213,
21200,
1140,
334,
6508,
9,
199,
646,
13397,
199,
3,
7094,
109,
237,
18236,
2018,
7094,
228,
101,
29427,
119,
8106,
747,
8853,
102,
95,
23767,
227,
12,
7094,
250,
255,
24889,
747,
8853,
102,
95,
23767,
227,
24889,
2018,
7094,
228,
101,
29427,
119,
12,
8853,
232,
223,
23681,
164,
227,
95,
166,
251,
223,
14333,
238,
24744,
237,
3272,
14,
647,
7094,
107,
232,
29655,
252,
199,
646,
747,
199,
3,
7094,
109,
237,
18236,
2196,
8853,
102,
95,
23767,
227,
199,
646,
2196,
199,
3,
7094,
109,
237,
18236,
2312,
285,
8853,
102,
95,
23767,
227,
199,
646,
2312,
285,
199,
646,
2169,
199,
199,
749,
3,
334,
18,
9,
7094,
120,
97,
25056,
254,
14082,
233,
24814,
20278,
256,
20766,
10450,
223,
199,
3,
9112,
96,
119,
20766,
30664,
21041,
163,
104,
243,
31333,
231,
16570,
21448,
31869,
166,
235,
227,
12,
7094,
251,
102,
5417,
221,
24233,
20916,
23112,
19073,
235,
8106,
6075,
236,
10310,
251,
27035,
249,
199,
63,
15594,
275,
747,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
747,
14,
515,
14,
3475,
3460,
493,
8964,
199,
3,
9065,
102,
256,
20766,
21448,
22982,
111,
21341,
108,
165,
231,
230,
13201,
240,
21341,
108,
8106,
29273,
230,
10310,
248,
162,
227,
111,
29846,
31869,
166,
235,
227,
199,
692,
283,
9935,
18013,
63,
20424,
63,
3022,
7,
315,
747,
14,
2314,
14,
1612,
837,
272,
327,
9065,
95,
102,
29875,
119,
30664,
21041,
21448,
22982,
111,
21341,
108,
25056,
116,
12609,
272,
5235,
63,
1231,
63,
694,
275,
747,
14,
2314,
459,
9935,
18013,
63,
3998,
63,
3022,
418,
272,
666,
63,
694,
275,
747,
14,
2314,
459,
9935,
18013,
63,
3998,
63,
3022,
418,
199,
2836,
26,
272,
327,
9065,
95,
102,
29875,
119,
30664,
21041,
21448,
13201,
240,
21341,
108,
25056,
116,
12609,
272,
5235,
63,
1231,
63,
694,
275,
485,
15594,
435,
3286,
1832,
63,
576,
6687,
272,
666,
63,
694,
275,
485,
15594,
435,
3286,
1832,
63,
576,
6687,
199,
199,
2344,
23681,
24233,
24889,
13201,
240,
21341,
108,
1324,
342,
9065,
231,
230,
367,
9065,
124,
113,
11987,
231,
163,
230,
232,
11428,
8106,
30664,
21041,
164,
96,
121,
12,
9065,
234,
99,
22274,
15348,
230,
30664,
21041,
14333,
224,
29507,
3232,
14379,
7094,
254,
116,
12609,
12,
10469,
248,
98,
30998,
17797,
95,
11428,
30992,
27794,
9112,
115,
111,
166,
249,
250,
31333,
229,
19349,
115,
11546,
245,
12,
10469,
225,
227,
22274,
19182,
232,
24889,
3517,
7094,
231,
246,
10450,
109,
199,
3,
7094,
231,
103,
11428,
1324,
342,
221,
22924,
19073,
246,
8106,
29273,
230,
10310,
248,
162,
9809,
9051,
99,
24889,
26032,
4344,
111,
199,
2119,
672,
275,
1324,
480,
22274,
10450,
109,
8383,
249,
166,
119,
121,
8379,
101,
10270,
118,
18582,
199,
3,
9065,
234,
99,
22274,
15348,
230,
1324,
342,
221,
22924,
19073,
246,
8106,
26032,
4344,
111,
19182,
232,
24889,
9221,
113,
24814,
30026,
12,
7094,
124,
228,
166,
255,
231,
9051,
103,
11428,
1109,
342,
9065,
122,
232,
22843,
250,
199,
8755,
63,
889,
275,
1109,
8,
1210,
480,
10770,
236,
165,
98,
230,
32551,
10450,
109,
16322,
123,
30493,
31,
2237,
199,
509,
284,
315,
1425,
8,
8755,
63,
889,
304,
272,
870,
8,
2119,
672,
9,
199,
2344,
199,
17577,
13,
8999,
21200,
1140,
199,
17577,
11,
21714,
199,
17577,
11,
932,
26,
7280,
70,
452,
14,
7280,
25481,
1643,
8216,
21,
14,
8881,
23,
26,
1011,
1021,
23833,
199,
749,
3,
334,
19,
9,
9112,
102,
234,
21041,
27513,
253,
9051,
99,
20766,
164,
123,
103,
10450,
223,
199,
3,
221,
23681,
24233,
17130,
118,
11428,
30992,
27794,
9112,
115,
111,
166,
249,
250,
31333,
229,
19349,
115,
30664,
21041,
19349,
115,
163,
101,
234,
199,
3,
221,
23681,
24233,
24889,
23833,
10469,
95,
253,
9051,
99,
8106,
20278,
256,
20278,
231,
8379,
101,
10270,
118,
12,
7094,
228,
115,
17088,
8106,
909,
221,
30026,
12,
9065,
95,
102,
29875,
119,
23833,
10469,
95,
253,
9051,
99,
164,
118,
121,
10862,
124,
909,
221,
8106,
16570,
20916,
19431,
118,
17182,
101,
12,
7094,
235,
228,
163,
234,
106,
24302,
27397,
165,
231,
230,
27289,
106,
17182,
101,
20278,
256,
20278,
231,
199,
533,
23833,
8,
785,
304,
339,
327,
23833,
10469,
95,
253,
9051,
99,
8106,
29548,
254,
162,
234,
244,
20278,
256,
20766,
272,
485,
1850,
63,
888,
275,
469,
272,
283,
2537,
14,
2143,
14,
2991,
356,
283,
1624,
13,
24,
297,
272,
283,
2537,
14,
11676,
14,
265,
7,
520,
715,
12,
272,
283,
2537,
14,
11676,
14,
3494,
63,
466,
7,
520,
283,
493,
297,
272,
17384,
2537,
14,
11676,
14,
24056,
7,
520,
283,
10306,
297,
272,
327,
2351,
221,
23681,
163,
104,
243,
31333,
231,
162,
227,
111,
29846,
12,
9065,
223,
235,
4344,
243,
30555,
10310,
121,
666,
63,
694,
221,
24233,
8106,
3529,
9112,
250,
107,
166,
235,
227,
272,
283,
2537,
14,
11676,
14,
3494,
63,
515,
7,
520,
666,
63,
694,
23164,
2791,
297,
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,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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
] |
ericvandenbergfb/spark
|
python/pyspark/daemon.py
|
79
|
6127
|
#
# 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 numbers
import os
import signal
import select
import socket
import sys
import traceback
import time
import gc
from errno import EINTR, EAGAIN
from socket import AF_INET, SOCK_STREAM, SOMAXCONN
from signal import SIGHUP, SIGTERM, SIGCHLD, SIG_DFL, SIG_IGN, SIGINT
from pyspark.worker import main as worker_main
from pyspark.serializers import read_int, write_int
def compute_real_exit_code(exit_code):
# SystemExit's code can be integer or string, but os._exit only accepts integers
if isinstance(exit_code, numbers.Integral):
return exit_code
else:
return 1
def worker(sock):
"""
Called by a worker process after the fork().
"""
signal.signal(SIGHUP, SIG_DFL)
signal.signal(SIGCHLD, SIG_DFL)
signal.signal(SIGTERM, SIG_DFL)
# restore the handler for SIGINT,
# it's useful for debugging (show the stacktrace before exit)
signal.signal(SIGINT, signal.default_int_handler)
# Read the socket using fdopen instead of socket.makefile() because the latter
# seems to be very slow; note that we need to dup() the file descriptor because
# otherwise writes also cause a seek that makes us miss data on the read side.
infile = os.fdopen(os.dup(sock.fileno()), "rb", 65536)
outfile = os.fdopen(os.dup(sock.fileno()), "wb", 65536)
exit_code = 0
try:
worker_main(infile, outfile)
except SystemExit as exc:
exit_code = compute_real_exit_code(exc.code)
finally:
try:
outfile.flush()
except Exception:
pass
return exit_code
def manager():
# Create a new process group to corral our children
os.setpgid(0, 0)
# Create a listening socket on the AF_INET loopback interface
listen_sock = socket.socket(AF_INET, SOCK_STREAM)
listen_sock.bind(('127.0.0.1', 0))
listen_sock.listen(max(1024, SOMAXCONN))
listen_host, listen_port = listen_sock.getsockname()
# re-open stdin/stdout in 'wb' mode
stdin_bin = os.fdopen(sys.stdin.fileno(), 'rb', 4)
stdout_bin = os.fdopen(sys.stdout.fileno(), 'wb', 4)
write_int(listen_port, stdout_bin)
stdout_bin.flush()
def shutdown(code):
signal.signal(SIGTERM, SIG_DFL)
# Send SIGHUP to notify workers of shutdown
os.kill(0, SIGHUP)
exit(code)
def handle_sigterm(*args):
shutdown(1)
signal.signal(SIGTERM, handle_sigterm) # Gracefully exit on SIGTERM
signal.signal(SIGHUP, SIG_IGN) # Don't die on SIGHUP
signal.signal(SIGCHLD, SIG_IGN)
reuse = os.environ.get("SPARK_REUSE_WORKER")
# Initialization complete
try:
while True:
try:
ready_fds = select.select([0, listen_sock], [], [], 1)[0]
except select.error as ex:
if ex[0] == EINTR:
continue
else:
raise
if 0 in ready_fds:
try:
worker_pid = read_int(stdin_bin)
except EOFError:
# Spark told us to exit by closing stdin
shutdown(0)
try:
os.kill(worker_pid, signal.SIGKILL)
except OSError:
pass # process already died
if listen_sock in ready_fds:
try:
sock, _ = listen_sock.accept()
except OSError as e:
if e.errno == EINTR:
continue
raise
# Launch a worker process
try:
pid = os.fork()
except OSError as e:
if e.errno in (EAGAIN, EINTR):
time.sleep(1)
pid = os.fork() # error here will shutdown daemon
else:
outfile = sock.makefile(mode='wb')
write_int(e.errno, outfile) # Signal that the fork failed
outfile.flush()
outfile.close()
sock.close()
continue
if pid == 0:
# in child process
listen_sock.close()
try:
# Acknowledge that the fork was successful
outfile = sock.makefile(mode="wb")
write_int(os.getpid(), outfile)
outfile.flush()
outfile.close()
while True:
code = worker(sock)
if not reuse or code:
# wait for closing
try:
while sock.recv(1024):
pass
except Exception:
pass
break
gc.collect()
except:
traceback.print_exc()
os._exit(1)
else:
os._exit(0)
else:
sock.close()
finally:
shutdown(1)
if __name__ == '__main__':
manager()
|
apache-2.0
|
[
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
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,
199,
199,
646,
5579,
199,
646,
747,
199,
646,
4673,
199,
646,
3504,
199,
646,
2838,
199,
646,
984,
199,
646,
5190,
199,
646,
900,
199,
646,
9486,
199,
504,
7554,
492,
662,
19652,
12,
662,
1254,
9021,
199,
504,
2838,
492,
20089,
63,
11367,
12,
26327,
63,
9484,
12,
3562,
4283,
17489,
199,
504,
4673,
492,
428,
13454,
2160,
12,
15522,
16718,
12,
15522,
1244,
6533,
12,
15522,
63,
36,
3143,
12,
15522,
63,
3203,
12,
15522,
2919,
199,
199,
504,
15847,
14,
6599,
492,
2446,
465,
7239,
63,
973,
199,
504,
15847,
14,
12844,
492,
1586,
63,
442,
12,
2218,
63,
442,
421,
199,
318,
4526,
63,
3093,
63,
2224,
63,
600,
8,
2224,
63,
600,
304,
272,
327,
14838,
1159,
1233,
883,
506,
3000,
503,
1059,
12,
1325,
747,
423,
2224,
1454,
11479,
9446,
272,
340,
1228,
8,
2224,
63,
600,
12,
5579,
14,
18949,
304,
267,
372,
4458,
63,
600,
272,
587,
26,
267,
372,
413,
421,
199,
318,
7239,
8,
5096,
304,
272,
408,
272,
12295,
701,
282,
7239,
2112,
2410,
314,
14926,
1252,
272,
408,
272,
4673,
14,
4653,
8,
7864,
40,
2160,
12,
15522,
63,
36,
3143,
9,
272,
4673,
14,
4653,
8,
7864,
1244,
6533,
12,
15522,
63,
36,
3143,
9,
272,
4673,
14,
4653,
8,
29190,
12,
15522,
63,
36,
3143,
9,
272,
327,
9066,
314,
3016,
367,
15522,
2919,
12,
272,
327,
652,
1159,
2997,
367,
10201,
334,
2384,
314,
3464,
3446,
2544,
4458,
9,
272,
4673,
14,
4653,
8,
21223,
12,
4673,
14,
885,
63,
442,
63,
2232,
9,
339,
327,
5574,
314,
2838,
1808,
6111,
1490,
3140,
402,
2838,
14,
13941,
342,
2952,
314,
19045,
272,
327,
12237,
370,
506,
7437,
11999,
27,
5317,
626,
781,
1929,
370,
11866,
342,
314,
570,
5872,
2952,
272,
327,
4257,
14511,
2597,
7675,
282,
12005,
626,
7704,
2739,
26747,
666,
641,
314,
1586,
5366,
14,
272,
14734,
275,
747,
14,
23140,
8,
736,
14,
11048,
8,
5096,
14,
9843,
4000,
298,
4848,
401,
25980,
9,
272,
4386,
275,
747,
14,
23140,
8,
736,
14,
11048,
8,
5096,
14,
9843,
4000,
298,
6603,
401,
25980,
9,
272,
4458,
63,
600,
275,
378,
272,
862,
26,
267,
7239,
63,
973,
8,
13880,
12,
4386,
9,
272,
871,
14838,
465,
3178,
26,
267,
4458,
63,
600,
275,
4526,
63,
3093,
63,
2224,
63,
600,
8,
2804,
14,
600,
9,
272,
3753,
26,
267,
862,
26,
288,
4386,
14,
4939,
342,
267,
871,
2186,
26,
288,
986,
272,
372,
4458,
63,
600,
421,
199,
318,
5256,
837,
272,
327,
2790,
282,
892,
2112,
1572,
370,
1970,
13984,
4154,
4978,
272,
747,
14,
409,
4198,
344,
8,
16,
12,
378,
9,
339,
327,
2790,
282,
22721,
2838,
641,
314,
20089,
63,
11367,
4438,
894,
3217,
272,
6938,
63,
5096,
275,
2838,
14,
3450,
8,
5699,
63,
11367,
12,
26327,
63,
9484,
9,
272,
6938,
63,
5096,
14,
3409,
4725,
4195,
14,
16,
14,
16,
14,
17,
297,
378,
430,
272,
6938,
63,
5096,
14,
5859,
8,
988,
8,
7727,
12,
3562,
4283,
17489,
430,
272,
6938,
63,
1102,
12,
6938,
63,
719,
275,
6938,
63,
5096,
14,
27886,
342,
339,
327,
295,
13,
1490,
9009,
15,
2703,
315,
283,
6603,
7,
818,
272,
9009,
63,
1393,
275,
747,
14,
23140,
8,
1274,
14,
6626,
14,
9843,
1062,
283,
4848,
297,
841,
9,
272,
3839,
63,
1393,
275,
747,
14,
23140,
8,
1274,
14,
2703,
14,
9843,
1062,
283,
6603,
297,
841,
9,
272,
2218,
63,
442,
8,
5859,
63,
719,
12,
3839,
63,
1393,
9,
272,
3839,
63,
1393,
14,
4939,
342,
339,
347,
12842,
8,
600,
304,
267,
4673,
14,
4653,
8,
29190,
12,
15522,
63,
36,
3143,
9,
267,
327,
10217,
428,
13454,
2160,
370,
11705,
14123,
402,
12842,
267,
747,
14,
8997,
8,
16,
12,
428,
13454,
2160,
9,
267,
4458,
8,
600,
9,
339,
347,
2429,
63,
4093,
5125,
2031,
589,
304,
267,
12842,
8,
17,
9,
272,
4673,
14,
4653,
8,
29190,
12,
2429,
63,
4093,
5125,
9,
221,
327,
598,
5986,
5836,
4458,
641,
15522,
16718,
272,
4673,
14,
4653,
8,
7864,
40,
2160,
12,
15522,
63,
3203,
9,
221,
327,
7529,
1133,
18833,
641,
428,
13454,
2160,
272,
4673,
14,
4653,
8,
7864,
1244,
6533,
12,
15522,
63,
3203,
9,
339,
12598,
275,
747,
14,
2314,
14,
362,
480,
51,
28535,
63,
907,
4701,
63,
8406,
540,
531,
339,
327,
6026,
2072,
4890,
272,
862,
26,
267,
1830,
715,
26,
288,
862,
26,
355,
10144,
63,
14240,
275,
3504,
14,
2416,
779,
16,
12,
6938,
63,
5096,
467,
990,
990,
413,
2788,
16,
61,
288,
871,
3504,
14,
705,
465,
444,
26,
355,
340,
444,
59,
16,
61,
508,
662,
19652,
26,
490,
1980,
355,
587,
26,
490,
746,
953,
340,
378,
315,
10144,
63,
14240,
26,
355,
862,
26,
490,
7239,
63,
3150,
275,
1586,
63,
442,
8,
6626,
63,
1393,
9,
355,
871,
21157,
26,
490,
327,
13932,
370,
1447,
2739,
370,
4458,
701,
11261,
9009,
490,
12842,
8,
16,
9,
355,
862,
26,
490,
747,
14,
8997,
8,
6599,
63,
3150,
12
] |
[
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
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,
199,
199,
646,
5579,
199,
646,
747,
199,
646,
4673,
199,
646,
3504,
199,
646,
2838,
199,
646,
984,
199,
646,
5190,
199,
646,
900,
199,
646,
9486,
199,
504,
7554,
492,
662,
19652,
12,
662,
1254,
9021,
199,
504,
2838,
492,
20089,
63,
11367,
12,
26327,
63,
9484,
12,
3562,
4283,
17489,
199,
504,
4673,
492,
428,
13454,
2160,
12,
15522,
16718,
12,
15522,
1244,
6533,
12,
15522,
63,
36,
3143,
12,
15522,
63,
3203,
12,
15522,
2919,
199,
199,
504,
15847,
14,
6599,
492,
2446,
465,
7239,
63,
973,
199,
504,
15847,
14,
12844,
492,
1586,
63,
442,
12,
2218,
63,
442,
421,
199,
318,
4526,
63,
3093,
63,
2224,
63,
600,
8,
2224,
63,
600,
304,
272,
327,
14838,
1159,
1233,
883,
506,
3000,
503,
1059,
12,
1325,
747,
423,
2224,
1454,
11479,
9446,
272,
340,
1228,
8,
2224,
63,
600,
12,
5579,
14,
18949,
304,
267,
372,
4458,
63,
600,
272,
587,
26,
267,
372,
413,
421,
199,
318,
7239,
8,
5096,
304,
272,
408,
272,
12295,
701,
282,
7239,
2112,
2410,
314,
14926,
1252,
272,
408,
272,
4673,
14,
4653,
8,
7864,
40,
2160,
12,
15522,
63,
36,
3143,
9,
272,
4673,
14,
4653,
8,
7864,
1244,
6533,
12,
15522,
63,
36,
3143,
9,
272,
4673,
14,
4653,
8,
29190,
12,
15522,
63,
36,
3143,
9,
272,
327,
9066,
314,
3016,
367,
15522,
2919,
12,
272,
327,
652,
1159,
2997,
367,
10201,
334,
2384,
314,
3464,
3446,
2544,
4458,
9,
272,
4673,
14,
4653,
8,
21223,
12,
4673,
14,
885,
63,
442,
63,
2232,
9,
339,
327,
5574,
314,
2838,
1808,
6111,
1490,
3140,
402,
2838,
14,
13941,
342,
2952,
314,
19045,
272,
327,
12237,
370,
506,
7437,
11999,
27,
5317,
626,
781,
1929,
370,
11866,
342,
314,
570,
5872,
2952,
272,
327,
4257,
14511,
2597,
7675,
282,
12005,
626,
7704,
2739,
26747,
666,
641,
314,
1586,
5366,
14,
272,
14734,
275,
747,
14,
23140,
8,
736,
14,
11048,
8,
5096,
14,
9843,
4000,
298,
4848,
401,
25980,
9,
272,
4386,
275,
747,
14,
23140,
8,
736,
14,
11048,
8,
5096,
14,
9843,
4000,
298,
6603,
401,
25980,
9,
272,
4458,
63,
600,
275,
378,
272,
862,
26,
267,
7239,
63,
973,
8,
13880,
12,
4386,
9,
272,
871,
14838,
465,
3178,
26,
267,
4458,
63,
600,
275,
4526,
63,
3093,
63,
2224,
63,
600,
8,
2804,
14,
600,
9,
272,
3753,
26,
267,
862,
26,
288,
4386,
14,
4939,
342,
267,
871,
2186,
26,
288,
986,
272,
372,
4458,
63,
600,
421,
199,
318,
5256,
837,
272,
327,
2790,
282,
892,
2112,
1572,
370,
1970,
13984,
4154,
4978,
272,
747,
14,
409,
4198,
344,
8,
16,
12,
378,
9,
339,
327,
2790,
282,
22721,
2838,
641,
314,
20089,
63,
11367,
4438,
894,
3217,
272,
6938,
63,
5096,
275,
2838,
14,
3450,
8,
5699,
63,
11367,
12,
26327,
63,
9484,
9,
272,
6938,
63,
5096,
14,
3409,
4725,
4195,
14,
16,
14,
16,
14,
17,
297,
378,
430,
272,
6938,
63,
5096,
14,
5859,
8,
988,
8,
7727,
12,
3562,
4283,
17489,
430,
272,
6938,
63,
1102,
12,
6938,
63,
719,
275,
6938,
63,
5096,
14,
27886,
342,
339,
327,
295,
13,
1490,
9009,
15,
2703,
315,
283,
6603,
7,
818,
272,
9009,
63,
1393,
275,
747,
14,
23140,
8,
1274,
14,
6626,
14,
9843,
1062,
283,
4848,
297,
841,
9,
272,
3839,
63,
1393,
275,
747,
14,
23140,
8,
1274,
14,
2703,
14,
9843,
1062,
283,
6603,
297,
841,
9,
272,
2218,
63,
442,
8,
5859,
63,
719,
12,
3839,
63,
1393,
9,
272,
3839,
63,
1393,
14,
4939,
342,
339,
347,
12842,
8,
600,
304,
267,
4673,
14,
4653,
8,
29190,
12,
15522,
63,
36,
3143,
9,
267,
327,
10217,
428,
13454,
2160,
370,
11705,
14123,
402,
12842,
267,
747,
14,
8997,
8,
16,
12,
428,
13454,
2160,
9,
267,
4458,
8,
600,
9,
339,
347,
2429,
63,
4093,
5125,
2031,
589,
304,
267,
12842,
8,
17,
9,
272,
4673,
14,
4653,
8,
29190,
12,
2429,
63,
4093,
5125,
9,
221,
327,
598,
5986,
5836,
4458,
641,
15522,
16718,
272,
4673,
14,
4653,
8,
7864,
40,
2160,
12,
15522,
63,
3203,
9,
221,
327,
7529,
1133,
18833,
641,
428,
13454,
2160,
272,
4673,
14,
4653,
8,
7864,
1244,
6533,
12,
15522,
63,
3203,
9,
339,
12598,
275,
747,
14,
2314,
14,
362,
480,
51,
28535,
63,
907,
4701,
63,
8406,
540,
531,
339,
327,
6026,
2072,
4890,
272,
862,
26,
267,
1830,
715,
26,
288,
862,
26,
355,
10144,
63,
14240,
275,
3504,
14,
2416,
779,
16,
12,
6938,
63,
5096,
467,
990,
990,
413,
2788,
16,
61,
288,
871,
3504,
14,
705,
465,
444,
26,
355,
340,
444,
59,
16,
61,
508,
662,
19652,
26,
490,
1980,
355,
587,
26,
490,
746,
953,
340,
378,
315,
10144,
63,
14240,
26,
355,
862,
26,
490,
7239,
63,
3150,
275,
1586,
63,
442,
8,
6626,
63,
1393,
9,
355,
871,
21157,
26,
490,
327,
13932,
370,
1447,
2739,
370,
4458,
701,
11261,
9009,
490,
12842,
8,
16,
9,
355,
862,
26,
490,
747,
14,
8997,
8,
6599,
63,
3150,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
polarise/BioClasses
|
LeafCounter.py
|
2
|
1218
|
# -*- encoding: utf-8 -*-
from __future__ import division
import sys
class LeafCounter( object ):
def __init__( self ):
self.state_count = 0
self.zero_count = 0
self.one_count = 0
self.two_count = 0
self.branch_count = 0
def add_node( self, node ):
if self.state_count == 0:
if node.name == 0:
self.zero_count = 0
self.one_count = 1
self.two_count = 1
elif node.name == 1:
self.zero_count = 1
self.one_count = 0
self.two_count = 1
elif node.name == 2:
self.zero_count = 1
self.one_count = 1
self.two_count = 0
self.branch_count = 0
else:
if node.name == 0:
self.branch_count = self.zero_count
self.zero_count = 0
self.one_count += self.branch_count
self.two_count += self.branch_count
elif node.name == 1:
self.branch_count = self.one_count
self.zero_count += self.branch_count
self.one_count = 0
self.two_count += self.branch_count
elif node.name == 2:
self.branch_count = self.two_count
self.zero_count += self.branch_count
self.one_count += self.branch_count
self.two_count = 0
self.state_count += 1
def leaf_count( self ):
return self.zero_count + self.one_count + self.two_count
|
gpl-2.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
4629,
199,
646,
984,
199,
199,
533,
27836,
11348,
8,
909,
3461,
199,
198,
318,
636,
826,
721,
291,
3461,
507,
198,
277,
14,
929,
63,
835,
275,
378,
507,
198,
277,
14,
4262,
63,
835,
275,
378,
507,
198,
277,
14,
368,
63,
835,
275,
378,
507,
198,
277,
14,
5601,
63,
835,
275,
378,
507,
198,
277,
14,
4694,
63,
835,
275,
378,
8299,
198,
318,
1050,
63,
932,
8,
291,
12,
1031,
3461,
507,
198,
692,
291,
14,
929,
63,
835,
508,
378,
26,
686,
198,
692,
1031,
14,
354,
508,
378,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
378,
1585,
198,
277,
14,
368,
63,
835,
275,
413,
1585,
198,
277,
14,
5601,
63,
835,
275,
413,
686,
198,
4164,
1031,
14,
354,
508,
413,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
413,
1585,
198,
277,
14,
368,
63,
835,
275,
378,
1585,
198,
277,
14,
5601,
63,
835,
275,
413,
686,
198,
4164,
1031,
14,
354,
508,
499,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
413,
1585,
198,
277,
14,
368,
63,
835,
275,
413,
1585,
198,
277,
14,
5601,
63,
835,
275,
378,
686,
198,
277,
14,
4694,
63,
835,
275,
378,
507,
198,
2836,
26,
686,
198,
692,
1031,
14,
354,
508,
378,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
4262,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
275,
378,
1585,
198,
277,
14,
368,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
5601,
63,
835,
847,
291,
14,
4694,
63,
835,
686,
198,
4164,
1031,
14,
354,
508,
413,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
368,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
368,
63,
835,
275,
378,
1585,
198,
277,
14,
5601,
63,
835,
847,
291,
14,
4694,
63,
835,
686,
198,
4164,
1031,
14,
354,
508,
499,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
5601,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
368,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
5601,
63,
835,
275,
378,
507,
198,
277,
14,
929,
63,
835,
847,
413,
8299,
198,
318,
11747,
63,
835,
8,
291,
3461,
507,
198,
1107,
291,
14,
4262,
63,
835,
435,
291,
14,
368,
63,
835,
435,
291,
14,
5601,
63,
835,
1585,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
4629,
199,
646,
984,
199,
199,
533,
27836,
11348,
8,
909,
3461,
199,
198,
318,
636,
826,
721,
291,
3461,
507,
198,
277,
14,
929,
63,
835,
275,
378,
507,
198,
277,
14,
4262,
63,
835,
275,
378,
507,
198,
277,
14,
368,
63,
835,
275,
378,
507,
198,
277,
14,
5601,
63,
835,
275,
378,
507,
198,
277,
14,
4694,
63,
835,
275,
378,
8299,
198,
318,
1050,
63,
932,
8,
291,
12,
1031,
3461,
507,
198,
692,
291,
14,
929,
63,
835,
508,
378,
26,
686,
198,
692,
1031,
14,
354,
508,
378,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
378,
1585,
198,
277,
14,
368,
63,
835,
275,
413,
1585,
198,
277,
14,
5601,
63,
835,
275,
413,
686,
198,
4164,
1031,
14,
354,
508,
413,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
413,
1585,
198,
277,
14,
368,
63,
835,
275,
378,
1585,
198,
277,
14,
5601,
63,
835,
275,
413,
686,
198,
4164,
1031,
14,
354,
508,
499,
26,
1585,
198,
277,
14,
4262,
63,
835,
275,
413,
1585,
198,
277,
14,
368,
63,
835,
275,
413,
1585,
198,
277,
14,
5601,
63,
835,
275,
378,
686,
198,
277,
14,
4694,
63,
835,
275,
378,
507,
198,
2836,
26,
686,
198,
692,
1031,
14,
354,
508,
378,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
4262,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
275,
378,
1585,
198,
277,
14,
368,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
5601,
63,
835,
847,
291,
14,
4694,
63,
835,
686,
198,
4164,
1031,
14,
354,
508,
413,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
368,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
368,
63,
835,
275,
378,
1585,
198,
277,
14,
5601,
63,
835,
847,
291,
14,
4694,
63,
835,
686,
198,
4164,
1031,
14,
354,
508,
499,
26,
1585,
198,
277,
14,
4694,
63,
835,
275,
291,
14,
5601,
63,
835,
1585,
198,
277,
14,
4262,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
368,
63,
835,
847,
291,
14,
4694,
63,
835,
1585,
198,
277,
14,
5601,
63,
835,
275,
378,
507,
198,
277,
14,
929,
63,
835,
847,
413,
8299,
198,
318,
11747,
63,
835,
8,
291,
3461,
507,
198,
1107,
291,
14,
4262,
63,
835,
435,
291,
14,
368,
63,
835,
435,
291,
14,
5601,
63,
835,
1585,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
cesarmarinhorj/ansible
|
test/units/vars/test_variable_manager.py
|
70
|
5534
|
# (c) 2012-2014, Michael DeHaan <michael.dehaan@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/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch, MagicMock
from ansible.vars import VariableManager
from units.mock.loader import DictDataLoader
class TestVariableManager(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_basic_manager(self):
fake_loader = DictDataLoader({})
v = VariableManager()
vars = v.get_vars(loader=fake_loader, use_cache=False)
if 'omit' in vars:
del vars['omit']
if 'vars' in vars:
del vars['vars']
if 'ansible_version' in vars:
del vars['ansible_version']
self.assertEqual(vars, dict(playbook_dir='.'))
self.assertEqual(
v._merge_dicts(
dict(a=1),
dict(b=2)
), dict(a=1, b=2)
)
self.assertEqual(
v._merge_dicts(
dict(a=1, c=dict(foo='bar')),
dict(b=2, c=dict(baz='bam'))
), dict(a=1, b=2, c=dict(foo='bar', baz='bam'))
)
def test_variable_manager_extra_vars(self):
fake_loader = DictDataLoader({})
extra_vars = dict(a=1, b=2, c=3)
v = VariableManager()
v.extra_vars = extra_vars
vars = v.get_vars(loader=fake_loader, use_cache=False)
for (key, val) in extra_vars.iteritems():
self.assertEqual(vars.get(key), val)
self.assertIsNot(v.extra_vars, extra_vars)
def test_variable_manager_host_vars_file(self):
fake_loader = DictDataLoader({
"host_vars/hostname1.yml": """
foo: bar
"""
})
v = VariableManager()
v.add_host_vars_file("host_vars/hostname1.yml", loader=fake_loader)
self.assertIn("hostname1", v._host_vars_files)
self.assertEqual(v._host_vars_files["hostname1"], dict(foo="bar"))
mock_host = MagicMock()
mock_host.get_name.return_value = "hostname1"
mock_host.get_vars.return_value = dict()
mock_host.get_groups.return_value = ()
self.assertEqual(v.get_vars(loader=fake_loader, host=mock_host, use_cache=False).get("foo"), "bar")
def test_variable_manager_group_vars_file(self):
fake_loader = DictDataLoader({
"group_vars/all.yml": """
foo: bar
""",
"group_vars/somegroup.yml": """
bam: baz
"""
})
v = VariableManager()
v.add_group_vars_file("group_vars/all.yml", loader=fake_loader)
v.add_group_vars_file("group_vars/somegroup.yml", loader=fake_loader)
self.assertIn("somegroup", v._group_vars_files)
self.assertEqual(v._group_vars_files["all"], dict(foo="bar"))
self.assertEqual(v._group_vars_files["somegroup"], dict(bam="baz"))
mock_group = MagicMock()
mock_group.name = "somegroup"
mock_group.get_ancestors.return_value = ()
mock_group.get_vars.return_value = dict()
mock_host = MagicMock()
mock_host.get_name.return_value = "hostname1"
mock_host.get_vars.return_value = dict()
mock_host.get_groups.return_value = (mock_group,)
vars = v.get_vars(loader=fake_loader, host=mock_host, use_cache=False)
self.assertEqual(vars.get("foo"), "bar")
self.assertEqual(vars.get("bam"), "baz")
def test_variable_manager_play_vars(self):
fake_loader = DictDataLoader({})
mock_play = MagicMock()
mock_play.get_vars.return_value = dict(foo="bar")
mock_play.get_roles.return_value = []
mock_play.get_vars_files.return_value = []
v = VariableManager()
self.assertEqual(v.get_vars(loader=fake_loader, play=mock_play, use_cache=False).get("foo"), "bar")
def test_variable_manager_play_vars_files(self):
fake_loader = DictDataLoader({
"/path/to/somefile.yml": """
foo: bar
"""
})
mock_play = MagicMock()
mock_play.get_vars.return_value = dict()
mock_play.get_roles.return_value = []
mock_play.get_vars_files.return_value = ['/path/to/somefile.yml']
v = VariableManager()
self.assertEqual(v.get_vars(loader=fake_loader, play=mock_play, use_cache=False).get("foo"), "bar")
def test_variable_manager_task_vars(self):
fake_loader = DictDataLoader({})
mock_task = MagicMock()
mock_task._role = None
mock_task.get_vars.return_value = dict(foo="bar")
v = VariableManager()
self.assertEqual(v.get_vars(loader=fake_loader, task=mock_task, use_cache=False).get("foo"), "bar")
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
199,
199,
504,
3242,
14,
2936,
492,
4905,
2988,
199,
199,
504,
6204,
14,
1805,
14,
3422,
492,
7448,
1451,
5455,
199,
199,
533,
1379,
2773,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
347,
511,
63,
4316,
63,
2609,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
14079,
398,
373,
275,
4905,
2988,
342,
267,
6802,
275,
373,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
675,
63,
1637,
29,
797,
9,
267,
340,
283,
19007,
7,
315,
6802,
26,
288,
2150,
6802,
459,
19007,
418,
267,
340,
283,
2936,
7,
315,
6802,
26,
288,
2150,
6802,
459,
2936,
418,
267,
340,
283,
4853,
63,
1023,
7,
315,
6802,
26,
288,
2150,
6802,
459,
4853,
63,
1023,
418,
398,
291,
14,
629,
8,
2936,
12,
1211,
8,
14205,
63,
694,
534,
12459,
398,
291,
14,
629,
8,
288,
373,
423,
5628,
63,
7892,
8,
355,
1211,
8,
65,
29,
17,
395,
355,
1211,
8,
66,
29,
18,
9,
288,
2318,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
9,
267,
776,
267,
291,
14,
629,
8,
288,
373,
423,
5628,
63,
7892,
8,
355,
1211,
8,
65,
29,
17,
12,
286,
29,
807,
8,
1421,
534,
1700,
3855,
355,
1211,
8,
66,
29,
18,
12,
286,
29,
807,
8,
6185,
534,
21112,
1333,
288,
2318,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
12,
286,
29,
807,
8,
1421,
534,
1700,
297,
15507,
534,
21112,
1333,
267,
776,
2378,
347,
511,
63,
1975,
63,
2609,
63,
2911,
63,
2936,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
14079,
398,
2402,
63,
2936,
275,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
12,
286,
29,
19,
9,
267,
373,
275,
4905,
2988,
342,
267,
373,
14,
2911,
63,
2936,
275,
2402,
63,
2936,
398,
6802,
275,
373,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
675,
63,
1637,
29,
797,
9,
398,
367,
334,
498,
12,
1139,
9,
315,
2402,
63,
2936,
14,
4611,
837,
288,
291,
14,
629,
8,
2936,
14,
362,
8,
498,
395,
1139,
9,
398,
291,
14,
9422,
8,
86,
14,
2911,
63,
2936,
12,
2402,
63,
2936,
9,
339,
347,
511,
63,
1975,
63,
2609,
63,
1102,
63,
2936,
63,
493,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
2561,
288,
298,
1102,
63,
2936,
15,
4269,
17,
14,
11714,
582,
408,
2049,
3925,
26,
4681,
288,
408,
267,
3828,
398,
373,
275,
4905,
2988,
342,
267,
373,
14,
525,
63,
1102,
63,
2936,
63,
493,
480,
1102,
63,
2936,
15,
4269,
17,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
291,
14,
4080,
480,
4269,
17,
401,
373,
423,
1102,
63,
2936,
63,
1725,
9,
267,
291,
14,
629,
8,
86,
423,
1102,
63,
2936,
63,
1725,
905,
4269,
17,
2255,
1211,
8,
1421,
628,
1700,
2237,
398,
1683,
63,
1102,
275,
10079,
342,
267,
1683,
63,
1102,
14,
362,
63,
354,
14,
1107,
63,
585,
275,
298,
4269,
17,
2,
267,
1683,
63,
1102,
14,
362,
63,
2936,
14,
1107,
63,
585,
275,
1211,
342,
267,
1683,
63,
1102,
14,
362,
63,
2634,
14,
1107,
63,
585,
275,
6248,
398,
291,
14,
629,
8,
86,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
1591,
29,
1805,
63,
1102,
12,
675,
63,
1637,
29,
797,
680,
362,
480,
1421,
1288,
298,
1700,
531,
339,
347,
511,
63,
1975,
63,
2609,
63,
923,
63,
2936,
63,
493,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
2561,
288,
298,
923,
63,
2936,
15,
452,
14,
11714,
582,
408,
2049,
3925,
26,
4681,
288,
10327,
288,
298,
923,
63,
2936,
15,
3972,
923,
14,
11714,
582,
408,
2049,
330,
455,
26,
15507,
288,
408,
267,
3828,
398,
373,
275,
4905,
2988,
342,
267,
373,
14,
525,
63,
923,
63,
2936,
63,
493,
480,
923,
63,
2936,
15,
452,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
373,
14,
525,
63,
923,
63,
2936,
63,
493,
480,
923,
63,
2936,
15,
3972,
923,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
291,
14,
4080,
480,
3972,
923,
401,
373,
423,
923,
63,
2936,
63,
1725,
9,
267,
291,
14,
629,
8,
86,
423,
923,
63,
2936,
63,
1725,
905,
452,
2255,
1211,
8,
1421,
628,
1700,
2237,
267,
291,
14,
629,
8,
86,
423,
923,
63,
2936,
63,
1725,
905,
3972,
923,
2255,
1211,
8,
21112,
628,
6185,
2237,
398,
1683,
63,
923,
275,
10079,
342,
267,
1683,
63,
923,
14,
354,
275,
298,
3972,
923,
2,
267,
1683,
63,
923,
14,
362,
63
] |
[
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
3242,
14,
5819,
14,
2219,
492,
2882,
199,
504,
3242,
14,
5819,
14,
2219,
14,
1805,
492,
3371,
12,
10079,
199,
199,
504,
3242,
14,
2936,
492,
4905,
2988,
199,
199,
504,
6204,
14,
1805,
14,
3422,
492,
7448,
1451,
5455,
199,
199,
533,
1379,
2773,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
986,
339,
347,
6766,
8,
277,
304,
267,
986,
339,
347,
511,
63,
4316,
63,
2609,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
14079,
398,
373,
275,
4905,
2988,
342,
267,
6802,
275,
373,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
675,
63,
1637,
29,
797,
9,
267,
340,
283,
19007,
7,
315,
6802,
26,
288,
2150,
6802,
459,
19007,
418,
267,
340,
283,
2936,
7,
315,
6802,
26,
288,
2150,
6802,
459,
2936,
418,
267,
340,
283,
4853,
63,
1023,
7,
315,
6802,
26,
288,
2150,
6802,
459,
4853,
63,
1023,
418,
398,
291,
14,
629,
8,
2936,
12,
1211,
8,
14205,
63,
694,
534,
12459,
398,
291,
14,
629,
8,
288,
373,
423,
5628,
63,
7892,
8,
355,
1211,
8,
65,
29,
17,
395,
355,
1211,
8,
66,
29,
18,
9,
288,
2318,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
9,
267,
776,
267,
291,
14,
629,
8,
288,
373,
423,
5628,
63,
7892,
8,
355,
1211,
8,
65,
29,
17,
12,
286,
29,
807,
8,
1421,
534,
1700,
3855,
355,
1211,
8,
66,
29,
18,
12,
286,
29,
807,
8,
6185,
534,
21112,
1333,
288,
2318,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
12,
286,
29,
807,
8,
1421,
534,
1700,
297,
15507,
534,
21112,
1333,
267,
776,
2378,
347,
511,
63,
1975,
63,
2609,
63,
2911,
63,
2936,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
14079,
398,
2402,
63,
2936,
275,
1211,
8,
65,
29,
17,
12,
330,
29,
18,
12,
286,
29,
19,
9,
267,
373,
275,
4905,
2988,
342,
267,
373,
14,
2911,
63,
2936,
275,
2402,
63,
2936,
398,
6802,
275,
373,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
675,
63,
1637,
29,
797,
9,
398,
367,
334,
498,
12,
1139,
9,
315,
2402,
63,
2936,
14,
4611,
837,
288,
291,
14,
629,
8,
2936,
14,
362,
8,
498,
395,
1139,
9,
398,
291,
14,
9422,
8,
86,
14,
2911,
63,
2936,
12,
2402,
63,
2936,
9,
339,
347,
511,
63,
1975,
63,
2609,
63,
1102,
63,
2936,
63,
493,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
2561,
288,
298,
1102,
63,
2936,
15,
4269,
17,
14,
11714,
582,
408,
2049,
3925,
26,
4681,
288,
408,
267,
3828,
398,
373,
275,
4905,
2988,
342,
267,
373,
14,
525,
63,
1102,
63,
2936,
63,
493,
480,
1102,
63,
2936,
15,
4269,
17,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
291,
14,
4080,
480,
4269,
17,
401,
373,
423,
1102,
63,
2936,
63,
1725,
9,
267,
291,
14,
629,
8,
86,
423,
1102,
63,
2936,
63,
1725,
905,
4269,
17,
2255,
1211,
8,
1421,
628,
1700,
2237,
398,
1683,
63,
1102,
275,
10079,
342,
267,
1683,
63,
1102,
14,
362,
63,
354,
14,
1107,
63,
585,
275,
298,
4269,
17,
2,
267,
1683,
63,
1102,
14,
362,
63,
2936,
14,
1107,
63,
585,
275,
1211,
342,
267,
1683,
63,
1102,
14,
362,
63,
2634,
14,
1107,
63,
585,
275,
6248,
398,
291,
14,
629,
8,
86,
14,
362,
63,
2936,
8,
3422,
29,
3183,
63,
3422,
12,
1591,
29,
1805,
63,
1102,
12,
675,
63,
1637,
29,
797,
680,
362,
480,
1421,
1288,
298,
1700,
531,
339,
347,
511,
63,
1975,
63,
2609,
63,
923,
63,
2936,
63,
493,
8,
277,
304,
267,
4026,
63,
3422,
275,
7448,
1451,
5455,
2561,
288,
298,
923,
63,
2936,
15,
452,
14,
11714,
582,
408,
2049,
3925,
26,
4681,
288,
10327,
288,
298,
923,
63,
2936,
15,
3972,
923,
14,
11714,
582,
408,
2049,
330,
455,
26,
15507,
288,
408,
267,
3828,
398,
373,
275,
4905,
2988,
342,
267,
373,
14,
525,
63,
923,
63,
2936,
63,
493,
480,
923,
63,
2936,
15,
452,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
373,
14,
525,
63,
923,
63,
2936,
63,
493,
480,
923,
63,
2936,
15,
3972,
923,
14,
11714,
401,
5077,
29,
3183,
63,
3422,
9,
267,
291,
14,
4080,
480,
3972,
923,
401,
373,
423,
923,
63,
2936,
63,
1725,
9,
267,
291,
14,
629,
8,
86,
423,
923,
63,
2936,
63,
1725,
905,
452,
2255,
1211,
8,
1421,
628,
1700,
2237,
267,
291,
14,
629,
8,
86,
423,
923,
63,
2936,
63,
1725,
905,
3972,
923,
2255,
1211,
8,
21112,
628,
6185,
2237,
398,
1683,
63,
923,
275,
10079,
342,
267,
1683,
63,
923,
14,
354,
275,
298,
3972,
923,
2,
267,
1683,
63,
923,
14,
362,
63,
0
] |
[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] |
sorenk/ansible
|
test/units/modules/network/fortimanager/fortimanager_module.py
|
111
|
2107
|
# (c) 2016 Red Hat Inc.
#
# 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/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase
class TestFortimanagerModule(ModuleTestCase):
def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
self.load_fixtures(commands)
if failed:
result = self.failed()
self.assertTrue(result['failed'], result)
else:
result = self.changed(changed)
self.assertEqual(result['changed'], changed, result)
if commands is not None:
if sort:
self.assertEqual(sorted(commands), sorted(result['commands']), result['commands'])
else:
self.assertEqual(commands, result['commands'], result['commands'])
return result
def failed(self):
with self.assertRaises(AnsibleFailJson) as exc:
self.module.main()
result = exc.exception.args[0]
self.assertTrue(result['failed'], result)
return result
def changed(self, changed=False):
with self.assertRaises(AnsibleExitJson) as exc:
self.module.main()
result = exc.exception.args[0]
self.assertEqual(result['changed'], changed, result)
return result
def load_fixtures(self, commands=None):
pass
|
gpl-3.0
|
[
3,
334,
67,
9,
7800,
9572,
13002,
3277,
14,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
421,
199,
504,
6204,
14,
3112,
14,
1208,
492,
2622,
6699,
9653,
12,
2622,
4874,
9653,
12,
5673,
1746,
421,
199,
533,
1379,
28027,
2609,
2377,
8,
2377,
1746,
304,
339,
347,
5341,
63,
578,
8,
277,
12,
3405,
29,
797,
12,
2896,
29,
797,
12,
3718,
29,
403,
12,
4069,
29,
549,
12,
4243,
29,
797,
304,
398,
291,
14,
912,
63,
8769,
8,
4405,
9,
398,
340,
3405,
26,
288,
754,
275,
291,
14,
4892,
342,
288,
291,
14,
1815,
8,
1099,
459,
4892,
995,
754,
9,
267,
587,
26,
288,
754,
275,
291,
14,
2489,
8,
2489,
9,
288,
291,
14,
629,
8,
1099,
459,
2489,
995,
2896,
12,
754,
9,
398,
340,
3718,
365,
440,
488,
26,
288,
340,
4069,
26,
355,
291,
14,
629,
8,
5917,
8,
4405,
395,
3355,
8,
1099,
459,
4405,
3815,
754,
459,
4405,
1105,
288,
587,
26,
355,
291,
14,
629,
8,
4405,
12,
754,
459,
4405,
995,
754,
459,
4405,
1105,
398,
372,
754,
339,
347,
3405,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
10047,
4874,
9653,
9,
465,
3178,
26,
288,
291,
14,
578,
14,
973,
342,
398,
754,
275,
3178,
14,
1971,
14,
589,
59,
16,
61,
267,
291,
14,
1815,
8,
1099,
459,
4892,
995,
754,
9,
267,
372,
754,
339,
347,
2896,
8,
277,
12,
2896,
29,
797,
304,
267,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
3178,
26,
288,
291,
14,
578,
14,
973,
342,
398,
754,
275,
3178,
14,
1971,
14,
589,
59,
16,
61,
267,
291,
14,
629,
8,
1099,
459,
2489,
995,
2896,
12,
754,
9,
267,
372,
754,
339,
347,
2248,
63,
8769,
8,
277,
12,
3718,
29,
403,
304,
267,
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
] |
[
334,
67,
9,
7800,
9572,
13002,
3277,
14,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
421,
199,
504,
6204,
14,
3112,
14,
1208,
492,
2622,
6699,
9653,
12,
2622,
4874,
9653,
12,
5673,
1746,
421,
199,
533,
1379,
28027,
2609,
2377,
8,
2377,
1746,
304,
339,
347,
5341,
63,
578,
8,
277,
12,
3405,
29,
797,
12,
2896,
29,
797,
12,
3718,
29,
403,
12,
4069,
29,
549,
12,
4243,
29,
797,
304,
398,
291,
14,
912,
63,
8769,
8,
4405,
9,
398,
340,
3405,
26,
288,
754,
275,
291,
14,
4892,
342,
288,
291,
14,
1815,
8,
1099,
459,
4892,
995,
754,
9,
267,
587,
26,
288,
754,
275,
291,
14,
2489,
8,
2489,
9,
288,
291,
14,
629,
8,
1099,
459,
2489,
995,
2896,
12,
754,
9,
398,
340,
3718,
365,
440,
488,
26,
288,
340,
4069,
26,
355,
291,
14,
629,
8,
5917,
8,
4405,
395,
3355,
8,
1099,
459,
4405,
3815,
754,
459,
4405,
1105,
288,
587,
26,
355,
291,
14,
629,
8,
4405,
12,
754,
459,
4405,
995,
754,
459,
4405,
1105,
398,
372,
754,
339,
347,
3405,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
10047,
4874,
9653,
9,
465,
3178,
26,
288,
291,
14,
578,
14,
973,
342,
398,
754,
275,
3178,
14,
1971,
14,
589,
59,
16,
61,
267,
291,
14,
1815,
8,
1099,
459,
4892,
995,
754,
9,
267,
372,
754,
339,
347,
2896,
8,
277,
12,
2896,
29,
797,
304,
267,
543,
291,
14,
1855,
8,
10047,
6699,
9653,
9,
465,
3178,
26,
288,
291,
14,
578,
14,
973,
342,
398,
754,
275,
3178,
14,
1971,
14,
589,
59,
16,
61,
267,
291,
14,
629,
8,
1099,
459,
2489,
995,
2896,
12,
754,
9,
267,
372,
754,
339,
347,
2248,
63,
8769,
8,
277,
12,
3718,
29,
403,
304,
267,
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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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
] |
HybridF5/tempest
|
tempest/tests/lib/common/test_api_version_request.py
|
4
|
6634
|
# Copyright 2014 IBM Corp.
#
# 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 tempest.lib.common import api_version_request
from tempest.lib import exceptions
from tempest.tests.lib import base
class APIVersionRequestTests(base.TestCase):
def test_valid_version_strings(self):
def _test_string(version, exp_major, exp_minor):
v = api_version_request.APIVersionRequest(version)
self.assertEqual(v.ver_major, exp_major)
self.assertEqual(v.ver_minor, exp_minor)
_test_string("1.1", 1, 1)
_test_string("2.10", 2, 10)
_test_string("5.234", 5, 234)
_test_string("12.5", 12, 5)
_test_string("2.0", 2, 0)
_test_string("2.200", 2, 200)
def test_null_version(self):
v = api_version_request.APIVersionRequest()
self.assertTrue(v.is_null())
def test_invalid_version_strings(self):
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "2")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "200")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "2.1.4")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "200.23.66.3")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "5 .3")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "5. 3")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "5.03")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "02.1")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "2.001")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, " 2.1")
self.assertRaises(exceptions.InvalidAPIVersionString,
api_version_request.APIVersionRequest, "2.1 ")
def test_version_comparisons(self):
vers2_0 = api_version_request.APIVersionRequest("2.0")
vers2_5 = api_version_request.APIVersionRequest("2.5")
vers5_23 = api_version_request.APIVersionRequest("5.23")
v_null = api_version_request.APIVersionRequest()
v_latest = api_version_request.APIVersionRequest('latest')
self.assertTrue(v_null < vers2_5)
self.assertTrue(vers2_0 < vers2_5)
self.assertTrue(vers2_0 <= vers2_5)
self.assertTrue(vers2_0 <= vers2_0)
self.assertTrue(vers2_5 > v_null)
self.assertTrue(vers5_23 > vers2_5)
self.assertTrue(vers2_0 >= vers2_0)
self.assertTrue(vers5_23 >= vers2_5)
self.assertTrue(vers2_0 != vers2_5)
self.assertTrue(vers2_0 == vers2_0)
self.assertTrue(vers2_0 != v_null)
self.assertTrue(v_null == v_null)
self.assertTrue(vers2_0 <= v_latest)
self.assertTrue(vers2_0 != v_latest)
self.assertTrue(v_latest == v_latest)
self.assertRaises(TypeError, vers2_0.__lt__, "2.1")
def test_version_matches(self):
vers2_0 = api_version_request.APIVersionRequest("2.0")
vers2_5 = api_version_request.APIVersionRequest("2.5")
vers2_45 = api_version_request.APIVersionRequest("2.45")
vers3_3 = api_version_request.APIVersionRequest("3.3")
vers3_23 = api_version_request.APIVersionRequest("3.23")
vers4_0 = api_version_request.APIVersionRequest("4.0")
v_null = api_version_request.APIVersionRequest()
v_latest = api_version_request.APIVersionRequest('latest')
def _check_version_matches(version, version1, version2, check=True):
if check:
msg = "Version %s does not matches with [%s - %s] range"
self.assertTrue(version.matches(version1, version2),
msg % (version.get_string(),
version1.get_string(),
version2.get_string()))
else:
msg = "Version %s matches with [%s - %s] range"
self.assertFalse(version.matches(version1, version2),
msg % (version.get_string(),
version1.get_string(),
version2.get_string()))
_check_version_matches(vers2_5, vers2_0, vers2_45)
_check_version_matches(vers2_5, vers2_0, v_null)
_check_version_matches(vers2_0, vers2_0, vers2_5)
_check_version_matches(vers3_3, vers2_5, vers3_3)
_check_version_matches(vers3_3, v_null, vers3_3)
_check_version_matches(vers3_3, v_null, vers4_0)
_check_version_matches(vers2_0, vers2_5, vers2_45, False)
_check_version_matches(vers3_23, vers2_5, vers3_3, False)
_check_version_matches(vers2_5, vers2_45, vers2_0, False)
_check_version_matches(vers2_5, vers2_0, v_latest)
_check_version_matches(v_latest, v_latest, v_latest)
_check_version_matches(vers2_5, v_latest, v_latest, False)
_check_version_matches(v_latest, vers2_0, vers4_0, False)
self.assertRaises(ValueError, v_null.matches, vers2_0, vers2_45)
def test_get_string(self):
vers_string = ["3.23", "latest"]
for ver in vers_string:
ver_obj = api_version_request.APIVersionRequest(ver)
self.assertEqual(ver, ver_obj.get_string())
self.assertIsNotNone(
api_version_request.APIVersionRequest().get_string)
|
apache-2.0
|
[
3,
1898,
6927,
26202,
22304,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
24076,
14,
773,
14,
2330,
492,
2986,
63,
1023,
63,
1069,
199,
504,
24076,
14,
773,
492,
4967,
199,
504,
24076,
14,
2219,
14,
773,
492,
1300,
421,
199,
533,
3261,
3353,
2017,
2925,
8,
1095,
14,
1746,
304,
272,
347,
511,
63,
1078,
63,
1023,
63,
5465,
8,
277,
304,
267,
347,
485,
396,
63,
875,
8,
1023,
12,
1437,
63,
8452,
12,
1437,
63,
11067,
304,
288,
373,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
8,
1023,
9,
288,
291,
14,
629,
8,
86,
14,
422,
63,
8452,
12,
1437,
63,
8452,
9,
288,
291,
14,
629,
8,
86,
14,
422,
63,
11067,
12,
1437,
63,
11067,
9,
398,
485,
396,
63,
875,
480,
17,
14,
17,
401,
413,
12,
413,
9,
267,
485,
396,
63,
875,
480,
18,
14,
709,
401,
499,
12,
1616,
9,
267,
485,
396,
63,
875,
480,
21,
14,
5533,
401,
959,
12,
26569,
9,
267,
485,
396,
63,
875,
480,
713,
14,
21,
401,
3144,
12,
959,
9,
267,
485,
396,
63,
875,
480,
18,
14,
16,
401,
499,
12,
378,
9,
267,
485,
396,
63,
875,
480,
18,
14,
1840,
401,
499,
12,
1926,
9,
339,
347,
511,
63,
2307,
63,
1023,
8,
277,
304,
267,
373,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
342,
267,
291,
14,
1815,
8,
86,
14,
374,
63,
2307,
1012,
339,
347,
511,
63,
3197,
63,
1023,
63,
5465,
8,
277,
304,
267,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
1840,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
17,
14,
20,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
1840,
14,
1789,
14,
1272,
14,
19,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
1275,
19,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
14,
650,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
14,
1644,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
996,
14,
17,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
4587,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
6899,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
499,
14,
17,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
17,
6099,
339,
347,
511,
63,
1023,
63,
863,
15864,
8,
277,
304,
267,
809,
83,
18,
63,
16,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
18,
14,
16,
531,
267,
809,
83,
18,
63,
21,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
18,
14,
21,
531,
267,
809,
83,
21,
63,
1789,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
21,
14,
1789,
531,
267,
373,
63,
2307,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
342,
267,
373,
63,
7410,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
360,
7410,
358,
398,
291,
14,
1815,
8,
86,
63,
2307,
665,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
665,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2695,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2695,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
21,
690,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
14895,
21,
63,
1789,
690,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2356,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
21,
63,
1789,
2356,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
1137,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
508,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
1137,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
86,
63,
2307,
508,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16
] |
[
1898,
6927,
26202,
22304,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
24076,
14,
773,
14,
2330,
492,
2986,
63,
1023,
63,
1069,
199,
504,
24076,
14,
773,
492,
4967,
199,
504,
24076,
14,
2219,
14,
773,
492,
1300,
421,
199,
533,
3261,
3353,
2017,
2925,
8,
1095,
14,
1746,
304,
272,
347,
511,
63,
1078,
63,
1023,
63,
5465,
8,
277,
304,
267,
347,
485,
396,
63,
875,
8,
1023,
12,
1437,
63,
8452,
12,
1437,
63,
11067,
304,
288,
373,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
8,
1023,
9,
288,
291,
14,
629,
8,
86,
14,
422,
63,
8452,
12,
1437,
63,
8452,
9,
288,
291,
14,
629,
8,
86,
14,
422,
63,
11067,
12,
1437,
63,
11067,
9,
398,
485,
396,
63,
875,
480,
17,
14,
17,
401,
413,
12,
413,
9,
267,
485,
396,
63,
875,
480,
18,
14,
709,
401,
499,
12,
1616,
9,
267,
485,
396,
63,
875,
480,
21,
14,
5533,
401,
959,
12,
26569,
9,
267,
485,
396,
63,
875,
480,
713,
14,
21,
401,
3144,
12,
959,
9,
267,
485,
396,
63,
875,
480,
18,
14,
16,
401,
499,
12,
378,
9,
267,
485,
396,
63,
875,
480,
18,
14,
1840,
401,
499,
12,
1926,
9,
339,
347,
511,
63,
2307,
63,
1023,
8,
277,
304,
267,
373,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
342,
267,
291,
14,
1815,
8,
86,
14,
374,
63,
2307,
1012,
339,
347,
511,
63,
3197,
63,
1023,
63,
5465,
8,
277,
304,
267,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
1840,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
17,
14,
20,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
1840,
14,
1789,
14,
1272,
14,
19,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
1275,
19,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
14,
650,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
21,
14,
1644,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
996,
14,
17,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
4587,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
6899,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
499,
14,
17,
531,
398,
291,
14,
1855,
8,
3924,
14,
3364,
3735,
3353,
1558,
12,
2079,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
12,
298,
18,
14,
17,
6099,
339,
347,
511,
63,
1023,
63,
863,
15864,
8,
277,
304,
267,
809,
83,
18,
63,
16,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
18,
14,
16,
531,
267,
809,
83,
18,
63,
21,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
18,
14,
21,
531,
267,
809,
83,
21,
63,
1789,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
480,
21,
14,
1789,
531,
267,
373,
63,
2307,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
342,
267,
373,
63,
7410,
275,
2986,
63,
1023,
63,
1069,
14,
3735,
3353,
2017,
360,
7410,
358,
398,
291,
14,
1815,
8,
86,
63,
2307,
665,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
665,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2695,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2695,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
21,
690,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
14895,
21,
63,
1789,
690,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
2356,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
21,
63,
1789,
2356,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
1137,
809,
83,
18,
63,
21,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
508,
809,
83,
18,
63,
16,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
1137,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
86,
63,
2307,
508,
373,
63,
2307,
9,
267,
291,
14,
1815,
8,
14895,
18,
63,
16,
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,
1
] |
tangkun75/docker-registry
|
depends/docker-registry-core/docker_registry/core/boto.py
|
27
|
4825
|
# -*- coding: utf-8 -*-
# Copyright (c) 2014 Docker.
#
# 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.
"""
docker_registry.core.boto
~~~~~~~~~~~~~~~~~~~~~~~~~~
Might be useful for
* Amazon Simple Storage Service (S3)
* Google Cloud Storage
* Amazon Glacier
* Amazon Elastic Block Store (EBS)
"""
import gevent.monkey
gevent.monkey.patch_all()
import logging
import os
from . import driver
from . import lru
from .exceptions import FileNotFoundError
logger = logging.getLogger(__name__)
class Base(driver.Base):
supports_bytes_range = True
def __init__(self, path=None, config=None):
self._config = config
self._root_path = path or '/test'
self._boto_conn = self.makeConnection()
self._boto_bucket = self._boto_conn.get_bucket(
self._config.boto_bucket)
logger.info("Boto based storage initialized")
def _build_connection_params(self):
kwargs = {'is_secure': (self._config.s3_secure is True)}
config_args = [
'host', 'port', 'debug',
'proxy', 'proxy_port',
'proxy_user', 'proxy_pass',
'calling_format'
]
for arg in config_args:
confkey = 'boto_' + arg
if getattr(self._config, confkey, None) is not None:
kwargs[arg] = getattr(self._config, confkey)
return kwargs
def _debug_key(self, key):
"""Used for debugging only."""
orig_meth = key.bucket.connection.make_request
def new_meth(*args, **kwargs):
print('#' * 16)
print(args)
print(kwargs)
print('#' * 16)
return orig_meth(*args, **kwargs)
key.bucket.connection.make_request = new_meth
def _init_path(self, path=None):
path = os.path.join(self._root_path, path) if path else self._root_path
if path and path[0] == '/':
return path[1:]
return path
def stream_read(self, path, bytes_range=None):
path = self._init_path(path)
headers = None
if bytes_range:
headers = {'Range': 'bytes={0}-{1}'.format(*bytes_range)}
key = self._boto_bucket.lookup(path, headers=headers)
if not key:
raise FileNotFoundError('%s is not there' % path)
while True:
buf = key.read(self.buffer_size)
if not buf:
break
yield buf
def list_directory(self, path=None):
path = self._init_path(path)
if not path.endswith('/'):
path += '/'
ln = 0
if self._root_path != '/':
ln = len(self._root_path)
exists = False
for key in self._boto_bucket.list(prefix=path, delimiter='/'):
if '%s/' % key.name == path:
continue
exists = True
name = key.name
if name.endswith('/'):
yield name[ln:-1]
else:
yield name[ln:]
if not exists:
raise FileNotFoundError('%s is not there' % path)
def get_size(self, path):
path = self._init_path(path)
# Lookup does a HEAD HTTP Request on the object
key = self._boto_bucket.lookup(path)
if not key:
raise FileNotFoundError('%s is not there' % path)
return key.size
@lru.get
def get_content(self, path):
path = self._init_path(path)
key = self.makeKey(path)
if not key.exists():
raise FileNotFoundError('%s is not there' % path)
return key.get_contents_as_string()
def exists(self, path):
path = self._init_path(path)
key = self.makeKey(path)
return key.exists()
@lru.remove
def remove(self, path):
path = self._init_path(path)
key = self.makeKey(path)
if key.exists():
# It's a file
key.delete()
return
# We assume it's a directory
if not path.endswith('/'):
path += '/'
exists = False
for key in self._boto_bucket.list(prefix=path, delimiter='/'):
if '%s/' % key.name == path:
continue
exists = True
key.delete()
if not exists:
raise FileNotFoundError('%s is not there' % path)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
6927,
22067,
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,
259,
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,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
624,
199,
9991,
63,
5189,
14,
1018,
14,
10914,
199,
9753,
4919,
1714,
199,
199,
45,
1070,
506,
2997,
367,
199,
627,
14347,
5870,
10533,
7591,
334,
51,
19,
9,
199,
627,
4475,
8142,
10533,
199,
627,
14347,
598,
19976,
281,
199,
627,
14347,
19509,
8651,
13874,
334,
37,
11087,
9,
199,
199,
624,
199,
199,
646,
23386,
14,
20372,
199,
303,
782,
14,
20372,
14,
2068,
63,
452,
342,
199,
199,
646,
2050,
199,
646,
747,
199,
199,
504,
1275,
492,
5253,
199,
504,
1275,
492,
634,
6558,
199,
504,
1275,
3924,
492,
3814,
10870,
199,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
3523,
8,
3090,
14,
1563,
304,
339,
5171,
63,
2394,
63,
1842,
275,
715,
339,
347,
636,
826,
721,
277,
12,
931,
29,
403,
12,
1101,
29,
403,
304,
267,
291,
423,
888,
275,
1101,
267,
291,
423,
1231,
63,
515,
275,
931,
503,
1994,
396,
7,
267,
291,
423,
10914,
63,
1631,
275,
291,
14,
1875,
3225,
342,
267,
291,
423,
10914,
63,
4623,
275,
291,
423,
10914,
63,
1631,
14,
362,
63,
4623,
8,
288,
291,
423,
888,
14,
10914,
63,
4623,
9,
267,
2512,
14,
815,
480,
20380,
4079,
4887,
10038,
531,
339,
347,
485,
1506,
63,
2105,
63,
1162,
8,
277,
304,
267,
2074,
275,
791,
374,
63,
7817,
356,
334,
277,
423,
888,
14,
83,
19,
63,
7817,
365,
715,
6769,
267,
1101,
63,
589,
275,
359,
288,
283,
1102,
297,
283,
719,
297,
283,
1757,
297,
288,
283,
3280,
297,
283,
3280,
63,
719,
297,
288,
283,
3280,
63,
751,
297,
283,
3280,
63,
1529,
297,
288,
283,
25566,
63,
908,
7,
267,
1622,
267,
367,
1680,
315,
1101,
63,
589,
26,
288,
3743,
498,
275,
283,
10914,
8650,
435,
1680,
288,
340,
2519,
8,
277,
423,
888,
12,
3743,
498,
12,
488,
9,
365,
440,
488,
26,
355,
2074,
59,
1273,
61,
275,
2519,
8,
277,
423,
888,
12,
3743,
498,
9,
267,
372,
2074,
339,
347,
485,
1757,
63,
498,
8,
277,
12,
790,
304,
267,
408,
9167,
367,
10201,
1454,
1041,
267,
2306,
63,
5247,
275,
790,
14,
4623,
14,
2105,
14,
1875,
63,
1069,
398,
347,
892,
63,
5247,
2031,
589,
12,
1011,
958,
304,
288,
870,
7863,
7,
627,
3193,
9,
288,
870,
8,
589,
9,
288,
870,
8,
958,
9,
288,
870,
7863,
7,
627,
3193,
9,
288,
372,
2306,
63,
5247,
2031,
589,
12,
1011,
958,
9,
267,
790,
14,
4623,
14,
2105,
14,
1875,
63,
1069,
275,
892,
63,
5247,
339,
347,
485,
826,
63,
515,
8,
277,
12,
931,
29,
403,
304,
267,
931,
275,
747,
14,
515,
14,
904,
8,
277,
423,
1231,
63,
515,
12,
931,
9,
340,
931,
587,
291,
423,
1231,
63,
515,
267,
340,
931,
436,
931,
59,
16,
61,
508,
20549,
288,
372,
931,
59,
17,
2938,
267,
372,
931,
339,
347,
2547,
63,
739,
8,
277,
12,
931,
12,
2783,
63,
1842,
29,
403,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
2323,
275,
488,
267,
340,
2783,
63,
1842,
26,
288,
2323,
275,
791,
4709,
356,
283,
2394,
3126,
16,
30289,
17,
5285,
908,
2031,
2394,
63,
1842,
6769,
267,
790,
275,
291,
423,
10914,
63,
4623,
14,
3892,
8,
515,
12,
2323,
29,
2139,
9,
267,
340,
440,
790,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
1830,
715,
26,
288,
4123,
275,
790,
14,
739,
8,
277,
14,
2738,
63,
890,
9,
288,
340,
440,
4123,
26,
355,
2059,
288,
1995,
4123,
339,
347,
769,
63,
3619,
8,
277,
12,
931,
29,
403,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
340,
440,
931,
14,
4130,
18265,
288,
931,
847,
7324,
267,
10359,
275,
378,
267,
340,
291,
423,
1231,
63,
515,
1137,
20549,
288,
10359,
275,
822,
8,
277,
423,
1231,
63,
515,
9,
267,
3495,
275,
756,
267,
367,
790,
315,
291,
423,
10914,
63,
4623,
14,
513,
8,
1861,
29,
515,
12,
11172,
8805,
735,
288,
340,
1543,
83,
4805,
450,
790,
14,
354,
508,
931,
26,
355,
1980,
288,
3495,
275,
715,
288,
536,
275,
790,
14,
354,
288,
340,
536,
14,
4130,
18265,
355,
1995,
536,
59,
6066,
6809,
17,
61,
288,
587,
26,
355,
1995,
536,
59,
6066,
2938,
267,
340,
440,
3495,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
339,
347,
664,
63,
890,
8,
277,
12,
931,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
327,
12785,
1630,
282,
13053,
3101,
4784,
641,
314,
909,
267,
790,
275,
291,
423,
10914,
63,
4623,
14,
3892,
8,
515,
9,
267,
340,
440,
790,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
372,
790,
14,
890,
339,
768,
25003,
14,
362,
272,
347,
664,
63,
1317,
8,
277,
12,
931,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
790,
275,
291,
14,
1875,
1197,
8,
515,
9,
267,
340,
440,
790,
14,
2444,
837,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
372,
790,
14
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
6927,
22067,
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,
259,
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,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
624,
199,
9991,
63,
5189,
14,
1018,
14,
10914,
199,
9753,
4919,
1714,
199,
199,
45,
1070,
506,
2997,
367,
199,
627,
14347,
5870,
10533,
7591,
334,
51,
19,
9,
199,
627,
4475,
8142,
10533,
199,
627,
14347,
598,
19976,
281,
199,
627,
14347,
19509,
8651,
13874,
334,
37,
11087,
9,
199,
199,
624,
199,
199,
646,
23386,
14,
20372,
199,
303,
782,
14,
20372,
14,
2068,
63,
452,
342,
199,
199,
646,
2050,
199,
646,
747,
199,
199,
504,
1275,
492,
5253,
199,
504,
1275,
492,
634,
6558,
199,
504,
1275,
3924,
492,
3814,
10870,
199,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
3523,
8,
3090,
14,
1563,
304,
339,
5171,
63,
2394,
63,
1842,
275,
715,
339,
347,
636,
826,
721,
277,
12,
931,
29,
403,
12,
1101,
29,
403,
304,
267,
291,
423,
888,
275,
1101,
267,
291,
423,
1231,
63,
515,
275,
931,
503,
1994,
396,
7,
267,
291,
423,
10914,
63,
1631,
275,
291,
14,
1875,
3225,
342,
267,
291,
423,
10914,
63,
4623,
275,
291,
423,
10914,
63,
1631,
14,
362,
63,
4623,
8,
288,
291,
423,
888,
14,
10914,
63,
4623,
9,
267,
2512,
14,
815,
480,
20380,
4079,
4887,
10038,
531,
339,
347,
485,
1506,
63,
2105,
63,
1162,
8,
277,
304,
267,
2074,
275,
791,
374,
63,
7817,
356,
334,
277,
423,
888,
14,
83,
19,
63,
7817,
365,
715,
6769,
267,
1101,
63,
589,
275,
359,
288,
283,
1102,
297,
283,
719,
297,
283,
1757,
297,
288,
283,
3280,
297,
283,
3280,
63,
719,
297,
288,
283,
3280,
63,
751,
297,
283,
3280,
63,
1529,
297,
288,
283,
25566,
63,
908,
7,
267,
1622,
267,
367,
1680,
315,
1101,
63,
589,
26,
288,
3743,
498,
275,
283,
10914,
8650,
435,
1680,
288,
340,
2519,
8,
277,
423,
888,
12,
3743,
498,
12,
488,
9,
365,
440,
488,
26,
355,
2074,
59,
1273,
61,
275,
2519,
8,
277,
423,
888,
12,
3743,
498,
9,
267,
372,
2074,
339,
347,
485,
1757,
63,
498,
8,
277,
12,
790,
304,
267,
408,
9167,
367,
10201,
1454,
1041,
267,
2306,
63,
5247,
275,
790,
14,
4623,
14,
2105,
14,
1875,
63,
1069,
398,
347,
892,
63,
5247,
2031,
589,
12,
1011,
958,
304,
288,
870,
7863,
7,
627,
3193,
9,
288,
870,
8,
589,
9,
288,
870,
8,
958,
9,
288,
870,
7863,
7,
627,
3193,
9,
288,
372,
2306,
63,
5247,
2031,
589,
12,
1011,
958,
9,
267,
790,
14,
4623,
14,
2105,
14,
1875,
63,
1069,
275,
892,
63,
5247,
339,
347,
485,
826,
63,
515,
8,
277,
12,
931,
29,
403,
304,
267,
931,
275,
747,
14,
515,
14,
904,
8,
277,
423,
1231,
63,
515,
12,
931,
9,
340,
931,
587,
291,
423,
1231,
63,
515,
267,
340,
931,
436,
931,
59,
16,
61,
508,
20549,
288,
372,
931,
59,
17,
2938,
267,
372,
931,
339,
347,
2547,
63,
739,
8,
277,
12,
931,
12,
2783,
63,
1842,
29,
403,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
2323,
275,
488,
267,
340,
2783,
63,
1842,
26,
288,
2323,
275,
791,
4709,
356,
283,
2394,
3126,
16,
30289,
17,
5285,
908,
2031,
2394,
63,
1842,
6769,
267,
790,
275,
291,
423,
10914,
63,
4623,
14,
3892,
8,
515,
12,
2323,
29,
2139,
9,
267,
340,
440,
790,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
1830,
715,
26,
288,
4123,
275,
790,
14,
739,
8,
277,
14,
2738,
63,
890,
9,
288,
340,
440,
4123,
26,
355,
2059,
288,
1995,
4123,
339,
347,
769,
63,
3619,
8,
277,
12,
931,
29,
403,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
340,
440,
931,
14,
4130,
18265,
288,
931,
847,
7324,
267,
10359,
275,
378,
267,
340,
291,
423,
1231,
63,
515,
1137,
20549,
288,
10359,
275,
822,
8,
277,
423,
1231,
63,
515,
9,
267,
3495,
275,
756,
267,
367,
790,
315,
291,
423,
10914,
63,
4623,
14,
513,
8,
1861,
29,
515,
12,
11172,
8805,
735,
288,
340,
1543,
83,
4805,
450,
790,
14,
354,
508,
931,
26,
355,
1980,
288,
3495,
275,
715,
288,
536,
275,
790,
14,
354,
288,
340,
536,
14,
4130,
18265,
355,
1995,
536,
59,
6066,
6809,
17,
61,
288,
587,
26,
355,
1995,
536,
59,
6066,
2938,
267,
340,
440,
3495,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
339,
347,
664,
63,
890,
8,
277,
12,
931,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
327,
12785,
1630,
282,
13053,
3101,
4784,
641,
314,
909,
267,
790,
275,
291,
423,
10914,
63,
4623,
14,
3892,
8,
515,
9,
267,
340,
440,
790,
26,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
372,
790,
14,
890,
339,
768,
25003,
14,
362,
272,
347,
664,
63,
1317,
8,
277,
12,
931,
304,
267,
931,
275,
291,
423,
826,
63,
515,
8,
515,
9,
267,
790,
275,
291,
14,
1875,
1197,
8,
515,
9,
267,
340,
440,
790,
14,
2444,
837,
288,
746,
3814,
10870,
3508,
83,
365,
440,
2337,
7,
450,
931,
9,
267,
372,
790,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
amchoukir/ycmd
|
build.py
|
1
|
6445
|
#!/usr/bin/env python
import os
import os.path as p
import sys
major, minor = sys.version_info[ 0 : 2 ]
if major != 2 or minor < 6:
sys.exit( 'The build script requires Python version >= 2.6 and < 3.0; '
'your version of Python is ' + sys.version )
DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
for folder in os.listdir( DIR_OF_THIRD_PARTY ):
abs_folder_path = p.join( DIR_OF_THIRD_PARTY, folder )
if p.isdir( abs_folder_path ) and not os.listdir( abs_folder_path ):
sys.exit( 'Some folders in ' + DIR_OF_THIRD_PARTY + ' are empty; '
'you probably forgot to run:'
'\n\tgit submodule update --init --recursive\n\n' )
sys.path.insert( 0, p.abspath( p.join( DIR_OF_THIRD_PARTY, 'sh' ) ) )
sys.path.insert( 0, p.abspath( p.join( DIR_OF_THIRD_PARTY, 'argparse' ) ) )
import sh
import platform
import argparse
import multiprocessing
from distutils.spawn import find_executable
def OnMac():
return platform.system() == 'Darwin'
def PathToFirstExistingExecutable( executable_name_list ):
for executable_name in executable_name_list:
path = find_executable( executable_name )
if path:
return path
return None
def NumCores():
ycm_cores = os.environ.get( 'YCM_CORES' )
if ycm_cores:
return int( ycm_cores )
try:
return multiprocessing.cpu_count()
except NotImplementedError:
return 1
def CheckDeps():
if not PathToFirstExistingExecutable( [ 'cmake' ] ):
sys.exit( 'Please install CMake and retry.')
def CustomPythonCmakeArgs():
# The CMake 'FindPythonLibs' Module does not work properly.
# So we are forced to do its job for it.
python_prefix = sh.python_config( '--prefix' ).strip()
if p.isfile( p.join( python_prefix, '/Python' ) ):
python_library = p.join( python_prefix, '/Python' )
python_include = p.join( python_prefix, '/Headers' )
else:
which_python = sh.python(
'-c',
'import sys;i=sys.version_info;print "python%d.%d" % (i[0], i[1])'
).strip()
lib_python = '{0}/lib/lib{1}'.format( python_prefix, which_python ).strip()
if p.isfile( '{0}.a'.format( lib_python ) ):
python_library = '{0}.a'.format( lib_python )
# This check is for CYGWIN
elif p.isfile( '{0}.dll.a'.format( lib_python ) ):
python_library = '{0}.dll.a'.format( lib_python )
else:
python_library = '{0}.dylib'.format( lib_python )
python_include = '{0}/include/{1}'.format( python_prefix, which_python )
python_executable = '{0}/bin/python'.format( python_prefix )
return [
'-DPYTHON_LIBRARY={0}'.format( python_library ),
'-DPYTHON_INCLUDE_DIR={0}'.format( python_include ),
'-DPYTHON_EXECUTABLE={0}'.format( python_executable )
]
def ParseArguments():
parser = argparse.ArgumentParser()
parser.add_argument( '--clang-completer', action = 'store_true',
help = 'Build C-family semantic completion engine.')
parser.add_argument( '--system-libclang', action = 'store_true',
help = 'Use system libclang instead of downloading one '
'from llvm.org. NOT RECOMMENDED OR SUPPORTED!' )
parser.add_argument( '--omnisharp-completer', action = 'store_true',
help = 'Build C# semantic completion engine.' )
parser.add_argument( '--gocode-completer', action = 'store_true',
help = 'Build Go semantic completion engine.' )
parser.add_argument( '--system-boost', action = 'store_true',
help = 'Use the system boost instead of bundled one. '
'NOT RECOMMENDED OR SUPPORTED!')
args = parser.parse_args()
if args.system_libclang and not args.clang_completer:
sys.exit( "You can't pass --system-libclang without also passing "
"--clang-completer as well." )
return args
def GetCmakeArgs( parsed_args ):
cmake_args = []
if parsed_args.clang_completer:
cmake_args.append( '-DUSE_CLANG_COMPLETER=ON' )
if parsed_args.system_libclang:
cmake_args.append( '-DUSE_SYSTEM_LIBCLANG=ON' )
if parsed_args.system_boost:
cmake_args.append( '-DUSE_SYSTEM_BOOST=ON' )
extra_cmake_args = os.environ.get( 'EXTRA_CMAKE_ARGS', '' )
cmake_args.extend( extra_cmake_args.split() )
return cmake_args
def RunYcmdTests( build_dir ):
tests_dir = p.join( build_dir, 'ycm/tests' )
sh.cd( tests_dir )
new_env = os.environ.copy()
new_env[ 'LD_LIBRARY_PATH' ] = DIR_OF_THIS_SCRIPT
sh.Command( p.join( tests_dir, 'ycm_core_tests' ) )(
_env = new_env, _out = sys.stdout )
def BuildYcmdLibs( cmake_args ):
build_dir = unicode( sh.mktemp( '-d', '-t', 'ycm_build.XXXXXX' ) ).strip()
try:
full_cmake_args = [ '-G', 'Unix Makefiles' ]
if OnMac():
full_cmake_args.extend( CustomPythonCmakeArgs() )
full_cmake_args.extend( cmake_args )
full_cmake_args.append( p.join( DIR_OF_THIS_SCRIPT, 'cpp' ) )
sh.cd( build_dir )
sh.cmake( *full_cmake_args, _out = sys.stdout )
build_target = ( 'ycm_support_libs' if 'YCM_TESTRUN' not in os.environ else
'ycm_core_tests' )
sh.make( '-j', NumCores(), build_target, _out = sys.stdout,
_err = sys.stderr )
if 'YCM_TESTRUN' in os.environ:
RunYcmdTests( build_dir )
finally:
sh.cd( DIR_OF_THIS_SCRIPT )
sh.rm( '-rf', build_dir )
def BuildOmniSharp():
build_command = PathToFirstExistingExecutable(
[ 'msbuild', 'msbuild.exe', 'xbuild' ] )
if not build_command:
sys.exit( 'msbuild or xbuild is required to build Omnisharp' )
sh.cd( p.join( DIR_OF_THIS_SCRIPT, 'third_party/OmniSharpServer' ) )
sh.Command( build_command )( "/property:Configuration=Release", _out = sys.stdout )
def BuildGoCode():
if not find_executable( 'go' ):
sys.exit( 'go is required to build gocode' )
sh.cd( p.join( DIR_OF_THIS_SCRIPT, 'third_party/gocode' ) )
sh.Command( 'go' )( 'build', _out = sys.stdout )
def ApplyWorkarounds():
# Some OSs define a 'make' ENV VAR and this confuses sh when we try to do
# sh.make. See https://github.com/Valloric/YouCompleteMe/issues/1401
os.environ.pop('make', None)
def Main():
ApplyWorkarounds()
CheckDeps()
args = ParseArguments()
BuildYcmdLibs( GetCmakeArgs( args ) )
if args.omnisharp_completer:
BuildOmniSharp()
if args.gocode_completer:
BuildGoCode()
if __name__ == "__main__":
Main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
747,
14,
515,
465,
299,
199,
646,
984,
199,
199,
8452,
12,
12612,
275,
984,
14,
1023,
63,
815,
59,
378,
520,
499,
1622,
199,
692,
12160,
1137,
499,
503,
12612,
665,
1227,
26,
523,
984,
14,
2224,
8,
283,
1918,
1900,
2884,
5074,
2018,
1015,
2356,
499,
14,
22,
436,
665,
650,
14,
16,
27,
283,
288,
283,
12695,
1015,
402,
2018,
365,
283,
435,
984,
14,
1023,
776,
199,
199,
3022,
63,
3359,
63,
24571,
63,
10484,
275,
299,
14,
3475,
8,
299,
14,
4832,
8,
636,
493,
363,
776,
776,
199,
3022,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
275,
299,
14,
904,
8,
19253,
63,
3359,
63,
24571,
63,
10484,
12,
283,
11470,
63,
7522,
7,
776,
199,
199,
509,
4922,
315,
747,
14,
7374,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
3461,
523,
2853,
63,
3741,
63,
515,
275,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
4922,
776,
523,
340,
299,
14,
6027,
8,
2853,
63,
3741,
63,
515,
776,
436,
440,
747,
14,
7374,
8,
2853,
63,
3741,
63,
515,
3461,
272,
984,
14,
2224,
8,
283,
7700,
16533,
315,
283,
435,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
435,
283,
787,
2701,
27,
283,
1598,
283,
13297,
8646,
367,
7808,
370,
1255,
4881,
1598,
1557,
78,
60,
84,
3187,
22988,
1678,
1553,
826,
1553,
9931,
60,
78,
60,
78,
7,
776,
199,
199,
1274,
14,
515,
14,
3176,
8,
378,
12,
299,
14,
4832,
8,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
283,
609,
7,
776,
776,
776,
199,
1274,
14,
515,
14,
3176,
8,
378,
12,
299,
14,
4832,
8,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
283,
18978,
7,
776,
776,
776,
199,
199,
646,
1033,
199,
646,
4298,
199,
646,
7534,
199,
646,
12866,
199,
504,
7065,
14,
10212,
492,
2342,
63,
5904,
421,
199,
318,
4068,
3399,
837,
523,
372,
4298,
14,
2253,
342,
508,
283,
31065,
7,
421,
199,
318,
6912,
1378,
7147,
23490,
18039,
8,
7286,
63,
354,
63,
513,
3461,
523,
367,
7286,
63,
354,
315,
7286,
63,
354,
63,
513,
26,
272,
931,
275,
2342,
63,
5904,
8,
7286,
63,
354,
776,
272,
340,
931,
26,
489,
372,
931,
523,
372,
488,
421,
199,
318,
16817,
967,
470,
837,
523,
612,
4400,
63,
4630,
275,
747,
14,
2314,
14,
362,
8,
283,
57,
9249,
63,
18650,
654,
7,
776,
523,
340,
612,
4400,
63,
4630,
26,
272,
372,
1109,
8,
612,
4400,
63,
4630,
776,
523,
862,
26,
272,
372,
12866,
14,
3541,
63,
835,
342,
523,
871,
4279,
26,
272,
372,
413,
421,
199,
318,
2670,
27683,
837,
523,
340,
440,
6912,
1378,
7147,
23490,
18039,
8,
359,
283,
16472,
7,
1622,
3461,
272,
984,
14,
2224,
8,
283,
8254,
3907,
21355,
436,
7269,
2659,
421,
199,
318,
8388,
4718,
35,
1875,
6213,
837,
523,
327,
710,
21355,
283,
6591,
4718,
13009,
1533,
7,
5673,
1630,
440,
1736,
7684,
14,
523,
327,
2002,
781,
787,
19565,
370,
886,
2399,
3906,
367,
652,
14,
819,
2366,
63,
1861,
275,
1033,
14,
1548,
63,
888,
8,
2850,
1861,
7,
7092,
1913,
342,
523,
340,
299,
14,
6292,
8,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
4718,
7,
776,
3461,
272,
2366,
63,
4342,
275,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
4718,
7,
776,
272,
2366,
63,
2613,
275,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
9883,
7,
776,
523,
587,
26,
272,
1314,
63,
1548,
275,
1033,
14,
1548,
8,
489,
2475,
67,
297,
489,
283,
646,
984,
27,
73,
29,
1274,
14,
1023,
63,
815,
27,
1361,
298,
1548,
5,
68,
4111,
68,
2,
450,
334,
73,
59,
16,
467,
284,
59,
17,
566,
7,
489,
7092,
1913,
342,
272,
1973,
63,
1548,
275,
5041,
16,
5995,
773,
15,
773,
91,
17,
5285,
908,
8,
2366,
63,
1861,
12,
1314,
63,
1548,
7092,
1913,
342,
339,
340,
299,
14,
6292,
8,
5041,
16,
5565,
65,
1370,
908,
8,
1973,
63,
1548,
776,
3461,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
65,
1370,
908,
8,
1973,
63,
1548,
776,
272,
327,
961,
1104,
365,
367,
445,
57,
39,
7941,
272,
916,
299,
14,
6292,
8,
5041,
16,
5565,
9259,
14,
65,
1370,
908,
8,
1973,
63,
1548,
776,
3461,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
9259,
14,
65,
1370,
908,
8,
1973,
63,
1548,
776,
272,
587,
26,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
22305,
1370,
908,
8,
1973,
63,
1548,
776,
272,
2366,
63,
2613,
275,
5041,
16,
5995,
2613,
5321,
17,
5285,
908,
8,
2366,
63,
1861,
12,
1314,
63,
1548,
776,
272,
2366,
63,
5904,
275,
5041,
16,
5995,
1393,
15,
1548,
1370,
908,
8,
2366,
63,
1861,
776,
819,
372,
359,
272,
2475,
36,
11720,
63,
16983,
3126,
16,
5285,
908,
8,
2366,
63,
4342,
2318,
272,
2475,
36,
11720,
63,
18171,
63,
3022,
3126,
16,
5285,
908,
8,
2366,
63,
2613,
2318,
272,
2475,
36,
11720,
63,
21623,
3126,
16,
5285,
908,
8,
2366,
63,
5904,
776,
523,
1622,
421,
199,
318,
6077,
14517,
837,
523,
1798,
275,
7534,
14,
10730,
342,
523,
1798,
14,
525,
63,
2094,
8,
2850,
16066,
13,
18452,
297,
1595,
275,
283,
1617,
63,
2052,
297,
2432,
1720,
275,
283,
3425,
445,
13,
6606,
32451,
13659,
6869,
2659,
523,
1798,
14,
525,
63,
2094,
8,
2850,
2253,
13,
773,
16066,
297,
1595,
275,
283,
1617,
63,
2052,
297,
2432,
1720,
275,
283,
6119,
2656,
1973,
16066,
3140,
402,
25937,
1373,
283,
2432,
283,
504,
18338,
2611,
14,
1308,
14,
2845,
5363,
5378,
25518,
1549,
32501,
11213,
776,
523,
1798,
14,
525,
63,
2094,
8,
2850,
676,
78,
2453,
12868,
13,
18452,
297,
1595,
275,
283,
1617,
63,
2052,
297,
2432,
1720,
275,
283,
3425,
445,
3,
32451,
13659,
6869,
3530,
776,
523,
1798,
14,
525,
63,
2094,
8,
2850,
1939,
600,
13
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
747,
14,
515,
465,
299,
199,
646,
984,
199,
199,
8452,
12,
12612,
275,
984,
14,
1023,
63,
815,
59,
378,
520,
499,
1622,
199,
692,
12160,
1137,
499,
503,
12612,
665,
1227,
26,
523,
984,
14,
2224,
8,
283,
1918,
1900,
2884,
5074,
2018,
1015,
2356,
499,
14,
22,
436,
665,
650,
14,
16,
27,
283,
288,
283,
12695,
1015,
402,
2018,
365,
283,
435,
984,
14,
1023,
776,
199,
199,
3022,
63,
3359,
63,
24571,
63,
10484,
275,
299,
14,
3475,
8,
299,
14,
4832,
8,
636,
493,
363,
776,
776,
199,
3022,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
275,
299,
14,
904,
8,
19253,
63,
3359,
63,
24571,
63,
10484,
12,
283,
11470,
63,
7522,
7,
776,
199,
199,
509,
4922,
315,
747,
14,
7374,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
3461,
523,
2853,
63,
3741,
63,
515,
275,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
4922,
776,
523,
340,
299,
14,
6027,
8,
2853,
63,
3741,
63,
515,
776,
436,
440,
747,
14,
7374,
8,
2853,
63,
3741,
63,
515,
3461,
272,
984,
14,
2224,
8,
283,
7700,
16533,
315,
283,
435,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
435,
283,
787,
2701,
27,
283,
1598,
283,
13297,
8646,
367,
7808,
370,
1255,
4881,
1598,
1557,
78,
60,
84,
3187,
22988,
1678,
1553,
826,
1553,
9931,
60,
78,
60,
78,
7,
776,
199,
199,
1274,
14,
515,
14,
3176,
8,
378,
12,
299,
14,
4832,
8,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
283,
609,
7,
776,
776,
776,
199,
1274,
14,
515,
14,
3176,
8,
378,
12,
299,
14,
4832,
8,
299,
14,
904,
8,
19253,
63,
3359,
63,
2080,
3927,
36,
63,
4014,
2099,
12,
283,
18978,
7,
776,
776,
776,
199,
199,
646,
1033,
199,
646,
4298,
199,
646,
7534,
199,
646,
12866,
199,
504,
7065,
14,
10212,
492,
2342,
63,
5904,
421,
199,
318,
4068,
3399,
837,
523,
372,
4298,
14,
2253,
342,
508,
283,
31065,
7,
421,
199,
318,
6912,
1378,
7147,
23490,
18039,
8,
7286,
63,
354,
63,
513,
3461,
523,
367,
7286,
63,
354,
315,
7286,
63,
354,
63,
513,
26,
272,
931,
275,
2342,
63,
5904,
8,
7286,
63,
354,
776,
272,
340,
931,
26,
489,
372,
931,
523,
372,
488,
421,
199,
318,
16817,
967,
470,
837,
523,
612,
4400,
63,
4630,
275,
747,
14,
2314,
14,
362,
8,
283,
57,
9249,
63,
18650,
654,
7,
776,
523,
340,
612,
4400,
63,
4630,
26,
272,
372,
1109,
8,
612,
4400,
63,
4630,
776,
523,
862,
26,
272,
372,
12866,
14,
3541,
63,
835,
342,
523,
871,
4279,
26,
272,
372,
413,
421,
199,
318,
2670,
27683,
837,
523,
340,
440,
6912,
1378,
7147,
23490,
18039,
8,
359,
283,
16472,
7,
1622,
3461,
272,
984,
14,
2224,
8,
283,
8254,
3907,
21355,
436,
7269,
2659,
421,
199,
318,
8388,
4718,
35,
1875,
6213,
837,
523,
327,
710,
21355,
283,
6591,
4718,
13009,
1533,
7,
5673,
1630,
440,
1736,
7684,
14,
523,
327,
2002,
781,
787,
19565,
370,
886,
2399,
3906,
367,
652,
14,
819,
2366,
63,
1861,
275,
1033,
14,
1548,
63,
888,
8,
2850,
1861,
7,
7092,
1913,
342,
523,
340,
299,
14,
6292,
8,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
4718,
7,
776,
3461,
272,
2366,
63,
4342,
275,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
4718,
7,
776,
272,
2366,
63,
2613,
275,
299,
14,
904,
8,
2366,
63,
1861,
12,
1994,
9883,
7,
776,
523,
587,
26,
272,
1314,
63,
1548,
275,
1033,
14,
1548,
8,
489,
2475,
67,
297,
489,
283,
646,
984,
27,
73,
29,
1274,
14,
1023,
63,
815,
27,
1361,
298,
1548,
5,
68,
4111,
68,
2,
450,
334,
73,
59,
16,
467,
284,
59,
17,
566,
7,
489,
7092,
1913,
342,
272,
1973,
63,
1548,
275,
5041,
16,
5995,
773,
15,
773,
91,
17,
5285,
908,
8,
2366,
63,
1861,
12,
1314,
63,
1548,
7092,
1913,
342,
339,
340,
299,
14,
6292,
8,
5041,
16,
5565,
65,
1370,
908,
8,
1973,
63,
1548,
776,
3461,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
65,
1370,
908,
8,
1973,
63,
1548,
776,
272,
327,
961,
1104,
365,
367,
445,
57,
39,
7941,
272,
916,
299,
14,
6292,
8,
5041,
16,
5565,
9259,
14,
65,
1370,
908,
8,
1973,
63,
1548,
776,
3461,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
9259,
14,
65,
1370,
908,
8,
1973,
63,
1548,
776,
272,
587,
26,
489,
2366,
63,
4342,
275,
5041,
16,
5565,
22305,
1370,
908,
8,
1973,
63,
1548,
776,
272,
2366,
63,
2613,
275,
5041,
16,
5995,
2613,
5321,
17,
5285,
908,
8,
2366,
63,
1861,
12,
1314,
63,
1548,
776,
272,
2366,
63,
5904,
275,
5041,
16,
5995,
1393,
15,
1548,
1370,
908,
8,
2366,
63,
1861,
776,
819,
372,
359,
272,
2475,
36,
11720,
63,
16983,
3126,
16,
5285,
908,
8,
2366,
63,
4342,
2318,
272,
2475,
36,
11720,
63,
18171,
63,
3022,
3126,
16,
5285,
908,
8,
2366,
63,
2613,
2318,
272,
2475,
36,
11720,
63,
21623,
3126,
16,
5285,
908,
8,
2366,
63,
5904,
776,
523,
1622,
421,
199,
318,
6077,
14517,
837,
523,
1798,
275,
7534,
14,
10730,
342,
523,
1798,
14,
525,
63,
2094,
8,
2850,
16066,
13,
18452,
297,
1595,
275,
283,
1617,
63,
2052,
297,
2432,
1720,
275,
283,
3425,
445,
13,
6606,
32451,
13659,
6869,
2659,
523,
1798,
14,
525,
63,
2094,
8,
2850,
2253,
13,
773,
16066,
297,
1595,
275,
283,
1617,
63,
2052,
297,
2432,
1720,
275,
283,
6119,
2656,
1973,
16066,
3140,
402,
25937,
1373,
283,
2432,
283,
504,
18338,
2611,
14,
1308,
14,
2845,
5363,
5378,
25518,
1549,
32501,
11213,
776,
523,
1798,
14,
525,
63,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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
] |
malev/pomodoro-indicator
|
pomodoro/tests/pomodoro_state.py
|
2
|
1080
|
import unittest
from pomodoro-indicator.pomodoro_state import PomodoroState
class TestPomodoroState(unittest.TestCase):
def setUp(self):
self.state = PomodoroState()
def test_has_all_the_methods(self):
"""There a list of methods it has to have but do nothing"""
methods_list = ["enabled_buttons", "start", "next_state", "pause", "resume"]
for method in methods_list:
assert hasattr(self.state, method)
def test_should_not_be_on_any_state(self):
"""The super class should not be on any singular state"""
states = ["working", "resting", "paused", "waiting"]
for state in states:
method = getattr(self.state, state)
self.assertFalse(method())
def test_current_state(self):
"""Every state should have a name and this method provides it"""
self.state.name = "name"
self.assertEqual("name", self.state.current_state())
def test_wont_work(self):
self.assertFalse(True)
if __name__ == '__main__':
unittest.main()
|
gpl-3.0
|
[
646,
2882,
199,
504,
299,
676,
364,
269,
79,
13,
15785,
14,
555,
1494,
269,
79,
63,
929,
492,
510,
676,
364,
269,
79,
2223,
199,
199,
533,
1379,
48,
676,
364,
269,
79,
2223,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
929,
275,
510,
676,
364,
269,
79,
2223,
342,
339,
347,
511,
63,
1989,
63,
452,
63,
1589,
63,
2474,
8,
277,
304,
267,
408,
10924,
282,
769,
402,
3102,
652,
965,
370,
1172,
1325,
886,
6548,
624,
267,
3102,
63,
513,
275,
2097,
3827,
63,
15687,
401,
298,
928,
401,
298,
2184,
63,
929,
401,
298,
11241,
401,
298,
9964,
937,
267,
367,
1083,
315,
3102,
63,
513,
26,
288,
702,
2688,
8,
277,
14,
929,
12,
1083,
9,
15567,
347,
511,
63,
5626,
63,
1397,
63,
1235,
63,
265,
63,
1629,
63,
929,
8,
277,
304,
267,
408,
1918,
1613,
1021,
1077,
440,
506,
641,
1263,
15823,
1174,
624,
267,
6363,
275,
2097,
9818,
401,
298,
3911,
316,
401,
298,
22478,
401,
298,
14093,
937,
267,
367,
1174,
315,
6363,
26,
288,
1083,
275,
2519,
8,
277,
14,
929,
12,
1174,
9,
288,
291,
14,
3334,
8,
765,
1012,
2286,
347,
511,
63,
1818,
63,
929,
8,
277,
304,
267,
408,
24527,
1174,
1077,
1172,
282,
536,
436,
642,
1083,
6571,
652,
624,
267,
291,
14,
929,
14,
354,
275,
298,
354,
2,
267,
291,
14,
629,
480,
354,
401,
291,
14,
929,
14,
1818,
63,
929,
1012,
2286,
347,
511,
63,
87,
1888,
63,
800,
8,
277,
304,
267,
291,
14,
3334,
8,
549,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
504,
299,
676,
364,
269,
79,
13,
15785,
14,
555,
1494,
269,
79,
63,
929,
492,
510,
676,
364,
269,
79,
2223,
199,
199,
533,
1379,
48,
676,
364,
269,
79,
2223,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
929,
275,
510,
676,
364,
269,
79,
2223,
342,
339,
347,
511,
63,
1989,
63,
452,
63,
1589,
63,
2474,
8,
277,
304,
267,
408,
10924,
282,
769,
402,
3102,
652,
965,
370,
1172,
1325,
886,
6548,
624,
267,
3102,
63,
513,
275,
2097,
3827,
63,
15687,
401,
298,
928,
401,
298,
2184,
63,
929,
401,
298,
11241,
401,
298,
9964,
937,
267,
367,
1083,
315,
3102,
63,
513,
26,
288,
702,
2688,
8,
277,
14,
929,
12,
1083,
9,
15567,
347,
511,
63,
5626,
63,
1397,
63,
1235,
63,
265,
63,
1629,
63,
929,
8,
277,
304,
267,
408,
1918,
1613,
1021,
1077,
440,
506,
641,
1263,
15823,
1174,
624,
267,
6363,
275,
2097,
9818,
401,
298,
3911,
316,
401,
298,
22478,
401,
298,
14093,
937,
267,
367,
1174,
315,
6363,
26,
288,
1083,
275,
2519,
8,
277,
14,
929,
12,
1174,
9,
288,
291,
14,
3334,
8,
765,
1012,
2286,
347,
511,
63,
1818,
63,
929,
8,
277,
304,
267,
408,
24527,
1174,
1077,
1172,
282,
536,
436,
642,
1083,
6571,
652,
624,
267,
291,
14,
929,
14,
354,
275,
298,
354,
2,
267,
291,
14,
629,
480,
354,
401,
291,
14,
929,
14,
1818,
63,
929,
1012,
2286,
347,
511,
63,
87,
1888,
63,
800,
8,
277,
304,
267,
291,
14,
3334,
8,
549,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
snehasi/servo
|
components/style/properties/data.py
|
1
|
11812
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re
PHYSICAL_SIDES = ["top", "left", "bottom", "right"]
LOGICAL_SIDES = ["block-start", "block-end", "inline-start", "inline-end"]
PHYSICAL_SIZES = ["width", "height"]
LOGICAL_SIZES = ["block-size", "inline-size"]
# bool is True when logical
ALL_SIDES = [(side, False) for side in PHYSICAL_SIDES] + [(side, True) for side in LOGICAL_SIDES]
ALL_SIZES = [(size, False) for size in PHYSICAL_SIZES] + [(size, True) for size in LOGICAL_SIZES]
def maybe_moz_logical_alias(product, side, prop):
if product == "gecko" and side[1]:
axis, dir = side[0].split("-")
if axis == "inline":
return prop % dir
return None
def to_rust_ident(name):
name = name.replace("-", "_")
if name in ["static", "super", "box", "move"]: # Rust keywords
name += "_"
return name
def to_camel_case(ident):
return re.sub("(^|_|-)([a-z])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
class Keyword(object):
def __init__(self, name, values, gecko_constant_prefix=None,
gecko_enum_prefix=None, custom_consts=None,
extra_gecko_values=None, extra_servo_values=None,
gecko_strip_moz_prefix=True,
gecko_inexhaustive=None):
self.name = name
self.values = values.split()
if gecko_constant_prefix and gecko_enum_prefix:
raise TypeError("Only one of gecko_constant_prefix and gecko_enum_prefix can be specified")
self.gecko_constant_prefix = gecko_constant_prefix or \
"NS_STYLE_" + self.name.upper().replace("-", "_")
self.gecko_enum_prefix = gecko_enum_prefix
self.extra_gecko_values = (extra_gecko_values or "").split()
self.extra_servo_values = (extra_servo_values or "").split()
self.consts_map = {} if custom_consts is None else custom_consts
self.gecko_strip_moz_prefix = gecko_strip_moz_prefix
self.gecko_inexhaustive = gecko_inexhaustive or (gecko_enum_prefix is None)
def gecko_values(self):
return self.values + self.extra_gecko_values
def servo_values(self):
return self.values + self.extra_servo_values
def values_for(self, product):
if product == "gecko":
return self.gecko_values()
elif product == "servo":
return self.servo_values()
else:
raise Exception("Bad product: " + product)
def gecko_constant(self, value):
moz_stripped = value.replace("-moz-", '') if self.gecko_strip_moz_prefix else value.replace("-moz-", 'moz-')
mapped = self.consts_map.get(value)
if self.gecko_enum_prefix:
parts = moz_stripped.replace('-', '_').split('_')
parts = mapped if mapped else [p.title() for p in parts]
return self.gecko_enum_prefix + "::" + "".join(parts)
else:
suffix = mapped if mapped else moz_stripped.replace("-", "_")
return self.gecko_constant_prefix + "_" + suffix.upper()
def needs_cast(self):
return self.gecko_enum_prefix is None
def maybe_cast(self, type_str):
return "as " + type_str if self.needs_cast() else ""
def arg_to_bool(arg):
if isinstance(arg, bool):
return arg
assert arg in ["True", "False"]
return arg == "True"
class Longhand(object):
def __init__(self, style_struct, name, spec=None, animation_type=None, derived_from=None, keyword=None,
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False,
allowed_in_keyframe_block=True, complex_color=False, cast_type='u8',
has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
creates_stacking_context=False, fixpos_cb=False, abspos_cb=False):
self.name = name
if not spec:
raise TypeError("Spec should be specified for %s" % name)
self.spec = spec
self.keyword = keyword
self.predefined_type = predefined_type
self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident)
self.style_struct = style_struct
self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.custom_cascade = custom_cascade
self.internal = internal
self.need_index = need_index
self.has_uncacheable_values = has_uncacheable_values
self.gecko_ffi_name = gecko_ffi_name or "m" + self.camel_case
self.depend_on_viewport_size = depend_on_viewport_size
self.derived_from = (derived_from or "").split()
self.complex_color = complex_color
self.cast_type = cast_type
self.logical = arg_to_bool(logical)
self.alias = alias.split() if alias else []
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
self.boxed = arg_to_bool(boxed)
self.creates_stacking_context = arg_to_bool(creates_stacking_context)
self.fixpos_cb = arg_to_bool(fixpos_cb)
self.abspos_cb = arg_to_bool(abspos_cb)
# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
# > except those defined in this specification,
# > but does accept the `animation-play-state` property and interprets it specially.
self.allowed_in_keyframe_block = allowed_in_keyframe_block \
and allowed_in_keyframe_block != "False"
# This is done like this since just a plain bool argument seemed like
# really random.
if animation_type is None:
raise TypeError("animation_type should be specified for (" + name + ")")
animation_types = ["none", "normal", "discrete"]
if animation_type not in animation_types:
raise TypeError("animation_type should be one of (" + str(animation_types) + ")")
self.animation_type = animation_type
self.animatable = animation_type != "none"
if self.logical:
# Logical properties don't animate separately
self.animatable = False
# NB: Animatable implies clone because a property animation requires a
# copy of the computed value.
#
# See components/style/helpers/animated_properties.mako.rs.
self.need_clone = need_clone or self.animatable
class Shorthand(object):
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None):
self.name = name
if not spec:
raise TypeError("Spec should be specified for %s" % name)
self.spec = spec
self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident)
self.derived_from = None
self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.sub_properties = sub_properties
self.internal = internal
self.alias = alias.split() if alias else []
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
# > except those defined in this specification,
# > but does accept the `animation-play-state` property and interprets it specially.
self.allowed_in_keyframe_block = allowed_in_keyframe_block \
and allowed_in_keyframe_block != "False"
class Method(object):
def __init__(self, name, return_type=None, arg_types=None, is_mut=False):
self.name = name
self.return_type = return_type
self.arg_types = arg_types or []
self.is_mut = is_mut
def arg_list(self):
args = ["_: " + x for x in self.arg_types]
args = ["&mut self" if self.is_mut else "&self"] + args
return ", ".join(args)
def signature(self):
sig = "fn %s(%s)" % (self.name, self.arg_list())
if self.return_type:
sig = sig + " -> " + self.return_type
return sig
def declare(self):
return self.signature() + ";"
def stub(self):
return self.signature() + "{ unimplemented!() }"
class StyleStruct(object):
def __init__(self, name, inherited, gecko_name=None, additional_methods=None):
self.gecko_struct_name = "Gecko" + name
self.name = name
self.name_lower = name.lower()
self.ident = to_rust_ident(self.name_lower)
self.longhands = []
self.inherited = inherited
self.gecko_name = gecko_name or name
self.gecko_ffi_name = "nsStyle" + self.gecko_name
self.additional_methods = additional_methods or []
class PropertiesData(object):
"""
The `testing` parameter means that we're running tests.
In this situation, the `product` value is ignored while choosing
which shorthands and longhands to generate; and instead all properties for
which code exists for either servo or stylo are generated. Note that we skip
this behavior when the style crate is being built in gecko mode, because we
need manual glue for such properties and we don't have it.
"""
def __init__(self, product, testing):
self.product = product
self.testing = testing and product != "gecko"
self.style_structs = []
self.current_style_struct = None
self.longhands = []
self.longhands_by_name = {}
self.derived_longhands = {}
self.shorthands = []
def new_style_struct(self, *args, **kwargs):
style_struct = StyleStruct(*args, **kwargs)
self.style_structs.append(style_struct)
self.current_style_struct = style_struct
def active_style_structs(self):
return [s for s in self.style_structs if s.additional_methods or s.longhands]
def add_prefixed_aliases(self, property):
# FIXME Servo's DOM architecture doesn't support vendor-prefixed properties.
# See servo/servo#14941.
if self.product == "gecko":
for prefix in property.extra_prefixes:
property.alias.append('-%s-%s' % (prefix, property.name))
def declare_longhand(self, name, products="gecko servo", disable_when_testing=False, **kwargs):
products = products.split()
if self.product not in products and not (self.testing and not disable_when_testing):
return
longhand = Longhand(self.current_style_struct, name, **kwargs)
self.add_prefixed_aliases(longhand)
self.current_style_struct.longhands.append(longhand)
self.longhands.append(longhand)
self.longhands_by_name[name] = longhand
for name in longhand.derived_from:
self.derived_longhands.setdefault(name, []).append(longhand)
return longhand
def declare_shorthand(self, name, sub_properties, products="gecko servo",
disable_when_testing=False, *args, **kwargs):
products = products.split()
if self.product not in products and not (self.testing and not disable_when_testing):
return
sub_properties = [self.longhands_by_name[s] for s in sub_properties]
shorthand = Shorthand(name, sub_properties, *args, **kwargs)
self.add_prefixed_aliases(shorthand)
self.shorthands.append(shorthand)
return shorthand
|
mpl-2.0
|
[
3,
961,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
646,
295,
199,
199,
9791,
20238,
5974,
63,
19514,
654,
275,
2097,
2119,
401,
298,
3039,
401,
298,
8305,
401,
298,
1019,
937,
199,
4947,
5974,
63,
19514,
654,
275,
2097,
1457,
13,
928,
401,
298,
1457,
13,
500,
401,
298,
6460,
13,
928,
401,
298,
6460,
13,
500,
937,
199,
9791,
20238,
5974,
63,
2684,
58,
654,
275,
2097,
2063,
401,
298,
3333,
937,
199,
4947,
5974,
63,
2684,
58,
654,
275,
2097,
1457,
13,
890,
401,
298,
6460,
13,
890,
937,
199,
199,
3,
2155,
365,
715,
1380,
11461,
199,
1761,
63,
19514,
654,
275,
3842,
2441,
12,
756,
9,
367,
5366,
315,
510,
16255,
51,
5974,
63,
19514,
654,
61,
435,
3842,
2441,
12,
715,
9,
367,
5366,
315,
5051,
5974,
63,
19514,
654,
61,
199,
1761,
63,
2684,
58,
654,
275,
3842,
890,
12,
756,
9,
367,
1568,
315,
510,
16255,
51,
5974,
63,
2684,
58,
654,
61,
435,
3842,
890,
12,
715,
9,
367,
1568,
315,
5051,
5974,
63,
2684,
58,
654,
61,
421,
199,
318,
11703,
63,
23120,
63,
7954,
63,
3620,
8,
2558,
12,
5366,
12,
5931,
304,
272,
340,
3336,
508,
298,
303,
21633,
2,
436,
5366,
59,
17,
2189,
267,
3114,
12,
2935,
275,
5366,
59,
16,
1055,
1294,
6096,
531,
267,
340,
3114,
508,
298,
6460,
582,
288,
372,
5931,
450,
2935,
272,
372,
488,
421,
199,
318,
370,
63,
19622,
63,
5425,
8,
354,
304,
272,
536,
275,
536,
14,
1814,
6096,
401,
2668,
531,
272,
340,
536,
315,
2097,
1986,
401,
298,
4792,
401,
298,
1977,
401,
298,
1185,
6229,
221,
327,
820,
833,
7681,
267,
536,
847,
14220,
272,
372,
536,
421,
199,
318,
370,
63,
22997,
63,
2546,
8,
5425,
304,
272,
372,
295,
14,
954,
18353,
62,
30007,
28447,
31440,
65,
13,
90,
566,
401,
2400,
333,
26,
333,
14,
923,
8,
18,
680,
4142,
1062,
12893,
14,
1913,
11008,
3471,
1913,
6096,
2237,
421,
199,
533,
6431,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1338,
12,
2312,
21633,
63,
4083,
63,
1861,
29,
403,
12,
326,
2312,
21633,
63,
4869,
63,
1861,
29,
403,
12,
3537,
63,
20473,
29,
403,
12,
326,
2402,
63,
303,
21633,
63,
1459,
29,
403,
12,
2402,
63,
25943,
63,
1459,
29,
403,
12,
326,
2312,
21633,
63,
1913,
63,
23120,
63,
1861,
29,
549,
12,
326,
2312,
21633,
63,
262,
476,
2411,
833,
1912,
29,
403,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
1459,
275,
1338,
14,
1294,
342,
267,
340,
2312,
21633,
63,
4083,
63,
1861,
436,
2312,
21633,
63,
4869,
63,
1861,
26,
288,
746,
3146,
480,
5903,
1373,
402,
2312,
21633,
63,
4083,
63,
1861,
436,
2312,
21633,
63,
4869,
63,
1861,
883,
506,
2013,
531,
267,
291,
14,
303,
21633,
63,
4083,
63,
1861,
275,
2312,
21633,
63,
4083,
63,
1861,
503,
971,
288,
298,
2709,
63,
18466,
12172,
435,
291,
14,
354,
14,
4142,
1252,
1814,
6096,
401,
2668,
531,
267,
291,
14,
303,
21633,
63,
4869,
63,
1861,
275,
2312,
21633,
63,
4869,
63,
1861,
267,
291,
14,
2911,
63,
303,
21633,
63,
1459,
275,
334,
2911,
63,
303,
21633,
63,
1459,
503,
25354,
1294,
342,
267,
291,
14,
2911,
63,
25943,
63,
1459,
275,
334,
2911,
63,
25943,
63,
1459,
503,
25354,
1294,
342,
267,
291,
14,
20473,
63,
1130,
275,
1052,
340,
3537,
63,
20473,
365,
488,
587,
3537,
63,
20473,
267,
291,
14,
303,
21633,
63,
1913,
63,
23120,
63,
1861,
275,
2312,
21633,
63,
1913,
63,
23120,
63,
1861,
267,
291,
14,
303,
21633,
63,
262,
476,
2411,
833,
1912,
275,
2312,
21633,
63,
262,
476,
2411,
833,
1912,
503,
334,
303,
21633,
63,
4869,
63,
1861,
365,
488,
9,
339,
347,
2312,
21633,
63,
1459,
8,
277,
304,
267,
372,
291,
14,
1459,
435,
291,
14,
2911,
63,
303,
21633,
63,
1459,
339,
347,
8926,
2392,
63,
1459,
8,
277,
304,
267,
372,
291,
14,
1459,
435,
291,
14,
2911,
63,
25943,
63,
1459,
339,
347,
1338,
63,
509,
8,
277,
12,
3336,
304,
267,
340,
3336,
508,
298,
303,
21633,
582,
288,
372,
291,
14,
303,
21633,
63,
1459,
342,
267,
916,
3336,
508,
298,
25943,
582,
288,
372,
291,
14,
25943,
63,
1459,
342,
267,
587,
26,
288,
746,
2186,
480,
5725,
3336,
26,
298,
435,
3336,
9,
339,
347,
2312,
21633,
63,
4083,
8,
277,
12,
574,
304,
267,
1303,
90,
63,
25382,
275,
574,
14,
1814,
6096,
23120,
13,
401,
4074,
340,
291,
14,
303,
21633,
63,
1913,
63,
23120,
63,
1861,
587,
574,
14,
1814,
6096,
23120,
13,
401,
283,
23120,
25815,
267,
9994,
275,
291,
14,
20473,
63,
1130,
14,
362,
8,
585,
9,
267,
340,
291,
14,
303,
21633,
63,
4869,
63,
1861,
26,
288,
4184,
275,
1303,
90,
63,
25382,
14,
1814,
13858,
2513,
1959,
1294,
26341,
288,
4184,
275,
9994,
340,
9994,
587,
359,
80,
14,
1213,
342,
367,
299,
315,
4184,
61,
288,
372,
291,
14,
303,
21633,
63,
4869,
63,
1861,
435,
27472,
2,
435,
10587,
904,
8,
4181,
9,
267,
587,
26,
288,
4739,
275,
9994,
340,
9994,
587,
1303,
90,
63,
25382,
14,
1814,
6096,
401,
2668,
531,
288,
372,
291,
14,
303,
21633,
63,
4083,
63,
1861,
435,
14220,
435,
4739,
14,
4142,
342,
339,
347,
4839,
63,
2931,
8,
277,
304,
267,
372,
291,
14,
303,
21633,
63,
4869,
63,
1861,
365,
488,
339,
347,
11703,
63,
2931,
8,
277,
12,
730,
63,
495,
304,
267,
372,
298,
305,
298,
435,
730,
63,
495,
340,
291,
14,
10065,
63,
2931,
342,
587,
3087,
421,
199,
318,
1680,
63,
475,
63,
2245,
8,
1273,
304,
272,
340,
1228,
8,
1273,
12,
2155,
304,
267,
372,
1680,
272,
702,
1680,
315,
2097,
549,
401,
298,
797,
937,
272,
372,
1680,
508,
298
] |
[
961,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
646,
295,
199,
199,
9791,
20238,
5974,
63,
19514,
654,
275,
2097,
2119,
401,
298,
3039,
401,
298,
8305,
401,
298,
1019,
937,
199,
4947,
5974,
63,
19514,
654,
275,
2097,
1457,
13,
928,
401,
298,
1457,
13,
500,
401,
298,
6460,
13,
928,
401,
298,
6460,
13,
500,
937,
199,
9791,
20238,
5974,
63,
2684,
58,
654,
275,
2097,
2063,
401,
298,
3333,
937,
199,
4947,
5974,
63,
2684,
58,
654,
275,
2097,
1457,
13,
890,
401,
298,
6460,
13,
890,
937,
199,
199,
3,
2155,
365,
715,
1380,
11461,
199,
1761,
63,
19514,
654,
275,
3842,
2441,
12,
756,
9,
367,
5366,
315,
510,
16255,
51,
5974,
63,
19514,
654,
61,
435,
3842,
2441,
12,
715,
9,
367,
5366,
315,
5051,
5974,
63,
19514,
654,
61,
199,
1761,
63,
2684,
58,
654,
275,
3842,
890,
12,
756,
9,
367,
1568,
315,
510,
16255,
51,
5974,
63,
2684,
58,
654,
61,
435,
3842,
890,
12,
715,
9,
367,
1568,
315,
5051,
5974,
63,
2684,
58,
654,
61,
421,
199,
318,
11703,
63,
23120,
63,
7954,
63,
3620,
8,
2558,
12,
5366,
12,
5931,
304,
272,
340,
3336,
508,
298,
303,
21633,
2,
436,
5366,
59,
17,
2189,
267,
3114,
12,
2935,
275,
5366,
59,
16,
1055,
1294,
6096,
531,
267,
340,
3114,
508,
298,
6460,
582,
288,
372,
5931,
450,
2935,
272,
372,
488,
421,
199,
318,
370,
63,
19622,
63,
5425,
8,
354,
304,
272,
536,
275,
536,
14,
1814,
6096,
401,
2668,
531,
272,
340,
536,
315,
2097,
1986,
401,
298,
4792,
401,
298,
1977,
401,
298,
1185,
6229,
221,
327,
820,
833,
7681,
267,
536,
847,
14220,
272,
372,
536,
421,
199,
318,
370,
63,
22997,
63,
2546,
8,
5425,
304,
272,
372,
295,
14,
954,
18353,
62,
30007,
28447,
31440,
65,
13,
90,
566,
401,
2400,
333,
26,
333,
14,
923,
8,
18,
680,
4142,
1062,
12893,
14,
1913,
11008,
3471,
1913,
6096,
2237,
421,
199,
533,
6431,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1338,
12,
2312,
21633,
63,
4083,
63,
1861,
29,
403,
12,
326,
2312,
21633,
63,
4869,
63,
1861,
29,
403,
12,
3537,
63,
20473,
29,
403,
12,
326,
2402,
63,
303,
21633,
63,
1459,
29,
403,
12,
2402,
63,
25943,
63,
1459,
29,
403,
12,
326,
2312,
21633,
63,
1913,
63,
23120,
63,
1861,
29,
549,
12,
326,
2312,
21633,
63,
262,
476,
2411,
833,
1912,
29,
403,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
1459,
275,
1338,
14,
1294,
342,
267,
340,
2312,
21633,
63,
4083,
63,
1861,
436,
2312,
21633,
63,
4869,
63,
1861,
26,
288,
746,
3146,
480,
5903,
1373,
402,
2312,
21633,
63,
4083,
63,
1861,
436,
2312,
21633,
63,
4869,
63,
1861,
883,
506,
2013,
531,
267,
291,
14,
303,
21633,
63,
4083,
63,
1861,
275,
2312,
21633,
63,
4083,
63,
1861,
503,
971,
288,
298,
2709,
63,
18466,
12172,
435,
291,
14,
354,
14,
4142,
1252,
1814,
6096,
401,
2668,
531,
267,
291,
14,
303,
21633,
63,
4869,
63,
1861,
275,
2312,
21633,
63,
4869,
63,
1861,
267,
291,
14,
2911,
63,
303,
21633,
63,
1459,
275,
334,
2911,
63,
303,
21633,
63,
1459,
503,
25354,
1294,
342,
267,
291,
14,
2911,
63,
25943,
63,
1459,
275,
334,
2911,
63,
25943,
63,
1459,
503,
25354,
1294,
342,
267,
291,
14,
20473,
63,
1130,
275,
1052,
340,
3537,
63,
20473,
365,
488,
587,
3537,
63,
20473,
267,
291,
14,
303,
21633,
63,
1913,
63,
23120,
63,
1861,
275,
2312,
21633,
63,
1913,
63,
23120,
63,
1861,
267,
291,
14,
303,
21633,
63,
262,
476,
2411,
833,
1912,
275,
2312,
21633,
63,
262,
476,
2411,
833,
1912,
503,
334,
303,
21633,
63,
4869,
63,
1861,
365,
488,
9,
339,
347,
2312,
21633,
63,
1459,
8,
277,
304,
267,
372,
291,
14,
1459,
435,
291,
14,
2911,
63,
303,
21633,
63,
1459,
339,
347,
8926,
2392,
63,
1459,
8,
277,
304,
267,
372,
291,
14,
1459,
435,
291,
14,
2911,
63,
25943,
63,
1459,
339,
347,
1338,
63,
509,
8,
277,
12,
3336,
304,
267,
340,
3336,
508,
298,
303,
21633,
582,
288,
372,
291,
14,
303,
21633,
63,
1459,
342,
267,
916,
3336,
508,
298,
25943,
582,
288,
372,
291,
14,
25943,
63,
1459,
342,
267,
587,
26,
288,
746,
2186,
480,
5725,
3336,
26,
298,
435,
3336,
9,
339,
347,
2312,
21633,
63,
4083,
8,
277,
12,
574,
304,
267,
1303,
90,
63,
25382,
275,
574,
14,
1814,
6096,
23120,
13,
401,
4074,
340,
291,
14,
303,
21633,
63,
1913,
63,
23120,
63,
1861,
587,
574,
14,
1814,
6096,
23120,
13,
401,
283,
23120,
25815,
267,
9994,
275,
291,
14,
20473,
63,
1130,
14,
362,
8,
585,
9,
267,
340,
291,
14,
303,
21633,
63,
4869,
63,
1861,
26,
288,
4184,
275,
1303,
90,
63,
25382,
14,
1814,
13858,
2513,
1959,
1294,
26341,
288,
4184,
275,
9994,
340,
9994,
587,
359,
80,
14,
1213,
342,
367,
299,
315,
4184,
61,
288,
372,
291,
14,
303,
21633,
63,
4869,
63,
1861,
435,
27472,
2,
435,
10587,
904,
8,
4181,
9,
267,
587,
26,
288,
4739,
275,
9994,
340,
9994,
587,
1303,
90,
63,
25382,
14,
1814,
6096,
401,
2668,
531,
288,
372,
291,
14,
303,
21633,
63,
4083,
63,
1861,
435,
14220,
435,
4739,
14,
4142,
342,
339,
347,
4839,
63,
2931,
8,
277,
304,
267,
372,
291,
14,
303,
21633,
63,
4869,
63,
1861,
365,
488,
339,
347,
11703,
63,
2931,
8,
277,
12,
730,
63,
495,
304,
267,
372,
298,
305,
298,
435,
730,
63,
495,
340,
291,
14,
10065,
63,
2931,
342,
587,
3087,
421,
199,
318,
1680,
63,
475,
63,
2245,
8,
1273,
304,
272,
340,
1228,
8,
1273,
12,
2155,
304,
267,
372,
1680,
272,
702,
1680,
315,
2097,
549,
401,
298,
797,
937,
272,
372,
1680,
508,
298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
meiavy/python-weixin
|
lib/python2.7/site-packages/pip/commands/search.py
|
84
|
4717
|
import sys
import textwrap
import pkg_resources
import pip.download
from pip.basecommand import Command, SUCCESS
from pip.util import get_terminal_size
from pip.log import logger
from pip.backwardcompat import xmlrpclib, reduce, cmp
from pip.exceptions import CommandError
from pip.status_codes import NO_MATCHES_FOUND
from distutils.version import StrictVersion, LooseVersion
class SearchCommand(Command):
"""Search for PyPI packages whose name or summary contains <query>."""
name = 'search'
usage = """
%prog [options] <query>"""
summary = 'Search PyPI for packages.'
def __init__(self, *args, **kw):
super(SearchCommand, self).__init__(*args, **kw)
self.cmd_opts.add_option(
'--index',
dest='index',
metavar='URL',
default='https://pypi.python.org/pypi',
help='Base URL of Python Package Index (default %default)')
self.parser.insert_option_group(0, self.cmd_opts)
def run(self, options, args):
if not args:
raise CommandError('Missing required argument (search query).')
query = args
index_url = options.index
pypi_hits = self.search(query, index_url)
hits = transform_hits(pypi_hits)
terminal_width = None
if sys.stdout.isatty():
terminal_width = get_terminal_size()[0]
print_results(hits, terminal_width=terminal_width)
if pypi_hits:
return SUCCESS
return NO_MATCHES_FOUND
def search(self, query, index_url):
pypi = xmlrpclib.ServerProxy(index_url)
hits = pypi.search({'name': query, 'summary': query}, 'or')
return hits
def transform_hits(hits):
"""
The list from pypi is really a list of versions. We want a list of
packages with the list of versions stored inline. This converts the
list from pypi into one we can use.
"""
packages = {}
for hit in hits:
name = hit['name']
summary = hit['summary']
version = hit['version']
score = hit['_pypi_ordering']
if score is None:
score = 0
if name not in packages.keys():
packages[name] = {'name': name, 'summary': summary, 'versions': [version], 'score': score}
else:
packages[name]['versions'].append(version)
# if this is the highest version, replace summary and score
if version == highest_version(packages[name]['versions']):
packages[name]['summary'] = summary
packages[name]['score'] = score
# each record has a unique name now, so we will convert the dict into a list sorted by score
package_list = sorted(packages.values(), key=lambda x: x['score'], reverse=True)
return package_list
def print_results(hits, name_column_width=25, terminal_width=None):
installed_packages = [p.project_name for p in pkg_resources.working_set]
for hit in hits:
name = hit['name']
summary = hit['summary'] or ''
if terminal_width is not None:
# wrap and indent summary to fit terminal
summary = textwrap.wrap(summary, terminal_width - name_column_width - 5)
summary = ('\n' + ' ' * (name_column_width + 3)).join(summary)
line = '%s - %s' % (name.ljust(name_column_width), summary)
try:
logger.notify(line)
if name in installed_packages:
dist = pkg_resources.get_distribution(name)
logger.indent += 2
try:
latest = highest_version(hit['versions'])
if dist.version == latest:
logger.notify('INSTALLED: %s (latest)' % dist.version)
else:
logger.notify('INSTALLED: %s' % dist.version)
logger.notify('LATEST: %s' % latest)
finally:
logger.indent -= 2
except UnicodeEncodeError:
pass
def compare_versions(version1, version2):
try:
return cmp(StrictVersion(version1), StrictVersion(version2))
# in case of abnormal version number, fall back to LooseVersion
except ValueError:
pass
try:
return cmp(LooseVersion(version1), LooseVersion(version2))
except TypeError:
# certain LooseVersion comparions raise due to unorderable types,
# fallback to string comparison
return cmp([str(v) for v in LooseVersion(version1).version],
[str(v) for v in LooseVersion(version2).version])
def highest_version(versions):
return reduce((lambda v1, v2: compare_versions(v1, v2) == 1 and v1 or v2), versions)
|
apache-2.0
|
[
646,
984,
199,
646,
13390,
199,
646,
5496,
63,
4435,
199,
646,
7305,
14,
4249,
199,
504,
7305,
14,
1095,
1531,
492,
5817,
12,
28364,
199,
504,
7305,
14,
1974,
492,
664,
63,
12010,
63,
890,
199,
504,
7305,
14,
793,
492,
2512,
199,
504,
7305,
14,
15457,
5819,
492,
19122,
12,
7114,
12,
10467,
199,
504,
7305,
14,
3924,
492,
14393,
199,
504,
7305,
14,
1205,
63,
6021,
492,
4825,
63,
14747,
654,
63,
13945,
199,
504,
7065,
14,
1023,
492,
23052,
3353,
12,
18462,
421,
199,
533,
8730,
3110,
8,
3110,
304,
272,
408,
5278,
367,
24330,
6117,
7447,
536,
503,
6212,
3509,
665,
1131,
30,
1041,
272,
536,
275,
283,
1733,
7,
272,
4503,
275,
408,
489,
450,
6595,
359,
1419,
61,
665,
1131,
11193,
272,
6212,
275,
283,
5278,
24330,
367,
6117,
3530,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
5278,
3110,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2850,
1080,
297,
288,
2053,
534,
1080,
297,
288,
8214,
534,
2632,
297,
288,
849,
534,
2859,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
297,
288,
1720,
534,
1563,
2851,
402,
2018,
15665,
5499,
334,
885,
450,
885,
5942,
398,
291,
14,
2087,
14,
3176,
63,
1422,
63,
923,
8,
16,
12,
291,
14,
1760,
63,
3291,
9,
339,
347,
1255,
8,
277,
12,
1511,
12,
1249,
304,
267,
340,
440,
1249,
26,
288,
746,
14393,
360,
7718,
1415,
1423,
334,
1733,
1827,
28583,
267,
1827,
275,
1249,
267,
1478,
63,
633,
275,
1511,
14,
1080,
398,
1134,
1038,
63,
16595,
275,
291,
14,
1733,
8,
1131,
12,
1478,
63,
633,
9,
267,
19745,
275,
5793,
63,
16595,
8,
17343,
63,
16595,
9,
398,
11167,
63,
2063,
275,
488,
267,
340,
984,
14,
2703,
14,
21122,
837,
288,
11167,
63,
2063,
275,
664,
63,
12010,
63,
890,
3430,
16,
61,
398,
870,
63,
2604,
8,
16595,
12,
11167,
63,
2063,
29,
12010,
63,
2063,
9,
267,
340,
1134,
1038,
63,
16595,
26,
288,
372,
28364,
267,
372,
4825,
63,
14747,
654,
63,
13945,
339,
347,
2754,
8,
277,
12,
1827,
12,
1478,
63,
633,
304,
267,
1134,
1038,
275,
19122,
14,
3120,
4936,
8,
1080,
63,
633,
9,
267,
19745,
275,
1134,
1038,
14,
1733,
3252,
354,
356,
1827,
12,
283,
4705,
356,
1827,
1386,
283,
269,
358,
267,
372,
19745,
421,
199,
318,
5793,
63,
16595,
8,
16595,
304,
272,
408,
272,
710,
769,
687,
1134,
1038,
365,
7710,
282,
769,
402,
5459,
14,
2136,
2934,
282,
769,
402,
272,
6117,
543,
314,
769,
402,
5459,
5489,
8308,
14,
961,
15373,
314,
272,
769,
687,
1134,
1038,
1901,
1373,
781,
883,
675,
14,
272,
408,
272,
6117,
275,
1052,
272,
367,
9793,
315,
19745,
26,
267,
536,
275,
9793,
459,
354,
418,
267,
6212,
275,
9793,
459,
4705,
418,
267,
1015,
275,
9793,
459,
1023,
418,
267,
5396,
275,
9793,
8680,
17343,
63,
7128,
418,
267,
340,
5396,
365,
488,
26,
288,
5396,
275,
378,
398,
340,
536,
440,
315,
6117,
14,
1612,
837,
288,
6117,
59,
354,
61,
275,
791,
354,
356,
536,
12,
283,
4705,
356,
6212,
12,
283,
6234,
356,
359,
1023,
467,
283,
3397,
356,
5396,
93,
267,
587,
26,
288,
6117,
59,
354,
2733,
6234,
2278,
740,
8,
1023,
9,
953,
327,
340,
642,
365,
314,
15356,
1015,
12,
3350,
6212,
436,
5396,
288,
340,
1015,
508,
15356,
63,
1023,
8,
5154,
59,
354,
2733,
6234,
9090,
355,
6117,
59,
354,
2733,
4705,
418,
275,
6212,
355,
6117,
59,
354,
2733,
3397,
418,
275,
5396,
339,
327,
1924,
2777,
965,
282,
3747,
536,
3063,
12,
880,
781,
911,
3957,
314,
1211,
1901,
282,
769,
3355,
701,
5396,
272,
2559,
63,
513,
275,
3355,
8,
5154,
14,
1459,
1062,
790,
29,
2734,
671,
26,
671,
459,
3397,
995,
3837,
29,
549,
9,
272,
372,
2559,
63,
513,
421,
199,
318,
870,
63,
2604,
8,
16595,
12,
536,
63,
2301,
63,
2063,
29,
821,
12,
11167,
63,
2063,
29,
403,
304,
272,
4903,
63,
5154,
275,
359,
80,
14,
1715,
63,
354,
367,
299,
315,
5496,
63,
4435,
14,
9818,
63,
409,
61,
272,
367,
9793,
315,
19745,
26,
267,
536,
275,
9793,
459,
354,
418,
267,
6212,
275,
9793,
459,
4705,
418,
503,
2125,
267,
340,
11167,
63,
2063,
365,
440,
488,
26,
288,
327,
4816,
436,
4363,
6212,
370,
5542,
11167,
288,
6212,
275,
13390,
14,
3823,
8,
4705,
12,
11167,
63,
2063,
446,
536,
63,
2301,
63,
2063,
446,
959,
9,
288,
6212,
275,
17485,
78,
7,
435,
283,
283,
627,
334,
354,
63,
2301,
63,
2063,
435,
650,
4992,
904,
8,
4705,
9,
267,
1004,
275,
1543,
83,
446,
450,
83,
7,
450,
334,
354,
14,
19996,
8,
354,
63,
2301,
63,
2063,
395,
6212,
9,
267,
862,
26,
288,
2512,
14,
6814,
8,
604,
9,
288,
340,
536,
315,
4903,
63,
5154,
26,
355,
2917,
275,
5496,
63,
4435,
14,
362,
63,
4972,
8,
354,
9,
355,
2512,
14,
3724,
847,
499,
355,
862,
26,
490,
8839,
275,
15356,
63,
1023,
8,
12948,
459,
6234,
1105,
490,
340,
2917,
14,
1023,
508,
8839,
26,
717,
2512,
14,
6814,
360,
15942,
26,
450,
83,
334,
7410,
3171,
450,
2917,
14,
1023,
9,
490,
587,
26,
717,
2512,
14,
6814,
360,
15942,
26,
450,
83,
7,
450,
2917,
14,
1023,
9,
717,
2512,
14,
6814,
360,
20307,
1719,
26,
259,
450,
83,
7,
450,
8839,
9,
355,
3753,
26,
490,
2512,
14,
3724,
4862,
499,
267,
871,
24094,
26,
288,
986,
421,
199,
318,
6540,
63,
6234,
8,
1023,
17,
12,
1015,
18,
304,
272,
862,
26,
267,
372,
10467,
8,
18625,
3353,
8,
1023,
17,
395,
23052,
3353,
8,
1023,
18,
430,
272,
327,
315,
1930,
402,
2236,
3302,
1015,
1329,
12,
11264,
1771,
370,
18462,
272,
871,
1722,
26,
267,
986,
272,
862,
26,
267,
372,
10467,
8,
44,
17851,
8,
1023,
17,
395,
18462,
8,
1023,
18,
430,
272,
871,
3146,
26,
272,
327,
9842,
18462,
1013,
759,
4654,
746,
7037,
370,
625,
27788,
6842,
2943
] |
[
984,
199,
646,
13390,
199,
646,
5496,
63,
4435,
199,
646,
7305,
14,
4249,
199,
504,
7305,
14,
1095,
1531,
492,
5817,
12,
28364,
199,
504,
7305,
14,
1974,
492,
664,
63,
12010,
63,
890,
199,
504,
7305,
14,
793,
492,
2512,
199,
504,
7305,
14,
15457,
5819,
492,
19122,
12,
7114,
12,
10467,
199,
504,
7305,
14,
3924,
492,
14393,
199,
504,
7305,
14,
1205,
63,
6021,
492,
4825,
63,
14747,
654,
63,
13945,
199,
504,
7065,
14,
1023,
492,
23052,
3353,
12,
18462,
421,
199,
533,
8730,
3110,
8,
3110,
304,
272,
408,
5278,
367,
24330,
6117,
7447,
536,
503,
6212,
3509,
665,
1131,
30,
1041,
272,
536,
275,
283,
1733,
7,
272,
4503,
275,
408,
489,
450,
6595,
359,
1419,
61,
665,
1131,
11193,
272,
6212,
275,
283,
5278,
24330,
367,
6117,
3530,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
5278,
3110,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
267,
291,
14,
1760,
63,
3291,
14,
525,
63,
1422,
8,
288,
2850,
1080,
297,
288,
2053,
534,
1080,
297,
288,
8214,
534,
2632,
297,
288,
849,
534,
2859,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
297,
288,
1720,
534,
1563,
2851,
402,
2018,
15665,
5499,
334,
885,
450,
885,
5942,
398,
291,
14,
2087,
14,
3176,
63,
1422,
63,
923,
8,
16,
12,
291,
14,
1760,
63,
3291,
9,
339,
347,
1255,
8,
277,
12,
1511,
12,
1249,
304,
267,
340,
440,
1249,
26,
288,
746,
14393,
360,
7718,
1415,
1423,
334,
1733,
1827,
28583,
267,
1827,
275,
1249,
267,
1478,
63,
633,
275,
1511,
14,
1080,
398,
1134,
1038,
63,
16595,
275,
291,
14,
1733,
8,
1131,
12,
1478,
63,
633,
9,
267,
19745,
275,
5793,
63,
16595,
8,
17343,
63,
16595,
9,
398,
11167,
63,
2063,
275,
488,
267,
340,
984,
14,
2703,
14,
21122,
837,
288,
11167,
63,
2063,
275,
664,
63,
12010,
63,
890,
3430,
16,
61,
398,
870,
63,
2604,
8,
16595,
12,
11167,
63,
2063,
29,
12010,
63,
2063,
9,
267,
340,
1134,
1038,
63,
16595,
26,
288,
372,
28364,
267,
372,
4825,
63,
14747,
654,
63,
13945,
339,
347,
2754,
8,
277,
12,
1827,
12,
1478,
63,
633,
304,
267,
1134,
1038,
275,
19122,
14,
3120,
4936,
8,
1080,
63,
633,
9,
267,
19745,
275,
1134,
1038,
14,
1733,
3252,
354,
356,
1827,
12,
283,
4705,
356,
1827,
1386,
283,
269,
358,
267,
372,
19745,
421,
199,
318,
5793,
63,
16595,
8,
16595,
304,
272,
408,
272,
710,
769,
687,
1134,
1038,
365,
7710,
282,
769,
402,
5459,
14,
2136,
2934,
282,
769,
402,
272,
6117,
543,
314,
769,
402,
5459,
5489,
8308,
14,
961,
15373,
314,
272,
769,
687,
1134,
1038,
1901,
1373,
781,
883,
675,
14,
272,
408,
272,
6117,
275,
1052,
272,
367,
9793,
315,
19745,
26,
267,
536,
275,
9793,
459,
354,
418,
267,
6212,
275,
9793,
459,
4705,
418,
267,
1015,
275,
9793,
459,
1023,
418,
267,
5396,
275,
9793,
8680,
17343,
63,
7128,
418,
267,
340,
5396,
365,
488,
26,
288,
5396,
275,
378,
398,
340,
536,
440,
315,
6117,
14,
1612,
837,
288,
6117,
59,
354,
61,
275,
791,
354,
356,
536,
12,
283,
4705,
356,
6212,
12,
283,
6234,
356,
359,
1023,
467,
283,
3397,
356,
5396,
93,
267,
587,
26,
288,
6117,
59,
354,
2733,
6234,
2278,
740,
8,
1023,
9,
953,
327,
340,
642,
365,
314,
15356,
1015,
12,
3350,
6212,
436,
5396,
288,
340,
1015,
508,
15356,
63,
1023,
8,
5154,
59,
354,
2733,
6234,
9090,
355,
6117,
59,
354,
2733,
4705,
418,
275,
6212,
355,
6117,
59,
354,
2733,
3397,
418,
275,
5396,
339,
327,
1924,
2777,
965,
282,
3747,
536,
3063,
12,
880,
781,
911,
3957,
314,
1211,
1901,
282,
769,
3355,
701,
5396,
272,
2559,
63,
513,
275,
3355,
8,
5154,
14,
1459,
1062,
790,
29,
2734,
671,
26,
671,
459,
3397,
995,
3837,
29,
549,
9,
272,
372,
2559,
63,
513,
421,
199,
318,
870,
63,
2604,
8,
16595,
12,
536,
63,
2301,
63,
2063,
29,
821,
12,
11167,
63,
2063,
29,
403,
304,
272,
4903,
63,
5154,
275,
359,
80,
14,
1715,
63,
354,
367,
299,
315,
5496,
63,
4435,
14,
9818,
63,
409,
61,
272,
367,
9793,
315,
19745,
26,
267,
536,
275,
9793,
459,
354,
418,
267,
6212,
275,
9793,
459,
4705,
418,
503,
2125,
267,
340,
11167,
63,
2063,
365,
440,
488,
26,
288,
327,
4816,
436,
4363,
6212,
370,
5542,
11167,
288,
6212,
275,
13390,
14,
3823,
8,
4705,
12,
11167,
63,
2063,
446,
536,
63,
2301,
63,
2063,
446,
959,
9,
288,
6212,
275,
17485,
78,
7,
435,
283,
283,
627,
334,
354,
63,
2301,
63,
2063,
435,
650,
4992,
904,
8,
4705,
9,
267,
1004,
275,
1543,
83,
446,
450,
83,
7,
450,
334,
354,
14,
19996,
8,
354,
63,
2301,
63,
2063,
395,
6212,
9,
267,
862,
26,
288,
2512,
14,
6814,
8,
604,
9,
288,
340,
536,
315,
4903,
63,
5154,
26,
355,
2917,
275,
5496,
63,
4435,
14,
362,
63,
4972,
8,
354,
9,
355,
2512,
14,
3724,
847,
499,
355,
862,
26,
490,
8839,
275,
15356,
63,
1023,
8,
12948,
459,
6234,
1105,
490,
340,
2917,
14,
1023,
508,
8839,
26,
717,
2512,
14,
6814,
360,
15942,
26,
450,
83,
334,
7410,
3171,
450,
2917,
14,
1023,
9,
490,
587,
26,
717,
2512,
14,
6814,
360,
15942,
26,
450,
83,
7,
450,
2917,
14,
1023,
9,
717,
2512,
14,
6814,
360,
20307,
1719,
26,
259,
450,
83,
7,
450,
8839,
9,
355,
3753,
26,
490,
2512,
14,
3724,
4862,
499,
267,
871,
24094,
26,
288,
986,
421,
199,
318,
6540,
63,
6234,
8,
1023,
17,
12,
1015,
18,
304,
272,
862,
26,
267,
372,
10467,
8,
18625,
3353,
8,
1023,
17,
395,
23052,
3353,
8,
1023,
18,
430,
272,
327,
315,
1930,
402,
2236,
3302,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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
] |
babywolfh/iris-panel
|
iris/core/migrations/0006_copy_bak_back_to_nn.py
|
7
|
15478
|
# -*- coding: utf-8 -*-
# This file is part of IRIS: Infrastructure and Release Information System
#
# Copyright (C) 2013-2015 Intel Corporation
#
# IRIS is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2.0 as published by the Free Software Foundation.
#pylint: skip-file
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
Package = orm['core.Package']
Backup = orm['core.PackageBackup']
for bak in Backup.objects.order_by('pid').all():
pack = Package.objects.get(name=bak.name)
pack.gittree_set.add(bak.tid)
def backwards(self, orm):
"Write your backwards methods here."
for pack in orm['core.Package'].objects.all():
pack.gittree_set.clean()
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': '225'})
},
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'})
},
'core.domain': {
'Meta': {'object_name': 'Domain'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'core.domainrole': {
'Meta': {'object_name': 'DomainRole', '_ormbases': [u'auth.Group']},
'domain': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'role_set'", 'to': "orm['core.Domain']"}),
u'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),
'role': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'})
},
'core.gittree': {
'Meta': {'object_name': 'GitTree'},
'gitpath': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'licenses': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.License']", 'symmetrical': 'False'}),
'packages': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.Package']", 'symmetrical': 'False'}),
'subdomain': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.SubDomain']"})
},
'core.gittreerole': {
'Meta': {'object_name': 'GitTreeRole', '_ormbases': [u'auth.Group']},
'gittree': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'role_set'", 'to': "orm['core.GitTree']"}),
u'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),
'role': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'})
},
'core.image': {
'Meta': {'object_name': 'Image'},
'arch': ('django.db.models.fields.TextField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Product']"}),
'target': ('django.db.models.fields.TextField', [], {})
},
'core.imagebuild': {
'Meta': {'object_name': 'ImageBuild'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Image']"}),
'log': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['core.Log']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '8'})
},
'core.license': {
'Meta': {'object_name': 'License'},
'fullname': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'shortname': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'text': ('django.db.models.fields.TextField', [], {})
},
'core.log': {
'Meta': {'object_name': 'Log'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
},
'core.package': {
'Meta': {'object_name': 'Package'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'core.packagebackup': {
'Meta': {'object_name': 'PackageBackup'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'isdel': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
'pid': ('django.db.models.fields.IntegerField', [], {}),
'tid': ('django.db.models.fields.IntegerField', [], {})
},
'core.packagebuild': {
'Meta': {'object_name': 'PackageBuild'},
'arch': ('django.db.models.fields.TextField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'log': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['core.Log']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Package']"}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
'target': ('django.db.models.fields.TextField', [], {})
},
'core.product': {
'Meta': {'object_name': 'Product'},
'description': ('django.db.models.fields.TextField', [], {}),
'gittrees': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.GitTree']", 'symmetrical': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
},
'core.productrole': {
'Meta': {'object_name': 'ProductRole', '_ormbases': [u'auth.Group']},
u'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),
'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Product']"}),
'role': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'})
},
'core.subdomain': {
'Meta': {'unique_together': "(('name', 'domain'),)", 'object_name': 'SubDomain'},
'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Domain']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
},
'core.subdomainrole': {
'Meta': {'object_name': 'SubDomainRole', '_ormbases': [u'auth.Group']},
u'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),
'role': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'subdomain': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.SubDomain']"})
},
'core.submission': {
'Meta': {'object_name': 'Submission'},
'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'commit': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'gittree': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.GitTree']", 'symmetrical': 'False', 'blank': 'True'}),
'ibuilds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.ImageBuild']", 'symmetrical': 'False', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'db_index': 'True'}),
'pbuilds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.PackageBuild']", 'symmetrical': 'False', 'blank': 'True'}),
'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Product']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}),
'submitters': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'symmetrical': 'False'}),
'testresults': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.TestResult']", 'symmetrical': 'False', 'blank': 'True'}),
'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'core.submissiongroup': {
'Meta': {'object_name': 'SubmissionGroup'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'db_index': 'True'}),
'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Product']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
'submissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['core.Submission']", 'symmetrical': 'False'}),
'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'core.testresult': {
'Meta': {'object_name': 'TestResult'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'log': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['core.Log']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '16'})
},
'core.userparty': {
'Meta': {'object_name': 'UserParty', '_ormbases': [u'auth.Group']},
u'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}),
'party': ('django.db.models.fields.CharField', [], {'max_length': '15'})
},
'core.userprofile': {
'Meta': {'object_name': 'UserProfile'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'})
}
}
complete_apps = ['core']
symmetrical = True
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1777,
402,
473,
50,
1311,
26,
1010,
21844,
6976,
436,
17646,
17064,
6187,
199,
3,
199,
3,
1898,
334,
35,
9,
6171,
13,
7806,
20619,
11098,
199,
3,
199,
3,
473,
50,
1311,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
1015,
499,
14,
16,
465,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
26324,
26,
3372,
13,
493,
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,
3918,
9816,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
1451,
9816,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
3102,
2348,
2122,
267,
327,
3390,
26,
7529,
1133,
675,
298,
504,
20268,
14,
992,
492,
5822,
985,
1674,
267,
327,
3645,
9813,
14,
1685,
985,
370,
10618,
370,
1709,
315,
642,
4223,
12,
267,
327,
436,
9813,
459,
21653,
14,
1685,
985,
418,
367,
1709,
315,
1163,
13103,
14,
267,
15665,
275,
9813,
459,
1018,
14,
8599,
418,
267,
10257,
384,
275,
9813,
459,
1018,
14,
8599,
16559,
418,
267,
367,
330,
1151,
315,
10257,
384,
14,
1462,
14,
1648,
63,
991,
360,
3150,
1959,
452,
837,
288,
1706,
275,
15665,
14,
1462,
14,
362,
8,
354,
29,
27162,
14,
354,
9,
288,
1706,
14,
3187,
2350,
63,
409,
14,
525,
8,
27162,
14,
5700,
9,
339,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
3102,
2348,
2122,
267,
367,
1706,
315,
9813,
459,
1018,
14,
8599,
2278,
1462,
14,
452,
837,
288,
1706,
14,
3187,
2350,
63,
409,
14,
3118,
342,
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,
10932,
3071,
267
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1777,
402,
473,
50,
1311,
26,
1010,
21844,
6976,
436,
17646,
17064,
6187,
199,
3,
199,
3,
1898,
334,
35,
9,
6171,
13,
7806,
20619,
11098,
199,
3,
199,
3,
473,
50,
1311,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
1015,
499,
14,
16,
465,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
26324,
26,
3372,
13,
493,
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,
3918,
9816,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
1451,
9816,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
17465,
3102,
2348,
2122,
267,
327,
3390,
26,
7529,
1133,
675,
298,
504,
20268,
14,
992,
492,
5822,
985,
1674,
267,
327,
3645,
9813,
14,
1685,
985,
370,
10618,
370,
1709,
315,
642,
4223,
12,
267,
327,
436,
9813,
459,
21653,
14,
1685,
985,
418,
367,
1709,
315,
1163,
13103,
14,
267,
15665,
275,
9813,
459,
1018,
14,
8599,
418,
267,
10257,
384,
275,
9813,
459,
1018,
14,
8599,
16559,
418,
267,
367,
330,
1151,
315,
10257,
384,
14,
1462,
14,
1648,
63,
991,
360,
3150,
1959,
452,
837,
288,
1706,
275,
15665,
14,
1462,
14,
362,
8,
354,
29,
27162,
14,
354,
9,
288,
1706,
14,
3187,
2350,
63,
409,
14,
525,
8,
27162,
14,
5700,
9,
339,
347,
8552,
8,
277,
12,
9813,
304,
267,
298,
3534,
2195,
8552,
3102,
2348,
2122,
267,
367,
1706,
315,
9813,
459,
1018,
14,
8599,
2278,
1462,
14,
452,
837,
288,
1706,
14,
3187,
2350,
63,
409,
14,
3118,
342,
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,
10932,
3071,
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,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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
] |
lovesnow/flexx
|
flexx/webruntime/chromeapp.py
|
12
|
2788
|
""" Web runtime based on a chrome app
In contrast to running in the chrome browser, this makes the app have
more the look and feel of a desktop app.
"""
import os
import sys
from .common import DesktopRuntime
# todo: icon, sizing, etc.
def get_chrome_exe():
""" Get the path of the Chrome executable
If the path could not be found, returns None.
"""
paths = []
# Collect possible locations
if sys.platform.startswith('win'):
paths.append("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe")
paths.append("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
paths.append(os.path.expanduser("~\\AppData\\Local\\Google\\Chrome\\chrome.exe"))
paths.append(os.path.expanduser("~\\Local Settings\\Application Data\\Google\\Chrome\\chrome.exe")) # xp
elif sys.platform.startswith('linux'):
paths.append('/usr/bin/google-chrome-stable')
paths.append('/usr/bin/google-chrome-beta')
paths.append('/usr/bin/google-chrome-dev')
elif sys.platform.startswith('darwin'):
paths.append('/Applications/Chrome.app')
# Try location until we find one that exists
for path in paths:
if os.path.isfile(path):
return path
else:
return None
def get_chromium_exe():
""" Get the path of the Chromium executable
If the path could not be found, returns None.
"""
paths = []
# Collect possible locations
if sys.platform.startswith('win'):
paths.append("C:\\Program Files\\Chromium\\Application\\chrome.exe")
paths.append("C:\\Program Files (x86)\\Chromium\\Application\\chrome.exe")
paths.append(os.path.expanduser("~\\AppData\\Local\\Chromium\\chrome.exe"))
paths.append(os.path.expanduser("~\\Local Settings\\Application Data\\Chromium\\chrome.exe")) # xp
elif sys.platform.startswith('linux'):
paths.append('/usr/bin/chromium')
elif sys.platform.startswith('darwin'):
paths.append('/Applications/Chromium.app')
# Try location until we find one that exists
for path in paths:
if os.path.isfile(path):
return path
else:
return None
class ChromeAppRuntime(DesktopRuntime):
""" Desktop runtime based on chrome app. Requires the Chrome or
Chromium browser to be installed.
Note: icon, sizing and title is not yet supported.
"""
def _launch(self):
# Get chrome executable
exe = get_chrome_exe() or get_chromium_exe()
if exe is None:
raise RuntimeError('Chrome or Chromium browser was not detected.')
# Launch url
url = self._kwargs['url']
self._start_subprocess([exe, '--incognito', '--app=%s' % url])
|
bsd-2-clause
|
[
624,
6001,
8836,
4079,
641,
282,
18221,
1145,
199,
199,
607,
30347,
370,
3879,
315,
314,
18221,
7042,
12,
642,
7704,
314,
1145,
1172,
199,
6878,
314,
3648,
436,
23109,
402,
282,
19763,
1145,
14,
199,
624,
199,
199,
646,
747,
199,
646,
984,
199,
199,
504,
1275,
2330,
492,
8055,
17827,
14357,
199,
199,
3,
11386,
26,
7016,
12,
308,
9147,
12,
5423,
14,
199,
199,
318,
664,
63,
9887,
63,
5803,
837,
272,
408,
2372,
314,
931,
402,
314,
16776,
7286,
2286,
982,
314,
931,
4293,
440,
506,
1911,
12,
2529,
488,
14,
272,
408,
272,
3792,
275,
942,
2286,
327,
19649,
3962,
9918,
272,
340,
984,
14,
3246,
14,
2460,
360,
2676,
735,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
1103,
13266,
1103,
18083,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
334,
88,
1184,
22532,
13266,
1103,
18083,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
2640,
1451,
1103,
5339,
1103,
13266,
1103,
18083,
1103,
9887,
14,
5803,
2237,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
5339,
13303,
1103,
5039,
3918,
1103,
13266,
1103,
18083,
1103,
9887,
14,
5803,
2237,
221,
327,
21499,
272,
916,
984,
14,
3246,
14,
2460,
360,
5135,
735,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
11989,
358,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
5683,
358,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
2374,
358,
272,
916,
984,
14,
3246,
14,
2460,
360,
13245,
735,
267,
3792,
14,
740,
2336,
31907,
15,
18083,
14,
571,
358,
2286,
327,
7649,
2909,
5133,
781,
2342,
1373,
626,
3495,
272,
367,
931,
315,
3792,
26,
267,
340,
747,
14,
515,
14,
6292,
8,
515,
304,
288,
372,
931,
272,
587,
26,
267,
372,
488,
421,
199,
318,
664,
63,
13211,
63,
5803,
837,
272,
408,
2372,
314,
931,
402,
314,
12051,
7286,
2286,
982,
314,
931,
4293,
440,
506,
1911,
12,
2529,
488,
14,
272,
408,
272,
3792,
275,
942,
2286,
327,
19649,
3962,
9918,
272,
340,
984,
14,
3246,
14,
2460,
360,
2676,
735,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
1103,
29381,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
334,
88,
1184,
22532,
29381,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
2640,
1451,
1103,
5339,
1103,
29381,
1103,
9887,
14,
5803,
2237,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
5339,
13303,
1103,
5039,
3918,
1103,
29381,
1103,
9887,
14,
5803,
2237,
221,
327,
21499,
267,
272,
916,
984,
14,
3246,
14,
2460,
360,
5135,
735,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
13211,
358,
272,
916,
984,
14,
3246,
14,
2460,
360,
13245,
735,
267,
3792,
14,
740,
2336,
31907,
15,
29381,
14,
571,
358,
2286,
327,
7649,
2909,
5133,
781,
2342,
1373,
626,
3495,
272,
367,
931,
315,
3792,
26,
267,
340,
747,
14,
515,
14,
6292,
8,
515,
304,
288,
372,
931,
272,
587,
26,
267,
372,
488,
421,
199,
533,
16776,
2640,
14357,
8,
20436,
14357,
304,
272,
408,
8055,
17827,
8836,
4079,
641,
18221,
1145,
14,
15127,
314,
16776,
503,
272,
12051,
7042,
370,
506,
4903,
14,
2286,
3390,
26,
7016,
12,
308,
9147,
436,
2538,
365,
440,
5966,
3748,
14,
272,
408,
2286,
347,
485,
9850,
8,
277,
304,
267,
327,
2372,
18221,
7286,
267,
14778,
275,
664,
63,
9887,
63,
5803,
342,
503,
664,
63,
13211,
63,
5803,
342,
267,
340,
14778,
365,
488,
26,
288,
746,
6064,
360,
18083,
503,
12051,
7042,
1990,
440,
10501,
2659,
267,
327,
23615,
1166,
267,
1166,
275,
291,
423,
958,
459,
633,
418,
267,
291,
423,
928,
63,
5781,
779,
5803,
12,
2850,
262,
6862,
24308,
297,
2850,
571,
2458,
83,
7,
450,
1166,
566,
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
] |
[
6001,
8836,
4079,
641,
282,
18221,
1145,
199,
199,
607,
30347,
370,
3879,
315,
314,
18221,
7042,
12,
642,
7704,
314,
1145,
1172,
199,
6878,
314,
3648,
436,
23109,
402,
282,
19763,
1145,
14,
199,
624,
199,
199,
646,
747,
199,
646,
984,
199,
199,
504,
1275,
2330,
492,
8055,
17827,
14357,
199,
199,
3,
11386,
26,
7016,
12,
308,
9147,
12,
5423,
14,
199,
199,
318,
664,
63,
9887,
63,
5803,
837,
272,
408,
2372,
314,
931,
402,
314,
16776,
7286,
2286,
982,
314,
931,
4293,
440,
506,
1911,
12,
2529,
488,
14,
272,
408,
272,
3792,
275,
942,
2286,
327,
19649,
3962,
9918,
272,
340,
984,
14,
3246,
14,
2460,
360,
2676,
735,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
1103,
13266,
1103,
18083,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
334,
88,
1184,
22532,
13266,
1103,
18083,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
2640,
1451,
1103,
5339,
1103,
13266,
1103,
18083,
1103,
9887,
14,
5803,
2237,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
5339,
13303,
1103,
5039,
3918,
1103,
13266,
1103,
18083,
1103,
9887,
14,
5803,
2237,
221,
327,
21499,
272,
916,
984,
14,
3246,
14,
2460,
360,
5135,
735,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
11989,
358,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
5683,
358,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
3098,
13,
9887,
13,
2374,
358,
272,
916,
984,
14,
3246,
14,
2460,
360,
13245,
735,
267,
3792,
14,
740,
2336,
31907,
15,
18083,
14,
571,
358,
2286,
327,
7649,
2909,
5133,
781,
2342,
1373,
626,
3495,
272,
367,
931,
315,
3792,
26,
267,
340,
747,
14,
515,
14,
6292,
8,
515,
304,
288,
372,
931,
272,
587,
26,
267,
372,
488,
421,
199,
318,
664,
63,
13211,
63,
5803,
837,
272,
408,
2372,
314,
931,
402,
314,
12051,
7286,
2286,
982,
314,
931,
4293,
440,
506,
1911,
12,
2529,
488,
14,
272,
408,
272,
3792,
275,
942,
2286,
327,
19649,
3962,
9918,
272,
340,
984,
14,
3246,
14,
2460,
360,
2676,
735,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
1103,
29381,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
480,
35,
18589,
9184,
16920,
334,
88,
1184,
22532,
29381,
1103,
5039,
1103,
9887,
14,
5803,
531,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
2640,
1451,
1103,
5339,
1103,
29381,
1103,
9887,
14,
5803,
2237,
267,
3792,
14,
740,
8,
736,
14,
515,
14,
12131,
20793,
1103,
5339,
13303,
1103,
5039,
3918,
1103,
29381,
1103,
9887,
14,
5803,
2237,
221,
327,
21499,
267,
272,
916,
984,
14,
3246,
14,
2460,
360,
5135,
735,
267,
3792,
14,
740,
2336,
2647,
15,
1393,
15,
13211,
358,
272,
916,
984,
14,
3246,
14,
2460,
360,
13245,
735,
267,
3792,
14,
740,
2336,
31907,
15,
29381,
14,
571,
358,
2286,
327,
7649,
2909,
5133,
781,
2342,
1373,
626,
3495,
272,
367,
931,
315,
3792,
26,
267,
340,
747,
14,
515,
14,
6292,
8,
515,
304,
288,
372,
931,
272,
587,
26,
267,
372,
488,
421,
199,
533,
16776,
2640,
14357,
8,
20436,
14357,
304,
272,
408,
8055,
17827,
8836,
4079,
641,
18221,
1145,
14,
15127,
314,
16776,
503,
272,
12051,
7042,
370,
506,
4903,
14,
2286,
3390,
26,
7016,
12,
308,
9147,
436,
2538,
365,
440,
5966,
3748,
14,
272,
408,
2286,
347,
485,
9850,
8,
277,
304,
267,
327,
2372,
18221,
7286,
267,
14778,
275,
664,
63,
9887,
63,
5803,
342,
503,
664,
63,
13211,
63,
5803,
342,
267,
340,
14778,
365,
488,
26,
288,
746,
6064,
360,
18083,
503,
12051,
7042,
1990,
440,
10501,
2659,
267,
327,
23615,
1166,
267,
1166,
275,
291,
423,
958,
459,
633,
418,
267,
291,
423,
928,
63,
5781,
779,
5803,
12,
2850,
262,
6862,
24308,
297,
2850,
571,
2458,
83,
7,
450,
1166,
566,
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,
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,
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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
] |
vcatechnology/cmake-boilerplate
|
cmake/pygh/__init__.py
|
1
|
25114
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import sys
import json
import errno
import platform
import fileinput
import subprocess
from datetime import datetime, timezone
try:
import requests
except ImportError:
raise ImportError(
'Failed to import \'requests\', run \'pip install requests\'')
try:
import pystache
except ImportError:
raise ImportError(
'Failed to import \'pystache\', run \'pip install pystache\'')
class ReleaseError(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class ExecuteCommandError(Exception):
def __init__(self, message, cmd, code, out, err):
self.message = message
self.cmd = cmd
self.code = code
self.out = out
self.err = err
def __str__(self):
return self.message
class EmptyLogger(object):
'''Provides an implementation of an empty logging function'''
def debug(self, *k, **kw):
pass
def info(self, *k, **kw):
pass
def warn(self, *k, **kw):
pass
def error(self, *k, **kw):
pass
def critical(self, *k, **kw):
pass
def setLevel(self, *k, **kw):
pass
class Version(object):
'''Represents a version number'''
def __init__(self, *k, **kw):
'''
A version number can be instantiate with:
- a dot-separated string
- Version('1.2.3')
- an iterable
- Version([1, 2, 3])
- seperate arguments
- `Version(1, 2, 3)`
- another version class
- `Version(Version(1, 2, 3))`
- a dictionary
- `Version({'minor':2,'major':1,'patch':3})`
- keywords
- `Version(minor = 2,major = 1, patch = 3)`
'''
try:
version = (k[0].major, k[0].minor, k[0].patch)
except (AttributeError, TypeError):
try:
version = (kw['major'], kw['minor'], kw['patch'])
except (KeyError, TypeError):
try:
version = (k[0]['major'], k[0]['minor'], k[0]['patch'])
except (KeyError, TypeError):
if isinstance(k[0], str):
version = k[0].split('.')
else:
try:
version = (k[0][0], k[0][1], k[0][2])
except (IndexError, TypeError):
version = k
self.major = int(version[0])
self.minor = int(version[1])
self.patch = int(version[2])
def bump(self, category):
'''
Bumps the version number depending on the category
'''
setattr(self, category, getattr(self, category) + 1)
if category == 'major':
self.minor = 0
self.patch = 0
elif category == 'minor':
self.patch = 0
def __gt__(self, other):
return tuple(self) > tuple(other)
def __ge__(self, other):
return tuple(self) >= tuple(other)
def __lt__(self, other):
return tuple(self) < tuple(other)
def __le__(self, other):
return tuple(self) <= tuple(other)
def __eq__(self, other):
return tuple(self) == tuple(other)
def __ne__(self, other):
return tuple(self) != tuple(other)
def __getitem__(self, index):
'''
Allows iteration of the version number
'''
if index == 0:
return self.major
elif index == 1:
return self.minor
elif index == 2:
return self.patch
else:
raise IndexError('version index out of range')
def __repr__(self):
'''
Provides a dot-separated string representation of the version number
'''
return '%i.%i.%i' % (self.major, self.minor, self.patch)
class GitVersion(Version):
'''A git repository version number'''
def __init__(self, *k, **kw):
'''
A git version number can be instantiate with:
- a dot-separated string
- Version('1.2.3.ef3aa43d-dirty')
- an iterable
- Version([1, 2, 3, 'ef3aa43d', True])
- seperate arguments
- `Version(1, 2, 3, 'ef3aa43d', True)`
- another version class
- `Version(Version(1, 2, 3, 'ef3aa43d', True))`
- a dictionary
- `Version({'minor':2,'major':1,'patch':3, 'commit': 'ef3aa43d', 'dirty', True})`
- keywords
- `Version(minor = 2,major = 1, patch = 3, commit ='ef3aa43d', dirty =True)`
'''
super(GitVersion, self).__init__(*k, **kw)
try:
version = (k[0].commit, k[0].dirty)
except (AttributeError, TypeError):
try:
version = (kw['commit'], kw['dirty'])
except (KeyError, TypeError):
try:
version = (k[0]['commit'], k[0]['dirty'])
except (KeyError, TypeError):
if isinstance(k[0], str):
version = k[0].split('.')[3]
else:
try:
version = (k[0][3], k[0][4])
except (IndexError, TypeError):
version = k[3:]
self.commit = str(version[0])
try:
self.dirty = bool(version[1])
except:
try:
split = self.commit.split('-')
self.dirty = (split[1] == 'dirty')
self.commit = split[0]
except:
self.dirty = False
try:
int(self.commit, 16)
except ValueError:
raise ValueError('The git commit string is not hexidecimal: %s'
% self.commit)
def __repr__(self):
'''
Provides a dot-separated string representation of the version number
'''
string = '%s.%s' % (super(GitVersion, self).__repr__(),
self.commit[:8])
if self.dirty:
string += '-dirty'
return string
def find_exe_in_path(filename, path=None):
'''
Finds an executable in the PATH environment variable
'''
if platform.system() == 'Windows':
filename += '.exe'
if path is None:
path = os.environ.get('PATH', '')
if type(path) is type(''):
pathlist = path.split(os.pathsep)
return list(filter(os.path.exists, map(lambda dir, filename=filename: os.path.join(dir, filename), pathlist)))
def execute_command(cmd,
error_message='Failed to run external program',
expected=0,
cwd=os.getcwd()):
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
cwd=cwd)
(out, err) = p.communicate()
if expected != None and p.returncode != expected:
raise ExecuteCommandError(error_message, cmd, p.returncode, out, err)
return (p.returncode, out, err)
def close_milestone(number, repo, token, logger=EmptyLogger()):
logger.debug('Closing milestone #%d for %s' % (number, repo))
number = int(number)
r = requests.patch('https://api.github.com/repos/%s/milestones/%d' %
(repo, number),
params={
'access_token': token,
},
json={
'state': 'closed',
})
if r.status_code != 200:
json = r.json()
message = json['message']
errors = json.get('errors', [])
for e in errors:
message += '\n - %s: %s: %s' % (e.get('resource', 'unknown'),
e.get('field', 'unknown'),
e.get('code', 'unknown'))
raise ReleaseError('Failed to close github milestone #%d: %s' %
(number, message))
logger.info('Closed milestone #%d' % number)
return r.json()
def get_milestones(repo, token, logger=EmptyLogger()):
logger.debug('Retrieving milestones for %s' % repo)
r = requests.get('https://api.github.com/repos/%s/milestones' % repo,
params={
'access_token': token,
})
if r.status_code != 200:
raise ReleaseError('Failed to retrieve github milestones from %s: %s' %
(repo, r.json()['message']))
return r.json()
def get_git_tag_version(path,
git_executable=find_exe_in_path('git'),
logger=EmptyLogger()):
if isinstance(git_executable, list):
git_executable = git_executable[0]
logger.debug('Getting latest git tag version')
# Get the head commit
cmd = [git_executable, 'rev-parse', 'HEAD']
_, out, _ = execute_command(cmd,
'Failed to get HEAD revision of repository',
cwd=path)
commit = out.split('\n')[0].strip()
if commit == 'HEAD' or not commit:
commit = '0000000000000000000000000000000000000000'
# Check if dirty
dirty = False
cmd = [git_executable, 'diff-index', '--name-only', 'HEAD']
if execute_command(
cmd,
'Failed to check if the project had local modifications',
cwd=path)[1]:
dirty = True
cmd = [git_executable, 'status', '--porcelain']
if '?? ' in execute_command(
cmd,
'Failed to check if the project had local modifications',
cwd=path)[1]:
dirty = True
# Find the latest tag
cmd = [git_executable, 'describe', '--match=v[0-9]*', 'HEAD']
code, out, _ = execute_command(cmd, expected=None, cwd=path)
if code:
return GitVersion(0, 0, 0, commit, dirty)
# Parse the tag
re_tag = re.compile('^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9]+-g[a-f0-9]+)?')
matches = re_tag.match(out)
major = int(matches.group(1))
minor = int(matches.group(2))
revision = int(matches.group(3))
version = GitVersion(major, minor, revision, commit, dirty)
logger.info('Latest git tag version %s' % version)
return version
re_remote_fetch_url = re.compile(
r'Fetch URL: (?:(?:(git)(?:@))|(?:(https)(?:://)))([^:/]+)[:/]([^/]+/[^.]+)(?:\.git)?')
def get_repo(path=os.getcwd(), git_executable=find_exe_in_path('git')):
if isinstance(git_executable, list):
git_executable = git_executable[0]
cmd = [git_executable, 'remote', 'show', '-n', 'origin']
code, out, err = execute_command(
cmd,
'Failed to get repository remote information',
cwd=path)
match = re_remote_fetch_url.search(out)
if not match:
raise ExecuteCommandError('Failed to match fetch url', cmd, code, out,
err)
protocol = match.group(1) or match.group(2)
server = match.group(3)
if server != 'github.com':
raise ExecuteCommandError('Repository is not from github', cmd, code,
out, err)
repo = match.group(4)
return repo
def get_git_version(git_executable=find_exe_in_path('git'),
logger=EmptyLogger()):
if isinstance(git_executable, list):
git_executable = git_executable[0]
logger.debug('Getting git version')
_, out, _ = execute_command([git_executable, '--version'])
git_version = Version(out.replace('git version ', ''))
logger.debug('Using git %s' % git_version)
return git_version
changelog_template = \
'## [v{{version.to}}](https://github.com/{{repo}}/tree/v{{version.to}}) ({{date}})\n' \
'{{#version.from}}' \
'[Full Changelog](https://github.com/{{repo}}/compare/v{{version.from}}...v{{version.to}})' \
'{{/version.from}}' \
'{{#milestone}}' \
'{{#version.from}} {{/version.from}}' \
'[Milestone]({{html_url}})' \
'{{/milestone}}\n' \
'\n' \
'{{description}}\n' \
'\n' \
'**Closed issues:**\n' \
'{{#issues}}\n' \
'\n' \
' - {{title}} [\#{{number}}]({{html_url}})\n' \
'{{/issues}}\n' \
'{{^issues}}\n' \
'\n' \
'_None_\n' \
'{{/issues}}\n' \
'\n' \
'**Merged pull requests:**\n' \
'{{#pullrequests}}\n' \
'\n' \
' - {{title}} [\#{{number}}]({{pull_request.html_url}})\n' \
'{{/pullrequests}}\n' \
'{{^pullrequests}}\n' \
'\n' \
'_None_\n' \
'{{/pullrequests}}\n'
def get_closed_issues(repo,
token=os.environ.get('GITHUB_TOKEN', None),
since=None,
logger=EmptyLogger()):
logger.debug('Getting issues for %s' % (repo))
if not token:
raise ReleaseError('Must provide a valid GitHub API token')
issues = []
params = {'state': 'closed', 'sort': 'asc', 'access_token': token, }
if since:
since = since.astimezone(timezone.utc)
params['since'] = since.isoformat()[:19] + 'Z'
r = requests.get('https://api.github.com/repos/%s/issues' % repo,
params=params)
if r.status_code != 200:
raise ReleaseError('Failed to retrieve github issues from %s: %s' %
(repo, r.json()['message']))
issues = r.json()
logger.debug('Retrieved %i closed issues for %s' % (len(issues), repo))
return issues
def create_changelog(current_version,
previous_version,
repo,
milestone=None,
token=os.environ.get('GITHUB_TOKEN', None),
description=None,
since=None,
date=datetime.utcnow(),
template=changelog_template,
logger=EmptyLogger()):
logger.debug('Creating changelog for %s from %s' % (current_version, repo))
description = description or 'The v%s release of %s' % (current_version,
repo.split('/')[1])
issues = get_closed_issues(repo=repo,
token=token,
since=since,
logger=logger)
if milestone:
milestone[
'html_url'] = 'https://github.com/%s/issues?q=milestone%%3Av%s+is%%3Aall' % (
repo, current_version)
data = {
'version': {
'from': str(previous_version)
if previous_version > (0, 0, 0) else None,
'to': str(current_version),
},
'milestone': milestone,
'date': date.isoformat()[:10],
'repo': repo,
'description': description,
'issues': [i for i in issues if not i.get('pull_request', None)],
'pullrequests': [i for i in issues if i.get('pull_request', None)],
}
renderer = pystache.Renderer()
parsed = pystache.parse(template)
changelog = renderer.render(parsed, data)
logger.info('Rendered changelog')
return changelog
def write_version(path, version, logger=EmptyLogger()):
if not isinstance(version, Version):
raise ValueError('must provide a version class')
version = Version(version)
with open(path, 'w') as f:
f.write('%s' % version)
logger.info('Wrote %s' % os.path.basename(path))
def write_changelog(path, changelog, logger=EmptyLogger()):
try:
for line in fileinput.input(path, inplace=True):
sys.stdout.write(line)
if line.startswith('# Changelog'):
print()
sys.stdout.write(changelog)
logger.info('Updated %s' % os.path.basename(path))
except EnvironmentError as e:
if e.errno == errno.ENOENT:
with open(path, 'w') as f:
f.write('# Changelog\n\n')
f.write(changelog)
logger.info('Created %s' % os.path.basename(path))
else:
raise
def get_git_root(path, git_executable=find_exe_in_path('git')):
abspath = os.path.abspath(path)
if os.path.isfile(abspath):
abspath = os.path.dirname(abspath)
cmd = [git_executable, 'rev-parse', '--show-toplevel']
_, out, _ = execute_command(cmd,
'Failed to find root of repository',
cwd=abspath)
return out.strip()
def commit_file(path,
message,
git_executable=find_exe_in_path('git'),
logger=EmptyLogger()):
if isinstance(git_executable, list):
git_executable = git_executable[0]
logger.debug('Commiting %s' % path)
cwd = get_git_root(path, git_executable=git_executable)
path = os.path.relpath(path, cwd)
cmd = [git_executable, 'add', path]
execute_command(cmd, 'Failed to add file %s' % path, cwd=cwd)
cmd = [git_executable, 'commit', '-m', message]
execute_command(cmd, 'Failed to commit file %s' % path, cwd=cwd)
logger.info('Committed %s' % path)
def get_tag_date(tag,
path=os.getcwd(),
git_executable=find_exe_in_path('git')):
if isinstance(git_executable, list):
git_executable = git_executable[0]
cwd = get_git_root(path, git_executable=git_executable)
cmd = [git_executable, 'log', '-1', '--format=%ai', tag]
_, out, _ = execute_command(cmd,
'Failed to get tag date: %s' % tag,
cwd=cwd)
out = out.strip()
return datetime.strptime(out, '%Y-%m-%d %H:%M:%S %z')
def create_git_version_tag(version,
message=None,
path=os.getcwd(),
git_executable=find_exe_in_path('git'),
logger=EmptyLogger()):
if isinstance(git_executable, list):
git_executable = git_executable[0]
if not isinstance(version, Version):
raise ValueError('must provide a version class')
version = Version(version)
logger.debug('Tagging %s' % version)
message = message or 'The v%s release of the project' % version
cwd = get_git_root(path, git_executable=git_executable)
cmd = [git_executable, 'tag', '-a', 'v%s' % version, '-m', message]
execute_command(cmd, 'Failed to create version tag %s' % version, cwd=cwd)
logger.info('Tagged %s' % version)
def create_release(repo,
version,
description,
token=os.environ.get('GITHUB_TOKEN', None),
files=[],
path=os.getcwd(),
git_executable=find_exe_in_path('git'),
logger=EmptyLogger()):
if isinstance(git_executable, list):
git_executable = git_executable[0]
if not isinstance(version, Version):
raise ValueError('must provide a version class')
logger.debug('Creating github release %s' % version)
r = requests.post('https://api.github.com/repos/%s/releases' % repo,
params={
'access_token': token,
},
json={
'tag_name': 'v%s' % version,
'name': str(version),
'body': description,
})
if r.status_code != 201:
json = r.json()
message = json['message']
errors = json.get('errors', [])
for e in errors:
message += '\n - %s: %s: %s' % (e.get('resource', 'unknown'),
e.get('field', 'unknown'),
e.get('code', 'unknown'))
raise ReleaseError('Failed to create github release %s: %s' %
(repo, message))
logger.info('Created GitHub release')
def release(category='patch',
path=os.getcwd(),
git_executable=find_exe_in_path('git'),
token=os.environ.get('GITHUB_TOKEN', None),
repo=None,
date=datetime.utcnow(),
description=None,
changelog='CHANGELOG.md',
version='VERSION',
template=changelog_template,
logger=EmptyLogger(),
hooks={}):
'''
Performs the release of a repository on GitHub.
'''
if isinstance(git_executable, list):
git_executable = git_executable[0]
logger.debug('Starting %r release' % category)
git_version = get_git_version(git_executable=git_executable, logger=logger)
if git_version < (1, 0, 0):
raise ReleaseError('The version of git is too old %s' % git_version)
previous_version = get_git_tag_version(path=path,
git_executable=git_executable,
logger=logger)
if previous_version.dirty:
raise ReleaseError(
'Cannot release a dirty repository. Make sure all files are committed')
current_version = Version(previous_version)
previous_version = Version(current_version)
current_version.bump(category)
logger.debug('Previous version %r' % previous_version)
logger.debug('Bumped version %r' % current_version)
repo = repo or get_repo(path=path, git_executable=git_executable)
description = description or 'The v%s release of %s' % (current_version,
repo.split('/')[1])
milestones = get_milestones(repo=repo, token=token, logger=logger)
try:
milestone = [
m
for m in milestones
if m['title'] == ('v%s' % current_version) and m['state'] == 'open'
][0]
open_issues = milestone['open_issues']
if open_issues:
raise ReleaseError('The v%s milestone has %d open issues' %
(current_version, open_issues))
except IndexError:
milestone = None
try:
previous_date = get_tag_date('v%s' % previous_version,
path=path,
git_executable=git_executable)
except ExecuteCommandError:
previous_date = None
changelog_data = create_changelog(description=description,
repo=repo,
date=date,
token=token,
current_version=current_version,
previous_version=previous_version,
template=template,
since=previous_date,
logger=logger,
milestone=milestone)
changelog_data = hooks.get('changelog', lambda d: d)(changelog_data)
write_changelog(path=os.path.join(path, changelog),
changelog=changelog_data,
logger=logger)
commit_file(changelog,
'Updated changelog for v%s' % current_version,
git_executable=git_executable,
logger=logger)
write_version(path=os.path.join(path, version),
version=current_version,
logger=logger)
commit_file(version,
'Updated version to v%s' % current_version,
git_executable=git_executable,
logger=logger)
create_git_version_tag(current_version,
message=description,
path=path,
git_executable=git_executable,
logger=logger)
logger.debug('Pushing branch to remote')
cwd = get_git_root(path, git_executable=git_executable)
cmd = [git_executable, 'push']
execute_command(cmd, 'Failed to push to remote', cwd=cwd)
logger.info('Pushed branch to remote')
logger.debug('Pushing tags to remote')
cwd = get_git_root(path, git_executable=git_executable)
cmd = [git_executable, 'push', '--tags']
execute_command(cmd, 'Failed to push tags to remote', cwd=cwd)
logger.info('Pushed tags to remote')
files = []
create_release(path=path,
version=current_version,
description=changelog_data,
git_executable=git_executable,
repo=repo,
logger=logger,
files=files,
token=token)
if milestone:
close_milestone(number=milestone['number'],
repo=repo,
token=token,
logger=logger)
logger.info('Released %s' % current_version)
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
2022,
199,
646,
7554,
199,
646,
4298,
199,
646,
570,
1210,
199,
646,
3873,
199,
199,
504,
2197,
492,
2197,
12,
7137,
199,
199,
893,
26,
272,
492,
4145,
199,
2590,
3545,
26,
272,
746,
3545,
8,
267,
283,
4276,
370,
492,
8891,
6615,
22458,
1255,
8891,
9983,
3907,
4145,
3985,
358,
199,
199,
893,
26,
272,
492,
1134,
1207,
595,
199,
2590,
3545,
26,
272,
746,
3545,
8,
267,
283,
4276,
370,
492,
8891,
647,
1207,
595,
22458,
1255,
8891,
9983,
3907,
1134,
1207,
595,
3985,
358,
421,
199,
533,
17646,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
304,
267,
291,
14,
1188,
275,
1245,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1188,
421,
199,
533,
17009,
31542,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
2088,
12,
1233,
12,
734,
12,
2329,
304,
267,
291,
14,
1188,
275,
1245,
267,
291,
14,
1760,
275,
2088,
267,
291,
14,
600,
275,
1233,
267,
291,
14,
548,
275,
734,
267,
291,
14,
1508,
275,
2329,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1188,
421,
199,
533,
9630,
4455,
8,
785,
304,
272,
1449,
17473,
376,
4514,
402,
376,
2701,
2050,
805,
2344,
339,
347,
3105,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
2256,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
7987,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
1125,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
19698,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
663,
4670,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
421,
199,
533,
3394,
8,
785,
304,
272,
1449,
18089,
282,
1015,
1329,
2344,
339,
347,
636,
826,
721,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
1449,
267,
437,
1015,
1329,
883,
506,
17321,
543,
26,
953,
446,
282,
6308,
13,
12794,
1059,
355,
446,
3394,
360,
17,
14,
18,
14,
19,
358,
288,
446,
376,
6076,
355,
446,
3394,
779,
17,
12,
499,
12,
650,
566,
288,
446,
542,
529,
323,
2368,
355,
446,
658,
3353,
8,
17,
12,
499,
12,
650,
12544,
288,
446,
4573,
1015,
1021,
355,
446,
658,
3353,
8,
3353,
8,
17,
12,
499,
12,
650,
430,
64,
288,
446,
282,
2600,
355,
446,
658,
3353,
3252,
11067,
356,
18,
2584,
8452,
356,
17,
2584,
2068,
356,
19,
1552,
64,
288,
446,
7681,
355,
446,
658,
3353,
8,
11067,
275,
499,
12,
8452,
275,
413,
12,
3371,
275,
650,
12544,
267,
1449,
267,
862,
26,
288,
1015,
275,
334,
75,
59,
16,
1055,
8452,
12,
1022,
59,
16,
1055,
11067,
12,
1022,
59,
16,
1055,
2068,
9,
267,
871,
334,
10227,
12,
3146,
304,
288,
862,
26,
355,
1015,
275,
334,
829,
459,
8452,
995,
4775,
459,
11067,
995,
4775,
459,
2068,
1105,
288,
871,
334,
10230,
12,
3146,
304,
355,
862,
26,
490,
1015,
275,
334,
75,
59,
16,
2733,
8452,
995,
1022,
59,
16,
2733,
11067,
995,
1022,
59,
16,
2733,
2068,
1105,
355,
871,
334,
10230,
12,
3146,
304,
490,
340,
1228,
8,
75,
59,
16,
467,
620,
304,
717,
1015,
275,
1022,
59,
16,
1055,
1294,
7563,
490,
587,
26,
717,
862,
26,
1169,
1015,
275,
334,
75,
59,
16,
1527,
16,
467,
1022,
59,
16,
1527,
17,
467,
1022,
59,
16,
1527,
18,
566,
717,
871,
334,
12129,
12,
3146,
304,
1169,
1015,
275,
1022,
267,
291,
14,
8452,
275,
1109,
8,
1023,
59,
16,
566,
267,
291,
14,
11067,
275,
1109,
8,
1023,
59,
17,
566,
267,
291,
14,
2068,
275,
1109,
8,
1023,
59,
18,
566,
339,
347,
28108,
8,
277,
12,
4637,
304,
267,
1449,
267,
699,
1220,
83,
314,
1015,
1329,
10298,
641,
314,
4637,
267,
1449,
267,
5371,
8,
277,
12,
4637,
12,
2519,
8,
277,
12,
4637,
9,
435,
413,
9,
267,
340,
4637,
508,
283,
8452,
356,
288,
291,
14,
11067,
275,
378,
288,
291,
14,
2068,
275,
378,
267,
916,
4637,
508,
283,
11067,
356,
288,
291,
14,
2068,
275,
378,
339,
347,
636,
3308,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
690,
2008,
8,
1848,
9,
339,
347,
636,
303,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
2356,
2008,
8,
1848,
9,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
665,
2008,
8,
1848,
9,
339,
347,
636,
274,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
2695,
2008,
8,
1848,
9,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
508,
2008,
8,
1848,
9,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
1137,
2008,
8,
1848,
9,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
1449,
267,
22819,
8494,
402,
314,
1015,
1329,
267,
1449,
267,
340,
1478,
508,
378,
26,
288,
372,
291,
14,
8452,
267,
916,
1478,
508,
413,
26,
288,
372,
291,
14,
11067,
267,
916,
1478,
508,
499,
26,
288,
372,
291,
14,
2068,
267,
587,
26,
288,
746,
7888,
360,
1023,
1478,
734,
402,
1425,
358,
339,
347,
636,
2722,
721,
277,
304,
267,
1449,
267,
21552,
282,
6308,
13,
12794,
1059,
6025,
402,
314,
1015,
1329,
267,
1449,
267,
372,
1543,
73,
4111,
73,
4111,
73,
7,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
2068,
9,
421,
199,
533,
12579,
3353,
8,
3353,
304,
272,
1449,
33,
6135,
7611,
1015,
1329,
2344,
339,
347,
636,
826,
721,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
1449,
267,
437,
6135,
1015,
1329,
883,
506,
17321,
543,
26,
953,
446,
282,
6308,
13,
12794,
1059,
355,
446,
3394,
360,
17,
14,
18,
14,
19,
14,
2829,
19,
2158,
2824,
68,
13,
8799,
358,
288,
446,
376
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
2022,
199,
646,
7554,
199,
646,
4298,
199,
646,
570,
1210,
199,
646,
3873,
199,
199,
504,
2197,
492,
2197,
12,
7137,
199,
199,
893,
26,
272,
492,
4145,
199,
2590,
3545,
26,
272,
746,
3545,
8,
267,
283,
4276,
370,
492,
8891,
6615,
22458,
1255,
8891,
9983,
3907,
4145,
3985,
358,
199,
199,
893,
26,
272,
492,
1134,
1207,
595,
199,
2590,
3545,
26,
272,
746,
3545,
8,
267,
283,
4276,
370,
492,
8891,
647,
1207,
595,
22458,
1255,
8891,
9983,
3907,
1134,
1207,
595,
3985,
358,
421,
199,
533,
17646,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
304,
267,
291,
14,
1188,
275,
1245,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1188,
421,
199,
533,
17009,
31542,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1245,
12,
2088,
12,
1233,
12,
734,
12,
2329,
304,
267,
291,
14,
1188,
275,
1245,
267,
291,
14,
1760,
275,
2088,
267,
291,
14,
600,
275,
1233,
267,
291,
14,
548,
275,
734,
267,
291,
14,
1508,
275,
2329,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
1188,
421,
199,
533,
9630,
4455,
8,
785,
304,
272,
1449,
17473,
376,
4514,
402,
376,
2701,
2050,
805,
2344,
339,
347,
3105,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
2256,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
7987,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
1125,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
19698,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
339,
347,
663,
4670,
8,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
986,
421,
199,
533,
3394,
8,
785,
304,
272,
1449,
18089,
282,
1015,
1329,
2344,
339,
347,
636,
826,
721,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
1449,
267,
437,
1015,
1329,
883,
506,
17321,
543,
26,
953,
446,
282,
6308,
13,
12794,
1059,
355,
446,
3394,
360,
17,
14,
18,
14,
19,
358,
288,
446,
376,
6076,
355,
446,
3394,
779,
17,
12,
499,
12,
650,
566,
288,
446,
542,
529,
323,
2368,
355,
446,
658,
3353,
8,
17,
12,
499,
12,
650,
12544,
288,
446,
4573,
1015,
1021,
355,
446,
658,
3353,
8,
3353,
8,
17,
12,
499,
12,
650,
430,
64,
288,
446,
282,
2600,
355,
446,
658,
3353,
3252,
11067,
356,
18,
2584,
8452,
356,
17,
2584,
2068,
356,
19,
1552,
64,
288,
446,
7681,
355,
446,
658,
3353,
8,
11067,
275,
499,
12,
8452,
275,
413,
12,
3371,
275,
650,
12544,
267,
1449,
267,
862,
26,
288,
1015,
275,
334,
75,
59,
16,
1055,
8452,
12,
1022,
59,
16,
1055,
11067,
12,
1022,
59,
16,
1055,
2068,
9,
267,
871,
334,
10227,
12,
3146,
304,
288,
862,
26,
355,
1015,
275,
334,
829,
459,
8452,
995,
4775,
459,
11067,
995,
4775,
459,
2068,
1105,
288,
871,
334,
10230,
12,
3146,
304,
355,
862,
26,
490,
1015,
275,
334,
75,
59,
16,
2733,
8452,
995,
1022,
59,
16,
2733,
11067,
995,
1022,
59,
16,
2733,
2068,
1105,
355,
871,
334,
10230,
12,
3146,
304,
490,
340,
1228,
8,
75,
59,
16,
467,
620,
304,
717,
1015,
275,
1022,
59,
16,
1055,
1294,
7563,
490,
587,
26,
717,
862,
26,
1169,
1015,
275,
334,
75,
59,
16,
1527,
16,
467,
1022,
59,
16,
1527,
17,
467,
1022,
59,
16,
1527,
18,
566,
717,
871,
334,
12129,
12,
3146,
304,
1169,
1015,
275,
1022,
267,
291,
14,
8452,
275,
1109,
8,
1023,
59,
16,
566,
267,
291,
14,
11067,
275,
1109,
8,
1023,
59,
17,
566,
267,
291,
14,
2068,
275,
1109,
8,
1023,
59,
18,
566,
339,
347,
28108,
8,
277,
12,
4637,
304,
267,
1449,
267,
699,
1220,
83,
314,
1015,
1329,
10298,
641,
314,
4637,
267,
1449,
267,
5371,
8,
277,
12,
4637,
12,
2519,
8,
277,
12,
4637,
9,
435,
413,
9,
267,
340,
4637,
508,
283,
8452,
356,
288,
291,
14,
11067,
275,
378,
288,
291,
14,
2068,
275,
378,
267,
916,
4637,
508,
283,
11067,
356,
288,
291,
14,
2068,
275,
378,
339,
347,
636,
3308,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
690,
2008,
8,
1848,
9,
339,
347,
636,
303,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
2356,
2008,
8,
1848,
9,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
665,
2008,
8,
1848,
9,
339,
347,
636,
274,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
2695,
2008,
8,
1848,
9,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
508,
2008,
8,
1848,
9,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
2008,
8,
277,
9,
1137,
2008,
8,
1848,
9,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
1449,
267,
22819,
8494,
402,
314,
1015,
1329,
267,
1449,
267,
340,
1478,
508,
378,
26,
288,
372,
291,
14,
8452,
267,
916,
1478,
508,
413,
26,
288,
372,
291,
14,
11067,
267,
916,
1478,
508,
499,
26,
288,
372,
291,
14,
2068,
267,
587,
26,
288,
746,
7888,
360,
1023,
1478,
734,
402,
1425,
358,
339,
347,
636,
2722,
721,
277,
304,
267,
1449,
267,
21552,
282,
6308,
13,
12794,
1059,
6025,
402,
314,
1015,
1329,
267,
1449,
267,
372,
1543,
73,
4111,
73,
4111,
73,
7,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
2068,
9,
421,
199,
533,
12579,
3353,
8,
3353,
304,
272,
1449,
33,
6135,
7611,
1015,
1329,
2344,
339,
347,
636,
826,
721,
277,
12,
627,
75,
12,
1011,
829,
304,
267,
1449,
267,
437,
6135,
1015,
1329,
883,
506,
17321,
543,
26,
953,
446,
282,
6308,
13,
12794,
1059,
355,
446,
3394,
360,
17,
14,
18,
14,
19,
14,
2829,
19,
2158,
2824,
68,
13,
8799,
358,
288,
446,
376,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rynomad/SFCCW2
|
server/express/node_modules/npm/node_modules/node-gyp/gyp/test/lib/TestGyp.py
|
46
|
37947
|
# 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.
"""
TestGyp.py: a testing framework for GYP integration tests.
"""
import os
import re
import shutil
import stat
import subprocess
import sys
import tempfile
import TestCommon
from TestCommon import __all__
__all__.extend([
'TestGyp',
])
def remove_debug_line_numbers(contents):
"""Function to remove the line numbers from the debug output
of gyp and thus remove the exremem fragility of the stdout
comparison tests.
"""
lines = contents.splitlines()
# split each line on ":"
lines = [l.split(":", 3) for l in lines]
# join each line back together while ignoring the
# 3rd column which is the line number
lines = [len(l) > 3 and ":".join(l[3:]) or l for l in lines]
return "\n".join(lines)
def match_modulo_line_numbers(contents_a, contents_b):
"""File contents matcher that ignores line numbers."""
contents_a = remove_debug_line_numbers(contents_a)
contents_b = remove_debug_line_numbers(contents_b)
return TestCommon.match_exact(contents_a, contents_b)
class TestGypBase(TestCommon.TestCommon):
"""
Class for controlling end-to-end tests of gyp generators.
Instantiating this class will create a temporary directory and
arrange for its destruction (via the TestCmd superclass) and
copy all of the non-gyptest files in the directory hierarchy of the
executing script.
The default behavior is to test the 'gyp' or 'gyp.bat' file in the
current directory. An alternative may be specified explicitly on
instantiation, or by setting the TESTGYP_GYP environment variable.
This class should be subclassed for each supported gyp generator
(format). Various abstract methods below define calling signatures
used by the test scripts to invoke builds on the generated build
configuration and to run executables generated by those builds.
"""
build_tool = None
build_tool_list = []
_exe = TestCommon.exe_suffix
_obj = TestCommon.obj_suffix
shobj_ = TestCommon.shobj_prefix
_shobj = TestCommon.shobj_suffix
lib_ = TestCommon.lib_prefix
_lib = TestCommon.lib_suffix
dll_ = TestCommon.dll_prefix
_dll = TestCommon.dll_suffix
# Constants to represent different targets.
ALL = '__all__'
DEFAULT = '__default__'
# Constants for different target types.
EXECUTABLE = '__executable__'
STATIC_LIB = '__static_lib__'
SHARED_LIB = '__shared_lib__'
def __init__(self, gyp=None, *args, **kw):
self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
self.extra_args = sys.argv[1:]
if not gyp:
gyp = os.environ.get('TESTGYP_GYP')
if not gyp:
if sys.platform == 'win32':
gyp = 'gyp.bat'
else:
gyp = 'gyp'
self.gyp = os.path.abspath(gyp)
self.initialize_build_tool()
kw.setdefault('match', TestCommon.match_exact)
# Put test output in out/testworkarea by default.
# Use temporary names so there are no collisions.
workdir = os.path.join('out', kw.get('workdir', 'testworkarea'))
# Create work area if it doesn't already exist.
if not os.path.isdir(workdir):
os.makedirs(workdir)
kw['workdir'] = tempfile.mktemp(prefix='testgyp.', dir=workdir)
formats = kw.pop('formats', [])
super(TestGypBase, self).__init__(*args, **kw)
excluded_formats = set([f for f in formats if f[0] == '!'])
included_formats = set(formats) - excluded_formats
if ('!'+self.format in excluded_formats or
included_formats and self.format not in included_formats):
msg = 'Invalid test for %r format; skipping test.\n'
self.skip_test(msg % self.format)
self.copy_test_configuration(self.origin_cwd, self.workdir)
self.set_configuration(None)
# Set $HOME so that gyp doesn't read the user's actual
# ~/.gyp/include.gypi file, which may contain variables
# and other settings that would change the output.
os.environ['HOME'] = self.workpath()
# Clear $GYP_DEFINES for the same reason.
if 'GYP_DEFINES' in os.environ:
del os.environ['GYP_DEFINES']
def built_file_must_exist(self, name, type=None, **kw):
"""
Fails the test if the specified built file name does not exist.
"""
return self.must_exist(self.built_file_path(name, type, **kw))
def built_file_must_not_exist(self, name, type=None, **kw):
"""
Fails the test if the specified built file name exists.
"""
return self.must_not_exist(self.built_file_path(name, type, **kw))
def built_file_must_match(self, name, contents, **kw):
"""
Fails the test if the contents of the specified built file name
do not match the specified contents.
"""
return self.must_match(self.built_file_path(name, **kw), contents)
def built_file_must_not_match(self, name, contents, **kw):
"""
Fails the test if the contents of the specified built file name
match the specified contents.
"""
return self.must_not_match(self.built_file_path(name, **kw), contents)
def copy_test_configuration(self, source_dir, dest_dir):
"""
Copies the test configuration from the specified source_dir
(the directory in which the test script lives) to the
specified dest_dir (a temporary working directory).
This ignores all files and directories that begin with
the string 'gyptest', and all '.svn' subdirectories.
"""
for root, dirs, files in os.walk(source_dir):
if '.svn' in dirs:
dirs.remove('.svn')
dirs = [ d for d in dirs if not d.startswith('gyptest') ]
files = [ f for f in files if not f.startswith('gyptest') ]
for dirname in dirs:
source = os.path.join(root, dirname)
destination = source.replace(source_dir, dest_dir)
os.mkdir(destination)
if sys.platform != 'win32':
shutil.copystat(source, destination)
for filename in files:
source = os.path.join(root, filename)
destination = source.replace(source_dir, dest_dir)
shutil.copy2(source, destination)
def initialize_build_tool(self):
"""
Initializes the .build_tool attribute.
Searches the .build_tool_list for an executable name on the user's
$PATH. The first tool on the list is used as-is if nothing is found
on the current $PATH.
"""
for build_tool in self.build_tool_list:
if not build_tool:
continue
if os.path.isabs(build_tool):
self.build_tool = build_tool
return
build_tool = self.where_is(build_tool)
if build_tool:
self.build_tool = build_tool
return
if self.build_tool_list:
self.build_tool = self.build_tool_list[0]
def relocate(self, source, destination):
"""
Renames (relocates) the specified source (usually a directory)
to the specified destination, creating the destination directory
first if necessary.
Note: Don't use this as a generic "rename" operation. In the
future, "relocating" parts of a GYP tree may affect the state of
the test to modify the behavior of later method calls.
"""
destination_dir = os.path.dirname(destination)
if not os.path.exists(destination_dir):
self.subdir(destination_dir)
os.rename(source, destination)
def report_not_up_to_date(self):
"""
Reports that a build is not up-to-date.
This provides common reporting for formats that have complicated
conditions for checking whether a build is up-to-date. Formats
that expect exact output from the command (make, scons) can
just set stdout= when they call the run_build() method.
"""
print "Build is not up-to-date:"
print self.banner('STDOUT ')
print self.stdout()
stderr = self.stderr()
if stderr:
print self.banner('STDERR ')
print stderr
def run_gyp(self, gyp_file, *args, **kw):
"""
Runs gyp against the specified gyp_file with the specified args.
"""
# When running gyp, and comparing its output we use a comparitor
# that ignores the line numbers that gyp logs in its debug output.
if kw.pop('ignore_line_numbers', False):
kw.setdefault('match', match_modulo_line_numbers)
# TODO: --depth=. works around Chromium-specific tree climbing.
depth = kw.pop('depth', '.')
run_args = ['--depth='+depth, '--format='+self.format, gyp_file]
run_args.extend(self.extra_args)
run_args.extend(args)
return self.run(program=self.gyp, arguments=run_args, **kw)
def run(self, *args, **kw):
"""
Executes a program by calling the superclass .run() method.
This exists to provide a common place to filter out keyword
arguments implemented in this layer, without having to update
the tool-specific subclasses or clutter the tests themselves
with platform-specific code.
"""
if kw.has_key('SYMROOT'):
del kw['SYMROOT']
super(TestGypBase, self).run(*args, **kw)
def set_configuration(self, configuration):
"""
Sets the configuration, to be used for invoking the build
tool and testing potential built output.
"""
self.configuration = configuration
def configuration_dirname(self):
if self.configuration:
return self.configuration.split('|')[0]
else:
return 'Default'
def configuration_buildname(self):
if self.configuration:
return self.configuration
else:
return 'Default'
#
# Abstract methods to be defined by format-specific subclasses.
#
def build(self, gyp_file, target=None, **kw):
"""
Runs a build of the specified target against the configuration
generated from the specified gyp_file.
A 'target' argument of None or the special value TestGyp.DEFAULT
specifies the default argument for the underlying build tool.
A 'target' argument of TestGyp.ALL specifies the 'all' target
(if any) of the underlying build tool.
"""
raise NotImplementedError
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type.
"""
raise NotImplementedError
def built_file_basename(self, name, type=None, **kw):
"""
Returns the base name of the specified file name, of the specified type.
A bare=True keyword argument specifies that prefixes and suffixes shouldn't
be applied.
"""
if not kw.get('bare'):
if type == self.EXECUTABLE:
name = name + self._exe
elif type == self.STATIC_LIB:
name = self.lib_ + name + self._lib
elif type == self.SHARED_LIB:
name = self.dll_ + name + self._dll
return name
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable program built from a gyp-generated configuration.
The specified name should be independent of any particular generator.
Subclasses should find the output executable in the appropriate
output build directory, tack on any necessary executable suffix, etc.
"""
raise NotImplementedError
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified target is up to date.
The subclass should implement this by calling build()
(or a reasonable equivalent), checking whatever conditions
will tell it the build was an "up to date" null build, and
failing if it isn't.
"""
raise NotImplementedError
class TestGypGypd(TestGypBase):
"""
Subclass for testing the GYP 'gypd' generator (spit out the
internal data structure as pretty-printed Python).
"""
format = 'gypd'
class TestGypCustom(TestGypBase):
"""
Subclass for testing the GYP with custom generator
"""
def __init__(self, gyp=None, *args, **kw):
self.format = kw.pop("format")
super(TestGypCustom, self).__init__(*args, **kw)
class TestGypAndroid(TestGypBase):
"""
Subclass for testing the GYP Android makefile generator. Note that
build/envsetup.sh and lunch must have been run before running tests.
TODO: This is currently an incomplete implementation. We do not support
run_built_executable(), so we pass only tests which do not use this. As a
result, support for host targets is not properly tested.
"""
format = 'android'
# Note that we can't use mmm as the build tool because ...
# - it builds all targets, whereas we need to pass a target
# - it is a function, whereas the test runner assumes the build tool is a file
# Instead we use make and duplicate the logic from mmm.
build_tool_list = ['make']
# We use our custom target 'gyp_all_modules', as opposed to the 'all_modules'
# target used by mmm, to build only those targets which are part of the gyp
# target 'all'.
ALL = 'gyp_all_modules'
def __init__(self, gyp=None, *args, **kw):
# Android requires build and test output to be outside its source tree.
# We use the following working directory for the test's source, but the
# test's build output still goes to $ANDROID_PRODUCT_OUT.
# Note that some tests explicitly set format='gypd' to invoke the gypd
# backend. This writes to the source tree, but there's no way around this.
kw['workdir'] = os.path.join('/tmp', 'gyptest',
kw.get('workdir', 'testworkarea'))
# We need to remove all gyp outputs from out/. Ths is because some tests
# don't have rules to regenerate output, so they will simply re-use stale
# output if present. Since the test working directory gets regenerated for
# each test run, this can confuse things.
# We don't have a list of build outputs because we don't know which
# dependent targets were built. Instead we delete all gyp-generated output.
# This may be excessive, but should be safe.
out_dir = os.environ['ANDROID_PRODUCT_OUT']
obj_dir = os.path.join(out_dir, 'obj')
shutil.rmtree(os.path.join(obj_dir, 'GYP'), ignore_errors = True)
for x in ['EXECUTABLES', 'STATIC_LIBRARIES', 'SHARED_LIBRARIES']:
for d in os.listdir(os.path.join(obj_dir, x)):
if d.endswith('_gyp_intermediates'):
shutil.rmtree(os.path.join(obj_dir, x, d), ignore_errors = True)
for x in [os.path.join('obj', 'lib'), os.path.join('system', 'lib')]:
for d in os.listdir(os.path.join(out_dir, x)):
if d.endswith('_gyp.so'):
os.remove(os.path.join(out_dir, x, d))
super(TestGypAndroid, self).__init__(*args, **kw)
def target_name(self, target):
if target == self.ALL:
return self.ALL
# The default target is 'droid'. However, we want to use our special target
# to build only the gyp target 'all'.
if target in (None, self.DEFAULT):
return self.ALL
return target
def build(self, gyp_file, target=None, **kw):
"""
Runs a build using the Android makefiles generated from the specified
gyp_file. This logic is taken from Android's mmm.
"""
arguments = kw.get('arguments', [])[:]
arguments.append(self.target_name(target))
arguments.append('-C')
arguments.append(os.environ['ANDROID_BUILD_TOP'])
kw['arguments'] = arguments
chdir = kw.get('chdir', '')
makefile = os.path.join(self.workdir, chdir, 'GypAndroid.mk')
os.environ['ONE_SHOT_MAKEFILE'] = makefile
result = self.run(program=self.build_tool, **kw)
del os.environ['ONE_SHOT_MAKEFILE']
return result
def android_module(self, group, name, subdir):
if subdir:
name = '%s_%s' % (subdir, name)
if group == 'SHARED_LIBRARIES':
name = 'lib_%s' % name
return '%s_gyp' % name
def intermediates_dir(self, group, module_name):
return os.path.join(os.environ['ANDROID_PRODUCT_OUT'], 'obj', group,
'%s_intermediates' % module_name)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Android. Note that we don't support the configuration
parameter.
"""
# Built files are in $ANDROID_PRODUCT_OUT. This requires copying logic from
# the Android build system.
if type == None:
return os.path.join(os.environ['ANDROID_PRODUCT_OUT'], 'obj', 'GYP',
'shared_intermediates', name)
subdir = kw.get('subdir')
if type == self.EXECUTABLE:
# We don't install executables
group = 'EXECUTABLES'
module_name = self.android_module(group, name, subdir)
return os.path.join(self.intermediates_dir(group, module_name), name)
if type == self.STATIC_LIB:
group = 'STATIC_LIBRARIES'
module_name = self.android_module(group, name, subdir)
return os.path.join(self.intermediates_dir(group, module_name),
'%s.a' % module_name)
if type == self.SHARED_LIB:
group = 'SHARED_LIBRARIES'
module_name = self.android_module(group, name, subdir)
return os.path.join(self.intermediates_dir(group, module_name), 'LINKED',
'%s.so' % module_name)
assert False, 'Unhandled type'
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable program built from a gyp-generated configuration.
This is not correctly implemented for Android. For now, we simply check
that the executable file exists.
"""
# Running executables requires a device. Even if we build for target x86,
# the binary is not built with the correct toolchain options to actually
# run on the host.
# Copied from TestCommon.run()
match = kw.pop('match', self.match)
status = None
if os.path.exists(self.built_file_path(name)):
status = 1
self._complete(None, None, None, None, status, self.match)
def match_single_line(self, lines = None, expected_line = None):
"""
Checks that specified line appears in the text.
"""
for line in lines.split('\n'):
if line == expected_line:
return 1
return
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified target is up to date.
"""
kw['stdout'] = ("make: Nothing to be done for `%s'." %
self.target_name(target))
# We need to supply a custom matcher, since we don't want to depend on the
# exact stdout string.
kw['match'] = self.match_single_line
return self.build(gyp_file, target, **kw)
class TestGypMake(TestGypBase):
"""
Subclass for testing the GYP Make generator.
"""
format = 'make'
build_tool_list = ['make']
ALL = 'all'
def build(self, gyp_file, target=None, **kw):
"""
Runs a Make build using the Makefiles generated from the specified
gyp_file.
"""
arguments = kw.get('arguments', [])[:]
if self.configuration:
arguments.append('BUILDTYPE=' + self.configuration)
if target not in (None, self.DEFAULT):
arguments.append(target)
# Sub-directory builds provide per-gyp Makefiles (i.e.
# Makefile.gyp_filename), so use that if there is no Makefile.
chdir = kw.get('chdir', '')
if not os.path.exists(os.path.join(chdir, 'Makefile')):
print "NO Makefile in " + os.path.join(chdir, 'Makefile')
arguments.insert(0, '-f')
arguments.insert(1, os.path.splitext(gyp_file)[0] + '.Makefile')
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Make target is up to date.
"""
if target in (None, self.DEFAULT):
message_target = 'all'
else:
message_target = target
kw['stdout'] = "make: Nothing to be done for `%s'.\n" % message_target
return self.build(gyp_file, target, **kw)
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by Make.
"""
configuration = self.configuration_dirname()
libdir = os.path.join('out', configuration, 'lib')
# TODO(piman): when everything is cross-compile safe, remove lib.target
if sys.platform == 'darwin':
# Mac puts target shared libraries right in the product directory.
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = (
libdir + '.host:' + os.path.join('out', configuration))
else:
os.environ['LD_LIBRARY_PATH'] = libdir + '.host:' + libdir + '.target'
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Make.
Built files are in the subdirectory 'out/{configuration}'.
The default is 'out/Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
A subdir= keyword argument specifies a library subdirectory within
the default 'obj.target'.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
configuration = self.configuration_dirname()
result.extend(['out', configuration])
if type == self.STATIC_LIB and sys.platform != 'darwin':
result.append('obj.target')
elif type == self.SHARED_LIB and sys.platform != 'darwin':
result.append('lib.target')
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def ConvertToCygpath(path):
"""Convert to cygwin path if we are using cygwin."""
if sys.platform == 'cygwin':
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
return path
def FindVisualStudioInstallation():
"""Returns appropriate values for .build_tool and .uses_msbuild fields
of TestGypBase for Visual Studio.
We use the value specified by GYP_MSVS_VERSION. If not specified, we
search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable.
Failing that, we search for likely deployment paths.
"""
possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix)
for drive in range(ord('C'), ord('Z') + 1)
for suffix in ['', ' (x86)']]
possible_paths = {
'2012': r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com',
'2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com',
'2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com',
'2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'}
possible_roots = [ConvertToCygpath(r) for r in possible_roots]
msvs_version = 'auto'
for flag in (f for f in sys.argv if f.startswith('msvs_version=')):
msvs_version = flag.split('=')[-1]
msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version)
build_tool = None
if msvs_version in possible_paths:
# Check that the path to the specified GYP_MSVS_VERSION exists.
path = possible_paths[msvs_version]
for r in possible_roots:
bt = os.path.join(r, path)
if os.path.exists(bt):
build_tool = bt
uses_msbuild = msvs_version >= '2010'
return build_tool, uses_msbuild
else:
print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
'but corresponding "%s" was not found.' % (msvs_version, path))
if build_tool:
# We found 'devenv' on the path, use that and try to guess the version.
for version, path in possible_paths.iteritems():
if build_tool.find(path) >= 0:
uses_msbuild = version >= '2010'
return build_tool, uses_msbuild
else:
# If not, assume not MSBuild.
uses_msbuild = False
return build_tool, uses_msbuild
# Neither GYP_MSVS_VERSION nor the path help us out. Iterate through
# the choices looking for a match.
for version in sorted(possible_paths, reverse=True):
path = possible_paths[version]
for r in possible_roots:
bt = os.path.join(r, path)
if os.path.exists(bt):
build_tool = bt
uses_msbuild = msvs_version >= '2010'
return build_tool, uses_msbuild
print 'Error: could not find devenv'
sys.exit(1)
class TestGypOnMSToolchain(TestGypBase):
"""
Common subclass for testing generators that target the Microsoft Visual
Studio toolchain (cl, link, dumpbin, etc.)
"""
@staticmethod
def _ComputeVsvarsPath(devenv_path):
devenv_dir = os.path.split(devenv_path)[0]
vsvars_path = os.path.join(devenv_path, '../../Tools/vsvars32.bat')
return vsvars_path
def initialize_build_tool(self):
super(TestGypOnMSToolchain, self).initialize_build_tool()
if sys.platform in ('win32', 'cygwin'):
self.devenv_path, self.uses_msbuild = FindVisualStudioInstallation()
self.vsvars_path = TestGypOnMSToolchain._ComputeVsvarsPath(
self.devenv_path)
def run_dumpbin(self, *dumpbin_args):
"""Run the dumpbin tool with the specified arguments, and capturing and
returning stdout."""
assert sys.platform in ('win32', 'cygwin')
cmd = os.environ.get('COMSPEC', 'cmd.exe')
arguments = [cmd, '/c', self.vsvars_path, '&&', 'dumpbin']
arguments.extend(dumpbin_args)
proc = subprocess.Popen(arguments, stdout=subprocess.PIPE)
output = proc.communicate()[0]
assert not proc.returncode
return output
class TestGypNinja(TestGypOnMSToolchain):
"""
Subclass for testing the GYP Ninja generator.
"""
format = 'ninja'
build_tool_list = ['ninja']
ALL = 'all'
DEFAULT = 'all'
def run_gyp(self, gyp_file, *args, **kw):
TestGypBase.run_gyp(self, gyp_file, *args, **kw)
def build(self, gyp_file, target=None, **kw):
arguments = kw.get('arguments', [])[:]
# Add a -C output/path to the command line.
arguments.append('-C')
arguments.append(os.path.join('out', self.configuration_dirname()))
if target is None:
target = 'all'
arguments.append(target)
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def run_built_executable(self, name, *args, **kw):
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
if sys.platform == 'darwin':
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append('out')
result.append(self.configuration_dirname())
if type == self.STATIC_LIB:
if sys.platform != 'darwin':
result.append('obj')
elif type == self.SHARED_LIB:
if sys.platform != 'darwin' and sys.platform != 'win32':
result.append('lib')
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def up_to_date(self, gyp_file, target=None, **kw):
result = self.build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
if 'ninja: no work to do' not in stdout:
self.report_not_up_to_date()
self.fail_test()
return result
class TestGypMSVS(TestGypOnMSToolchain):
"""
Subclass for testing the GYP Visual Studio generator.
"""
format = 'msvs'
u = r'=== Build: 0 succeeded, 0 failed, (\d+) up-to-date, 0 skipped ==='
up_to_date_re = re.compile(u, re.M)
# Initial None element will indicate to our .initialize_build_tool()
# method below that 'devenv' was not found on %PATH%.
#
# Note: we must use devenv.com to be able to capture build output.
# Directly executing devenv.exe only sends output to BuildLog.htm.
build_tool_list = [None, 'devenv.com']
def initialize_build_tool(self):
super(TestGypMSVS, self).initialize_build_tool()
self.build_tool = self.devenv_path
def build(self, gyp_file, target=None, rebuild=False, **kw):
"""
Runs a Visual Studio build using the configuration generated
from the specified gyp_file.
"""
configuration = self.configuration_buildname()
if rebuild:
build = '/Rebuild'
else:
build = '/Build'
arguments = kw.get('arguments', [])[:]
arguments.extend([gyp_file.replace('.gyp', '.sln'),
build, configuration])
# Note: the Visual Studio generator doesn't add an explicit 'all'
# target, so we just treat it the same as the default.
if target not in (None, self.ALL, self.DEFAULT):
arguments.extend(['/Project', target])
if self.configuration:
arguments.extend(['/ProjectConfig', self.configuration])
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Visual Studio target is up to date.
Beware that VS2010 will behave strangely if you build under
C:\USERS\yourname\AppData\Local. It will cause needless work. The ouptut
will be "1 succeeded and 0 up to date". MSBuild tracing reveals that:
"Project 'C:\Users\...\AppData\Local\...vcxproj' not up to date because
'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 10.0\VC\BIN\1033\CLUI.DLL'
was modified at 02/21/2011 17:03:30, which is newer than '' which was
modified at 01/01/0001 00:00:00.
The workaround is to specify a workdir when instantiating the test, e.g.
test = TestGyp.TestGyp(workdir='workarea')
"""
result = self.build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
m = self.up_to_date_re.search(stdout)
up_to_date = m and int(m.group(1)) > 0
if not up_to_date:
self.report_not_up_to_date()
self.fail_test()
return result
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by Visual Studio.
"""
configuration = self.configuration_dirname()
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Visual Studio.
Built files are in a subdirectory that matches the configuration
name. The default is 'Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append(self.configuration_dirname())
if type == self.STATIC_LIB:
result.append('lib')
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
class TestGypSCons(TestGypBase):
"""
Subclass for testing the GYP SCons generator.
"""
format = 'scons'
build_tool_list = ['scons', 'scons.py']
ALL = 'all'
def build(self, gyp_file, target=None, **kw):
"""
Runs a scons build using the SCons configuration generated from the
specified gyp_file.
"""
arguments = kw.get('arguments', [])[:]
dirname = os.path.dirname(gyp_file)
if dirname:
arguments.extend(['-C', dirname])
if self.configuration:
arguments.append('--mode=' + self.configuration)
if target not in (None, self.DEFAULT):
arguments.append(target)
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified SCons target is up to date.
"""
if target in (None, self.DEFAULT):
up_to_date_targets = 'all'
else:
up_to_date_targets = target
up_to_date_lines = []
for arg in up_to_date_targets.split():
up_to_date_lines.append("scons: `%s' is up to date.\n" % arg)
kw['stdout'] = ''.join(up_to_date_lines)
arguments = kw.get('arguments', [])[:]
arguments.append('-Q')
kw['arguments'] = arguments
return self.build(gyp_file, target, **kw)
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by scons.
"""
configuration = self.configuration_dirname()
os.environ['LD_LIBRARY_PATH'] = os.path.join(configuration, 'lib')
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Scons.
Built files are in a subdirectory that matches the configuration
name. The default is 'Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append(self.configuration_dirname())
if type in (self.STATIC_LIB, self.SHARED_LIB):
result.append('lib')
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
class TestGypXcode(TestGypBase):
"""
Subclass for testing the GYP Xcode generator.
"""
format = 'xcode'
build_tool_list = ['xcodebuild']
phase_script_execution = ("\n"
"PhaseScriptExecution /\\S+/Script-[0-9A-F]+\\.sh\n"
" cd /\\S+\n"
" /bin/sh -c /\\S+/Script-[0-9A-F]+\\.sh\n"
"(make: Nothing to be done for `all'\\.\n)?")
strip_up_to_date_expressions = [
# Various actions or rules can run even when the overall build target
# is up to date. Strip those phases' GYP-generated output.
re.compile(phase_script_execution, re.S),
# The message from distcc_pump can trail the "BUILD SUCCEEDED"
# message, so strip that, too.
re.compile('__________Shutting down distcc-pump include server\n', re.S),
]
up_to_date_endings = (
'Checking Dependencies...\n** BUILD SUCCEEDED **\n', # Xcode 3.0/3.1
'Check dependencies\n** BUILD SUCCEEDED **\n\n', # Xcode 3.2
)
def build(self, gyp_file, target=None, **kw):
"""
Runs an xcodebuild using the .xcodeproj generated from the specified
gyp_file.
"""
# Be sure we're working with a copy of 'arguments' since we modify it.
# The caller may not be expecting it to be modified.
arguments = kw.get('arguments', [])[:]
arguments.extend(['-project', gyp_file.replace('.gyp', '.xcodeproj')])
if target == self.ALL:
arguments.append('-alltargets',)
elif target not in (None, self.DEFAULT):
arguments.extend(['-target', target])
if self.configuration:
arguments.extend(['-configuration', self.configuration])
symroot = kw.get('SYMROOT', '$SRCROOT/build')
if symroot:
arguments.append('SYMROOT='+symroot)
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Xcode target is up to date.
"""
result = self.build(gyp_file, target, **kw)
if not result:
output = self.stdout()
for expression in self.strip_up_to_date_expressions:
output = expression.sub('', output)
if not output.endswith(self.up_to_date_endings):
self.report_not_up_to_date()
self.fail_test()
return result
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by xcodebuild.
"""
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('build', configuration)
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Xcode.
Built files are in the subdirectory 'build/{configuration}'.
The default is 'build/Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
configuration = self.configuration_dirname()
result.extend(['build', configuration])
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
format_class_list = [
TestGypGypd,
TestGypAndroid,
TestGypMake,
TestGypMSVS,
TestGypNinja,
TestGypSCons,
TestGypXcode,
]
def TestGyp(*args, **kw):
"""
Returns an appropriate TestGyp* instance for a specified GYP format.
"""
format = kw.pop('format', os.environ.get('TESTGYP_FORMAT'))
for format_class in format_class_list:
if format == format_class.format:
return format_class(*args, **kw)
raise Exception, "unknown format %r" % format
|
mit
|
[
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,
774,
13899,
14,
647,
26,
221,
282,
5343,
10059,
367,
25686,
13150,
2295,
14,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
199,
646,
1379,
7844,
199,
504,
1379,
7844,
492,
636,
452,
363,
199,
199,
363,
452,
4343,
2880,
779,
523,
283,
774,
13899,
297,
199,
566,
199,
199,
318,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
304,
523,
408,
3481,
370,
2813,
314,
1004,
5579,
687,
314,
3105,
1072,
523,
402,
4902,
436,
12850,
2813,
314,
444,
264,
5286,
11101,
2012,
402,
314,
3839,
523,
9132,
2295,
14,
523,
408,
523,
2385,
275,
4072,
14,
7644,
342,
523,
327,
3715,
1924,
1004,
641,
14725,
523,
2385,
275,
359,
76,
14,
1294,
480,
6783,
650,
9,
367,
634,
315,
2385,
61,
523,
327,
4263,
1924,
1004,
1771,
10451,
1830,
17289,
314,
523,
327,
650,
6883,
2763,
1314,
365,
314,
1004,
1329,
523,
2385,
275,
359,
552,
8,
76,
9,
690,
650,
436,
7244,
1674,
904,
8,
76,
59,
19,
5728,
503,
634,
367,
634,
315,
2385,
61,
523,
372,
1867,
78,
1674,
904,
8,
1278,
9,
199,
199,
318,
1336,
63,
1494,
13957,
63,
604,
63,
10548,
8,
4407,
63,
65,
12,
4072,
63,
66,
304,
523,
408,
1173,
4072,
15990,
626,
24010,
1004,
5579,
1041,
523,
4072,
63,
65,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
65,
9,
523,
4072,
63,
66,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
66,
9,
523,
372,
1379,
7844,
14,
1431,
63,
7327,
8,
4407,
63,
65,
12,
4072,
63,
66,
9,
199,
199,
533,
25688,
1563,
8,
774,
7844,
14,
774,
7844,
304,
523,
408,
523,
8089,
367,
30350,
1284,
13,
475,
13,
500,
2295,
402,
4902,
16952,
14,
819,
14089,
4466,
1958,
642,
1021,
911,
1218,
282,
7937,
2082,
436,
523,
601,
1842,
367,
2399,
477,
4742,
334,
12897,
314,
1379,
7874,
17035,
9,
436,
523,
1331,
1006,
402,
314,
2222,
13,
6179,
396,
1584,
315,
314,
2082,
14446,
402,
314,
523,
14043,
2884,
14,
819,
710,
849,
5953,
365,
370,
511,
314,
283,
6179,
7,
503,
283,
6179,
14,
13475,
7,
570,
315,
314,
523,
1453,
2082,
14,
221,
1626,
13943,
1443,
506,
2013,
7662,
641,
523,
26621,
12,
503,
701,
4260,
314,
7393,
14884,
63,
14884,
3734,
1750,
14,
819,
961,
1021,
1077,
506,
1007,
28271,
367,
1924,
3748,
4902,
4306,
523,
334,
908,
680,
221,
21107,
1785,
9006,
3102,
5084,
5627,
6358,
17597,
523,
1202,
701,
314,
511,
10554,
370,
12677,
14723,
641,
314,
4046,
1900,
523,
2897,
436,
370,
1255,
31172,
4046,
701,
5204,
14723,
14,
523,
408,
819,
1900,
63,
3557,
275,
488,
523,
1900,
63,
3557,
63,
513,
275,
942,
819,
485,
5803,
275,
1379,
7844,
14,
5803,
63,
4511,
523,
485,
1113,
275,
1379,
7844,
14,
1113,
63,
4511,
523,
930,
468,
63,
275,
1379,
7844,
14,
13927,
468,
63,
1861,
523,
485,
13927,
468,
275,
1379,
7844,
14,
13927,
468,
63,
4511,
523,
1973,
63,
275,
1379,
7844,
14,
773,
63,
1861,
523,
485,
773,
275,
1379,
7844,
14,
773,
63,
4511,
523,
17112,
63,
275,
1379,
7844,
14,
9259,
63,
1861,
523,
485,
9259,
275,
1379,
7844,
14,
9259,
63,
4511,
819,
327,
22296,
370,
2954,
3365,
4545,
14,
523,
11727,
275,
2560,
452,
12217,
523,
6186,
275,
2560,
885,
12217,
819,
327,
22296,
367,
3365,
1347,
2943,
14,
523,
3651,
4220,
934,
2617,
275,
2560,
5904,
12217,
523,
27815,
63,
5617,
275,
2560,
1986,
63,
773,
12217,
523,
4410,
689,
1149,
63,
5617,
275,
2560,
5555,
63,
773,
12217,
819,
347,
636,
826,
721,
277,
12,
4902,
29,
403,
12,
627,
589,
12,
1011,
829,
304,
272,
291,
14,
6493,
63,
6525,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
291,
14,
2911,
63,
589,
275,
984,
14,
3020,
59,
17,
2938,
339,
340,
440,
4902,
26,
489,
4902,
275,
747,
14,
2314,
14,
362,
360,
2864,
14884,
63,
14884,
358,
489,
340,
440,
4902,
26,
267,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
881,
4902,
275,
283,
6179,
14,
13475,
7,
267,
587,
26,
881,
4902,
275,
283,
6179,
7,
272,
291,
14,
6179,
275,
747,
14,
515,
14,
4832,
8,
6179,
9,
339,
291,
14,
8489,
63,
1506,
63,
3557,
342,
339,
4775,
14,
5486,
360,
1431,
297,
1379,
7844,
14,
1431,
63,
7327,
9,
339,
327,
16280,
511,
1072,
315,
734,
15,
396,
800,
6789,
701,
849,
14,
272,
327,
3645,
7937,
1561,
880,
2337,
787,
949,
30063,
14,
272,
1736,
694,
275,
747,
14,
515,
14,
904,
360,
548,
297,
4775,
14,
362,
360,
19132,
297,
283,
396,
800,
6789,
1333,
272,
327,
2790,
1736,
9150,
340,
652,
3181,
1133,
2575,
2187,
14,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
19132,
304,
489,
747,
14,
8347,
8,
19132,
9,
339,
4775,
459,
19132,
418,
275,
5549,
14,
22136,
8,
1861,
534,
396,
6179,
3130,
2935,
29,
19132,
9,
339,
6752,
275,
4775,
14,
1935,
360,
6321,
297,
3073,
339,
1613,
8,
774,
13899,
1563,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
339,
8789,
63,
6321,
275,
663,
779,
70,
367,
289,
315,
6752,
340,
289,
59,
16,
61,
508,
14597,
1105,
272,
5120,
63,
6321,
275,
663,
8,
6321,
9,
446,
8789,
63,
6321,
272,
340,
661,
1,
6828,
277,
14,
908,
315,
8789,
63,
6321,
503,
267,
5120,
63,
6321,
436,
291,
14,
908,
440,
315,
5120,
63,
6321,
304,
489,
1499,
275,
283,
3364,
511,
367,
450,
82,
1475,
27,
16068,
511,
3134,
78,
7,
489,
291,
14,
2759,
63,
396,
8,
1328,
450,
291,
14,
908,
9,
339,
291,
14,
1574,
63,
396,
63,
4758,
8,
277,
14,
6493,
63,
6525,
12,
291,
14,
19132,
9,
272,
291
] |
[
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,
774,
13899,
14,
647,
26,
221,
282,
5343,
10059,
367,
25686,
13150,
2295,
14,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
199,
646,
1379,
7844,
199,
504,
1379,
7844,
492,
636,
452,
363,
199,
199,
363,
452,
4343,
2880,
779,
523,
283,
774,
13899,
297,
199,
566,
199,
199,
318,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
304,
523,
408,
3481,
370,
2813,
314,
1004,
5579,
687,
314,
3105,
1072,
523,
402,
4902,
436,
12850,
2813,
314,
444,
264,
5286,
11101,
2012,
402,
314,
3839,
523,
9132,
2295,
14,
523,
408,
523,
2385,
275,
4072,
14,
7644,
342,
523,
327,
3715,
1924,
1004,
641,
14725,
523,
2385,
275,
359,
76,
14,
1294,
480,
6783,
650,
9,
367,
634,
315,
2385,
61,
523,
327,
4263,
1924,
1004,
1771,
10451,
1830,
17289,
314,
523,
327,
650,
6883,
2763,
1314,
365,
314,
1004,
1329,
523,
2385,
275,
359,
552,
8,
76,
9,
690,
650,
436,
7244,
1674,
904,
8,
76,
59,
19,
5728,
503,
634,
367,
634,
315,
2385,
61,
523,
372,
1867,
78,
1674,
904,
8,
1278,
9,
199,
199,
318,
1336,
63,
1494,
13957,
63,
604,
63,
10548,
8,
4407,
63,
65,
12,
4072,
63,
66,
304,
523,
408,
1173,
4072,
15990,
626,
24010,
1004,
5579,
1041,
523,
4072,
63,
65,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
65,
9,
523,
4072,
63,
66,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
66,
9,
523,
372,
1379,
7844,
14,
1431,
63,
7327,
8,
4407,
63,
65,
12,
4072,
63,
66,
9,
199,
199,
533,
25688,
1563,
8,
774,
7844,
14,
774,
7844,
304,
523,
408,
523,
8089,
367,
30350,
1284,
13,
475,
13,
500,
2295,
402,
4902,
16952,
14,
819,
14089,
4466,
1958,
642,
1021,
911,
1218,
282,
7937,
2082,
436,
523,
601,
1842,
367,
2399,
477,
4742,
334,
12897,
314,
1379,
7874,
17035,
9,
436,
523,
1331,
1006,
402,
314,
2222,
13,
6179,
396,
1584,
315,
314,
2082,
14446,
402,
314,
523,
14043,
2884,
14,
819,
710,
849,
5953,
365,
370,
511,
314,
283,
6179,
7,
503,
283,
6179,
14,
13475,
7,
570,
315,
314,
523,
1453,
2082,
14,
221,
1626,
13943,
1443,
506,
2013,
7662,
641,
523,
26621,
12,
503,
701,
4260,
314,
7393,
14884,
63,
14884,
3734,
1750,
14,
819,
961,
1021,
1077,
506,
1007,
28271,
367,
1924,
3748,
4902,
4306,
523,
334,
908,
680,
221,
21107,
1785,
9006,
3102,
5084,
5627,
6358,
17597,
523,
1202,
701,
314,
511,
10554,
370,
12677,
14723,
641,
314,
4046,
1900,
523,
2897,
436,
370,
1255,
31172,
4046,
701,
5204,
14723,
14,
523,
408,
819,
1900,
63,
3557,
275,
488,
523,
1900,
63,
3557,
63,
513,
275,
942,
819,
485,
5803,
275,
1379,
7844,
14,
5803,
63,
4511,
523,
485,
1113,
275,
1379,
7844,
14,
1113,
63,
4511,
523,
930,
468,
63,
275,
1379,
7844,
14,
13927,
468,
63,
1861,
523,
485,
13927,
468,
275,
1379,
7844,
14,
13927,
468,
63,
4511,
523,
1973,
63,
275,
1379,
7844,
14,
773,
63,
1861,
523,
485,
773,
275,
1379,
7844,
14,
773,
63,
4511,
523,
17112,
63,
275,
1379,
7844,
14,
9259,
63,
1861,
523,
485,
9259,
275,
1379,
7844,
14,
9259,
63,
4511,
819,
327,
22296,
370,
2954,
3365,
4545,
14,
523,
11727,
275,
2560,
452,
12217,
523,
6186,
275,
2560,
885,
12217,
819,
327,
22296,
367,
3365,
1347,
2943,
14,
523,
3651,
4220,
934,
2617,
275,
2560,
5904,
12217,
523,
27815,
63,
5617,
275,
2560,
1986,
63,
773,
12217,
523,
4410,
689,
1149,
63,
5617,
275,
2560,
5555,
63,
773,
12217,
819,
347,
636,
826,
721,
277,
12,
4902,
29,
403,
12,
627,
589,
12,
1011,
829,
304,
272,
291,
14,
6493,
63,
6525,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
291,
14,
2911,
63,
589,
275,
984,
14,
3020,
59,
17,
2938,
339,
340,
440,
4902,
26,
489,
4902,
275,
747,
14,
2314,
14,
362,
360,
2864,
14884,
63,
14884,
358,
489,
340,
440,
4902,
26,
267,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
881,
4902,
275,
283,
6179,
14,
13475,
7,
267,
587,
26,
881,
4902,
275,
283,
6179,
7,
272,
291,
14,
6179,
275,
747,
14,
515,
14,
4832,
8,
6179,
9,
339,
291,
14,
8489,
63,
1506,
63,
3557,
342,
339,
4775,
14,
5486,
360,
1431,
297,
1379,
7844,
14,
1431,
63,
7327,
9,
339,
327,
16280,
511,
1072,
315,
734,
15,
396,
800,
6789,
701,
849,
14,
272,
327,
3645,
7937,
1561,
880,
2337,
787,
949,
30063,
14,
272,
1736,
694,
275,
747,
14,
515,
14,
904,
360,
548,
297,
4775,
14,
362,
360,
19132,
297,
283,
396,
800,
6789,
1333,
272,
327,
2790,
1736,
9150,
340,
652,
3181,
1133,
2575,
2187,
14,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
19132,
304,
489,
747,
14,
8347,
8,
19132,
9,
339,
4775,
459,
19132,
418,
275,
5549,
14,
22136,
8,
1861,
534,
396,
6179,
3130,
2935,
29,
19132,
9,
339,
6752,
275,
4775,
14,
1935,
360,
6321,
297,
3073,
339,
1613,
8,
774,
13899,
1563,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
339,
8789,
63,
6321,
275,
663,
779,
70,
367,
289,
315,
6752,
340,
289,
59,
16,
61,
508,
14597,
1105,
272,
5120,
63,
6321,
275,
663,
8,
6321,
9,
446,
8789,
63,
6321,
272,
340,
661,
1,
6828,
277,
14,
908,
315,
8789,
63,
6321,
503,
267,
5120,
63,
6321,
436,
291,
14,
908,
440,
315,
5120,
63,
6321,
304,
489,
1499,
275,
283,
3364,
511,
367,
450,
82,
1475,
27,
16068,
511,
3134,
78,
7,
489,
291,
14,
2759,
63,
396,
8,
1328,
450,
291,
14,
908,
9,
339,
291,
14,
1574,
63,
396,
63,
4758,
8,
277,
14,
6493,
63,
6525,
12,
291,
14,
19132,
9,
272,
291,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
marcusmueller/gnuradio
|
gr-filter/examples/fft_filter_ccc.py
|
7
|
4367
|
#!/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 print_function
from __future__ import division
from __future__ import unicode_literals
from gnuradio import gr, filter
from gnuradio import analog
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio.eng_arg import eng_float, intx
from argparse import ArgumentParser
import sys
import numpy
try:
from matplotlib import pyplot
except ImportError:
print("Error: could not from matplotlib import pyplot (http://matplotlib.sourceforge.net/)")
sys.exit(1)
class example_fft_filter_ccc(gr.top_block):
def __init__(self, N, fs, bw0, bw1, tw, atten, D):
gr.top_block.__init__(self)
self._nsamps = N
self._fs = fs
self._bw0 = bw0
self._bw1 = bw1
self._tw = tw
self._at = atten
self._decim = D
taps = filter.firdes.complex_band_pass_2(1, self._fs,
self._bw0, self._bw1,
self._tw, self._at)
print("Num. Taps: ", len(taps))
self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps)
self.filt0 = filter.fft_filter_ccc(self._decim, taps)
self.vsnk_src = blocks.vector_sink_c()
self.vsnk_out = blocks.vector_sink_c()
self.connect(self.src, self.head, self.vsnk_src)
self.connect(self.head, self.filt0, self.vsnk_out)
def main():
parser = ArgumentParser(conflict_handler="resolve")
parser.add_argument("-N", "--nsamples", type=int, default=10000,
help="Number of samples to process [default=%(default)r]")
parser.add_argument("-s", "--samplerate", type=eng_float, default=8000,
help="System sample rate [default=%(default)r]")
parser.add_argument("-S", "--start-pass", type=eng_float, default=1000,
help="Start of Passband [default=%(default)r]")
parser.add_argument("-E", "--end-pass", type=eng_float, default=2000,
help="End of Passband [default=%(default)r]")
parser.add_argument("-T", "--transition", type=eng_float, default=100,
help="Transition band [default=%(default)r]")
parser.add_argument("-A", "--attenuation", type=eng_float, default=80,
help="Stopband attenuation [default=%(default)r]")
parser.add_argument("-D", "--decimation", type=int, default=1,
help="Decmation factor [default=%(default)r]")
args = parser.parse_args()
put = example_fft_filter_ccc(args.nsamples,
args.samplerate,
args.start_pass,
args.end_pass,
args.transition,
args.attenuation,
args.decimation)
put.run()
data_src = numpy.array(put.vsnk_src.data())
data_snk = numpy.array(put.vsnk_out.data())
# Plot the signals PSDs
nfft = 1024
f1 = pyplot.figure(1, figsize=(12,10))
s1 = f1.add_subplot(1,1,1)
s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
f2 = pyplot.figure(2, figsize=(12,10))
s2 = f2.add_subplot(1,1,1)
s2.plot(data_src)
s2.plot(data_snk.real, 'g')
pyplot.show()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
|
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,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
24526,
492,
7192,
12,
2457,
199,
504,
24526,
492,
20439,
199,
504,
24526,
492,
5664,
199,
504,
24526,
492,
20171,
63,
12251,
199,
504,
24526,
14,
7420,
63,
1273,
492,
20171,
63,
1609,
12,
1109,
88,
199,
504,
7534,
492,
27615,
199,
646,
984,
199,
646,
2680,
199,
199,
893,
26,
272,
687,
8027,
492,
1134,
2798,
199,
2590,
3545,
26,
272,
870,
480,
547,
26,
4293,
440,
687,
8027,
492,
1134,
2798,
334,
1014,
921,
16440,
14,
22943,
14,
846,
15,
6320,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
533,
2893,
63,
9996,
63,
1541,
63,
19504,
8,
2587,
14,
2119,
63,
1457,
304,
272,
347,
636,
826,
721,
277,
12,
653,
12,
7449,
12,
21028,
16,
12,
21028,
17,
12,
8900,
12,
22624,
12,
577,
304,
267,
7192,
14,
2119,
63,
1457,
855,
826,
721,
277,
9,
398,
291,
423,
561,
5282,
83,
275,
653,
267,
291,
423,
2319,
275,
7449,
267,
291,
423,
12415,
16,
275,
21028,
16,
267,
291,
423,
12415,
17,
275,
21028,
17,
267,
291,
423,
8122,
275,
8900,
267,
291,
423,
292,
275,
22624,
267,
291,
423,
22612,
77,
275,
577,
267,
307,
7461,
275,
2457,
14,
1795,
3424,
14,
5254,
63,
7877,
63,
1529,
63,
18,
8,
17,
12,
291,
423,
2319,
12,
1740,
291,
423,
12415,
16,
12,
291,
423,
12415,
17,
12,
1740,
291,
423,
8122,
12,
291,
423,
292,
9,
267,
870,
480,
5667,
14,
377,
7461,
26,
3872,
822,
8,
26335,
430,
398,
291,
14,
2164,
221,
275,
20439,
14,
11838,
63,
1365,
63,
67,
8,
290,
2548,
14,
3975,
63,
9741,
1668,
2684,
879,
12,
413,
9,
267,
291,
14,
2993,
275,
5664,
14,
2993,
8,
2587,
14,
12590,
63,
2587,
63,
5254,
12,
291,
423,
561,
5282,
83,
9,
398,
291,
14,
18872,
16,
275,
2457,
14,
9996,
63,
1541,
63,
19504,
8,
277,
423,
22612,
77,
12,
307,
7461,
9,
398,
291,
14,
3122,
23175,
63,
2164,
275,
5664,
14,
4106,
63,
11279,
63,
67,
342,
267,
291,
14,
3122,
23175,
63,
548,
275,
5664,
14,
4106,
63,
11279,
63,
67,
342,
398,
291,
14,
2242,
8,
277,
14,
2164,
12,
291,
14,
2993,
12,
291,
14,
3122,
23175,
63,
2164,
9,
267,
291,
14,
2242,
8,
277,
14,
2993,
12,
291,
14,
18872,
16,
12,
291,
14,
3122,
23175,
63,
548,
9,
199,
199,
318,
2446,
837,
272,
1798,
275,
27615,
8,
15207,
63,
2232,
628,
6983,
531,
272,
1798,
14,
525,
63,
2094,
6096,
46,
401,
4320,
561,
1889,
401,
730,
29,
442,
12,
849,
29,
9943,
12,
1993,
1720,
628,
3259,
402,
5845,
370,
2112,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
83,
401,
4320,
3271,
1866,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
15214,
12,
1993,
1720,
628,
3989,
2690,
6634,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
51,
401,
4320,
928,
13,
1529,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
5279,
12,
1993,
1720,
628,
3162,
402,
8325,
7877,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
37,
401,
4320,
500,
13,
1529,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
8269,
12,
1993,
1720,
628,
3005,
402,
8325,
7877,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
52,
401,
4320,
14143,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
1960,
12,
1993,
1720,
628,
21881,
10981,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
33,
401,
4320,
4867,
4086,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
1257,
12,
1993,
1720,
628,
6293,
7877,
22624,
4086,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
36,
401,
4320,
22612,
1615,
401,
730,
29,
442,
12,
849,
29,
17,
12,
1993,
1720,
628,
8584,
1615,
6535,
359,
885,
15438,
885,
9,
82,
12523,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
5324,
275,
2893,
63,
9996,
63,
1541,
63,
19504,
8,
589,
14,
561,
1889,
12,
639,
1249,
14,
3271,
1866,
12,
639,
1249,
14,
928,
63,
1529,
12,
639,
1249,
14,
500,
63,
1529,
12,
639,
1249,
14,
14143,
12,
639,
1249,
14,
4867,
4086,
12,
639,
1249,
14,
22612,
1615,
9,
272,
5324,
14,
1065,
342,
339,
666,
63,
2164,
275,
2680,
14,
1144,
8,
524,
14,
3122,
23175,
63,
2164,
14,
576,
1012,
272,
666,
63,
5167,
75,
275,
2680,
14,
1144,
8,
524,
14,
3122,
23175,
63,
548,
14,
576,
1012,
339,
327,
14794,
314,
10166,
510,
3693,
83,
272,
302,
9996,
275,
6619,
272,
289,
17,
275,
1134,
2798,
14,
8941,
8,
17,
12,
6085,
890,
2687,
713,
12,
709,
430,
272,
308,
17
] |
[
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,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
24526,
492,
7192,
12,
2457,
199,
504,
24526,
492,
20439,
199,
504,
24526,
492,
5664,
199,
504,
24526,
492,
20171,
63,
12251,
199,
504,
24526,
14,
7420,
63,
1273,
492,
20171,
63,
1609,
12,
1109,
88,
199,
504,
7534,
492,
27615,
199,
646,
984,
199,
646,
2680,
199,
199,
893,
26,
272,
687,
8027,
492,
1134,
2798,
199,
2590,
3545,
26,
272,
870,
480,
547,
26,
4293,
440,
687,
8027,
492,
1134,
2798,
334,
1014,
921,
16440,
14,
22943,
14,
846,
15,
6320,
272,
984,
14,
2224,
8,
17,
9,
199,
199,
533,
2893,
63,
9996,
63,
1541,
63,
19504,
8,
2587,
14,
2119,
63,
1457,
304,
272,
347,
636,
826,
721,
277,
12,
653,
12,
7449,
12,
21028,
16,
12,
21028,
17,
12,
8900,
12,
22624,
12,
577,
304,
267,
7192,
14,
2119,
63,
1457,
855,
826,
721,
277,
9,
398,
291,
423,
561,
5282,
83,
275,
653,
267,
291,
423,
2319,
275,
7449,
267,
291,
423,
12415,
16,
275,
21028,
16,
267,
291,
423,
12415,
17,
275,
21028,
17,
267,
291,
423,
8122,
275,
8900,
267,
291,
423,
292,
275,
22624,
267,
291,
423,
22612,
77,
275,
577,
267,
307,
7461,
275,
2457,
14,
1795,
3424,
14,
5254,
63,
7877,
63,
1529,
63,
18,
8,
17,
12,
291,
423,
2319,
12,
1740,
291,
423,
12415,
16,
12,
291,
423,
12415,
17,
12,
1740,
291,
423,
8122,
12,
291,
423,
292,
9,
267,
870,
480,
5667,
14,
377,
7461,
26,
3872,
822,
8,
26335,
430,
398,
291,
14,
2164,
221,
275,
20439,
14,
11838,
63,
1365,
63,
67,
8,
290,
2548,
14,
3975,
63,
9741,
1668,
2684,
879,
12,
413,
9,
267,
291,
14,
2993,
275,
5664,
14,
2993,
8,
2587,
14,
12590,
63,
2587,
63,
5254,
12,
291,
423,
561,
5282,
83,
9,
398,
291,
14,
18872,
16,
275,
2457,
14,
9996,
63,
1541,
63,
19504,
8,
277,
423,
22612,
77,
12,
307,
7461,
9,
398,
291,
14,
3122,
23175,
63,
2164,
275,
5664,
14,
4106,
63,
11279,
63,
67,
342,
267,
291,
14,
3122,
23175,
63,
548,
275,
5664,
14,
4106,
63,
11279,
63,
67,
342,
398,
291,
14,
2242,
8,
277,
14,
2164,
12,
291,
14,
2993,
12,
291,
14,
3122,
23175,
63,
2164,
9,
267,
291,
14,
2242,
8,
277,
14,
2993,
12,
291,
14,
18872,
16,
12,
291,
14,
3122,
23175,
63,
548,
9,
199,
199,
318,
2446,
837,
272,
1798,
275,
27615,
8,
15207,
63,
2232,
628,
6983,
531,
272,
1798,
14,
525,
63,
2094,
6096,
46,
401,
4320,
561,
1889,
401,
730,
29,
442,
12,
849,
29,
9943,
12,
1993,
1720,
628,
3259,
402,
5845,
370,
2112,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
83,
401,
4320,
3271,
1866,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
15214,
12,
1993,
1720,
628,
3989,
2690,
6634,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
51,
401,
4320,
928,
13,
1529,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
5279,
12,
1993,
1720,
628,
3162,
402,
8325,
7877,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
37,
401,
4320,
500,
13,
1529,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
8269,
12,
1993,
1720,
628,
3005,
402,
8325,
7877,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
52,
401,
4320,
14143,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
1960,
12,
1993,
1720,
628,
21881,
10981,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
33,
401,
4320,
4867,
4086,
401,
730,
29,
7420,
63,
1609,
12,
849,
29,
1257,
12,
1993,
1720,
628,
6293,
7877,
22624,
4086,
359,
885,
15438,
885,
9,
82,
12523,
272,
1798,
14,
525,
63,
2094,
6096,
36,
401,
4320,
22612,
1615,
401,
730,
29,
442,
12,
849,
29,
17,
12,
1993,
1720,
628,
8584,
1615,
6535,
359,
885,
15438,
885,
9,
82,
12523,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
5324,
275,
2893,
63,
9996,
63,
1541,
63,
19504,
8,
589,
14,
561,
1889,
12,
639,
1249,
14,
3271,
1866,
12,
639,
1249,
14,
928,
63,
1529,
12,
639,
1249,
14,
500,
63,
1529,
12,
639,
1249,
14,
14143,
12,
639,
1249,
14,
4867,
4086,
12,
639,
1249,
14,
22612,
1615,
9,
272,
5324,
14,
1065,
342,
339,
666,
63,
2164,
275,
2680,
14,
1144,
8,
524,
14,
3122,
23175,
63,
2164,
14,
576,
1012,
272,
666,
63,
5167,
75,
275,
2680,
14,
1144,
8,
524,
14,
3122,
23175,
63,
548,
14,
576,
1012,
339,
327,
14794,
314,
10166,
510,
3693,
83,
272,
302,
9996,
275,
6619,
272,
289,
17,
275,
1134,
2798,
14,
8941,
8,
17,
12,
6085,
890,
2687,
713,
12,
709,
430,
272,
308,
17,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BeATz-UnKNoWN/python-for-android
|
python3-alpha/python3-src/Lib/random.py
|
45
|
25557
|
"""Random variable generators.
integers
--------
uniform within range
sequences
---------
pick random element
pick random sample
generate random permutation
distributions on the real line:
------------------------------
uniform
triangular
normal (Gaussian)
lognormal
negative exponential
gamma
beta
pareto
Weibull
distributions on the circle (angles 0 to 2pi)
---------------------------------------------
circular uniform
von Mises
General notes on the underlying Mersenne Twister core generator:
* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
* The random() method is implemented in C, executes in a single Python step,
and is, therefore, threadsafe.
"""
from __future__ import division
from warnings import warn as _warn
from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
from os import urandom as _urandom
from collections import Set as _Set, Sequence as _Sequence
from hashlib import sha512 as _sha512
__all__ = ["Random","seed","random","uniform","randint","choice","sample",
"randrange","shuffle","normalvariate","lognormvariate",
"expovariate","vonmisesvariate","gammavariate","triangular",
"gauss","betavariate","paretovariate","weibullvariate",
"getstate","setstate", "getrandbits",
"SystemRandom"]
NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
TWOPI = 2.0*_pi
LOG4 = _log(4.0)
SG_MAGICCONST = 1.0 + _log(4.5)
BPF = 53 # Number of bits in a float
RECIP_BPF = 2**-BPF
# Translated by Guido van Rossum from C source provided by
# Adrian Baddeley. Adapted by Raymond Hettinger for use with
# the Mersenne Twister and os.urandom() core generators.
import _random
class Random(_random.Random):
"""Random number generator base class used by bound module functions.
Used to instantiate instances of Random to get generators that don't
share state.
Class Random can also be subclassed if you want to use a different basic
generator of your own devising: in that case, override the following
methods: random(), seed(), getstate(), and setstate().
Optionally, implement a getrandbits() method so that randrange()
can cover arbitrarily large ranges.
"""
VERSION = 3 # used by getstate/setstate
def __init__(self, x=None):
"""Initialize an instance.
Optional argument x controls seeding, as for Random.seed().
"""
self.seed(x)
self.gauss_next = None
def seed(self, a=None, version=2):
"""Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
For version 2 (the default), all of the bits are used if *a *is a str,
bytes, or bytearray. For version 1, the hash() of *a* is used instead.
If *a* is an int, all bits are used.
"""
if a is None:
try:
a = int.from_bytes(_urandom(32), 'big')
except NotImplementedError:
import time
a = int(time.time() * 256) # use fractional seconds
if version == 2:
if isinstance(a, (str, bytes, bytearray)):
if isinstance(a, str):
a = a.encode()
a += _sha512(a).digest()
a = int.from_bytes(a, 'big')
super().seed(a)
self.gauss_next = None
def getstate(self):
"""Return internal state; can be passed to setstate() later."""
return self.VERSION, super().getstate(), self.gauss_next
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
if version == 3:
version, internalstate, self.gauss_next = state
super().setstate(internalstate)
elif version == 2:
version, internalstate, self.gauss_next = state
# In version 2, the state was saved as signed ints, which causes
# inconsistencies between 32/64-bit systems. The state is
# really unsigned 32-bit ints, so we convert negative ints from
# version 2 to positive longs for version 3.
try:
internalstate = tuple(x % (2**32) for x in internalstate)
except ValueError as e:
raise TypeError from e
super().setstate(internalstate)
else:
raise ValueError("state with version %s passed to "
"Random.setstate() of version %s" %
(version, self.VERSION))
## ---- Methods below this point do not need to be overridden when
## ---- subclassing for the purpose of using a different core generator.
## -------------------- pickle support -------------------
def __getstate__(self): # for pickle
return self.getstate()
def __setstate__(self, state): # for pickle
self.setstate(state)
def __reduce__(self):
return self.__class__, (), self.getstate()
## -------------------- integer methods -------------------
def randrange(self, start, stop=None, step=1, int=int):
"""Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
Do not supply the 'int' argument.
"""
# This code is a bit messy to make it fast for the
# common case while still doing adequate error checking.
istart = int(start)
if istart != start:
raise ValueError("non-integer arg 1 for randrange()")
if stop is None:
if istart > 0:
return self._randbelow(istart)
raise ValueError("empty range for randrange()")
# stop argument supplied.
istop = int(stop)
if istop != stop:
raise ValueError("non-integer stop for randrange()")
width = istop - istart
if step == 1 and width > 0:
return istart + self._randbelow(width)
if step == 1:
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
# Non-unit step argument supplied.
istep = int(step)
if istep != step:
raise ValueError("non-integer step for randrange()")
if istep > 0:
n = (width + istep - 1) // istep
elif istep < 0:
n = (width + istep + 1) // istep
else:
raise ValueError("zero step for randrange()")
if n <= 0:
raise ValueError("empty range for randrange()")
return istart + istep*self._randbelow(n)
def randint(self, a, b):
"""Return random integer in range [a, b], including both end points.
"""
return self.randrange(a, b+1)
def _randbelow(self, n, int=int, maxsize=1<<BPF, type=type,
Method=_MethodType, BuiltinMethod=_BuiltinMethodType):
"Return a random int in the range [0,n). Raises ValueError if n==0."
getrandbits = self.getrandbits
# Only call self.getrandbits if the original random() builtin method
# has not been overridden or if a new getrandbits() was supplied.
if type(self.random) is BuiltinMethod or type(getrandbits) is Method:
k = n.bit_length() # don't use (n-1) here because n can be 1
r = getrandbits(k) # 0 <= r < 2**k
while r >= n:
r = getrandbits(k)
return r
# There's an overriden random() method but no new getrandbits() method,
# so we can only use random() from here.
random = self.random
if n >= maxsize:
_warn("Underlying random() generator does not supply \n"
"enough bits to choose from a population range this large.\n"
"To remove the range limitation, add a getrandbits() method.")
return int(random() * n)
rem = maxsize % n
limit = (maxsize - rem) / maxsize # int(limit * maxsize) % n == 0
r = random()
while r >= limit:
r = random()
return int(r*maxsize) % n
## -------------------- sequence methods -------------------
def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
try:
i = self._randbelow(len(seq))
except ValueError:
raise IndexError('Cannot choose from an empty sequence')
return seq[i]
def shuffle(self, x, random=None, int=int):
"""x, random=random.random -> shuffle list x in place; return None.
Optional arg random is a 0-argument function returning a random
float in [0.0, 1.0); by default, the standard random.random.
"""
randbelow = self._randbelow
for i in reversed(range(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
j = randbelow(i+1) if random is None else int(random() * (i+1))
x[i], x[j] = x[j], x[i]
def sample(self, population, k):
"""Chooses k unique random elements from a population sequence or set.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be valid random
samples. This allows raffle winners (the sample) to be partitioned
into grand prize and second place winners (the subslices).
Members of the population need not be hashable or unique. If the
population contains repeats, then each occurrence is a possible
selection in the sample.
To choose a sample in a range of integers, use range as an argument.
This is especially fast and space efficient for sampling from a
large population: sample(range(10000000), 60)
"""
# Sampling without replacement entails tracking either potential
# selections (the pool) in a list or previous selections in a set.
# When the number of selections is small compared to the
# population, then tracking selections is efficient, requiring
# only a small set and an occasional reselection. For
# a larger number of selections, the pool tracking method is
# preferred since the list takes less space than the
# set and it doesn't suffer from frequent reselections.
if isinstance(population, _Set):
population = tuple(population)
if not isinstance(population, _Sequence):
raise TypeError("Population must be a sequence or set. For dicts, use list(d).")
randbelow = self._randbelow
n = len(population)
if not 0 <= k <= n:
raise ValueError("Sample larger than population")
result = [None] * k
setsize = 21 # size of a small set minus size of an empty list
if k > 5:
setsize += 4 ** _ceil(_log(k * 3, 4)) # table size for big sets
if n <= setsize:
# An n-length list is smaller than a k-length set
pool = list(population)
for i in range(k): # invariant: non-selected at [0,n-i)
j = randbelow(n-i)
result[i] = pool[j]
pool[j] = pool[n-i-1] # move non-selected item into vacancy
else:
selected = set()
selected_add = selected.add
for i in range(k):
j = randbelow(n)
while j in selected:
j = randbelow(n)
selected_add(j)
result[i] = population[j]
return result
## -------------------- real-valued distributions -------------------
## -------------------- uniform distribution -------------------
def uniform(self, a, b):
"Get a random number in the range [a, b) or [a, b] depending on rounding."
return a + (b-a) * self.random()
## -------------------- triangular --------------------
def triangular(self, low=0.0, high=1.0, mode=None):
"""Triangular distribution.
Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between.
http://en.wikipedia.org/wiki/Triangular_distribution
"""
u = self.random()
c = 0.5 if mode is None else (mode - low) / (high - low)
if u > c:
u = 1.0 - u
c = 1.0 - c
low, high = high, low
return low + (high - low) * (u * c) ** 0.5
## -------------------- normal distribution --------------------
def normalvariate(self, mu, sigma):
"""Normal distribution.
mu is the mean, and sigma is the standard deviation.
"""
# mu = mean, sigma = standard deviation
# Uses Kinderman and Monahan method. Reference: Kinderman,
# A.J. and Monahan, J.F., "Computer generation of random
# variables using the ratio of uniform deviates", ACM Trans
# Math Software, 3, (1977), pp257-260.
random = self.random
while 1:
u1 = random()
u2 = 1.0 - random()
z = NV_MAGICCONST*(u1-0.5)/u2
zz = z*z/4.0
if zz <= -_log(u2):
break
return mu + z*sigma
## -------------------- lognormal distribution --------------------
def lognormvariate(self, mu, sigma):
"""Log normal distribution.
If you take the natural logarithm of this distribution, you'll get a
normal distribution with mean mu and standard deviation sigma.
mu can have any value, and sigma must be greater than zero.
"""
return _exp(self.normalvariate(mu, sigma))
## -------------------- exponential distribution --------------------
def expovariate(self, lambd):
"""Exponential distribution.
lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, and from negative
infinity to 0 if lambd is negative.
"""
# lambd: rate lambd = 1/mean
# ('lambda' is a Python reserved word)
# we use 1-random() instead of random() to preclude the
# possibility of taking the log of zero.
return -_log(1.0 - self.random())/lambd
## -------------------- von Mises distribution --------------------
def vonmisesvariate(self, mu, kappa):
"""Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi.
"""
# mu: mean angle (in radians between 0 and 2*pi)
# kappa: concentration parameter kappa (>= 0)
# if kappa = 0 generate uniform random angle
# Based upon an algorithm published in: Fisher, N.I.,
# "Statistical Analysis of Circular Data", Cambridge
# University Press, 1993.
# Thanks to Magnus Kessler for a correction to the
# implementation of step 4.
random = self.random
if kappa <= 1e-6:
return TWOPI * random()
a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa)
b = (a - _sqrt(2.0 * a))/(2.0 * kappa)
r = (1.0 + b * b)/(2.0 * b)
while 1:
u1 = random()
z = _cos(_pi * u1)
f = (1.0 + r * z)/(r + z)
c = kappa * (r - f)
u2 = random()
if u2 < c * (2.0 - c) or u2 <= c * _exp(1.0 - c):
break
u3 = random()
if u3 > 0.5:
theta = (mu % TWOPI) + _acos(f)
else:
theta = (mu % TWOPI) - _acos(f)
return theta
## -------------------- gamma distribution --------------------
def gammavariate(self, alpha, beta):
"""Gamma distribution. Not the gamma function!
Conditions on the parameters are alpha > 0 and beta > 0.
The probability distribution function is:
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = --------------------------------------
math.gamma(alpha) * beta ** alpha
"""
# alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2
# Warning: a few older sources define the gamma distribution in terms
# of alpha > -1.0
if alpha <= 0.0 or beta <= 0.0:
raise ValueError('gammavariate: alpha and beta must be > 0.0')
random = self.random
if alpha > 1.0:
# Uses R.C.H. Cheng, "The generation of Gamma
# variables with non-integral shape parameters",
# Applied Statistics, (1977), 26, No. 1, p71-74
ainv = _sqrt(2.0 * alpha - 1.0)
bbb = alpha - LOG4
ccc = alpha + ainv
while 1:
u1 = random()
if not 1e-7 < u1 < .9999999:
continue
u2 = 1.0 - random()
v = _log(u1/(1.0-u1))/ainv
x = alpha*_exp(v)
z = u1*u1*u2
r = bbb+ccc*v-x
if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z):
return x * beta
elif alpha == 1.0:
# expovariate(1)
u = random()
while u <= 1e-7:
u = random()
return -_log(u) * beta
else: # alpha is between 0 and 1 (exclusive)
# Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle
while 1:
u = random()
b = (_e + alpha)/_e
p = b*u
if p <= 1.0:
x = p ** (1.0/alpha)
else:
x = -_log((b-p)/alpha)
u1 = random()
if p > 1.0:
if u1 <= x ** (alpha - 1.0):
break
elif u1 <= _exp(-x):
break
return x * beta
## -------------------- Gauss (faster alternative) --------------------
def gauss(self, mu, sigma):
"""Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function.
Not thread-safe without a lock around calls.
"""
# When x and y are two variables from [0, 1), uniformly
# distributed, then
#
# cos(2*pi*x)*sqrt(-2*log(1-y))
# sin(2*pi*x)*sqrt(-2*log(1-y))
#
# are two *independent* variables with normal distribution
# (mu = 0, sigma = 1).
# (Lambert Meertens)
# (corrected version; bug discovered by Mike Miller, fixed by LM)
# Multithreading note: When two threads call this function
# simultaneously, it is possible that they will receive the
# same return value. The window is very small though. To
# avoid this, you have to use a lock around all calls. (I
# didn't want to slow this down in the serial case by using a
# lock here.)
random = self.random
z = self.gauss_next
self.gauss_next = None
if z is None:
x2pi = random() * TWOPI
g2rad = _sqrt(-2.0 * _log(1.0 - random()))
z = _cos(x2pi) * g2rad
self.gauss_next = _sin(x2pi) * g2rad
return mu + z*sigma
## -------------------- beta --------------------
## See
## http://mail.python.org/pipermail/python-bugs-list/2001-January/003752.html
## for Ivan Frohne's insightful analysis of why the original implementation:
##
## def betavariate(self, alpha, beta):
## # Discrete Event Simulation in C, pp 87-88.
##
## y = self.expovariate(alpha)
## z = self.expovariate(1.0/beta)
## return z/(y+z)
##
## was dead wrong, and how it probably got that way.
def betavariate(self, alpha, beta):
"""Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
"""
# This version due to Janne Sinkkonen, and matches all the std
# texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution").
y = self.gammavariate(alpha, 1.)
if y == 0:
return 0.0
else:
return y / (y + self.gammavariate(beta, 1.))
## -------------------- Pareto --------------------
def paretovariate(self, alpha):
"""Pareto distribution. alpha is the shape parameter."""
# Jain, pg. 495
u = 1.0 - self.random()
return 1.0 / u ** (1.0/alpha)
## -------------------- Weibull --------------------
def weibullvariate(self, alpha, beta):
"""Weibull distribution.
alpha is the scale parameter and beta is the shape parameter.
"""
# Jain, pg. 499; bug fix courtesy Bill Arms
u = 1.0 - self.random()
return alpha * (-_log(u)) ** (1.0/beta)
## --------------- Operating System Random Source ------------------
class SystemRandom(Random):
"""Alternate random number generator using sources provided
by the operating system (such as /dev/urandom on Unix or
CryptGenRandom on Windows).
Not available on all systems (see os.urandom() for details).
"""
def random(self):
"""Get the next random number in the range [0.0, 1.0)."""
return (int.from_bytes(_urandom(7), 'big') >> 3) * RECIP_BPF
def getrandbits(self, k):
"""getrandbits(k) -> x. Generates a long int with k random bits."""
if k <= 0:
raise ValueError('number of bits must be greater than zero')
if k != int(k):
raise TypeError('number of bits should be an integer')
numbytes = (k + 7) // 8 # bits / 8 and rounded up
x = int.from_bytes(_urandom(numbytes), 'big')
return x >> (numbytes * 8 - k) # trim excess bits
def seed(self, *args, **kwds):
"Stub method. Not used for a system random number generator."
return None
def _notimplemented(self, *args, **kwds):
"Method should not be called for a system random number generator."
raise NotImplementedError('System entropy source does not have state.')
getstate = setstate = _notimplemented
## -------------------- test program --------------------
def _test_generator(n, func, args):
import time
print(n, 'times', func.__name__)
total = 0.0
sqsum = 0.0
smallest = 1e10
largest = -1e10
t0 = time.time()
for i in range(n):
x = func(*args)
total += x
sqsum = sqsum + x*x
smallest = min(x, smallest)
largest = max(x, largest)
t1 = time.time()
print(round(t1-t0, 3), 'sec,', end=' ')
avg = total/n
stddev = _sqrt(sqsum/n - avg*avg)
print('avg %g, stddev %g, min %g, max %g' % \
(avg, stddev, smallest, largest))
def _test(N=2000):
_test_generator(N, random, ())
_test_generator(N, normalvariate, (0.0, 1.0))
_test_generator(N, lognormvariate, (0.0, 1.0))
_test_generator(N, vonmisesvariate, (0.0, 1.0))
_test_generator(N, gammavariate, (0.01, 1.0))
_test_generator(N, gammavariate, (0.1, 1.0))
_test_generator(N, gammavariate, (0.1, 2.0))
_test_generator(N, gammavariate, (0.5, 1.0))
_test_generator(N, gammavariate, (0.9, 1.0))
_test_generator(N, gammavariate, (1.0, 1.0))
_test_generator(N, gammavariate, (2.0, 1.0))
_test_generator(N, gammavariate, (20.0, 1.0))
_test_generator(N, gammavariate, (200.0, 1.0))
_test_generator(N, gauss, (0.0, 1.0))
_test_generator(N, betavariate, (3.0, 3.0))
_test_generator(N, triangular, (0.0, 1.0, 1.0/3.0))
# Create one instance, seeded from current time, and export its methods
# as module-level functions. The functions share state across all uses
#(both in the user's code and in the Python libraries), but that's fine
# for most programs and is easier for the casual user than making them
# instantiate their own Random() instance.
_inst = Random()
seed = _inst.seed
random = _inst.random
uniform = _inst.uniform
triangular = _inst.triangular
randint = _inst.randint
choice = _inst.choice
randrange = _inst.randrange
sample = _inst.sample
shuffle = _inst.shuffle
normalvariate = _inst.normalvariate
lognormvariate = _inst.lognormvariate
expovariate = _inst.expovariate
vonmisesvariate = _inst.vonmisesvariate
gammavariate = _inst.gammavariate
gauss = _inst.gauss
betavariate = _inst.betavariate
paretovariate = _inst.paretovariate
weibullvariate = _inst.weibullvariate
getstate = _inst.getstate
setstate = _inst.setstate
getrandbits = _inst.getrandbits
if __name__ == '__main__':
_test()
|
apache-2.0
|
[
624,
3883,
1750,
16952,
14,
339,
9446,
272,
3001,
1779,
14818,
4453,
1425,
339,
8013,
272,
3001,
13,
1779,
3732,
2196,
1819,
1779,
3732,
2196,
2690,
1779,
3550,
2196,
22966,
339,
10208,
641,
314,
3363,
1004,
26,
272,
10652,
10965,
1779,
14818,
1779,
3229,
11572,
1779,
3293,
334,
26756,
9,
1779,
560,
784,
1783,
1779,
6946,
23160,
1779,
10169,
1779,
8201,
1779,
691,
264,
475,
1779,
2136,
20587,
339,
10208,
641,
314,
17990,
334,
13162,
378,
370,
499,
1038,
9,
272,
11016,
8684,
1779,
15032,
14818,
1779,
373,
265,
603,
1388,
199,
199,
14109,
12681,
641,
314,
8793,
18880,
2464,
685,
377,
87,
1429,
6170,
4306,
26,
199,
199,
10,
710,
6247,
365,
499,
538,
7155,
1401,
13,
17,
14,
199,
10,
2779,
365,
1373,
402,
314,
4750,
2178,
9840,
12470,
16952,
315,
23780,
14,
199,
10,
710,
2196,
342,
1083,
365,
6366,
315,
445,
12,
24956,
315,
282,
2849,
2018,
3650,
12,
523,
436,
365,
12,
16119,
12,
2462,
3489,
14,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
3598,
492,
7987,
465,
485,
4050,
199,
504,
2943,
492,
9075,
804,
465,
485,
24674,
12,
22422,
24674,
465,
485,
12306,
24674,
199,
504,
3473,
492,
943,
465,
485,
793,
12,
1437,
465,
485,
1474,
12,
6682,
465,
485,
1038,
12,
325,
465,
485,
69,
12,
30449,
465,
485,
14085,
199,
504,
3473,
492,
7452,
465,
485,
5079,
12,
282,
5197,
465,
485,
65,
5197,
12,
9794,
465,
485,
5197,
12,
9829,
465,
485,
5911,
199,
504,
747,
492,
7629,
1241,
465,
485,
22776,
199,
504,
5055,
492,
2494,
465,
485,
1084,
12,
10975,
465,
485,
5826,
199,
504,
8337,
492,
7793,
7736,
465,
485,
4835,
7736,
199,
199,
363,
452,
363,
275,
2097,
3883,
2266,
5176,
2266,
2355,
2266,
8830,
2266,
8393,
2266,
5095,
2266,
3271,
401,
1779,
298,
20539,
2266,
11777,
2266,
3302,
13805,
2266,
320,
784,
1025,
13805,
401,
1779,
298,
476,
555,
13805,
2266,
86,
265,
77,
1388,
13805,
2266,
7325,
13805,
2266,
29663,
401,
1779,
298,
25898,
2266,
9549,
1214,
18449,
2266,
4096,
475,
13805,
2266,
1129,
20587,
13805,
401,
1779,
298,
16011,
2266,
17212,
401,
298,
362,
3759,
5609,
401,
1779,
298,
3989,
3883,
937,
199,
199,
7312,
63,
19973,
13310,
275,
841,
627,
485,
1474,
2801,
16,
14,
21,
2447,
63,
5079,
8,
18,
14,
16,
9,
199,
16491,
1938,
41,
275,
499,
14,
16,
10,
63,
1038,
199,
4947,
20,
275,
485,
793,
8,
20,
14,
16,
9,
199,
4254,
63,
19973,
13310,
275,
413,
14,
16,
435,
485,
793,
8,
20,
14,
21,
9,
199,
34,
10966,
275,
13564,
263,
327,
4860,
402,
5821,
315,
282,
2069,
199,
9481,
1772,
63,
34,
10966,
275,
499,
25376,
34,
10966,
421,
199,
3,
6266,
1776,
701,
598,
1535,
79,
20744,
6848,
385,
453,
687,
445,
1350,
2741,
701,
199,
3,
4431,
18429,
8857,
7346,
89,
14,
221,
4431,
18309,
701,
30703,
2106,
68,
869,
386,
1337,
281,
367,
675,
543,
199,
3,
314,
18880,
2464,
685,
377,
87,
1429,
221,
436,
747,
14,
22776,
342,
6170,
16952,
14,
199,
199,
646,
485,
2355,
199,
199,
533,
9571,
1547,
2355,
14,
3883,
304,
272,
408,
3883,
1329,
4306,
1300,
1021,
1202,
701,
3914,
859,
3423,
14,
339,
8051,
370,
17321,
4454,
402,
9571,
370,
664,
16952,
626,
2793,
1133,
272,
8663,
1174,
14,
339,
8089,
9571,
883,
2597,
506,
1007,
28271,
340,
1265,
2934,
370,
675,
282,
3365,
5678,
272,
4306,
402,
2195,
5705,
4866,
11136,
26,
315,
626,
1930,
12,
4278,
314,
2569,
272,
3102,
26,
221,
2196,
1062,
6347,
1062,
664,
929,
1062,
436,
663,
929,
1252,
272,
22383,
12,
5669,
282,
664,
3759,
5609,
342,
1083,
880,
626,
10261,
1842,
342,
272,
883,
8486,
601,
2075,
82,
11406,
7031,
12271,
14,
339,
408,
339,
15945,
275,
650,
258,
327,
1202,
701,
664,
929,
15,
17212,
339,
347,
636,
826,
721,
277,
12,
671,
29,
403,
304,
267,
408,
9345,
376,
1256,
14,
398,
4879,
1423,
671,
13467,
6347,
316,
12,
465,
367,
9571,
14,
5176,
1252,
267,
408,
398,
291,
14,
5176,
8,
88,
9,
267,
291,
14,
25898,
63,
2184,
275,
488,
339,
347,
6347,
8,
277,
12,
282,
29,
403,
12,
1015,
29,
18,
304,
267,
408,
9345,
5007,
1174,
687,
21197,
909,
14,
398,
488,
503,
949,
1423,
26825,
687,
1453,
900,
503,
687,
376,
17406,
267,
2656,
2488,
2196,
4171,
1350,
340,
2808,
14,
398,
2104,
1015,
499,
334,
1589,
849,
395,
1006,
402,
314,
5821,
787,
1202,
340,
627,
65,
627,
374,
282,
620,
12,
267,
2783,
12,
503,
11640,
14,
221,
2104,
1015,
413,
12,
314,
2631,
342,
402,
627,
65,
10,
365,
1202,
3140,
14,
398,
982,
627,
65,
10,
365,
376,
1109,
12,
1006,
5821,
787,
1202,
14,
398,
408,
398,
340,
282,
365,
488,
26,
288,
862,
26,
355,
282,
275,
1109,
14,
504,
63,
2394,
1547,
22776,
8,
708,
395,
283,
5076,
358,
288,
871,
4279,
26,
355,
492,
900,
355,
282,
275,
1109,
8,
521,
14,
521,
342,
627,
7633,
9,
327,
675,
27487,
4696,
398,
340,
1015,
508,
499,
26,
288,
340,
1228,
8,
65,
12,
334,
495,
12,
2783,
12,
11640,
2298,
355,
340,
1228,
8,
65,
12,
620,
304,
490,
282,
275,
282,
14,
2143,
342,
355,
282,
847,
485,
4835,
7736,
8,
65,
680,
5671,
342,
355,
282,
275,
1109,
14,
504,
63,
2394,
8,
65,
12,
283,
5076,
358,
398,
1613,
1252,
5176,
8,
65,
9,
267,
291,
14,
25898,
63,
2184,
275,
488,
339,
347,
664,
929,
8,
277,
304,
267,
408,
1767,
5007,
1174,
27,
883,
506,
3032,
370,
663,
929,
342,
2945,
1041,
267,
372,
291,
14,
4612,
12,
1613,
1252,
16011,
1062,
291,
14,
25898,
63,
2184,
339,
347,
663,
929,
8,
277,
12,
1174,
304,
267,
408,
21012,
5007,
1174,
687,
909,
2138,
701,
664,
929,
20693,
267,
1015,
275,
1174,
59,
16,
61,
267,
340,
1015,
508,
650,
26,
288,
1015,
12,
5007,
929,
12,
291,
14,
25898,
63,
2184,
275,
1174,
288,
1613,
1252,
17212,
8,
4672,
929,
9,
267,
916,
1015,
508,
499,
26,
288,
1015,
12,
5007,
929,
12,
291,
14,
25898,
63,
2184,
275
] |
[
3883,
1750,
16952,
14,
339,
9446,
272,
3001,
1779,
14818,
4453,
1425,
339,
8013,
272,
3001,
13,
1779,
3732,
2196,
1819,
1779,
3732,
2196,
2690,
1779,
3550,
2196,
22966,
339,
10208,
641,
314,
3363,
1004,
26,
272,
10652,
10965,
1779,
14818,
1779,
3229,
11572,
1779,
3293,
334,
26756,
9,
1779,
560,
784,
1783,
1779,
6946,
23160,
1779,
10169,
1779,
8201,
1779,
691,
264,
475,
1779,
2136,
20587,
339,
10208,
641,
314,
17990,
334,
13162,
378,
370,
499,
1038,
9,
272,
11016,
8684,
1779,
15032,
14818,
1779,
373,
265,
603,
1388,
199,
199,
14109,
12681,
641,
314,
8793,
18880,
2464,
685,
377,
87,
1429,
6170,
4306,
26,
199,
199,
10,
710,
6247,
365,
499,
538,
7155,
1401,
13,
17,
14,
199,
10,
2779,
365,
1373,
402,
314,
4750,
2178,
9840,
12470,
16952,
315,
23780,
14,
199,
10,
710,
2196,
342,
1083,
365,
6366,
315,
445,
12,
24956,
315,
282,
2849,
2018,
3650,
12,
523,
436,
365,
12,
16119,
12,
2462,
3489,
14,
199,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
3598,
492,
7987,
465,
485,
4050,
199,
504,
2943,
492,
9075,
804,
465,
485,
24674,
12,
22422,
24674,
465,
485,
12306,
24674,
199,
504,
3473,
492,
943,
465,
485,
793,
12,
1437,
465,
485,
1474,
12,
6682,
465,
485,
1038,
12,
325,
465,
485,
69,
12,
30449,
465,
485,
14085,
199,
504,
3473,
492,
7452,
465,
485,
5079,
12,
282,
5197,
465,
485,
65,
5197,
12,
9794,
465,
485,
5197,
12,
9829,
465,
485,
5911,
199,
504,
747,
492,
7629,
1241,
465,
485,
22776,
199,
504,
5055,
492,
2494,
465,
485,
1084,
12,
10975,
465,
485,
5826,
199,
504,
8337,
492,
7793,
7736,
465,
485,
4835,
7736,
199,
199,
363,
452,
363,
275,
2097,
3883,
2266,
5176,
2266,
2355,
2266,
8830,
2266,
8393,
2266,
5095,
2266,
3271,
401,
1779,
298,
20539,
2266,
11777,
2266,
3302,
13805,
2266,
320,
784,
1025,
13805,
401,
1779,
298,
476,
555,
13805,
2266,
86,
265,
77,
1388,
13805,
2266,
7325,
13805,
2266,
29663,
401,
1779,
298,
25898,
2266,
9549,
1214,
18449,
2266,
4096,
475,
13805,
2266,
1129,
20587,
13805,
401,
1779,
298,
16011,
2266,
17212,
401,
298,
362,
3759,
5609,
401,
1779,
298,
3989,
3883,
937,
199,
199,
7312,
63,
19973,
13310,
275,
841,
627,
485,
1474,
2801,
16,
14,
21,
2447,
63,
5079,
8,
18,
14,
16,
9,
199,
16491,
1938,
41,
275,
499,
14,
16,
10,
63,
1038,
199,
4947,
20,
275,
485,
793,
8,
20,
14,
16,
9,
199,
4254,
63,
19973,
13310,
275,
413,
14,
16,
435,
485,
793,
8,
20,
14,
21,
9,
199,
34,
10966,
275,
13564,
263,
327,
4860,
402,
5821,
315,
282,
2069,
199,
9481,
1772,
63,
34,
10966,
275,
499,
25376,
34,
10966,
421,
199,
3,
6266,
1776,
701,
598,
1535,
79,
20744,
6848,
385,
453,
687,
445,
1350,
2741,
701,
199,
3,
4431,
18429,
8857,
7346,
89,
14,
221,
4431,
18309,
701,
30703,
2106,
68,
869,
386,
1337,
281,
367,
675,
543,
199,
3,
314,
18880,
2464,
685,
377,
87,
1429,
221,
436,
747,
14,
22776,
342,
6170,
16952,
14,
199,
199,
646,
485,
2355,
199,
199,
533,
9571,
1547,
2355,
14,
3883,
304,
272,
408,
3883,
1329,
4306,
1300,
1021,
1202,
701,
3914,
859,
3423,
14,
339,
8051,
370,
17321,
4454,
402,
9571,
370,
664,
16952,
626,
2793,
1133,
272,
8663,
1174,
14,
339,
8089,
9571,
883,
2597,
506,
1007,
28271,
340,
1265,
2934,
370,
675,
282,
3365,
5678,
272,
4306,
402,
2195,
5705,
4866,
11136,
26,
315,
626,
1930,
12,
4278,
314,
2569,
272,
3102,
26,
221,
2196,
1062,
6347,
1062,
664,
929,
1062,
436,
663,
929,
1252,
272,
22383,
12,
5669,
282,
664,
3759,
5609,
342,
1083,
880,
626,
10261,
1842,
342,
272,
883,
8486,
601,
2075,
82,
11406,
7031,
12271,
14,
339,
408,
339,
15945,
275,
650,
258,
327,
1202,
701,
664,
929,
15,
17212,
339,
347,
636,
826,
721,
277,
12,
671,
29,
403,
304,
267,
408,
9345,
376,
1256,
14,
398,
4879,
1423,
671,
13467,
6347,
316,
12,
465,
367,
9571,
14,
5176,
1252,
267,
408,
398,
291,
14,
5176,
8,
88,
9,
267,
291,
14,
25898,
63,
2184,
275,
488,
339,
347,
6347,
8,
277,
12,
282,
29,
403,
12,
1015,
29,
18,
304,
267,
408,
9345,
5007,
1174,
687,
21197,
909,
14,
398,
488,
503,
949,
1423,
26825,
687,
1453,
900,
503,
687,
376,
17406,
267,
2656,
2488,
2196,
4171,
1350,
340,
2808,
14,
398,
2104,
1015,
499,
334,
1589,
849,
395,
1006,
402,
314,
5821,
787,
1202,
340,
627,
65,
627,
374,
282,
620,
12,
267,
2783,
12,
503,
11640,
14,
221,
2104,
1015,
413,
12,
314,
2631,
342,
402,
627,
65,
10,
365,
1202,
3140,
14,
398,
982,
627,
65,
10,
365,
376,
1109,
12,
1006,
5821,
787,
1202,
14,
398,
408,
398,
340,
282,
365,
488,
26,
288,
862,
26,
355,
282,
275,
1109,
14,
504,
63,
2394,
1547,
22776,
8,
708,
395,
283,
5076,
358,
288,
871,
4279,
26,
355,
492,
900,
355,
282,
275,
1109,
8,
521,
14,
521,
342,
627,
7633,
9,
327,
675,
27487,
4696,
398,
340,
1015,
508,
499,
26,
288,
340,
1228,
8,
65,
12,
334,
495,
12,
2783,
12,
11640,
2298,
355,
340,
1228,
8,
65,
12,
620,
304,
490,
282,
275,
282,
14,
2143,
342,
355,
282,
847,
485,
4835,
7736,
8,
65,
680,
5671,
342,
355,
282,
275,
1109,
14,
504,
63,
2394,
8,
65,
12,
283,
5076,
358,
398,
1613,
1252,
5176,
8,
65,
9,
267,
291,
14,
25898,
63,
2184,
275,
488,
339,
347,
664,
929,
8,
277,
304,
267,
408,
1767,
5007,
1174,
27,
883,
506,
3032,
370,
663,
929,
342,
2945,
1041,
267,
372,
291,
14,
4612,
12,
1613,
1252,
16011,
1062,
291,
14,
25898,
63,
2184,
339,
347,
663,
929,
8,
277,
12,
1174,
304,
267,
408,
21012,
5007,
1174,
687,
909,
2138,
701,
664,
929,
20693,
267,
1015,
275,
1174,
59,
16,
61,
267,
340,
1015,
508,
650,
26,
288,
1015,
12,
5007,
929,
12,
291,
14,
25898,
63,
2184,
275,
1174,
288,
1613,
1252,
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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
] |
yongtang/tensorflow
|
tensorflow/python/ops/signal/spectral_ops.py
|
6
|
20175
|
# 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.
# ==============================================================================
"""Spectral operations (e.g. Short-time Fourier Transform)."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops.signal import dct_ops
from tensorflow.python.ops.signal import fft_ops
from tensorflow.python.ops.signal import reconstruction_ops
from tensorflow.python.ops.signal import shape_ops
from tensorflow.python.ops.signal import window_ops
from tensorflow.python.util import dispatch
from tensorflow.python.util.tf_export import tf_export
@tf_export('signal.stft')
@dispatch.add_dispatch_support
def stft(signals, frame_length, frame_step, fft_length=None,
window_fn=window_ops.hann_window,
pad_end=False, name=None):
"""Computes the [Short-time Fourier Transform][stft] of `signals`.
Implemented with TPU/GPU-compatible ops and supports gradients.
Args:
signals: A `[..., samples]` `float32`/`float64` `Tensor` of real-valued
signals.
frame_length: An integer scalar `Tensor`. The window length in samples.
frame_step: An integer scalar `Tensor`. The number of samples to step.
fft_length: An integer scalar `Tensor`. The size of the FFT to apply.
If not provided, uses the smallest power of 2 enclosing `frame_length`.
window_fn: A callable that takes a window length and a `dtype` keyword
argument and returns a `[window_length]` `Tensor` of samples in the
provided datatype. If set to `None`, no windowing is used.
pad_end: Whether to pad the end of `signals` with zeros when the provided
frame length and step produces a frame that lies partially past its end.
name: An optional name for the operation.
Returns:
A `[..., frames, fft_unique_bins]` `Tensor` of `complex64`/`complex128`
STFT values where `fft_unique_bins` is `fft_length // 2 + 1` (the unique
components of the FFT).
Raises:
ValueError: If `signals` is not at least rank 1, `frame_length` is
not scalar, or `frame_step` is not scalar.
[stft]: https://en.wikipedia.org/wiki/Short-time_Fourier_transform
"""
with ops.name_scope(name, 'stft', [signals, frame_length,
frame_step]):
signals = ops.convert_to_tensor(signals, name='signals')
signals.shape.with_rank_at_least(1)
frame_length = ops.convert_to_tensor(frame_length, name='frame_length')
frame_length.shape.assert_has_rank(0)
frame_step = ops.convert_to_tensor(frame_step, name='frame_step')
frame_step.shape.assert_has_rank(0)
if fft_length is None:
fft_length = _enclosing_power_of_two(frame_length)
else:
fft_length = ops.convert_to_tensor(fft_length, name='fft_length')
framed_signals = shape_ops.frame(
signals, frame_length, frame_step, pad_end=pad_end)
# Optionally window the framed signals.
if window_fn is not None:
window = window_fn(frame_length, dtype=framed_signals.dtype)
framed_signals *= window
# fft_ops.rfft produces the (fft_length/2 + 1) unique components of the
# FFT of the real windowed signals in framed_signals.
return fft_ops.rfft(framed_signals, [fft_length])
@tf_export('signal.inverse_stft_window_fn')
@dispatch.add_dispatch_support
def inverse_stft_window_fn(frame_step,
forward_window_fn=window_ops.hann_window,
name=None):
"""Generates a window function that can be used in `inverse_stft`.
Constructs a window that is equal to the forward window with a further
pointwise amplitude correction. `inverse_stft_window_fn` is equivalent to
`forward_window_fn` in the case where it would produce an exact inverse.
See examples in `inverse_stft` documentation for usage.
Args:
frame_step: An integer scalar `Tensor`. The number of samples to step.
forward_window_fn: window_fn used in the forward transform, `stft`.
name: An optional name for the operation.
Returns:
A callable that takes a window length and a `dtype` keyword argument and
returns a `[window_length]` `Tensor` of samples in the provided datatype.
The returned window is suitable for reconstructing original waveform in
inverse_stft.
"""
def inverse_stft_window_fn_inner(frame_length, dtype):
"""Computes a window that can be used in `inverse_stft`.
Args:
frame_length: An integer scalar `Tensor`. The window length in samples.
dtype: Data type of waveform passed to `stft`.
Returns:
A window suitable for reconstructing original waveform in `inverse_stft`.
Raises:
ValueError: If `frame_length` is not scalar, `forward_window_fn` is not a
callable that takes a window length and a `dtype` keyword argument and
returns a `[window_length]` `Tensor` of samples in the provided datatype
`frame_step` is not scalar, or `frame_step` is not scalar.
"""
with ops.name_scope(name, 'inverse_stft_window_fn', [forward_window_fn]):
frame_step_ = ops.convert_to_tensor(frame_step, name='frame_step')
frame_step_.shape.assert_has_rank(0)
frame_length = ops.convert_to_tensor(frame_length, name='frame_length')
frame_length.shape.assert_has_rank(0)
# Use equation 7 from Griffin + Lim.
forward_window = forward_window_fn(frame_length, dtype=dtype)
denom = math_ops.square(forward_window)
overlaps = -(-frame_length // frame_step_) # Ceiling division. # pylint: disable=invalid-unary-operand-type
denom = array_ops.pad(denom, [(0, overlaps * frame_step_ - frame_length)])
denom = array_ops.reshape(denom, [overlaps, frame_step_])
denom = math_ops.reduce_sum(denom, 0, keepdims=True)
denom = array_ops.tile(denom, [overlaps, 1])
denom = array_ops.reshape(denom, [overlaps * frame_step_])
return forward_window / denom[:frame_length]
return inverse_stft_window_fn_inner
@tf_export('signal.inverse_stft')
@dispatch.add_dispatch_support
def inverse_stft(stfts,
frame_length,
frame_step,
fft_length=None,
window_fn=window_ops.hann_window,
name=None):
"""Computes the inverse [Short-time Fourier Transform][stft] of `stfts`.
To reconstruct an original waveform, a complementary window function should
be used with `inverse_stft`. Such a window function can be constructed with
`tf.signal.inverse_stft_window_fn`.
Example:
```python
frame_length = 400
frame_step = 160
waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
stft = tf.signal.stft(waveform, frame_length, frame_step)
inverse_stft = tf.signal.inverse_stft(
stft, frame_length, frame_step,
window_fn=tf.signal.inverse_stft_window_fn(frame_step))
```
If a custom `window_fn` is used with `tf.signal.stft`, it must be passed to
`tf.signal.inverse_stft_window_fn`:
```python
frame_length = 400
frame_step = 160
window_fn = tf.signal.hamming_window
waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
stft = tf.signal.stft(
waveform, frame_length, frame_step, window_fn=window_fn)
inverse_stft = tf.signal.inverse_stft(
stft, frame_length, frame_step,
window_fn=tf.signal.inverse_stft_window_fn(
frame_step, forward_window_fn=window_fn))
```
Implemented with TPU/GPU-compatible ops and supports gradients.
Args:
stfts: A `complex64`/`complex128` `[..., frames, fft_unique_bins]`
`Tensor` of STFT bins representing a batch of `fft_length`-point STFTs
where `fft_unique_bins` is `fft_length // 2 + 1`
frame_length: An integer scalar `Tensor`. The window length in samples.
frame_step: An integer scalar `Tensor`. The number of samples to step.
fft_length: An integer scalar `Tensor`. The size of the FFT that produced
`stfts`. If not provided, uses the smallest power of 2 enclosing
`frame_length`.
window_fn: A callable that takes a window length and a `dtype` keyword
argument and returns a `[window_length]` `Tensor` of samples in the
provided datatype. If set to `None`, no windowing is used.
name: An optional name for the operation.
Returns:
A `[..., samples]` `Tensor` of `float32`/`float64` signals representing
the inverse STFT for each input STFT in `stfts`.
Raises:
ValueError: If `stfts` is not at least rank 2, `frame_length` is not scalar,
`frame_step` is not scalar, or `fft_length` is not scalar.
[stft]: https://en.wikipedia.org/wiki/Short-time_Fourier_transform
"""
with ops.name_scope(name, 'inverse_stft', [stfts]):
stfts = ops.convert_to_tensor(stfts, name='stfts')
stfts.shape.with_rank_at_least(2)
frame_length = ops.convert_to_tensor(frame_length, name='frame_length')
frame_length.shape.assert_has_rank(0)
frame_step = ops.convert_to_tensor(frame_step, name='frame_step')
frame_step.shape.assert_has_rank(0)
if fft_length is None:
fft_length = _enclosing_power_of_two(frame_length)
else:
fft_length = ops.convert_to_tensor(fft_length, name='fft_length')
fft_length.shape.assert_has_rank(0)
real_frames = fft_ops.irfft(stfts, [fft_length])
# frame_length may be larger or smaller than fft_length, so we pad or
# truncate real_frames to frame_length.
frame_length_static = tensor_util.constant_value(frame_length)
# If we don't know the shape of real_frames's inner dimension, pad and
# truncate to frame_length.
if (frame_length_static is None or real_frames.shape.ndims is None or
real_frames.shape.as_list()[-1] is None):
real_frames = real_frames[..., :frame_length]
real_frames_rank = array_ops.rank(real_frames)
real_frames_shape = array_ops.shape(real_frames)
paddings = array_ops.concat(
[array_ops.zeros([real_frames_rank - 1, 2],
dtype=frame_length.dtype),
[[0, math_ops.maximum(0, frame_length - real_frames_shape[-1])]]], 0)
real_frames = array_ops.pad(real_frames, paddings)
# We know real_frames's last dimension and frame_length statically. If they
# are different, then pad or truncate real_frames to frame_length.
elif real_frames.shape.as_list()[-1] > frame_length_static:
real_frames = real_frames[..., :frame_length_static]
elif real_frames.shape.as_list()[-1] < frame_length_static:
pad_amount = frame_length_static - real_frames.shape.as_list()[-1]
real_frames = array_ops.pad(real_frames,
[[0, 0]] * (real_frames.shape.ndims - 1) +
[[0, pad_amount]])
# The above code pads the inner dimension of real_frames to frame_length,
# but it does so in a way that may not be shape-inference friendly.
# Restore shape information if we are able to.
if frame_length_static is not None and real_frames.shape.ndims is not None:
real_frames.set_shape([None] * (real_frames.shape.ndims - 1) +
[frame_length_static])
# Optionally window and overlap-add the inner 2 dimensions of real_frames
# into a single [samples] dimension.
if window_fn is not None:
window = window_fn(frame_length, dtype=stfts.dtype.real_dtype)
real_frames *= window
return reconstruction_ops.overlap_and_add(real_frames, frame_step)
def _enclosing_power_of_two(value):
"""Return 2**N for integer N such that 2**N >= value."""
value_static = tensor_util.constant_value(value)
if value_static is not None:
return constant_op.constant(
int(2**np.ceil(np.log(value_static) / np.log(2.0))), value.dtype)
return math_ops.cast(
math_ops.pow(
2.0,
math_ops.ceil(
math_ops.log(math_ops.cast(value, dtypes.float32)) /
math_ops.log(2.0))), value.dtype)
@tf_export('signal.mdct')
@dispatch.add_dispatch_support
def mdct(signals, frame_length, window_fn=window_ops.vorbis_window,
pad_end=False, norm=None, name=None):
"""Computes the [Modified Discrete Cosine Transform][mdct] of `signals`.
Implemented with TPU/GPU-compatible ops and supports gradients.
Args:
signals: A `[..., samples]` `float32`/`float64` `Tensor` of real-valued
signals.
frame_length: An integer scalar `Tensor`. The window length in samples
which must be divisible by 4.
window_fn: A callable that takes a frame_length and a `dtype` keyword
argument and returns a `[frame_length]` `Tensor` of samples in the
provided datatype. If set to `None`, a rectangular window with a scale of
1/sqrt(2) is used. For perfect reconstruction of a signal from `mdct`
followed by `inverse_mdct`, please use `tf.signal.vorbis_window`,
`tf.signal.kaiser_bessel_derived_window` or `None`. If using another
window function, make sure that w[n]^2 + w[n + frame_length // 2]^2 = 1
and w[n] = w[frame_length - n - 1] for n = 0,...,frame_length // 2 - 1 to
achieve perfect reconstruction.
pad_end: Whether to pad the end of `signals` with zeros when the provided
frame length and step produces a frame that lies partially past its end.
norm: If it is None, unnormalized dct4 is used, if it is "ortho"
orthonormal dct4 is used.
name: An optional name for the operation.
Returns:
A `[..., frames, frame_length // 2]` `Tensor` of `float32`/`float64`
MDCT values where `frames` is roughly `samples // (frame_length // 2)`
when `pad_end=False`.
Raises:
ValueError: If `signals` is not at least rank 1, `frame_length` is
not scalar, or `frame_length` is not a multiple of `4`.
[mdct]: https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform
"""
with ops.name_scope(name, 'mdct', [signals, frame_length]):
signals = ops.convert_to_tensor(signals, name='signals')
signals.shape.with_rank_at_least(1)
frame_length = ops.convert_to_tensor(frame_length, name='frame_length')
frame_length.shape.assert_has_rank(0)
# Assert that frame_length is divisible by 4.
frame_length_static = tensor_util.constant_value(frame_length)
if frame_length_static is not None:
if frame_length_static % 4 != 0:
raise ValueError('The frame length must be a multiple of 4.')
frame_step = ops.convert_to_tensor(frame_length_static // 2,
dtype=frame_length.dtype)
else:
frame_step = frame_length // 2
framed_signals = shape_ops.frame(
signals, frame_length, frame_step, pad_end=pad_end)
# Optionally window the framed signals.
if window_fn is not None:
window = window_fn(frame_length, dtype=framed_signals.dtype)
framed_signals *= window
else:
framed_signals *= 1.0 / np.sqrt(2)
split_frames = array_ops.split(framed_signals, 4, axis=-1)
frame_firsthalf = -array_ops.reverse(split_frames[2],
[-1]) - split_frames[3]
frame_secondhalf = split_frames[0] - array_ops.reverse(split_frames[1],
[-1])
frames_rearranged = array_ops.concat((frame_firsthalf, frame_secondhalf),
axis=-1)
# Below call produces the (frame_length // 2) unique components of the
# type 4 orthonormal DCT of the real windowed signals in frames_rearranged.
return dct_ops.dct(frames_rearranged, type=4, norm=norm)
@tf_export('signal.inverse_mdct')
@dispatch.add_dispatch_support
def inverse_mdct(mdcts,
window_fn=window_ops.vorbis_window,
norm=None,
name=None):
"""Computes the inverse modified DCT of `mdcts`.
To reconstruct an original waveform, the same window function should
be used with `mdct` and `inverse_mdct`.
Example usage:
>>> @tf.function
... def compare_round_trip():
... samples = 1000
... frame_length = 400
... halflen = frame_length // 2
... waveform = tf.random.normal(dtype=tf.float32, shape=[samples])
... waveform_pad = tf.pad(waveform, [[halflen, 0],])
... mdct = tf.signal.mdct(waveform_pad, frame_length, pad_end=True,
... window_fn=tf.signal.vorbis_window)
... inverse_mdct = tf.signal.inverse_mdct(mdct,
... window_fn=tf.signal.vorbis_window)
... inverse_mdct = inverse_mdct[halflen: halflen + samples]
... return waveform, inverse_mdct
>>> waveform, inverse_mdct = compare_round_trip()
>>> np.allclose(waveform.numpy(), inverse_mdct.numpy(), rtol=1e-3, atol=1e-4)
True
Implemented with TPU/GPU-compatible ops and supports gradients.
Args:
mdcts: A `float32`/`float64` `[..., frames, frame_length // 2]`
`Tensor` of MDCT bins representing a batch of `frame_length // 2`-point
MDCTs.
window_fn: A callable that takes a frame_length and a `dtype` keyword
argument and returns a `[frame_length]` `Tensor` of samples in the
provided datatype. If set to `None`, a rectangular window with a scale of
1/sqrt(2) is used. For perfect reconstruction of a signal from `mdct`
followed by `inverse_mdct`, please use `tf.signal.vorbis_window`,
`tf.signal.kaiser_bessel_derived_window` or `None`. If using another
window function, make sure that w[n]^2 + w[n + frame_length // 2]^2 = 1
and w[n] = w[frame_length - n - 1] for n = 0,...,frame_length // 2 - 1 to
achieve perfect reconstruction.
norm: If "ortho", orthonormal inverse DCT4 is performed, if it is None,
a regular dct4 followed by scaling of `1/frame_length` is performed.
name: An optional name for the operation.
Returns:
A `[..., samples]` `Tensor` of `float32`/`float64` signals representing
the inverse MDCT for each input MDCT in `mdcts` where `samples` is
`(frames - 1) * (frame_length // 2) + frame_length`.
Raises:
ValueError: If `mdcts` is not at least rank 2.
[mdct]: https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform
"""
with ops.name_scope(name, 'inverse_mdct', [mdcts]):
mdcts = ops.convert_to_tensor(mdcts, name='mdcts')
mdcts.shape.with_rank_at_least(2)
half_len = math_ops.cast(mdcts.shape[-1], dtype=dtypes.int32)
if norm is None:
half_len_float = math_ops.cast(half_len, dtype=mdcts.dtype)
result_idct4 = (0.5 / half_len_float) * dct_ops.dct(mdcts, type=4)
elif norm == 'ortho':
result_idct4 = dct_ops.dct(mdcts, type=4, norm='ortho')
split_result = array_ops.split(result_idct4, 2, axis=-1)
real_frames = array_ops.concat((split_result[1],
-array_ops.reverse(split_result[1], [-1]),
-array_ops.reverse(split_result[0], [-1]),
-split_result[0]), axis=-1)
# Optionally window and overlap-add the inner 2 dimensions of real_frames
# into a single [samples] dimension.
if window_fn is not None:
window = window_fn(2 * half_len, dtype=mdcts.dtype)
real_frames *= window
else:
real_frames *= 1.0 / np.sqrt(2)
return reconstruction_ops.overlap_and_add(real_frames, half_len)
|
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,
51,
15832,
5331,
334,
69,
14,
71,
14,
20124,
13,
521,
23843,
4446,
19463,
10477,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2345,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
16354,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
18160,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
295,
12708,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
2215,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
4353,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1974,
492,
7634,
199,
504,
3228,
14,
1548,
14,
1974,
14,
3249,
63,
3790,
492,
2833,
63,
3790,
421,
199,
32,
3249,
63,
3790,
360,
4653,
14,
270,
856,
358,
199,
32,
6052,
14,
525,
63,
6052,
63,
4058,
199,
318,
410,
856,
8,
10458,
12,
2787,
63,
1267,
12,
2787,
63,
2926,
12,
18160,
63,
1267,
29,
403,
12,
268,
4353,
63,
2324,
29,
3806,
63,
1483,
14,
72,
1189,
63,
3806,
12,
268,
6567,
63,
500,
29,
797,
12,
536,
29,
403,
304,
523,
408,
22594,
314,
359,
10039,
13,
521,
23843,
4446,
19463,
1527,
270,
856,
61,
402,
658,
10458,
2313,
819,
11794,
2509,
543,
377,
6903,
15,
20769,
13,
6490,
4156,
436,
5171,
12661,
14,
819,
3033,
26,
272,
10166,
26,
437,
14505,
11577,
5845,
16090,
658,
1609,
708,
64,
15,
64,
1609,
772,
64,
658,
3861,
64,
402,
3363,
13,
16611,
489,
10166,
14,
272,
2787,
63,
1267,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
4353,
2582,
315,
5845,
14,
272,
2787,
63,
2926,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
1329,
402,
5845,
370,
3650,
14,
272,
18160,
63,
1267,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
1568,
402,
314,
29484,
370,
4838,
14,
489,
982,
440,
2741,
12,
4440,
314,
18604,
7074,
402,
499,
25188,
658,
1943,
63,
1267,
2313,
272,
4353,
63,
2324,
26,
437,
4550,
626,
6181,
282,
4353,
2582,
436,
282,
658,
2271,
64,
4252,
489,
1423,
436,
2529,
282,
14505,
3806,
63,
1267,
16090,
658,
3861,
64,
402,
5845,
315,
314,
489,
2741,
16048,
14,
982,
663,
370,
658,
403,
3559,
949,
4353,
316,
365,
1202,
14,
272,
6567,
63,
500,
26,
7480,
370,
6567,
314,
1284,
402,
658,
10458,
64,
543,
10136,
1380,
314,
2741,
489,
2787,
2582,
436,
3650,
16904,
282,
2787,
626,
1212,
397,
25172,
13541,
2399,
1284,
14,
272,
536,
26,
1626,
2716,
536,
367,
314,
3439,
14,
819,
1803,
26,
272,
437,
14505,
11577,
11223,
12,
18160,
63,
3235,
63,
11329,
16090,
658,
3861,
64,
402,
658,
5254,
772,
64,
15,
64,
5254,
3933,
64,
272,
4384,
2161,
1338,
2382,
658,
9996,
63,
3235,
63,
11329,
64,
365,
658,
9996,
63,
1267,
5001,
499,
435,
413,
64,
334,
1589,
3747,
272,
7323,
402,
314,
29484,
680,
819,
6218,
26,
272,
1722,
26,
982,
658,
10458,
64,
365,
440,
737,
5210,
6915,
413,
12,
658,
1943,
63,
1267,
64,
365,
489,
440,
6917,
12,
503,
658,
1943,
63,
2926,
64,
365,
440,
6917,
14,
819,
359,
270,
856,
2189,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
10039,
13,
521,
63,
24766,
4446,
63,
4711,
523,
408,
523,
543,
4156,
14,
354,
63,
2645,
8,
354,
12,
283,
270,
856,
297,
359,
10458,
12,
2787,
63,
1267,
12,
3660,
2787,
63,
2926,
4682,
272,
10166,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
10458,
12,
536,
534,
10458,
358,
272,
10166,
14,
1392,
14,
1045,
63,
4648,
63,
292,
63,
11790,
8,
17,
9,
272,
2787,
63,
1267,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
1943,
63,
1267,
12,
536,
534,
1943,
63,
1267,
358,
272,
2787,
63,
1267,
14,
1392,
14,
479,
63,
1989,
63,
4648,
8,
16,
9,
272,
2787,
63,
2926,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
1943,
63,
2926,
12,
536,
534,
1943,
63,
2926,
358,
272,
2787,
63,
2926,
14,
1392,
14,
479,
63,
1989,
63,
4648,
8,
16,
9,
339,
340,
18160,
63,
1267,
365,
488,
26,
489,
18160,
63,
1267,
275,
485,
287,
11707,
63,
5652,
63,
1618,
63,
5601,
8,
1943,
63,
1267,
9,
272,
587,
26,
489,
18160,
63,
1267,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
9996,
63,
1267,
12,
536,
534,
9996,
63,
1267,
358,
339,
2787,
68,
63,
10458,
275,
2215,
63,
1483,
14,
1943,
8,
267,
10166,
12,
2787,
63,
1267,
12,
2787,
63,
2926,
12,
6567,
63,
500,
29,
6226,
63,
500,
9,
339,
327,
22383,
4353,
314,
2787,
68,
10166,
14,
272,
340,
4353,
63,
2324,
365,
440,
488,
26,
489,
4353,
275,
4353,
63,
2324,
8,
1943,
63,
1267,
12,
2152,
29,
1943,
68,
63,
10458,
14,
2271,
9,
489,
2787
] |
[
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,
51,
15832,
5331,
334,
69,
14,
71,
14,
20124,
13,
521,
23843,
4446,
19463,
10477,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
4857,
492,
2345,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
16354,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
18160,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
295,
12708,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
2215,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
4653,
492,
4353,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1974,
492,
7634,
199,
504,
3228,
14,
1548,
14,
1974,
14,
3249,
63,
3790,
492,
2833,
63,
3790,
421,
199,
32,
3249,
63,
3790,
360,
4653,
14,
270,
856,
358,
199,
32,
6052,
14,
525,
63,
6052,
63,
4058,
199,
318,
410,
856,
8,
10458,
12,
2787,
63,
1267,
12,
2787,
63,
2926,
12,
18160,
63,
1267,
29,
403,
12,
268,
4353,
63,
2324,
29,
3806,
63,
1483,
14,
72,
1189,
63,
3806,
12,
268,
6567,
63,
500,
29,
797,
12,
536,
29,
403,
304,
523,
408,
22594,
314,
359,
10039,
13,
521,
23843,
4446,
19463,
1527,
270,
856,
61,
402,
658,
10458,
2313,
819,
11794,
2509,
543,
377,
6903,
15,
20769,
13,
6490,
4156,
436,
5171,
12661,
14,
819,
3033,
26,
272,
10166,
26,
437,
14505,
11577,
5845,
16090,
658,
1609,
708,
64,
15,
64,
1609,
772,
64,
658,
3861,
64,
402,
3363,
13,
16611,
489,
10166,
14,
272,
2787,
63,
1267,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
4353,
2582,
315,
5845,
14,
272,
2787,
63,
2926,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
1329,
402,
5845,
370,
3650,
14,
272,
18160,
63,
1267,
26,
1626,
3000,
6917,
658,
3861,
2313,
710,
1568,
402,
314,
29484,
370,
4838,
14,
489,
982,
440,
2741,
12,
4440,
314,
18604,
7074,
402,
499,
25188,
658,
1943,
63,
1267,
2313,
272,
4353,
63,
2324,
26,
437,
4550,
626,
6181,
282,
4353,
2582,
436,
282,
658,
2271,
64,
4252,
489,
1423,
436,
2529,
282,
14505,
3806,
63,
1267,
16090,
658,
3861,
64,
402,
5845,
315,
314,
489,
2741,
16048,
14,
982,
663,
370,
658,
403,
3559,
949,
4353,
316,
365,
1202,
14,
272,
6567,
63,
500,
26,
7480,
370,
6567,
314,
1284,
402,
658,
10458,
64,
543,
10136,
1380,
314,
2741,
489,
2787,
2582,
436,
3650,
16904,
282,
2787,
626,
1212,
397,
25172,
13541,
2399,
1284,
14,
272,
536,
26,
1626,
2716,
536,
367,
314,
3439,
14,
819,
1803,
26,
272,
437,
14505,
11577,
11223,
12,
18160,
63,
3235,
63,
11329,
16090,
658,
3861,
64,
402,
658,
5254,
772,
64,
15,
64,
5254,
3933,
64,
272,
4384,
2161,
1338,
2382,
658,
9996,
63,
3235,
63,
11329,
64,
365,
658,
9996,
63,
1267,
5001,
499,
435,
413,
64,
334,
1589,
3747,
272,
7323,
402,
314,
29484,
680,
819,
6218,
26,
272,
1722,
26,
982,
658,
10458,
64,
365,
440,
737,
5210,
6915,
413,
12,
658,
1943,
63,
1267,
64,
365,
489,
440,
6917,
12,
503,
658,
1943,
63,
2926,
64,
365,
440,
6917,
14,
819,
359,
270,
856,
2189,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
10039,
13,
521,
63,
24766,
4446,
63,
4711,
523,
408,
523,
543,
4156,
14,
354,
63,
2645,
8,
354,
12,
283,
270,
856,
297,
359,
10458,
12,
2787,
63,
1267,
12,
3660,
2787,
63,
2926,
4682,
272,
10166,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
10458,
12,
536,
534,
10458,
358,
272,
10166,
14,
1392,
14,
1045,
63,
4648,
63,
292,
63,
11790,
8,
17,
9,
272,
2787,
63,
1267,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
1943,
63,
1267,
12,
536,
534,
1943,
63,
1267,
358,
272,
2787,
63,
1267,
14,
1392,
14,
479,
63,
1989,
63,
4648,
8,
16,
9,
272,
2787,
63,
2926,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
1943,
63,
2926,
12,
536,
534,
1943,
63,
2926,
358,
272,
2787,
63,
2926,
14,
1392,
14,
479,
63,
1989,
63,
4648,
8,
16,
9,
339,
340,
18160,
63,
1267,
365,
488,
26,
489,
18160,
63,
1267,
275,
485,
287,
11707,
63,
5652,
63,
1618,
63,
5601,
8,
1943,
63,
1267,
9,
272,
587,
26,
489,
18160,
63,
1267,
275,
4156,
14,
3916,
63,
475,
63,
3128,
8,
9996,
63,
1267,
12,
536,
534,
9996,
63,
1267,
358,
339,
2787,
68,
63,
10458,
275,
2215,
63,
1483,
14,
1943,
8,
267,
10166,
12,
2787,
63,
1267,
12,
2787,
63,
2926,
12,
6567,
63,
500,
29,
6226,
63,
500,
9,
339,
327,
22383,
4353,
314,
2787,
68,
10166,
14,
272,
340,
4353,
63,
2324,
365,
440,
488,
26,
489,
4353,
275,
4353,
63,
2324,
8,
1943,
63,
1267,
12,
2152,
29,
1943,
68,
63,
10458,
14,
2271,
9,
489,
2787,
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,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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
] |
kenshay/ImageScript
|
ProgramData/SystemFiles/Python/Lib/site-packages/OpenGL/GL/MESA/resize_buffers.py
|
9
|
1565
|
'''OpenGL extension MESA.resize_buffers
This module customises the behaviour of the
OpenGL.raw.GL.MESA.resize_buffers to provide a more
Python-friendly API
Overview (from the spec)
Mesa is often used as a client library with no integration with
the computer's window system (an X server, for example). And since
Mesa does not have an event loop nor window system callbacks, it
cannot properly respond to window system events. In particular,
Mesa cannot automatically detect when a window has been resized.
Mesa's glViewport command queries the current window size and updates
its internal data structors accordingly. This normally works fine
since most applications call glViewport in responce to window size
changes.
In some situations, however, the application may not call glViewport
when a window size changes but would still like Mesa to adjust to
the new window size. This extension exports a new function to solve
this problem.
The official definition of this extension is available here:
http://www.opengl.org/registry/specs/MESA/resize_buffers.txt
'''
from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.MESA.resize_buffers import *
from OpenGL.raw.GL.MESA.resize_buffers import _EXTENSION_NAME
def glInitResizeBuffersMESA():
'''Return boolean indicating whether this extension is available'''
from OpenGL import extensions
return extensions.hasGLExtension( _EXTENSION_NAME )
### END AUTOGENERATED SECTION
|
gpl-3.0
|
[
2344,
4299,
2226,
3329,
603,
654,
33,
14,
8709,
63,
17389,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
45,
397,
65,
365,
14115,
1202,
465,
282,
1890,
3555,
543,
949,
13150,
543,
199,
198,
1589,
24189,
1159,
4353,
2656,
334,
290,
1323,
1654,
12,
367,
2893,
680,
221,
6061,
3967,
199,
198,
45,
397,
65,
1630,
440,
1172,
376,
1566,
4438,
6590,
4353,
2656,
13484,
12,
652,
199,
198,
11250,
7684,
22722,
370,
4353,
2656,
4474,
14,
221,
1010,
6770,
12,
199,
198,
45,
397,
65,
3913,
5847,
9696,
1380,
282,
4353,
965,
2757,
295,
15308,
14,
8299,
198,
45,
397,
65,
1159,
6482,
2768,
719,
1414,
9212,
314,
1453,
4353,
1568,
436,
7029,
199,
198,
1405,
5007,
666,
620,
85,
13451,
24137,
14,
221,
961,
12252,
5419,
15701,
199,
198,
8585,
4750,
13103,
1240,
6482,
2768,
719,
315,
9163,
301,
370,
4353,
1568,
199,
198,
6627,
14,
8299,
198,
607,
2005,
24325,
12,
13432,
12,
314,
4223,
1443,
440,
1240,
6482,
2768,
719,
199,
198,
6526,
282,
4353,
1568,
4493,
1325,
3955,
5139,
2839,
603,
397,
65,
370,
11311,
370,
199,
198,
1589,
892,
4353,
1568,
14,
221,
961,
3329,
22609,
282,
892,
805,
370,
14241,
199,
198,
3749,
5160,
14,
199,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
22076,
33,
15,
8709,
63,
17389,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
492,
485,
1313,
12,
485,
3528,
24894,
199,
504,
24374,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
492,
627,
199,
504,
24374,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
492,
485,
15498,
63,
2339,
199,
199,
318,
6482,
9346,
24559,
30705,
22076,
33,
837,
272,
1449,
1767,
5046,
9297,
3775,
642,
3329,
365,
2808,
2344,
272,
687,
24374,
492,
5478,
272,
372,
5478,
14,
1989,
12827,
88,
724,
438,
8,
485,
15498,
63,
2339,
776,
421,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4299,
2226,
3329,
603,
654,
33,
14,
8709,
63,
17389,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
45,
397,
65,
365,
14115,
1202,
465,
282,
1890,
3555,
543,
949,
13150,
543,
199,
198,
1589,
24189,
1159,
4353,
2656,
334,
290,
1323,
1654,
12,
367,
2893,
680,
221,
6061,
3967,
199,
198,
45,
397,
65,
1630,
440,
1172,
376,
1566,
4438,
6590,
4353,
2656,
13484,
12,
652,
199,
198,
11250,
7684,
22722,
370,
4353,
2656,
4474,
14,
221,
1010,
6770,
12,
199,
198,
45,
397,
65,
3913,
5847,
9696,
1380,
282,
4353,
965,
2757,
295,
15308,
14,
8299,
198,
45,
397,
65,
1159,
6482,
2768,
719,
1414,
9212,
314,
1453,
4353,
1568,
436,
7029,
199,
198,
1405,
5007,
666,
620,
85,
13451,
24137,
14,
221,
961,
12252,
5419,
15701,
199,
198,
8585,
4750,
13103,
1240,
6482,
2768,
719,
315,
9163,
301,
370,
4353,
1568,
199,
198,
6627,
14,
8299,
198,
607,
2005,
24325,
12,
13432,
12,
314,
4223,
1443,
440,
1240,
6482,
2768,
719,
199,
198,
6526,
282,
4353,
1568,
4493,
1325,
3955,
5139,
2839,
603,
397,
65,
370,
11311,
370,
199,
198,
1589,
892,
4353,
1568,
14,
221,
961,
3329,
22609,
282,
892,
805,
370,
14241,
199,
198,
3749,
5160,
14,
199,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
22076,
33,
15,
8709,
63,
17389,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
492,
485,
1313,
12,
485,
3528,
24894,
199,
504,
24374,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
492,
627,
199,
504,
24374,
14,
1773,
14,
2226,
14,
22076,
33,
14,
8709,
63,
17389,
492,
485,
15498,
63,
2339,
199,
199,
318,
6482,
9346,
24559,
30705,
22076,
33,
837,
272,
1449,
1767,
5046,
9297,
3775,
642,
3329,
365,
2808,
2344,
272,
687,
24374,
492,
5478,
272,
372,
5478,
14,
1989,
12827,
88,
724,
438,
8,
485,
15498,
63,
2339,
776,
421,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
nin042/phantomjs
|
src/qt/qtwebkit/Tools/Scripts/webkitpy/common/system/urlfetcher_mock.py
|
165
|
2053
|
# Copyright (C) 2011 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
def make_fetcher_cls(urls):
"""UrlFetcher factory routine that simulates network access
using a dict of URLs -> contents."""
class MockFetcher(object):
def __init__(self, filesystem):
self._filesystem = filesystem
def fetch(self, url):
return urls[url]
def fetch_into_file(self, url):
f, fn = self._filesystem.open_binary_tempfile('mockfetcher')
f.write(self.fetch(url))
f.close()
return fn
return MockFetcher
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
7760,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
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,
259,
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,
259,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
318,
1852,
63,
26983,
63,
1886,
8,
3603,
304,
272,
408,
6417,
11135,
281,
6434,
12981,
626,
4389,
15409,
2784,
2879,
272,
1808,
282,
1211,
402,
10867,
1035,
4072,
1041,
272,
1021,
4420,
11135,
281,
8,
785,
304,
267,
347,
636,
826,
721,
277,
12,
10036,
304,
288,
291,
423,
11381,
275,
10036,
398,
347,
5267,
8,
277,
12,
1166,
304,
288,
372,
8187,
59,
633,
61,
398,
347,
5267,
63,
9924,
63,
493,
8,
277,
12,
1166,
304,
288,
289,
12,
4325,
275,
291,
423,
11381,
14,
1490,
63,
3008,
63,
17336,
360,
1805,
26983,
358,
288,
289,
14,
952,
8,
277,
14,
3535,
8,
633,
430,
288,
289,
14,
1600,
342,
288,
372,
4325,
339,
372,
4420,
11135,
281,
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
] |
[
1898,
334,
35,
9,
7760,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
259,
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,
259,
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,
259,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
318,
1852,
63,
26983,
63,
1886,
8,
3603,
304,
272,
408,
6417,
11135,
281,
6434,
12981,
626,
4389,
15409,
2784,
2879,
272,
1808,
282,
1211,
402,
10867,
1035,
4072,
1041,
272,
1021,
4420,
11135,
281,
8,
785,
304,
267,
347,
636,
826,
721,
277,
12,
10036,
304,
288,
291,
423,
11381,
275,
10036,
398,
347,
5267,
8,
277,
12,
1166,
304,
288,
372,
8187,
59,
633,
61,
398,
347,
5267,
63,
9924,
63,
493,
8,
277,
12,
1166,
304,
288,
289,
12,
4325,
275,
291,
423,
11381,
14,
1490,
63,
3008,
63,
17336,
360,
1805,
26983,
358,
288,
289,
14,
952,
8,
277,
14,
3535,
8,
633,
430,
288,
289,
14,
1600,
342,
288,
372,
4325,
339,
372,
4420,
11135,
281,
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,
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
] |
pmarques/ansible
|
test/integration/targets/dict_transformations/library/convert_snake_case.py
|
29
|
1432
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# 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
DOCUMENTATION = '''
---
module: convert_snake_case
short_description: test converting data to snake_case
description: test converting data to snake_case
options:
data:
description: Data to modify
type: dict
required: True
reversible:
description:
- Make the snake_case conversion in a way that can be converted back to the original value
- For example, convert IAMUser to i_a_m_user instead of iam_user
default: False
ignore_list:
description: list of top level keys that should not have their contents converted
type: list
default: []
'''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
def main():
module = AnsibleModule(
argument_spec=dict(
data=dict(type='dict', required=True),
reversible=dict(type='bool', default=False),
ignore_list=dict(type='list', default=[]),
),
)
result = camel_dict_to_snake_dict(
module.params['data'],
module.params['reversible'],
module.params['ignore_list']
)
module.exit_json(data=result)
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,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
3957,
63,
21415,
63,
2546,
199,
3612,
63,
1802,
26,
511,
13806,
666,
370,
6895,
1728,
63,
2546,
199,
1802,
26,
511,
13806,
666,
370,
6895,
1728,
63,
2546,
199,
1419,
26,
523,
666,
26,
272,
1369,
26,
3918,
370,
2811,
272,
730,
26,
1211,
272,
1415,
26,
715,
523,
29465,
1164,
26,
272,
1369,
26,
489,
446,
4155,
314,
6895,
1728,
63,
2546,
8603,
315,
282,
4340,
626,
883,
506,
6702,
1771,
370,
314,
3379,
574,
489,
446,
2104,
2893,
12,
3957,
28155,
1899,
370,
284,
63,
65,
63,
77,
63,
751,
3140,
402,
22361,
63,
751,
272,
849,
26,
756,
523,
3686,
63,
513,
26,
272,
1369,
26,
769,
402,
2746,
2166,
2883,
626,
1077,
440,
1172,
3932,
4072,
6702,
272,
730,
26,
769,
272,
849,
26,
942,
199,
2344,
421,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
2330,
14,
807,
63,
1515,
17308,
492,
31129,
63,
807,
63,
475,
63,
21415,
63,
807,
421,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
807,
8,
288,
666,
29,
807,
8,
466,
534,
807,
297,
1415,
29,
549,
395,
288,
29465,
1164,
29,
807,
8,
466,
534,
2245,
297,
849,
29,
797,
395,
288,
3686,
63,
513,
29,
807,
8,
466,
534,
513,
297,
849,
1524,
2522,
267,
2318,
272,
776,
339,
754,
275,
31129,
63,
807,
63,
475,
63,
21415,
63,
807,
8,
267,
859,
14,
1162,
459,
576,
995,
267,
859,
14,
1162,
459,
264,
422,
1164,
995,
267,
859,
14,
1162,
459,
4247,
63,
513,
418,
272,
776,
339,
859,
14,
2224,
63,
1001,
8,
576,
29,
1099,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
3957,
63,
21415,
63,
2546,
199,
3612,
63,
1802,
26,
511,
13806,
666,
370,
6895,
1728,
63,
2546,
199,
1802,
26,
511,
13806,
666,
370,
6895,
1728,
63,
2546,
199,
1419,
26,
523,
666,
26,
272,
1369,
26,
3918,
370,
2811,
272,
730,
26,
1211,
272,
1415,
26,
715,
523,
29465,
1164,
26,
272,
1369,
26,
489,
446,
4155,
314,
6895,
1728,
63,
2546,
8603,
315,
282,
4340,
626,
883,
506,
6702,
1771,
370,
314,
3379,
574,
489,
446,
2104,
2893,
12,
3957,
28155,
1899,
370,
284,
63,
65,
63,
77,
63,
751,
3140,
402,
22361,
63,
751,
272,
849,
26,
756,
523,
3686,
63,
513,
26,
272,
1369,
26,
769,
402,
2746,
2166,
2883,
626,
1077,
440,
1172,
3932,
4072,
6702,
272,
730,
26,
769,
272,
849,
26,
942,
199,
2344,
421,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
2330,
14,
807,
63,
1515,
17308,
492,
31129,
63,
807,
63,
475,
63,
21415,
63,
807,
421,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
807,
8,
288,
666,
29,
807,
8,
466,
534,
807,
297,
1415,
29,
549,
395,
288,
29465,
1164,
29,
807,
8,
466,
534,
2245,
297,
849,
29,
797,
395,
288,
3686,
63,
513,
29,
807,
8,
466,
534,
513,
297,
849,
1524,
2522,
267,
2318,
272,
776,
339,
754,
275,
31129,
63,
807,
63,
475,
63,
21415,
63,
807,
8,
267,
859,
14,
1162,
459,
576,
995,
267,
859,
14,
1162,
459,
264,
422,
1164,
995,
267,
859,
14,
1162,
459,
4247,
63,
513,
418,
272,
776,
339,
859,
14,
2224,
63,
1001,
8,
576,
29,
1099,
9,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
stephen144/odoo
|
addons/account_budget/wizard/account_budget_analytic.py
|
47
|
1099
|
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from openerp.osv import fields, osv
class account_budget_analytic(osv.osv_memory):
_name = 'account.budget.analytic'
_description = 'Account Budget report for analytic account'
_columns = {
'date_from': fields.date('Start of period', required=True),
'date_to': fields.date('End of period', required=True),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-01-01'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
}
def check_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
data = self.read(cr, uid, ids, context=context)[0]
datas = {
'ids': context.get('active_ids', []),
'model': 'account.analytic.account',
'form': data
}
datas['form']['ids'] = datas['ids']
return self.pool['report'].get_action(cr, uid, [], 'account_budget.report_analyticaccountbudget', data=datas, context=context)
|
agpl-3.0
|
[
259,
327,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
14320,
402,
28935,
14,
1666,
5113,
570,
367,
2615,
4248,
436,
32572,
2436,
14,
199,
199,
646,
900,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
421,
199,
533,
2933,
63,
16501,
63,
9782,
8,
4795,
14,
4795,
63,
4844,
304,
339,
485,
354,
275,
283,
2048,
14,
16501,
14,
9782,
7,
272,
485,
1802,
275,
283,
6009,
699,
1181,
362,
3622,
367,
20705,
2933,
7,
272,
485,
3406,
275,
469,
267,
283,
602,
63,
504,
356,
1504,
14,
602,
360,
3162,
402,
6247,
297,
1415,
29,
549,
395,
267,
283,
602,
63,
475,
356,
1504,
14,
602,
360,
3005,
402,
6247,
297,
1415,
29,
549,
395,
272,
789,
272,
485,
4322,
275,
469,
267,
283,
602,
63,
504,
356,
2400,
627,
65,
26,
900,
14,
6205,
3508,
57,
13,
614,
13,
614,
659,
267,
283,
602,
63,
475,
356,
2400,
627,
65,
26,
900,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
659,
272,
789,
339,
347,
1104,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
666,
275,
291,
14,
739,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
2788,
16,
61,
267,
15012,
275,
469,
288,
283,
1580,
356,
1067,
14,
362,
360,
2682,
63,
1580,
297,
14431,
288,
283,
1238,
356,
283,
2048,
14,
9782,
14,
2048,
297,
288,
283,
964,
356,
666,
267,
789,
267,
15012,
459,
964,
2545,
1580,
418,
275,
15012,
459,
1580,
418,
267,
372,
291,
14,
2293,
459,
3070,
2278,
362,
63,
1287,
8,
1556,
12,
1747,
12,
990,
283,
2048,
63,
16501,
14,
3070,
63,
9782,
2048,
16501,
297,
666,
29,
11563,
12,
1067,
29,
1100,
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
] |
[
327,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
14320,
402,
28935,
14,
1666,
5113,
570,
367,
2615,
4248,
436,
32572,
2436,
14,
199,
199,
646,
900,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
421,
199,
533,
2933,
63,
16501,
63,
9782,
8,
4795,
14,
4795,
63,
4844,
304,
339,
485,
354,
275,
283,
2048,
14,
16501,
14,
9782,
7,
272,
485,
1802,
275,
283,
6009,
699,
1181,
362,
3622,
367,
20705,
2933,
7,
272,
485,
3406,
275,
469,
267,
283,
602,
63,
504,
356,
1504,
14,
602,
360,
3162,
402,
6247,
297,
1415,
29,
549,
395,
267,
283,
602,
63,
475,
356,
1504,
14,
602,
360,
3005,
402,
6247,
297,
1415,
29,
549,
395,
272,
789,
272,
485,
4322,
275,
469,
267,
283,
602,
63,
504,
356,
2400,
627,
65,
26,
900,
14,
6205,
3508,
57,
13,
614,
13,
614,
659,
267,
283,
602,
63,
475,
356,
2400,
627,
65,
26,
900,
14,
6205,
3508,
57,
3295,
77,
3295,
68,
659,
272,
789,
339,
347,
1104,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
666,
275,
291,
14,
739,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
2788,
16,
61,
267,
15012,
275,
469,
288,
283,
1580,
356,
1067,
14,
362,
360,
2682,
63,
1580,
297,
14431,
288,
283,
1238,
356,
283,
2048,
14,
9782,
14,
2048,
297,
288,
283,
964,
356,
666,
267,
789,
267,
15012,
459,
964,
2545,
1580,
418,
275,
15012,
459,
1580,
418,
267,
372,
291,
14,
2293,
459,
3070,
2278,
362,
63,
1287,
8,
1556,
12,
1747,
12,
990,
283,
2048,
63,
16501,
14,
3070,
63,
9782,
2048,
16501,
297,
666,
29,
11563,
12,
1067,
29,
1100,
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,
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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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
] |
Adel-Magebinary/odoo
|
addons/crm_claim/report/__init__.py
|
446
|
1080
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import crm_claim_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
646,
2467,
77,
63,
17904,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
420,
199,
3,
199,
4605,
199,
199,
646,
2467,
77,
63,
17904,
63,
3070,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
jelugbo/ddi
|
common/djangoapps/user_api/tests/test_profile_api.py
|
8
|
4688
|
# -*- coding: utf-8 -*-
""" Tests for the profile API. """
from django.test import TestCase
import ddt
from nose.tools import raises
from dateutil.parser import parse as parse_datetime
from user_api.api import account as account_api
from user_api.api import profile as profile_api
from user_api.models import UserProfile
@ddt.ddt
class ProfileApiTest(TestCase):
USERNAME = u'frank-underwood'
PASSWORD = u'ṕáśśẃőŕd'
EMAIL = u'frank+underwood@example.com'
def test_create_profile(self):
# Create a new account, which should have an empty profile by default.
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
# Retrieve the profile, expecting default values
profile = profile_api.profile_info(username=self.USERNAME)
self.assertEqual(profile, {
'username': self.USERNAME,
'email': self.EMAIL,
'full_name': u'',
})
def test_update_full_name(self):
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
profile_api.update_profile(self.USERNAME, full_name=u'ȻħȺɍłɇs')
profile = profile_api.profile_info(self.USERNAME)
self.assertEqual(profile['full_name'], u'ȻħȺɍłɇs')
@raises(profile_api.ProfileInvalidField)
@ddt.data('', 'a' * profile_api.FULL_NAME_MAX_LENGTH + 'a')
def test_update_full_name_invalid(self, invalid_name):
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
profile_api.update_profile(self.USERNAME, full_name=invalid_name)
@raises(profile_api.ProfileUserNotFound)
def test_update_profile_no_user(self):
profile_api.update_profile(self.USERNAME, full_name='test')
def test_retrieve_profile_no_user(self):
profile = profile_api.profile_info('does not exist')
self.assertIs(profile, None)
def test_record_name_change_history(self):
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
# Change the name once
# Since the original name was an empty string, expect that the list
# of old names is empty
profile_api.update_profile(self.USERNAME, full_name='new name')
meta = UserProfile.objects.get(user__username=self.USERNAME).get_meta()
self.assertEqual(meta, {})
# Change the name again and expect the new name is stored in the history
profile_api.update_profile(self.USERNAME, full_name='another new name')
meta = UserProfile.objects.get(user__username=self.USERNAME).get_meta()
self.assertEqual(len(meta['old_names']), 1)
name, rationale, timestamp = meta['old_names'][0]
self.assertEqual(name, 'new name')
self.assertEqual(rationale, u'')
self._assert_is_datetime(timestamp)
# Change the name a third time and expect both names are stored in the history
profile_api.update_profile(self.USERNAME, full_name='yet another new name')
meta = UserProfile.objects.get(user__username=self.USERNAME).get_meta()
self.assertEqual(len(meta['old_names']), 2)
name, rationale, timestamp = meta['old_names'][1]
self.assertEqual(name, 'another new name')
self.assertEqual(rationale, u'')
self._assert_is_datetime(timestamp)
def test_update_and_retrieve_preference_info(self):
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
profile_api.update_preferences(self.USERNAME, preference_key='preference_value')
preferences = profile_api.preference_info(self.USERNAME)
self.assertEqual(preferences['preference_key'], 'preference_value')
@raises(profile_api.ProfileUserNotFound)
def test_retrieve_and_update_preference_info_no_user(self):
preferences = profile_api.preference_info(self.USERNAME)
self.assertEqual(preferences, {})
profile_api.update_preferences(self.USERNAME, preference_key='preference_value')
def test_update_and_retrieve_preference_info_unicode(self):
account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
profile_api.update_preferences(self.USERNAME, **{u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ': u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd'})
preferences = profile_api.preference_info(self.USERNAME)
self.assertEqual(preferences[u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ'], u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd')
def _assert_is_datetime(self, timestamp):
if not timestamp:
return False
try:
parse_datetime(timestamp)
except ValueError:
return False
else:
return True
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
6496,
367,
314,
4690,
3261,
14,
408,
199,
199,
504,
1639,
14,
396,
492,
7640,
199,
646,
366,
3583,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
22208,
14,
2087,
492,
2198,
465,
2198,
63,
2083,
199,
199,
504,
922,
63,
1246,
14,
1246,
492,
2933,
465,
2933,
63,
1246,
199,
504,
922,
63,
1246,
14,
1246,
492,
4690,
465,
4690,
63,
1246,
199,
504,
922,
63,
1246,
14,
992,
492,
19037,
421,
199,
32,
11138,
14,
11138,
199,
533,
14386,
7394,
774,
8,
1746,
304,
339,
13044,
2339,
275,
399,
7,
70,
4648,
13,
7138,
22736,
7,
272,
21705,
5172,
275,
399,
7,
158,
118,
244,
11302,
130,
250,
130,
250,
158,
119,
226,
130,
240,
130,
244,
68,
7,
272,
32320,
275,
399,
7,
70,
4648,
11,
7138,
22736,
32,
2694,
14,
957,
7,
339,
347,
511,
63,
981,
63,
2913,
8,
277,
304,
267,
327,
2790,
282,
892,
2933,
12,
1314,
1077,
1172,
376,
2701,
4690,
701,
849,
14,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
327,
13939,
314,
4690,
12,
21055,
849,
1338,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
8,
2473,
29,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
2913,
12,
469,
288,
283,
2473,
356,
291,
14,
11958,
12,
288,
283,
2123,
356,
291,
14,
10089,
12,
288,
283,
2861,
63,
354,
356,
399,
6448,
267,
3828,
339,
347,
511,
63,
873,
63,
2861,
63,
354,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
29,
85,
7,
133,
120,
129,
101,
133,
119,
134,
236,
130,
225,
134,
230,
83,
358,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
8,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
2913,
459,
2861,
63,
354,
995,
399,
7,
133,
120,
129,
101,
133,
119,
134,
236,
130,
225,
134,
230,
83,
358,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
3364,
792,
9,
272,
768,
11138,
14,
576,
8594,
283,
65,
7,
627,
4690,
63,
1246,
14,
14742,
63,
2339,
63,
4283,
63,
9127,
435,
283,
65,
358,
272,
347,
511,
63,
873,
63,
2861,
63,
354,
63,
3197,
8,
277,
12,
3866,
63,
354,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
29,
3197,
63,
354,
9,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
1899,
4667,
9,
272,
347,
511,
63,
873,
63,
2913,
63,
889,
63,
751,
8,
277,
304,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
396,
358,
339,
347,
511,
63,
14270,
63,
2913,
63,
889,
63,
751,
8,
277,
304,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
360,
9105,
440,
2187,
358,
267,
291,
14,
3436,
8,
2913,
12,
488,
9,
339,
347,
511,
63,
3059,
63,
354,
63,
1461,
63,
5570,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
327,
7743,
314,
536,
5403,
267,
327,
9336,
314,
3379,
536,
1990,
376,
2701,
1059,
12,
4282,
626,
314,
769,
267,
327,
402,
2269,
1561,
365,
2701,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
1222,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
267,
291,
14,
629,
8,
2024,
12,
5009,
398,
327,
7743,
314,
536,
4020,
436,
4282,
314,
892,
536,
365,
5489,
315,
314,
7994,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
13565,
892,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
398,
291,
14,
629,
8,
552,
8,
2024,
459,
1753,
63,
1247,
3815,
413,
9,
267,
536,
12,
660,
296,
1895,
12,
4913,
275,
3404,
459,
1753,
63,
1247,
3488,
16,
61,
267,
291,
14,
629,
8,
354,
12,
283,
1222,
536,
358,
267,
291,
14,
629,
8,
1754,
1895,
12,
399,
17483,
267,
291,
423,
479,
63,
374,
63,
2083,
8,
3954,
9,
398,
327,
7743,
314,
536,
282,
10919,
900,
436,
4282,
3865,
1561,
787,
5489,
315,
314,
7994,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
28064,
4573,
892,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
398,
291,
14,
629,
8,
552,
8,
2024,
459,
1753,
63,
1247,
3815,
499,
9,
267,
536,
12,
660,
296,
1895,
12,
4913,
275,
3404,
459,
1753,
63,
1247,
3488,
17,
61,
267,
291,
14,
629,
8,
354,
12,
283,
13565,
892,
536,
358,
267,
291,
14,
629,
8,
1754,
1895,
12,
399,
17483,
267,
291,
423,
479,
63,
374,
63,
2083,
8,
3954,
9,
339,
347,
511,
63,
873,
63,
460,
63,
14270,
63,
14994,
63,
815,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
4690,
63,
1246,
14,
873,
63,
18063,
8,
277,
14,
11958,
12,
16705,
63,
498,
534,
14994,
63,
585,
358,
398,
23453,
275,
4690,
63,
1246,
14,
14994,
63,
815,
8,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
18063,
459,
14994,
63,
498,
995,
283,
14994,
63,
585,
358,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
1899,
4667,
9,
272,
347,
511,
63,
14270,
63,
460,
63,
873,
63,
14994,
63,
815,
63,
889,
63,
751,
8,
277,
304,
267,
23453
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
6496,
367,
314,
4690,
3261,
14,
408,
199,
199,
504,
1639,
14,
396,
492,
7640,
199,
646,
366,
3583,
199,
504,
11354,
14,
2537,
492,
6534,
199,
504,
22208,
14,
2087,
492,
2198,
465,
2198,
63,
2083,
199,
199,
504,
922,
63,
1246,
14,
1246,
492,
2933,
465,
2933,
63,
1246,
199,
504,
922,
63,
1246,
14,
1246,
492,
4690,
465,
4690,
63,
1246,
199,
504,
922,
63,
1246,
14,
992,
492,
19037,
421,
199,
32,
11138,
14,
11138,
199,
533,
14386,
7394,
774,
8,
1746,
304,
339,
13044,
2339,
275,
399,
7,
70,
4648,
13,
7138,
22736,
7,
272,
21705,
5172,
275,
399,
7,
158,
118,
244,
11302,
130,
250,
130,
250,
158,
119,
226,
130,
240,
130,
244,
68,
7,
272,
32320,
275,
399,
7,
70,
4648,
11,
7138,
22736,
32,
2694,
14,
957,
7,
339,
347,
511,
63,
981,
63,
2913,
8,
277,
304,
267,
327,
2790,
282,
892,
2933,
12,
1314,
1077,
1172,
376,
2701,
4690,
701,
849,
14,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
327,
13939,
314,
4690,
12,
21055,
849,
1338,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
8,
2473,
29,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
2913,
12,
469,
288,
283,
2473,
356,
291,
14,
11958,
12,
288,
283,
2123,
356,
291,
14,
10089,
12,
288,
283,
2861,
63,
354,
356,
399,
6448,
267,
3828,
339,
347,
511,
63,
873,
63,
2861,
63,
354,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
29,
85,
7,
133,
120,
129,
101,
133,
119,
134,
236,
130,
225,
134,
230,
83,
358,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
8,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
2913,
459,
2861,
63,
354,
995,
399,
7,
133,
120,
129,
101,
133,
119,
134,
236,
130,
225,
134,
230,
83,
358,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
3364,
792,
9,
272,
768,
11138,
14,
576,
8594,
283,
65,
7,
627,
4690,
63,
1246,
14,
14742,
63,
2339,
63,
4283,
63,
9127,
435,
283,
65,
358,
272,
347,
511,
63,
873,
63,
2861,
63,
354,
63,
3197,
8,
277,
12,
3866,
63,
354,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
29,
3197,
63,
354,
9,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
1899,
4667,
9,
272,
347,
511,
63,
873,
63,
2913,
63,
889,
63,
751,
8,
277,
304,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
396,
358,
339,
347,
511,
63,
14270,
63,
2913,
63,
889,
63,
751,
8,
277,
304,
267,
4690,
275,
4690,
63,
1246,
14,
2913,
63,
815,
360,
9105,
440,
2187,
358,
267,
291,
14,
3436,
8,
2913,
12,
488,
9,
339,
347,
511,
63,
3059,
63,
354,
63,
1461,
63,
5570,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
327,
7743,
314,
536,
5403,
267,
327,
9336,
314,
3379,
536,
1990,
376,
2701,
1059,
12,
4282,
626,
314,
769,
267,
327,
402,
2269,
1561,
365,
2701,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
1222,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
267,
291,
14,
629,
8,
2024,
12,
5009,
398,
327,
7743,
314,
536,
4020,
436,
4282,
314,
892,
536,
365,
5489,
315,
314,
7994,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
13565,
892,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
398,
291,
14,
629,
8,
552,
8,
2024,
459,
1753,
63,
1247,
3815,
413,
9,
267,
536,
12,
660,
296,
1895,
12,
4913,
275,
3404,
459,
1753,
63,
1247,
3488,
16,
61,
267,
291,
14,
629,
8,
354,
12,
283,
1222,
536,
358,
267,
291,
14,
629,
8,
1754,
1895,
12,
399,
17483,
267,
291,
423,
479,
63,
374,
63,
2083,
8,
3954,
9,
398,
327,
7743,
314,
536,
282,
10919,
900,
436,
4282,
3865,
1561,
787,
5489,
315,
314,
7994,
267,
4690,
63,
1246,
14,
873,
63,
2913,
8,
277,
14,
11958,
12,
2615,
63,
354,
534,
28064,
4573,
892,
536,
358,
267,
3404,
275,
19037,
14,
1462,
14,
362,
8,
751,
363,
2473,
29,
277,
14,
11958,
680,
362,
63,
2024,
342,
398,
291,
14,
629,
8,
552,
8,
2024,
459,
1753,
63,
1247,
3815,
499,
9,
267,
536,
12,
660,
296,
1895,
12,
4913,
275,
3404,
459,
1753,
63,
1247,
3488,
17,
61,
267,
291,
14,
629,
8,
354,
12,
283,
13565,
892,
536,
358,
267,
291,
14,
629,
8,
1754,
1895,
12,
399,
17483,
267,
291,
423,
479,
63,
374,
63,
2083,
8,
3954,
9,
339,
347,
511,
63,
873,
63,
460,
63,
14270,
63,
14994,
63,
815,
8,
277,
304,
267,
2933,
63,
1246,
14,
981,
63,
2048,
8,
277,
14,
11958,
12,
291,
14,
9032,
12,
291,
14,
10089,
9,
398,
4690,
63,
1246,
14,
873,
63,
18063,
8,
277,
14,
11958,
12,
16705,
63,
498,
534,
14994,
63,
585,
358,
398,
23453,
275,
4690,
63,
1246,
14,
14994,
63,
815,
8,
277,
14,
11958,
9,
267,
291,
14,
629,
8,
18063,
459,
14994,
63,
498,
995,
283,
14994,
63,
585,
358,
339,
768,
3536,
8,
2913,
63,
1246,
14,
5736,
1899,
4667,
9,
272,
347,
511,
63,
14270,
63,
460,
63,
873,
63,
14994,
63,
815,
63,
889,
63,
751,
8,
277,
304,
267,
23453,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1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|
__unported__/account_statement_cancel_line/wizard/cancel_statement_line.py
|
36
|
2098
|
# -*- coding: utf-8 -*-
###############################################################################
# #
# Author: Leonardo Pistone
# Copyright 2014 Camptocamp SA
# #
# 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/>. #
# #
###############################################################################
"""Wizard to Cancel a Statement Line."""
from openerp.osv import orm
class wizard_cancel_statement_line(orm.TransientModel):
"""Wizard to Cancel a Statement Line."""
_name = "wizard.cancel.statement.line"
_description = "Cancel Statement Line"
_columns = {
}
def unreconcile(self, cr, uid, ids, context=None):
"""Proceed and cancel the statement line, return Action.
This will delete the move.line and the reconciliation.
"""
return self.pool['account.bank.statement.line'].cancel(
cr,
uid,
context['active_ids'],
context=context
)
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
11490,
199,
3,
6208,
3777,
327,
199,
3,
257,
6529,
26,
7005,
265,
1005,
79,
510,
631,
368,
199,
3,
257,
1898,
6927,
24569,
475,
20290,
13950,
199,
3,
6208,
3777,
327,
199,
3,
257,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
420,
327,
199,
3,
257,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3322,
327,
199,
3,
257,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
263,
327,
199,
3,
257,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
13235,
327,
199,
3,
6208,
3777,
327,
199,
3,
257,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
3698,
327,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3322,
327,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
3777,
327,
199,
3,
257,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
9668,
327,
199,
3,
6208,
3777,
327,
199,
3,
257,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
221,
327,
199,
3,
257,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
258,
327,
199,
3,
6208,
3777,
327,
199,
11490,
199,
624,
20120,
370,
28374,
282,
29697,
7030,
1041,
199,
199,
504,
5166,
14,
4795,
492,
9813,
421,
199,
533,
12262,
63,
6406,
63,
6242,
63,
604,
8,
1025,
14,
14612,
14928,
1685,
304,
339,
408,
20120,
370,
28374,
282,
29697,
7030,
1041,
339,
485,
354,
275,
298,
9819,
14,
6406,
14,
6242,
14,
604,
2,
272,
485,
1802,
275,
298,
9083,
29697,
7030,
2,
272,
485,
3406,
275,
469,
272,
789,
339,
347,
625,
18403,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
919,
15648,
436,
9311,
314,
5164,
1004,
12,
372,
10033,
14,
398,
961,
911,
3145,
314,
4057,
14,
604,
436,
314,
24711,
29685,
14,
398,
408,
267,
372,
291,
14,
2293,
459,
2048,
14,
9860,
14,
6242,
14,
604,
2278,
6406,
8,
288,
2467,
12,
288,
1747,
12,
288,
1067,
459,
2682,
63,
1580,
995,
288,
1067,
29,
1100,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
11490,
199,
3,
6208,
3777,
327,
199,
3,
257,
6529,
26,
7005,
265,
1005,
79,
510,
631,
368,
199,
3,
257,
1898,
6927,
24569,
475,
20290,
13950,
199,
3,
6208,
3777,
327,
199,
3,
257,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
420,
327,
199,
3,
257,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3322,
327,
199,
3,
257,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
263,
327,
199,
3,
257,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
13235,
327,
199,
3,
6208,
3777,
327,
199,
3,
257,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
3698,
327,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3322,
327,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
3777,
327,
199,
3,
257,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
9668,
327,
199,
3,
6208,
3777,
327,
199,
3,
257,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
221,
327,
199,
3,
257,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
258,
327,
199,
3,
6208,
3777,
327,
199,
11490,
199,
624,
20120,
370,
28374,
282,
29697,
7030,
1041,
199,
199,
504,
5166,
14,
4795,
492,
9813,
421,
199,
533,
12262,
63,
6406,
63,
6242,
63,
604,
8,
1025,
14,
14612,
14928,
1685,
304,
339,
408,
20120,
370,
28374,
282,
29697,
7030,
1041,
339,
485,
354,
275,
298,
9819,
14,
6406,
14,
6242,
14,
604,
2,
272,
485,
1802,
275,
298,
9083,
29697,
7030,
2,
272,
485,
3406,
275,
469,
272,
789,
339,
347,
625,
18403,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
919,
15648,
436,
9311,
314,
5164,
1004,
12,
372,
10033,
14,
398,
961,
911,
3145,
314,
4057,
14,
604,
436,
314,
24711,
29685,
14,
398,
408,
267,
372,
291,
14,
2293,
459,
2048,
14,
9860,
14,
6242,
14,
604,
2278,
6406,
8,
288,
2467,
12,
288,
1747,
12,
288,
1067,
459,
2682,
63,
1580,
995,
288,
1067,
29,
1100,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
anetasie/sherpa
|
sherpa/image/pyds9_backend.py
|
3
|
5786
|
#
# Copyright (C) 2007 Smithsonian Astrophysical Observatory
#
#
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from itertools import izip
import numpy
import time
import ds9
from sherpa.utils import get_keyword_defaults, SherpaFloat
from sherpa.utils.err import DS9Err
_target = 'sherpa'
def _get_win():
return ds9.ds9(_target)
def doOpen():
_get_win()
def isOpen():
targets = ds9.ds9_targets()
if targets is None:
return False
if type(targets) in (list,):
for target in targets:
if _target in target:
return True
return False
def close():
if isOpen():
imager = _get_win()
imager.set("quit")
def delete_frames():
if not isOpen():
raise DS9Err('open')
imager = _get_win()
try:
imager.set("frame delete all")
return imager.set("frame new")
except:
raise DS9Err('delframe')
def get_region(coord):
if not isOpen():
raise DS9Err('open')
imager = _get_win()
try:
regionstr = "regions -format saoimage -strip yes"
if (coord != ''):
if (coord != 'image'):
regionstr = "regions -format ciao -strip yes -system " + str(coord)
else:
regionstr = "regions -format saoimage -strip yes -system image"
reg = imager.get(regionstr)
reg = reg.replace(';','')
return reg
except:
raise DS9Err('retreg')
def image(arr, newframe=False, tile=False):
if not isOpen():
doOpen()
imager = _get_win()
if newframe is True:
try:
imager.set("frame new")
imager.set("frame last")
except:
raise DS9Err('newframe')
try:
if tile is True:
imager.set("tile yes")
else:
imager.set("tile no")
except:
raise DS9Err('settile')
time.sleep(1)
try:
# pyds9 expects shape[::-1] compared to DS9.py
# therefore transpose the image before sending
arr = numpy.asarray(arr, dtype=SherpaFloat)
imager.set_np2arr(arr.T)
except:
raise # DS9Err('noimage')
def _set_wcs(keys):
eqpos, sky, name = keys
phys = ''
wcs = "OBJECT = '%s'\n" % name
if eqpos is not None:
wcrpix = eqpos.crpix
wcrval = eqpos.crval
wcdelt = eqpos.cdelt
if sky is not None:
pcrpix = sky.crpix
pcrval = sky.crval
pcdelt = sky.cdelt
# join together all strings with a '\n' between each
phys = '\n'.join(["WCSNAMEP = 'PHYSICAL'",
"CTYPE1P = 'x '",
'CRVAL1P = %.14E' % pcrval[0],
'CRPIX1P = %.14E' % pcrpix[0],
'CDELT1P = %.14E' % pcdelt[0],
"CTYPE2P = 'y '",
'CRVAL2P = %.14E' % pcrval[1],
'CRPIX2P = %.14E' % pcrpix[1],
'CDELT2P = %.14E' % pcdelt[1]])
if eqpos is not None:
wcdelt = wcdelt * pcdelt
wcrpix = ((wcrpix - pcrval) /
pcdelt + pcrpix )
if eqpos is not None:
# join together all strings with a '\n' between each
wcs = wcs + '\n'.join(["RADECSYS = 'ICRS '",
"CTYPE1 = 'RA---TAN'",
'CRVAL1 = %.14E' % wcrval[0],
'CRPIX1 = %.14E' % wcrpix[0],
'CDELT1 = %.14E' % wcdelt[0],
"CTYPE2 = 'DEC--TAN'",
'CRVAL2 = %.14E' % wcrval[1],
'CRPIX2 = %.14E' % wcrpix[1],
'CDELT2 = %.14E' % wcdelt[1]])
# join the wcs and physical with '\n' between them and at the end
return ('\n'.join([wcs,phys]) + '\n')
def wcs(keys):
if not isOpen():
raise DS9Err('open')
imager = _get_win()
info = _set_wcs( keys )
try:
# use stdin to pass the WCS info
imager.set('wcs replace', info)
except:
raise DS9Err('setwcs')
def open():
doOpen()
def set_region(reg, coord):
if not isOpen():
raise DS9Err('open')
imager = _get_win()
try:
if (access(reg, R_OK) is True):
imager.set("regions load " + "'" + reg + "'")
else:
# Assume region string has to be in CIAO format
regions = reg.split(";")
for region in regions:
if (region != ''):
if (coord != ''):
imager.set("regions", str(coord) + ";" + region)
else:
imager.set("regions", region)
except:
raise DS9Err('badreg', str(reg))
def xpaget(arg):
if not isOpen():
raise DS9Err('open')
imager = _get_win()
return imager.get(arg)
def xpaset(arg, data=None):
if not isOpen():
raise DS9Err('open')
imager = _get_win()
return imager.set(arg, data)
|
gpl-3.0
|
[
3,
221,
199,
3,
221,
1898,
334,
35,
9,
10219,
221,
25924,
834,
5653,
437,
24627,
15020,
17985,
7297,
8658,
199,
3,
199,
3,
199,
3,
221,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
221,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
221,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
221,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
221,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
221,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
199,
3,
221,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
221,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
199,
504,
7975,
492,
28697,
199,
646,
2680,
199,
646,
900,
199,
646,
6364,
25,
199,
199,
504,
1033,
281,
387,
14,
1208,
492,
664,
63,
6691,
63,
4322,
12,
428,
2523,
387,
5136,
199,
504,
1033,
281,
387,
14,
1208,
14,
1508,
492,
577,
51,
25,
5432,
199,
199,
63,
1375,
275,
283,
609,
281,
387,
7,
199,
199,
318,
485,
362,
63,
2676,
837,
272,
372,
6364,
25,
14,
795,
25,
1547,
1375,
9,
258,
199,
199,
318,
886,
4299,
837,
272,
485,
362,
63,
2676,
342,
199,
199,
318,
365,
4299,
837,
339,
4545,
275,
6364,
25,
14,
795,
25,
63,
4684,
342,
272,
340,
4545,
365,
488,
26,
267,
372,
756,
339,
340,
730,
8,
4684,
9,
315,
334,
513,
16095,
267,
367,
1347,
315,
4545,
26,
288,
340,
485,
1375,
315,
1347,
26,
355,
372,
715,
339,
372,
756,
199,
199,
318,
4002,
837,
272,
340,
365,
4299,
837,
267,
18884,
836,
275,
485,
362,
63,
2676,
342,
267,
18884,
836,
14,
409,
480,
10589,
531,
199,
199,
318,
3145,
63,
8444,
837,
272,
340,
440,
365,
4299,
837,
267,
746,
577,
51,
25,
5432,
360,
1490,
358,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
862,
26,
267,
18884,
836,
14,
409,
480,
1943,
3145,
1006,
531,
267,
372,
18884,
836,
14,
409,
480,
1943,
892,
531,
272,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
271,
276,
1186,
358,
199,
199,
318,
664,
63,
4551,
8,
7988,
304,
272,
340,
440,
365,
4299,
837,
267,
746,
577,
51,
25,
5432,
360,
1490,
358,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
862,
26,
267,
4897,
495,
275,
298,
11963,
446,
908,
2937,
79,
1569,
446,
1913,
9456,
2,
267,
340,
334,
7988,
1137,
21019,
288,
340,
334,
7988,
1137,
283,
1569,
735,
355,
4897,
495,
275,
298,
11963,
446,
908,
286,
18939,
446,
1913,
9456,
446,
2253,
298,
435,
620,
8,
7988,
9,
288,
587,
26,
355,
4897,
495,
275,
298,
11963,
446,
908,
2937,
79,
1569,
446,
1913,
9456,
446,
2253,
1834,
2,
398,
1295,
275,
18884,
836,
14,
362,
8,
4551,
495,
9,
267,
1295,
275,
1295,
14,
1814,
25282,
20944,
267,
372,
1295,
339,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
3292,
1135,
358,
199,
199,
318,
1834,
8,
5250,
12,
892,
1943,
29,
797,
12,
12835,
29,
797,
304,
272,
340,
440,
365,
4299,
837,
267,
886,
4299,
342,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
340,
892,
1943,
365,
715,
26,
267,
862,
26,
288,
18884,
836,
14,
409,
480,
1943,
892,
531,
288,
18884,
836,
14,
409,
480,
1943,
2061,
531,
267,
871,
26,
288,
746,
577,
51,
25,
5432,
360,
1222,
1943,
358,
272,
862,
26,
267,
340,
12835,
365,
715,
26,
288,
18884,
836,
14,
409,
480,
7172,
9456,
531,
267,
587,
26,
288,
18884,
836,
14,
409,
480,
7172,
949,
531,
272,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
409,
7172,
358,
272,
900,
14,
4532,
8,
17,
9,
272,
862,
26,
267,
327,
1134,
795,
25,
14292,
2215,
14172,
17,
61,
13524,
370,
577,
51,
25,
14,
647,
267,
327,
16119,
16992,
314,
1834,
2544,
10209,
267,
7953,
275,
2680,
14,
8748,
8,
5250,
12,
2152,
29,
51,
2523,
387,
5136,
9,
267,
18884,
836,
14,
409,
63,
1590,
18,
5250,
8,
5250,
14,
52,
9,
272,
871,
26,
267,
746,
327,
577,
51,
25,
5432,
360,
889,
1569,
358,
199,
199,
318,
485,
409,
63,
30394,
8,
1612,
304,
272,
3850,
1712,
12,
2386,
89,
12,
536,
275,
2883,
339,
3945,
588,
275,
2125,
272,
336,
1259,
221,
275,
298,
9868,
275,
1543,
83,
1154,
78,
2,
450,
536,
339,
340,
3850,
1712,
365,
440,
488,
26,
267,
336,
1556,
6644,
221,
275,
3850,
1712,
14,
1556,
6644,
267,
336,
1556,
637,
221,
275,
3850,
1712,
14,
1556,
637,
267,
21304,
2264,
84,
221,
275,
3850,
1712,
14,
67,
2264,
84,
339,
340,
2386,
89,
365,
440,
488,
26,
267,
299,
1556,
6644,
275,
2386,
89,
14,
1556,
6644,
267,
299,
1556,
637,
275,
2386,
89,
14,
1556,
637,
267,
13171,
2264,
84,
275,
2386,
89,
14,
67,
2264,
84,
398,
327,
4263,
10451,
1006,
3326,
543,
282,
1557,
78,
7,
3382,
1924,
267,
3945,
588,
275,
1557,
78,
1370,
904,
5234,
55,
3298,
2339,
48,
275,
283,
9791,
20238,
5974,
4662,
2079,
298,
7540,
17,
48,
275,
283,
88,
755,
283,
401,
2079,
283,
2944,
3204,
17,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
637,
59,
16,
467,
2079,
283,
2944,
18545,
17,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
6644,
59,
16,
467,
2079,
283,
35,
4424,
52,
17,
48,
275,
10536,
1079,
37,
7,
450,
13171,
2264,
84,
59,
16,
467,
2079,
298,
7540,
18,
48,
275,
283,
89,
755,
283,
401,
2079,
283,
2944,
3204,
18,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
637
] |
[
221,
199,
3,
221,
1898,
334,
35,
9,
10219,
221,
25924,
834,
5653,
437,
24627,
15020,
17985,
7297,
8658,
199,
3,
199,
3,
199,
3,
221,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
221,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
221,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
221,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
221,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
221,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
221,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
221,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
199,
3,
221,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
221,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
199,
504,
7975,
492,
28697,
199,
646,
2680,
199,
646,
900,
199,
646,
6364,
25,
199,
199,
504,
1033,
281,
387,
14,
1208,
492,
664,
63,
6691,
63,
4322,
12,
428,
2523,
387,
5136,
199,
504,
1033,
281,
387,
14,
1208,
14,
1508,
492,
577,
51,
25,
5432,
199,
199,
63,
1375,
275,
283,
609,
281,
387,
7,
199,
199,
318,
485,
362,
63,
2676,
837,
272,
372,
6364,
25,
14,
795,
25,
1547,
1375,
9,
258,
199,
199,
318,
886,
4299,
837,
272,
485,
362,
63,
2676,
342,
199,
199,
318,
365,
4299,
837,
339,
4545,
275,
6364,
25,
14,
795,
25,
63,
4684,
342,
272,
340,
4545,
365,
488,
26,
267,
372,
756,
339,
340,
730,
8,
4684,
9,
315,
334,
513,
16095,
267,
367,
1347,
315,
4545,
26,
288,
340,
485,
1375,
315,
1347,
26,
355,
372,
715,
339,
372,
756,
199,
199,
318,
4002,
837,
272,
340,
365,
4299,
837,
267,
18884,
836,
275,
485,
362,
63,
2676,
342,
267,
18884,
836,
14,
409,
480,
10589,
531,
199,
199,
318,
3145,
63,
8444,
837,
272,
340,
440,
365,
4299,
837,
267,
746,
577,
51,
25,
5432,
360,
1490,
358,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
862,
26,
267,
18884,
836,
14,
409,
480,
1943,
3145,
1006,
531,
267,
372,
18884,
836,
14,
409,
480,
1943,
892,
531,
272,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
271,
276,
1186,
358,
199,
199,
318,
664,
63,
4551,
8,
7988,
304,
272,
340,
440,
365,
4299,
837,
267,
746,
577,
51,
25,
5432,
360,
1490,
358,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
862,
26,
267,
4897,
495,
275,
298,
11963,
446,
908,
2937,
79,
1569,
446,
1913,
9456,
2,
267,
340,
334,
7988,
1137,
21019,
288,
340,
334,
7988,
1137,
283,
1569,
735,
355,
4897,
495,
275,
298,
11963,
446,
908,
286,
18939,
446,
1913,
9456,
446,
2253,
298,
435,
620,
8,
7988,
9,
288,
587,
26,
355,
4897,
495,
275,
298,
11963,
446,
908,
2937,
79,
1569,
446,
1913,
9456,
446,
2253,
1834,
2,
398,
1295,
275,
18884,
836,
14,
362,
8,
4551,
495,
9,
267,
1295,
275,
1295,
14,
1814,
25282,
20944,
267,
372,
1295,
339,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
3292,
1135,
358,
199,
199,
318,
1834,
8,
5250,
12,
892,
1943,
29,
797,
12,
12835,
29,
797,
304,
272,
340,
440,
365,
4299,
837,
267,
886,
4299,
342,
339,
18884,
836,
275,
485,
362,
63,
2676,
342,
339,
340,
892,
1943,
365,
715,
26,
267,
862,
26,
288,
18884,
836,
14,
409,
480,
1943,
892,
531,
288,
18884,
836,
14,
409,
480,
1943,
2061,
531,
267,
871,
26,
288,
746,
577,
51,
25,
5432,
360,
1222,
1943,
358,
272,
862,
26,
267,
340,
12835,
365,
715,
26,
288,
18884,
836,
14,
409,
480,
7172,
9456,
531,
267,
587,
26,
288,
18884,
836,
14,
409,
480,
7172,
949,
531,
272,
871,
26,
267,
746,
577,
51,
25,
5432,
360,
409,
7172,
358,
272,
900,
14,
4532,
8,
17,
9,
272,
862,
26,
267,
327,
1134,
795,
25,
14292,
2215,
14172,
17,
61,
13524,
370,
577,
51,
25,
14,
647,
267,
327,
16119,
16992,
314,
1834,
2544,
10209,
267,
7953,
275,
2680,
14,
8748,
8,
5250,
12,
2152,
29,
51,
2523,
387,
5136,
9,
267,
18884,
836,
14,
409,
63,
1590,
18,
5250,
8,
5250,
14,
52,
9,
272,
871,
26,
267,
746,
327,
577,
51,
25,
5432,
360,
889,
1569,
358,
199,
199,
318,
485,
409,
63,
30394,
8,
1612,
304,
272,
3850,
1712,
12,
2386,
89,
12,
536,
275,
2883,
339,
3945,
588,
275,
2125,
272,
336,
1259,
221,
275,
298,
9868,
275,
1543,
83,
1154,
78,
2,
450,
536,
339,
340,
3850,
1712,
365,
440,
488,
26,
267,
336,
1556,
6644,
221,
275,
3850,
1712,
14,
1556,
6644,
267,
336,
1556,
637,
221,
275,
3850,
1712,
14,
1556,
637,
267,
21304,
2264,
84,
221,
275,
3850,
1712,
14,
67,
2264,
84,
339,
340,
2386,
89,
365,
440,
488,
26,
267,
299,
1556,
6644,
275,
2386,
89,
14,
1556,
6644,
267,
299,
1556,
637,
275,
2386,
89,
14,
1556,
637,
267,
13171,
2264,
84,
275,
2386,
89,
14,
67,
2264,
84,
398,
327,
4263,
10451,
1006,
3326,
543,
282,
1557,
78,
7,
3382,
1924,
267,
3945,
588,
275,
1557,
78,
1370,
904,
5234,
55,
3298,
2339,
48,
275,
283,
9791,
20238,
5974,
4662,
2079,
298,
7540,
17,
48,
275,
283,
88,
755,
283,
401,
2079,
283,
2944,
3204,
17,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
637,
59,
16,
467,
2079,
283,
2944,
18545,
17,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
6644,
59,
16,
467,
2079,
283,
35,
4424,
52,
17,
48,
275,
10536,
1079,
37,
7,
450,
13171,
2264,
84,
59,
16,
467,
2079,
298,
7540,
18,
48,
275,
283,
89,
755,
283,
401,
2079,
283,
2944,
3204,
18,
48,
275,
10536,
1079,
37,
7,
450,
299,
1556,
637,
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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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
dlazz/ansible
|
lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py
|
13
|
14169
|
#!/usr/bin/python
# Copyright: Ansible Project
# 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': 'community'}
DOCUMENTATION = '''
module: ec2_vpc_peer
short_description: create, delete, accept, and reject VPC peering connections between two VPCs.
description:
- Read the AWS documentation for VPC Peering Connections
U(https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-peering.html).
version_added: "2.2"
options:
vpc_id:
description:
- VPC id of the requesting VPC.
required: false
peering_id:
description:
- Peering connection id.
required: false
peer_region:
description:
- Region of the accepting VPC.
required: false
version_added: '2.5'
peer_vpc_id:
description:
- VPC id of the accepting VPC.
required: false
peer_owner_id:
description:
- The AWS account number for cross account peering.
required: false
tags:
description:
- Dictionary of tags to look for and apply when creating a Peering Connection.
required: false
state:
description:
- Create, delete, accept, reject a peering connection.
required: false
default: present
choices: ['present', 'absent', 'accept', 'reject']
author: Mike Mochan (@mmochan)
extends_documentation_fragment:
- aws
- ec2
requirements: [ botocore, boto3, json ]
'''
EXAMPLES = '''
# Complete example to create and accept a local peering connection.
- name: Create local account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-87654321
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Accept local VPC peering request
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
state: accept
register: action_peer
# Complete example to delete a local peering connection.
- name: Create local account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-87654321
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: delete a local VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
state: absent
register: vpc_peer
# Complete example to create and accept a cross account peering connection.
- name: Create cross account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-12345678
peer_owner_id: 123456789102
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Accept peering connection from remote account
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
profile: bot03_profile_for_cross_account
state: accept
register: vpc_peer
# Complete example to create and accept an intra-region peering connection.
- name: Create intra-region VPC peering Connection
ec2_vpc_peer:
region: us-east-1
vpc_id: vpc-12345678
peer_vpc_id: vpc-87654321
peer_region: us-west-2
state: present
tags:
Name: Peering connection for us-east-1 VPC to us-west-2 VPC
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Accept peering connection from peer region
ec2_vpc_peer:
region: us-west-2
peering_id: "{{ vpc_peer.peering_id }}"
state: accept
register: vpc_peer
# Complete example to create and reject a local peering connection.
- name: Create local account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-87654321
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Reject a local VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
state: reject
# Complete example to create and accept a cross account peering connection.
- name: Create cross account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-12345678
peer_owner_id: 123456789102
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Accept a cross account VPC peering connection request
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
profile: bot03_profile_for_cross_account
state: accept
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
# Complete example to create and reject a cross account peering connection.
- name: Create cross account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
vpc_id: vpc-12345678
peer_vpc_id: vpc-12345678
peer_owner_id: 123456789102
state: present
tags:
Name: Peering connection for VPC 21 to VPC 22
CostCode: CC1234
Project: phoenix
register: vpc_peer
- name: Reject a cross account VPC peering Connection
ec2_vpc_peer:
region: ap-southeast-2
peering_id: "{{ vpc_peer.peering_id }}"
profile: bot03_profile_for_cross_account
state: reject
'''
RETURN = '''
task:
description: The result of the create, accept, reject or delete action.
returned: success
type: dict
'''
try:
import botocore
except ImportError:
pass # caught by imported HAS_BOTO3
import distutils.version
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info, HAS_BOTO3
from ansible.module_utils.aws.core import is_boto3_error_code
def tags_changed(pcx_id, client, module):
changed = False
tags = dict()
if module.params.get('tags'):
tags = module.params.get('tags')
pcx = find_pcx_by_id(pcx_id, client, module)
if pcx['VpcPeeringConnections']:
pcx_values = [t.values() for t in pcx['VpcPeeringConnections'][0]['Tags']]
pcx_tags = [item for sublist in pcx_values for item in sublist]
tag_values = [[key, str(value)] for key, value in tags.items()]
tags = [item for sublist in tag_values for item in sublist]
if sorted(pcx_tags) == sorted(tags):
changed = False
elif tags:
delete_tags(pcx_id, client, module)
create_tags(pcx_id, client, module)
changed = True
return changed
def describe_peering_connections(params, client):
result = client.describe_vpc_peering_connections(
Filters=[
{'Name': 'requester-vpc-info.vpc-id', 'Values': [params['VpcId']]},
{'Name': 'accepter-vpc-info.vpc-id', 'Values': [params['PeerVpcId']]}
]
)
if result['VpcPeeringConnections'] == []:
result = client.describe_vpc_peering_connections(
Filters=[
{'Name': 'requester-vpc-info.vpc-id', 'Values': [params['PeerVpcId']]},
{'Name': 'accepter-vpc-info.vpc-id', 'Values': [params['VpcId']]}
]
)
return result
def is_active(peering_conn):
return peering_conn['Status']['Code'] == 'active'
def is_pending(peering_conn):
return peering_conn['Status']['Code'] == 'pending-acceptance'
def create_peer_connection(client, module):
changed = False
params = dict()
params['VpcId'] = module.params.get('vpc_id')
params['PeerVpcId'] = module.params.get('peer_vpc_id')
if module.params.get('peer_region'):
if distutils.version.StrictVersion(botocore.__version__) < distutils.version.StrictVersion('1.8.6'):
module.fail_json(msg="specifying peer_region parameter requires botocore >= 1.8.6")
params['PeerRegion'] = module.params.get('peer_region')
if module.params.get('peer_owner_id'):
params['PeerOwnerId'] = str(module.params.get('peer_owner_id'))
peering_conns = describe_peering_connections(params, client)
for peering_conn in peering_conns['VpcPeeringConnections']:
pcx_id = peering_conn['VpcPeeringConnectionId']
if tags_changed(pcx_id, client, module):
changed = True
if is_active(peering_conn):
return (changed, peering_conn['VpcPeeringConnectionId'])
if is_pending(peering_conn):
return (changed, peering_conn['VpcPeeringConnectionId'])
try:
peering_conn = client.create_vpc_peering_connection(**params)
pcx_id = peering_conn['VpcPeeringConnection']['VpcPeeringConnectionId']
if module.params.get('tags'):
create_tags(pcx_id, client, module)
changed = True
return (changed, peering_conn['VpcPeeringConnection']['VpcPeeringConnectionId'])
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
def remove_peer_connection(client, module):
pcx_id = module.params.get('peering_id')
if not pcx_id:
params = dict()
params['VpcId'] = module.params.get('vpc_id')
params['PeerVpcId'] = module.params.get('peer_vpc_id')
params['PeerRegion'] = module.params.get('peer_region')
if module.params.get('peer_owner_id'):
params['PeerOwnerId'] = str(module.params.get('peer_owner_id'))
peering_conns = describe_peering_connections(params, client)
if not peering_conns:
module.exit_json(changed=False)
else:
pcx_id = peering_conns['VpcPeeringConnections'][0]['VpcPeeringConnectionId']
try:
params = dict()
params['VpcPeeringConnectionId'] = pcx_id
client.delete_vpc_peering_connection(**params)
module.exit_json(changed=True)
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
def peer_status(client, module):
params = dict()
params['VpcPeeringConnectionIds'] = [module.params.get('peering_id')]
try:
vpc_peering_connection = client.describe_vpc_peering_connections(**params)
return vpc_peering_connection['VpcPeeringConnections'][0]['Status']['Code']
except is_boto3_error_code('InvalidVpcPeeringConnectionId.Malformed') as e: # pylint: disable=duplicate-except
module.fail_json(msg='Malformed connection ID: {0}'.format(e), traceback=traceback.format_exc())
except botocore.exceptions.ClientError as e: # pylint: disable=duplicate-except
module.fail_json(msg='Error while describing peering connection by peering_id: {0}'.format(e), traceback=traceback.format_exc())
def accept_reject(state, client, module):
changed = False
params = dict()
params['VpcPeeringConnectionId'] = module.params.get('peering_id')
if peer_status(client, module) != 'active':
try:
if state == 'accept':
client.accept_vpc_peering_connection(**params)
else:
client.reject_vpc_peering_connection(**params)
if module.params.get('tags'):
create_tags(params['VpcPeeringConnectionId'], client, module)
changed = True
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
if tags_changed(params['VpcPeeringConnectionId'], client, module):
changed = True
return changed, params['VpcPeeringConnectionId']
def load_tags(module):
tags = []
if module.params.get('tags'):
for name, value in module.params.get('tags').items():
tags.append({'Key': name, 'Value': str(value)})
return tags
def create_tags(pcx_id, client, module):
try:
delete_tags(pcx_id, client, module)
client.create_tags(Resources=[pcx_id], Tags=load_tags(module))
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
def delete_tags(pcx_id, client, module):
try:
client.delete_tags(Resources=[pcx_id])
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
def find_pcx_by_id(pcx_id, client, module):
try:
return client.describe_vpc_peering_connections(VpcPeeringConnectionIds=[pcx_id])
except botocore.exceptions.ClientError as e:
module.fail_json(msg=str(e))
def main():
argument_spec = ec2_argument_spec()
argument_spec.update(
dict(
vpc_id=dict(),
peer_vpc_id=dict(),
peer_region=dict(),
peering_id=dict(),
peer_owner_id=dict(),
tags=dict(required=False, type='dict'),
profile=dict(),
state=dict(default='present', choices=['present', 'absent', 'accept', 'reject'])
)
)
module = AnsibleModule(argument_spec=argument_spec)
if not HAS_BOTO3:
module.fail_json(msg='json, botocore and boto3 are required.')
state = module.params.get('state')
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
client = boto3_conn(module, conn_type='client', resource='ec2',
region=region, endpoint=ec2_url, **aws_connect_kwargs)
except botocore.exceptions.NoCredentialsError as e:
module.fail_json(msg="Can't authorize connection - " + str(e))
if state == 'present':
(changed, results) = create_peer_connection(client, module)
module.exit_json(changed=changed, peering_id=results)
elif state == 'absent':
remove_peer_connection(client, module)
else:
(changed, results) = accept_reject(state, client, module)
module.exit_json(changed=changed, peering_id=results)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
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,
9387,
936,
421,
199,
8948,
275,
1449,
199,
578,
26,
7062,
18,
63,
11742,
63,
7866,
199,
3612,
63,
1802,
26,
1218,
12,
3145,
12,
4729,
12,
436,
17100,
19209,
9104,
316,
6947,
3382,
2877,
19209,
83,
14,
199,
1802,
26,
523,
446,
5574,
314,
10168,
3794,
367,
19209,
11379,
15663,
8113,
83,
272,
738,
8,
2859,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
54,
4222,
15,
7410,
15,
1899,
4324,
271,
15,
11742,
13,
7866,
316,
14,
1360,
680,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
1419,
26,
523,
12830,
63,
344,
26,
272,
1369,
26,
489,
446,
19209,
1305,
402,
314,
23502,
19209,
14,
272,
1415,
26,
3055,
523,
9104,
316,
63,
344,
26,
272,
1369,
26,
489,
446,
11379,
15663,
1950,
1305,
14,
272,
1415,
26,
3055,
523,
9104,
63,
4551,
26,
272,
1369,
26,
489,
446,
22240,
402,
314,
32163,
19209,
14,
272,
1415,
26,
3055,
272,
1015,
63,
3270,
26,
283,
18,
14,
21,
7,
523,
9104,
63,
11742,
63,
344,
26,
272,
1369,
26,
489,
446,
19209,
1305,
402,
314,
32163,
19209,
14,
272,
1415,
26,
3055,
523,
9104,
63,
4597,
63,
344,
26,
272,
1369,
26,
489,
446,
710,
10168,
2933,
1329,
367,
8059,
2933,
9104,
316,
14,
272,
1415,
26,
3055,
523,
3762,
26,
272,
1369,
26,
489,
446,
11932,
402,
3762,
370,
3648,
367,
436,
4838,
1380,
6425,
282,
11379,
15663,
8113,
14,
272,
1415,
26,
3055,
523,
1174,
26,
272,
1369,
26,
489,
446,
2790,
12,
3145,
12,
4729,
12,
17100,
282,
9104,
316,
1950,
14,
272,
1415,
26,
3055,
272,
849,
26,
3451,
272,
3415,
26,
788,
1881,
297,
283,
5575,
297,
283,
5694,
297,
283,
16857,
418,
199,
2502,
26,
603,
7455,
3930,
11984,
8593,
77,
573,
11984,
9,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
7538,
26,
359,
21199,
12,
6055,
19,
12,
2022,
1622,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
28393,
2893,
370,
1218,
436,
4729,
282,
2257,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
2257,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
15506,
2257,
19209,
9104,
316,
1056,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
1174,
26,
4729,
523,
2274,
26,
1595,
63,
7866,
199,
199,
3,
28393,
2893,
370,
3145,
282,
2257,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
2257,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
3145,
282,
2257,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
1174,
26,
9552,
523,
2274,
26,
12830,
63,
7866,
819,
327,
28393,
2893,
370,
1218,
436,
4729,
282,
8059,
2933,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
8059,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
4597,
63,
344,
26,
32695,
7759,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
15506,
9104,
316,
1950,
687,
3982,
2933,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
4690,
26,
5888,
1644,
63,
2913,
63,
509,
63,
7925,
63,
2048,
272,
1174,
26,
4729,
523,
2274,
26,
12830,
63,
7866,
199,
199,
3,
28393,
2893,
370,
1218,
436,
4729,
376,
1109,
345,
13,
4551,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
1109,
345,
13,
4551,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
9104,
63,
4551,
26,
2739,
13,
19082,
13,
18,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
2739,
13,
14346,
13,
17,
19209,
370,
2739,
13,
19082,
13,
18,
19209,
489,
24681,
3034,
26,
17586,
4321,
489
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
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,
9387,
936,
421,
199,
8948,
275,
1449,
199,
578,
26,
7062,
18,
63,
11742,
63,
7866,
199,
3612,
63,
1802,
26,
1218,
12,
3145,
12,
4729,
12,
436,
17100,
19209,
9104,
316,
6947,
3382,
2877,
19209,
83,
14,
199,
1802,
26,
523,
446,
5574,
314,
10168,
3794,
367,
19209,
11379,
15663,
8113,
83,
272,
738,
8,
2859,
921,
4757,
14,
7231,
14,
15144,
14,
957,
15,
33,
8872,
54,
4222,
15,
7410,
15,
1899,
4324,
271,
15,
11742,
13,
7866,
316,
14,
1360,
680,
199,
1023,
63,
3270,
26,
298,
18,
14,
18,
2,
199,
1419,
26,
523,
12830,
63,
344,
26,
272,
1369,
26,
489,
446,
19209,
1305,
402,
314,
23502,
19209,
14,
272,
1415,
26,
3055,
523,
9104,
316,
63,
344,
26,
272,
1369,
26,
489,
446,
11379,
15663,
1950,
1305,
14,
272,
1415,
26,
3055,
523,
9104,
63,
4551,
26,
272,
1369,
26,
489,
446,
22240,
402,
314,
32163,
19209,
14,
272,
1415,
26,
3055,
272,
1015,
63,
3270,
26,
283,
18,
14,
21,
7,
523,
9104,
63,
11742,
63,
344,
26,
272,
1369,
26,
489,
446,
19209,
1305,
402,
314,
32163,
19209,
14,
272,
1415,
26,
3055,
523,
9104,
63,
4597,
63,
344,
26,
272,
1369,
26,
489,
446,
710,
10168,
2933,
1329,
367,
8059,
2933,
9104,
316,
14,
272,
1415,
26,
3055,
523,
3762,
26,
272,
1369,
26,
489,
446,
11932,
402,
3762,
370,
3648,
367,
436,
4838,
1380,
6425,
282,
11379,
15663,
8113,
14,
272,
1415,
26,
3055,
523,
1174,
26,
272,
1369,
26,
489,
446,
2790,
12,
3145,
12,
4729,
12,
17100,
282,
9104,
316,
1950,
14,
272,
1415,
26,
3055,
272,
849,
26,
3451,
272,
3415,
26,
788,
1881,
297,
283,
5575,
297,
283,
5694,
297,
283,
16857,
418,
199,
2502,
26,
603,
7455,
3930,
11984,
8593,
77,
573,
11984,
9,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
7538,
26,
359,
21199,
12,
6055,
19,
12,
2022,
1622,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
28393,
2893,
370,
1218,
436,
4729,
282,
2257,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
2257,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
15506,
2257,
19209,
9104,
316,
1056,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
1174,
26,
4729,
523,
2274,
26,
1595,
63,
7866,
199,
199,
3,
28393,
2893,
370,
3145,
282,
2257,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
2257,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
3145,
282,
2257,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
1174,
26,
9552,
523,
2274,
26,
12830,
63,
7866,
819,
327,
28393,
2893,
370,
1218,
436,
4729,
282,
8059,
2933,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
8059,
2933,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
4597,
63,
344,
26,
32695,
7759,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
19209,
7829,
370,
19209,
6928,
489,
24681,
3034,
26,
17586,
4321,
489,
7290,
26,
299,
526,
287,
1148,
523,
2274,
26,
12830,
63,
7866,
199,
199,
13,
536,
26,
15506,
9104,
316,
1950,
687,
3982,
2933,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2771,
13,
22607,
14346,
13,
18,
272,
9104,
316,
63,
344,
26,
7370,
12830,
63,
7866,
14,
7866,
316,
63,
344,
7820,
272,
4690,
26,
5888,
1644,
63,
2913,
63,
509,
63,
7925,
63,
2048,
272,
1174,
26,
4729,
523,
2274,
26,
12830,
63,
7866,
199,
199,
3,
28393,
2893,
370,
1218,
436,
4729,
376,
1109,
345,
13,
4551,
9104,
316,
1950,
14,
199,
13,
536,
26,
2790,
1109,
345,
13,
4551,
19209,
9104,
316,
8113,
523,
7062,
18,
63,
11742,
63,
7866,
26,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
12830,
63,
344,
26,
12830,
13,
19542,
272,
9104,
63,
11742,
63,
344,
26,
12830,
13,
1555,
11157,
12638,
272,
9104,
63,
4551,
26,
2739,
13,
19082,
13,
18,
272,
1174,
26,
3451,
272,
3762,
26,
489,
2812,
26,
11379,
15663,
1950,
367,
2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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
] |
miguelparaiso/PracticaOdoo
|
addons/auth_oauth/__openerp__.py
|
300
|
1654
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'OAuth2 Authentication',
'version': '1.0',
'category': 'Tools',
'description': """
Allow users to login through OAuth2 Provider.
=============================================
""",
'author': 'OpenERP s.a.',
'maintainer': 'OpenERP s.a.',
'website': 'https://www.odoo.com',
'depends': ['base', 'web', 'base_setup', 'auth_signup'],
'data': [
'res_users.xml',
'auth_oauth_data.xml',
'auth_oauth_data.yml',
'auth_oauth_view.xml',
'security/ir.model.access.csv',
'res_config.xml',
'views/auth_oauth_login.xml',
],
'installable': True,
'auto_install': False,
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
7409,
7653,
308,
14,
65,
14,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
421,
199,
91,
272,
283,
354,
356,
283,
12906,
18,
15995,
297,
272,
283,
1023,
356,
283,
17,
14,
16,
297,
272,
283,
3710,
356,
283,
11654,
297,
272,
283,
1802,
356,
408,
199,
7852,
4390,
370,
4676,
4012,
11715,
18,
18489,
14,
199,
2486,
9152,
199,
7208,
272,
283,
2502,
356,
283,
25347,
308,
14,
65,
3130,
272,
283,
26665,
356,
283,
25347,
308,
14,
65,
3130,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
297,
272,
283,
8912,
356,
788,
1095,
297,
283,
2520,
297,
283,
1095,
63,
2758,
297,
283,
1178,
63,
19799,
995,
272,
283,
576,
356,
359,
267,
283,
470,
63,
3707,
14,
1652,
297,
267,
283,
1178,
63,
6126,
63,
576,
14,
1652,
297,
267,
283,
1178,
63,
6126,
63,
576,
14,
11714,
297,
267,
283,
1178,
63,
6126,
63,
1345,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
470,
63,
888,
14,
1652,
297,
267,
283,
4196,
15,
1178,
63,
6126,
63,
2886,
14,
1652,
297,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
7409,
7653,
308,
14,
65,
14,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
421,
199,
91,
272,
283,
354,
356,
283,
12906,
18,
15995,
297,
272,
283,
1023,
356,
283,
17,
14,
16,
297,
272,
283,
3710,
356,
283,
11654,
297,
272,
283,
1802,
356,
408,
199,
7852,
4390,
370,
4676,
4012,
11715,
18,
18489,
14,
199,
2486,
9152,
199,
7208,
272,
283,
2502,
356,
283,
25347,
308,
14,
65,
3130,
272,
283,
26665,
356,
283,
25347,
308,
14,
65,
3130,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
297,
272,
283,
8912,
356,
788,
1095,
297,
283,
2520,
297,
283,
1095,
63,
2758,
297,
283,
1178,
63,
19799,
995,
272,
283,
576,
356,
359,
267,
283,
470,
63,
3707,
14,
1652,
297,
267,
283,
1178,
63,
6126,
63,
576,
14,
1652,
297,
267,
283,
1178,
63,
6126,
63,
576,
14,
11714,
297,
267,
283,
1178,
63,
6126,
63,
1345,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
470,
63,
888,
14,
1652,
297,
267,
283,
4196,
15,
1178,
63,
6126,
63,
2886,
14,
1652,
297,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
PixNDom/android_kernel_lenovo_Tab2A710F
|
tools/perf/util/setup.py
|
2079
|
1438
|
#!/usr/bin/python2
from distutils.core import setup, Extension
from os import getenv
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.install_lib import install_lib as _install_lib
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
self.build_lib = build_lib
self.build_temp = build_tmp
class install_lib(_install_lib):
def finalize_options(self):
_install_lib.finalize_options(self)
self.build_dir = build_lib
cflags = ['-fno-strict-aliasing', '-Wno-write-strings']
cflags += getenv('CFLAGS', '').split()
build_lib = getenv('PYTHON_EXTBUILD_LIB')
build_tmp = getenv('PYTHON_EXTBUILD_TMP')
libtraceevent = getenv('LIBTRACEEVENT')
liblk = getenv('LIBLK')
ext_sources = [f.strip() for f in file('util/python-ext-sources')
if len(f.strip()) > 0 and f[0] != '#']
perf = Extension('perf',
sources = ext_sources,
include_dirs = ['util/include'],
extra_compile_args = cflags,
extra_objects = [libtraceevent, liblk],
)
setup(name='perf',
version='0.1',
description='Interface with the Linux profiling infrastructure',
author='Arnaldo Carvalho de Melo',
author_email='acme@redhat.com',
license='GPLv2',
url='http://perf.wiki.kernel.org',
ext_modules=[perf],
cmdclass={'build_ext': build_ext, 'install_lib': install_lib})
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
18,
199,
199,
504,
7065,
14,
1018,
492,
3272,
12,
13282,
199,
504,
747,
492,
29626,
199,
199,
504,
7065,
14,
1531,
14,
1506,
63,
832,
257,
492,
1900,
63,
832,
257,
465,
485,
1506,
63,
832,
199,
504,
7065,
14,
1531,
14,
3174,
63,
773,
492,
3907,
63,
773,
465,
485,
3174,
63,
773,
199,
199,
533,
1900,
63,
832,
1547,
1506,
63,
832,
304,
272,
347,
17284,
63,
1419,
8,
277,
304,
267,
485,
1506,
63,
832,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
1506,
63,
773,
221,
275,
1900,
63,
773,
267,
291,
14,
1506,
63,
808,
275,
1900,
63,
2791,
199,
199,
533,
3907,
63,
773,
1547,
3174,
63,
773,
304,
272,
347,
17284,
63,
1419,
8,
277,
304,
267,
485,
3174,
63,
773,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
1506,
63,
694,
275,
1900,
63,
773,
421,
199,
14002,
275,
11573,
70,
889,
13,
4768,
13,
3620,
316,
297,
2475,
55,
889,
13,
952,
13,
5465,
418,
199,
14002,
847,
29626,
360,
14804,
297,
12548,
1294,
342,
199,
199,
1506,
63,
773,
275,
29626,
360,
11720,
63,
2472,
8248,
63,
5617,
358,
199,
1506,
63,
2791,
275,
29626,
360,
11720,
63,
2472,
8248,
63,
17983,
358,
199,
773,
3446,
1430,
275,
29626,
360,
5617,
20112,
8193,
358,
199,
773,
23333,
275,
29626,
360,
5617,
44,
43,
358,
199,
199,
832,
63,
4553,
275,
359,
70,
14,
1913,
342,
367,
289,
315,
570,
360,
1974,
15,
1548,
13,
832,
13,
4553,
358,
1585,
198,
692,
822,
8,
70,
14,
1913,
1012,
690,
378,
436,
289,
59,
16,
61,
1137,
3943,
418,
199,
199,
9452,
275,
13282,
360,
9452,
297,
29294,
5274,
275,
1599,
63,
4553,
12,
29294,
2387,
63,
3220,
275,
788,
1974,
15,
2613,
995,
29294,
2402,
63,
2014,
63,
589,
275,
13426,
12,
29294,
2402,
63,
1462,
275,
359,
773,
3446,
1430,
12,
1973,
23333,
467,
326,
776,
199,
199,
2758,
8,
354,
534,
9452,
297,
489,
1015,
534,
16,
14,
17,
297,
489,
1369,
534,
4267,
543,
314,
10130,
30238,
28890,
6976,
297,
489,
4132,
534,
20498,
279,
1117,
14243,
637,
526,
477,
3194,
320,
297,
489,
4132,
63,
2123,
534,
18107,
32,
17164,
14,
957,
297,
489,
4190,
534,
28863,
18,
297,
489,
1166,
534,
1014,
921,
9452,
14,
6797,
14,
4989,
14,
1308,
297,
489,
1599,
63,
3112,
1524,
9452,
467,
489,
2088,
533,
3713,
1506,
63,
832,
356,
1900,
63,
832,
12,
283,
3174,
63,
773,
356,
3907,
63,
773,
1552,
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
] |
[
2647,
15,
1393,
15,
1548,
18,
199,
199,
504,
7065,
14,
1018,
492,
3272,
12,
13282,
199,
504,
747,
492,
29626,
199,
199,
504,
7065,
14,
1531,
14,
1506,
63,
832,
257,
492,
1900,
63,
832,
257,
465,
485,
1506,
63,
832,
199,
504,
7065,
14,
1531,
14,
3174,
63,
773,
492,
3907,
63,
773,
465,
485,
3174,
63,
773,
199,
199,
533,
1900,
63,
832,
1547,
1506,
63,
832,
304,
272,
347,
17284,
63,
1419,
8,
277,
304,
267,
485,
1506,
63,
832,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
1506,
63,
773,
221,
275,
1900,
63,
773,
267,
291,
14,
1506,
63,
808,
275,
1900,
63,
2791,
199,
199,
533,
3907,
63,
773,
1547,
3174,
63,
773,
304,
272,
347,
17284,
63,
1419,
8,
277,
304,
267,
485,
3174,
63,
773,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
1506,
63,
694,
275,
1900,
63,
773,
421,
199,
14002,
275,
11573,
70,
889,
13,
4768,
13,
3620,
316,
297,
2475,
55,
889,
13,
952,
13,
5465,
418,
199,
14002,
847,
29626,
360,
14804,
297,
12548,
1294,
342,
199,
199,
1506,
63,
773,
275,
29626,
360,
11720,
63,
2472,
8248,
63,
5617,
358,
199,
1506,
63,
2791,
275,
29626,
360,
11720,
63,
2472,
8248,
63,
17983,
358,
199,
773,
3446,
1430,
275,
29626,
360,
5617,
20112,
8193,
358,
199,
773,
23333,
275,
29626,
360,
5617,
44,
43,
358,
199,
199,
832,
63,
4553,
275,
359,
70,
14,
1913,
342,
367,
289,
315,
570,
360,
1974,
15,
1548,
13,
832,
13,
4553,
358,
1585,
198,
692,
822,
8,
70,
14,
1913,
1012,
690,
378,
436,
289,
59,
16,
61,
1137,
3943,
418,
199,
199,
9452,
275,
13282,
360,
9452,
297,
29294,
5274,
275,
1599,
63,
4553,
12,
29294,
2387,
63,
3220,
275,
788,
1974,
15,
2613,
995,
29294,
2402,
63,
2014,
63,
589,
275,
13426,
12,
29294,
2402,
63,
1462,
275,
359,
773,
3446,
1430,
12,
1973,
23333,
467,
326,
776,
199,
199,
2758,
8,
354,
534,
9452,
297,
489,
1015,
534,
16,
14,
17,
297,
489,
1369,
534,
4267,
543,
314,
10130,
30238,
28890,
6976,
297,
489,
4132,
534,
20498,
279,
1117,
14243,
637,
526,
477,
3194,
320,
297,
489,
4132,
63,
2123,
534,
18107,
32,
17164,
14,
957,
297,
489,
4190,
534,
28863,
18,
297,
489,
1166,
534,
1014,
921,
9452,
14,
6797,
14,
4989,
14,
1308,
297,
489,
1599,
63,
3112,
1524,
9452,
467,
489,
2088,
533,
3713,
1506,
63,
832,
356,
1900,
63,
832,
12,
283,
3174,
63,
773,
356,
3907,
63,
773,
1552,
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,
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,
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